1333 lines
60 KiB
HTML
1333 lines
60 KiB
HTML
<!doctype html>
|
||
<html xmlns:th="http://www.thymeleaf.org">
|
||
<head>
|
||
<base th:href="${#request.getContextPath() + '/'}">
|
||
<meta charset="utf-8">
|
||
<meta name="renderer" content="webkit">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||
<style>
|
||
.layui-form-select{
|
||
min-width:200px!important;
|
||
}
|
||
.layui-select-title{
|
||
min-width:200px!important;
|
||
}
|
||
.layui-select-title input{
|
||
min-width:200px!important;
|
||
}
|
||
#queryTab{
|
||
background-color: #FFFFFF;
|
||
}
|
||
.tabLevel1 > .layui-form-checkbox span {
|
||
background-color: #db4343;
|
||
}
|
||
.tabLevel2 > .layui-form-checkbox span {
|
||
background-color: #F48208;
|
||
}
|
||
.tabLevel3 > .layui-form-checkbox span {
|
||
background-color: #F4CF08;
|
||
}
|
||
.tabLevel4 > .layui-form-checkbox span {
|
||
background-color: #08A7F4;
|
||
}
|
||
.tabLevel5 > .layui-form-checkbox span {
|
||
background-color: #08F422;
|
||
}
|
||
.tabLevelGroup > .layui-form-checkbox:nth-of-type(1) span {
|
||
background-color: #db4343;
|
||
}
|
||
.tabLevelGroup > .layui-form-checkbox:nth-of-type(2) span {
|
||
background-color: #F48208;
|
||
}
|
||
.tabLevelGroup > .layui-form-checkbox:nth-of-type(3) span {
|
||
background-color: #F4CF08;
|
||
}
|
||
.tabLevelGroup > .layui-form-checkbox:nth-of-type(4) span {
|
||
background-color: #08A7F4;
|
||
}
|
||
.tabLevelGroup > .layui-form-checkbox:nth-of-type(5) span {
|
||
background-color: #08F422;
|
||
}
|
||
.layui-form-checkbox {
|
||
line-height: 20px !important;
|
||
padding-right: 20px !important;
|
||
height: 20px !important;
|
||
}
|
||
.layui-form-checkbox i{
|
||
height: 18px !important;
|
||
width: 20px !important;
|
||
}
|
||
.layui-form-checkbox span{
|
||
font-size: 11px !important;
|
||
padding: 0 2px !important;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||
<div class="layui-row layui-col-space10">
|
||
<div class="layui-col-xs2">
|
||
<div class="layui-card" id="queryTab">
|
||
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||
<div class="layui-form-item layui-form-text">
|
||
<label class="layui-form-label">人员所在街道</label>
|
||
<input type="hidden" id="creatorArea1" name="creatorArea1" class="layui-input" value="" maxlength="36">
|
||
<div class="layui-input-block layui-form layui-text" id="streetNameSelectTemplateBox" lay-filter="streetNameSelectTemplateBox"></div>
|
||
<script id="streetNameSelectTemplate" type="text/html">
|
||
<select id="street" name="street" lay-filter="street" lay-verify="required" lay-search>
|
||
<option value="">请选择街道</option>
|
||
{{# for(var i = 0, item; item = d.list[i++];) { }}
|
||
{{# if(d.jiedao == item.name){ }}
|
||
<option selected value="{{item.id}}">{{item.name}}</option>
|
||
{{# } else { }}
|
||
<option value="{{item.id}}">{{item.name}}</option>
|
||
{{# } }}
|
||
{{# } }}
|
||
</select>
|
||
</script>
|
||
</div>
|
||
<div class="layui-form-item layui-form-text">
|
||
<label class="layui-form-label">人员所在社区</label>
|
||
<input type="hidden" id="creatorArea2" name="creatorArea2" class="layui-input" value="" maxlength="36">
|
||
<div class="layui-input-block layui-form layui-text" id="communityNameSelectTemplateBox" lay-filter="communityNameSelectTemplateBox"></div>
|
||
<script id="communityNameSelectTemplate" type="text/html">
|
||
<select id="community" name="community" lay-filter="community" lay-verify="required" lay-search>
|
||
<option value="">请选择社区</option>
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
<option value="{{item.communityId}}">{{item.communityName}}</option>
|
||
{{# } }}
|
||
</select>
|
||
</script>
|
||
</div>
|
||
<div class="layui-form-item layui-form-text">
|
||
<label class="layui-form-label">人员所在小区</label>
|
||
<div class="layui-input-block layui-form layui-text" id="residentialNameSelectTemplateBox" lay-filter="residentialNameSelectTemplateBox"></div>
|
||
<script id="residentialNameSelectTemplate" type="text/html">
|
||
<select id="residentialId" name="residentialId" lay-filter="residentialId" lay-verify="required" lay-search>
|
||
<option value="">请选择小区</option>
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
<option value="{{item.residentialId}}">{{item.name}}</option>
|
||
{{# } }}
|
||
</select>
|
||
</script>
|
||
</div>
|
||
<div class="layui-form-item layui-form-text">
|
||
<label class="layui-form-label">人员所在楼/排</label>
|
||
<div class="layui-input-block layui-form layui-text" id="buildingNameSelectTemplateBox" lay-filter="buildingNameSelectTemplateBox"></div>
|
||
<script id="buildingNameSelectTemplate" type="text/html">
|
||
<select id="buildingId" name="buildingId" lay-filter="buildingId" lay-verify="required" lay-search>
|
||
<option value="">请选择楼/排</option>
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
<option value="{{item.buildingId}}">{{item.name}}</option>
|
||
{{# } }}
|
||
</select>
|
||
</script>
|
||
</div>
|
||
<div class="layui-form-item layui-form-text">
|
||
<label class="layui-form-label">人员所在房屋</label>
|
||
<div class="layui-input-block layui-form layui-text" id="houseNameSelectTemplateBox" lay-filter="houseNameSelectTemplateBox"></div>
|
||
<script id="houseNameSelectTemplate" type="text/html">
|
||
<select id="houseId" name="houseId" lay-filter="houseId" lay-verify="required" lay-search>
|
||
<option value="">请选择房屋</option>
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
<option value="{{item.houseId}}">{{item.affiliationUnit}} / {{item.affiliationFloors}} / {{item.houseNum}}</option>
|
||
{{# } }}
|
||
</select>
|
||
</script>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<div class="layui-col-xs7">
|
||
<div class="layui-card">
|
||
<div class="layui-card-body">
|
||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||
<div class="layui-inline">
|
||
<input type="text" id="name" class="layui-input search-item" placeholder="请输入姓名">
|
||
</div>
|
||
<div class="layui-inline layui-form search-item" id="idcardTypeSelectTemplateBox" lay-filter="idcardTypeSelectTemplateBox"></div>
|
||
<div class="layui-inline">
|
||
<input type="text" id="idcard" class="layui-input search-item" placeholder="请输入证件号">
|
||
</div>
|
||
<div class="layui-inline layui-form search-item" >
|
||
<select id="type" name="type">
|
||
<option value="">请选择人员类型</option>
|
||
<option value="户籍人口">户籍人口</option>
|
||
<option value="常住人口">常住人口</option>
|
||
<option value="流动人口">流动人口</option>
|
||
</select>
|
||
</div>
|
||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||
<i class="fa fa-lg fa-search"></i> 搜索
|
||
</button>
|
||
<button type="button" id="clear-search" class="layui-btn layui-btn-sm">
|
||
<i class="fa fa-lg fa-close"></i> 清空条件
|
||
</button>
|
||
</div>
|
||
<div class="layui-input-block layui-form tabLevelGroup" style="margin-left: 0px;margin-top: -2px;min-height: 24px;">
|
||
<input type="checkbox" name="tabLevelGroup" value="#db4343" title="特别关注">
|
||
<input type="checkbox" name="tabLevelGroup" value="#F48208" title="及时关注">
|
||
<input type="checkbox" name="tabLevelGroup" value="#F4CF08" title="一般关注">
|
||
<input type="checkbox" name="tabLevelGroup" value="#08A7F4" title="重点关注">
|
||
<input type="checkbox" name="tabLevelGroup" value="#08F422" title="日常关注">
|
||
</div>
|
||
<div class="layui-form-item" id="labelSelectTemplateBox" lay-filter="labelSelectTemplateBox"></div>
|
||
<script id="labelSelectTemplate" type="text/html">
|
||
{{# var tabLevel1 = 0; var tabLevel2 = 0; var tabLevel3 = 0; var tabLevel4 = 0; var tabLevel5 = 0; }}
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
{{# if(item.level == 1) { }}
|
||
{{# tabLevel1 = tabLevel1 + 1; }}
|
||
{{# } }}
|
||
{{# if(item.level == 2) { }}
|
||
{{# tabLevel2 = tabLevel2 + 1; }}
|
||
{{# } }}
|
||
{{# if(item.level == 3) { }}
|
||
{{# tabLevel3 = tabLevel3 + 1; }}
|
||
{{# } }}
|
||
{{# if(item.level == 4) { }}
|
||
{{# tabLevel4 = tabLevel4 + 1; }}
|
||
{{# } }}
|
||
{{# if(item.level == 5) { }}
|
||
{{# tabLevel5= tabLevel5 + 1; }}
|
||
{{# } }}
|
||
{{# } }}
|
||
{{# if(tabLevel1 > 0 ) { }}
|
||
<div class="layui-input-block layui-form tabLevel1" style="margin-left: 0px;margin-top: -2px;min-height: 24px;">
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
{{# if(item.level == 1) { }}
|
||
<input type="checkbox" name="tabLevel1" value="{{item.id}}" title="{{item.name}}">
|
||
{{# } }}
|
||
{{# } }}
|
||
</div>
|
||
{{# } }}
|
||
{{# if(tabLevel2 > 0 ) { }}
|
||
<div class="layui-input-block layui-form tabLevel2" style="margin-left: 0px;margin-top: -2px;min-height: 24px;">
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
{{# if(item.level == 2) { }}
|
||
<input type="checkbox" name="tabLevel2" value="{{item.id}}" title="{{item.name}}">
|
||
{{# } }}
|
||
{{# } }}
|
||
</div>
|
||
{{# } }}
|
||
{{# if(tabLevel3 > 0 ) { }}
|
||
<div class="layui-input-block layui-form tabLevel3" style="margin-left: 0px;margin-top: -2px;min-height: 24px;">
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
{{# if(item.level == 3) { }}
|
||
<input type="checkbox" name="tabLevel3" value="{{item.id}}" title="{{item.name}}">
|
||
{{# } }}
|
||
{{# } }}
|
||
</div>
|
||
{{# } }}
|
||
{{# if(tabLevel4 > 0 ) { }}
|
||
<div class="layui-input-block layui-form tabLevel4" style="margin-left: 0px;margin-top: -2px;min-height: 24px;">
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
{{# if(item.level == 4) { }}
|
||
<input type="checkbox" name="tabLevel4" value="{{item.id}}" title="{{item.name}}">
|
||
{{# } }}
|
||
{{# } }}
|
||
</div>
|
||
{{# } }}
|
||
{{# if(tabLevel5 > 0 ) { }}
|
||
<div class="layui-input-block layui-form tabLevel5" style="margin-left: 0px;margin-top: -2px;min-height: 24px;">
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
{{# if(item.level == 5) { }}
|
||
<input type="checkbox" name="tabLevel5" value="{{item.id}}" title="{{item.name}}">
|
||
{{# } }}
|
||
{{# } }}
|
||
</div>
|
||
{{# } }}
|
||
</script>
|
||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||
<!-- 表头按钮组 -->
|
||
<script type="text/html" id="headerToolBar">
|
||
<div class="layui-btn-group">
|
||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
|
||
<i class="fa fa-lg fa-edit"></i> 查看
|
||
</button>
|
||
<button type="button" class="layui-btn layui-btn-sm" lay-event="excelOutEvent">
|
||
Excel导出(未脱敏)
|
||
</button>
|
||
</div>
|
||
</script>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="layui-col-xs3">
|
||
<div style="width:100%; height:400px; margin-top: 100px" id="dataPie"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script id="idcardTypeSelectTemplate" type="text/html" lay-search>
|
||
<select id="idcardType" name="idcardType">
|
||
<option value="">请选择证件类型</option>
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
<option value="{{item.dictionaryName}}">{{item.dictionaryName}}</option>
|
||
{{# } }}
|
||
</select>
|
||
</script>
|
||
<div style="display: none" id="exportExcel">
|
||
<div class="layui-form-item" pane="">
|
||
<label class="layui-form-label">导出内容</label>
|
||
<div class="layui-input-block layui-form" id="exportFieldTemplateBox" lay-filter="exportFieldTemplateBox" pane=""></div>
|
||
<script id="exportFieldTemplate" type="text/html">
|
||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||
<input type="checkbox" name="exportFieldTemplate" value="{{item.key}}" title="{{item.name}}" data-color="{{item.color}}">
|
||
{{# } }}
|
||
</script>
|
||
</div>
|
||
<div class="layui-form-item layui-layout-admin">
|
||
<div class="layui-input-block">
|
||
<div class="layui-footer" style="left: 0;">
|
||
<button type="button" id="excelExport1" class="layui-btn layui-btn-sm">
|
||
<i class="fa fa-lg fa-flag-checkered"></i> 全选
|
||
</button>
|
||
<button type="button" id="excelExport2" class="layui-btn layui-btn-sm">
|
||
<i class="fa fa-lg fa-flag-checkered"></i> 选择必填内容
|
||
</button>
|
||
<button type="button" id="excelExport" class="layui-btn layui-btn-sm">
|
||
<i class="fa fa-lg fa-file-excel-o"></i> 开始导出Excel
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||
<script src="assets/js/echarts.js"></script>
|
||
<script src="assets/js/echarts-gl.js"></script>
|
||
<script src="assets/js/echarts-auto-tooltip.js"></script>
|
||
<script>
|
||
layui.config({
|
||
base: 'assets/layuiadmin/'
|
||
}).extend({
|
||
index: 'lib/index', //主入口模块
|
||
excel: 'layui_exts/excel'
|
||
}).use(['index', 'table', 'form', 'laytpl', 'laydate', 'excel', 'common'], function() {
|
||
var $ = layui.$;
|
||
var $win = $(window);
|
||
var table = layui.table;
|
||
var admin = layui.admin;
|
||
var laydate = layui.laydate;
|
||
var form = layui.form;
|
||
var laytpl = layui.laytpl;
|
||
var excel = layui.excel;
|
||
var common = layui.common;
|
||
var resizeTimeout = null;
|
||
var tableUrl = 'api/populationinfo/listpage-system?[[${params}]]';
|
||
var countUrl = 'api/populationinfo/count-system?[[${params}]]';
|
||
|
||
function exportFieldTemplate(data) {
|
||
laytpl(document.getElementById('exportFieldTemplate').innerHTML).render(data, function(html) {
|
||
document.getElementById('exportFieldTemplateBox').innerHTML = html;
|
||
form.render();
|
||
});
|
||
}
|
||
|
||
$("#queryTab").height($win.height() - 30);
|
||
$("#dataPie").height($win.height() - 200);
|
||
|
||
// 初始化标签
|
||
function initLabelSelect() {
|
||
$.ajax({
|
||
url: 'api/populationinfo/label',
|
||
cache: false,
|
||
type: 'get',
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
laytpl(document.getElementById('labelSelectTemplate').innerHTML).render(data, function(html) {
|
||
document.getElementById('labelSelectTemplateBox').innerHTML = html;
|
||
});
|
||
form.render();
|
||
}
|
||
});
|
||
}
|
||
|
||
function getTabLevelGroup() {
|
||
var values = new Array();
|
||
$('input[name="tabLevelGroup"]:checked').each(function() {
|
||
values.push($(this).val()); // 将选中的值添加到数组中
|
||
});
|
||
if (values.length < 1) {
|
||
return "";
|
||
}
|
||
return values.join(",");
|
||
}
|
||
|
||
function getTabLevel() {
|
||
var values = new Array();
|
||
$('input[name="tabLevel1"]:checked').each(function() {
|
||
values.push($(this).val()); // 将选中的值添加到数组中
|
||
});
|
||
$('input[name="tabLevel2"]:checked').each(function() {
|
||
values.push($(this).val()); // 将选中的值添加到数组中
|
||
});
|
||
$('input[name="tabLevel3"]:checked').each(function() {
|
||
values.push($(this).val()); // 将选中的值添加到数组中
|
||
});
|
||
$('input[name="tabLevel4"]:checked').each(function() {
|
||
values.push($(this).val()); // 将选中的值添加到数组中
|
||
});
|
||
$('input[name="tabLevel5"]:checked').each(function() {
|
||
values.push($(this).val()); // 将选中的值添加到数组中
|
||
});
|
||
if (values.length < 1) {
|
||
return "";
|
||
}
|
||
return values.join(",");
|
||
}
|
||
|
||
initLabelSelect();
|
||
|
||
function initPie(groupBy, data) {
|
||
$.ajax({
|
||
url: countUrl + "&groupBy=" + groupBy,
|
||
cache: false,
|
||
data: data,
|
||
type: 'get',
|
||
dataType: 'json',
|
||
success: function (dataSource) {
|
||
const paramsList = dataSource.map((item, index) => {
|
||
return {
|
||
...item,
|
||
shading: "realistic"
|
||
};
|
||
});
|
||
console.log(paramsList);
|
||
// echarts清除旧的循环任务
|
||
echarts.dispose(document.getElementById("dataPie"))
|
||
var option = getPie3D(paramsList);
|
||
const elem = echarts.init(document.getElementById("dataPie"));
|
||
console.log("option", option);
|
||
elem.setOption(option);
|
||
// 在需要触发 tooltip 的地方调用函数
|
||
elem.on('click', function(params) {
|
||
console.log(params);
|
||
});
|
||
|
||
}
|
||
});
|
||
}
|
||
initPie("getCommunity", {});
|
||
|
||
// 初始化街道下拉选择
|
||
var jiedao = "[[${jiedao}]]";
|
||
initStreetNameSelect();
|
||
initResidentialNameSelect('9999', '9999');
|
||
initBuildingNameSelect("9999");
|
||
initHouseNameSelect("9999");
|
||
|
||
// 初始化街道下拉选择
|
||
function initStreetNameSelect() {
|
||
$.ajax({
|
||
url: 'api/residential/getStreetList',
|
||
type: 'get',
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
laytpl(document.getElementById('streetNameSelectTemplate').innerHTML).render({jiedao: jiedao , list: data}, function(html) {
|
||
document.getElementById('streetNameSelectTemplateBox').innerHTML = html;
|
||
});
|
||
form.render('select', 'streetNameSelectTemplateBox');
|
||
if (jiedao) {
|
||
$("#creatorArea1").val(jiedao);
|
||
initCommunityNameSelect($("#street").val());
|
||
}else{
|
||
initCommunityNameSelect('9999');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
// 初始化街道变化
|
||
form.on('select(street)', function(data){
|
||
var selectedText = data.elem[data.elem.selectedIndex].text;
|
||
$("#creatorArea1").val(selectedText);
|
||
if(data.value) {
|
||
initCommunityNameSelect(data.value);
|
||
}else {
|
||
initCommunityNameSelect('9999');
|
||
}
|
||
});
|
||
|
||
// 初始化社区变化
|
||
form.on('select(community)', function(data){
|
||
var streetValue = $("#street").val();
|
||
var selectedText = data.elem[data.elem.selectedIndex].text;
|
||
$("#creatorArea2").val(selectedText);
|
||
if(data.value) {
|
||
initResidentialNameSelect(streetValue, data.value);
|
||
}else {
|
||
initResidentialNameSelect(streetValue, '');
|
||
}
|
||
});
|
||
|
||
// 初始化社区下拉选择
|
||
function initCommunityNameSelect(areaId) {
|
||
$.ajax({
|
||
url: 'api/residential/getCommunityList?areaId=' + areaId,
|
||
type: 'get',
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
laytpl(document.getElementById('communityNameSelectTemplate').innerHTML).render(data, function(html) {
|
||
document.getElementById('communityNameSelectTemplateBox').innerHTML = html;
|
||
});
|
||
form.render('select', 'communityNameSelectTemplateBox');
|
||
initResidentialNameSelect('9999', '9999');
|
||
initBuildingNameSelect("9999");
|
||
initHouseNameSelect("9999");
|
||
}
|
||
});
|
||
}
|
||
|
||
// 初始化小区变化
|
||
form.on('select(residentialId)', function(data){
|
||
if(data.value) {
|
||
initBuildingNameSelect(data.value);
|
||
}else {
|
||
initBuildingNameSelect('9999');
|
||
}
|
||
});
|
||
|
||
// 初始化小区下拉选择
|
||
function initResidentialNameSelect(street, community) {
|
||
$.ajax({
|
||
url: 'api/residential/list?street=' + street + '&community=' + community,
|
||
type: 'get',
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
laytpl(document.getElementById('residentialNameSelectTemplate').innerHTML).render(data, function(html) {
|
||
document.getElementById('residentialNameSelectTemplateBox').innerHTML = html;
|
||
});
|
||
form.render('select', 'residentialNameSelectTemplateBox');
|
||
initBuildingNameSelect("9999");
|
||
initHouseNameSelect("9999");
|
||
}
|
||
});
|
||
}
|
||
|
||
// 初始化楼栋变化
|
||
form.on('select(buildingId)', function(data){
|
||
if(data.value) {
|
||
initHouseNameSelect(data.value);
|
||
}else {
|
||
initHouseNameSelect('9999');
|
||
}
|
||
});
|
||
|
||
// 初始化楼/排下拉选择
|
||
function initBuildingNameSelect(residentialId) {
|
||
$.ajax({
|
||
url: 'api/building/list?residentialId=' + residentialId,
|
||
type: 'get',
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
if(data.length < 1 && residentialId != 9999) {
|
||
layer.msg("该小区暂无录入楼/排");
|
||
}
|
||
|
||
laytpl(document.getElementById('buildingNameSelectTemplate').innerHTML).render(data, function(html) {
|
||
document.getElementById('buildingNameSelectTemplateBox').innerHTML = html;
|
||
});
|
||
form.render('select', 'buildingNameSelectTemplateBox');
|
||
initHouseNameSelect("9999");
|
||
}
|
||
});
|
||
}
|
||
|
||
// 初始化房屋下拉选择
|
||
function initHouseNameSelect(buildingId) {
|
||
$.ajax({
|
||
url: 'api/house/list?buildingId=' + buildingId,
|
||
type: 'get',
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
if(data.length < 1 && buildingId != 9999) {
|
||
layer.msg("该楼/排暂无录入房屋");
|
||
}
|
||
laytpl(document.getElementById('houseNameSelectTemplate').innerHTML).render(data, function(html) {
|
||
document.getElementById('houseNameSelectTemplateBox').innerHTML = html;
|
||
});
|
||
form.render('select', 'houseNameSelectTemplateBox');
|
||
}
|
||
});
|
||
}
|
||
|
||
// 初始化证件类型下拉选择
|
||
function initIdcardTypeSelect() {
|
||
$.ajax({
|
||
url: 'api/datadictionary/listdictionarybyparentid/76c5044f-805a-4313-b1e8-79e966b97c0d',
|
||
type: 'get',
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
laytpl(document.getElementById('idcardTypeSelectTemplate').innerHTML).render(data, function(html) {
|
||
document.getElementById('idcardTypeSelectTemplateBox').innerHTML = html;
|
||
});
|
||
form.render('select', 'idcardTypeSelectTemplateBox');
|
||
}
|
||
});
|
||
}
|
||
initIdcardTypeSelect();
|
||
|
||
// 初始化表格
|
||
function initTable() {
|
||
table.render({
|
||
elem: '#dataTable',
|
||
id: 'dataTable',
|
||
url: tableUrl,
|
||
width: admin.screen() > 1 ? '100%' : '',
|
||
height: $win.height() - 145,
|
||
defaultToolbar: [],
|
||
limit: 20,
|
||
limits: [20, 40, 60, 80, 100, 200],
|
||
toolbar: '#headerToolBar',
|
||
request: {
|
||
pageName: 'page',
|
||
limitName: 'rows'
|
||
},
|
||
cols: [
|
||
[
|
||
{type:'checkbox', fixed: 'left'},
|
||
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||
// {field: 'populationInfoId', width: 130, title: 'ID', align:'center',
|
||
// templet: function(row) {
|
||
// var rowData = row[this.field];
|
||
// if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||
// return '-';
|
||
// }
|
||
// return rowData;
|
||
// }
|
||
// },
|
||
{field: 'name', width: 130, title: '姓名', align:'center',
|
||
templet: function(row) {
|
||
var rowData = row[this.field];
|
||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||
return '-';
|
||
}
|
||
return rowData;
|
||
}
|
||
},
|
||
{field: 'idcardType', width: 130, title: '证件类型', align:'center',
|
||
templet: function(row) {
|
||
var rowData = row[this.field];
|
||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||
return '-';
|
||
}
|
||
return rowData;
|
||
}
|
||
},
|
||
{field: 'idcard', width: 180, title: '证件号码', align:'center',
|
||
templet: function(row) {
|
||
var rowData = row[this.field];
|
||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||
return '-';
|
||
}
|
||
return rowData;
|
||
}
|
||
},
|
||
{field: 'birthday', width: 130, title: '出生日期', align:'center',
|
||
templet: function(row) {
|
||
var rowData = row[this.field];
|
||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||
return '-';
|
||
}
|
||
return rowData;
|
||
}
|
||
},
|
||
{field: 'sex', width: 130, title: '性别', align:'center',
|
||
templet: function(row) {
|
||
var rowData = row[this.field];
|
||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||
return '-';
|
||
}
|
||
return rowData;
|
||
}
|
||
},
|
||
{field: 'nation', width: 130, title: '民族', align:'center',
|
||
templet: function(row) {
|
||
var rowData = row[this.field];
|
||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||
return '-';
|
||
}
|
||
return rowData;
|
||
}
|
||
},
|
||
{field: 'label', width: 380, title: '标签', align:'center',
|
||
templet: function(row) {
|
||
var rowData = row['labelList'];
|
||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||
return '-';
|
||
}
|
||
var b = "";
|
||
for(var i = 0 ; i < rowData.length; i++) {
|
||
b = b + '<button type="button" class="layui-btn layui-btn-xs" style="background-color: ' + rowData[i].color + ';">' + rowData[i].name + '</button>';
|
||
}
|
||
return b;
|
||
}
|
||
},
|
||
{field: 'creatorName', width: 120, title: '当前认领人', align:'center',
|
||
templet: function(row) {
|
||
var rowData = row[this.field];
|
||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||
return '-';
|
||
}
|
||
return rowData;
|
||
}
|
||
}
|
||
]
|
||
],
|
||
page: true,
|
||
parseData: function(data) {
|
||
return {
|
||
'code': 0,
|
||
'msg': '',
|
||
'count': data.total,
|
||
'data': data.rows
|
||
};
|
||
}
|
||
});
|
||
}
|
||
// 重载表格
|
||
function reloadTable(currentPage) {
|
||
var data = getParams();
|
||
table.reload('dataTable', {
|
||
url: tableUrl,
|
||
where: data,
|
||
page: {
|
||
curr: currentPage
|
||
},
|
||
height: $win.height() - 145,
|
||
});
|
||
}
|
||
|
||
function getParams() {
|
||
var tabLevel = getTabLevel();
|
||
var tabLevelGroup = getTabLevelGroup();
|
||
var dataParams = {
|
||
tabLevel: tabLevel,
|
||
tabLevelGroup: tabLevelGroup,
|
||
type: $("#type").val(),
|
||
name: $('#name').val(),
|
||
idcardType: $('#idcardType').val(),
|
||
idcard: $('#idcard').val(),
|
||
creatorArea1: "",
|
||
creatorArea2: "",
|
||
residentialId: "",
|
||
buildingId: "",
|
||
houseId:""
|
||
};
|
||
if ($("#creatorArea1").val() == undefined || $("#creatorArea1").val() == "" || $("#creatorArea1").val() == "请选择街道" ) {
|
||
initPie("getCommunity", dataParams);
|
||
return dataParams;
|
||
}else{
|
||
dataParams.creatorArea1 = $("#creatorArea1").val();
|
||
}
|
||
if ($("#creatorArea2").val() == undefined || $("#creatorArea2").val() == "" || $("#creatorArea2").val() == "请选择社区" ) {
|
||
initPie("getStreet", dataParams);
|
||
return dataParams;
|
||
}else{
|
||
dataParams.creatorArea2 = $("#creatorArea2").val();
|
||
}
|
||
if ($("#residentialId").val() == undefined || $("#residentialId").val() == "" || $("#creatorArea2").val() == "请选择小区" ) {
|
||
//initPie("getResidential", dataParams);
|
||
return dataParams;
|
||
}else{
|
||
dataParams.residentialId = $("#residentialId").val();
|
||
}
|
||
if ($("#buildingId").val() == undefined || $("#buildingId").val() == "" || $("#creatorArea2").val() == "请选择楼/排" ) {
|
||
//initPie("getBuilding", dataParams);
|
||
return dataParams;
|
||
}else{
|
||
dataParams.residentialId = "";
|
||
dataParams.buildingId = $("#buildingId").val();
|
||
}
|
||
if ($("#houseId").val() == undefined || $("#houseId").val() == "" || $("#creatorArea2").val() == "请选择房屋" ) {
|
||
//initPie("getHouse", dataParams);
|
||
return dataParams;
|
||
}else{
|
||
dataParams.residentialId = "";
|
||
dataParams.buildingId = "";
|
||
dataParams.houseId = $("#houseId").val();
|
||
}
|
||
return dataParams;
|
||
}
|
||
|
||
initTable();
|
||
// 事件 - 页面变化
|
||
$win.on('resize', function() {
|
||
clearTimeout(resizeTimeout);
|
||
resizeTimeout = setTimeout(function() {
|
||
reloadTable();
|
||
}, 500);
|
||
});
|
||
// 事件 - 搜索
|
||
$(document).on('click', '#search', function() {
|
||
reloadTable(1);
|
||
});
|
||
|
||
$(document).on('click', '#clear-search', function() {
|
||
initStreetNameSelect("9999");
|
||
$("#creatorArea1").val("");
|
||
$("#creatorArea2").val("");
|
||
$("#residential").val("");
|
||
$("#building").val("");
|
||
$("#house").val("");
|
||
$('#name').val("");
|
||
$('#idcard').val("");
|
||
initIdcardTypeSelect();
|
||
initLabelSelect();
|
||
$('#idcardType').val("");
|
||
reloadTable(1);
|
||
});
|
||
|
||
// 事件 - 增删改
|
||
table.on('toolbar(dataTable)', function(obj) {
|
||
var layEvent = obj.event;
|
||
var checkStatus = table.checkStatus('dataTable');
|
||
var checkDatas = checkStatus.data;
|
||
if(layEvent === 'updateEvent') {
|
||
if(checkDatas.length === 0) {
|
||
layer.msg("至少选择一个人员");
|
||
} else if(checkDatas.length > 1) {
|
||
layer.msg("只能选择一个人员");
|
||
} else {
|
||
layer.open({
|
||
type: 2,
|
||
title: '个人信息卡片',
|
||
closeBtn: 1,
|
||
area: ['80%', '80%'],
|
||
shadeClose: false,
|
||
anim: 2,
|
||
content: 'pages/housepopulation/index.html#/population-info?populationInfoId=' + checkDatas[0].populationInfoId,
|
||
end: function() {
|
||
reloadTable();
|
||
}
|
||
});
|
||
}
|
||
}else if(layEvent === 'excelOutEvent') {
|
||
if ($("#creatorArea1").val() == undefined || $("#creatorArea1").val() == "" || $("#creatorArea1").val() == "请选择街道" ) {
|
||
layer.msg("为了提升导出速度 , 请至少选择一个街道");
|
||
return;
|
||
}
|
||
exportFieldTemplate(titleArray);
|
||
layer.open({
|
||
type: 1,
|
||
title: "选择要导出的内容",
|
||
closeBtn: 1,
|
||
area: ['60%', '50%'],
|
||
shadeClose: true,
|
||
anim: 2,
|
||
content: $("#exportExcel"),
|
||
end: function() {
|
||
layer.close(loadLayerIndex);
|
||
}
|
||
});
|
||
|
||
}
|
||
});
|
||
|
||
$(document).on('click', '#excelExport1' , function() {
|
||
// 遍历每个多选框元素
|
||
$('input[name="exportFieldTemplate"]').each(function() {
|
||
$(this).prop('checked', true);
|
||
});
|
||
form.render("checkbox");
|
||
});
|
||
|
||
$(document).on('click', '#excelExport2' , function() {
|
||
// 遍历每个多选框元素
|
||
$('input[name="exportFieldTemplate"]').each(function() {
|
||
$(this).prop('checked', false);
|
||
});
|
||
// 遍历每个多选框元素
|
||
$('input[name="exportFieldTemplate"]').each(function() {
|
||
if($(this).data("color") == 'FF0000') {
|
||
$(this).prop('checked', true);
|
||
}
|
||
});
|
||
form.render("checkbox");
|
||
});
|
||
|
||
$(document).on('click', '#excelExport' , function() {
|
||
var selectedValues = []; // 存放选中的值的数组
|
||
// 遍历每个多选框元素
|
||
$('input[name="exportFieldTemplate"]').each(function() {
|
||
if ($(this).is(':checked')) { // 判断当前复选框是否被选中
|
||
selectedValues.push($(this).val()); // 将选中的值添加到数组中
|
||
}
|
||
});
|
||
var data1 = getParams();
|
||
data1.tabLevelGroup = encodeURIComponent(data1.tabLevelGroup);
|
||
var logMsg = "数据正在查询 . </br>请勿关闭窗口 ....";
|
||
var loadLayerIndex = layer.msg(logMsg, {icon: 16, time: 0, shade: 0.3});
|
||
$.ajax({
|
||
url: 'api/populationinfo/list-system?[[${params}]]',
|
||
data: data1,
|
||
cache: false,
|
||
type: 'get',
|
||
timeout: 600 * 1000,
|
||
contentType: "application/json;charset=utf-8",
|
||
success: function (data) {
|
||
layer.close(loadLayerIndex);
|
||
var len = Math.ceil(data.length / 40000)
|
||
if(len > 1) {
|
||
for(var i = 0 ; i < len ; i++) {
|
||
var dat = data.slice(i*40000, (i+1)*40000);
|
||
exportApi(dat, selectedValues);
|
||
}
|
||
}else{
|
||
exportApi(data, selectedValues);
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
/**
|
||
* 封装导出的格式
|
||
* */
|
||
function getExcelFormat(content, bold, color) {
|
||
return {
|
||
v: content,// 内容
|
||
t:"s", // 单元格的类型 'b'布尔值、'n'数字、'e'错误、's'字符串、'd'日期
|
||
s:{
|
||
alignment: {
|
||
horizontal: 'center',// "left"、"center" 或 "right" 水平对齐
|
||
vertical: 'center',// "bottom"、"center" 或 "top" 垂直对齐
|
||
},
|
||
font: {
|
||
bold: bold, // 是否加粗
|
||
// sz: 12 字号
|
||
color: {
|
||
rgb: color // 文字颜色
|
||
}
|
||
}
|
||
}
|
||
};
|
||
}
|
||
|
||
var titleArray = [
|
||
{name: '街道', key: 'creatorArea1', color: 'FF0000'},
|
||
{name: '社区', key: 'creatorArea2', color: 'FF0000'},
|
||
{name: '认领人', key: 'creatorName', color: 'FF0000'},
|
||
{name: '姓名', key: 'name', color: 'FF0000'},
|
||
{name: '证件类型', key: 'idcardType', color: 'FF0000'},
|
||
{name: '证件号码', key: 'idcard', color: 'FF0000'},
|
||
{name: '出生日期', key: 'birthday', color: 'FF0000'},
|
||
{name: '性别', key: 'sex', color: 'FF0000'},
|
||
{name: '民族', key: 'nation', color: 'FF0000'},
|
||
{name: '文化程度', key: 'education', color: 'FF0000'},
|
||
{name: '就读院校及专业', key: 'description'},
|
||
{name: '所属党派', key: 'organization', color: 'FF0000'},
|
||
{name: '宗教信仰', key: 'religion', color: 'FF0000'},
|
||
{name: '婚姻状况', key: 'marriageStatus', color: 'FF0000'},
|
||
{name: '婚变日期', key: 'marriageChangeTime', color: 'FF0000'},
|
||
{name: '初婚日期', key: 'marriageFirstTime', color: 'FF0000'},
|
||
{name: '社会保险情况', key: 'socialSecurity', color: 'FF0000'},
|
||
{name: '健康状况', key: 'healthStatus', color: 'FF0000'},
|
||
{name: '就业状态', key: 'departmentType', color: 'FF0000'},
|
||
{name: '工作单位', key: 'department'},
|
||
{name: '工作职务', key: 'pastion'},
|
||
{name: '专业技术职称', key: 'pastionTitle'},
|
||
{name: '专长', key: 'expertise'},
|
||
{name: '联系电话', key: 'phone', color: 'FF0000'},
|
||
{name: '与户主关系', key: 'relationship', color: 'FF0000'},
|
||
{name: '标签', key: 'labels'},
|
||
{name: '父亲姓名', key: 'fatherName'},
|
||
{name: '父亲证件', key: 'fatherIdcard'},
|
||
{name: '父亲电话', key: 'fatherPhone'},
|
||
{name: '母亲姓名', key: 'motherName'},
|
||
{name: '母亲证件', key: 'motherIdcard'},
|
||
{name: '母亲电话', key: 'motherPhone'},
|
||
{name: '配偶姓名', key: 'spouseName'},
|
||
{name: '配偶证件', key: 'spouseIdcard'},
|
||
{name: '配偶电话', key: 'spousePhone'},
|
||
{name: '户籍地址', key: 'domicileAreaName', color: 'FF0000'},
|
||
{name: '户籍详细地址', key: 'domicileAddress'},
|
||
{name: '籍贯地址', key: 'originAddress'},
|
||
{name: '流动日期', key: 'flowTime'},
|
||
{name: '流动原因', key: 'flowReason'},
|
||
{name: '其他原因', key: 'flowReasontext'},
|
||
{name: '是否为老年人', key: 'isOldage'},
|
||
{name: '老人类别', key: 'oldageType'},
|
||
{name: '离退休前单位', key: 'oldageDepartment'},
|
||
{name: '生活照料情况', key: 'oldageLift'},
|
||
{name: '健康状况', key: 'oldageHealthStatus'},
|
||
{name: '生活自理能力', key: 'oldageSelfcare'},
|
||
{name: '居住状况', key: 'oldageLive'},
|
||
{name: '是否为残疾人', key: 'isDisability'},
|
||
{name: '残疾类别', key: 'disabilityType'},
|
||
{name: '残疾等级', key: 'disabilityLevel'},
|
||
{name: '残疾证号', key: 'disabilityNumber'},
|
||
{name: '残疾车牌号', key: 'disabilityCarnumber'},
|
||
{name: '居住地址', key: 'disabilityAddress'},
|
||
{name: '收入情况', key: 'disabilityIncome'},
|
||
{name: '住房来源', key: 'disabilityHouse'},
|
||
{name: '办证时间', key: 'disabilityTime'},
|
||
{name: '监护人或配偶姓名', key: 'disabilityGuardian'},
|
||
{name: '是否为服役/退役', key: 'isMilitary'},
|
||
{name: '批准退出现役日期', key: 'militaryTime'},
|
||
{name: '退出现役时职级', key: 'militaryPosition'},
|
||
{name: '是否为社会救助', key: 'isSuccour'},
|
||
{name: '低保户', key: 'succourDibao'},
|
||
{name: '医疗救助', key: 'succourHelp'},
|
||
{name: '困难职工', key: 'succourDifficulty'},
|
||
{name: '老龄补贴', key: 'succourSubsidy'},
|
||
{name: '是否为党员', key: 'isParty'},
|
||
{name: '党组织名称', key: 'partyOrganization'},
|
||
{name: '入党时间', key: 'partyTime'},
|
||
{name: '其他', key: 'othertext'}
|
||
];
|
||
|
||
/**
|
||
* 将传入的数据导出
|
||
*/
|
||
function exportApi(list , fieldArray) {
|
||
var timestart = Date.now();
|
||
var logMsg = "数据正在导出 . </br>请勿关闭窗口 ....";
|
||
var loadLayerIndex = layer.msg(logMsg, {icon: 16, time: 0, shade: 0.3});
|
||
/**
|
||
* v:单元格的值
|
||
* t:单元格的类型 'b'布尔值、'n'数字、'e'错误、's'字符串、'd'日期
|
||
* s:单元格的样式
|
||
*/
|
||
var data = new Array();
|
||
var obj = {};
|
||
for(var i = 0 , item; item = titleArray[i++];) {
|
||
for(var j = 0 , item1; item1 = fieldArray[j++];) {
|
||
if(item.key == item1) {
|
||
obj[item1] = getExcelFormat(item.name, true , '000000');
|
||
}
|
||
}
|
||
}
|
||
data.push(obj);
|
||
for(var i = 0 ; i < list.length; i++) {
|
||
var rowData = list[i].labelList;
|
||
var label = "";
|
||
for(var j = 0 ; j < rowData.length; j++) {
|
||
label = label + rowData[j].name + "、";
|
||
}
|
||
var obj1 = {};
|
||
for(var l = 0 , item; item = titleArray[l++];) {
|
||
for(var k = 0 , item1; item1 = fieldArray[k++];) {
|
||
if(item.key == item1) {
|
||
obj1[item1] = getExcelFormat(list[i][item1], false , (item.color ? item.color : '000000') );
|
||
}
|
||
}
|
||
}
|
||
data.push(obj1);
|
||
}
|
||
// A列宽 200, 默认给80
|
||
var colConf = excel.makeColConfig({
|
||
}, 140);
|
||
// 每一行的行高, 默认给20
|
||
var rowConf = excel.makeRowConfig({
|
||
1: 30,
|
||
}, 20)
|
||
var creatorArea1 = $("#creatorArea1").val();
|
||
var creatorArea2 = $("#creatorArea2").val();
|
||
if ($("#creatorArea2").val() == undefined || $("#creatorArea2").val() == "" || $("#creatorArea2").val() == "请选择社区" ) {
|
||
}else{
|
||
creatorArea1 = creatorArea1 + "-" + creatorArea2;
|
||
}
|
||
console.log("开始导出...");
|
||
excel.exportExcel({
|
||
sheet1: data
|
||
}, creatorArea1 + '人口信息.xlsx', 'xlsx', {
|
||
extend: {
|
||
sheet1: {
|
||
'!cols': colConf
|
||
, '!rows': rowConf
|
||
}
|
||
}
|
||
})
|
||
var timeend = Date.now()
|
||
var spent = (timeend - timestart) / 1000
|
||
layer.close(loadLayerIndex);
|
||
layer.msg('导入耗时 :' + spent + ' 秒');
|
||
}
|
||
|
||
function getParametricEquation(startRatio, endRatio) {
|
||
let midRatio = (startRatio + endRatio) / 2;
|
||
let startRadian = startRatio * Math.PI * 2;
|
||
let endRadian = endRatio * Math.PI * 2;
|
||
let midRadian = midRatio * Math.PI * 2;
|
||
let offsetX = 0;
|
||
let offsetY = 0;
|
||
let offsetZ = 0;
|
||
let tmp;
|
||
return {
|
||
u: {
|
||
min: 0,
|
||
max: Math.PI * 2,
|
||
step: Math.PI / 250,
|
||
},
|
||
v: {
|
||
min: 0,
|
||
max: Math.PI,
|
||
step: Math.PI / 50,
|
||
},
|
||
x: function (u, v) {
|
||
if (midRatio < 0.5) {
|
||
if (u < startRadian || u > midRadian + Math.PI) {
|
||
tmp =
|
||
u - Math.PI - midRadian < 0
|
||
? u + Math.PI - midRadian
|
||
: u - Math.PI - midRadian;
|
||
return (
|
||
offsetX +
|
||
(Math.sin(startRadian) * tmp) /
|
||
(Math.PI - midRadian + startRadian)
|
||
);
|
||
}
|
||
if (u > endRadian && u < midRadian + Math.PI) {
|
||
tmp = midRadian + Math.PI - u;
|
||
return (
|
||
offsetX +
|
||
(Math.sin(endRadian) * tmp) /
|
||
(Math.PI - midRadian + startRadian)
|
||
);
|
||
}
|
||
} else {
|
||
if (u < startRadian && u > midRadian - Math.PI) {
|
||
tmp = u + Math.PI - midRadian;
|
||
return (
|
||
offsetX +
|
||
(Math.sin(startRadian) * tmp) /
|
||
(Math.PI - midRadian + startRadian)
|
||
);
|
||
}
|
||
if (u > endRadian || u < midRadian - Math.PI) {
|
||
tmp =
|
||
midRadian - Math.PI - u < 0
|
||
? midRadian + Math.PI - u
|
||
: midRadian - Math.PI - u;
|
||
return (
|
||
offsetX +
|
||
(Math.sin(endRadian) * tmp) /
|
||
(Math.PI - midRadian + startRadian)
|
||
);
|
||
}
|
||
}
|
||
return offsetX + Math.sin(v) * Math.sin(u);
|
||
},
|
||
y: function (u, v) {
|
||
if (midRatio < 0.5) {
|
||
if (u < startRadian || u > midRadian + Math.PI) {
|
||
tmp =
|
||
u - Math.PI - midRadian < 0
|
||
? u + Math.PI - midRadian
|
||
: u - Math.PI - midRadian;
|
||
return (
|
||
offsetX +
|
||
(Math.cos(startRadian) * tmp) /
|
||
(Math.PI - midRadian + startRadian)
|
||
);
|
||
}
|
||
if (u > endRadian && u < midRadian + Math.PI) {
|
||
tmp = midRadian + Math.PI - u;
|
||
return (
|
||
offsetX +
|
||
(Math.cos(endRadian) * tmp) /
|
||
(Math.PI - midRadian + startRadian)
|
||
);
|
||
}
|
||
} else {
|
||
if (u < startRadian && u > midRadian - Math.PI) {
|
||
tmp = u + Math.PI - midRadian;
|
||
return (
|
||
offsetX +
|
||
(Math.cos(startRadian) * tmp) /
|
||
(Math.PI - midRadian + startRadian)
|
||
);
|
||
}
|
||
if (u > endRadian || u < midRadian - Math.PI) {
|
||
tmp =
|
||
midRadian - Math.PI - u < 0
|
||
? midRadian + Math.PI - u
|
||
: midRadian - Math.PI - u;
|
||
return (
|
||
offsetX +
|
||
(Math.cos(endRadian) * tmp) /
|
||
(Math.PI - midRadian + startRadian)
|
||
);
|
||
}
|
||
}
|
||
return offsetX + Math.sin(v) * Math.cos(u);
|
||
},
|
||
z: function (u, v) {
|
||
return offsetZ + (Math.cos(v) > 0 ? 0.1 : -0.1);
|
||
},
|
||
};
|
||
}
|
||
|
||
// 生成模拟 3D 饼图的配置项
|
||
function getPie3D(pieData) {
|
||
let series = [];
|
||
let sumValue = 0;
|
||
let startValue = 0;
|
||
let endValue = 0;
|
||
let legendData = [];
|
||
for (let i = 0; i < pieData.length; i++) {
|
||
sumValue += pieData[i].value;
|
||
let seriesItem = {
|
||
name: !pieData[i].name ? `series${i}` : pieData[i].name,
|
||
type: "surface",
|
||
parametric: true,
|
||
wireframe: {
|
||
show: false,
|
||
},
|
||
pieData: pieData[i],
|
||
pieStatus: {
|
||
selected: false,
|
||
hovered: false,
|
||
}
|
||
};
|
||
|
||
if (pieData[i].itemStyle) {
|
||
let itemStyle = {};
|
||
if (pieData[i].itemStyle.color) {
|
||
itemStyle.color = pieData[i].itemStyle.color;
|
||
}
|
||
if (pieData[i].itemStyle.opacity) {
|
||
itemStyle.opacity = pieData[i].itemStyle.opacity;
|
||
}
|
||
seriesItem.itemStyle = itemStyle;
|
||
}
|
||
seriesItem.label = { //饼图图形上的文本标签
|
||
normal:{
|
||
show:true,
|
||
position:'inner', //标签的位置
|
||
textStyle : {
|
||
},
|
||
formatter:'{d}%'
|
||
}
|
||
};
|
||
series.push(seriesItem);
|
||
}
|
||
let barData = [];
|
||
for (let i = 0; i < series.length; i++) {
|
||
let pieData = series[i].pieData;
|
||
endValue = startValue + pieData.value;
|
||
pieData.startRatio = startValue / sumValue;
|
||
pieData.endRatio = endValue / sumValue;
|
||
series[i].parametricEquation = getParametricEquation(pieData.startRatio, pieData.endRatio);
|
||
startValue = endValue;
|
||
legendData.push({name: series[i].pieData.name, value: series[i].pieData.value});
|
||
// 柱子,为了在饼状图上显示数字
|
||
let midRatio = (pieData.startRatio + pieData.endRatio) / 2;
|
||
barData.push({
|
||
name: `${pieData.name}: ${pieData.value}`,
|
||
// 柱子透明
|
||
itemStyle: {
|
||
color: [1, 1, 1, 0]
|
||
},
|
||
label: {
|
||
show: true,
|
||
formatter: `{b}`,
|
||
textStyle: {
|
||
color: '#FFFFFF',
|
||
fontSize: 14
|
||
}
|
||
},
|
||
value: [Math.sin(midRatio * Math.PI * 2) * 0.6, Math.cos(midRatio * Math.PI * 2) * 0.6, 0.1]
|
||
})
|
||
}
|
||
// 添加柱子,为了在饼状图上显示数字
|
||
series.push({
|
||
type: 'bar3D',
|
||
data: barData,
|
||
shading: 'lambert',
|
||
label: {
|
||
fontSize: 16,
|
||
borderWidth: 1
|
||
},
|
||
emphasis: {
|
||
label: {
|
||
fontSize: 20,
|
||
color: '#FFFFFF'
|
||
},
|
||
itemStyle: {
|
||
color: '#FFFFFF'
|
||
}
|
||
}
|
||
})
|
||
|
||
let option = {
|
||
data: pieData,
|
||
legend: {
|
||
// type:'scroll',
|
||
show: true,
|
||
data: legendData,
|
||
textStyle: {
|
||
color: "#FFF"
|
||
},
|
||
formatter: function(params) {
|
||
for (var i = 0 ; i < legendData.length ; i++) {
|
||
if(legendData[i].name == params) {
|
||
return legendData[i].name + ': 占比 ' + (legendData[i].value / startValue * 100).toFixed(2) + '%';
|
||
}
|
||
}
|
||
}
|
||
},
|
||
tooltip: {
|
||
formatter: (params) => {
|
||
if (params.seriesName !== "mouseoutSeries") {
|
||
return `${
|
||
params.seriesName
|
||
}<br/><span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${
|
||
params.color
|
||
};"></span>${
|
||
option.series[params.seriesIndex].pieData
|
||
.value
|
||
}`;
|
||
}else{
|
||
return "123";
|
||
}
|
||
},
|
||
},
|
||
xAxis3D: {
|
||
min: -1,
|
||
max: 1,
|
||
},
|
||
yAxis3D: {
|
||
min: -1,
|
||
max: 1,
|
||
},
|
||
zAxis3D: {
|
||
min: -1,
|
||
max: 1,
|
||
},
|
||
grid3D: {
|
||
show: false,
|
||
boxHeight: 100, // 厚度
|
||
top: 4,
|
||
left: 0,
|
||
viewControl: {
|
||
//3d效果可以放大、旋转等,请自己去查看官方配置
|
||
alpha: 43, // 角度
|
||
beta: 0, // 饼块开始位置角度
|
||
rotateSensitivity: 0,
|
||
zoomSensitivity: 0,
|
||
panSensitivity: 0,
|
||
autoRotate: true,
|
||
},
|
||
light: {
|
||
main: {
|
||
color: "rgb(85, 84, 84)", // 主光源的颜色。
|
||
shadow: false, // 主光源是否投射阴影
|
||
alpha: 80, // 主光源绕 x 轴,即上下旋转的角度
|
||
},
|
||
},
|
||
},
|
||
series: series,
|
||
};
|
||
|
||
return option;
|
||
}
|
||
|
||
});
|
||
</script>
|
||
</body>
|
||
</html> |