cuilei
2025-06-03 f43aeaa3b3960e7b886023a41bd799fce7232ce5
src/views/tms/modules/GoodsShelvesForm.vue
@@ -40,7 +40,7 @@
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="库位号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="true" :value="locationCode"  placeholder="请输入库位号"  ></a-input>
              <a-input v-model="model.locationCode"  placeholder="请输入库位号"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
@@ -87,6 +87,8 @@
          locationCode: '',
          remark: ''
        },
        autoLocationCode: '', // 自动拼接的库位号
        userEditedLocationCode: false,
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
@@ -125,7 +127,7 @@
        return this.disabled
      },
      //拼接库位号
      locationCode() {
      autoGeneratedLocationCode() {
        const { shelfNumber, storey, arrange, columnNumber } = this.model;
        if (shelfNumber || storey || arrange || columnNumber) {
          return `${shelfNumber}${storey}${arrange}${columnNumber}`;
@@ -182,10 +184,21 @@
      },
    },
    watch: {
      'model.shelfNumber': 'updateLocationCode',
      'model.storey': 'updateLocationCode',
      'model.arrange': 'updateLocationCode',
      'model.columnNumber': 'updateLocationCode'
      autoGeneratedLocationCode(newVal) {
        // 只有当用户没有手动输入时才自动填充
        if (!this.userEditedLocationCode) {
          this.model.locationCode = newVal;
        }
        this.autoLocationCode = newVal;
      },
      'model.locationCode'(newVal) {
        // 如果用户手动输入,则标记为已编辑
        if (newVal !== this.autoLocationCode) {
          this.userEditedLocationCode = true;
        } else {
          this.userEditedLocationCode = false;
        }
      }
    }
  }
</script>