| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432 |
- <template>
- <gui-page :custom-header="true" :is-header-sized="false"
- :header-class="['gui-theme-background-color', isLandscapeScreen?'width: 100vmax;':'']"
- :style="[isLandscapeScreen?'width: 100vmax':'']">
- <template #gHeader>
- <view :style="[isLandscapeScreen?'height:44px;width: 100vmax':'height:44px;']"
- class="gui-flex gui-nowrap gui-rows gui-align-items-center">
- <!-- 使用组件实现返回按钮及返回首页按钮 -->
- <text style="font-size:44rpx;" class="gui-header-leader-btns gui-color-white font-icons"
- @tap="goBack"></text>
- <!-- 导航文本此处也可以是其他自定义内容 -->
- <text :style="[isPad?'font-size: 18px':'font-size: 14px']"
- class="gui-h4 gui-blod gui-flex1 gui-text-center gui-color-white gui-ellipsis gui-primary-text">分切</text>
- <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
- <!-- 实际宽度请根据自己情况设置 -->
- <view style="width:40px;" />
- </view>
- </template>
- <template #gBody>
- <view class="oqc-checkout">
- <view v-if="params.slitStatus !== 2" class="scan">
- <view class="scan-card">
- <uni-easyinput ref="batchNumberInput" v-model="params.scanBatchNumber" :input-border="false"
- type="text" focus placeholder="扫描母卷" @confirm="confirmBatchNumber"
- @focus="handleInputFocus('batchNumber')" @clear="handleClear('batchNumber')" />
- <text class="font-icons" @click="handleMapass"></text>
- </view>
- </view>
- <view v-if="params.slitStatus !== 2" class="scan">
- <view class="scan-card">
- <uni-easyinput ref="employeeInput" v-model="params.scanEmployeeName" :input-border="false"
- :clearable="false" type="text" placeholder="员工码" @confirm="confirmQrCodeEmployee"
- @focus="handleInputFocus('employee')" @clear="handleClear('employee')" />
- <text class="font-icons" @click="handleMapassQrCodeEmployee"></text>
- </view>
- </view>
- <view v-if="params.slitStatus !== 2" class="scan">
- <view class="scan-card">
- <uni-easyinput ref="deviceInput" v-model="params.scanDeviceName" :input-border="false"
- :clearable="false" type="text" placeholder="设备码" @confirm="confirmQrCodeDeviceId"
- @focus="handleInputFocus('device')" @clear="handleClear('device')" />
- <text class="font-icons" @click="handleMapassQrCodeDeviceId"></text>
- </view>
- </view>
- <view class="table-title">
- <span>分切来源</span>
- </view>
- <view class="custom-table">
- <uni-table border stripe empty-text="暂无更多数据">
- <!-- 表头行 -->
- <uni-tr class="custom-table-head">
- <uni-th align="center" width="50px">序号</uni-th>
- <uni-th align="center" width="170px">批次号</uni-th>
- <uni-th align="center" width="120px">物料编码</uni-th>
- <uni-th align="center" width="140px">物料名称</uni-th>
- <uni-th align="center" width="140px">规格</uni-th>
- <uni-th align="center" width="140px">余量</uni-th>
- </uni-tr>
- <!-- 表格数据行 -->
- <uni-tr v-for="(item, key) in slittingLots" :key="key"
- :style="[params.scanBatchNumber === item.materialLots? 'background-color: rgba(109, 205, 50, 1)':'background-color: white']">
- <uni-td align="center"
- :style="[params.scanBatchNumber === item.materialLots? 'color: white':'']">{{ ++key }}</uni-td>
- <uni-td align="center"
- :style="[params.scanBatchNumber === item.materialLots? 'color: white':'']">{{ item.materialLots }}</uni-td>
- <uni-td align="center"
- :style="[params.scanBatchNumber === item.materialLots? 'color: white':'']">{{ item.materialNo }}</uni-td>
- <uni-td align="center"
- :style="[params.scanBatchNumber === item.materialLots? 'color: white':'']">{{ item.materialName }}</uni-td>
- <uni-td align="center"
- :style="[params.scanBatchNumber === item.materialLots? 'color: white':'']">{{ item.size }}</uni-td>
- <uni-td align="center"
- :style="[params.scanBatchNumber === item.materialLots? 'color: white':'']">{{ item.remainQty }}</uni-td>
- </uni-tr>
- </uni-table>
- </view>
- <view class="table-title">
- <span>分切后规格</span>
- </view>
- <view class="custom-table">
- <uni-table border stripe empty-text="暂无更多数据">
- <!-- 表头行 -->
- <uni-tr class="custom-table-head">
- <uni-th align="center" width="80px"
- @click="handleCheckedAllRow">{{ isCheckedAllRow?"取消全选": "全选" }}</uni-th>
- <uni-th align="center" width="170px">来源批次</uni-th>
- <uni-th align="center" width="120px">宽</uni-th>
- <uni-th align="center" width="140px">长</uni-th>
- <uni-th align="center" width="140px">物料名称</uni-th>
- <uni-th align="center" width="140px">数量</uni-th>
- <uni-th align="center" width="140px">生产日期</uni-th>
- </uni-tr>
- <!-- 表格数据行 -->
- <uni-tr v-for="(item, key) in slittedLots" :key="key"
- :style="[computedLight(item)? 'background-color: rgba(109, 205, 50, 1)':'background-color: white']">
- <uni-td align="center">
- <checkbox :checked="item.checked" @click="handleCkeckedRow(item)" />
- </uni-td>
- <uni-td align="center"
- :style="[computedLight(item)? 'color: white':'']">{{ item.batchNumber }}</uni-td>
- <uni-td align="center"
- :style="[computedLight(item)? 'color: white':'']">{{ item.width }}</uni-td>
- <uni-td align="center"
- :style="[computedLight(item)? 'color: white':'']">{{ item.length }}</uni-td>
- <uni-td align="center"
- :style="[computedLight(item)? 'color: white':'']">{{ item.materialName }}</uni-td>
- <uni-td align="center"
- :style="[computedLight(item)? 'color: white':'']">{{ item.qty }}</uni-td>
- <uni-td align="center"
- :style="[computedLight(item)? 'color: white':'']">{{ $parseTime(item.produceDate) }}</uni-td>
- </uni-tr>
- </uni-table>
- </view>
- </view>
- <gui-right-menus>
- <!-- 扩展按钮 -->
- <template #menus-more>
- <view hover-class="gui-tap"
- class="menu-items gui-bg-blue gui-flex gui-columns gui-justify-content-center"
- @click="handleShowPrintDialog">
- <text class="menu-text gui-block gui-text-center gui-color-white">打印</text>
- </view>
- <view v-if="(params.slitStatus === 0 || params.slitStatus === 1) && params.scanBatchNumber"
- hover-class="gui-tap"
- class="menu-items gui-bg-green gui-flex gui-columns gui-justify-content-center"
- @click="handleCutting">
- <text class="menu-text gui-block gui-text-center gui-color-white">执行分切</text>
- </view>
- </template>
- <!-- 核心按钮 -->
- <template #menus-primary>
- <view class="menu-items gui-bg-primary gui-flex gui-columns gui-justify-content-center">
- <text class="menu-icon gui-color-white gui-block gui-text-center gui-icons"></text>
- <text class="menu-text gui-color-white gui-block gui-text-center">操作</text>
- </view>
- </template>
- </gui-right-menus><!-- 提示窗示例 -->
- <uni-popup ref="popup" type="dialog">
- <uni-popup-dialog type="success" cancel-text="取消" confirm-text="确认" title="提示"
- @confirm="handlePrintLabel" @close="popup.close()">
- <!-- eslint-disable-next-line -->
- <template #default="custom">
- <view class="form" style="width: 100%;margin: 0;">
- <div class="form-item">
- <div class="title">打印方式</div>
- <div class="content">
- <uni-data-select v-model="printType" :localdata="printTypeList" />
- </div>
- </div>
- <div class="form-item" v-if="printType === '0'">
- <div class="title">打印机</div>
- <div class="content">
- <uni-data-select v-model="printer" :localdata="printerList" />
- </div>
- </div>
- </view>
- </template>
- </uni-popup-dialog>
- </uni-popup>
- <uni-popup ref="errorTip" type="dialog">
- <uni-popup-dialog type="error" cancel-text="关闭" confirm-text="确认" title="提示" :content="errorTipMessage"
- @confirm="handleCloseErrorTipsModal" @close="handleCloseErrorTipsModal" />
- </uni-popup>
- </template>
- </gui-page>
- </template>
- <script>
- import {
- computed,
- defineComponent,
- ref,
- onMounted,
- onBeforeMount
- } from 'vue'
- import tsc from '@/unit/CHITEN_SDK_APP/tsc.js'
- export default defineComponent({
- // onLoad() {
- // // // #ifdef APP-PLUS
- // // plus.screen.lockOrientation('default');
- // // // #endif
- // },
- // onUnload() {
- // // // #ifdef APP-PLUS
- // // plus.screen.lockOrientation('portrait-primary');
- // // // #endif
- // },
- // onResize() {
- // if ([90, -90].includes(plus.navigator.getOrientation())) {
- // this.isLandscapeScreen = true
- // } else {
- // this.isLandscapeScreen = false
- // }
- // },
- setup(options) {
- const popup = ref()
- const printType = ref('0')
- const printer = ref('')
- const printerList = ref([]);
- const printData = ref([]);
- const isLandscapeScreen = ref(false)
- const parentRow = options?.params ?? {}
- const bluetooth = ref()
- const blueConfig = ref({
- loopBuffer: 0,
- currentTime: 1,
- lastData: 0,
- onBufferSize: 20,
- printerNum: 1,
- currentPrint: 1,
- isLabelSend: false
- })
- // 绑定的检查人信息
- const params = ref({
- eBillNo: '',
- slitStatus: 0,
- materialNo: '',
- scanBatchNumber: '',
- scanEmployee: '',
- scanEmployeeName: '',
- scanDeviceId: '',
- scanDeviceName: '',
- scanChildrenList: []
- })
- const slittingLots = ref([])
- const slittedLots = ref([])
- // 是否全选
- const isCheckedAllRow = ref(false)
- const batchNumberInput = ref()
- const employeeInput = ref()
- const deviceInput = ref()
- const emptyDocument = ref()
- const errorState = ref(0)
- const errorTip = ref('')
- const errorTipMessage = ref('')
- // 是否存在分切来源标签码
- const computedLight = computed(() => {
- return item => {
- if (params.value.scanChildrenList.includes(item.batchNumber)) {
- return true
- }
- return false
- }
- })
- // 多选框点击事件
- const handleCkeckedRow = function(ret) {
- const fdIndex = slittedLots.value.findIndex(item => item?.id === ret?.id)
- slittedLots.value[fdIndex].checked = !slittedLots.value[fdIndex].checked
- }
- onBeforeMount(() => {
- // #ifdef APP-PLUS
- const bluetoothConfig = uni.getStorageSync('bluetoothConfig')
- if ([null, '', undefined].includes(bluetoothConfig)) {
- bluetooth.value = {
- 'isOpenBle': false,
- 'deviceId': '',
- 'serviceId': '',
- 'writeId': '',
- 'notifyId': ''
- }
- setTimeout(() => {
- // #ifdef APP-PLUS
- plus.device.beep(2)
- // #endif
- errorTipMessage.value = '蓝牙打印机未连接'
- errorState.value = -1
- errorTip.value.open()
- }, 800)
- } else {
- bluetooth.value = JSON.parse(bluetoothConfig)
- }
- // #endif
- if (Object.keys(JSON.parse(parentRow)).length > 0) {
- params.value.slitStatus = JSON.parse(parentRow)?.slitStatus
- params.value.eBillNo = JSON.parse(parentRow)?.ebillNo
- params.value.materialNo = JSON.parse(parentRow)?.materialNo
- uni.$reqGet('getSlittingLots', {
- eBillNo: params.value.eBillNo
- })
- .then(({
- data
- }) => {
- slittingLots.value = data
- })
- uni.$reqGet('getSlittedLots', {
- eBillNo: params.value.eBillNo
- })
- .then(({
- data
- }) => {
- data.map(ret => {
- ret.checked = false
- })
- slittedLots.value = data
- })
- } else {
- uni.showToast({
- title: '没有物料编码',
- icon: 'none',
- duration: 1000
- })
- setTimeout(() => {
- uni.$goBack('/pages/workbranch/production/cutting/cuttingList')
- }, 1500)
- }
- })
- onMounted(() => {
- const paramsToJSON = JSON.parse(parentRow)
- if (Object.keys(paramsToJSON).length > 0) {
- if (Object.prototype.toString.call(paramsToJSON) === '[object Object]') {
- if (![NaN, null, undefined, ''].includes(paramsToJSON?.qrCode)) {
- uni.$reqPost('scanSlitting', {
- ebillNo: paramsToJSON.ebillNo,
- qrCode: paramsToJSON.qrCode
- })
- .then(({
- code,
- data,
- msg
- }) => {
- if (code === 0) {
- params.value.scanBatchNumber = data?.batchNumber
- params.value.scanChildrenList = data?.list
- employeeInput.value.onBlur()
- employeeInput.value.onFocus()
- } else {
- // #ifdef APP-PLUS
- plus.device.beep(2)
- // #endif
- errorTipMessage.value = msg
- errorTip.value.open()
- errorState.value = 0
- }
- })
- } else {
- setTimeout(() => {
- if (params.value.slitStatus !== 2) {
- handleMapass()
- }
- }, 500)
- }
- }
- }
- // GetPrinters();
- })
- const GetPrinters = function() {
- var cfgData = new Object;
- cfgData.XAction = "Printers";
- cfgData.XOpenId = "10000861";
- cfgData.XTokens = "+fdBeHkvLvLW2tIeEVMWr2DikZtd9jOb";
- cfgData.XUrl = "http://192.168.1.58:51320";
- // uniapp 1 其它 0
- cfgData.FaceType = "1";
- uni.CCPrintingAPI.Excute(cfgData,
- function(XTimeout) {},
- function(XFail) {
- // #ifdef APP-PLUS
- plus.device.beep(2)
- // #endif
- errorTipMessage.value = "API可能未安装或未启动"
- errorTip.value.open()
- errorState.value = -1
- },
- function(XSuccess) {
- var apiResult = JSON.parse(XSuccess.trim());
- if (apiResult.Status == "1") {
- /*获取到打印机列表*/
- if (apiResult.Message.length > 1) {
- for (var i = 1; i < apiResult.Message.length; i++) {
- printerList.value.push({
- text: apiResult.Message[i],
- value: apiResult.Message[i]
- })
- }
- /*设置上次使用的打印机*/
- printer.value = 'selected'
- }
- }
- }
- );
- }
- const goBack = function() {
- uni.reLaunch({
- url: '/pages/workbranch/production/cutting/cuttingList'
- })
- }
- const handleMapass = function() {
- // #ifdef APP-PLUS
- const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
- mpaasScanModule.mpaasScan({
- // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
- 'scanType': ['qrCode', 'barCode'],
- // 是否隐藏相册,默认false不隐藏
- 'hideAlbum': false
- },
- (ret) => {
- if (ret.resp_code === 1000) {
- uni.$reqPost('scanSlitting', {
- ebillNo: params.value.eBillNo,
- qrCode: ret.resp_result
- })
- .then(({
- code,
- data,
- msg
- }) => {
- if (code === 0) {
- params.value.scanBatchNumber = data?.batchNumber
- params.value.scanChildrenList = data?.list
- employeeInput.value.onBlur()
- employeeInput.value.onFocus()
- } else {
- // #ifdef APP-PLUS
- plus.device.beep(2)
- // #endif
- errorTipMessage.value = msg
- errorTip.value.open()
- errorState.value = 0
- }
- })
- }
- })
- // #endif
- }
- const confirmBatchNumber = function(e) {
- uni.$reqPost('scanSlitting', {
- ebillNo: params.value.eBillNo,
- qrCode: e
- })
- .then(({
- code,
- data,
- msg
- }) => {
- if (code === 0) {
- params.value.scanBatchNumber = data?.batchNumber
- params.value.scanChildrenList = data?.list
- employeeInput.value.onBlur()
- employeeInput.value.onFocus()
- } else {
- // #ifdef APP-PLUS
- plus.device.beep(2)
- // #endif
- errorTipMessage.value = msg
- errorTip.value.open()
- errorState.value = 0
- }
- })
- }
- const handleMapassQrCodeEmployee = function() {
- // #ifdef APP-PLUS
- const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
- mpaasScanModule.mpaasScan({
- // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
- 'scanType': ['qrCode', 'barCode'],
- // 是否隐藏相册,默认false不隐藏
- 'hideAlbum': false
- },
- (ret) => {
- if (ret.resp_code === 1000) {
- uni.$reqGet("getEmployeeDetail", {
- id: ret.resp_result
- })
- .then(({
- data
- }) => {
- params.value.scanEmployee = ret.resp_result
- params.value.scanEmployeeName = data?.employeeName;
- deviceInput.value.onBlur()
- deviceInput.value.onFocus()
- })
- }
- })
- // #endif
- }
- const handleMapassQrCodeDeviceId = function() {
- // #ifdef APP-PLUS
- const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
- mpaasScanModule.mpaasScan({
- // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
- 'scanType': ['qrCode', 'barCode'],
- // 是否隐藏相册,默认false不隐藏
- 'hideAlbum': false
- },
- (ret) => {
- if (ret.resp_code === 1000) {
- params.value.scanDeviceId = ret.resp_result
- }
- })
- // #endif
- }
- const setInputFocus = function() {
- params.value.scanBatchNumber = ''
- batchNumberInput.value.onBlur()
- batchNumberInput.value.onFocus()
- }
- // 关闭错误信息弹窗
- const handleCloseErrorTipsModal = async function() {
- errorTip.value.close()
- if (errorState.value === 0) {
- await setInputFocus()
- }
- }
- const handleInputFocus = function(text) {
- // #ifdef APP-PLUS
- setTimeout(() => {
- uni.hideKeyboard()
- }, 100)
- // #endif
- emptyDocument.value ? emptyDocument.value.$el.className = 'uni-easyinput' : false
- if (text === 'batchNumber') {
- batchNumberInput.value.$el.className = 'uni-easyinput light-focus'
- emptyDocument.value = batchNumberInput.value
- }
- if (text === 'employee') {
- employeeInput.value.$el.className = 'uni-easyinput light-focus'
- emptyDocument.value = employeeInput.value
- }
- if (text === 'device') {
- deviceInput.value.$el.className = 'uni-easyinput light-focus'
- emptyDocument.value = deviceInput.value
- }
- }
- const handleClear = function(text) {
- if (text === 'batchNumber') {
- batchNumberInput.value.onBlur()
- batchNumberInput.value.onFocus()
- }
- if (text === 'employee') {
- employeeInput.value.onBlur()
- employeeInput.value.onFocus()
- }
- if (text === 'device') {
- deviceInput.value.onBlur()
- deviceInput.value.onFocus()
- }
- }
- const confirmQrCodeEmployee = function(e) {
- uni.$reqGet("getEmployeeDetail", {
- id: e
- })
- .then(({
- code, data, msg
- }) => {
- if (code === 0) {
- params.value.scanEmployee = e
- params.value.scanEmployeeName = data?.employeeName;
- } else {
- // #ifdef APP-PLUS
- plus.device.beep(2)
- // #endif
- errorTipMessage.value = "用户信息不存在请重新扫码"
- errorTip.value.open()
- errorState.value = -1
- }
- deviceInput.value.onBlur()
- deviceInput.value.onFocus()
- })
- }
- const confirmQrCodeDeviceId = function(e) {
- uni.$reqGet("getEquipmentBaseDetail", {
- id: e
- })
- .then(({
- code, data, msg
- }) => {
- if (code === 0) {
- params.value.scanDeviceId = e
- params.value.scanDeviceName = data?.equipmentName;
- } else {
- // #ifdef APP-PLUS
- plus.device.beep(2)
- // #endif
- errorTipMessage.value = "设备信息不存在请重新扫码"
- errorTip.value.open()
- errorState.value = -1
- }
- deviceInput.value.onBlur()
- deviceInput.value.onFocus()
- deviceInput.value.$el.className = 'uni-easyinput'
- })
- }
- const Send = function(buff) {
- var currentTime = blueConfig.value.currentTime
- var loopBuffer = blueConfig.value.loopBuffer
- var lastData = blueConfig.value.lastData
- var onBufferSize = blueConfig.value.onBufferSize
- var printNum = blueConfig.value.printerNum
- var currentPrint = blueConfig.value.currentPrint
- var buf
- var dataView
- if (currentTime < loopBuffer) {
- buf = new ArrayBuffer(onBufferSize)
- dataView = new DataView(buf)
- for (let i = 0; i < onBufferSize; ++i) {
- dataView.setUint8(i, buff[(currentTime - 1) * onBufferSize + i])
- }
- } else {
- buf = new ArrayBuffer(lastData)
- dataView = new DataView(buf)
- for (let i = 0; i < lastData; ++i) {
- dataView.setUint8(i, buff[(currentTime - 1) * onBufferSize + i])
- }
- }
- plus.bluetooth.writeBLECharacteristicValue({
- deviceId: bluetooth.value.deviceId,
- serviceId: bluetooth.value.serviceId,
- characteristicId: bluetooth.value.writeId,
- value: buf,
- success: function(res) {
- if (currentPrint <= printNum) {
- wx.showToast({
- title: '数据打印中',
- icon: 'loading'
- })
- }
- // 将complete中处理数据的代码挪过来,增加30ms延迟, 解决蓝牙打印数据传输10007问题
- setTimeout(() => {
- currentTime += 1
- if (currentTime <= loopBuffer) {
- blueConfig.value.isLabelSend = true
- blueConfig.value.currentTime = currentTime
- Send(buff)
- }
- // end
- if (currentTime === loopBuffer) {
- blueConfig.value.currentPrint += 1
- blueConfig.value.isLabelSend = false
- }
- }, 10)
- },
- fail: function(e) {
- wx.showToast({
- title: '打印第' + currentPrint + '张失败' + 'error: code ' + e
- ?.code + ', message ' + e?.message,
- icon: 'none',
- duration: 4000
- })
- },
- complete: function() {}
- })
- }
- const prepareSend = function(buff) {
- var time = blueConfig.value.onBufferSize
- var loopBuffer = parseInt(buff.length / time)
- var lastData = parseInt(buff.length % time)
- blueConfig.value.loopBuffer = loopBuffer + 1
- blueConfig.value.lastData = lastData
- blueConfig.value.currentTime = 1
- Send(buff)
- }
- // 打印测试
- const labelTest = async function(ret) {
- var command = tsc.dlabelPrinter.createNew()
- command.setBackFeed(6)
- // (640 * 320)dots
- command.setSize(80, 40)
- command.setCls()
- command.setGap(8)
- command.setBox(0, 0, 635, 315, 1)
- command.setBar(0, 40, 640, 2)
- command.setBar(0, 80, 640, 2)
- command.setBar(0, 120, 640, 2)
- command.setBar(0, 160, 640, 2)
- command.setBar(0, 200, 366, 2)
- command.setBar(0, 240, 366, 2)
- command.setBar(0, 280, 640, 2)
- // 1
- command.setBar(115, 0, 2, 40)
- command.setBar(115, 40, 2, 40)
- command.setBar(115, 80, 2, 40)
- command.setBar(115, 120, 2, 40)
- command.setBar(115, 160, 2, 40)
- command.setBar(115, 200, 2, 40)
- command.setBar(115, 240, 2, 40)
- command.setBar(115, 280, 2, 40)
- // 2
- command.setBar(360, 40, 2, 40)
- command.setBar(360, 80, 2, 40)
- command.setBar(360, 120, 2, 40)
- command.setBar(360, 160, 2, 40)
- command.setBar(360, 200, 2, 40)
- command.setBar(360, 240, 2, 40)
- command.setBar(360, 280, 2, 40)
- // 3
- command.setBar(475, 40, 2, 40)
- command.setBar(475, 80, 2, 40)
- command.setBar(475, 120, 2, 40)
- command.setBar(475, 280, 2, 40)
- command.setText(10, 6, 'TSS24.BF2', 0, 1, 1, '物料名称')
- command.setText(126, 6, 'TSS24.BF2', 0, 1, 1, ret.materialName)
- // row2
- command.setText(10, 46, 'TSS24.BF2', 0, 1, 1, '物料编码')
- command.setText(126, 46, 'TSS24.BF2', 0, 1, 1, ret.materialNo)
- command.setText(366, 46, 'TSS24.BF2', 0, 1, 1, '供应商')
- command.setText(481, 46, 'TSS24.BF2', 0, 1, 1, ret.supplierName)
- // row3
- command.setText(10, 86, 'TSS24.BF2', 0, 1, 1, '物料规格')
- command.setText(126, 86, 'TSS24.BF2', 0, 1, 1, ret.size)
- command.setText(366, 86, 'TSS24.BF2', 0, 1, 1, '分切日期')
- command.setText(481, 86, 'TSS24.BF2', 0, 1, 1, ret.createTime)
- // row4
- command.setText(10, 126, 'TSS24.BF2', 0, 1, 1, 'Lot no.')
- command.setText(126, 126, '1', 0, 1, 1, ret.materialLots)
- command.setText(366, 126, 'TSS24.BF2', 0, 1, 1, '储位')
- command.setText(481, 126, 'TSS24.BF2', 0, 1, 1, ret.wmsStockLocationName)
- // row5
- command.setText(10, 166, 'TSS24.BF2', 0, 1, 1, '有效期')
- command.setText(126, 166, 'TSS24.BF2', 0, 1, 1, ret.validityDate)
- // row6
- command.setText(10, 206, 'TSS24.BF2', 0, 1, 1, '检测日期')
- command.setText(126, 206, 'TSS24.BF2', 0, 1, 1, ret.inspectTime)
- // row7
- command.setText(10, 246, 'TSS24.BF2', 0, 1, 1, '存储条件')
- const strList = ret.storageEnvironment?.split(' ')
- const strText = strList[0] + ' ' + strList[1]
- command.setText(126, 246, 'TSS24.BF2', 0, 1, 1, strText)
- // row8
- command.setText(10, 286, 'TSS24.BF2', 0, 1, 1, '分切单号')
- command.setText(126, 286, 'TSS24.BF2', 0, 1, 1, ret.slittingOrderNo)
- command.setText(366, 286, 'TSS24.BF2', 0, 1, 1, '生产日期')
- command.setText(481, 286, 'TSS24.BF2', 0, 1, 1, ret.produceDate)
- command.setText(480, 216, '2', 0, 1, 1, ret.qty)
- command.setQrcode(366, 166, 'L', 4, 'A', ret.batchNumber)
- command.setPagePrint()
- blueConfig.value.isLabelSend = true
- const forMatData = await command.getData()
- await prepareSend(forMatData)
- }
- const handleCutting = async function() {
- if ([undefined, null, ''].includes(params.value.scanEmployee)) {
- uni.showToast({
- title: '请绑定员工',
- icon: 'none',
- duration: 1000
- })
- return
- }
- if ([undefined, null, ''].includes(params.value.scanDeviceId)) {
- uni.showToast({
- title: '请绑定设备',
- icon: 'none',
- duration: 1000
- })
- return
- }
- uni.$reqPost('executeCutting', {
- slittingOrderNo: params.value.eBillNo,
- employee: params.value.scanEmployee,
- deviceId: params.value.scanDeviceId
- })
- .then(({
- code,
- data,
- msg
- }) => {
- if (code === 0) {
- uni.showToast({
- title: '分切成功',
- icon: 'none',
- duration: 2000
- })
- } else {
- uni.showToast({
- title: msg,
- icon: 'none',
- duration: 2000
- })
- }
- })
- // uni.$reqPost("executeCutting", {
- // slittingOrderNo: params.value.eBillNo,
- // employee: params.value.scanEmployee,
- // deviceId: params.value.scanDeviceId,
- // })
- // .then(({
- // code,
- // data,
- // msg
- // }) => {
- // if (code === 0) {
- // // #ifdef APP-PLUS
- // const Activity = plus.android.runtimeMainActivity();
- // const Intent = plus.android.importClass("android.content.Intent");
- // const Uri = plus.android.importClass("android.net.Uri");
- // const browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
- // `${uni.$baseUrl}/jmreport/view/821903765761437696?id=${params.value.eBillNo}`
- // ))
- // Activity.startActivity(browserIntent);
- // // #endif
- // // #ifdef H5
- // const dom = document.createElement('a');
- // dom.setAttribute("href",
- // `${uni.$baseUrl}/jmreport/view/821903765761437696?id=${params.value.eBillNo}`
- // );
- // dom.setAttribute("target", "_blank");
- // dom.click();
- // // #endif
- // uni.navigateTo({
- // url: "/pages/workbranch/production/cutting/cuttingList"
- // })
- // } else {
- // uni.showToast({
- // title: msg,
- // icon: "none",
- // duration: 1000,
- // })
- // }
- // })
- }
- // 获取打印数据
- const handleGetPrintData = function(id) {
- uni.request({
- url: uni.$baseUrl + '/report/print/slittingPrintData',
- data: {
- id
- }
- }).then(async ({
- data
- }) => {
- printData.value = [];
- if (data.data?.length > 0) {
- printData.value = data.data
- } else {
- // #ifdef APP-PLUS
- plus.device.beep(2)
- // #endif
- errorTipMessage.value = '无打印数据'
- errorTip.value.open()
- errorState.value = -1
- }
- })
- }
- // 蓝牙打印
- const bluetoothPrint = function() {
- if (printData.value.length > 0) {
- blueConfig.value.currentPrint = 1
- blueConfig.value.printNum = printData.value.length
- const timer = setInterval(async () => {
- const currentPrint = blueConfig.value.currentPrint -
- 1
- if (blueConfig.value.isLabelSend === false &&
- currentPrint <
- blueConfig.value.printNum) {
- const paramsObj = {
- materialName: printData.value[currentPrint]
- .materialName ?? '',
- materialNo: printData.value[currentPrint]
- .materialNo ??
- '',
- supplierName: printData.value[currentPrint]
- .supplierName ??
- '',
- size: printData.value[currentPrint]
- .size ??
- '',
- createTime: printData.value[currentPrint]
- .createTime ??
- '',
- materialLots: printData.value[currentPrint]
- .materialLots ??
- '',
- wmsStockLocationName: printData.value[
- currentPrint]
- .wmsStockLocationName ??
- '',
- validityDate: printData.value[currentPrint]
- .validityDate ??
- '',
- inspectTime: printData.value[currentPrint]
- .inspectTime ??
- '',
- storageEnvironment: printData.value[currentPrint]
- .storageEnvironment ??
- '',
- slittingOrderNo: printData.value[currentPrint]
- .slittingOrderNo ??
- '',
- produceDate: printData.value[currentPrint]
- .produceDate ??
- '',
- batchNumber: printData.value[currentPrint]
- .batchNumber ??
- '',
- qty: printData.value[currentPrint]
- .qty ??
- ''
- }
- await labelTest(paramsObj)
- }
- if (currentPrint === blueConfig.value.printNum) {
- await clearInterval(timer)
- }
- }, 3000)
- }
- }
- // 智高打印
- const hicorePrint = function() {
- var cfgData = new Object;
- cfgData.XAction = "Print"
- cfgData.XOpenId = "10000004";
- cfgData.XTokens = "+fdBeHkvLvJgWBKF/6iODpmABblarwVz";
- cfgData.XUrl = "http://192.168.1.58:51320";
- // uniapp 1 其它 0
- cfgData.FaceType = "1";
- /*指定打印机*/
- cfgData.PrinterName = printer.value;
- /*模板方式,0-客户端模板,1-远程模板,
- 2-如果本地模板存在,使用本地,不存在使用远程模板,3-不使用模板*/
- cfgData.TemplateMode = "2";
- /*远程模板URL或本地模板的文件夹*/
- // cfgData.TemplateURL = "http://img.51321.cn/web/chicore/VPrinting/API";
- cfgData.TemplateURL = "http://113.105.183.190:9163/bucket163";
- // cfgData.TemplateURL = "D:\\\\";
- /*模板文件名*/
- // cfgData.TemplateName = "183601-70X40.Lblx";
- cfgData.TemplateName = "2024-01-26-10-04-38-1706234678133_Label3.Lblx";
- // cfgData.TemplateName = "Label2.Lblx";
- /*打印数据的类型,0-数组,1-Json数组,元素为JSON对象,字段:值*/
- cfgData.PrintDataType = 1;
- /*传递打印数据 Json数组*/
- /*内容不允许 半角的逗号及半角的分隔符*/
- var arr = printData.value;
- cfgData.PrintData = JSON.stringify(arr);
- /*打印 发送给打印机进行打印*/
- uni.CCPrintingAPI.Excute(cfgData,
- function(XTimeout) {},
- function(XFail) {
- // #ifdef APP-PLUS
- plus.device.beep(2)
- // #endif
- errorTipMessage.value = "API可能未安装或未启动"
- errorTip.value.open()
- errorState.value = -1
- },
- function(XSuccess) {
- var apiResult = JSON.parse(XSuccess.trim());
- if (apiResult.Status == "1") {
- uni.showToast({
- title: '标签打印成功',
- icon: "none",
- duration: 1500
- })
- }
- }
- );
- }
- const handleShowPrintDialog = function() {
- const ids = []
- slittedLots.value.forEach(ret => {
- if (ret.checked) {
- ids.push(ret?.id)
- }
- })
- if (ids.length === 0) {
- // #ifdef APP-PLUS
- plus.device.beep(2)
- // #endif
- errorTipMessage.value = '请选中至少一行打印数据'
- errorTip.value.open()
- errorState.value = -1
- } else {
- popup.value.open();
- handleGetPrintData(ids.toString());
- }
- }
- const handlePrintLabel = function() {
- if (printType.value === '0') {
- hicorePrint();
- }
- if (printType.value === '1') {
- bluetoothPrint();
- }
- }
- // 全选
- const handleCheckedAllRow = function() {
- slittedLots.value.map(ret => {
- ret.checked = !isCheckedAllRow.value
- })
- isCheckedAllRow.value = !isCheckedAllRow.value
- }
- return {
- printTypeList: [{
- text: '智高标签打印',
- value: '0',
- }, {
- text: '蓝牙打印',
- value: '1',
- }, ],
- popup,
- goBack,
- printType,
- printer,
- printerList,
- slittedLots,
- slittingLots,
- isLandscapeScreen,
- batchNumberInput,
- employeeInput,
- handleInputFocus,
- deviceInput,
- errorState,
- errorTip,
- errorTipMessage,
- params,
- computedLight,
- handleClear,
- handleMapass,
- handleCutting,
- isCheckedAllRow,
- handlePrintLabel,
- confirmQrCodeEmployee,
- confirmQrCodeDeviceId,
- confirmBatchNumber,
- handleCkeckedRow,
- handleShowPrintDialog,
- handleCheckedAllRow,
- handleMapassQrCodeEmployee,
- handleMapassQrCodeDeviceId,
- handleCloseErrorTipsModal
- }
- }
- })
- </script>
- <style lang="scss" scoped>
- .gui-header-leader-btns {
- color: black;
- font-size: 24px !important;
- margin-left: 24rpx;
- }
- .gui-sbody {
- background-color: rgba(234, 239, 242, 1);
- }
- .gui-relative {
- overflow: visible;
- height: 100vh;
- .oqc-checkout {
- width: 100vw;
- height: calc(100vh - 75px);
- position: absolute;
- top: 95px;
- overflow-y: scroll;
- }
- }
- .popup-content {
- width: 100vw;
- height: 55vh;
- overflow-y: scroll;
- }
- .card-list-flexbox-popup {
- width: 100vw;
- display: flex;
- flex-direction: row;
- align-items: center;
- flex-wrap: wrap;
- .card-list-item,
- .card-list-item-input {
- width: 100vw;
- height: 100%;
- min-height: 40px;
- display: flex;
- flex-direction: row;
- align-items: center;
- background-color: #fff;
- uni-text {
- font-size: 14px;
- height: 50rpx;
- text-align: left;
- padding: 0 12px;
- display: flex;
- flex-direction: row;
- align-items: center;
- }
- uni-image {
- width: calc(100vw / 2 - 4px);
- height: calc(100vw / 3.2 - 2px);
- pointer-events: none;
- }
- uni-image::after {
- content: "×";
- width: 22px;
- height: 22px;
- position: absolute;
- top: 5px;
- right: 5px;
- display: flex;
- justify-content: center;
- align-items: center;
- color: rgba(255, 255, 255, 0.9);
- background-color: rgba(0, 0, 0, 0.5);
- border-radius: 50%;
- font-size: 24px;
- /*给伪元素开启鼠标事件,将事件冒泡到父元素的点击事件中*/
- pointer-events: auto;
- }
- .text-1 {
- flex: 1;
- height: 40px;
- justify-content: flex-start;
- }
- .text-2 {
- flex: 3;
- height: 40px;
- justify-content: flex-end;
- margin-right: 4px;
- padding: 2px 6px;
- }
- .text-3 {
- width: calc(100% - 15%);
- min-height: 35px;
- justify-content: flex-end;
- padding: 2px 6px;
- }
- .text-3::before {}
- .btn-mg {
- margin: 0 5px;
- }
- }
- .card-list-item {
- justify-content: center;
- }
- .card-list-item-input {
- margin: 10px 0 10px 2%;
- display: flex;
- flex-direction: column;
- uni-view {
- width: 100%;
- height: 100%;
- display: flex;
- uni-textarea {
- flex: 8;
- }
- uni-view {
- flex: 1;
- }
- .operation-icon,
- .operation-icon-2 {
- height: auto;
- uni-text {
- width: 22px;
- height: 100%;
- padding: 0 !important;
- text-align: center;
- display: flex;
- justify-content: center;
- align-items: center;
- border-top-right-radius: 4px;
- border-bottom-right-radius: 4px;
- color: white;
- background-color: #80b7ff;
- }
- }
- .operation-icon-2 {
- uni-text {
- background-color: #ff5962;
- }
- }
- }
- }
- .grid-image {
- /* 设置容器布局为grid布局 */
- display: grid;
- /* 指定每一行的宽度 每个宽度中间用空格隔开 */
- grid-template-rows: repeat(auto-fill, 1fr);
- /* 指定每一列的宽度 每个宽度中间用空格隔开 */
- grid-template-columns: repeat(2, 1fr);
- padding: 0 4px;
- }
- .card-list-item:nth-of-type(1) {
- .text-1 {
- flex: 9;
- font-weight: bold;
- color: black !important;
- }
- .text-1::before {
- content: "";
- width: 4px;
- height: 20px;
- border-radius: 4px;
- margin-right: 4px;
- background-color: skyblue;
- }
- .text-2 {
- flex: 4;
- display: flex;
- flex-direction: row;
- justify-content: flex-end;
- align-items: center;
- color: limegreen !important;
- }
- }
- }
- .table-title {
- height: 40px;
- line-height: 40px;
- margin: 0 0 -3px 0;
- padding: 0 12px;
- font-size: 16px;
- font-weight: bold;
- background-color: white;
- }
- .uni-list-cell {
- width: 100vw;
- height: 35px;
- margin: 4px 0;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- border-bottom: 2px solid #eaeff2;
- background-color: #fff;
- view {
- font-size: 14px;
- height: 50rpx;
- text-align: left;
- padding: 0 8px;
- display: flex;
- flex-direction: row;
- align-items: center;
- }
- .uni-list-cell-left {
- flex: 1;
- height: 35px;
- justify-content: flex-start;
- }
- .uni-list-cell-db {
- flex: 3;
- height: 35px;
- justify-content: flex-end;
- margin-right: 4px;
- padding: 2px 6px;
- uni-picker {
- width: 100%;
- display: flex;
- flex-direction: row;
- justify-content: center;
- }
- }
- }
- .modal-btns {
- height: 100rpx;
- line-height: 100rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .line {
- margin-top: 10rpx;
- height: 80rpx;
- width: 1rpx;
- background-color: #dcdcdc;
- }
- .font-icons {
- width: 40px;
- font-size: 20px;
- }
- .scan {
- height: 45px;
- width: calc(100% - 48px);
- margin: 0 12px 12px 12px;
- padding: 0 12px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- border-radius: 6px;
- background-color: white;
- .scan-card {
- width: 100%;
- display: grid;
- grid-template-rows: 1fr;
- grid-template-columns: 7fr 2fr;
- align-items: center;
- input {
- height: 35px;
- line-height: 35px;
- }
- text {
- width: 100%;
- text-align: right;
- }
- }
- }
- .light-focus {
- border: 1px solid #008aff;
- border-radius: 6px !important;
- ::v-deep .uni-easyinput__content {
- border-radius: 6px !important;
- }
- }
- .light-focus::before {
- position: absolute;
- left: -10px;
- top: -10px;
- content: "✏️";
- width: 20px;
- height: 20px;
- color: red;
- font-weight: bold;
- font-size: 18px;
- }
- .form {
- font-size: 14px;
- margin: 0 12px 12px 12px;
- padding: 4px 8px;
- border-radius: 4px;
- background-color: white;
- .form-title {
- height: 32px;
- line-height: 32px;
- text-align: center;
- font-size: 16px;
- font-weight: bold;
- border-bottom: 2px dashed #edeeee;
- }
- .form-item {
- .title {
- height: 32px;
- line-height: 32px;
- text-align: left;
- font-weight: bold;
- color: #333;
- }
- .content {
- height: 42px;
- line-height: 42px;
- margin: 0 0 6px 0;
- position: relative;
- .button-add {
- position: absolute;
- width: 37px;
- height: 37px;
- right: 0;
- top: 0;
- display: flex;
- justify-content: center;
- align-items: center;
- border-radius: 4px;
- color: white;
- cursor: pointer;
- background-color: #00a0e9;
- }
- }
- }
- }
- </style>
|