xiaojiao
8 天以前 b532ba8806996246ab7a0896bf34b884c47dee7e
ÏîÄ¿´úÂë/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,20 +67,26 @@
                  <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>
               
            </u-tr>
            <u-tr>
               <u-td width="30%">轴承单号</u-td>
               <u-td width="30%">轴承批次号</u-td>
               <u-td>
                  <u-input v-model="LotNumber" :border="true"  placeholder="轴承单号" />
                  <u-input v-model="LotNumber" :border="true"  placeholder="轴承批次号" />
               </u-td>
            </u-tr>
            <u-tr>
               <u-td width="30%">生产日期</u-td>
               <u-td width="30%">轴承重量</u-td>
               <u-td>
                  <u-input v-model="Standard_value" :border="true"  placeholder="轴承重量" />
               </u-td>
            </u-tr>
            <u-tr>
               <u-td width="30%">生产/检修 æ—¥æœŸ</u-td>
               <u-td>
                  <u-input v-model="ProductDate" :border="true" :focus="prdateFocus" placeholder="生产日期" />
               </u-td>
@@ -105,7 +111,15 @@
   export default {
      data() {
         return {
            bearingSelectKey: 0, // ä¿ç•™key作为双保险
            stateKey: 0, // æ–°å¢žï¼šæŽ§åˆ¶ç»„件重建 ã€è½´æ‰¿ç±»åˆ«ã€‘
            stateInitValue: '请选择', // åˆå§‹å€¼ï¼ŒåŽç»­åŠ¨æ€ä¿®æ”¹ã€è½´æ‰¿ç±»åˆ«ã€‘
            bearingSelectKey: 0, // ä¿ç•™key作为双保险 ã€è½´æ‰¿åž‹å·ã€‘
            stateInitValueBearingModel:'请选择', //【轴承型号】
            CarmodelKey: 0, //【车型】
            stateInitValueCarmodel:'请选择', // ã€è½¦åž‹ã€‘
            showBearingSelect: true, // æ–°å¢žï¼šæŽ§åˆ¶ç»„件销毁/创建
            date: '',
            CurrentUser: '', //当前用户
@@ -131,17 +145,63 @@
            BearingModels:[], // å¯¹åº”车型下面的所有轴承型号
            templists:[], // ä¸´æ—¶ä¿å­˜ è½´æ‰¿åž‹å· å’Œ åނ家
            StateArray: [{
                  label: 'RO',
                  label: 'R0',
                  value: '新造'
               },{
                  label: 'R1',
                  value: '检修'
               }]
         }
               }],
            Standard_value:'', // ç§°é‡æ ‡å‡†å€¼
         }
      },
      methods: {
         barcodeChange(){
            // 1. æ‹¿åˆ°åŽŸå§‹çš„ç±»JSON字符串(如:{'轴承条码':'1','车型':'2',...})
            if(_this.value_qrcode.length > 60){
               const rawStr = _this.value_qrcode;
               console.log(_this.value_qrcode.length)
               // 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.Standard_value = temp_dict["轴承重量"]
               _this.ProductDate = 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 = {};
@@ -220,7 +280,7 @@
         BearingModelss(value){
            console.log("选择的轴承型号是",value.orignItem)
            // è¿™é‡Œèµ‹å€¼åނ家
            _this.templists.forEach(x => { // å…³é”®ï¼šforEach å°å†™e
            _this.templists.forEach(x => { // å…³é”®ï¼šforEach å°å†™
               if(value.orignItem == x.materiel_zc_id_list){
                  _this.madeUnit = x.materiel_zc_name_list
                  _this.materielType = value.orignItem
@@ -244,26 +304,43 @@
            }
         },
         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,
                  Standard_value: _this.Standard_value,
               },
            };
            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,
                  icon: 'none',
               });
               return;
            }
            if(_this.Standard_value == '' || _this.Standard_value == 0 || _this.Standard_value == "0"){
               _this.Standard_value = '0'
            }
            if (_this.value_rfid.length > 6) {
               uni.showToast({
@@ -273,7 +350,7 @@
               });
               return;
            }
            //_this.LotNumber = '111111';
            uni.showModal({
               title: '提示',
               content: '是否确认组盘?',
@@ -288,7 +365,8 @@
                           materielType: _this.materielType,
                           NewOrOld: _this.NewOrOld,
                           LotNumber: _this.LotNumber,
                           ProductDate: _this.ProductDate
                           ProductDate: _this.ProductDate,
                           Standard_value: _this.Standard_value,
                        },
                     };
                     console.log("最后提交的组盘信息",data)
@@ -302,8 +380,10 @@
                           });
                           _this.value_rfid = "";
                           _this.value_qrcode = "";
                           _this.Standard_value = "";
                           _this.initInfo();
                           _this.rfidFocus = true;
                        } else {
                           uni.showToast({
                              icon: 'none',
@@ -322,6 +402,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 +432,7 @@
      mounted() {
         _this = this;
         _this.rfidFocus = true;
         _this.ProductDate = this.getCurrentDate();
         this.VehicleType();
      },