const Fontweight = [ { text: 'normal', value: 'normal' }, { text: 'bold', value: 'bold' }, { text: 'bolder', value: 'bolder' }, { text: 'lighter', value: 'lighter' } ] const Color = [ { text: '黑色', value: 'black' }, { text: '红色', value: 'red' }, { text: '灰色', value: 'gray' }, { text: '蓝色', value: 'blue' }, { text: '绿色', value: 'green' }, { text: '白色', value: 'white' } ] const Fontfamily = [ { text: '宋体', value: 'SimSun' }, { text: '微软雅黑', value: 'Microsoft YaHei' }, { text: '黑体', value: 'SimHei' }, { text: '微软正黑体', value: 'Microsoft JhengHei' }, { text: '新宋体', value: 'NSimSun' }, { text: '仿宋', value: 'FangSong' }, { text: '楷体', value: 'KaiTi' } ] const Rotate = [ { text: '0度', value: 0 }, { text: '90度', value: 90 }, { text: '180度', value: 180 }, { text: '270度', value: 270 } ] const Align = [ { text: '左对齐', value: 'left' }, { text: '右对齐', value: 'right' }, { text: '居中对齐', value: 'center' }, { text: '两端对齐', value: 'justify' } ] const Barcodealign = [ { text: '左对齐', value: 'left' }, { text: '右对齐', value: 'right' }, { text: '居中对齐', value: 'center' } ] const VertialAlign = [ { text: '顶部对齐', value: 'top' }, { text: '底部对齐', value: 'bottom' }, { text: '居中对齐', value: 'middle' } ] const BarcodeType = [ { text: 'code128', value: 'code128' }, { text: 'EAN13', value: 'EAN13' } ] const Boolen = [ { text: '显示', value: 'true' }, { text: '隐藏', value: 'false' } ] const QrcodeType = [ { text: 'qrcode', value: 'qrcode' }, { text: 'datamatrix', value: 'datamatrix' } ] // 模板元素 export const printItems = [ { type: 'print', label: '文 本', subType: 'text', icon: 'file-text' }, { type: 'print', label: '条形码', subType: 'barcode', icon: 'barcode' }, { type: 'print', label: '二维码', subType: 'qrcode', icon: 'qrcode' }, { type: 'print', label: '图 片', subType: 'image', icon: 'file-image' } ] // 模板元素 export const originConfig = { name: '', remark: '', papertype: 'resize', width: 210, height: 297, isreadonly: false, PrintTempNO: '', elements: [] } export function getpageform (config) { return [ { type: 'text', key: 'name', label: '模板名称', initval: config.name, required: true }, { type: 'textarea', key: 'remark', label: '描述', initval: config.remark, required: false }, { type: 'select', key: 'papertype', label: '纸张类型', initval: config.papertype, required: true, options: [{ text: 'A0', value: 'A0', width: 841, height: 1189 }, { text: 'A1', value: 'A1', width: 594, height: 841 }, { text: 'A2', value: 'A2', width: 420, height: 594 }, { text: 'A3', value: 'A3', width: 297, height: 420 }, { text: 'A4', value: 'A4', width: 210, height: 297 }, { text: '80x50', value: '80x50', width: 80, height: 50 }, { text: '60x40', value: '60x40', width: 60, height: 40 }, { text: '自定义', value: 'resize', width: 210, height: 297 }] }, { type: 'number', key: 'width', label: '宽度', initval: config.width, min: 1, required: true }, { type: 'number', key: 'height', label: '高度', initval: config.height, min: 1, required: true }, { type: 'select', key: 'rotate', label: '旋转角度', initval: config.rotate || 0, required: false, options: Rotate }, { type: 'number', key: 'gap', label: '间隙', initval: config.gap || '', tooltip: 'RFID标签间隙。', min: 0, required: false } ] } export function getElement (type, uuid, cx, cy, width, height, url, boxwidth) { let item = { uuid: uuid, type: type, name: '', field: '', left: cx, top: cy, width: width, height: height, rotate: 0, borderSize: 1, borderColor: 'black', align: 'center', vertialAlign: 'middle', background: 'white' } if (type === 'text') { item.value = '' item.fontSize = 12 item.fontWeight = 'normal' item.fontColor = 'black' item.fontFamily = 'SimSun' item.padding = 1 item.align = 'left' item.vertialAlign = 'top' } else if (type === 'barcode') { item.value = '' item.url = url item.barcodeType = 'code128' item.barcodeWidth = Math.floor(width * 0.6) item.barcodeHeight = Math.floor(height * 0.4) item.barcodeLabel = 'true' item.fontSize = Math.floor(12 * (boxwidth / 210)) } else if (type === 'qrcode') { item.value = '' item.url = url item.qrcodeType = 'qrcode' item.qrcodeWidth = Math.floor(height * 0.6) } else if (type === 'image') { item.url = url item.imgWidth = Math.floor(width * 0.6) item.imgHeight = Math.floor(height * 0.5) } return item } export function getTextForm (item, fields) { return [ { type: 'title', label: '类型', initval: '文本', class: 'text', required: false }, { type: 'text', key: 'name', label: '名称', initval: item.name || '', required: false }, { type: 'textarea', key: 'value', label: '内容', initval: item.value || '', required: false }, { type: 'select', key: 'field', label: '关联字段', initval: item.field || '', required: false, options: fields }, { type: 'text', key: 'cusfield', label: '自定义', initval: item.cusfield || '', required: true, hidden: true }, { type: 'number', key: 'left', label: '距左', initval: item.left, precision: 0, required: true }, { type: 'number', key: 'top', label: '距上', initval: item.top, precision: 0, required: true }, { type: 'number', key: 'width', label: '宽度', initval: item.width, precision: 0, required: true }, { type: 'number', key: 'height', label: '高度', initval: item.height, precision: 0, required: true }, { type: 'number', key: 'fontSize', label: '字体大小', initval: item.fontSize, precision: 0, required: true }, { type: 'select', key: 'fontWeight', label: '字体粗细', initval: item.fontWeight, required: false, options: Fontweight }, { type: 'select', key: 'fontColor', label: '字体颜色', initval: item.fontColor, required: false, options: Color }, { type: 'select', key: 'fontFamily', label: '字体名称', initval: item.fontFamily, required: false, options: Fontfamily }, // { // type: 'select', // key: 'rotate', // label: '旋转角度', // initval: item.rotate, // required: false, // options: Rotate // }, { type: 'number', key: 'borderSize', label: '边框宽度', initval: item.borderSize, tooltip: '注:边框宽度的计量单位是正常值的十分之一。', precision: 1, required: true }, { type: 'select', key: 'borderColor', label: '边框颜色', initval: item.borderColor, required: false, options: Color }, { type: 'number', key: 'padding', label: '边距', initval: item.padding, precision: 1, required: true }, { type: 'select', key: 'align', label: '水平对齐', initval: item.align, required: false, options: Align }, { type: 'select', key: 'vertialAlign', label: '垂直对齐', initval: item.vertialAlign, required: false, options: VertialAlign }, { type: 'select', key: 'background', label: '背景色', initval: item.background, required: false, options: Color } ] } export function getBarcodeForm (item, fields) { return [ { type: 'title', label: '类型', initval: '条形码', class: 'barcode', required: false }, { type: 'text', key: 'name', label: '名称', initval: item.name, required: false }, { type: 'text', key: 'value', label: '内容', initval: item.value || '', required: false }, { type: 'select', key: 'field', label: '关联字段', initval: item.field, required: false, options: fields }, { type: 'text', key: 'cusfield', label: '自定义', initval: item.cusfield || '', required: true, hidden: true }, { type: 'number', key: 'left', label: '距左', initval: item.left, precision: 0, required: true }, { type: 'number', key: 'top', label: '距上', initval: item.top, precision: 0, required: true }, { type: 'number', key: 'width', label: '宽度', initval: item.width, precision: 0, required: true }, { type: 'number', key: 'height', label: '高度', initval: item.height, precision: 0, required: true }, // { // type: 'select', // key: 'rotate', // label: '旋转角度', // initval: item.rotate, // required: false, // options: Rotate // }, { type: 'number', key: 'borderSize', label: '边框宽度', initval: item.borderSize, tooltip: '注:边框宽度的计量单位是正常值的十分之一。', precision: 1, required: true }, { type: 'select', key: 'borderColor', label: '边框颜色', initval: item.borderColor, required: false, options: Color }, { type: 'select', key: 'align', label: '水平对齐', initval: item.align, required: false, options: Barcodealign }, { type: 'select', key: 'vertialAlign', label: '垂直对齐', initval: item.vertialAlign, required: false, options: VertialAlign }, { type: 'select', key: 'barcodeType', label: '编码类型', initval: item.barcodeType, required: true, options: BarcodeType }, { type: 'number', key: 'barcodeWidth', label: '条码宽度', initval: item.barcodeWidth, precision: 0, required: true }, { type: 'number', key: 'barcodeHeight', label: '条码高度', initval: item.barcodeHeight, precision: 0, required: true }, { type: 'select', key: 'barcodeLabel', label: '条码标识', initval: item.barcodeLabel, required: true, options: Boolen }, { type: 'number', key: 'fontSize', label: '字体大小', initval: item.fontSize, precision: 0, required: true }, { type: 'number', key: 'narrowWidth', label: '单元宽度', initval: item.narrowWidth, tooltip: '注:RFID条码单元宽度,默认值为2。', precision: 0, required: false }, { type: 'select', key: 'background', label: '背景色', initval: item.background, required: false, options: Color } ] } export function getQrcodeForm (item, fields) { return [ { type: 'title', label: '类型', initval: '二维码', class: 'qrcode', required: false }, { type: 'text', key: 'name', label: '名称', initval: item.name, required: false }, { type: 'text', key: 'value', label: '内容', initval: item.value || '', required: false }, { type: 'select', key: 'field', label: '关联字段', initval: item.field, required: false, options: fields }, { type: 'text', key: 'cusfield', label: '自定义', initval: item.cusfield || '', required: true, hidden: true }, { type: 'number', key: 'left', label: '距左', initval: item.left, precision: 0, required: true }, { type: 'number', key: 'top', label: '距上', initval: item.top, precision: 0, required: true }, { type: 'number', key: 'width', label: '宽度', initval: item.width, precision: 0, required: true }, { type: 'number', key: 'height', label: '高度', initval: item.height, precision: 0, required: true }, // { // type: 'select', // key: 'rotate', // label: '旋转角度', // initval: item.rotate, // required: false, // options: Rotate // }, { type: 'number', key: 'borderSize', label: '边框宽度', initval: item.borderSize, tooltip: '注:边框宽度的计量单位是正常值的十分之一。', precision: 1, required: true }, { type: 'select', key: 'borderColor', label: '边框颜色', initval: item.borderColor, required: false, options: Color }, { type: 'select', key: 'align', label: '水平对齐', initval: item.align, required: false, options: Barcodealign }, { type: 'select', key: 'vertialAlign', label: '垂直对齐', initval: item.vertialAlign, required: false, options: VertialAlign }, { type: 'select', key: 'qrcodeType', label: '编码类型', initval: item.qrcodeType, required: true, options: QrcodeType }, { type: 'number', key: 'qrcodeWidth', label: '边长', initval: item.qrcodeWidth, precision: 0, required: true }, { type: 'select', key: 'background', label: '背景色', initval: item.background, required: false, options: Color } ] } export function getImageForm (item, fields) { return [ { type: 'title', label: '类型', initval: '图片', class: 'image', required: false }, { type: 'text', key: 'name', label: '名称', initval: item.name, required: false }, { type: 'fileupload', key: 'value', label: '图片地址', initval: item.value, required: false }, { type: 'textarea', key: 'productValue', label: '正式地址', initval: item.productValue || '', tooltip: '正式系统使用的图片,为空时使用图片地址。', required: false }, { type: 'select', key: 'field', label: '关联字段', initval: item.field, required: false, options: fields }, { type: 'text', key: 'cusfield', label: '自定义', initval: item.cusfield || '', required: true, hidden: true }, { type: 'number', key: 'left', label: '距左', initval: item.left, precision: 0, required: true }, { type: 'number', key: 'top', label: '距上', initval: item.top, precision: 0, required: true }, { type: 'number', key: 'width', label: '宽度', initval: item.width, precision: 0, required: true }, { type: 'number', key: 'height', label: '高度', initval: item.height, precision: 0, required: true }, // { // type: 'select', // key: 'rotate', // label: '旋转角度', // initval: item.rotate, // required: false, // options: Rotate // }, { type: 'number', key: 'borderSize', label: '边框宽度', initval: item.borderSize, tooltip: '注:边框宽度的计量单位是正常值的十分之一。', precision: 1, required: true }, { type: 'select', key: 'borderColor', label: '边框颜色', initval: item.borderColor, required: false, options: Color }, { type: 'select', key: 'align', label: '水平对齐', initval: item.align, required: false, options: Barcodealign }, { type: 'select', key: 'vertialAlign', label: '垂直对齐', initval: item.vertialAlign, required: false, options: VertialAlign }, { type: 'number', key: 'imgWidth', label: '图片宽度', initval: item.imgWidth, precision: 0, required: true }, { type: 'number', key: 'imgHeight', label: '图片高度', initval: item.imgHeight, precision: 0, required: true }, { type: 'select', key: 'background', label: '背景色', initval: item.background, required: false, options: Color } ] } export const barurl = require('@/assets/img/barcode.jpg') export const qrurl = require('@/assets/img/qrcode.png') export const imgurl = require('@/assets/img/shunfeng.jpg')