|
@@ -13,7 +13,7 @@
|
|
|
<el-button type="primary" class="bt" icon="edit" @click="onout">月度人工维护</el-button>
|
|
<el-button type="primary" class="bt" icon="edit" @click="onout">月度人工维护</el-button>
|
|
|
<el-button type="primary" class="bt" icon="download" @click="hzToExcel" >导出到Excel(汇总)</el-button>
|
|
<el-button type="primary" class="bt" icon="download" @click="hzToExcel" >导出到Excel(汇总)</el-button>
|
|
|
<el-button type="primary" class="bt" icon="download" @click="mxToExcel" >导出到Excel(明细)</el-button>
|
|
<el-button type="primary" class="bt" icon="download" @click="mxToExcel" >导出到Excel(明细)</el-button>
|
|
|
- <el-button type="primary" class="bt" icon="edit" @click="onout">能耗报表</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" class="bt" icon="edit" @click="onforms">能耗报表</el-button>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-form>
|
|
</el-form>
|
|
@@ -157,6 +157,7 @@
|
|
|
import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
|
|
import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
|
|
|
|
|
|
|
|
import {ref, reactive} from 'vue'
|
|
import {ref, reactive} from 'vue'
|
|
|
|
|
+ import {hiprint} from "vue-plugin-hiprint";
|
|
|
import { exportExcelFile } from '@/utils/excel'
|
|
import { exportExcelFile } from '@/utils/excel'
|
|
|
import {ElMessage} from "element-plus";
|
|
import {ElMessage} from "element-plus";
|
|
|
defineOptions({name: 'Company'})
|
|
defineOptions({name: 'Company'})
|
|
@@ -164,9 +165,381 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ let _table_print = ref([
|
|
|
|
|
+ {
|
|
|
|
|
+ mergeRowCount: 3,
|
|
|
|
|
+ data: [
|
|
|
|
|
+ {
|
|
|
|
|
+ type: "公共课",
|
|
|
|
|
+ id: "A001",
|
|
|
|
|
+ name2: "QQ", // 补全所有字段
|
|
|
|
|
+ time: "",
|
|
|
|
|
+ score: "",
|
|
|
|
|
+ start: "",
|
|
|
|
|
+ tName2: ""
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ type: "",
|
|
|
|
|
+ id: "A002",
|
|
|
|
|
+ name2: "WW", // 补全所有字段
|
|
|
|
|
+ time: "",
|
|
|
|
|
+ score: "",
|
|
|
|
|
+ start: "",
|
|
|
|
|
+ tName2: ""
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ type: "",
|
|
|
|
|
+ id: "A002",
|
|
|
|
|
+ name2: "EE", // 补全所有字段
|
|
|
|
|
+ time: "",
|
|
|
|
|
+ score: "",
|
|
|
|
|
+ start: "",
|
|
|
|
|
+ tName2: ""
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ type: "选修课",
|
|
|
|
|
+ id: "B001",
|
|
|
|
|
+ name2: "RR", // 补全所有字段
|
|
|
|
|
+ time: "",
|
|
|
|
|
+ score: "",
|
|
|
|
|
+ start: "",
|
|
|
|
|
+ tName2: ""
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ type: "课外课",
|
|
|
|
|
+ id: "C001",
|
|
|
|
|
+ name2: "TT", // 补全所有字段
|
|
|
|
|
+ time: "",
|
|
|
|
|
+ score: "",
|
|
|
|
|
+ start: "",
|
|
|
|
|
+ tName2: ""
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ type: "",
|
|
|
|
|
+ id: "小计",
|
|
|
|
|
+ name2: "0", // 补全所有字段
|
|
|
|
|
+ time: "",
|
|
|
|
|
+ score: "",
|
|
|
|
|
+ start: "",
|
|
|
|
|
+ tName2: ""
|
|
|
|
|
+ },
|
|
|
|
|
+ ]
|
|
|
|
|
+}
|
|
|
|
|
+]);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //打印小票数据
|
|
|
|
|
+ const jsondata ={
|
|
|
|
|
+ "panels": [{
|
|
|
|
|
+ "index": 0,
|
|
|
|
|
+ "name": 1,
|
|
|
|
|
+ "height": 296.6,
|
|
|
|
|
+ "width": 210,
|
|
|
|
|
+ "paperHeader": 76.5,
|
|
|
|
|
+ "paperFooter": 832.5,
|
|
|
|
|
+ "printElements": [{
|
|
|
|
|
+ "options": {
|
|
|
|
|
+ "left": 228,
|
|
|
|
|
+ "top": 25.5,
|
|
|
|
|
+ "height": 33,
|
|
|
|
|
+ "width": 169.5,
|
|
|
|
|
+ "title": "各月水电气统计报表",
|
|
|
|
|
+ "right": 397.4947814941406,
|
|
|
|
|
+ "bottom": 57.75,
|
|
|
|
|
+ "vCenter": 312.7447814941406,
|
|
|
|
|
+ "hCenter": 41.25,
|
|
|
|
|
+ "coordinateSync": false,
|
|
|
|
|
+ "widthHeightSync": false,
|
|
|
|
|
+ "fontSize": 18,
|
|
|
|
|
+ "fontWeight": "bolder",
|
|
|
|
|
+ "textAlign": "center",
|
|
|
|
|
+ "textContentVerticalAlign": "middle",
|
|
|
|
|
+ "qrCodeLevel": 0
|
|
|
|
|
+ },
|
|
|
|
|
+ "printElementType": {
|
|
|
|
|
+ "title": "文本",
|
|
|
|
|
+ "type": "text"
|
|
|
|
|
+ }
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "options": {
|
|
|
|
|
+ "left": 19.5,
|
|
|
|
|
+ "top": 9,
|
|
|
|
|
+ "height": 30,
|
|
|
|
|
+ "width": 177,
|
|
|
|
|
+ "right": 197.24478149414062,
|
|
|
|
|
+ "bottom": 39,
|
|
|
|
|
+ "vCenter": 108.74478149414062,
|
|
|
|
|
+ "hCenter": 24
|
|
|
|
|
+ },
|
|
|
|
|
+ "printElementType": {
|
|
|
|
|
+ "title": "图片",
|
|
|
|
|
+ "type": "image"
|
|
|
|
|
+ }
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "options": {
|
|
|
|
|
+ "left": 253.5,
|
|
|
|
|
+ "top": 55.5,
|
|
|
|
|
+ "height": 15,
|
|
|
|
|
+ "width": 120,
|
|
|
|
|
+ "title": "2024年11月",
|
|
|
|
|
+ "field": "riqi",
|
|
|
|
|
+ "coordinateSync": false,
|
|
|
|
|
+ "widthHeightSync": false,
|
|
|
|
|
+ "fontSize": 10.5,
|
|
|
|
|
+ "textAlign": "center",
|
|
|
|
|
+ "textContentVerticalAlign": "middle",
|
|
|
|
|
+ "qrCodeLevel": 0,
|
|
|
|
|
+ "right": 373.48956298828125,
|
|
|
|
|
+ "bottom": 70.48957443237305,
|
|
|
|
|
+ "vCenter": 313.48956298828125,
|
|
|
|
|
+ "hCenter": 62.98957443237305
|
|
|
|
|
+ },
|
|
|
|
|
+ "printElementType": {
|
|
|
|
|
+ "title": "文本",
|
|
|
|
|
+ "type": "text"
|
|
|
|
|
+ }
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "options": {
|
|
|
|
|
+ "left": 0,
|
|
|
|
|
+ "top": 61.5,
|
|
|
|
|
+ "height": 13.5,
|
|
|
|
|
+ "width": 67.5,
|
|
|
|
|
+ "title": "部门名称:",
|
|
|
|
|
+ "right": 79.49217224121094,
|
|
|
|
|
+ "bottom": 74.9999885559082,
|
|
|
|
|
+ "vCenter": 35.99217224121094,
|
|
|
|
|
+ "hCenter": 68.2499885559082,
|
|
|
|
|
+ "coordinateSync": false,
|
|
|
|
|
+ "widthHeightSync": false,
|
|
|
|
|
+ "fontSize": 15,
|
|
|
|
|
+ "fontWeight": "bolder",
|
|
|
|
|
+ "textAlign": "center",
|
|
|
|
|
+ "textContentVerticalAlign": "middle",
|
|
|
|
|
+ "qrCodeLevel": 0
|
|
|
|
|
+ },
|
|
|
|
|
+ "printElementType": {
|
|
|
|
|
+ "title": "文本",
|
|
|
|
|
+ "type": "text"
|
|
|
|
|
+ }
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "options": {
|
|
|
|
|
+ "left": 66,
|
|
|
|
|
+ "top": 61.5,
|
|
|
|
|
+ "height": 13.5,
|
|
|
|
|
+ "width": 78,
|
|
|
|
|
+ "title": "凹印车间",
|
|
|
|
|
+ "right": 133.49478149414062,
|
|
|
|
|
+ "bottom": 74.99740219116211,
|
|
|
|
|
+ "vCenter": 99.74478149414062,
|
|
|
|
|
+ "hCenter": 68.24740219116211,
|
|
|
|
|
+ "field": "bm",
|
|
|
|
|
+ "coordinateSync": false,
|
|
|
|
|
+ "widthHeightSync": false,
|
|
|
|
|
+ "fontSize": 15,
|
|
|
|
|
+ "fontWeight": "bolder",
|
|
|
|
|
+ "textAlign": "center",
|
|
|
|
|
+ "textContentVerticalAlign": "middle",
|
|
|
|
|
+ "qrCodeLevel": 0
|
|
|
|
|
+ },
|
|
|
|
|
+ "printElementType": {
|
|
|
|
|
+ "title": "文本",
|
|
|
|
|
+ "type": "text"
|
|
|
|
|
+ }
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "options": {
|
|
|
|
|
+ "left": 7.5,
|
|
|
|
|
+ "top": 111,
|
|
|
|
|
+ "height": 64.5,
|
|
|
|
|
+ "width": 555,
|
|
|
|
|
+ "field": "table",
|
|
|
|
|
+ "coordinateSync": false,
|
|
|
|
|
+ "widthHeightSync": false,
|
|
|
|
|
+ "right": 562.5,
|
|
|
|
|
+ "bottom": 176.24218368530273,
|
|
|
|
|
+ "vCenter": 285,
|
|
|
|
|
+ "hCenter": 143.99218368530273,
|
|
|
|
|
+ "tableHeaderRowHeight": 30,
|
|
|
|
|
+ "tableBodyRowHeight": 30,
|
|
|
|
|
+ "rowsColumnsMerge": "function (data, col, colIndex, rowIndex) {\n // 1. 获取当前行数据\n const rowData = (data.table || data)[rowIndex];\n \n // 2. 从行数据或顶层获取合并参数\n const mergeRowCount = rowData?._hiprintMergeInfo?.mergeRowCount || \n data?._hiprintOptions?.mergeRowCount || \n 0;\n \n // 3. 合并第一列\n if (colIndex === 0) {\n if (rowIndex === 0 && mergeRowCount > 1) {\n console.log(`合并第${rowIndex}行,合并${mergeRowCount}行`);\n return [mergeRowCount, 1];\n }\n if (rowIndex < mergeRowCount) {\n console.log(`隐藏第${rowIndex}行`);\n return [0, 1];\n }\n }\n \n // 4. 特殊行样式\n if (mergeRowCount > 0 && \n (rowIndex === mergeRowCount || rowIndex === mergeRowCount + 2)) {\n return {\n rowspan: 1,\n colspan: 1,\n style: {\n 'background-color': '#FFD700 !important',\n 'border': 'none !important',\n 'font-weight': 'bold !important'\n }\n };\n }\n \n // 5. 默认不合并\n return [1, 1];\n}",
|
|
|
|
|
+ "cellStyle": "function (data, rowIndex, colIndex) {\n // 1. 获取合并行数\n const mergeRowCount = data._hiprint_mergeRowCount || \n (data.table && data.table._mergeRowCount) || \n 0;\n \n // 2. 特殊行样式\n if (mergeRowCount > 0 && \n (rowIndex === mergeRowCount || rowIndex === mergeRowCount + 2)) {\n return {\n 'background-color': '#FFD700 !important',\n 'border': 'none !important',\n 'font-weight': 'bold !important'\n };\n }\n return null;\n}",
|
|
|
|
|
+ "rowsColumnsMergeClean": true,
|
|
|
|
|
+ "tableHeaderRepeat": "first",
|
|
|
|
|
+ "columns": [
|
|
|
|
|
+ [{
|
|
|
|
|
+ "width": 69.87094821428565,
|
|
|
|
|
+ "title": "费用<br/>类型",
|
|
|
|
|
+ "field": "type",
|
|
|
|
|
+ "checked": true,
|
|
|
|
|
+ "columnId": "type",
|
|
|
|
|
+ "fixed": false,
|
|
|
|
|
+ "rowspan": 1,
|
|
|
|
|
+ "colspan": 1,
|
|
|
|
|
+ "align": "center",
|
|
|
|
|
+ "tableColumnHeight": "30",
|
|
|
|
|
+ "tableTextType": "text",
|
|
|
|
|
+ "tableBarcodeMode": "CODE128A",
|
|
|
|
|
+ "tableQRCodeLevel": 0,
|
|
|
|
|
+ "tableSummaryTitle": true,
|
|
|
|
|
+ "tableSummary": ""
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "width": 148.38682500000007,
|
|
|
|
|
+ "title": "设备或科目名称",
|
|
|
|
|
+ "field": "id",
|
|
|
|
|
+ "checked": true,
|
|
|
|
|
+ "columnId": "id",
|
|
|
|
|
+ "fixed": false,
|
|
|
|
|
+ "rowspan": 1,
|
|
|
|
|
+ "colspan": 1,
|
|
|
|
|
+ "align": "center",
|
|
|
|
|
+ "tableColumnHeight": "30",
|
|
|
|
|
+ "tableTextType": "text",
|
|
|
|
|
+ "tableBarcodeMode": "CODE128A",
|
|
|
|
|
+ "tableQRCodeLevel": 0,
|
|
|
|
|
+ "tableSummaryTitle": true,
|
|
|
|
|
+ "tableSummary": ""
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "width": 91.0100303571429,
|
|
|
|
|
+ "title": "耗电量",
|
|
|
|
|
+ "field": "name2",
|
|
|
|
|
+ "checked": true,
|
|
|
|
|
+ "columnId": "name2",
|
|
|
|
|
+ "fixed": false,
|
|
|
|
|
+ "rowspan": 1,
|
|
|
|
|
+ "colspan": 1,
|
|
|
|
|
+ "align": "center",
|
|
|
|
|
+ "tableColumnHeight": "30",
|
|
|
|
|
+ "tableTextType": "text",
|
|
|
|
|
+ "tableBarcodeMode": "CODE128A",
|
|
|
|
|
+ "tableQRCodeLevel": 0,
|
|
|
|
|
+ "tableSummaryTitle": true,
|
|
|
|
|
+ "tableSummary": ""
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "width": 43.62438750000005,
|
|
|
|
|
+ "title": "电价",
|
|
|
|
|
+ "field": "time",
|
|
|
|
|
+ "checked": true,
|
|
|
|
|
+ "columnId": "time",
|
|
|
|
|
+ "fixed": false,
|
|
|
|
|
+ "rowspan": 1,
|
|
|
|
|
+ "colspan": 1,
|
|
|
|
|
+ "align": "center",
|
|
|
|
|
+ "tableColumnHeight": "30",
|
|
|
|
|
+ "tableTextType": "text",
|
|
|
|
|
+ "tableBarcodeMode": "CODE128A",
|
|
|
|
|
+ "tableQRCodeLevel": 0,
|
|
|
|
|
+ "tableSummaryTitle": true,
|
|
|
|
|
+ "tableSummary": ""
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "width": 57.384487500000006,
|
|
|
|
|
+ "title": "耗气量",
|
|
|
|
|
+ "field": "score",
|
|
|
|
|
+ "checked": true,
|
|
|
|
|
+ "columnId": "score",
|
|
|
|
|
+ "fixed": false,
|
|
|
|
|
+ "rowspan": 1,
|
|
|
|
|
+ "colspan": 1,
|
|
|
|
|
+ "align": "center",
|
|
|
|
|
+ "tableColumnHeight": "30",
|
|
|
|
|
+ "tableTextType": "text",
|
|
|
|
|
+ "tableBarcodeMode": "CODE128A",
|
|
|
|
|
+ "tableQRCodeLevel": 0,
|
|
|
|
|
+ "tableSummaryTitle": true,
|
|
|
|
|
+ "tableSummary": ""
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "width": 65.43760714285709,
|
|
|
|
|
+ "title": "气价",
|
|
|
|
|
+ "field": "start",
|
|
|
|
|
+ "checked": true,
|
|
|
|
|
+ "columnId": "start",
|
|
|
|
|
+ "fixed": false,
|
|
|
|
|
+ "rowspan": 1,
|
|
|
|
|
+ "colspan": 1,
|
|
|
|
|
+ "align": "center",
|
|
|
|
|
+ "tableColumnHeight": "30",
|
|
|
|
|
+ "tableTextType": "text",
|
|
|
|
|
+ "tableBarcodeMode": "CODE128A",
|
|
|
|
|
+ "tableQRCodeLevel": 0,
|
|
|
|
|
+ "tableSummaryTitle": true,
|
|
|
|
|
+ "tableSummary": ""
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "width": 79.28571428571428,
|
|
|
|
|
+ "title": "费用合计",
|
|
|
|
|
+ "field": "tName2",
|
|
|
|
|
+ "checked": true,
|
|
|
|
|
+ "columnId": "tName2",
|
|
|
|
|
+ "fixed": false,
|
|
|
|
|
+ "rowspan": 1,
|
|
|
|
|
+ "colspan": 1,
|
|
|
|
|
+ "align": "center",
|
|
|
|
|
+ "tableColumnHeight": "30",
|
|
|
|
|
+ "tableTextType": "text",
|
|
|
|
|
+ "tableBarcodeMode": "CODE128A",
|
|
|
|
|
+ "tableQRCodeLevel": 0,
|
|
|
|
|
+ "tableSummaryTitle": true,
|
|
|
|
|
+ "tableSummary": ""
|
|
|
|
|
+ }]
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ "printElementType": {
|
|
|
|
|
+ "title": "订单数据",
|
|
|
|
|
+ "type": "table",
|
|
|
|
|
+ "editable": true,
|
|
|
|
|
+ "columnDisplayEditable": true,
|
|
|
|
|
+ "columnDisplayIndexEditable": true,
|
|
|
|
|
+ "columnTitleEditable": true,
|
|
|
|
|
+ "columnResizable": true,
|
|
|
|
|
+ "columnAlignEditable": true,
|
|
|
|
|
+ "isEnableEditField": true,
|
|
|
|
|
+ "isEnableContextMenu": true,
|
|
|
|
|
+ "isEnableInsertRow": true,
|
|
|
|
|
+ "isEnableDeleteRow": true,
|
|
|
|
|
+ "isEnableInsertColumn": true,
|
|
|
|
|
+ "isEnableDeleteColumn": true,
|
|
|
|
|
+ "isEnableMergeCell": true
|
|
|
|
|
+ }
|
|
|
|
|
+ }],
|
|
|
|
|
+ "paperNumberLeft": 568.5,
|
|
|
|
|
+ "paperNumberTop": 339,
|
|
|
|
|
+ "paperNumberDisabled": true,
|
|
|
|
|
+ "paperNumberContinue": true,
|
|
|
|
|
+ "watermarkOptions": {
|
|
|
|
|
+ "content": "vue-plugin-hiprint",
|
|
|
|
|
+ "rotate": 25,
|
|
|
|
|
+ "timestamp": true,
|
|
|
|
|
+ "format": "YYYY-MM-DD HH:mm"
|
|
|
|
|
+ },
|
|
|
|
|
+ "panelLayoutOptions": {}
|
|
|
|
|
+ }]
|
|
|
|
|
+}
|
|
|
|
|
+const onforms = () => {
|
|
|
|
|
+ const hiprintTemplate = new hiprint.PrintTemplate({
|
|
|
|
|
+ template: jsondata
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 准备打印数据(关键修改)
|
|
|
|
|
+ const printData = {
|
|
|
|
|
+ // 1. 保持table字段结构
|
|
|
|
|
+ table: JSON.parse(JSON.stringify(_table_print.value[0].data)),
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 合并参数必须附加到每行数据上
|
|
|
|
|
+ _hiprintOptions: {
|
|
|
|
|
+ mergeRowCount: _table_print.value[0].mergeRowCount
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 其他模板字段
|
|
|
|
|
+ riqi: "2024年11月",
|
|
|
|
|
+ bm: "凹印车间"
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 将合并参数注入到每行数据(关键步骤)
|
|
|
|
|
+ printData.table.forEach(row => {
|
|
|
|
|
+ row._hiprintMergeInfo = {
|
|
|
|
|
+ mergeRowCount: _table_print.value[0].mergeRowCount
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ console.log("最终打印数据:", JSON.stringify(printData, null, 2));
|
|
|
|
|
+ hiprintTemplate.print(printData);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|