| | |
| | | <view class="wrap"> |
| | | <scroll-view class="finishProductIn-locno-scroll-list" scroll-y="true" @scrolltolower="loadMore"> |
| | | <u-cell-group class="finishProductIn-locno-scroll-list-group" :border="false"> |
| | | <view |
| | | class="content" |
| | | v-for="(item, index) in list" |
| | | :key="item.locNo" |
| | | :index="index" |
| | | @click="selectNo(item.index)" |
| | | > |
| | | <view class="content" v-for="(item, index) in list" :key="item.locNo" :index="index" @click="selectNo(item)"> |
| | | <view class="content-header"> |
| | | <view class="content-header-title">{{ index+1 }}</view> |
| | | </view> |
| | |
| | | </view> |
| | | </scroll-view> |
| | | </view> |
| | | <u-toast ref="uToast" /> |
| | | <view v-if="maskShow" class="uni-mask" @touchmove.stop.prevent="moveHandle" @click="maskclose"> |
| | | <scroll-view class="uni-scroll_box" scroll-y @touchmove.stop.prevent="moveHandle" @click.stop="moveHandle"> |
| | | <view class="uni-list-box" v-for="(item, index) in listDevice" :key="index" @click="tapQuery(item)"> |
| | | <view> |
| | | <view class="uni-list_name">名称:{{ item.name }}</view> |
| | | <view class="uni-list_item">UUID:{{ item.address }}</view> |
| | | </view> |
| | | </view> |
| | | </scroll-view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | <script> |
| | | import content_bg from '@/static/custom/finishProductIn/locNoBg.png' |
| | | const jcapi = uni.requireNativePlugin("JCSDK-JCApiModule"); |
| | | |
| | | // 二维码类型 |
| | | const QrCodeType = { |
| | | QrCode: 31, |
| | | PDF417: 32, |
| | | DataMatrix: 33, |
| | | AZTEC: 34 |
| | | } |
| | | // 线条类型 |
| | | const LineType = { |
| | | Solid: 1, // 实线 |
| | | Dotted: 2, // 虚线(默认虚实1:1相间) |
| | | } |
| | | // 换行方式 |
| | | const LineModeType = { |
| | | Justified: 1, // 宽高固定,内容自适应(字号/字间距/行间距按比例缩放) |
| | | AutoHeight: 2, // 宽度固定,高度自适应 |
| | | Fixed: 4, // 宽高固定,超出部分裁剪 |
| | | Adapt: 6, // 宽高固定,内容超过时预设宽高自动缩小 |
| | | } |
| | | export default { |
| | | data() { |
| | | return { |
| | |
| | | } |
| | | ], |
| | | count: 0, |
| | | loadStatus: 'loading' |
| | | loadStatus: 'loading', |
| | | maskShow: false, |
| | | listDevice: [], //蓝牙设备数据 |
| | | pritList: [] |
| | | }; |
| | | }, |
| | | onLoad() { |
| | |
| | | this.alllist = res.data |
| | | this.originList = res.data |
| | | this.loadList() |
| | | }) |
| | | // 初始化SDK |
| | | jcapi.initSDK() |
| | | // 监听页码回调 |
| | | jcapi.didReadPrintCountInfo(function (r) { |
| | | console.log(r) |
| | | }) |
| | | |
| | | // 监听错误回调 |
| | | jcapi.didReadPrintErrorInfo(function (r) { |
| | | console.log(r) |
| | | if (r.code == 23) { |
| | | // 打印机断开连接 |
| | | _this.connectedDevice = null |
| | | } |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: JSON.stringify(r), |
| | | duration: 2 * 1000 |
| | | }) |
| | | }) |
| | | }, |
| | | methods: { |
| | |
| | | this.loadList() |
| | | }, |
| | | // 打印单个信息 |
| | | selectNo(no) { |
| | | selectNo(item) { |
| | | let that = this |
| | | uni.showModal({ |
| | | title: '提示', |
| | | content: '是否打印装箱单?', |
| | | showCancel: true, |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | |
| | | that.searchDevice() |
| | | that.pritList = [item] |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | // 打印全部信息 |
| | | goPrintAll() { |
| | | let that = this |
| | | uni.showModal({ |
| | | title: '提示', |
| | | content: '是否打印装箱单?', |
| | | showCancel: true, |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | |
| | | that.searchDevice() |
| | | that.pritList = this.list |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | moveHandle() { |
| | | |
| | | }, |
| | | maskclose() { |
| | | |
| | | }, |
| | | //打印二维码 |
| | | async printQrCode(item) { |
| | | const params = { |
| | | rwMatlBindId: item.id |
| | | } |
| | | let res = await this.$u.api.dailyPaper.zongjianLabelInfo(params) |
| | | if (!res.data) { |
| | | this.$refs.uToast.show({ |
| | | title: '未查询到该标签信息!', |
| | | type: 'warning ' |
| | | }) |
| | | return |
| | | } |
| | | // 初始化画板 |
| | | jcapi.initDrawingBoard({ |
| | | width: 50, |
| | | height: 100, |
| | | rotate: 0 |
| | | }); |
| | | |
| | | // // 绘制二维码 |
| | | jcapi.drawLabelQrCode({ |
| | | x: 14.5, |
| | | y: 74, |
| | | width: 20, |
| | | height: 20, |
| | | value: jsonString, |
| | | rotate: 0, |
| | | codeType: QrCodeType.QrCode, |
| | | }); |
| | | // 绘制横线 实线8条 |
| | | let sum = 4; |
| | | for (let i = 1; i < 13; i++) { |
| | | this.getDrawLabelLine(4, sum, 46, 0.5, 0, LineType.Solid) // 实线 |
| | | sum = (i * 6) + 4 |
| | | } |
| | | // 二维码大框 |
| | | this.getDrawLabelLine(4, 97, 46, 0.5, 0, LineType.Solid) // 实线9 |
| | | |
| | | //绘制竖线 |
| | | this.getDrawLabelLine(4, 4, 0.5, 97, 0, LineType.Solid) // 竖线1 |
| | | this.getDrawLabelLine(20, 4, 0.5, 66, 0, LineType.Solid) // 竖线2 |
| | | this.getDrawLabelLine(44.5, 4, 0.5, 97, 0, LineType.Solid) // 竖线2 |
| | | |
| | | // 填冲文字标题 |
| | | this.getDrawLabelText(5, 5, 20, 20, '编 号:', 3.6, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | this.getDrawLabelText(5, 11, 20, 20, '工单号:', 3.6, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | this.getDrawLabelText(5, 17, 20, 20, '牌 号:', 3.6, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | this.getDrawLabelText(5, 23, 20, 20, '片宽(mm):', 3.6, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | this.getDrawLabelText(5, 29, 20, 20, '厚度(mm):', 3.6, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | this.getDrawLabelText(5, 35, 20, 20, '重量(KG):', 3.6, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | this.getDrawLabelText(5, 41, 20, 20, '长度(m):', 3.6, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | this.getDrawLabelText(5, 47, 20, 20, '生产人:', 3.6, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | this.getDrawLabelText(5, 53, 20, 20, '生产时间:', 3.4, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | this.getDrawLabelText(5, 59, 20, 20, '厂家:', 3.4, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | this.getDrawLabelText(5, 65, 20, 20, '铁损:', 3.4, 0, LineModeType.AutoHeight, 0, 0, 0, 1) |
| | | |
| | | // // 填冲参数值 |
| | | this.getDrawLabelText(22, 5, 35, 12, labelNo, 3, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | this.getDrawLabelText(22, 11, 35, 12, optaskNo, 3, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | this.getDrawLabelText(22, 17, 35, 12, grade, 3, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | this.getDrawLabelText(22, 23, 35, 12, sliceWidth, 3, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | this.getDrawLabelText(22, 29, 35, 12, thickness, 3, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | this.getDrawLabelText(22, 35, 35, 12, wweight, 3, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | this.getDrawLabelText(22, 41, 35, 12, llength, 3, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | this.getDrawLabelText(22, 47, 35, 12, reportName, 2, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | this.getDrawLabelText(22, 53, 35, 12, reportTime, 3, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | this.getDrawLabelText(22, 59, 35, 12, supplierVenderName, 3, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | this.getDrawLabelText(22, 65, 35, 12, ironLoss, 3, 0, LineModeType.AutoHeight, 0, 0, 0, 0) |
| | | |
| | | // 生成打印数据 |
| | | let imageJsonObj = jcapi.generateLabelJson() |
| | | // 设置打印任务 |
| | | jcapi.startJob({ |
| | | totalCount: 1, |
| | | density: this.printDensity, |
| | | labelType: this.labelType, |
| | | printMode: this.printMode, |
| | | }, function (r) { |
| | | if (r.code == 0) { |
| | | // 打印数据 |
| | | jcapi.printData(imageJsonObj, { |
| | | "printQuantity": 1, |
| | | }, function (r) { |
| | | if (r.code == 0) { |
| | | console.log("打印成功") |
| | | } else { |
| | | console.log("打印失败") |
| | | } |
| | | }) |
| | | } else { |
| | | console.log("设置打印任务失败") |
| | | } |
| | | }) |
| | | }, |
| | | tapQuery(item) { |
| | | this.maskShow = false |
| | | // 连接打印机 |
| | | let _this = this; |
| | | console.log(item) |
| | | jcapi.openPrinterByDevice({ |
| | | address: item.address, |
| | | name: item.name, |
| | | deviceType: item.deviceType // 设备类型:0-蓝牙,1-网络 |
| | | }, function (r) { |
| | | uni.showToast({ |
| | | title: (r.code == 0) ? "连接成功" : "连接失败", |
| | | duration: 2 * 1000 |
| | | }) |
| | | if (r.code == 0) { |
| | | _this.connectedDevice = item |
| | | // 绘标签进行打印 |
| | | _this.pritList.forEac(async item => { |
| | | await _this.printQrCode(item) |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | //打印相关 |
| | | searchDevice() { |
| | | let _this = this |
| | | uni.openBluetoothAdapter({ // 确认蓝牙是否打开 |
| | | success(r) { |
| | | uni.showLoading({ |
| | | title: "搜索中..." |
| | | }) |
| | | // 未授予蓝牙相关权限和未打开手机定位会搜索不到设备 |
| | | jcapi.getBluetoothDevices(function (r) { |
| | | console.log("device:" + JSON.stringify(r)) |
| | | // 搜索到设备回调 |
| | | uni.hideLoading() |
| | | _this.listDevice = r; |
| | | _this.maskShow = true |
| | | }) |
| | | }, |
| | | fail(e) { |
| | | uni.showModal({ |
| | | confirmText: "打开蓝牙失败" |
| | | }) |
| | | console.log("开启蓝牙设备失败" + e) |
| | | } |
| | | }) |
| | | }, |
| | | // 绘制横线 实线 |
| | | getDrawLabelLine(x, y, width, height, rotate, lineType) { |
| | | jcapi.drawLabelLine({ |
| | | x: x, |
| | | y: y, |
| | | width: width, |
| | | height: height, |
| | | rotate: rotate, |
| | | lineType: lineType |
| | | }); |
| | | }, |
| | | // 填冲文字标题 |
| | | getDrawLabelText(x, y, width, height, value, fontSize, rotate, lineMode, lineSpace, letterSpace, textAlignHorizontal, textAlignVertical) { |
| | | jcapi.drawLabelText({ |
| | | x: x, |
| | | y: y, |
| | | width: width, |
| | | height: height, |
| | | value: value, |
| | | fontSize: fontSize, |
| | | rotate: rotate, |
| | | lineMode: lineMode, |
| | | lineSpace: lineSpace, |
| | | letterSpace: letterSpace, |
| | | textAlignHorizontal: textAlignHorizontal, |
| | | textAlignVertical: textAlignVertical |
| | | }) |
| | | }, |
| | | |
| | | //刷新上一个页面 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | .navbar-right { |
| | | font-weight: 500; |
| | | font-size: 13px; |