houshuai
2025-07-03 6bbceeae0a692ef60f429dbca889752fcb09ec9a
src/views/lsw/modules/LswMaterialInboundForm.vue
@@ -3,34 +3,45 @@
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-form-model-item label="产线" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="factoryId">
            <a-row :gutter="24">
              <a-col :span="24">
                <a-form-item
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  label=""
                >
                  <j-select-factory
                    :disabled="disabled"
                    v-model="model.factoryId"
                    :multi="true"
                    @back="backFactoryInfo"
                    :backProduction="true"
                    :treeProductOpera="true"
                  ></j-select-factory>
                </a-form-item>
              </a-col>
            </a-row>
          </a-form-model-item>
          <a-col :span="12">
            <a-form-model-item label="删除标记" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delFlag">
              <a-input-number v-model="model.delFlag" placeholder="请输入删除标记" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="产线ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="factoryId">
              <a-input v-model="model.factoryId" placeholder="请输入产线ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="库存地ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="warehouseId">
              <a-input v-model="model.warehouseId" placeholder="请输入库存地ID"  ></a-input>
            <a-form-model-item label="库存地" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="warehouseId">
              <j-search-select-tag v-model="model.warehouseId" placeholder="请选择库存地"
                                   dict="base_line_side_warehouse,warehouse_name,id"></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">
              <a-input v-model="model.materialNumber" placeholder="请输入物料编码"  ></a-input>
              <a-input v-model="model.materialNumber" placeholder="请输入物料编码"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="物料名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialName">
              <a-input v-model="model.materialName" placeholder="请输入物料名称"  ></a-input>
              <a-input v-model="model.materialName" placeholder="请输入物料名称"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="批次号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="batchNumber">
              <a-input v-model="model.batchNumber" placeholder="请输入批次号"  ></a-input>
              <a-input v-model="model.batchNumber" placeholder="请输入批次号"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
@@ -40,12 +51,13 @@
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="接收人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="receiver">
              <a-input v-model="model.receiver" placeholder="请输入接收人"  ></a-input>
              <j-select-user-by-dep v-model="model.receiver" placeholder="请输入接收人"></j-select-user-by-dep>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="接收时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="receiveTime">
              <j-date placeholder="请选择接收时间"  v-model="model.receiveTime" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" />
              <j-date placeholder="请选择接收时间" v-model="model.receiveTime" :show-time="true"
                      date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
@@ -56,89 +68,128 @@
<script>
  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
import { httpAction, getAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
import JDate from '@/components/jeecg/JDate'
import pick from 'lodash.pick'
import moment from 'moment'
import { duplicateCheck } from '@/api/api'//重复校验
import JTreeDict from '@/components/jeecg/JTreeDict'//分类字典树形下拉组件
import JSelectFactory from '../../../../src/components/jeecgbiz/JSelectFactory.vue'
  export default {
    name: 'LswMaterialInboundForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
export default {
  name: 'LswMaterialInboundForm',
  components: {
    JDate,
    JTreeDict,
    JSelectFactory
  },
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  data() {
    return {
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      confirmLoading: false,
      validatorRules: {
        factoryId: [
          { required: true, message: '产线是必选项', trigger: 'change' }
        ],
        warehouseId: [
          { required: true, message: '库存地是必选项', trigger: 'change' }
        ],
        materialNumber: [
          { required: true, message: '物料编码是必选项', trigger: 'change' }
        ],
        materialName: [
          { required: true, message: '物料名称是必选项', trigger: 'change' }
        ],
        batchNumber: [
          { required: true, message: '批次号是必选项', trigger: 'change' }
        ],
        quantity: [
          { required: true, message: '入库数量是必选项', trigger: 'change' }
        ],
        receiver: [
          { required: true, message: '接收人是必选项', trigger: 'change' }
        ],
        receiveTime: [
          { required: true, message: '接收时间是必选项', trigger: 'change' }
        ]
      },
      url: {
        add: '/lswmaterialinbound/lswMaterialInbound/add',
        edit: '/lswmaterialinbound/lswMaterialInbound/edit',
        queryById: '/lswmaterialinbound/lswMaterialInbound/queryById'
      }
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    }
  },
  created() {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model))
  },
  methods: {
    backFactoryInfo(info) {
      this.model.factoryIds = this.model.factoryId
      this.nextFactoryOptions = info.map((item, index, arr) => {
        let c = { label: item.text, value: item.value + '' }
        return c
      })
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/lswmaterialinbound/lswMaterialInbound/add",
          edit: "/lswmaterialinbound/lswMaterialInbound/edit",
          queryById: "/lswmaterialinbound/lswMaterialInbound/queryById"
        }
      }
    add() {
      this.edit(this.modelDefault)
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    edit(record) {
      this.model = Object.assign({}, record)
      this.visible = true
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
    submitForm() {
      const that = this
      // 触发表单验证
      this.$refs.form.validate(valid => {
        if (valid) {
          that.confirmLoading = true
          let httpurl = ''
          let method = ''
          if (!this.model.id) {
            httpurl += this.url.add
            method = 'post'
          } else {
            httpurl += this.url.edit
            method = 'put'
          }
          httpAction(httpurl, this.model, method).then((res) => {
            if (res.success) {
              that.$message.success(res.message)
              that.$emit('ok')
            } else {
              that.$message.warning(res.message)
            }
          }).finally(() => {
            that.confirmLoading = false
          })
        }
        })
      },
      })
    }
  }
}
</script>