parent
46aa664caa
commit
5ecfc903fb
@ -0,0 +1,230 @@
|
||||
<template>
|
||||
<div class="asset-category-div">
|
||||
<div class="search-div">
|
||||
<div class="search-dom">
|
||||
<span class="search-title-style">资产类别</span>
|
||||
<span class="can-click-style" :title="assetNames" v-on:click="chooseAssets">{{assetNames}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="showLoading" class="show-loading-div">
|
||||
<a-spin/>
|
||||
</div>
|
||||
<div v-if="!showLoading" class="asset-category-content-div">
|
||||
<div v-if="showEmpty == false" id="assetCategory" style="width: 100%;height: 100%"></div>
|
||||
<div v-if="showEmpty" class="no-data-div">
|
||||
<a-empty/>
|
||||
</div>
|
||||
</div>
|
||||
<select-asset key="asset-select-com" :show="showAssetPanel" modalTitle="资产类别选择" :selectedDepart="selectAssets"
|
||||
@cancel="closeAssetPanel" @selectComplete="selectAssetComplete" :isMultipleChoice="true"/>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import SelectAsset from '../common/selectAsset.vue';
|
||||
import interConfig from './interConfig';
|
||||
import * as echarts from 'echarts';
|
||||
import {Spin,Empty} from 'ant-design-vue';
|
||||
export default{
|
||||
data(){
|
||||
return {
|
||||
showLoading:true,
|
||||
showEmpty:false,
|
||||
showAssetPanel: false,
|
||||
assetIds: "",
|
||||
assetNames: "全部",
|
||||
assetObjs: [],
|
||||
selectAssets: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
assetObjs: function (newVal) {
|
||||
let assetObjs = [];
|
||||
let assetNames = "全部";
|
||||
let assetIds = "";
|
||||
if (newVal.length > 0) {
|
||||
assetNames = "";
|
||||
for (let i = 0, len = newVal.length; i < len; i++) {
|
||||
let dom = {
|
||||
category_id: newVal[i].category_id,
|
||||
category_name: newVal[i].category_name
|
||||
}
|
||||
assetIds += dom.category_id + ",";
|
||||
assetNames += dom.category_name + ",";
|
||||
assetObjs.push(dom);
|
||||
}
|
||||
assetIds = assetIds.substring(0, assetIds.length - 1);
|
||||
assetNames = assetNames.substring(0, assetNames.length - 1);
|
||||
}
|
||||
this.assetIds = assetIds;
|
||||
this.assetNames = assetNames;
|
||||
this.selectAssets = assetObjs;
|
||||
this.getCategoryPieDiagram();
|
||||
},
|
||||
},
|
||||
mounted(){
|
||||
this.getCategoryPieDiagram();
|
||||
},
|
||||
methods: {
|
||||
getCategoryPieDiagram: function () {
|
||||
let param = {
|
||||
org_id: this.BaseConfig.person_info_my.bureau_id,
|
||||
}
|
||||
if (this.assetIds != '') {
|
||||
param.asset_classify_ids = this.assetIds;
|
||||
}
|
||||
this.InterfaceConfig.callInterface([{
|
||||
url: interConfig.getCategoryPieDiagram.url,
|
||||
params: param,
|
||||
method: interConfig.getCategoryPieDiagram.method,
|
||||
isTestLogin: interConfig.getCategoryPieDiagram.isTestLogin,
|
||||
}], (result) => {
|
||||
this.showLoading = false;
|
||||
let resData = result[0].data;
|
||||
if (result[0].status === 200) {
|
||||
if (resData.code === 2000) {
|
||||
let categoryList = resData.data.categoryList;
|
||||
if(categoryList && categoryList.length > 0){
|
||||
let chartData = [];
|
||||
for (let i = 0, len = categoryList.length; i < len; i++) {
|
||||
if(categoryList[i].category_value != null && parseInt(categoryList[i].category_value) > 0){
|
||||
chartData.push({name: categoryList[i].category_name, value: categoryList[i].category_value,})
|
||||
}
|
||||
if(chartData.length > 0){
|
||||
this.showEmpty = false;
|
||||
this.$nextTick(function () {
|
||||
this.buildEchart(chartData);
|
||||
})
|
||||
}else {
|
||||
this.showEmpty = true;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
this.showEmpty = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
buildEchart:function (dataList) {
|
||||
//可视化图表
|
||||
let myEchart = echarts.getInstanceByDom(document.getElementById("assetCategory"));
|
||||
if (myEchart == null) {
|
||||
myEchart = echarts.init(document.getElementById('assetCategory'));
|
||||
}
|
||||
myEchart.setOption(
|
||||
{
|
||||
tooltip: {
|
||||
trigger: 'item'
|
||||
},
|
||||
legend: {
|
||||
show:true,
|
||||
type:'scroll',
|
||||
orient: 'vertical',
|
||||
left:'0',
|
||||
align:"auto",
|
||||
padding: [5, 10],
|
||||
formatter: function (name) {
|
||||
return echarts.format.truncateText(name, 100, '14px Microsoft Yahei', '…');
|
||||
},
|
||||
tooltip: {
|
||||
show: true
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '累计数量',
|
||||
type: 'pie',
|
||||
radius: '50%',
|
||||
left:"20%",
|
||||
data: dataList,
|
||||
label: {
|
||||
show: false,
|
||||
},
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
)
|
||||
window.addEventListener("resize", () => {
|
||||
if (myEchart) {
|
||||
myEchart.resize()
|
||||
}
|
||||
})
|
||||
},
|
||||
chooseAssets: function () {
|
||||
if (!this.showAssetPanel) {
|
||||
this.showAssetPanel = true;
|
||||
}
|
||||
},
|
||||
closeAssetPanel: function () {
|
||||
this.showAssetPanel = false;
|
||||
},
|
||||
selectAssetComplete: function (selectedData) {
|
||||
this.assetObjs = selectedData;
|
||||
this.showAssetPanel = false;
|
||||
},
|
||||
},
|
||||
components: {
|
||||
SelectAsset,
|
||||
ASpin:Spin,
|
||||
AEmpty:Empty
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.asset-category-div {
|
||||
width: 100%;
|
||||
min-height: 20rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.search-div {
|
||||
width: 100%;
|
||||
height: 3rem;
|
||||
display: flex;
|
||||
.search-dom {
|
||||
width: 50%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.search-title-style {
|
||||
width: 45%;
|
||||
text-align: center;
|
||||
}
|
||||
.can-click-style {
|
||||
width: 55%;
|
||||
margin-left: 0.5rem;
|
||||
color: #31a8fa;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
.asset-category-content-div {
|
||||
width: 100%;
|
||||
height: 20rem;
|
||||
.no-data-div{
|
||||
min-height: 15rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
.show-loading-div {
|
||||
min-height: 15rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Reference in new issue