master
xy 2 years ago
parent 00785e19b0
commit 444e09e03f

@ -2,8 +2,8 @@
ENV = 'development' ENV = 'development'
# base api # base api
VUE_APP_DOMIAN=http://192.168.60.99:9003/ #VUE_APP_DOMIAN=http://192.168.60.99:9003/
#VUE_APP_DOMIAN=http://hdcontract.ali251.langye.net/ VUE_APP_DOMIAN=http://hdcontract.ali251.langye.net/
VUE_APP_BASE_API = '' VUE_APP_BASE_API = ''
VUE_APP_UPLOAD=http://hdcontract.ali251.langye.net/api/admin/upload-file VUE_APP_UPLOAD=http://hdcontract.ali251.langye.net/api/admin/upload-file
#VUE_APP_UPLOAD=http://192.168.60.99:9003/api/admin/upload-file #VUE_APP_UPLOAD=http://192.168.60.99:9003/api/admin/upload-file

@ -17,6 +17,7 @@
"axios": "0.18.1", "axios": "0.18.1",
"core-js": "3.6.5", "core-js": "3.6.5",
"element-ui": "2.13.2", "element-ui": "2.13.2",
"file-saver": "^2.0.5",
"html2canvas": "^1.4.1", "html2canvas": "^1.4.1",
"js-cookie": "2.2.0", "js-cookie": "2.2.0",
"less": "^3.13.1", "less": "^3.13.1",
@ -30,7 +31,8 @@
"vue-matomo": "^4.2.0", "vue-matomo": "^4.2.0",
"vue-router": "3.0.6", "vue-router": "3.0.6",
"vuex": "3.1.0", "vuex": "3.1.0",
"wangeditor": "^4.7.12" "wangeditor": "^4.7.12",
"xlsx": "^0.18.5"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "4.4.4", "@vue/cli-plugin-babel": "4.4.4",

@ -10,6 +10,19 @@
<span> <span>
<el-switch v-model="select.type" :active-value="1" :inactive-value="2" active-text="季度" inactive-text="月度" @change="getList"></el-switch> <el-switch v-model="select.type" :active-value="1" :inactive-value="2" active-text="季度" inactive-text="月度" @change="getList"></el-switch>
</span> </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 style="padding: 0 6px;word-break: keep-all;">年份</span>
<span> <span>
<DatePicker :value="select.year" placeholder="请选择年份" type="year" placement="bottom-start" style="width: 160px" <DatePicker :value="select.year" placeholder="请选择年份" type="year" placement="bottom-start" style="width: 160px"
@ -55,13 +68,18 @@
</template> </template>
<script> <script>
import * as XLSX from "xlsx";
import { saveAs } from "file-saver";
import { departmentMoney } from "@/api/static"; import { departmentMoney } from "@/api/static";
import {getparameter} from "@/api/system/dictionary";
export default { export default {
data() { data() {
return { return {
loading: false, loading: false,
parameterDetails: [],
select: { select: {
parameter_detail_id: "",
type: 1,//12 type: 1,//12
page: 1, page: 1,
page_size: 10, page_size: 10,
@ -74,6 +92,13 @@ export default {
}; };
}, },
methods: { methods: {
async getTypes() {
const res = await getparameter({
number: "money_way",
});
this.parameterDetails = res.detail;
},
exportXLSX () { exportXLSX () {
let data = [] let data = []
this.formatList.forEach((item) => { this.formatList.forEach((item) => {
@ -87,22 +112,88 @@ export default {
} }
}) })
let xlsxData = data.map(i => { 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 = [[],[]]; let header = [[],[]];
this.table.forEach((item,index) => { this.table.forEach((item,index) => {
if (item && item.hasOwnProperty("multiHd")) { if (index !== 0) {
const titleLen = item.multiHd.length; if (item && item.hasOwnProperty("multiHd")) {
for (let i = 0;i < titleLen;i++) { 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[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) { percent (a,b) {
@ -114,6 +205,7 @@ export default {
async getList() { async getList() {
this.list = []; this.list = [];
this.formatList = [];
const res = await departmentMoney(this.select); const res = await departmentMoney(this.select);
this.list = res; this.list = res;
this.$refs['xyTable'].doLayout() this.$refs['xyTable'].doLayout()
@ -128,7 +220,7 @@ export default {
let index = 0; let index = 0;
let arr = []; let arr = [];
while (index < (this.select.type === 1 ? 4 : 12)) { while (index < (this.select.type === 1 ? 4 : 12)) {
arr.push(plan.detail[index].plan_total) arr.push(parseFloat(plan.detail[index].plan_total))
index++; index++;
} }
return arr; return arr;
@ -137,7 +229,7 @@ export default {
let index = 0; let index = 0;
let arr = []; let arr = [];
while (index < (this.select.type === 1 ? 4 : 12)) { while (index < (this.select.type === 1 ? 4 : 12)) {
arr.push(plan.detail[index].act_total) arr.push(parseFloat(plan.detail[index].act_total))
index++; index++;
} }
return arr; return arr;
@ -147,13 +239,13 @@ export default {
index: planIndex+1, index: planIndex+1,
isSummary: 0, isSummary: 0,
name: plan.name, name: plan.name,
issueBudget: plan.money, issueBudget: parseFloat(plan.money),
planExpend, planExpend,
actExpend, actExpend,
impltRate: planExpend.map((j, ji) => (this.percent(parseFloat(actExpend[ji]),parseFloat(j)))), impltRate: planExpend.map((j, ji) => (this.percent(parseFloat(actExpend[ji]),parseFloat(j)))),
total: plan.detail?.reduce((a,b) => { total: plan.detail?.reduce((a,b) => {
return a + Number(b.plan_total??0) return a + parseFloat(b.plan_total??0)
},0).toFixed(2) },0)
}) })
}) })
// //
@ -162,8 +254,8 @@ export default {
let arr = []; let arr = [];
while (index < (this.select.type === 1 ? 4 : 12)) { while (index < (this.select.type === 1 ? 4 : 12)) {
arr.push(item.plan?.reduce((a, b) => { arr.push(item.plan?.reduce((a, b) => {
return Number(a) + Number(b.detail[index].act_total) return parseFloat(a) + parseFloat(b.detail[index].act_total)
},0).toFixed(2)) },0))
index++; index++;
} }
return arr; return arr;
@ -173,8 +265,8 @@ export default {
let arr = []; let arr = [];
while (index < (this.select.type === 1 ? 4 : 12)) { while (index < (this.select.type === 1 ? 4 : 12)) {
arr.push(item.plan?.reduce((a, b) => { arr.push(item.plan?.reduce((a, b) => {
return Number(a) + Number(b.detail[index].plan_total) return parseFloat(a) + parseFloat(b.detail[index].plan_total)
},0).toFixed(2)) },0))
index++; index++;
} }
return arr; return arr;
@ -185,12 +277,12 @@ export default {
isSummary: 1, isSummary: 1,
name: item.department?.name, name: item.department?.name,
issueBudget: item.plan?.reduce((a, b) => { issueBudget: item.plan?.reduce((a, b) => {
return Number(a) + Number(b.money??0) return parseFloat(a) + parseFloat(b.money??0)
},0).toFixed(2), },0),
planExpend, planExpend,
actExpend, actExpend,
impltRate: planExpend.map((j, ji) => (this.percent(parseFloat(actExpend[ji]),parseFloat(j)))), impltRate: planExpend.map((j, ji) => (this.percent(parseFloat(actExpend[ji]),parseFloat(j)))),
total: "/", total: planExpend.reduce((pre,cur) => (pre + parseFloat(cur)),0),
children children
}) })
} }
@ -255,7 +347,8 @@ export default {
prop: 'issueBudget', prop: 'issueBudget',
label: '合计', label: '合计',
align: "right", align: "right",
width: 160 width: 160,
formatter: (v1, v2, val) => (val.toFixed(2))
} }
] ]
}, },
@ -279,7 +372,7 @@ export default {
sortable: false, sortable: false,
width: 140, width: 140,
align: "right", align: "right",
formatter: (v1, v2, val) => (val[z]) formatter: (v1, v2, val) => (val[z].toFixed(2))
}, },
{ {
prop: "actExpend", prop: "actExpend",
@ -287,7 +380,7 @@ export default {
sortable: false, sortable: false,
width: 140, width: 140,
align: "right", align: "right",
formatter: (v1, v2, val) => (val[z]) formatter: (v1, v2, val) => (val[z].toFixed(2))
}, },
{ {
prop: "impltRate", prop: "impltRate",
@ -306,6 +399,7 @@ export default {
width: 120, width: 120,
prop: "total", prop: "total",
align: "right", align: "right",
formatter: (v1, v2, val) => (val.toFixed(2))
} }
] ]
} }
@ -485,8 +579,9 @@ export default {
// } // }
}, },
created() { created() {
this.select.year = this.$moment().format('YYYY'); this.getTypes();
this.getList(); this.select.year = this.$moment().format('YYYY');
this.getList();
}, },
}; };
</script> </script>

Loading…
Cancel
Save