master
lion 2 months ago
parent 67a6617046
commit 43bfd1b822

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

Loading…
Cancel
Save