zhangherong
3 天以前 9e1c79907d54bad69ee70e06a5ee6379c838094e
src/views/lsw/modules/LswMaterialInboundForm.vue
@@ -4,8 +4,15 @@
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="来源编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="originalCode">
            <a-form-model-item label="来源编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="originalCode"
                               v-if="model.inboundCategory !== 'MATERIAL_INNER_TRANSFER'">
              <a-input v-model="model.originalCode" placeholder="请输入来源编码"></a-input>
            </a-form-model-item>
            <a-form-model-item label="来源线边库" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="originalCode"
                               v-else>
              <j-search-select-tag v-model="model.originalCode" placeholder="请选择线边库"
                                   :dict-options="originalCodeDictOptions"
                                   @change="originalCodeSelectChange"></j-search-select-tag>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
@@ -16,12 +23,14 @@
          <a-col :span="12">
            <a-form-model-item label="线边库" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="warehouseId">
              <j-search-select-tag v-model="model.warehouseId" placeholder="请选择线边库"
                                   :dict-options="warehouseDictOptions" @change="warehouseSelectChange"></j-search-select-tag>
                                   :dict-options="warehouseDictOptions"
                                   @change="warehouseSelectChange"></j-search-select-tag>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="物料编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialNumber">
              <j-search-select-tag :dict-options="materialDictOptions" v-model="model.materialNumber" placeholder="请选择物料编码" @change="materialSelectChange"></j-search-select-tag>
              <j-search-select-tag :dict-options="materialDictOptions" v-model="model.materialNumber"
                                   placeholder="请选择物料编码" @change="materialSelectChange"></j-search-select-tag>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
@@ -47,7 +56,8 @@
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="入库类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inboundCategory">
              <j-search-select-tag v-model="model.inboundCategory" dict="material_inbound_category"></j-search-select-tag>
              <j-search-select-tag v-model="model.inboundCategory"
                                   dict="material_inbound_category"></j-search-select-tag>
            </a-form-model-item>
          </a-col>
        </a-row>
@@ -62,8 +72,7 @@
export default {
  name: 'LswMaterialInboundForm',
  components: {
  },
  components: {},
  props: {
    //表单禁用
    disabled: {
@@ -107,20 +116,27 @@
        ],
        quantity: [
          { required: true, message: '入库数量是必选项', trigger: 'change' }
        ],
        ]
      },
      url: {
        add: '/lsw/materialInbound/add',
        edit: '/lsw/materialInbound/edit',
        queryById: '/lsw/materialInbound/queryById',
        queryByProductionType: '/base/lineSideWarehouse/queryByProductionType',
        queryByMaterialCategory: '/lsw/lswMaterial/queryByMaterialCategory',
        queryByMaterialCategory: '/lsw/lswMaterial/queryByMaterialCategory'
      }
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
    originalCodeDictOptions() {
      return this.warehouseDictOptions.map(warehouse => ({
        ...warehouse,
        value: warehouse.warehouseCode,
        text: warehouse.warehouseName + '(' + warehouse.warehouseCode + ')'
      }))
    }
  },
  created() {
@@ -129,19 +145,19 @@
  },
  methods: {
    add(inboundCategory) {
      this.warehouseDictOptions = [];
      this.materialDictOptions = [];
      if(inboundCategory === 'HEAT_TREATMENT_INBOUND') {
        this.loadWarehouseDictOptions('OUTERFLANGE,INNERFLANGE');
        this.loadMaterialDictOptions('BLANK');
      }else if(inboundCategory === 'SMALL_INNER_RING') {
        this.loadWarehouseDictOptions('ASSEMBLE');
        this.loadMaterialDictOptions('SMALL_INNER_RING');
      } else if(inboundCategory === 'MATERIAL_INNER_TRANSFER') {
        this.loadWarehouseDictOptions('ASSEMBLE');
        this.loadMaterialDictOptions('STEEL_BALL');
      this.warehouseDictOptions = []
      this.materialDictOptions = []
      if (inboundCategory === 'HEAT_TREATMENT_INBOUND') {
        this.loadWarehouseDictOptions('OUTERFLANGE,INNERFLANGE')
        this.loadMaterialDictOptions('BLANK')
      } else if (inboundCategory === 'SMALL_INNER_RING') {
        this.loadWarehouseDictOptions('ASSEMBLE')
        this.loadMaterialDictOptions('SMALL_INNER_RING')
      } else if (inboundCategory === 'MATERIAL_INNER_TRANSFER') {
        this.loadWarehouseDictOptions('ASSEMBLE,OUTERFLANGE,INNERFLANG,HEATTREATMENT')
        this.loadMaterialDictOptions('OUTER_FLANGE,INNER_FLANGE,STEEL_BALL,BLANK,COMPONENTS')
      }
      this.modelDefault.inboundCategory = inboundCategory;
      this.modelDefault.inboundCategory = inboundCategory
      this.edit(this.modelDefault)
    },
    edit(record) {
@@ -178,35 +194,51 @@
      })
    },
    loadWarehouseDictOptions(productionType) {
      let params = {productionType : productionType}
      let params = { productionType: productionType }
      getAction(this.url.queryByProductionType, params).then(res => {
        if(res.success) {
          this.warehouseDictOptions = res.result.map(warehouse => ({...warehouse, value : warehouse.id, text: warehouse.warehouseName + '(' + warehouse.warehouseCode+')'}));
        if (res.success) {
          this.warehouseDictOptions = res.result.map(warehouse => ({
            ...warehouse,
            value: warehouse.id,
            text: warehouse.warehouseName + '(' + warehouse.warehouseCode + ')'
          }))
        }
      })
    },
    loadMaterialDictOptions(materialCategory) {
      let params = {materialCategory : materialCategory}
      let params = { materialCategory: materialCategory }
      getAction(this.url.queryByMaterialCategory, params).then(res => {
        if(res.success) {
          this.materialDictOptions = res.result.map(material => ({...material, value : material.materialNumber, text: material.materialNumber}));
        if (res.success) {
          this.materialDictOptions = res.result.map(material => ({
            ...material,
            value: material.materialNumber,
            text: material.materialNumber + '(' + material.materialName + ')'
          }))
        }
      })
    },
    warehouseSelectChange(value) {
      let warehouse = this.warehouseDictOptions.find(option => option.value === value)
      if(warehouse) {
      if (warehouse) {
        this.model.factoryId = warehouse.factoryId
      }else {
        this.model.factoryId = undefined;
      } else {
        this.model.factoryId = undefined
      }
    },
    materialSelectChange(value) {
      let material = this.materialDictOptions.find(option => option.value === value)
      if(material) {
      if (material) {
        this.model.materialName = material.materialName
      }else {
        this.model.materialName = undefined;
      } else {
        this.model.materialName = undefined
      }
    },
    originalCodeSelectChange(value) {
      let warehouse = this.originalCodeDictOptions.find(option => option.value === value)
      if (warehouse) {
        this.model.originalName = warehouse.warehouseName
      } else {
        this.model.originalName = undefined
      }
    }
  }