diff --git a/src/views/customerReport/unitPersonInspected.vue b/src/views/customerReport/unitPersonInspected.vue index 30f3a79..8086a3e 100644 --- a/src/views/customerReport/unitPersonInspected.vue +++ b/src/views/customerReport/unitPersonInspected.vue @@ -46,17 +46,17 @@ style="width: 380px" size="small" > - - + + - +
@@ -98,22 +98,67 @@ show-summary :summary-method="getSummaries" > - - - - - - - - - + + + + + + + + + + + - -
@@ -167,7 +212,7 @@ export default { }, computed: { - ...mapState(["window", "dict", "patientRegister", "diagnosis"]), + ...mapState(["window", "dict", "patientRegister", "diagnosis", "report"]), }, methods: { @@ -212,9 +257,81 @@ export default { } }); }, - btnQuery() {}, - handleExport() {}, - onPrint() {}, + btnQuery() { + let body = {}, + customerOrgs = []; + if (this.report.dataCusOrgOCX.length > 0) { + this.report.dataCusOrgOCX.forEach((e) => { + let rd = { + startDate: moment(e.startDate).format("yyyy-MM-DD"), + endDate: moment(e.endDate).format("yyyy-MM-DD"), + dateType: + e.dateType == "summaryDate" + ? "3" + : e.dateType == "medicalStartDate" + ? "2" + : "1", + }; + + if (e.customerOrgId) { + rd.customerOrgId = e.customerOrgId; + if (e.customerOrgId == this.dict.personOrgId) { + rd.customerOrgRegisterId = null; + rd.customerOrgGroupId = []; + } else { + rd.customerOrgRegisterId = e.customerOrgRegister.id; + rd.customerOrgGroupId = e.customerOrgGroupIds; + } + } + customerOrgs.push(rd); + }); + } + if (customerOrgs.length == 0) { + this.$message.warning({ showClose: true, message: "请选择单位" }); + return; + } + body.customerOrgs = customerOrgs; + if (this.completeFlag) body.statisticsType = this.completeFlag; + postapi( + "/api/app/CustomerReport/GetCustomerOrPersonCheckedStatistics", + body + ).then((res) => { + if (res.code != -1) { + this.dataList = res.data; + } + }); + }, + handleExport() { + exportToExcel("#table", "单位个人已检统计"+ moment(new Date()).format('yyyyMMDDHHmmss') ,false); + }, + onPrint() { + this.flag = false; + this.$nextTick(() => { + let width = this.$refs.imageDom.style.width; + let cloneDom = this.$refs.imageDom.cloneNode(true); + let imageDom = this.$refs.imageDom; + cloneDom.style.position = "absolute"; + cloneDom.style.top = "0px"; + cloneDom.style.zIndex = "-1"; + cloneDom.style.width = width; + console.log(cloneDom); + imageDom.appendChild(cloneDom); + html2canvas(cloneDom).then((canvas) => { + // 转成图片,生成图片地址 + const url = canvas.toDataURL("image/png"); + printJs({ + printable: url, + type: "image", + documentTitle: "", // 标题 + style: `@media print { @page {size: auto; margin: 0 0 0 0; } body{margin:0 5px}canvas{page-break-after: always;page-break-inside: avoid; +page-break-after: avoid; +page-break-before: avoid;}}`, // 去除页眉页脚 + }); + }); + cloneDom.style.display = "none"; + this.flag = true; + }); + }, tableRowClassName({ row, rowIndex }) { switch (row.isCharge) { case "N": @@ -224,6 +341,9 @@ export default { } }, getSummaries(param) { + this.$nextTick(() => { + this.$refs.dataList.doLayout(); + }); const { columns, data } = param; const sums = []; columns.forEach((column, index) => { @@ -234,6 +354,22 @@ export default { if (index === 1) { sums[index] = data.length + " 人"; } + const values = data.map(item => Number(item[column.property])); + if (column.label == "金额") { + if (!values.every(value => isNaN(value))) { + sums[index] = values.reduce((prev, curr) => { + const value = Number(curr); + if (!isNaN(value)) { + return prev + curr; + } else { + return prev; + } + }, 0); + // sums[index] += ' kg'; + } else { + // sums[index] = 'N/A'; + } + } }); return sums;