payne
2024-05-03 09542900534645e28c23f16caa94aa8a2c20cc5b
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/BaseCustomer/editForm.vue
@@ -1,30 +1,30 @@
<template>
  <a-modal
    title="编辑客户档案"
    :width="900"
    title="编辑往来单位"
    :width="1100"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="客户编号" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入客户编号" v-decorator="['custCode', {rules: [{required: true, message: '请输入客户编号!'}]}]" />
        <a-form-item label="中文名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入中文名称"
          @input="custChinaNameChange"
          v-decorator="['custChinaName', {rules: [{required: true, message: '请输入中文名称!'}]}]" />
        </a-form-item>
        <a-form-item label="客户中文名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入客户中文名称" v-decorator="['custChinaName', {rules: [{required: true, message: '请输入客户中文名称!'}]}]" />
        </a-form-item>
        <a-form-item label="客户英文名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入客户英文名称" v-decorator="['custEnglishName']" />
        <a-form-item label="英文名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入英文名称" v-decorator="['custEnglishName']" />
        </a-form-item>
        <a-form-item label="助记码" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入助记码" v-decorator="['mnemonicCode']" />
          <!-- <a-input placeholder="请输入助记码" v-decorator="['mnemonicCode']" /> -->
          <a-input  placeholder="请输入助记码" v-decorator="['mnemonicCode', { rules: [{ required: true, message: '请输入助记码!' }] }]" />
        </a-form-item>
        <a-form-item label="类型" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input-number placeholder="请输入类型" style="width: 100%" v-decorator="['custType', {rules: [{required: true, message: '请输入类型!'}]}]" />
        </a-form-item>
        <a-form-item label="类型名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入类型名称" v-decorator="['custTypeName']" />
        <a-form-item label="类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-select style="width: 100%" placeholder="请选择类型" v-decorator="['custType', {rules: [{ required: true, message: '请选择类型!' }]}]">
            <a-select-option v-for="(item,index) in custTypeData" :key="index" :value="Number(item.code)">{{ item.name }}</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入联系人" v-decorator="['linkMan']" />
@@ -59,7 +59,7 @@
<script>
import moment from 'moment'
  import {
  BaseCustomerEdit
  BaseCustomerEdit, BaseZjmList
  } from '@/api/modular/main/WmsBase/BaseCustomerManage'
  export default {
  data () {
@@ -74,6 +74,7 @@
  sm: { span: 15 }
  },
  record: {},
  custTypeData: [],
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
@@ -89,16 +90,16 @@
        });
        //深度拷贝 移除VUE的监听,防止INDEX页面值变动
        this.record = JSON.parse(JSON.stringify(record))
        const custTypeOption = this.$options
        this.custTypeData = custTypeOption.filters['dictData']('base_customer_type')
        this.$nextTick(() => {
          this.form.setFieldsValue(
            {
              id: record.id,
              custCode: record.custCode,
              custChinaName: record.custChinaName,
              custEnglishName: record.custEnglishName,
              mnemonicCode: record.mnemonicCode,
              custType: record.custType,
              custTypeName: record.custTypeName,
              linkMan: record.linkMan,
              phone: record.phone,
              email: record.email,
@@ -145,7 +146,54 @@
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      },
       /*中文名称值改变调用的方法*/
    custChinaNameChange(){
      let custChinaNameValue = this.form.getFieldValue('custChinaName');
       console.log(typeof custChinaNameValue)
      console.log("custChinaNameValue:"+custChinaNameValue);
      if(!custChinaNameValue){
        this.form.setFieldsValue({
              mnemonicCode: ''
            })
        return
      }
      if (custChinaNameValue!=undefined&&!custChinaNameValue.trim().length) {
        this.form.setFieldsValue({
              mnemonicCode: ''
            })
           return
       }
      /*调用获取助记码接口*/
      BaseZjmList({
        'name': custChinaNameValue
      }).then((res) => {
        if (res.success) {
          if (res.data) {
            this.zjCode = res.data || '';
            this.disabled = true;
            this.form.setFieldsValue({
              mnemonicCode: this.zjCode
            })
          } else {
            // this.$message.warning("助记码生成失败")
            this.form.setFieldsValue({
              mnemonicCode: ''
            })
          }
        } else {
          this.$message.error('助记码生成失败:' + JSON.stringify(res.message))
        }
      }).finally((res) => {
        this.confirmLoading = false
      })
    }
    }
  }
</script>
<style lang="less" scoped>
  .ant-row.ant-form-item {
    width: 50% !important;
    display: inline-block;
  }
</style>