TblTradeInquiryInfoForm.vue 10.2 KB
<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-card :bordered="false" title="供货商信息" type="inner">
          <a-row>
            <a-col :span="8" >
              <a-form-model-item label="供货商名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ghsmc">
                <a-input v-model="model.ghsmc" placeholder="请输入供货商名称" ></a-input>
              </a-form-model-item>
            </a-col>
          </a-row>

          <a-row>
            <a-col :span="8">
              <a-form-model-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lxr">
                <a-input v-model="model.lxr" placeholder="请输入联系人" ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tel">
                <a-input v-model="model.tel" placeholder="请输入电话" ></a-input>
              </a-form-model-item>
            </a-col>
          </a-row>

          <a-row>
            <a-col :span="8">
              <a-form-model-item label="微信号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wxh">
                <a-input v-model="model.wxh" placeholder="请输入微信号" ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="网址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wldz">
                <a-input v-model="model.wldz" placeholder="请输入网址" ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="网店" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wddz">
                <a-input v-model="model.wddz" placeholder="请输入网店地址" ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="开户行名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khhmc">
                <a-input v-model="model.khhmc" placeholder="请输入开户行名称" ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="银行账号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yhzh">
                <a-input v-model="model.yhzh" placeholder="请输入银行账号" ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="行号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hh">
                <a-input v-model="model.hh" placeholder="请输入行号" ></a-input>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-card>

        <a-card :bordered="false" title="价格信息" type="inner">
          <a-row>
            <a-col :span="8">
              <a-form-model-item label="专票单价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zpdj">
                <a-input-number v-model="model.zpdj" placeholder="请输入专票单价" style="width: 300px"></a-input-number>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="专票税率(%)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zpsl">
                <a-input-number v-model="model.zpsl" placeholder="请输入专票税率(%)" style="width: 300px"></a-input-number>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="8">
              <a-form-model-item label="普票单价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ppdj">
                <a-input-number v-model="model.ppdj" placeholder="请输入普票单价" style="width: 300px"></a-input-number>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="普票税率(%)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ppsl">
                <a-input-number v-model="model.ppsl" placeholder="请输入普票税率(%)" style="width: 300px"></a-input-number>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="8">
              <a-form-model-item label="无票单价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wpdj">
                <a-input-number v-model="model.wpdj" placeholder="请输入无票单价" style="width: 300px"></a-input-number>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-card>

        <a-card :bordered="false" title="运费信息" type="inner">
          <a-row>
            <a-col :span="8">
              <a-form-model-item label="是否含运费" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfhyf">
                <a-radio-group v-model="model.sfhyf" @change="onRadioChange">
                  <a-radio value="是">含运费</a-radio>
                  <a-radio value="否">不含运费</a-radio>
                </a-radio-group>
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-if="model.sfhyf == '否'">
              <a-form-model-item label="运费" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yf">
                <a-input-number v-model="model.yf" placeholder="请输入运费" style="width: 300px"></a-input-number>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-card>

        <a-card :bordered="false" title="出货信息" type="inner">
          <a-row>
            <a-col :span="8" >
              <a-form-model-item label="发货地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fhdz">
                <a-input v-model="model.fhdz" placeholder="请输入发货地址" ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="1" :offset="16"></a-col>
            <a-col :span="8">
              <a-form-model-item label="最小出货量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zxchl">
                <a-input v-model="model.zxchl" placeholder="请输入最小出货量" ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="1" :offset="16"></a-col>
            <a-col :span="8">
              <a-form-model-item label="L/T(交货周期天)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jhzqt">
                <a-input v-model="model.jhzqt" placeholder="请输入L/T(交货周期天)" ></a-input>
              </a-form-model-item>
            </a-col>

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

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'TblTradeInquiryInfoForm',
    components: {
    },
    props: {
      // 表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      },
      tradeId: {
        type: String,
        default: ''
      },
      wlbm: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
        model: {
          sfhyf: '是'
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        confirmLoading: false,
        validatorRules: {
          ghsmc: [{ required: true, message: '请输入数据!' }],
          lxr: [{ required: true, message: '请输入数据!' }],
          tel: [{ required: true, message: '请输入数据!' }],
          khhmc: [{ required: true, message: '请输入数据!' }],
          yhzh: [{ required: true, message: '请输入数据!' }],
          hh: [{ required: true, message: '请输入数据!' }],
          zpdj: [{ required: true, message: '请输入数据!' }],
          zpsl: [{ required: true, message: '请输入数据!' }],
          ppdj: [{ required: true, message: '请输入数据!' }],
          ppsl: [{ required: true, message: '请输入数据!' }],
          wpdj: [{ required: true, message: '请输入数据!' }],
          yf: [{ required: true, message: '请输入数据!' }],
          fhdz: [{ required: true, message: '请输入数据!' }],
          zxchl: [{ required: true, message: '请输入数据!' }],
          jhzqt: [{ required: true, message: '请输入数据!' }]
        },
        url: {
          add: '/trade/tblTradeInquiryInfo/add',
          edit: '/trade/tblTradeInquiryInfo/edit',
          queryById: '/trade/tblTradeInquiryInfo/queryById'
        }
      }
    },
    computed: {
      formDisabled() {
        return this.disabled
      }
    },
    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
      },
      onRadioChange(e) {
        if (e.target.value === '是') {
          this.model.yf = 0
        }
      },
      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'
              this.model.tradeId = this.tradeId
              this.model.wlbm = this.wlbm
            } else {
              httpurl += this.url.edit
               method = 'put'
            }
            console.log(httpurl)
            console.log(this.model)
            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>