xiaojiao
2026-03-23 f02d3a8ffc05a10a64859b2a16d5d43c8abb0fb9
ÏîÄ¿´úÂë/PDA/pages/Inbound/InboundBoxing_New.vue
@@ -27,7 +27,7 @@
               <u-td width="30%">轴承条码</u-td>
               <u-td>
                  <u-input v-model="value_qrcode" :border="true" :focus="qrcodeFocus"
                     placeholder="请输入轴承条码" />
                     placeholder="请输入轴承条码" @input="barcodeChange" />
               </u-td>
            </u-tr>
            <u-tr>
@@ -35,8 +35,8 @@
               <!-- <u-td>
                  <u-input v-model="materielId" :border="true"  placeholder="" />
               </u-td> -->
               <xfl-select :list="CxTypes" :initValue="'请选择'" :clearable="false" @change="Get_VehicleType_Alls"
                  ref="Get_VehicleType_All">
               <xfl-select :list="CxTypes" :initValue="stateInitValueCarmodel" :clearable="false" @change="Get_VehicleType_Alls"
                  ref="Get_VehicleType_All" :key="CarmodelKey">
               </xfl-select>
            </u-tr>
            <u-tr>
@@ -46,7 +46,7 @@
                <xfl-select 
                    v-if="showBearingSelect"
                    :list="BearingModels" 
                    :initValue="'请选择'"
                    :initValue="stateInitValueBearingModel"
                    :clearable="false" 
                    @change="BearingModelss"
                    ref="BearingModelsss" 
@@ -55,9 +55,9 @@
              </u-td>
            </u-tr>
            <u-tr>
               <u-td width="30%">厂家</u-td>
               <u-td width="30%">轴承品牌</u-td>
               <u-td>
                  <u-input v-model="madeUnit" :border="true" :disabled="true"  placeholder="自动获取厂家" />
                  <u-input v-model="madeUnit" :border="true" :disabled="true"  placeholder="自动获取轴承品牌" />
               </u-td>
            </u-tr>
            
@@ -67,7 +67,7 @@
                  <u-input v-model="NewOrOld" :border="true"  placeholder="" />
               </u-td> -->
               <u-td>
                  <xfl-select :list="StateArray" :initValue="'请选择'" :clearable="false" @change="StateChange"
                  <xfl-select :key="stateKey" :list="StateArray" :initValue="stateInitValue" :clearable="false" @change="StateChange"
                     ref="StateSelect">
                  </xfl-select>
               </u-td>
@@ -105,7 +105,15 @@
   export default {
      data() {
         return {
            bearingSelectKey: 0, // ä¿ç•™key作为双保险
            stateKey: 0, // æ–°å¢žï¼šæŽ§åˆ¶ç»„件重建 ã€è½´æ‰¿ç±»åˆ«ã€‘
            stateInitValue: '请选择', // åˆå§‹å€¼ï¼ŒåŽç»­åŠ¨æ€ä¿®æ”¹ã€è½´æ‰¿ç±»åˆ«ã€‘
            bearingSelectKey: 0, // ä¿ç•™key作为双保险 ã€è½´æ‰¿åž‹å·ã€‘
            stateInitValueBearingModel:'请选择', //【轴承型号】
            CarmodelKey: 0, //【车型】
            stateInitValueCarmodel:'请选择', // ã€è½¦åž‹ã€‘
            showBearingSelect: true, // æ–°å¢žï¼šæŽ§åˆ¶ç»„件销毁/创建
            date: '',
            CurrentUser: '', //当前用户
@@ -131,17 +139,59 @@
            BearingModels:[], // å¯¹åº”车型下面的所有轴承型号
            templists:[], // ä¸´æ—¶ä¿å­˜ è½´æ‰¿åž‹å· å’Œ åނ家
            StateArray: [{
                  label: 'RO',
                  label: 'R0',
                  value: '新造'
               },{
                  label: 'R1',
                  value: '检修'
               }]
         }
         }
      },
      methods: {
         barcodeChange(){
            // 1. æ‹¿åˆ°åŽŸå§‹çš„ç±»JSON字符串(如:{'轴承条码':'1','车型':'2',...})
            if(_this.value_qrcode.length > 60){
               const rawStr = _this.value_qrcode;
               // 2. ä¿®å¤æ ¼å¼ï¼ˆå•引号→双引号 + åˆ å°¾é€—号)
               const fixedStr = rawStr.replace(/'/g, '"').replace(/,\s*}/, '}');
               console.log(fixedStr)
               // 3. è§£æžä¸ºå­—典(对象)
               const temp_dict = JSON.parse(fixedStr);
               console.log(temp_dict)
               // 4. æ­£ç¡®èŽ·å–å€¼
               console.log(temp_dict['轴承条码']); // è¾“出:1(不再是undefined)
               _this.value_qrcode = temp_dict['轴承条码'];
               _this.madeUnit = temp_dict["厂家"]
               _this.LotNumber = temp_dict["轴承单号"]
               _this.Bearing_Category(temp_dict["轴承类别"])
               _this.BearingModel(temp_dict["轴承型号"])
               _this.Carmodel(temp_dict["车型"])
            }
         },
         Bearing_Category (type_name){
            _this.stateKey += 1; // 1. å…ˆæ”¹key,强制销毁旧组件
            _this.stateInitValue = type_name;
            const matchedItem = _this.StateArray.find(item => item.value == type_name);
                if (matchedItem) {
                  _this.NewOrOld = matchedItem.label;
                }
               console.log(_this.NewOrOld)
         },
         Carmodel(type_name){ // è½¦åž‹
            _this.CarmodelKey += 1;
            _this.stateInitValueCarmodel = type_name;
            _this.materielId = type_name;
         },
         BearingModel(type_name){ // è½´æ‰¿åž‹å·
            _this.bearingSelectKey += 1;
            _this.stateInitValueBearingModel = type_name;
            _this.materielType = type_name;
         },
         UserChange(value) {
         },
         VehicleType(){
            let data = {};
@@ -244,20 +294,33 @@
            }
         },
         initInfo() {
            _this.madeUnit = '';
            _this.materielId = '';
            _this.materielType = '';
            _this.NewOrOld = '';
            //_this.madeUnit = '';
            //_this.materielId = '';
            //_this.materielType = '';
            //_this.NewOrOld = '';
            _this.LotNumber = '';
            _this.ProductDate = '';
            //_this.ProductDate = '';
         },
         SaveInfomation() {
            let data = {
               MainData: {
                  rfid: _this.value_rfid,
                  qrcode: _this.value_qrcode,
                  madeUnit: _this.madeUnit,
                  materielId: _this.materielId,
                  materielType: _this.materielType,
                  NewOrOld: _this.NewOrOld,
                  LotNumber: _this.LotNumber,
                  ProductDate: _this.ProductDate
               },
            };
            console.log("最后提交的组盘信息",data)
            //_this.LotNumber == '' ||
            if (_this.value_rfid.length == 0 || _this.value_qrcode.length == 0 ||
               _this.madeUnit == '' || _this.materielId == '' ||
               _this.materielType == '' || _this.NewOrOld == '' ||
                _this.ProductDate == '') {
               uni.showToast({
                  title: "组盘信息不能为空",
                  duration: 2000,
@@ -273,7 +336,7 @@
               });
               return;
            }
            //_this.LotNumber = '111111';
            uni.showModal({
               title: '提示',
               content: '是否确认组盘?',
@@ -304,6 +367,7 @@
                           _this.value_qrcode = "";
                           _this.initInfo();
                           _this.rfidFocus = true;
                        } else {
                           uni.showToast({
                              icon: 'none',
@@ -322,6 +386,17 @@
               }
            });
         },
         getCurrentDate() {
               const now = new Date();
               // èŽ·å–å¹´ã€æœˆã€æ—¥ï¼ˆè¡¥0处理,确保月份/日期是两位数)
               const year = now.getFullYear();
               const month = String(now.getMonth() + 1).padStart(2, '0'); // æœˆä»½ä»Ž0开始,需+1
               const day = String(now.getDate()).padStart(2, '0');
               // æ‹¼æŽ¥æˆYYYY-MM-DD格式
               this.currentDate = `${year}-${month}-${day}`;
               // å¦‚果需要返回值(比如接口传参),可以return这个结果
               return `${year}-${month}-${day}`;
             },
      },
      created: function() {
         // æ¯æ¬¡è¿›å…¥ç•Œé¢æ—¶ï¼Œå…ˆæ¸…除之前的所有定时器,然后启动新的定时器
@@ -341,6 +416,7 @@
      mounted() {
         _this = this;
         _this.rfidFocus = true;
         _this.ProductDate = this.getCurrentDate();
         this.VehicleType();
      },