|
|
|
|
@ -10,6 +10,19 @@
|
|
|
|
|
<span>
|
|
|
|
|
<el-switch v-model="select.type" :active-value="1" :inactive-value="2" active-text="季度" inactive-text="月度" @change="getList"></el-switch>
|
|
|
|
|
</span>
|
|
|
|
|
<span style="padding: 0 6px;word-break: keep-all;">资金性质分类</span>
|
|
|
|
|
<span>
|
|
|
|
|
<Select
|
|
|
|
|
v-model="select.parameter_detail_id"
|
|
|
|
|
clearable
|
|
|
|
|
placeholder="选择预算类型"
|
|
|
|
|
style="width: 130px"
|
|
|
|
|
>
|
|
|
|
|
<Option v-for="item in parameterDetails" :key="item.id" :value="item.id">{{
|
|
|
|
|
item.value
|
|
|
|
|
}}</Option>
|
|
|
|
|
</Select>
|
|
|
|
|
</span>
|
|
|
|
|
<span style="padding: 0 6px;word-break: keep-all;">年份</span>
|
|
|
|
|
<span>
|
|
|
|
|
<DatePicker :value="select.year" placeholder="请选择年份" type="year" placement="bottom-start" style="width: 160px"
|
|
|
|
|
@ -55,13 +68,18 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import * as XLSX from "xlsx";
|
|
|
|
|
import { saveAs } from "file-saver";
|
|
|
|
|
import { departmentMoney } from "@/api/static";
|
|
|
|
|
import {getparameter} from "@/api/system/dictionary";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
loading: false,
|
|
|
|
|
parameterDetails: [],
|
|
|
|
|
select: {
|
|
|
|
|
parameter_detail_id: "",
|
|
|
|
|
type: 1,//1季度,2月
|
|
|
|
|
page: 1,
|
|
|
|
|
page_size: 10,
|
|
|
|
|
@ -74,6 +92,13 @@ export default {
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
async getTypes() {
|
|
|
|
|
const res = await getparameter({
|
|
|
|
|
number: "money_way",
|
|
|
|
|
});
|
|
|
|
|
this.parameterDetails = res.detail;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
exportXLSX () {
|
|
|
|
|
let data = []
|
|
|
|
|
this.formatList.forEach((item) => {
|
|
|
|
|
@ -87,22 +112,88 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let xlsxData = data.map(i => {
|
|
|
|
|
|
|
|
|
|
let arr = [i.name, i.issueBudget]
|
|
|
|
|
for (let z = 0;z < (this.select.type === 1 ? 4 : 12);z ++) {
|
|
|
|
|
arr.push(i.planExpend[z]);
|
|
|
|
|
arr.push(i.actExpend[z]);
|
|
|
|
|
arr.push(i.impltRate[z]);
|
|
|
|
|
}
|
|
|
|
|
arr.push(i.total);
|
|
|
|
|
return arr;
|
|
|
|
|
})
|
|
|
|
|
let header = [[],[]];
|
|
|
|
|
this.table.forEach((item,index) => {
|
|
|
|
|
if (item && item.hasOwnProperty("multiHd")) {
|
|
|
|
|
const titleLen = item.multiHd.length;
|
|
|
|
|
for (let i = 0;i < titleLen;i++) {
|
|
|
|
|
if (index !== 0) {
|
|
|
|
|
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.multiHd[i].label)
|
|
|
|
|
header[1].push(item.label)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
header[0].push(item.label)
|
|
|
|
|
header[1].push(item.label)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
console.log(data)
|
|
|
|
|
xlsxData.unshift(...header);
|
|
|
|
|
const wb = XLSX.utils.book_new();
|
|
|
|
|
const ws = XLSX.utils.aoa_to_sheet(xlsxData);
|
|
|
|
|
ws["!cols"] = [{ wch: 40 },...Array.from({ length: xlsxData.length - 1 },_ => ({ wch: 15 }))];
|
|
|
|
|
ws["!merges"] = [
|
|
|
|
|
{
|
|
|
|
|
s: {
|
|
|
|
|
c: 0,
|
|
|
|
|
r: 0
|
|
|
|
|
},
|
|
|
|
|
e: {
|
|
|
|
|
c: 0,
|
|
|
|
|
r: 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
let start = 2;
|
|
|
|
|
while (start < xlsxData[0].length) {
|
|
|
|
|
let index = 0;
|
|
|
|
|
let val = xlsxData[0][start]
|
|
|
|
|
while (val === xlsxData[0][start+index]) {
|
|
|
|
|
index++
|
|
|
|
|
}
|
|
|
|
|
ws["!merges"].push({
|
|
|
|
|
s: {
|
|
|
|
|
c: start,
|
|
|
|
|
r: 0
|
|
|
|
|
},
|
|
|
|
|
e: {
|
|
|
|
|
c: start + index - 1,
|
|
|
|
|
r: 0
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
start += index;
|
|
|
|
|
}
|
|
|
|
|
ws["!merges"].push(
|
|
|
|
|
{
|
|
|
|
|
s: {
|
|
|
|
|
c: xlsxData[0].length - 1,
|
|
|
|
|
r: 0
|
|
|
|
|
},
|
|
|
|
|
e: {
|
|
|
|
|
c: xlsxData[0].length - 1,
|
|
|
|
|
r: 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
console.log( ws["!merges"])
|
|
|
|
|
XLSX.utils.book_append_sheet(wb, ws, '部门预算执行情况');
|
|
|
|
|
const wbout = XLSX.write(wb, {
|
|
|
|
|
bookType: "xlsx",
|
|
|
|
|
bookSST: true,
|
|
|
|
|
type: "array",
|
|
|
|
|
});
|
|
|
|
|
saveAs(
|
|
|
|
|
new Blob([wbout], { type: "application/octet-stream" }),
|
|
|
|
|
`部门预算执行情况${this.select.year}年${this.select.type === 1 ? "季度表" : "月份表" } ${this.$moment().format('YYYY-MM-DD')}.xlsx`
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
percent (a,b) {
|
|
|
|
|
@ -114,6 +205,7 @@ export default {
|
|
|
|
|
|
|
|
|
|
async getList() {
|
|
|
|
|
this.list = [];
|
|
|
|
|
this.formatList = [];
|
|
|
|
|
const res = await departmentMoney(this.select);
|
|
|
|
|
this.list = res;
|
|
|
|
|
this.$refs['xyTable'].doLayout()
|
|
|
|
|
@ -128,7 +220,7 @@ export default {
|
|
|
|
|
let index = 0;
|
|
|
|
|
let arr = [];
|
|
|
|
|
while (index < (this.select.type === 1 ? 4 : 12)) {
|
|
|
|
|
arr.push(plan.detail[index].plan_total)
|
|
|
|
|
arr.push(parseFloat(plan.detail[index].plan_total))
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
return arr;
|
|
|
|
|
@ -137,7 +229,7 @@ export default {
|
|
|
|
|
let index = 0;
|
|
|
|
|
let arr = [];
|
|
|
|
|
while (index < (this.select.type === 1 ? 4 : 12)) {
|
|
|
|
|
arr.push(plan.detail[index].act_total)
|
|
|
|
|
arr.push(parseFloat(plan.detail[index].act_total))
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
return arr;
|
|
|
|
|
@ -147,13 +239,13 @@ export default {
|
|
|
|
|
index: planIndex+1,
|
|
|
|
|
isSummary: 0,
|
|
|
|
|
name: plan.name,
|
|
|
|
|
issueBudget: plan.money,
|
|
|
|
|
issueBudget: parseFloat(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)
|
|
|
|
|
return a + parseFloat(b.plan_total??0)
|
|
|
|
|
},0)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
//总计
|
|
|
|
|
@ -162,8 +254,8 @@ export default {
|
|
|
|
|
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))
|
|
|
|
|
return parseFloat(a) + parseFloat(b.detail[index].act_total)
|
|
|
|
|
},0))
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
return arr;
|
|
|
|
|
@ -173,8 +265,8 @@ export default {
|
|
|
|
|
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))
|
|
|
|
|
return parseFloat(a) + parseFloat(b.detail[index].plan_total)
|
|
|
|
|
},0))
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
return arr;
|
|
|
|
|
@ -185,12 +277,12 @@ export default {
|
|
|
|
|
isSummary: 1,
|
|
|
|
|
name: item.department?.name,
|
|
|
|
|
issueBudget: item.plan?.reduce((a, b) => {
|
|
|
|
|
return Number(a) + Number(b.money??0)
|
|
|
|
|
},0).toFixed(2),
|
|
|
|
|
return parseFloat(a) + parseFloat(b.money??0)
|
|
|
|
|
},0),
|
|
|
|
|
planExpend,
|
|
|
|
|
actExpend,
|
|
|
|
|
impltRate: planExpend.map((j, ji) => (this.percent(parseFloat(actExpend[ji]),parseFloat(j)))),
|
|
|
|
|
total: "/",
|
|
|
|
|
total: planExpend.reduce((pre,cur) => (pre + parseFloat(cur)),0),
|
|
|
|
|
children
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
@ -255,7 +347,8 @@ export default {
|
|
|
|
|
prop: 'issueBudget',
|
|
|
|
|
label: '合计',
|
|
|
|
|
align: "right",
|
|
|
|
|
width: 160
|
|
|
|
|
width: 160,
|
|
|
|
|
formatter: (v1, v2, val) => (val.toFixed(2))
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
@ -279,7 +372,7 @@ export default {
|
|
|
|
|
sortable: false,
|
|
|
|
|
width: 140,
|
|
|
|
|
align: "right",
|
|
|
|
|
formatter: (v1, v2, val) => (val[z])
|
|
|
|
|
formatter: (v1, v2, val) => (val[z].toFixed(2))
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: "actExpend",
|
|
|
|
|
@ -287,7 +380,7 @@ export default {
|
|
|
|
|
sortable: false,
|
|
|
|
|
width: 140,
|
|
|
|
|
align: "right",
|
|
|
|
|
formatter: (v1, v2, val) => (val[z])
|
|
|
|
|
formatter: (v1, v2, val) => (val[z].toFixed(2))
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: "impltRate",
|
|
|
|
|
@ -306,6 +399,7 @@ export default {
|
|
|
|
|
width: 120,
|
|
|
|
|
prop: "total",
|
|
|
|
|
align: "right",
|
|
|
|
|
formatter: (v1, v2, val) => (val.toFixed(2))
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
@ -485,8 +579,9 @@ export default {
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.select.year = this.$moment().format('YYYY');
|
|
|
|
|
this.getList();
|
|
|
|
|
this.getTypes();
|
|
|
|
|
this.select.year = this.$moment().format('YYYY');
|
|
|
|
|
this.getList();
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|