master
lion 7 months ago
parent 67a6617046
commit 43bfd1b822

@ -41,7 +41,7 @@
<myecharts :width="'100%'" :height="'400px'" :data="overall_month_data"></myecharts> <myecharts :width="'100%'" :height="'400px'" :data="overall_month_data"></myecharts>
</el-col> </el-col>
<el-col :span="24" class="chartSize" v-if="stateObj.is_dashboard_show"> <el-col :span="24" class="chartSize" v-if="stateObj.is_dashboard_show">
<div class="search"> <div class="search">
<!-- 年度业务统计 --> <!-- 年度业务统计 -->
<div class="title">各区域应收款到账情况</div> <div class="title">各区域应收款到账情况</div>
<div class="search-wrap"> <div class="search-wrap">
@ -58,11 +58,11 @@
</div> --> </div> -->
</div> </div>
</div> </div>
<div v-if="showList"> <div v-if="showList">
<xy-table :list="caiwuList" :is-page="false" :height="550" <xy-table :list="caiwuList" :is-page="false" :height="550"
:table-item="caiwuTable"> :table-item="caiwuTable">
</xy-table> </xy-table>
</div> </div>
<div class="yearData" v-if="false"> <div class="yearData" v-if="false">
<myecharts v-if="false" style="margin-top:20px" :width="'100%'" :height="'350px'" :data="budget_data"></myecharts> <myecharts v-if="false" style="margin-top:20px" :width="'100%'" :height="'350px'" :data="budget_data"></myecharts>
@ -123,7 +123,7 @@
fillChart fillChart
} from "@/api/home" } from "@/api/home"
import { import {
index, index,
show show
} from "@/api/system/baseForm.js" } from "@/api/system/baseForm.js"
import state from '@/store/modules/user.js' import state from '@/store/modules/user.js'
@ -139,11 +139,11 @@
// organizesTotal: 0, // organizesTotal: 0,
// areasTotal: 0, // areasTotal: 0,
status1Total: 0, status1Total: 0,
dateTotal: 0, dateTotal: 0,
person:{ person:{
total:0, total:0,
manage:0, manage:0,
serve:0 serve:0
} }
}, },
stateObj: {}, stateObj: {},
@ -170,18 +170,18 @@
all_areas: [], all_areas: [],
overall_year_data: {}, overall_year_data: {},
monthArr: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], monthArr: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
// //
caiwuTable:[{ caiwuTable:[{
prop:'name', prop:'name',
label:'区域', label:'区域',
width:180, width:180,
align:'center', align:'center',
fixed:'left' fixed:'left'
}], }],
showList:false, showList:false,
caiwuList:[], caiwuList:[],
id_business_types_business_id_relation:[], // id_business_types_business_id_relation:[], //
id_business_datas_business_id_relation:[], // id_business_datas_business_id_relation:[], //
} }
}, },
@ -193,10 +193,10 @@
this.yearSelect.year = this.$moment(new Date).format("YYYY") this.yearSelect.year = this.$moment(new Date).format("YYYY")
this.stateObj = state.state this.stateObj = state.state
this.init() this.init()
this.getRecords() this.getRecords()
this.getPerson() this.getPerson()
this.getMonthList() this.getMonthList()
this.getYearList() this.getYearList()
this.getCaiwuTable() this.getCaiwuTable()
}, },
mounted() { mounted() {
@ -227,132 +227,140 @@
}] }]
}) })
this.list.dateTotal = res.total this.list.dateTotal = res.total
}, },
// //
// http://sstt-dangan.ali251.langye.net/api/fill-datas-chart?business_id=20&year=2025&business_type_id=88&area_id=13 // http://sstt-dangan.ali251.langye.net/api/fill-datas-chart?business_id=20&year=2025&business_type_id=88&area_id=13
findLastNonZeroTotal(list) { findLastNonZeroTotal(list) {
const sortedKeys = Object.keys(list).sort((a, b) => Number(a) - Number(b)); const sortedKeys = Object.keys(list).sort((a, b) => Number(a) - Number(b));
for (let i = sortedKeys.length - 1; i >= 0; i--) { for (let i = sortedKeys.length - 1; i >= 0; i--) {
const currentArray = list[sortedKeys[i]]; const currentArray = list[sortedKeys[i]];
const totalItem = currentArray.find(item => item.name === '总人数'); const totalItem = currentArray.find(item => item.name === '总人数');
if (totalItem && totalItem.total > 0) { if (totalItem && totalItem.total > 0) {
return currentArray; // return currentArray; //
} }
} }
return null; // null return null; // null
}, },
async getPerson(){ async getPerson(){
const res = await fillChart({ let currentYear = parseInt(this.monthSelect.year);
business_id: 20, let currentMonthData = null;
year: this.monthSelect.year,
business_type_id: 88, //
area_id: 13 while (currentYear >= 2020 && !currentMonthData) {
}) const res = await fillChart({
const monthNum = (new Date()).getMonth() business_id: 20,
const currentMonth = monthNum===0?'01':String(new Date().getMonth()).padStart(2, '0'); year: String(currentYear),
// const currentMonth = monthNum<10?'0'+monthNum:monthNum business_type_id: 88,
console.log("currentMonth",currentMonth) area_id: 13
const currentMonthData = this.findLastNonZeroTotal(res.list); })
console.log("currentMonthData",currentMonthData) currentMonthData = this.findLastNonZeroTotal(res.list);
if(currentMonthData){
currentMonthData.forEach(item => { //
switch (item.name) { if (!currentMonthData) {
case "总人数": currentYear--;
this.list.person.total = item.total; // }
break; }
case "管理人员人数":
this.list.person.manage = item.total; // console.log("currentMonthData",currentMonthData)
break; if(currentMonthData){
case "服务人员人数": currentMonthData.forEach(item => {
this.list.person.serve = item.total; // switch (item.name) {
break; case "总人数":
} this.list.person.total = item.total; //
}); break;
} case "管理人员人数":
this.list.person.manage = item.total; //
}, break;
// case "服务人员人数":
// http://sstt-dangan.ali251.langye.net/api/admin/base-form/show?id=15&table_name=businesses&json_data_fields[]=area_ids this.list.person.serve = item.total; //
async getCaiwuTable(){ break;
}
});
}
},
//
// http://sstt-dangan.ali251.langye.net/api/admin/base-form/show?id=15&table_name=businesses&json_data_fields[]=area_ids
async getCaiwuTable(){
const res = await show({ const res = await show({
id: 15, id: 15,
table_name: 'businesses', table_name: 'businesses',
}) })
res.id_business_types_business_id_relation.map(item=>{ res.id_business_types_business_id_relation.map(item=>{
this.caiwuList.push({ this.caiwuList.push({
business_type_id:item.id, business_type_id:item.id,
name:item.name name:item.name
}) })
}) })
res.id_business_datas_business_id_relation.map(item=>{ res.id_business_datas_business_id_relation.map(item=>{
this.caiwuTable.push({ this.caiwuTable.push({
prop:item.name, prop:item.name,
business_data_id:item.id, business_data_id:item.id,
label:item.name label:item.name
}) })
this.caiwuList.map(item1=>{ this.caiwuList.map(item1=>{
item1.business_data_id = item.id item1.business_data_id = item.id
item1[item.name] = 0 item1[item.name] = 0
}) })
}) })
this.getCaiwuList() this.getCaiwuList()
}, },
async getCaiwuList(){ async getCaiwuList(){
const res = await index({ const res = await index({
page_size: 9999, page_size: 9999,
page: 1, page: 1,
table_name: 'fills', table_name: 'fills',
filter: [{ filter: [{
"key": "business_id", "key": "business_id",
"op": "eq", "op": "eq",
"value": 15 "value": 15
},{ },{
"key": "year", "key": "year",
"op": "eq", "op": "eq",
"value": this.monthSelect.year "value": this.monthSelect.year
}], }],
}) })
// return // return
// 1. id_fill_datas_fill_id_relation // 1. id_fill_datas_fill_id_relation
if(res.data.length>0){ if(res.data.length>0){
const data = res.data[0] const data = res.data[0]
console.log("data",data) console.log("data",data)
// 1. business_type_id id_fill_datas_fill_id_relation // 1. business_type_id id_fill_datas_fill_id_relation
const relationGroup = {}; const relationGroup = {};
data.id_fill_datas_fill_id_relation.forEach(relationItem => { data.id_fill_datas_fill_id_relation.forEach(relationItem => {
const typeId = relationItem.business_type_id; const typeId = relationItem.business_type_id;
// business_type_id relation // business_type_id relation
if (!relationGroup[typeId]) { if (!relationGroup[typeId]) {
relationGroup[typeId] = []; relationGroup[typeId] = [];
} }
relationGroup[typeId].push(relationItem); relationGroup[typeId].push(relationItem);
}); });
console.log("relationGroup",relationGroup) console.log("relationGroup",relationGroup)
// 2. caiwuList // 2. caiwuList
this.caiwuList.forEach(caiwuItem => { this.caiwuList.forEach(caiwuItem => {
const targetTypeId = caiwuItem.business_type_id; const targetTypeId = caiwuItem.business_type_id;
// business_type_id relation // business_type_id relation
const matchedRelations = relationGroup[targetTypeId] || []; const matchedRelations = relationGroup[targetTypeId] || [];
// relation business_data.name caiwuItem // relation business_data.name caiwuItem
matchedRelations.forEach(relationItem => { matchedRelations.forEach(relationItem => {
// relation business_data name // relation business_data name
const targetProp = relationItem.business_data?.name; const targetProp = relationItem.business_data?.name;
if (!targetProp) return; // name if (!targetProp) return; // name
// caiwuItem // caiwuItem
if (caiwuItem.hasOwnProperty(targetProp)) { if (caiwuItem.hasOwnProperty(targetProp)) {
caiwuItem[targetProp] = relationItem.value; caiwuItem[targetProp] = relationItem.value;
} }
}); });
}); });
console.log("this.caiwuList",this.caiwuList) console.log("this.caiwuList",this.caiwuList)
console.log("this.caiwuTable",this.caiwuTable) console.log("this.caiwuTable",this.caiwuTable)
this.$forceUpdate() this.$forceUpdate()
} }
this.showList = true this.showList = true
}, },
async getStatusList() { async getStatusList() {
this.nowDate = this.$moment().add(1, 'months').format('YYYY-MM-DD') this.nowDate = this.$moment().add(1, 'months').format('YYYY-MM-DD')
@ -389,7 +397,7 @@
this.getFillChart() this.getFillChart()
} }
}) })
}, },
changeArea(e) { changeArea(e) {
this.list_business.map(item => { this.list_business.map(item => {
@ -503,10 +511,10 @@
let last_total = total let last_total = total
if (name.includes('费用') || name.includes('补贴')) { if (name.includes('费用') || name.includes('补贴')) {
last_total = parseFloat(total / 10000).toFixed(2) last_total = parseFloat(total / 10000).toFixed(2)
} }
if (name=='服务人数') { if (name=='服务人数') {
last_total = total / 100 last_total = total / 100
} }
categorizedData[business_data_id].data[parseInt(month) - 1] = last_total; categorizedData[business_data_id].data[parseInt(month) - 1] = last_total;
}); });
@ -549,13 +557,13 @@
// //
getYearObj(list, budgets) { getYearObj(list, budgets) {
let flatBudgets = [].concat(...budgets); let flatBudgets = [].concat(...budgets);
let yearObjs = []; let yearObjs = [];
let budget_data_x = [] let budget_data_x = []
this.budget_data.list.map(item=>{ this.budget_data.list.map(item=>{
item.data = [] item.data = []
}) })
for (let name in list) { for (let name in list) {
budget_data_x.push(name) budget_data_x.push(name)
if (list.hasOwnProperty(name)) { if (list.hasOwnProperty(name)) {
let yearObj = { let yearObj = {
@ -581,10 +589,10 @@
let result = `${item.seriesName}<br/>`; let result = `${item.seriesName}<br/>`;
const name = item.name; // const name = item.name; //
const value = item.value; // const value = item.value; //
const marker = item.marker; // const marker = item.marker; //
let unit = item.name.includes('费用') || item.name.includes('补贴') ? '万元' : '' let unit = item.name.includes('费用') || item.name.includes('补贴') ? '万元' : ''
if(item.name=='服务人数'){ if(item.name=='服务人数'){
unit='百人' unit='百人'
} }
result += `${marker}${name}: ${value}${unit}<br/>`; result += `${marker}${name}: ${value}${unit}<br/>`;
return result; return result;
@ -603,16 +611,16 @@
); );
// console.log(name, list[name], matchedBudgets) // console.log(name, list[name], matchedBudgets)
// //
this.budget_data.list.map(item=>{ this.budget_data.list.map(item=>{
if(item.id==='quarter_1'){ if(item.id==='quarter_1'){
item.data.push(matchedBudgets.length > 0 ? matchedBudgets[0].quarter_1/10000 : 0) item.data.push(matchedBudgets.length > 0 ? matchedBudgets[0].quarter_1/10000 : 0)
}else if(item.id==='quarter_2'){ }else if(item.id==='quarter_2'){
item.data.push(matchedBudgets.length > 0 ? matchedBudgets[0].quarter_2/10000 : 0) item.data.push(matchedBudgets.length > 0 ? matchedBudgets[0].quarter_2/10000 : 0)
}else if(item.id==='quarter_3'){ }else if(item.id==='quarter_3'){
item.data.push(matchedBudgets.length > 0 ? matchedBudgets[0].quarter_3/10000 : 0) item.data.push(matchedBudgets.length > 0 ? matchedBudgets[0].quarter_3/10000 : 0)
}else if(item.id==='quarter_4'){ }else if(item.id==='quarter_4'){
item.data.push(matchedBudgets.length > 0 ? matchedBudgets[0].quarter_4/10000 : 0) item.data.push(matchedBudgets.length > 0 ? matchedBudgets[0].quarter_4/10000 : 0)
} }
}) })
// //
list[name].map(item => { list[name].map(item => {
@ -628,7 +636,7 @@
yearObjs.push(yearObj); yearObjs.push(yearObj);
// console.log("budget_data", this.budget_data) // console.log("budget_data", this.budget_data)
} }
} }
this.budget_data.x = budget_data_x this.budget_data.x = budget_data_x
return yearObjs return yearObjs
}, },
@ -652,10 +660,10 @@
// item // item
const seriesName = item.seriesName; // const seriesName = item.seriesName; //
const value = item.value; // const value = item.value; //
const marker = item.marker; // const marker = item.marker; //
let unit = item.seriesName.includes('费用') || item.seriesName.includes('补贴') ? '万元' : '' let unit = item.seriesName.includes('费用') || item.seriesName.includes('补贴') ? '万元' : ''
if(item.seriesName=='服务人数'){ if(item.seriesName=='服务人数'){
unit = '百人' unit = '百人'
} }
result += `${marker}${seriesName}: ${value}${unit}<br/>`; result += `${marker}${seriesName}: ${value}${unit}<br/>`;
@ -801,4 +809,4 @@
} }
} }
} }
</style> </style>

Loading…
Cancel
Save