TblTradInventoryIn.vue 8.2 KB
<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <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="meterialCode">
              <a-input
                v-model="model.meterialCode"
                placeholder="请输入物料编码"
                readonly
              ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="合同/订单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hth">
              <a-input-search
                v-model="model.hth"
                placeholder="请输入合同/订单号"
                @search="searchHth"

              />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="1">-->
<!--            <a >查询</a>-->
<!--          </a-col>-->
          <a-col :span="12">
            <a-form-model-item label="物料长描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="meterialReview">
              <a-input
                v-model="model.meterialReview"
                placeholder="请输入物料长描述"

              ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="物流单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wldh">
              <a-input
                v-model="model.wldh"
                placeholder="请输入物流单号"

              ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unit">
              <a-input
                v-model="model.unit"
                placeholder="请输入单位"

              ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否在途" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="iszt">
              <a-select
                ref="select"
                v-model:value="model.iszt"
              >
                <a-select-option value="1">在途</a-select-option>
                <a-select-option value="2">到库</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="供货商名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cs">
              <a-input
                v-model="model.cs"
                placeholder="请输入供货商名称"

              ></a-input>
            </a-form-model-item>
          </a-col>

          <a-col :span="12">
            <a-form-model-item label="品牌" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="brand">
              <a-input
                v-model="model.brand"
                placeholder="请输入品牌"

              ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="仓库" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="warehouse">
              <a-input
                v-model="model.warehouse"
                placeholder="请输入仓库"

              ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="入库数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="rksl">
              <a-input
                v-model="model.rksl"
                placeholder="请输入入库数量"
                @blur="changeRksl(model.rksl)"
              ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="采购员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operator">
              <a-input
                v-model="model.operator"
                placeholder="请输入采购员"

              ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="不良品数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="blpsl">
              <a-input type="number"
                v-model="model.blpsl"
                placeholder="请输入不良品数量"
                @blur="changeBlpsl(model.blpsl)"
              ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="异常原因" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ycyy">
              <a-input
                v-model="model.ycyy"
                placeholder="请输入异常原因"

              ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>

      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>
import { httpAction, getAction, selectUp } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'

export default {
  name: 'TblTradInventoryIn',

  components: {},
  props: {
    materialCode: String, //物料编码
    meterialReview: String, //物料长描述
    unit: String, //计量单位
    brand: String, //品牌
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false,
    },
  },
  data() {
    return {
      url:{
        searchHth: '/trade/tblTradeBidSub/queryHtInfoByHthAndWlbm'
      },
      model: {
        iszt: '1',
        operator: this.$store.state.user.info.realname,
        blpsl: 0,
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      validatorRules: {
        meterialCode: [{ required: true, message: '请输入物料编码!' },],
        hth: [{ required: true, message: '请输入合同/订单号!' },],
        meterialReview: [{ required: true, message: '请输入物料长描述!' },],
        wldh: [{ required: true, message: '请输入物流单号!' },],
        unit: [{ required: true, message: '请输入单位!' },],
        iszt: [{ required: true, message: '请选择是否在途!' },],
        cs: [{ required: true, message: '请输入供货商名称!' },],
        brand: [{ required: true, message: '请输入品牌!' },],
        warehouse: [{ required: true, message: '请输入仓库!' },],
        rksl: [{ required: true, message: '请输入入库数量!' },],
        operator: [{ required: true, message: '请输入采购员!' },],
      },
      confirmLoading: false,
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
  },
  created() {
    this.model.meterialCode = this.materialCode
    this.model.meterialReview = this.meterialReview
    this.model.unit = this.unit
    this.model.brand = this.brand
  },
  methods: {
    changeRksl(rksl){
      console.log(" this.model.sl", this.model.sl)
      console.log(" rksl", rksl)
      if (rksl < 0 ){
        this.$message.error("请输入正确的入库数量")
        return
      }
      this.model.blpsl = this.model.sl-rksl
    },
    changeBlpsl(blpsl){
      if (!this.model.hth){
        this.$message.error("请先查询合同/订单号信息")
      }

      if (blpsl < 0){
        this.$message.error("请输入正确的不良品数量")
      }
      //如果不良品数量大于0,增加对不良品的规则校验
      console.log("this.model.sl",this.model.sl)
      if (blpsl < this.model.sl){
        if (!this.model.ycyy){
          this.$message.error("请输入异常原因")
        }
      }

    },
    searchHth(){
      getAction(this.url.searchHth,{
        hth: this.model.hth,
        wlbm: this.materialCode
      }).then(res=>{
       if (res.success){
         // console.log(this.$store.state.user.info.realname)
         this.$set(this.model, "wldh", res.result.wldh);
         this.$set(this.model, "cs", res.result.cs);
         this.$set(this.model, "rksl", res.result.sl);
         this.$set(this.model, "sl", res.result.sl);
         // this.$set(this.model, "operator", this.$store.state.user.info.realname);


       }
      })
      console.log('根据订单号查询订单信息')
    }
  },
}
</script>