master
xy 2 years ago
parent 35ceb8fc3d
commit 00785e19b0

@ -156,6 +156,7 @@ export default {
row-style={rowStyle}
cell-style={cellStyle}
indent={indent}
stripe={true}
data={list}
height={height ?? tableHeight}
class="v-table"

@ -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,

@ -29,10 +29,13 @@
<Button type="primary" style="margin-left: 10px" @click="getList"
>查询</Button
>
<Button type="primary" style="margin-left: 10px" @click="exportXLSX"
>导出</Button
>
</slot>
</lx-header>
<xy-table ref="xyTable" :list="list" :table-item="table">
<xy-table :row-style="({ row }) => (row.isSummary ? {'font-weight': '600','font-size': '15px'} : '')" ref="xyTable" :show-index="false" :list="formatList" :table-item="table">
<template #btns> </template>
</xy-table>
@ -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 (
<div>
<el-tooltip class="item" effect="dark" content={row.department.name} placement="top">
<p class="split split__department">{row.department.name}</p>
</el-tooltip>
{
row.plan?.map((i,index) => {
return (
<el-tooltip class="item" effect="dark" content={i.name} placement="top">
<p class="split" style={{"background":index%2===0?'#ff000012':''}}>{i.name}</p>
</el-tooltip>
)
})
}
</div>
)
}
},
{
label: '下达预算',
@ -119,27 +252,10 @@ export default {
multiHd: [
{
sortable: false,
prop: 'plan.money',
prop: 'issueBudget',
label: '合计',
width: 160,
customFn: row => {
return (
<div style="display: flex;flex-direction: column;">
<p class="split split__department" style="text-align: right;padding-right: 5px;">{
row.plan?.reduce((a, b) => {
return Number(a) + Number(b.money)
},0).toFixed(2)
}</p>
{
row.plan?.map((i,index) => {
return (
<p class="split" style={{"text-align": "right","background":index%2===0?'#ff000012':''}}>{ i.money }</p>
)
})
}
</div>
)
}
align: "right",
width: 160
}
]
},
@ -158,75 +274,27 @@ export default {
Fprop: '',
multiHd: [
{
prop: "planExpend",
label: '计划支出',
sortable: false,
width: 140,
customFn: row => {
return (
<div style="display: flex;flex-direction: column;">
<p class="split split__department" style="text-align: right;padding-right: 5px;">{
row.plan?.reduce((a, b) => {
return Number(a) + Number(b.detail[z].plan_total)
},0).toFixed(2)
}</p>
{
row.plan?.map((i,index) => {
return (
<p class="split" style={{"text-align": "right","background":index%2===0?'#ff000012':''}}>{ i.detail[z].plan_total }</p>
)
})
}
</div>
)
}
align: "right",
formatter: (v1, v2, val) => (val[z])
},
{
prop: "actExpend",
label: '实际支出',
sortable: false,
width: 140,
customFn: row => {
return (
<div style="display: flex;flex-direction: column;">
<p class="split split__department" style="text-align: right;padding-right: 5px;">{
row.plan?.reduce((a, b) => {
return Number(a) + Number(b.detail[z].act_total)
},0).toFixed(2)
}</p>
{
row.plan?.map((i,index) => {
return (
<p class="split" style={{"text-align": "right","background":index%2===0?'#ff000015':''}}>{ i.detail[z].act_total }</p>
)
})
}
</div>
)
}
align: "right",
formatter: (v1, v2, val) => (val[z])
},
{
prop: "impltRate",
label: '执行率',
sortable: false,
width: 100,
customFn: row => {
return (
<div style="display: flex;flex-direction: column;">
<p class="split split__department" style="text-align: right;padding-right: 5px;">{
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))
}%</p>
{
row.plan?.map((i,index) => {
return (
<p class="split" style={{"text-align": "right","background":index%2===0?'#ff000012':''}}>{ this.percent(i.detail[z].act_total,i.detail[z].plan_total) }%</p>
)
})
}
</div>
)
}
formatter: (v1, v2, val) => (val[z] + "%")
}
]
})
@ -236,29 +304,185 @@ export default {
{
label: '合计',
width: 120,
customFn: row => {
return (
<div style="display: flex;flex-direction: column;">
<p class="split split__department" style="text-align: right;">{
'/'
}</p>
{
row.plan?.map((i,index) => {
return (
<p class="split" style={{"text-align": "right","background":index%2===0?'#ff000012':''}}>{
i.detail?.reduce((a,b) => {
return a + Number(b.plan_total)
},0).toFixed(2)
}</p>
)
})
}
</div>
)
}
prop: "total",
align: "right",
}
]
}
// table () {
// const type = this.select.type;
// return [
// {
// label: '',
// fixed: 'left',
// prop: 'department.name',
// minWidth: 260,
// sortable: false,
// customFn:row => {
// return (
// <div>
// <el-tooltip class="item" effect="dark" content={row.department.name} placement="top">
// <p class="split split__department">{row.department.name}</p>
// </el-tooltip>
// {
// row.plan?.map((i,index) => {
// return (
// <el-tooltip class="item" effect="dark" content={i.name} placement="top">
// <p class="split" style={{"background":index%2===0?'#ff000012':''}}>{i.name}</p>
// </el-tooltip>
// )
// })
// }
// </div>
// )
// }
// },
// {
// label: '',
// Fprop: '',
// multiHd: [
// {
// sortable: false,
// prop: 'plan.money',
// label: '',
// width: 160,
// customFn: row => {
// return (
// <div style="display: flex;flex-direction: column;">
// <p class="split split__department" style="text-align: right;padding-right: 5px;">{
// row.plan?.reduce((a, b) => {
// return Number(a) + Number(b.money)
// },0).toFixed(2)
// }</p>
// {
// row.plan?.map((i,index) => {
// return (
// <p class="split" style={{"text-align": "right","background":index%2===0?'#ff000012':''}}>{ i.money }</p>
// )
// })
// }
// </div>
// )
// }
// }
// ]
// },
// ...(() => {
// 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 (
// <div style="display: flex;flex-direction: column;">
// <p class="split split__department" style="text-align: right;padding-right: 5px;">{
// row.plan?.reduce((a, b) => {
// return Number(a) + Number(b.detail[z].plan_total)
// },0).toFixed(2)
// }</p>
// {
// row.plan?.map((i,index) => {
// return (
// <p class="split" style={{"text-align": "right","background":index%2===0?'#ff000012':''}}>{ i.detail[z].plan_total }</p>
// )
// })
// }
// </div>
// )
// }
// },
// {
// label: '',
// sortable: false,
// width: 140,
// customFn: row => {
// return (
// <div style="display: flex;flex-direction: column;">
// <p class="split split__department" style="text-align: right;padding-right: 5px;">{
// row.plan?.reduce((a, b) => {
// return Number(a) + Number(b.detail[z].act_total)
// },0).toFixed(2)
// }</p>
// {
// row.plan?.map((i,index) => {
// return (
// <p class="split" style={{"text-align": "right","background":index%2===0?'#ff000015':''}}>{ i.detail[z].act_total }</p>
// )
// })
// }
// </div>
// )
// }
// },
// {
// label: '',
// sortable: false,
// width: 100,
// customFn: row => {
// return (
// <div style="display: flex;flex-direction: column;">
// <p class="split split__department" style="text-align: right;padding-right: 5px;">{
// 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))
// }%</p>
// {
// row.plan?.map((i,index) => {
// return (
// <p class="split" style={{"text-align": "right","background":index%2===0?'#ff000012':''}}>{ this.percent(i.detail[z].act_total,i.detail[z].plan_total) }%</p>
// )
// })
// }
// </div>
// )
// }
// }
// ]
// })
// }
// return arr
// })(),
// {
// label: '',
// width: 120,
// customFn: row => {
// return (
// <div style="display: flex;flex-direction: column;">
// <p class="split split__department" style="text-align: right;">{
// '/'
// }</p>
// {
// row.plan?.map((i,index) => {
// return (
// <p class="split" style={{"text-align": "right","background":index%2===0?'#ff000012':''}}>{
// i.detail?.reduce((a,b) => {
// return a + Number(b.plan_total)
// },0).toFixed(2)
// }</p>
// )
// })
// }
// </div>
// )
// }
// }
// ]
// }
},
created() {
this.select.year = this.$moment().format('YYYY');
@ -268,11 +492,14 @@ export default {
</script>
<style scoped lang="scss">
::v-deep .cell {
padding: 0;
}
::v-deep .v-table .el-table__body td {
padding: 0!important;
//::v-deep .cell {
// padding: 0;
//}
//::v-deep .v-table .el-table__body td {
// padding: 0!important;
//}
::v-deep .el-table--striped .el-table__body tr.el-table__row--striped td {
background: #4d8bdc18;
}
.split {
word-break: keep-all;

Loading…
Cancel
Save