pages/tiaomadaying/tiaomadaying.vue
@@ -1,566 +1,606 @@
<template>
   <view class="container">
      <view class="content">
         <view class="header">基本信息</view>
         <view class="items">
            <view class="item">
               <view class="left">条码编号:</view>
               <view class="right">
                  <input name="HBarCode" disabled v-model="lailiaoInfo.barCodeNo" placeholder="请扫描来料条码" />
               </view>
               <view>
                  <uni-icons type="scan"
                     style="background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;font-weight: 500;"
                     size="20" @click="toScanCode"></uni-icons>
               </view>
            </view>
            <view class="item">
               <view class="left">源单号:</view>
               <view class="right">
                  <input name="HBillNo" v-model="lailiaoInfo.HBillNo" />
               </view>
            </view>
            <view class="item">
               <view class="left">源单行号:</view>
               <view class="right">
                  <input name="HBillLineNo" v-model="lailiaoInfo.HBillLineNo" />
               </view>
            </view>
            <view class="item">
               <view class="left">物料编码:</view>
               <view class="right">
                  <input name="HMaterNo" v-model="lailiaoInfo.HMaterNumber" />
               </view>
            </view>
            <view class="item">
               <view class="left">物料名称:</view>
               <view class="right">
                  <input name="HMaterName" v-model="lailiaoInfo.HMaterName" />
               </view>
            </view>
            <view class="item">
               <view class="left">规格型号:</view>
               <view class="right">
                  <input name="HMaterType" v-model="lailiaoInfo.HMaterModel" />
               </view>
            </view>
            <view class="item">
               <view class="left">批次:</view>
               <view class="right">
                  <input name="HBatchNo" v-model="lailiaoInfo.HBatchNo" />
               </view>
            </view>
            <view class="item">
               <view class="left">数量:</view>
               <view class="right">
                  <input name="HQty" v-model="lailiaoInfo.HQty" />
               </view>
            </view>
            <view class="item">
               <view class="left">MTO号:</view>
               <view class="right">
                  <input name="HMTONo" v-model="lailiaoInfo.HMTONo" />
               </view>
            </view>
            <view class="item">
               <view class="left">供应商:</view>
               <view class="right">
                  <input name="HSupName" v-model="lailiaoInfo.HSupName" />
               </view>
            </view>
            <view class="item">
               <view class="left">供应商简称:</view>
               <view class="right">
                  <input name="HSupNameShort" v-model="lailiaoInfo.HSupNameShort" />
               </view>
            </view>
         </view>
      </view>
      <view class="operation-zone">
         <button class="btn-c" :disabled="buttonStatus.btn1 == false" @click="GenereateBarCode">生成</button>
         <button class="btn-c" :disabled="buttonStatus.btn2 == false" @click="print">打印</button>
         <view></view>
         <button class="btn-c" @click="setClearLailiaoInfo">新增</button>
         <button class="btn-c" @click="exit">退出</button>
      </view>
      <labelPrinterComponentVue ref="labelPrinter" :printInfo="printInfo" :printMode="'cpcl'">
      </labelPrinterComponentVue>
   </view>
    <view class="container">
        <view class="content">
            <view class="header">基本信息</view>
            <view class="items">
                <view class="item">
                    <view class="left">条码编号:</view>
                    <view class="right barcode">
                        <input :focus="HBarCodeFocus" name="HBarCode" v-model="lailiaoInfo.barCodeNo"
                            @focus="lailiaoInfo.barCodeNo = ''" @confirm="barCodeEntryHandler(lailiaoInfo.barCodeNo)"
                            placeholder="请扫描商品条码" />
                    </view>
                    <view>
                        <uni-icons type="scan"
                            style="background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;font-weight: 500;"
                            size="20" @click="toScanCode"></uni-icons>
                    </view>
                </view>
                <view class="item">
                    <view class="left">源单号:</view>
                    <view class="right">
                        <input name="HBillNo" disabled v-model="lailiaoInfo.HBillNo" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">源单行号:</view>
                    <view class="right">
                        <input name="HBillLineNo" disabled v-model="lailiaoInfo.HBillLineNo" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">物料编码:</view>
                    <view class="right">
                        <input name="HMaterNo" disabled v-model="lailiaoInfo.HMaterNumber" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">物料名称:</view>
                    <view class="right">
                        <input name="HMaterName" disabled v-model="lailiaoInfo.HMaterName" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">规格型号:</view>
                    <view class="right">
                        <input name="HMaterType" disabled v-model="lailiaoInfo.HMaterModel" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">批次:</view>
                    <view class="right">
                        <input name="HBatchNo" disabled v-model="lailiaoInfo.HBatchNo" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">数量:</view>
                    <view class="right">
                        <input name="HQty" disabled v-model="lailiaoInfo.HQty" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">MTO号:</view>
                    <view class="right">
                        <input name="HMTONo" disabled v-model="lailiaoInfo.HMTONo" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">供应商:</view>
                    <view class="right">
                        <input name="HSupName" disabled v-model="lailiaoInfo.HSupName" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">供应商简称:</view>
                    <view class="right">
                        <input name="HSupNameShort" disabled v-model="lailiaoInfo.HSupNameShort" />
                    </view>
                </view>
            </view>
        </view>
        <view class="operation-zone">
            <button class="btn-c" :disabled="buttonStatus.btn1" @click="GenereateBarCode">生成</button>
            <button class="btn-c" :disabled="buttonStatus.btn2" @click="print">打印</button>
            <view></view>
            <button class="btn-c" @click="setClearLailiaoInfo">新增</button>
            <button class="btn-c" @click="exit">退出</button>
        </view>
        <labelPrinterComponentVue ref="labelPrinter" :printInfo="printInfo" :printMode="'cpcl'">
        </labelPrinterComponentVue>
    </view>
</template>
<script>
   import labelPrinterComponentVue from '../../components/labelPrinterComponent/labelPrinterComponent.vue';
   import {
      CBar,
      CBox,
      CForm,
      CImage,
      CLine,
      CCodeRotation,
      CCodeType,
      CPage,
      CText,
      CFont,
      CBold,
      CRotation,
      CInverse,
      CMag,
      CQRCode,
      CCorrectLevel,
      CSN,
      CStatus,
      CPCL,
   } from "@psdk/cpcl";
   import {
      CommonUtils
   } from '../../utils/common';
   import {
      getUserInfo
   } from "@/utils/auth.js";
   export default {
      data() {
         return {
            printInfo: "",
            userInfo: getUserInfo(),
            buttonStatus: {
               btn1: true,
               btn2: false
            },
            generatedBarCode: '',
            lailiaoInfo: {
               HMainID:'',
               HSubID:'',
               HOrderBillNo:'',
               HMaterID:'',
               barCodeNo: '',
               HBillNo: '',
               HBillLineNo: '',
               HMaterNumber: '',
               HMaterName: '',
               HMaterModel: '',
               HBatchNo: '',
               HQty: '',
               HMTONo: '',
               HSupName: '',
               HSupNameShort: '',
               HMinQty:'',
               HBQty:'',
               HSupID: ''
            }
         };
      },
      components: {
         labelPrinterComponentVue
      },
      methods: {
         async print() {
            if (this.$printer.isConnected() === false) {
               this.$refs.labelPrinter.openPopup()
            } else {
               // this.printInfo = async () => {
               //    let cpcl = await this.$printer.cpcl().clear()
               //       .page(new CPage({
               //          width: 608,
               //          height: 400
               //       }))
               //       .qrcode(new CQRCode({
               //          x: 500,
               //          y: 30,
               //          width: 3,
               //          content: this.generatedBarCode,
               //          codeRotation: CCodeRotation.ROTATION_0,
               //          level: CCorrectLevel.L
               //       }))
               //       .text(new CText({
               //          x: 30,
               //          y: 30,
               //          content: "供应商: ",
               //          font: CFont.TSS24
               //       }))
               //       .text(new CText({
               //          x: 30,
               //          y: 80,
               //          content: "供应商料号: ",
               //          font: CFont.TSS24
               //       }))
               //       .text(new CText({
               //          x: 30,
               //          y: 130,
               //          content: "物料编码: ",
               //          font: CFont.TSS24
               //       }))
               //       .text(new CText({
               //          x: 30,
               //          y: 180,
               //          content: "物料分组: ",
               //          font: CFont.TSS24
               //       }))
               //       .text(new CText({
               //          x: 300,
               //          y: 180,
               //          content: "规格型号: ",
               //          font: CFont.TSS24
               //       }))
               //       .text(new CText({
               //          x: 30,
               //          y: 230,
               //          content: "数量: ",
               //          font: CFont.TSS24
               //       }))
               //       .text(new CText({
               //          x: 300,
               //          y: 230,
               //          content: "日期: ",
               //          font: CFont.TSS24
               //       }))
               //       .text(new CText({
               //          x: 30,
               //          y: 280,
               //          content: "检验员: ",
               //          font: CFont.TSS24
               //       }))
               //       .text(new CText({
               //          x: 300,
               //          y: 280,
               //          content: "计划跟踪号: ",
               //          font: CFont.TSS24
               //       }))
               //       .text(new CText({
               //          x: 30,
               //          y: 330,
               //          content: "检验结果: ",
               //          font: CFont.TSS24
               //       }))
               //       .box(new CBox({
               //          topLeftX: 260,
               //          topLeftY: 320,
               //          bottomRightX: 280,
               //          bottomRightY: 340,
               //          lineWidth: 4,
               //       }))
               //       .text(new CText({
               //          x: 290,
               //          y: 320,
               //          content: "合格",
               //          font: CFont.TSS24
               //       }))
               //       .box(new CBox({
               //          topLeftX: 360,
               //          topLeftY: 320,
               //          bottomRightX: 380,
               //          bottomRightY: 340,
               //          lineWidth: 4,
               //       }))
               //       .text(new CText({
               //          x: 390,
               //          y: 320,
               //          content: "不合格",
               //          font: CFont.TSS24
               //       }))
               //       .box(new CBox({
               //          topLeftX: 480,
               //          topLeftY: 320,
               //          bottomRightX: 500,
               //          bottomRightY: 340,
               //          lineWidth: 4,
               //       }))
               //       .text(new CText({
               //          x: 510,
               //          y: 320,
               //          content: "特采",
               //          font: CFont.TSS24
               //       }))
               //       .form(new CForm())
               //       .print();
               //    console.log(cpcl.command().string())
               //    return cpcl.command().binary()
               // }
               // await this.$nextTick(() => {
               //    this.$refs.labelPrinter.execPrint()
               // })
    import labelPrinterComponentVue from '../../components/labelPrinterComponent/labelPrinterComponent.vue';
    import {
        CBar,
        CBox,
        CForm,
        CImage,
        CLine,
        CCodeRotation,
        CCodeType,
        CPage,
        CText,
        CFont,
        CBold,
        CRotation,
        CInverse,
        CMag,
        CQRCode,
        CCorrectLevel,
        CSN,
        CStatus,
        CPCL,
    } from "@psdk/cpcl";
    import {
        CommonUtils
    } from '../../utils/common';
    import {
        getUserInfo
    } from "@/utils/auth.js";
    export default {
        data() {
            return {
                HBarCodeFocus: false,
               this.printInfo = `! 0 200 200 400 1
                printInfo: "",
                userInfo: getUserInfo(),
                buttonStatus: {
                    btn1: true,
                    btn2: true
                },
                barCodeMeta: '',
                generatedBarCode: '',
                lailiaoInfo: {
                    HMainID: '',
                    HSubID: '',
                    HOrderBillNo: '',
                    HMaterID: '',
                    // barCodeNo: '',
                    HBillNo: '',
                    HBillLineNo: '',
                    HMaterNumber: '',
                    HMaterName: '',
                    HMaterModel: '',
                    HPcsName: '',
                    HBatchNo: '',
                    HQty: '',
                    HMTONo: '',
                    HSupName: '',
                    HSupNameShort: '',
                    HMinQty: '',
                    HBQty: '',
                    HSupID: '',
                    HUnitID: '',
                    HDate: '',
                    HSourceBillNo: '',
                    HMaker: getUserInfo()["Czymc"],
                    HSupNumber: '',
                    HCoilNO: '',
                    HFurnaceNO: '',
                    HFactory: '',
               HInnerBillNo: '',
                }
            };
        },
        components: {
            labelPrinterComponentVue
        },
        onLoad() {
            this.HBarCodeFocus = true
        },
        methods: {
            async refreshBarcodeState() {
                this.HBarCodeFocus = false
                await this.$nextTick(() => {
                    this.HBarCodeFocus = true
                    this.lailiaoInfo.barCodeNo = ""
                })
            },
            async print() {
                if (this.$printer.isConnected() === false) {
                    this.$refs.labelPrinter.openPopup()
                } else {
                    let HBarCodeNoStr =
                        // `${this.lailiaoInfo.HBillNo}@${this.lailiaoInfo.HBillLineNo}@${this.lailiaoInfo.HMaterNumber || ''}@${this.lailiaoInfo.HMTONo || ''}@${parseFloat(this.lailiaoInfo.HQty||0).toFixed(10)}@${this.lailiaoInfo.HSupNumber || ''}`
                        `${this.lailiaoInfo.HBillNo}@${this.lailiaoInfo.HBillLineNo}@${this.lailiaoInfo.HMaterNumber || ''}@${this.lailiaoInfo.HMTONo || ''}@${this.lailiaoInfo.HQty||0}@${this.lailiaoInfo.HSupNumber || ''}`
                    let pcsInfo = this.lailiaoInfo.HPcsName ? '(' + this.lailiaoInfo.HPcsName + ')' : ''
                    this.printInfo = `! 0 200 200 400 1
PAGE-WIDTH 608
SETQRVER 3
B QR 500 30 M 2 U 3
LA,${this.generatedBarCode}
B QR 475 15 Q 0 U 3
LA,${HBarCodeNoStr}
ENDQR
T 24 0 30 30 供应商: ${this.lailiaoInfo.HSupName}
T 24 0 30 80 供应商料号:
T 24 0 30 130 物料编码: ${this.lailiaoInfo.HMaterName}
T 24 0 30 180 物料分组:
T 24 0 300 180 规格型号: ${this.lailiaoInfo.HMaterModel}
T 24 0 30 230 数量:  ${this.lailiaoInfo.HQty}
T 24 0 300 230 日期:
T 24 0 30 280 检验员:
T 24 0 300 280 计划跟踪号: ${this.lailiaoInfo.HMTONo || ''}
T 24 0 30 330 检验结果:
BOX 260 330 280 350 4
T 24 0 290 330 合格
BOX 360 330 380 350 4
T 24 0 390 330 不合格
BOX 480 330 500 350 4
T 24 0 510 330 特采
T 24 0 0 30 供应商: ${this.lailiaoInfo.HSupName}
T 55 0 0 55 (Supplier)
T 24 0 0 75 供应商料号:  ${this.lailiaoInfo.HMaterNumber}
T 55 0 0 100 (Supplier Sku No.)
T 24 0 0 120 物料名称: ${this.lailiaoInfo.HMaterName}
T 55 0 0 145 (Material Code)
T 24 0 0 165 款号: ${this.lailiaoInfo.HCoilNO}
T 55 0 0 190 (Style No.)
T 24 0 300 165 客户编号: ${this.lailiaoInfo.HFactory}
T 55 0 300 190 (Consumer No.)
T 24 0 0 210 分组: ${this.lailiaoInfo.HFurnaceNO || ''}
T 55 0 0 235 (Group)
T 24 0 300 210 规格: ${this.lailiaoInfo.HMaterModel}
T 55 0 300 235 (SKU NO.)
T 24 0 0 255 数量:  ${ parseFloat(this.lailiaoInfo.HQty || 0).toFixed(0) } ${pcsInfo}
T 55 0 0 280 (Quantity)
T 24 0 300 255 日期: ${this.lailiaoInfo.HDate || ''}
T 55 0 300 280 (Date)
T 24 0 0 300 检验员:
T 55 0 0 325 (QC)
T 24 0 300 300 采购单号: ${this.lailiaoInfo.HBillNo || ''}
T 55 0 300 325 (Purchase Order No.)
T 24 0 0 345 检验结果:
T 55 0 0 370 (Inspection status)
BOX 240 345 260 365 4
T 24 0 270 345 合格
T 55 0 250 370 (Pass)
BOX 340 345 360 365 4
T 24 0 370 345 不合格
T 55 0 370 370 (Fail)
BOX 460 345 480 365 4
T 24 0 490 345 特采
T 55 0 440 370 (Spec. accepted)
FORM
PRINT`
                    await this.$nextTick(() => {
                        this.$refs.labelPrinter.execPrint()
                    })
                }
            },
            setLailiaoInfo(data, row, HQty) {
                let d = data[0]
                // console.log('数量: ', parseFloat(d['数量']).toFixed(10));
                this.lailiaoInfo = Object.assign(this.lailiaoInfo, {
                    HMaterNumber: d['物料编码'],
                    HMaterName: d['物料名称'],
                    HMaterModel: d['规格型号'],
                    // HBatchNo: d['批号'],
                    HQty: !CommonUtils.isEmpty(HQty) ? HQty : d['数量'],
                    HMinQty: d['数量'],
                    HBQty: d['数量'],
                    HSupID: d['HSupID'],
                    HSupNumber: d['供应商代码'],
                    HSupName: d['供应商'],
                    HUnitID: d['HUnitID'],
                    HPcsName: d['计量单位'],
                    HSupNameShort: d['供应商'],
                    HMTONo: d['计划跟踪号'],
                    HMainID: d['hmainid'],
                    HSubID: d['HEntryID'],
                    HMaterID: d['HMaterID'],
                    HDate: d['日期'],
                    HCoilNO: d['款号'] || '',
                    HFurnaceNO: d['分组'] || '',
                    HFactory: d['客户编号'] || '',
                })
                CommonUtils.playSound(1)
                this.buttonStatus.btn2 = true
            },
            setClearLailiaoInfo() {
                this.lailiaoInfo = {
                    HMainID: '',
                    HSubID: '',
                    HOrderBillNo: '',
                    HMaterID: '',
                    barCodeNo: '',
                    HBillNo: '',
                    HBillLineNo: '',
                    HMaterNumber: '',
                    HMaterName: '',
                    HMaterModel: '',
                    HPcsName: '',
                    HBatchNo: '',
                    HQty: '',
                    HMTONo: '',
                    HSupName: '',
                    HSupNameShort: '',
                    HMinQty: '',
                    HBQty: '',
                    HSupID: '',
                    HUnitID: '',
                    HDate: '',
                    HSourceBillNo: '',
                    HSupNumber: '',
                    HCoilNO: '',
                    HFurnaceNO: '',
                    HFactory: '',
                }
                this.buttonStatus = {
                    btn1: true,
                    btn2: false
                }
                this.refreshBarcodeState()
            },
            barCodeEntryHandler(barCode) {
                if (CommonUtils.isEmpty(barCode) === false) {
                    console.log('条码内容:' + barCode);
                    this.lailiaoInfo.barCodeNo = barCode;
                    if (barCode.includes("@") === false) {
                        this.buttonStatus.btn2 = false
                        CommonUtils.playSound(0)
                        this.refreshBarcodeState()
                        return uni.showToast({
                            icon: 'none',
                            title: '条码格式错误,请重新扫描...'
                        })
                    }
                    let barCodeInfo = barCode.split("@")
                    let [PurchaseBillNo, Row, MaterNumber, MTO, HQty, HSupNumber] = barCodeInfo
                    this.lailiaoInfo.HBillNo = PurchaseBillNo
               this.lailiaoInfo.HInnerBillNo = PurchaseBillNo
                    this.lailiaoInfo.HSourceBillNo = PurchaseBillNo
                    this.lailiaoInfo.HBillLineNo = Row
                    CommonUtils.doRequest(
                        "/Cg_POOrderBill/list", {
                            sWhere: ` and 单据号 = '${PurchaseBillNo}' and 行号 = ${Row}`,
                            user: this.userInfo.Czymc,
                        },
                        (res) => {
                            console.log('采购订单: ', res)
                            let {
                                data,
                                count,
                                Message
                            } = res.data
                            if (count > 0) {
                                console.log('data: ', data);
                                this.setLailiaoInfo(data, Row, HQty)
                                // uni.showToast({
                                //     icon: 'none',
                                //     title: Message
                                // })
                                this.buttonStatus.btn1 = false
               await this.$nextTick(() => {
                  this.$refs.labelPrinter.execPrint()
               })
            }
         },
         setLailiaoInfo(data, row) {
            if(row > data.length) {
               return uni.showToast({
                  icon: 'none',
                  title: '查询的单据号不存在...'
               })
            }
            let d = data[row - 1]
            this.lailiaoInfo = Object.assign(this.lailiaoInfo, {
               HMaterNumber: d['物料编码'],
               HMaterName: d['物料名称'],
               HMaterModel: d['规格型号'],
               HBatchNo: d['批号'],
               HQty: d['数量'],
               HMinQty: d['数量'],
               HBQty: d['数量'],
               HSupID: d['HSupID'],
               HSupName: d['供应商'],
               HSupNameShort: d['供应商'],
               HMTONo: d['订单跟踪号'],
               HMainID:d['linterid'],
               HSubID:d['HEntryID'],
               HMaterID:d['HMaterID'],
            })
         },
         setClearLailiaoInfo() {
            this.lailiaoInfo = {
               HMainID:'',
               HSubID:'',
               HOrderBillNo:'',
               HMaterID:'',
               barCodeNo: '',
               HBillNo: '',
               HBillLineNo: '',
               HMaterNumber: '',
               HMaterName: '',
               HMaterModel: '',
               HBatchNo: '',
               HQty: '',
               HMTONo: '',
               HSupName: '',
               HSupNameShort: '',
               HMinQty:'',
               HBQty:'',
            }
            this.buttonStatus = {
               btn1: true,
               btn2: false
            }
         },
         toScanCode() {
            uni.scanCode({
               onlyFromCamera: true,
               success: (res) => {
                  if (CommonUtils.isEmpty(res.result) === false) {
                     console.log('条码内容:' + res.result);
                     this.lailiaoInfo.barCodeNo = res.result;
                     if (res.result.includes("@") === false) {
                        return uni.showToast({
                           icon: 'none',
                           title: '条码格式错误,请重新扫描...'
                        })
                     }
                     let barCodeInfo = res.result.split("@")
                     let [PurchaseBillNo, Row] = barCodeInfo
                     this.lailiaoInfo.HBillNo = PurchaseBillNo,
                     this.lailiaoInfo.HBillLineNo = Row
                     console.log( {
                           sWhere: ` and 单据号 = '${PurchaseBillNo}'`,
                           user: this.userInfo.Czymc,
                        })
                     CommonUtils.doRequest(
                        "/Cg_POOrderBill/list", {
                           sWhere: ` and 单据号 = '${PurchaseBillNo}'`,
                           user: this.userInfo.Czymc,
                        },
                        (res) => {
                           console.log('采购订单: ', res)
                           let {data, count} = res.data
                           if(count > 0){
                              this.setLailiaoInfo(data, Row)
                           }
                        },
                        (error) => {
                            } else {
                                CommonUtils.playSound(0)
                                this.refreshBarcodeState()
                                // uni.showToast({
                                //     icon: 'none',
                                //     title: Message
                                // })
                                this.buttonStatus.btn1 = true
                                this.buttonStatus.btn2 = true
                            }
                        },
                        (error) => {
                            CommonUtils.playSound(0)
                            this.refreshBarcodeState()
                            this.buttonStatus.btn1 = true
                            this.buttonStatus.btn2 = true
                        }
                    )
                        }
                     )
                }
            },
            toScanCode() {
                var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
                mpaasScanModule.mpaasScan({
                    'hideAlbum': true,
                    'timeoutInterval': '10', //超时时间
                    'timeoutText': '未识别到二维码' //超时提醒
                }, (ret) => {
                    console.log(ret.resp_result)
                    if (CommonUtils.isEmpty(ret.resp_result) === false) {
                        console.log('条码内容:' + ret.resp_result);
                        this.lailiaoInfo.barCodeNo = ret.resp_result;
                        if (ret.resp_result.includes("@") === false) {
                            return uni.showToast({
                                icon: 'none',
                                title: '条码格式错误,请重新扫描...'
                            })
                        }
                        // let barCodeInfo = ret.resp_result.split("@")
                        // let [PurchaseBillNo, Row] = barCodeInfo
                        // this.lailiaoInfo.HBillNo = PurchaseBillNo,
                        //     this.lailiaoInfo.HBillLineNo = Row
                        // console.log({
                        //     sWhere: ` and 单据号 = '${PurchaseBillNo}'`,
                        //     user: this.userInfo.Czymc,
                        // })
                        // CommonUtils.doRequest(
                        //     "/Cg_POOrderBill/list", {
                        //         sWhere: ` and 单据号 = '${PurchaseBillNo}'`,
                        //         user: this.userInfo.Czymc,
                        //     },
                        //     (res) => {
                        //         console.log('采购订单: ', res)
                        //         let {
                        //             data,
                        //             count
                        //         } = res.data
                        //         if (count > 0) {
                        //             this.setLailiaoInfo(data, Row)
                        //         }
                        //     },
                        //     (error) => {
                  }
               }
            });
         },
         GenereateBarCode(){
            let sMain = []
            sMain[0] = this.lailiaoInfo
            let sMainStr = JSON.stringify(sMain);
            //获取选择的组织
            let HOrgType = uni.getStorageSync('Organization');
            //获取选择的工厂代码
            let CampanyName = "xxx";
            //获取选择的源单类型
            let HSourceBillType = "来料通知单";
            //获取选择的条码类型
            let HSelectBarCodeType = "唯一条码";
            //获取当前登录人员
            let UserName = uni.getStorageSync('HUserName');
            let sMainSub = sMainStr + ';' + HOrgType + ';' + HSourceBillType + ';' + HSelectBarCodeType + ';' + CampanyName + ';' + UserName;
            CommonUtils.doRequest(
            "/Sc_BarCode/Sub_SaveBill",
            {
               msg: sMainSub,
               CampanyName: CampanyName
            },
            (res) => {
               console.log(res)
               let {data, count, Message} = res.data
               if(count > 0){
                  this.buttonStatus = {
                     btn1: false,
                     btn2: true
                  }
                  this.generatedBarCode = data[0]['条码编号']
                  console.log(this.generatedBarCode)
                  uni.showToast({
                     icon: 'none',
                     title: Message
                  })
               }else {
                  uni.showToast({
                     icon: 'none',
                     title: Message
                  })
               }
            },
            (err) => {
                        //     }
                        // )
                        this.barCodeEntryHandler(ret.resp_result)
                    }
                })
            },
            GenereateBarCode() {
                let HBarCodeNoStr =
                    `${this.lailiaoInfo.HBillNo}@${this.lailiaoInfo.HBillLineNo}@${this.lailiaoInfo.HMaterNumber || ''}@${this.lailiaoInfo.HMTONo || ''}@${this.lailiaoInfo.HQty || 0}@${this.lailiaoInfo.HSupNumber  || ''}`
                let sMain = []
                sMain[0] = this.lailiaoInfo
                let sMainStr = JSON.stringify(sMain);
                //获取选择的组织
                let HOrgType = uni.getStorageSync('Organization');
                //获取选择的工厂代码
                let CampanyName = "xxx";
                //获取选择的源单类型
                let HSourceBillType = "采购订单";
                //获取选择的条码类型
                let HSelectBarCodeType = "品种条码";
                //获取当前登录人员
                let UserName = uni.getStorageSync('HUserName');
                let sMainSub = sMainStr + ';' + HOrgType + ';' + HSourceBillType + ';' + HSelectBarCodeType + ';' +
                    CampanyName + ';' + UserName + ';' + HBarCodeNoStr +
               ';"' + this.lailiaoInfo.HFactory + '";"' + this.lailiaoInfo.HCoilNO +
                '";"' + this.lailiaoInfo.HFurnaceNO + '"';
               
            },
            "POST"
            )
         },
         exit() {
            uni.navigateBack()
         }
      }
   }
            console.log(sMainSub.split(';'))
                CommonUtils.doRequest(
                    "/Sc_BarCode/SaveBarCode_NoGenerate", {
                        msg: sMainSub,
                        CampanyName: CampanyName
                    },
                    (res) => {
                        console.log(res)
                        let {
                            data,
                            count,
                            Message
                        } = res.data
                        if (count > 0) {
                            // this.generatedBarCode = data[0]['条码编号']/
                            // console.log(this.generatedBarCode)
                            uni.showToast({
                                icon: 'none',
                                title: Message
                            })
                            this.buttonStatus = {
                                btn1: true,
                                btn2: false
                            }
                        } else {
                            this.buttonStatus = {
                                btn1: false,
                                btn2: false
                            }
                            uni.showToast({
                                icon: 'none',
                                title: Message
                            })
                        }
                    },
                    (err) => {
                        this.buttonStatus = {
                            btn1: false,
                            btn2: false
                        }
                        uni.showToast({
                            icon: 'none',
                            title: err
                        })
                    },
                    "POST"
                )
            },
            exit() {
                uni.navigateBack()
            }
        }
    }
</script>
<style lang="scss" scoped>
   * {
      box-sizing: border-box;
   }
    * {
        box-sizing: border-box;
    }
   input {
      padding: 8rpx 20rpx;
      font-size: 30rpx;
      line-height: 30rpx;
   }
    input {
        padding: 8rpx 20rpx;
        font-size: 30rpx;
        line-height: 30rpx;
    }
   .container {
      display: flex;
      flex-direction: column;
      height: 100vh;
      padding: 20rpx 0 ;
    .uni-input-input[disabled] {
        background-color: #e4e4e4;
    }
      .content {
         flex: 1;
         background-image: url('/static/svgs/folder_bg.svg');
         background-size: cover;
         padding: 20rpx;
         .header {
            font-size: 30rpx;
         }
         .items {
            display: flex;
            flex-direction: column;
            gap: 10rpx;
            padding: 40rpx 0rpx;
    .container {
        display: flex;
        flex-direction: column;
        height: 100vh;
        padding: 20rpx 0;
            .item {
               display: flex;
               flex-direction: row;
               padding: 0 10rpx;
               gap: 20rpx;
               font-size: 30rpx;
               // height: 1.5rem;
               // justify-content: center;
               align-items: center;
        .content {
            flex: 1;
            background-image: url('/static/svgs/folder_bg.svg');
            background-size: cover;
            padding: 20rpx;
               .left {
                  text-align: left;
                  width: 6rem;
               }
            .header {
                font-size: 30rpx;
            }
               .right {
                  flex: 1;
                  height: 100%;
                  padding: 6rpx 0;
                  border-radius: 22rpx;
                  border: 1px solid #e4e4e4;
                  background-color: #e4e4e4;
            .items {
                display: flex;
                flex-direction: column;
                gap: 10rpx;
                padding: 40rpx 0rpx;
                  >input {
                     height: auto;
                  }
               }
            }
         }
      }
                .item {
                    display: flex;
                    flex-direction: row;
                    padding: 0 10rpx;
                    gap: 20rpx;
                    font-size: 30rpx;
                    // height: 1.5rem;
                    // justify-content: center;
                    align-items: center;
      .operation-zone {
         height: 3rem;
         display: flex;
         align-items: center;
         justify-content: space-between;
         gap: 30rpx;
         padding: 20rpx;
         >view {
            flex: 1;
         }
         >button {
            width: 4rem;
            padding: 0;
            font-size: 25rpx;
            border-radius: 50rpx;
            line-height: 66rpx;
            font-size: 28rpx;
         }
         >button[disabled] {
            background-color: #acacac;
            color: #fff;
         }
         .btn-a{
            background-color: #acacac;
            color: #fff;
         }
         .btn-b{
            background-color: #41a863;
            color: #fff;
         }
         .btn-c{
            background-color: #3a78ff;
            color: #fff;
         }
      }
   }
                    .left {
                        text-align: left;
                        width: 6rem;
                    }
                    .right {
                        flex: 1;
                        height: 100%;
                        padding: 6rpx 0;
                        border-radius: 22rpx;
                        border: 1px solid #e4e4e4;
                        background-color: #e4e4e4;
                        >input {
                            height: auto;
                        }
                    }
                    .barcode {
                        background-color: #fff !important;
                    }
                }
            }
        }
        .operation-zone {
            height: 3rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 30rpx;
            padding: 20rpx;
            >view {
                flex: 1;
            }
            >button {
                width: 4rem;
                padding: 0;
                font-size: 25rpx;
                border-radius: 50rpx;
                line-height: 66rpx;
                font-size: 28rpx;
            }
            >button[disabled] {
                background-color: #acacac;
                color: #fff;
            }
            .btn-a {
                background-color: #acacac;
                color: #fff;
            }
            .btn-b {
                background-color: #41a863;
                color: #fff;
            }
            .btn-c {
                background-color: #3a78ff;
                color: #fff;
            }
        }
    }
</style>