| | |
| | | const jcapi = uni.requireNativePlugin("JCSDK-JCApiModule"); |
| | | // 精臣打印机原生插件。插件由 DCloud 账号绑定,账号未购买/未打入基座时不能抛错, |
| | | // 否则页面一加载就白屏,所以这里做容错加载,缺失时打印功能给出提示而不是崩溃。 |
| | | let jcapi = null; |
| | | let pluginMissing = false; |
| | | try { |
| | | jcapi = uni.requireNativePlugin("JCSDK-JCApiModule"); |
| | | if (!jcapi) { |
| | | pluginMissing = true; |
| | | } |
| | | } catch (e) { |
| | | pluginMissing = true; |
| | | } |
| | | |
| | | const PLUGIN_MISSING_MSG = "未检测到精臣打印插件,请确认打包时已购买并勾选该原生插件"; |
| | | |
| | | function requirePlugin() { |
| | | if (pluginMissing || !jcapi) { |
| | | uni.showToast({ title: PLUGIN_MISSING_MSG, icon: "none", duration: 3000 }); |
| | | return null; |
| | | } |
| | | return jcapi; |
| | | } |
| | | |
| | | let state = { |
| | | connectedDevice: null, |
| | |
| | | |
| | | /** 初始化(全局只需一次) */ |
| | | function init() { |
| | | jcapi.initSDK(); |
| | | const api = requirePlugin(); |
| | | if (!api) return; |
| | | |
| | | api.initSDK(); |
| | | |
| | | const saved = uni.getStorageSync("bluetoothConnection"); |
| | | if (saved) { |
| | |
| | | } |
| | | |
| | | // 断开监听 |
| | | jcapi.didReadPrintErrorInfo((r) => { |
| | | api.didReadPrintErrorInfo((r) => { |
| | | if (r.code === 23) { |
| | | state.connectedDevice = null; |
| | | state.connectionStatus = "disconnected"; |
| | |
| | | /** 搜索设备 */ |
| | | function searchDevices() { |
| | | return new Promise((resolve, reject) => { |
| | | const api = requirePlugin(); |
| | | if (!api) { |
| | | return reject(new Error(PLUGIN_MISSING_MSG)); |
| | | } |
| | | uni.openBluetoothAdapter({ |
| | | success() { |
| | | jcapi.getBluetoothDevices(list => { |
| | | api.getBluetoothDevices(list => { |
| | | resolve(list || []); |
| | | }); |
| | | }, |
| | |
| | | /** 连接设备 */ |
| | | function connect(device) { |
| | | return new Promise((resolve, reject) => { |
| | | const api = requirePlugin(); |
| | | if (!api) { |
| | | return reject(new Error(PLUGIN_MISSING_MSG)); |
| | | } |
| | | state.connectionStatus = "connecting"; |
| | | notify(); |
| | | |
| | | jcapi.openPrinterByDevice({ |
| | | api.openPrinterByDevice({ |
| | | address: device.address, |
| | | name: device.name, |
| | | deviceType: 0, |
| | |
| | | config.env = "development"; |
| | | // config.baseUrl = 'https://mes-demo.asun.cloud'; |
| | | // config.baseUrl = "http://192.168.32.65:9999"; |
| | | config.baseUrl = ""; |
| | | // 后台服务真实地址(App / 小程序 打包后使用,必须是带端口的绝对地址) |
| | | config.serverUrl = "http://192.168.22.25:80"; |
| | | |
| | | // 浏览器(H5)里必须用相对地址,请求才会走 manifest.json 里的 devServer 代理; |
| | | // 一旦写成绝对地址,请求会直连后端,浏览器按跨域(CORS)拦截。 |
| | | const isH5 = typeof window !== "undefined" && typeof window.document !== "undefined"; |
| | | config.baseUrl = isH5 ? "" : config.serverUrl; |
| | | config._api_key = "7a0e8d2d441f8233ef0f3683ca2fc848"; |
| | | config.appKey = "55e70d3b74c1c8a70481173bf233a5e1"; |
| | | config.downLoadEnv = "development"; |
| | |
| | | { |
| | | "name": "江东合金MES", |
| | | "appid": "__UNI__2E031D3", |
| | | "description": "pigcloud", |
| | | "versionName": "4.0.2", |
| | | "versionCode": 2, |
| | | "transformPx": false, |
| | | "app-plus": { |
| | | "compilerVersion": 3, |
| | | "optimization": { |
| | | "subPackages": true |
| | | }, |
| | | "safearea": { |
| | | "bottom": { |
| | | "offset": "none" |
| | | } |
| | | }, |
| | | "splashscreen": { |
| | | "alwaysShowBeforeRender": true, |
| | | "waiting": true, |
| | | "autoclose": true, |
| | | "delay": 0 |
| | | }, |
| | | "compatible": { |
| | | "ignoreVersion": true |
| | | }, |
| | | "usingComponents": true, |
| | | "nvueCompiler": "uni-app", |
| | | "modules": { |
| | | "Bluetooth": {} |
| | | }, |
| | | "distribute": { |
| | | "android": { |
| | | "permissions": [ |
| | | "<uses-feature android:name=\"android.hardware.camera\"/>", |
| | | "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", |
| | | "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>", |
| | | "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>", |
| | | "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>", |
| | | "<uses-permission android:name=\"android.permission.CAMERA\"/>", |
| | | "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", |
| | | "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", |
| | | "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>", |
| | | "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", |
| | | "<uses-permission android:name=\"android.permission.READ_LOGS\"/>", |
| | | "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>", |
| | | "<uses-permission android:name=\"android.permission.VIBRATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", |
| | | "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>", |
| | | "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>", |
| | | "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>", |
| | | "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>", |
| | | "<uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\"/> ", |
| | | "<uses-permission android:name=\"android.permission.BLUETOOTH_SCAN\"/>", |
| | | "<uses-permission android:name=\"android.permission.RECEIVE_SMS\"/>", |
| | | "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>", |
| | | "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>" |
| | | ], |
| | | "abiFilters": ["armeabi-v7a", "arm64-v8a"] |
| | | }, |
| | | "ios": { |
| | | "dSYMs": false |
| | | }, |
| | | "sdkConfigs": { |
| | | "ad": {}, |
| | | "oauth": {} |
| | | }, |
| | | "icons": { |
| | | "android": { |
| | | "hdpi": "C:/Users/MLL/Desktop/03ae6e42ca681ffd98737b6a20f94d0.png", |
| | | "xhdpi": "C:/Users/MLL/Desktop/03ae6e42ca681ffd98737b6a20f94d0.png", |
| | | "xxhdpi": "C:/Users/MLL/Desktop/03ae6e42ca681ffd98737b6a20f94d0.png", |
| | | "xxxhdpi": "C:/Users/MLL/Desktop/03ae6e42ca681ffd98737b6a20f94d0.png" |
| | | "name" : "江东合金MES", |
| | | "appid" : "__UNI__BB8756A", |
| | | "description" : "pigcloud", |
| | | "versionName" : "4.0.2", |
| | | "versionCode" : 3, |
| | | "transformPx" : false, |
| | | "app-plus" : { |
| | | "compilerVersion" : 3, |
| | | "optimization" : { |
| | | "subPackages" : true |
| | | }, |
| | | "ios": { |
| | | "appstore": "", |
| | | "ipad": { |
| | | "app": "", |
| | | "app@2x": "", |
| | | "notification": "", |
| | | "notification@2x": "", |
| | | "proapp@2x": "", |
| | | "settings": "", |
| | | "settings@2x": "", |
| | | "spotlight": "", |
| | | "spotlight@2x": "" |
| | | }, |
| | | "iphone": { |
| | | "app@2x": "", |
| | | "app@3x": "", |
| | | "notification@2x": "", |
| | | "notification@3x": "", |
| | | "settings@2x": "", |
| | | "settings@3x": "", |
| | | "spotlight@2x": "", |
| | | "spotlight@3x": "" |
| | | } |
| | | } |
| | | }, |
| | | "splashscreen": { |
| | | "androidStyle": "common" |
| | | } |
| | | }, |
| | | "nativePlugins": { |
| | | "JCSDK-JCApiModule": { |
| | | "__plugin_info__": { |
| | | "name": "精臣打印机接入插件", |
| | | "description": "精臣系列打印机打印插件", |
| | | "platforms": "Android,iOS", |
| | | "url": "https://ext.dcloud.net.cn/plugin?id=10011", |
| | | "android_package_name": "uni.UNI2E031D3", |
| | | "ios_bundle_id": "", |
| | | "isCloud": true, |
| | | "bought": 1, |
| | | "pid": "10011", |
| | | "parameters": {} |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "quickapp": {}, |
| | | "mp-weixin": { |
| | | "appid": "wxf3e5cc7116d23b18", |
| | | "setting": { |
| | | "urlCheck": false, |
| | | "es6": false, |
| | | "minified": true, |
| | | "postcss": true |
| | | }, |
| | | "optimization": { |
| | | "subPackages": true |
| | | }, |
| | | "usingComponents": true |
| | | }, |
| | | "mp-alipay": { |
| | | "usingComponents": true, |
| | | "component2": true |
| | | }, |
| | | "mp-qq": { |
| | | "optimization": { |
| | | "subPackages": true |
| | | }, |
| | | "appid": "" |
| | | }, |
| | | "mp-baidu": { |
| | | "usingComponents": true, |
| | | "appid": "" |
| | | }, |
| | | "mp-toutiao": { |
| | | "usingComponents": true, |
| | | "appid": "" |
| | | }, |
| | | "h5": { |
| | | "template": "h5.html", |
| | | "router": { |
| | | "mode": "hash", |
| | | "base": "./" |
| | | }, |
| | | "optimization": { |
| | | "treeShaking": { |
| | | "enable": false |
| | | } |
| | | }, |
| | | "devServer": { |
| | | "port": 8080, //浏览器运行端口 |
| | | "disableHostCheck": true, |
| | | "proxy": { |
| | | "/auth": { |
| | | "target": "http://192.168.32.65:9999", |
| | | "changeOrigin": true, |
| | | "secure": false |
| | | "safearea" : { |
| | | "bottom" : { |
| | | "offset" : "none" |
| | | } |
| | | }, |
| | | "/mes": { |
| | | "target": "http://192.168.32.65:9999", |
| | | "changeOrigin": true, |
| | | "secure": false |
| | | "splashscreen" : { |
| | | "alwaysShowBeforeRender" : true, |
| | | "waiting" : true, |
| | | "autoclose" : true, |
| | | "delay" : 0 |
| | | }, |
| | | "/admin": { |
| | | "target": "http://192.168.32.65:9999", |
| | | "changeOrigin": true, |
| | | "secure": false |
| | | "compatible" : { |
| | | "ignoreVersion" : true |
| | | }, |
| | | "usingComponents" : true, |
| | | "nvueCompiler" : "uni-app", |
| | | "modules" : { |
| | | "Bluetooth" : {} |
| | | }, |
| | | "distribute" : { |
| | | "android" : { |
| | | "permissions" : [ |
| | | "<uses-feature android:name=\"android.hardware.camera\"/>", |
| | | "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", |
| | | "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>", |
| | | "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>", |
| | | "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>", |
| | | "<uses-permission android:name=\"android.permission.CAMERA\"/>", |
| | | "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", |
| | | "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", |
| | | "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>", |
| | | "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", |
| | | "<uses-permission android:name=\"android.permission.READ_LOGS\"/>", |
| | | "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>", |
| | | "<uses-permission android:name=\"android.permission.VIBRATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", |
| | | "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>", |
| | | "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>", |
| | | "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>", |
| | | "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>", |
| | | "<uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\"/> ", |
| | | "<uses-permission android:name=\"android.permission.BLUETOOTH_SCAN\"/>", |
| | | "<uses-permission android:name=\"android.permission.RECEIVE_SMS\"/>", |
| | | "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>", |
| | | "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>" |
| | | ], |
| | | "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ] |
| | | }, |
| | | "ios" : { |
| | | "dSYMs" : false |
| | | }, |
| | | "sdkConfigs" : { |
| | | "ad" : {}, |
| | | "oauth" : {} |
| | | }, |
| | | "icons" : { |
| | | "android" : { |
| | | "hdpi" : "unpackage/res/icons/72x72.png", |
| | | "xhdpi" : "unpackage/res/icons/96x96.png", |
| | | "xxhdpi" : "unpackage/res/icons/144x144.png", |
| | | "xxxhdpi" : "unpackage/res/icons/192x192.png" |
| | | }, |
| | | "ios" : { |
| | | "appstore" : "unpackage/res/icons/1024x1024.png", |
| | | "ipad" : { |
| | | "app" : "unpackage/res/icons/76x76.png", |
| | | "app@2x" : "unpackage/res/icons/152x152.png", |
| | | "notification" : "unpackage/res/icons/20x20.png", |
| | | "notification@2x" : "unpackage/res/icons/40x40.png", |
| | | "proapp@2x" : "unpackage/res/icons/167x167.png", |
| | | "settings" : "unpackage/res/icons/29x29.png", |
| | | "settings@2x" : "unpackage/res/icons/58x58.png", |
| | | "spotlight" : "unpackage/res/icons/40x40.png", |
| | | "spotlight@2x" : "unpackage/res/icons/80x80.png" |
| | | }, |
| | | "iphone" : { |
| | | "app@2x" : "unpackage/res/icons/120x120.png", |
| | | "app@3x" : "unpackage/res/icons/180x180.png", |
| | | "notification@2x" : "unpackage/res/icons/40x40.png", |
| | | "notification@3x" : "unpackage/res/icons/60x60.png", |
| | | "settings@2x" : "unpackage/res/icons/58x58.png", |
| | | "settings@3x" : "unpackage/res/icons/87x87.png", |
| | | "spotlight@2x" : "unpackage/res/icons/80x80.png", |
| | | "spotlight@3x" : "unpackage/res/icons/120x120.png" |
| | | } |
| | | } |
| | | }, |
| | | "splashscreen" : { |
| | | "androidStyle" : "common" |
| | | } |
| | | }, |
| | | "nativePlugins" : { |
| | | "JCSDK-JCApiModule" : { |
| | | "__plugin_info__" : { |
| | | "name" : "精臣打印机接入插件", |
| | | "description" : "精臣系列打印机打印插件", |
| | | "platforms" : "Android,iOS", |
| | | "url" : "https://ext.dcloud.net.cn/plugin?id=10011", |
| | | "android_package_name" : "uni.UNI2E031D3", |
| | | "ios_bundle_id" : "", |
| | | "isCloud" : true, |
| | | "bought" : 1, |
| | | "pid" : "10011", |
| | | "parameters" : {} |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "title": "Asun-Mes", |
| | | "domain": "/app" |
| | | }, |
| | | "locale": "zh-Hans", |
| | | "fallbackLocale": "zh-Hans" |
| | | "quickapp" : {}, |
| | | "mp-weixin" : { |
| | | "appid" : "wxf3e5cc7116d23b18", |
| | | "setting" : { |
| | | "urlCheck" : false, |
| | | "es6" : false, |
| | | "minified" : true, |
| | | "postcss" : true |
| | | }, |
| | | "optimization" : { |
| | | "subPackages" : true |
| | | }, |
| | | "usingComponents" : true |
| | | }, |
| | | "mp-alipay" : { |
| | | "usingComponents" : true, |
| | | "component2" : true |
| | | }, |
| | | "mp-qq" : { |
| | | "optimization" : { |
| | | "subPackages" : true |
| | | }, |
| | | "appid" : "" |
| | | }, |
| | | "mp-baidu" : { |
| | | "usingComponents" : true, |
| | | "appid" : "" |
| | | }, |
| | | "mp-toutiao" : { |
| | | "usingComponents" : true, |
| | | "appid" : "" |
| | | }, |
| | | "h5" : { |
| | | "template" : "h5.html", |
| | | "router" : { |
| | | "mode" : "hash", |
| | | "base" : "./" |
| | | }, |
| | | "optimization" : { |
| | | "treeShaking" : { |
| | | "enable" : false |
| | | } |
| | | }, |
| | | "devServer" : { |
| | | "port" : 8080, //浏览器运行端口 |
| | | "disableHostCheck" : true, |
| | | // 代理只对相对路径生效:config.js 里 H5 平台 baseUrl 必须为空字符串 |
| | | "proxy" : { |
| | | "/auth" : { |
| | | "target" : "http://192.168.22.25:80", |
| | | "changeOrigin" : true, |
| | | "secure" : false, |
| | | "logLevel" : "debug" |
| | | }, |
| | | "/mes" : { |
| | | "target" : "http://192.168.22.25:80", |
| | | "changeOrigin" : true, |
| | | "secure" : false, |
| | | "logLevel" : "debug" |
| | | }, |
| | | "/admin" : { |
| | | "target" : "http://192.168.22.25:80", |
| | | "changeOrigin" : true, |
| | | "secure" : false, |
| | | "logLevel" : "debug" |
| | | } |
| | | } |
| | | }, |
| | | "title" : "Asun-Mes", |
| | | "domain" : "/app" |
| | | }, |
| | | "locale" : "zh-Hans", |
| | | "fallbackLocale" : "zh-Hans" |
| | | } |
| | |
| | | }, |
| | | "dependencies": { |
| | | "crypto-js": "^3.3.0", |
| | | "qs": "^6.9.7", |
| | | "vue-i18n": "^8.20.0" |
| | | "qs": "^6.10.5", |
| | | "vue-i18n": "^8.27.1" |
| | | } |
| | | } |
| | |
| | | loading: false, |
| | | refreshLoading: false, |
| | | image: undefined, |
| | | currentVersion: "1.0.1", |
| | | currentVersion: "1.1.3", |
| | | }; |
| | | }, |
| | | onLoad() { |
| | |
| | | DataMatrix: 33, |
| | | AZTEC: 34, |
| | | }; |
| | | // 线条类型 |
| | | const LineType = { |
| | | Solid: 1, // 实线 |
| | | Dotted: 2, // 虚线(默认虚实1:1相间) |
| | | }; |
| | | // 换行方式 |
| | | const LineModeType = { |
| | | Justified: 1, // 宽高固定,内容自适应(字号/字间距/行间距按比例缩放) |
| | |
| | | } |
| | | |
| | | const ht = item.contractNo; |
| | | const lj = item.partNo; |
| | | const ljms = item.ccontrProModel; |
| | | const fh = item.newNetWeight; |
| | | const scdt = item.productionDate; |
| | | const scph = item.batchNo; |
| | | const shdw = item.customerName; |
| | | const fhdw = "江东合金技术有限公司"; |
| | | |
| | | // 初始化画板 |
| | | // ===== 标签纸排版参数(单位:mm):40*70 标签纸 ===== |
| | | const LABEL_W = 40; // 标签宽度 |
| | | const LABEL_H = 70; // 标签长度(走纸方向) |
| | | const MARGIN = 1; // 四周留白,防止打印截断 |
| | | const QR_SIZE = LABEL_W - MARGIN * 2; // 二维码铺满 40mm 宽(38mm) |
| | | const TEXT_FONT_SIZE = 3; // 字段字号 |
| | | |
| | | // 初始化画板:宽 40、长 70,不做旋转(x 为纸宽方向,y 为走纸方向) |
| | | jcapi.initDrawingBoard({ |
| | | width: 70, |
| | | height: 49, |
| | | rotate: 90, |
| | | width: LABEL_W, |
| | | height: LABEL_H, |
| | | rotate: 0, |
| | | }); |
| | | |
| | | // 绘制二维码 |
| | |
| | | }; |
| | | |
| | | jcapi.drawLabelQrCode({ |
| | | x: 43.5, |
| | | y: 2, |
| | | width: 24, |
| | | height: 24, |
| | | x: MARGIN, |
| | | y: MARGIN, |
| | | width: QR_SIZE, |
| | | height: QR_SIZE, |
| | | value: qrContent, |
| | | rotate: 0, |
| | | codeType: QrCodeType.QrCode, |
| | | }); |
| | | |
| | | // 绘制横线 |
| | | this.getDrawLabelLine(1, 1, 67, 0.5, 0, LineType.Solid); |
| | | this.getDrawLabelLine(1, 6, 42, 0.3, 0, LineType.Solid); |
| | | this.getDrawLabelLine(1, 11, 42, 0.3, 0, LineType.Solid); |
| | | this.getDrawLabelLine(1, 16, 42, 0.3, 0, LineType.Solid); |
| | | this.getDrawLabelLine(1, 23, 42, 0.3, 0, LineType.Solid); |
| | | this.getDrawLabelLine(1, 27.5, 67, 0.3, 0, LineType.Solid); |
| | | this.getDrawLabelLine(1, 32, 67, 0.3, 0, LineType.Solid); |
| | | this.getDrawLabelLine(1, 37, 67, 0.3, 0, LineType.Solid); |
| | | this.getDrawLabelLine(1, 42, 67, 0.3, 0, LineType.Solid); |
| | | this.getDrawLabelLine(1, 47, 67, 0.5, 0, LineType.Solid); |
| | | // 全部框线已去掉;二维码下方剩余空间横向展示三个字段 |
| | | const textTop = MARGIN + QR_SIZE + MARGIN; |
| | | const lineHeight = (LABEL_H - MARGIN - textTop) / 3; |
| | | const fields = [ |
| | | { label: "合同号", value: ht }, |
| | | { label: "发货/装箱数", value: fh }, |
| | | { label: "生产批号", value: scph }, |
| | | ]; |
| | | |
| | | //绘制竖线 |
| | | this.getDrawLabelLine(1, 1, 0.5, 46, 0, LineType.Solid); // 竖线1 |
| | | this.getDrawLabelLine(43, 1, 0.3, 26, 0, LineType.Solid); // 竖线2 |
| | | this.getDrawLabelLine(68, 1, 0.5, 46, 0, LineType.Solid); // 竖线3 |
| | | fields.forEach((field, index) => { |
| | | const value = |
| | | field.value === null || field.value === undefined |
| | | ? "" |
| | | : String(field.value); |
| | | this.getDrawLabelText( |
| | | MARGIN, |
| | | textTop + index * lineHeight, |
| | | LABEL_W - MARGIN * 2, |
| | | lineHeight, |
| | | `${field.label}: ${value}`, |
| | | TEXT_FONT_SIZE, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 1 |
| | | ); |
| | | }); |
| | | |
| | | // 绘制文本 |
| | | this.getDrawLabelText( |
| | | 3, |
| | | 2.5, |
| | | 40, |
| | | 8, |
| | | "中天科技装箱清单", |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 1, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 2, |
| | | 7, |
| | | 25, |
| | | 8, |
| | | "合同号:", |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 2, |
| | | 12, |
| | | 25, |
| | | 8, |
| | | "零件号:", |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 2, |
| | | 17, |
| | | 25, |
| | | 8, |
| | | "零件描述:", |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 2, |
| | | 23.5, |
| | | 25, |
| | | 8, |
| | | "发货/装箱数:", |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 2, |
| | | 28.5, |
| | | 25, |
| | | 8, |
| | | "生产日期:", |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 2, |
| | | 32.5, |
| | | 25, |
| | | 8, |
| | | "生产批号:", |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 2, |
| | | 37.5, |
| | | 25, |
| | | 8, |
| | | "发货单位:", |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 2, |
| | | 42.5, |
| | | 25, |
| | | 8, |
| | | "收货单位:", |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 1 |
| | | ); |
| | | |
| | | // 填充参数值 |
| | | this.getDrawLabelText( |
| | | 11, |
| | | 7, |
| | | 30, |
| | | 8, |
| | | ht, |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 11, |
| | | 12, |
| | | 32, |
| | | 8, |
| | | lj, |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 14, |
| | | 17, |
| | | 30, |
| | | 8, |
| | | ljms, |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 17, |
| | | 23.5, |
| | | 27, |
| | | 8, |
| | | fh, |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 14, |
| | | 28.5, |
| | | 55, |
| | | 8, |
| | | scdt, |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 14, |
| | | 32.7, |
| | | 55, |
| | | 8, |
| | | scph, |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 14, |
| | | 37.5, |
| | | 55, |
| | | 8, |
| | | fhdw, |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1 |
| | | ); |
| | | this.getDrawLabelText( |
| | | 14, |
| | | 42.5, |
| | | 55, |
| | | 8, |
| | | shdw, |
| | | 2.5, |
| | | 0, |
| | | LineModeType.AutoHeight, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 1 |
| | | ); |
| | | // 生成打印数据 |
| | | let imageJsonObj = jcapi.generateLabelJson(); |
| | | |
| | |
| | | } |
| | | }, |
| | | |
| | | // 绘制横线 |
| | | getDrawLabelLine(x, y, width, height, rotate, lineType) { |
| | | jcapi.drawLabelLine({ |
| | | x: x, |
| | | y: y, |
| | | width: width, |
| | | height: height, |
| | | rotate: rotate, |
| | | lineType: lineType, |
| | | }); |
| | | }, |
| | | // 填冲文字标题 |
| | | getDrawLabelText( |
| | | x, |
| | |
| | | import * as CryptoJS from "crypto-js"; |
| | | |
| | | /** |
| | | * Base64 编码(按 UTF-8 处理) |
| | | * 注意:btoa 只在浏览器(H5)存在,App 和小程序里没有,直接调用会报 btoa is not defined。 |
| | | * 这里在非 H5 环境用纯 JS 实现,不依赖任何平台 API。 |
| | | */ |
| | | const B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
| | | |
| | | function base64Encode(str) { |
| | | const text = String(str); |
| | | // UTF-8 字节序列 |
| | | const utf8 = unescape(encodeURIComponent(text)); |
| | | let out = ""; |
| | | for (let i = 0; i < utf8.length; i += 3) { |
| | | const c1 = utf8.charCodeAt(i); |
| | | const c2 = utf8.charCodeAt(i + 1); |
| | | const c3 = utf8.charCodeAt(i + 2); |
| | | out += B64_CHARS[c1 >> 2]; |
| | | out += B64_CHARS[((c1 & 3) << 4) | (isNaN(c2) ? 0 : c2 >> 4)]; |
| | | out += isNaN(c2) ? "=" : B64_CHARS[((c2 & 15) << 2) | (isNaN(c3) ? 0 : c3 >> 6)]; |
| | | out += isNaN(c3) ? "=" : B64_CHARS[c3 & 63]; |
| | | } |
| | | return out; |
| | | } |
| | | |
| | | /** |
| | | *加密处理 |
| | | */ |
| | | export const encryption = params => { |
| | |
| | | const result = JSON.parse(JSON.stringify(data)); |
| | | if (type === "Base64") { |
| | | param.forEach(ele => { |
| | | result[ele] = btoa(result[ele]); |
| | | result[ele] = base64Encode(result[ele]); |
| | | }); |
| | | } else { |
| | | param.forEach(ele => { |
| | |
| | | # yarn lockfile v1 |
| | | |
| | | |
| | | "call-bind@^1.0.0": |
| | | "integrity" "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==" |
| | | "resolved" "http://10.1.51.33:8081/repository/group-npm/call-bind/-/call-bind-1.0.2.tgz" |
| | | "version" "1.0.2" |
| | | call-bind@^1.0.0: |
| | | version "1.0.2" |
| | | resolved "http://10.1.51.33:8081/repository/group-npm/call-bind/-/call-bind-1.0.2.tgz" |
| | | integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== |
| | | dependencies: |
| | | "function-bind" "^1.1.1" |
| | | "get-intrinsic" "^1.0.2" |
| | | function-bind "^1.1.1" |
| | | get-intrinsic "^1.0.2" |
| | | |
| | | "crypto-js@^3.3.0": |
| | | "integrity" "sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q==" |
| | | "resolved" "https://registry.npmmirror.com/crypto-js/-/crypto-js-3.3.0.tgz" |
| | | "version" "3.3.0" |
| | | crypto-js@^3.3.0: |
| | | version "3.3.0" |
| | | resolved "https://registry.npmmirror.com/crypto-js/-/crypto-js-3.3.0.tgz" |
| | | integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q== |
| | | |
| | | "function-bind@^1.1.1": |
| | | "integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" |
| | | "resolved" "http://10.1.51.33:8081/repository/group-npm/function-bind/-/function-bind-1.1.1.tgz" |
| | | "version" "1.1.1" |
| | | function-bind@^1.1.1: |
| | | version "1.1.1" |
| | | resolved "http://10.1.51.33:8081/repository/group-npm/function-bind/-/function-bind-1.1.1.tgz" |
| | | integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== |
| | | |
| | | "get-intrinsic@^1.0.2": |
| | | "integrity" "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==" |
| | | "resolved" "http://10.1.51.33:8081/repository/group-npm/get-intrinsic/-/get-intrinsic-1.1.1.tgz" |
| | | "version" "1.1.1" |
| | | get-intrinsic@^1.0.2: |
| | | version "1.1.1" |
| | | resolved "http://10.1.51.33:8081/repository/group-npm/get-intrinsic/-/get-intrinsic-1.1.1.tgz" |
| | | integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== |
| | | dependencies: |
| | | "function-bind" "^1.1.1" |
| | | "has" "^1.0.3" |
| | | "has-symbols" "^1.0.1" |
| | | function-bind "^1.1.1" |
| | | has "^1.0.3" |
| | | has-symbols "^1.0.1" |
| | | |
| | | "has-symbols@^1.0.1": |
| | | "integrity" "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" |
| | | "resolved" "http://10.1.51.33:8081/repository/group-npm/has-symbols/-/has-symbols-1.0.3.tgz" |
| | | "version" "1.0.3" |
| | | has-symbols@^1.0.1: |
| | | version "1.0.3" |
| | | resolved "http://10.1.51.33:8081/repository/group-npm/has-symbols/-/has-symbols-1.0.3.tgz" |
| | | integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== |
| | | |
| | | "has@^1.0.3": |
| | | "integrity" "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==" |
| | | "resolved" "http://10.1.51.33:8081/repository/group-npm/has/-/has-1.0.3.tgz" |
| | | "version" "1.0.3" |
| | | has@^1.0.3: |
| | | version "1.0.3" |
| | | resolved "http://10.1.51.33:8081/repository/group-npm/has/-/has-1.0.3.tgz" |
| | | integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== |
| | | dependencies: |
| | | "function-bind" "^1.1.1" |
| | | function-bind "^1.1.1" |
| | | |
| | | "object-inspect@^1.9.0": |
| | | "integrity" "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==" |
| | | "resolved" "http://10.1.51.33:8081/repository/group-npm/object-inspect/-/object-inspect-1.12.2.tgz" |
| | | "version" "1.12.2" |
| | | object-inspect@^1.9.0: |
| | | version "1.12.2" |
| | | resolved "http://10.1.51.33:8081/repository/group-npm/object-inspect/-/object-inspect-1.12.2.tgz" |
| | | integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== |
| | | |
| | | "qs@^6.9.7": |
| | | "integrity" "sha512-O5RlPh0VFtR78y79rgcgKK4wbAI0C5zGVLztOIdpWX6ep368q5Hv6XRxDvXuZ9q3C6v+e3n8UfZZJw7IIG27eQ==" |
| | | "resolved" "http://10.1.51.33:8081/repository/group-npm/qs/-/qs-6.10.5.tgz" |
| | | "version" "6.10.5" |
| | | qs@^6.10.5: |
| | | version "6.10.5" |
| | | resolved "http://10.1.51.33:8081/repository/group-npm/qs/-/qs-6.10.5.tgz" |
| | | integrity sha512-O5RlPh0VFtR78y79rgcgKK4wbAI0C5zGVLztOIdpWX6ep368q5Hv6XRxDvXuZ9q3C6v+e3n8UfZZJw7IIG27eQ== |
| | | dependencies: |
| | | "side-channel" "^1.0.4" |
| | | side-channel "^1.0.4" |
| | | |
| | | "side-channel@^1.0.4": |
| | | "integrity" "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==" |
| | | "resolved" "http://10.1.51.33:8081/repository/group-npm/side-channel/-/side-channel-1.0.4.tgz" |
| | | "version" "1.0.4" |
| | | side-channel@^1.0.4: |
| | | version "1.0.4" |
| | | resolved "http://10.1.51.33:8081/repository/group-npm/side-channel/-/side-channel-1.0.4.tgz" |
| | | integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== |
| | | dependencies: |
| | | "call-bind" "^1.0.0" |
| | | "get-intrinsic" "^1.0.2" |
| | | "object-inspect" "^1.9.0" |
| | | call-bind "^1.0.0" |
| | | get-intrinsic "^1.0.2" |
| | | object-inspect "^1.9.0" |
| | | |
| | | "vue-i18n@^8.20.0": |
| | | "integrity" "sha512-lWrGm4F25qReJ7XxSnFVb2h3PfW54ldnM4C+YLBGGJ75+Myt/kj4hHSTKqsyDLamvNYpvINMicSOdW+7yuqgIQ==" |
| | | "resolved" "http://10.1.51.33:8081/repository/group-npm/vue-i18n/-/vue-i18n-8.27.1.tgz" |
| | | "version" "8.27.1" |
| | | vue-i18n@^8.27.1: |
| | | version "8.27.1" |
| | | resolved "http://10.1.51.33:8081/repository/group-npm/vue-i18n/-/vue-i18n-8.27.1.tgz" |
| | | integrity sha512-lWrGm4F25qReJ7XxSnFVb2h3PfW54ldnM4C+YLBGGJ75+Myt/kj4hHSTKqsyDLamvNYpvINMicSOdW+7yuqgIQ== |