-
+
各区域应收款到账情况
@@ -58,11 +58,11 @@
-->
-
-
-
-
+
+
+
+
@@ -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}
`;
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}
`;
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}
`;
@@ -801,4 +809,4 @@
}
}
}
-
+