diff --git a/src/components/XyTable/index.vue b/src/components/XyTable/index.vue index 86d708b..6d2e612 100644 --- a/src/components/XyTable/index.vue +++ b/src/components/XyTable/index.vue @@ -156,6 +156,7 @@ export default { row-style={rowStyle} cell-style={cellStyle} indent={indent} + stripe={true} data={list} height={height ?? tableHeight} class="v-table" diff --git a/src/views/contract/paymentRegistrationList.vue b/src/views/contract/paymentRegistrationList.vue index caba11d..9e0c2c2 100644 --- a/src/views/contract/paymentRegistrationList.vue +++ b/src/views/contract/paymentRegistrationList.vue @@ -547,6 +547,7 @@ export default { async getFundLogs(is_export) { await getFundLog({ + is_auth: this.is_auth, page_size: this.pageSize, page: this.pageIndex, keyword: this.keywords, diff --git a/src/views/statisticalReport/quarterlyStatistics.vue b/src/views/statisticalReport/quarterlyStatistics.vue index 455bb35..c6ad3a6 100644 --- a/src/views/statisticalReport/quarterlyStatistics.vue +++ b/src/views/statisticalReport/quarterlyStatistics.vue @@ -29,10 +29,13 @@ + - + @@ -67,9 +70,41 @@ export default { year:"" }, list: [], + formatList: [], }; }, - methods: { //日期选择 + methods: { + exportXLSX () { + let data = [] + this.formatList.forEach((item) => { + if (item && item.hasOwnProperty('children')) { + const childrenArr = item.children; + delete item.children; + data.push(item); + data.push(...childrenArr); + } else { + data.push(item); + } + }) + let xlsxData = data.map(i => { + + }) + let header = [[],[]]; + this.table.forEach((item,index) => { + if (item && item.hasOwnProperty("multiHd")) { + const titleLen = item.multiHd.length; + for (let i = 0;i < titleLen;i++) { + header[0].push(item.label) + header[1].push(item.multiHd[i].label) + } + } else { + header[0].push(item.label) + header[1].push(item.label) + } + }) + console.log(data) + }, + percent (a,b) { if (b == 0) { return 0 @@ -82,36 +117,134 @@ export default { const res = await departmentMoney(this.select); this.list = res; this.$refs['xyTable'].doLayout() + + let temp = []; + if (!res instanceof Array) return; + for (let [index,item] of res.entries()) { + //分类 + let children = [] + item.plan.forEach((plan, planIndex) => { + let planExpend = (() => { + let index = 0; + let arr = []; + while (index < (this.select.type === 1 ? 4 : 12)) { + arr.push(plan.detail[index].plan_total) + index++; + } + return arr; + })() + let actExpend = (() => { + let index = 0; + let arr = []; + while (index < (this.select.type === 1 ? 4 : 12)) { + arr.push(plan.detail[index].act_total) + index++; + } + return arr; + })() + children.push({ + id: this.toChineseNum(Number(index)+1) + planIndex+1, + index: planIndex+1, + isSummary: 0, + name: plan.name, + issueBudget: plan.money, + planExpend, + actExpend, + impltRate: planExpend.map((j, ji) => (this.percent(parseFloat(actExpend[ji]),parseFloat(j)))), + total: plan.detail?.reduce((a,b) => { + return a + Number(b.plan_total??0) + },0).toFixed(2) + }) + }) + //总计 + let actExpend = (() => { + let index = 0; + let arr = []; + while (index < (this.select.type === 1 ? 4 : 12)) { + arr.push(item.plan?.reduce((a, b) => { + return Number(a) + Number(b.detail[index].act_total) + },0).toFixed(2)) + index++; + } + return arr; + })() + let planExpend = (() => { + let index = 0; + let arr = []; + while (index < (this.select.type === 1 ? 4 : 12)) { + arr.push(item.plan?.reduce((a, b) => { + return Number(a) + Number(b.detail[index].plan_total) + },0).toFixed(2)) + index++; + } + return arr; + })() + temp.push({ + id: this.toChineseNum(Number(index)+1), + index: this.toChineseNum(Number(index)+1), + isSummary: 1, + name: item.department?.name, + issueBudget: item.plan?.reduce((a, b) => { + return Number(a) + Number(b.money??0) + },0).toFixed(2), + planExpend, + actExpend, + impltRate: planExpend.map((j, ji) => (this.percent(parseFloat(actExpend[ji]),parseFloat(j)))), + total: "/", + children + }) + } + + this.formatList = temp; + }, + + toChineseNum(number) { + const chineseNum = [ + "零", + "一", + "二", + "三", + "四", + "五", + "六", + "七", + "八", + "九", + ]; + const chineseUnit = ["", "十", "百", "千", "万", "亿"]; + let numStr = number.toString(); + let len = numStr.length; + let str = ""; + for (let i = 0; i < len; i++) { + str += chineseNum[parseInt(numStr[i])] + chineseUnit[len - 1 - i]; + } + str = str.replace(/零[十百千]/g, "零"); + str = str.replace(/零+/g, "零"); + str = str.replace(/^零+/, ""); + str = str.replace(/零+$/, ""); + if (str[str.length - 1] === "零") { + str = str.slice(0, -1); + } + return str; }, }, computed: { table () { const type = this.select.type; return [ + { + sortable: false, + label: " ", + fixed: "left", + width: 64, + prop: "index" + }, { label: '项目', fixed: 'left', - prop: 'department.name', + prop: 'name', minWidth: 260, sortable: false, - customFn:row => { - return ( -
- -

{row.department.name}

-
- { - row.plan?.map((i,index) => { - return ( - -

{i.name}

-
- ) - }) - } -
- ) - } }, { label: '下达预算', @@ -119,27 +252,10 @@ export default { multiHd: [ { sortable: false, - prop: 'plan.money', + prop: 'issueBudget', label: '合计', - width: 160, - customFn: row => { - return ( -
-

{ - row.plan?.reduce((a, b) => { - return Number(a) + Number(b.money) - },0).toFixed(2) - }

- { - row.plan?.map((i,index) => { - return ( -

{ i.money }

- ) - }) - } -
- ) - } + align: "right", + width: 160 } ] }, @@ -158,75 +274,27 @@ export default { Fprop: '', multiHd: [ { + prop: "planExpend", label: '计划支出', sortable: false, width: 140, - customFn: row => { - return ( -
-

{ - row.plan?.reduce((a, b) => { - return Number(a) + Number(b.detail[z].plan_total) - },0).toFixed(2) - }

- { - row.plan?.map((i,index) => { - return ( -

{ i.detail[z].plan_total }

- ) - }) - } -
- ) - } + align: "right", + formatter: (v1, v2, val) => (val[z]) }, { + prop: "actExpend", label: '实际支出', sortable: false, width: 140, - customFn: row => { - return ( -
-

{ - row.plan?.reduce((a, b) => { - return Number(a) + Number(b.detail[z].act_total) - },0).toFixed(2) - }

- { - row.plan?.map((i,index) => { - return ( -

{ i.detail[z].act_total }

- ) - }) - } -
- ) - } + align: "right", + formatter: (v1, v2, val) => (val[z]) }, { + prop: "impltRate", label: '执行率', sortable: false, width: 100, - customFn: row => { - return ( -
-

{ - this.percent(row.plan?.reduce((a, b) => { - return Number(a) + Number(b.detail[z].act_total) - },0),row.plan?.reduce((a, b) => { - return Number(a) + Number(b.detail[z].plan_total) - },0)) - }%

- { - row.plan?.map((i,index) => { - return ( -

{ this.percent(i.detail[z].act_total,i.detail[z].plan_total) }%

- ) - }) - } -
- ) - } + formatter: (v1, v2, val) => (val[z] + "%") } ] }) @@ -236,29 +304,185 @@ export default { { label: '合计', width: 120, - customFn: row => { - return ( -
-

{ - '/' - }

- { - row.plan?.map((i,index) => { - return ( -

{ - i.detail?.reduce((a,b) => { - return a + Number(b.plan_total) - },0).toFixed(2) - }

- ) - }) - } -
- ) - } + prop: "total", + align: "right", } ] } + // table () { + // const type = this.select.type; + // return [ + // { + // label: '项目', + // fixed: 'left', + // prop: 'department.name', + // minWidth: 260, + // sortable: false, + // customFn:row => { + // return ( + //
+ // + //

{row.department.name}

+ //
+ // { + // row.plan?.map((i,index) => { + // return ( + // + //

{i.name}

+ //
+ // ) + // }) + // } + //
+ // ) + // } + // }, + // { + // label: '下达预算', + // Fprop: '', + // multiHd: [ + // { + // sortable: false, + // prop: 'plan.money', + // label: '合计', + // width: 160, + // customFn: row => { + // return ( + //
+ //

{ + // row.plan?.reduce((a, b) => { + // return Number(a) + Number(b.money) + // },0).toFixed(2) + // }

+ // { + // row.plan?.map((i,index) => { + // return ( + //

{ i.money }

+ // ) + // }) + // } + //
+ // ) + // } + // } + // ] + // }, + // ...(() => { + // let quarterLabels = new Map([ + // [0, '第一季度'], + // [1, '第二季度'], + // [2, '第三季度'], + // [3, '第四季度'] + // ]) + // let monthLabels = new Map(Array.from({length: 12},(_,index)=>([index,`${index+1}月`]))) + // let arr = [] + // for (let z = 0;z < (type === 1 ? 4 : 12);z ++) { + // arr.push({ + // label: type === 1 ? quarterLabels.get(z) : monthLabels.get(z), + // Fprop: '', + // multiHd: [ + // { + // label: '计划支出', + // sortable: false, + // width: 140, + // customFn: row => { + // return ( + //
+ //

{ + // row.plan?.reduce((a, b) => { + // return Number(a) + Number(b.detail[z].plan_total) + // },0).toFixed(2) + // }

+ // { + // row.plan?.map((i,index) => { + // return ( + //

{ i.detail[z].plan_total }

+ // ) + // }) + // } + //
+ // ) + // } + // }, + // { + // label: '实际支出', + // sortable: false, + // width: 140, + // customFn: row => { + // return ( + //
+ //

{ + // row.plan?.reduce((a, b) => { + // return Number(a) + Number(b.detail[z].act_total) + // },0).toFixed(2) + // }

+ // { + // row.plan?.map((i,index) => { + // return ( + //

{ i.detail[z].act_total }

+ // ) + // }) + // } + //
+ // ) + // } + // }, + // { + // label: '执行率', + // sortable: false, + // width: 100, + // customFn: row => { + // return ( + //
+ //

{ + // this.percent(row.plan?.reduce((a, b) => { + // return Number(a) + Number(b.detail[z].act_total) + // },0),row.plan?.reduce((a, b) => { + // return Number(a) + Number(b.detail[z].plan_total) + // },0)) + // }%

+ // { + // row.plan?.map((i,index) => { + // return ( + //

{ this.percent(i.detail[z].act_total,i.detail[z].plan_total) }%

+ // ) + // }) + // } + //
+ // ) + // } + // } + // ] + // }) + // } + // return arr + // })(), + // { + // label: '合计', + // width: 120, + // customFn: row => { + // return ( + //
+ //

{ + // '/' + // }

+ // { + // row.plan?.map((i,index) => { + // return ( + //

{ + // i.detail?.reduce((a,b) => { + // return a + Number(b.plan_total) + // },0).toFixed(2) + // }

+ // ) + // }) + // } + //
+ // ) + // } + // } + // ] + // } }, created() { this.select.year = this.$moment().format('YYYY'); @@ -268,11 +492,14 @@ export default {