From 2ff447e7130469a026b4614bdbbe2573458dc213 Mon Sep 17 00:00:00 2001 From: zxx <47968546@163.com> Date: Sun, 3 Dec 2023 20:10:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/editors/MkFormDataSelector.vue | 124 +- .../Mes/MesMaterials/MesMaterials/Edit.vue | 74 +- .../Mes/MesMaterials/MesMaterials/List.vue | 70 +- .../Mes/MesMaterials/MesMaterials/index.vue | 3 +- .../Middle/Mes/MesStock/MesStock/List.vue | 3 +- .../Mes/MesStock/MesStock/OutIn/InList.vue | 183 +- .../Mes/MesStock/MesStock/OutIn/LogDetail.vue | 237 +- .../Mes/MesStock/MesStock/OutIn/OutList.vue | 149 +- .../Mes/MesStock/MesStock/OutIn/data.json | 2670 +++++++++++++++++ .../Mes/MesStock/MesStock/OutIn/preview.vue | 88 + .../Mes/MesStock/MesStock/OutIn/providers.js | 342 +++ .../MesStock/Position/PositionList.vue | 56 +- src/pages/Middle/Mold/basic/print.js | 102 +- src/pages/print_designer/custom/index.vue | 169 +- 14 files changed, 3859 insertions(+), 411 deletions(-) create mode 100644 src/pages/Middle/Mes/MesStock/MesStock/OutIn/data.json create mode 100644 src/pages/Middle/Mes/MesStock/MesStock/OutIn/preview.vue create mode 100644 src/pages/Middle/Mes/MesStock/MesStock/OutIn/providers.js diff --git a/src/application/mk/components/editors/MkFormDataSelector.vue b/src/application/mk/components/editors/MkFormDataSelector.vue index 3c3608c..95feb5c 100644 --- a/src/application/mk/components/editors/MkFormDataSelector.vue +++ b/src/application/mk/components/editors/MkFormDataSelector.vue @@ -3,27 +3,30 @@ + :height="modalHeight" v-model="modalVisible" @confirm="confirmEvent"> + :title-align="options.formOptions2.titleAlign" :rules="options.formOptions2.rules" + :items="options.formOptions2.items" titleColon> - - - + + - - - + -
确定 取消 @@ -64,8 +60,7 @@ export default { type: String, default: "edit" }, - dataId: { - } + dataId: {} }, data() { @@ -202,8 +197,7 @@ export default { isEdit: false, // 表单数据 formOptions: { - data: { - }, + data: {}, // 标题宽度 titleWidth: 150, // 标题对齐方式 @@ -232,6 +226,7 @@ export default { { field: 'code', title: '编号', span: 12, itemRender: { name: '$input' } }, { field: 'name', title: '名称', span: 12, itemRender: { name: '$input' } }, { title: '分类', span: 12, slots: { default: 'sort_id' } }, + { field: 'price', title: '单价', dataRule: { type: 'number' }, span: 12, itemRender: { name: '$input', props: { type: "number" } } }, { field: 'size', title: '尺寸', span: 12, itemRender: { name: '$input' } }, { @@ -423,34 +418,23 @@ export default { }, - - - ] }, // 新增模式表单项 - addModeItems: [ - - ], + addModeItems: [], formOptions2Done: false, formOptions2: { - data: { - - }, + data: {}, // 标题宽度 titleWidth: 150, // 标题对齐方式 titleAlign: 'right', // 表单校验规则 - rules: { - - }, + rules: {}, // 表单项 - items: [ - - ] + items: [] }, @@ -499,11 +483,15 @@ export default { a.data.attribute.forEach(item => { let formItem = { field: '', title: '', span: 12, itemRender: {} }; - let groupName = item.category.name; - if(groupName && !groupNames.filter(a=>a == groupName).length){ - - this.options.formOptions2.items.push({ span: 24, itemRender: { name:"MkFormInputShow" ,props:{ showType:"divider",header:groupName } },showTitle:false }); - groupNames.push(groupName); + let groupName = item.category.name; + if (groupName && !groupNames.filter(a => a == groupName).length) { + + this.options.formOptions2.items.push({ + span: 24, + itemRender: { name: "MkFormInputShow", props: { showType: "divider", header: groupName } }, + showTitle: false + }); + groupNames.push(groupName); } formItem.field = "attr" + item.id; @@ -514,8 +502,7 @@ export default { formItem.itemRender.name = "$input"; formData[formItem.field] = 0; - } - else if (item.typeName == "3" || + } else if (item.typeName == "3" || item.typeName == "4" || item.typeName == "5") { @@ -523,16 +510,14 @@ export default { formItem.itemRender.props = { type: "date" }; formData[formItem.field] = ''; - } - else if (item.typeName == "6") { + } else if (item.typeName == "6") { formItem.itemRender.name = "$select"; formItem.itemRender.options = getOptions(item.id); if (!formItem.itemRender.options.length) { return; } formData[formItem.field] = formItem.itemRender.options[0].value; - } - else if (item.typeName == "7") { + } else if (item.typeName == "7") { formItem.itemRender.name = "$switch"; formItem.itemRender.props = { openLabel: '是', openValue: "true", closeValue: "false", closeLabel: '否' }; @@ -565,9 +550,6 @@ export default { dataInit() { - - - // 获取路由的id参数 let dataId = this.getDataId(); // 如果有id参数,说明是编辑模式 @@ -754,7 +736,7 @@ export default { this.back(); } }).catch((a) => { // 失败回调 - console.log("a.data.code"+a) + console.log("a.data.code" + a) this.$mk.error(a.data.msg); // 显示错误信息 }); @@ -806,13 +788,11 @@ export default { }, }, // 监听属性 - watch: { - - } + watch: {} }; - + diff --git a/src/pages/Middle/Mes/MesStock/MesStock/OutIn/providers.js b/src/pages/Middle/Mes/MesStock/MesStock/OutIn/providers.js new file mode 100644 index 0000000..94000d1 --- /dev/null +++ b/src/pages/Middle/Mes/MesStock/MesStock/OutIn/providers.js @@ -0,0 +1,342 @@ +/* eslint-disable */ + + +// 自定义设计元素1 +export const aProvider = function (ops) { + var addElementTypes = function (context) { + context.removePrintElementTypes("aProviderModule"); // 移除已有的元素 + context.addPrintElementTypes( // 添加新的元素 + "aProviderModule", + [ + new this.$hiPrint.PrintElementTypeGroup("基本数据", [ + { + tid: 'aProviderModule.printDate', title: '打印时间', data: '2022-01-01 09:00', type: 'text', + options: { + field: 'printDate', + testData: '2022-01-01 09:00', + height: 16, + fontSize: 6.75, + fontWeight: "700", + textAlign: "left", + textContentVerticalAlign: "middle" + } + }, + { + tid: 'aProviderModule.customer_name', title: '客户名称', data: '', type: 'text', + options: { + title: '客户名称:', + testData: '李四', + field: 'data.product_stock_log.customer_name', + height: 16, + fontSize: 12, + fontWeight: "700", + textAlign: "left", + textContentVerticalAlign: "middle" + } + }, + { + tid: 'aProviderModule.customer_phone', title: '联系电话', data: '', type: 'text', + options: { + title: '联系电话:', + testData: '13800138000', + field: 'data.product_stock_log.customer_phone', + height: 16, + fontSize: 12, + fontWeight: "700", + textAlign: "left", + textContentVerticalAlign: "middle" + } + }, + { + tid: 'aProviderModule.customer_address', title: '联系地址', data: '', type: 'text', + options: { + title: '联系地址:', + testData: '潮州市浮洋镇潮汕公路乌洋路段', + field: 'data.product_stock_log.customer_address', + height: 16, + fontSize: 12, + fontWeight: "700", + textAlign: "left", + textContentVerticalAlign: "middle" + } + }, + { + tid: 'aProviderModule.code', title: '单据编号', data: '', type: 'text', + options: { + title: '单据编号:', + field: 'data.product_stock_log.code', + height: 16, + fontSize: 12, + fontWeight: "700", + textAlign: "left", + textContentVerticalAlign: "middle" + } + }, + { + tid: 'aProviderModule.creater', title: '制单人', data: '吴淑银', type: 'text', + options: { + title: '制单人:', + testData: '张三', + field: 'data.product_stock_log.out_user_name', + height: 16, + fontSize: 16, + fontWeight: "700", + textAlign: "left", + textContentVerticalAlign: "middle" + } + }, + { + tid: 'aProviderModule.signer', title: '送货人', data: '', type: 'text', + options: { + title: '送货人:', + height: 16, + fontSize: 16, + fontWeight: "700", + textAlign: "left", + textContentVerticalAlign: "middle" + } + }, + { + tid: 'aProviderModule.signer', title: '收货人', data: '', type: 'text', + options: { + title: '收货人:', + height: 16, + fontSize: 16, + fontWeight: "700", + textAlign: "left", + textContentVerticalAlign: "middle" + } + }, + ]), + new hiprint.PrintElementTypeGroup("表格/其他", [ + { + tid: 'aProviderModule.table', title: '出货单数据', + type: 'table', + options: { + field: 'data.table', + tableHeaderRepeat: 'first', // 表头重复方式 + tableFooterRepeat: 'last', // 表尾重复方式 + fields: [ + {text: "商品编号", field: "code"}, + {text: "商品名称", field: "name"}, + {text: "规格", field: "spec"}, + {text: "单位", field: "unit"}, + {text: "数量", field: "stock"}, + {text: "单价", field: "price"}, + {text: "金额", field: "total_price"}, + {text: "备注", field: "remark"} + ], + }, + editable: true, // 是否可编辑 + columnDisplayEditable: true,//列显示是否能编辑 + columnDisplayIndexEditable: true,//列顺序显示是否能编辑 + columnTitleEditable: true,//列标题是否能编辑 + columnResizable: true, //列宽是否能调整 + columnAlignEditable: true,//列对齐是否调整 + isEnableEditField: true, //编辑字段 + isEnableContextMenu: true, //开启右键菜单 默认true + isEnableInsertRow: true, //插入行 + isEnableDeleteRow: true, //删除行 + isEnableInsertColumn: true, //插入列 + isEnableDeleteColumn: true, //删除列 + isEnableMergeCell: true, //合并单元格 + columns: [ + [ + { + width: 84.61538461538461, + title: "商品编号", + field: "code", + columnId: "code", + checked: true, + fixed: false, + align: "center" + }, + { + width: 108.43929187999774, + title: "商品名称", + field: "name", + columnId: "name", + checked: true, + fixed: false, + align: "center" + }, + { + width: 57.83428900266546, + title: "规格", + field: "spec", + columnId: "spec", + checked: true, + fixed: false, + align: "center" + }, + { + width: 71.59763313609467, + title: "单位", + field: "unit", + columnId: "unit", + checked: true, + fixed: false, + align: "center" + }, + { + width: 60.58261265361857, + title: "数量", + field: "stock", + columnId: "stock", + checked: true, + fixed: false, + rowspan: 1, + colspan: 1, + align: "center" + }, + { + width: 51.26221070690802, + title: "单价", + field: "price", + columnId: "price", + checked: true, + fixed: false, + rowspan: 1, + colspan: 1, + align: "center" + }, + { + width: 43.3757167519991, + title: "金额", + field: "total_price", + columnId: "total_price", + checked: true, + fixed: false, + rowspan: 1, + colspan: 1, + align: "center" + }, + { + width: 72.29286125333182, + title: "备注", + field: "remark", + columnId: "remark", + checked: true, + fixed: false, + rowspan: 1, + colspan: 1, + align: "center" + } + ] + ], + + + // 表格行样式 + footerFormatter: function (options, rows, data, currentPageGridRowsData) { + // console.log("footerFormatter['options']:",options) + console.log("footerFormatter['rows']:", rows) + console.log("footerFormatter['data']:", data) + console.log("footerFormatter['currentPageGridRowsData']:", currentPageGridRowsData) + let total = 0; + currentPageGridRowsData.map((item, index) => { + total += item.total_price; + }) + // 转换为大写 + let digitUppercase = function (n) { + var fraction = ['角', '分']; + var digit = [ + '零', '壹', '贰', '叁', '肆', + '伍', '陆', '柒', '捌', '玖' + ]; + var unit = [ + ['元', '万', '亿'], + ['', '拾', '佰', '仟'] + ]; + var head = n < 0 ? '欠' : ''; + n = Math.abs(n); + var s = ''; + for (var i = 0; i < fraction.length; i++) { + s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, ''); + } + s = s || '整'; + n = Math.floor(n); + for (var i = 0; i < unit[0].length && n > 0; i++) { + var p = ''; + for (var j = 0; j < unit[1].length && n > 0; j++) { + p = digit[n % 10] + unit[1][j] + p; + n = Math.floor(n / 10); + } + s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s; + } + return head + s.replace(/(零.)*零元/, '元') + .replace(/(零.)+/g, '零') + .replace(/^整$/, '零元整'); + } + + // if (data && data['total_price']) { + // return `${'应收金额大写: ' + data['total_price']}` + // } + return '应收金额大写: ' + digitUppercase(total) + '' + }, + }, + ]), + new hiprint.PrintElementTypeGroup("辅助", + [ + // {tid: 'aProviderModule.logo', title: 'Logo', data: '', type: 'image'}, + + { + tid: 'aProviderModule.customText', + title: '文本', + customText: '自定义文本', + custom: true, + type: 'text' + }, + { + tid: 'aProviderModule.longText', title: '长文本', type: 'longText', options: { + field: 'test.longText', + width: 200, + testData: '长文本分页/不分页测试' + }, + }, + { + tid: 'aProviderModule.hline', + title: '横线', + type: 'hline' + }, + { + tid: 'aProviderModule.vline', + title: '竖线', + type: 'vline' + }, + { + tid: 'aProviderModule.rect', + title: '矩形', + type: 'rect' + }, + { + tid: 'aProviderModule.oval', + title: '椭圆', + type: 'oval' + }, + { + tid: 'aProviderModule.barcode', + title: '条形码', + type: 'barcode', + }, + { + tid: 'aProviderModule.qrcode', + title: '二维码', + type: 'qrcode', + } + ]) + ] + ); + }; + return { + addElementTypes: addElementTypes + }; +}; + + +// type: 1供货商 2经销商 +export default [{ + name: 'A设计', + value: 'aProviderModule', + type: 1, + f: aProvider() +}] diff --git a/src/pages/Middle/Mes/MesStock/MesStock/Position/PositionList.vue b/src/pages/Middle/Mes/MesStock/MesStock/Position/PositionList.vue index bed7f35..0a40982 100644 --- a/src/pages/Middle/Mes/MesStock/MesStock/Position/PositionList.vue +++ b/src/pages/Middle/Mes/MesStock/MesStock/Position/PositionList.vue @@ -29,7 +29,8 @@ export default { data() { return { pageOptions: {}, - warehouse_search: [] + warehouse_search: [], + warehouse_id: null, }; }, // 计算属性 @@ -84,7 +85,7 @@ export default { end_time: 0, // 结束时间 - //搜索区 +//搜索区 searchFormData: { warehouse_id: '', warehouse_pos_id: '', @@ -96,17 +97,13 @@ export default { {key: "warehouse_pos_id", mode: "="} ], - //搜索区 searchFormItems: [ // 子项 { field: 'materials', title: '料品', span: 4, itemRender: {name: '$input', props: {placeholder: '请输入料品'}} - }, - - - { + }, { title: '仓库', span: 5, field: 'warehouse_id', dataRule: { @@ -130,48 +127,16 @@ export default { onDataChanged: ({data}) => { console.log(data) - this.warehouse_search.clear(); - this.warehouse_search = [{ - column: "warehouse_id", - mode: "=", - value: data.id.toString() - }] + // this.pageOptions.searchFormItems.data.warehouse_pos_detail = {}; + // this.pageOptions.searchFormItems.data.warehouse_pos_id = null; + this.pageOptions.searchFormItems[2].itemRender.props.params.actionParams.search_rules[0].value = data.id.toString(); + this.pageOptions.searchFormItems[2].itemRender.props.params = JSON.parse(JSON.stringify(this.pageOptions.searchFormItems[2].itemRender.props.params)); this.$forceUpdate(); // 强制刷新 } } } } }, - { - title: '仓位', span: 5, - field: 'warehouse_pos_id', - dataRule: { - fromField: "id", - saveField: "warehouse_pos_id" - }, - itemRender: { - name: 'MkFormDataSelector', props: { - searchFieldNames: ["warehouse_id", "id"], - params: { - dataType: "object", - valueField: "id", - textField: "warehouse_location_name", - columns: [ - {field: 'warehouse_location_name', title: '名称'}, - {field: 'code', title: '编码'} - ], - isClickToLoad: true, - actionParams: { - search_rules: this.warehouse_search - }, - - - listdataFieldName: 'WarehouseLocation', - dataUrl: `${BASE_URL.BASE_URL}/MesWarehouse/v1/warehouse/location/list` - } - } - } - }, { align: 'right', span: 4, itemRender: { // 按钮列 @@ -202,11 +167,12 @@ export default { {field: 'warehouse_pos_idetail.name', sortable: true, title: '库位', width: 120}, // 库位信息 {field: 'product_detail.image', slots: {default: 'column2'}, sortable: true, title: '料品图片', width: 100}, // 产品详情 {field: 'product_detail.name', sortable: true, title: '料品名称', width: 250}, // 产品详情 - {field: 'product_detail.code', sortable: true, title: '料品编号', width: 150}, // 产品详情 + {field: 'product_detail.code', sortable: true, title: '料品编号', width: 120}, // 产品详情 + {field: 'product_detail.price', sortable: true, title: '单价(¥)', width: 120}, // 产品详情 + {field: 'stock', sortable: true, title: '库存数量', width: 100}, // 库存数量 {field: 'product_detail.spec', sortable: true, title: '规格型号', width: 150}, // 规格型号 {field: 'product_detail.size', sortable: true, title: '尺寸', width: 100}, // 尺寸 {field: 'product_detail.color', sortable: true, title: '颜色', width: 100}, // 颜色 - {field: 'stock', sortable: true, title: '库存数量', width: 100}, // 库存数量 { field: 'create_time', formatter: 'formatDate', diff --git a/src/pages/Middle/Mold/basic/print.js b/src/pages/Middle/Mold/basic/print.js index 66cf355..01d8b78 100644 --- a/src/pages/Middle/Mold/basic/print.js +++ b/src/pages/Middle/Mold/basic/print.js @@ -1,40 +1,92 @@ var config = { - - printTagConfig:{ + printTagConfig: { "name": "标签信息", "title": "标签信息", "fields": [{ - "name": "sequance", - "type": "string", - "title": "批次号" + "name": "sequance", + "type": "string", + "title": "批次号" }, { - "name": "voucherdate", - "type": "string", - "title": "单据日期" + "name": "voucherdate", + "type": "string", + "title": "单据日期" }, { - "name": "vouchercode", - "type": "string", - "title": "单据号" + "name": "vouchercode", + "type": "string", + "title": "单据号" }, { - "name": "departmentName", - "type": "string", - "title": "生产车间" + "name": "departmentName", + "type": "string", + "title": "生产车间" }, { - "name": "inventoryName", - "type": "string", - "title": "存货名称" + "name": "inventoryName", + "type": "string", + "title": "存货名称" }, { - "name": "quantity", - "type": "string", - "title": "数量" - }] - }, - - printTagTemplate:{"panels":[{"index":0,"name":1,"height":70,"width":60,"paperHeader":4.5,"paperFooter":190.5,"printElements":[{"options":{"left":10.5,"top":28.5,"height":17,"width":142.5,"field":"sequance","fontSize":21.75,"fontWeight":"400","textAlign":"center","hideTitle":true,"title":"批次号","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":153,"bottom":45.5,"vCenter":81.75,"hCenter":37,"lineHeight":27},"printElementType":{"title":"批次号","type":"text"}}],"paperNumberLeft":142.5,"paperNumberTop":199.5,"paperNumberDisabled":true}]} + "name": "quantity", + "type": "string", + "title": "数量" + }, { + "name": "table", + "type": "table", + "title": "table", + fields: [ + { + "name": "inventoryName", + "type": "string", + "title": "存货名称" + }, { + "name": "quantity", + "type": "string", + "title": "数量" + } - }; + ] + } + + + ] + }, + + printTagTemplate: { + "panels": [{ + "index": 0, + "name": 1, + "height": 70, + "width": 60, + "paperHeader": 4.5, + "paperFooter": 190.5, + "printElements": [{ + "options": { + "left": 10.5, + "top": 28.5, + "height": 17, + "width": 142.5, + "field": "sequance", + "fontSize": 21.75, + "fontWeight": "400", + "textAlign": "center", + "hideTitle": true, + "title": "批次号", + "coordinateSync": false, + "widthHeightSync": false, + "qrCodeLevel": 0, + "right": 153, + "bottom": 45.5, + "vCenter": 81.75, + "hCenter": 37, + "lineHeight": 27 + }, "printElementType": {"title": "批次号", "type": "text"} + }], + "paperNumberLeft": 142.5, + "paperNumberTop": 199.5, + "paperNumberDisabled": true + }] + } + +}; module.exports = config \ No newline at end of file diff --git a/src/pages/print_designer/custom/index.vue b/src/pages/print_designer/custom/index.vue index 4c183a0..221bf96 100644 --- a/src/pages/print_designer/custom/index.vue +++ b/src/pages/print_designer/custom/index.vue @@ -14,11 +14,11 @@
+ placeholder="宽(mm)"/> + placeholder="~" disabled/> + placeholder="高(mm)"/> 确定
@@ -27,7 +27,8 @@ + :formatter="value => `${(value * 100).toFixed(0)}%`" + :parser="value => value.replace('%', '')"/> @@ -35,10 +36,10 @@ 预览 - + 清空 - + @@ -68,7 +69,7 @@ - + @@ -76,14 +77,15 @@ import printPreview from './preview' -import { hiprint } from "vue-plugin-hiprint"; +import {hiprint} from "vue-plugin-hiprint"; import providers from './providers' import printData from './print-data' import $ from "jquery" + let hiprintTemplate; export default { name: "printCustom", - components: { printPreview }, + components: {printPreview}, data() { return { template: null, @@ -139,7 +141,7 @@ export default { let types = this.paperTypes for (const key in types) { let item = types[key] - let { width, height } = this.curPaper + let {width, height} = this.curPaper if (item.width === width && item.height === height) { type = key } @@ -154,7 +156,7 @@ export default { methods: { init() { this.modeList = providers.map((e) => { - return { type: e.type, name: e.name, value: e.value } + return {type: e.type, name: e.name, value: e.value} }) this.changeMode() }, @@ -167,7 +169,7 @@ export default { data.fields.forEach(field => { - if (field.type == "one2many" && field.fields) { + if ((field.type == "one2many" || field.type == "table") && field.fields) { let subFields = []; var columns = []; @@ -184,21 +186,21 @@ export default { }) }); elements2.push( - { - tid: 'bProviderModule.' + field.name, title: field.title, - type: 'table', - options: { - field: field.name, - fields: subFields, - }, - editable: true, - columnDisplayEditable: true,//列显示是否能编辑 - columnDisplayIndexEditable: true,//列顺序显示是否能编辑 - columnTitleEditable: true,//列标题是否能编辑 - columnResizable: true, //列宽是否能调整 - columnAlignEditable: true,//列对齐是否调整 - columns: [columns] - }); + { + tid: 'bProviderModule.' + field.name, title: field.title, + type: 'table', + options: { + field: field.name, + fields: subFields, + }, + editable: true, + columnDisplayEditable: true,//列显示是否能编辑 + columnDisplayIndexEditable: true,//列顺序显示是否能编辑 + columnTitleEditable: true,//列标题是否能编辑 + columnResizable: true, //列宽是否能调整 + columnAlignEditable: true,//列对齐是否调整 + columns: [columns] + }); return; @@ -224,46 +226,52 @@ export default { context.removePrintElementTypes("aProviderModule"); context.addPrintElementTypes( - "aProviderModule", [ + "aProviderModule", [ - new hiprint.PrintElementTypeGroup("常规", elements), + new hiprint.PrintElementTypeGroup("常规", elements), - new hiprint.PrintElementTypeGroup("表格/其他", [ - ...elements2, - { tid: 'bProviderModule.customText', title: '文本', customText: '自定义文本', custom: true, type: 'text' }, - { - tid: 'bProviderModule.longText', title: '长文本', type: 'longText', options: { - field: 'test.longText', - width: 200, - testData: '长文本分页/不分页测试' - }, - } - ]), + new hiprint.PrintElementTypeGroup("表格/其他", [ + ...elements2, + { + tid: 'bProviderModule.customText', + title: '文本', + customText: '自定义文本', + custom: true, + type: 'text' + }, + { + tid: 'bProviderModule.longText', title: '长文本', type: 'longText', options: { + field: 'test.longText', + width: 200, + testData: '长文本分页/不分页测试' + }, + } + ]), - new hiprint.PrintElementTypeGroup("辅助", [ - { - tid: 'aProviderModule.hline', - title: '横线', - type: 'hline' - }, - { - tid: 'aProviderModule.vline', - title: '竖线', - type: 'vline' - }, - { - tid: 'aProviderModule.rect', - title: '矩形', - type: 'rect' - }, - { - tid: 'aProviderModule.oval', - title: '椭圆', - type: 'oval' - } - ]) - ] + new hiprint.PrintElementTypeGroup("辅助", [ + { + tid: 'aProviderModule.hline', + title: '横线', + type: 'hline' + }, + { + tid: 'aProviderModule.vline', + title: '竖线', + type: 'vline' + }, + { + tid: 'aProviderModule.rect', + title: '矩形', + type: 'rect' + }, + { + tid: 'aProviderModule.oval', + title: '椭圆', + type: 'oval' + } + ]) + ] ); }; return { @@ -272,7 +280,7 @@ export default { }, changeMode() { - let { mode } = this + let {mode} = this let provider = providers[mode] console.log(provider) hiprint.init({ @@ -309,10 +317,10 @@ export default { setPaper(type, value) { try { if (Object.keys(this.paperTypes).includes(type)) { - this.curPaper = { type: type, width: value.width, height: value.height } + this.curPaper = {type: type, width: value.width, height: value.height} hiprintTemplate.setPaper(value.width, value.height) } else { - this.curPaper = { type: 'other', width: value.width, height: value.height } + this.curPaper = {type: 'other', width: value.width, height: value.height} hiprintTemplate.setPaper(value.width, value.height) } } catch (error) { @@ -342,21 +350,21 @@ export default { this.setPaper('other', value) }, preView() { - let { width } = this.curPaper + let {width} = this.curPaper this.$refs.preView.show(hiprintTemplate, printData, width) }, print() { if (window.hiwebSocket.opened) { const printerList = hiprintTemplate.getPrinterList(); console.log(printerList) - hiprintTemplate.print2(printData, { printer: '', title: 'hiprint测试打印' }); + hiprintTemplate.print2(printData, {printer: '', title: 'hiprint测试打印'}); return } this.$message.error('客户端未连接,无法直接打印') }, - initDesigner({ config, template }) { + initDesigner({config, template}) { if (!config || !config.fields || !config.fields.length) { return; @@ -392,29 +400,29 @@ export default { // 获取当前放大比例, 当zoom时传true 才会有 this.scaleValue = hiprintTemplate.editingPanel.scale || 1; }, - setValue({ value, config }) { - + setValue({value, config}) { + console.log(value, config) var a4 = { - width: 210, - height: 296.6 - }; - - this.curPaper = { type: value.PrintPage || "A4", width: value.Width || a4.width, height: value.Height || a4.height } + width: 210, + height: 296.6 + }; + + this.curPaper = {type: value.PrintPage || "A4", width: value.Width || a4.width, height: value.Height || a4.height} this.paperWidth = this.curPaper.width; this.pagerHeight = this.curPaper.heigth; let template = value.TemplateBody; - if(typeof(template) == 'string'){ + if (typeof (template) == 'string') { template = JSON.parse(template); } - this.initDesigner({ template: template, config: config }); + this.initDesigner({template: template, config: config}); }, getValue() { - let { width, height } = this.curPaper + let {width, height} = this.curPaper return { TemplateBody: hiprintTemplate.getJson(), PrintPage: this.curPaperType, @@ -442,7 +450,7 @@ export default {