addAccount.vue 11.3 KB
<template>
  <div>
    <a-modal
      :title="title"
      :maskClosable="false"  
      :width="800"
      :centered="true"
      :visible="visible"
      :confirmLoading="confirmLoading"
      @ok="handleSubmit"
      @cancel="handleCancel"
      cancelText="关闭"
      style="top:20px;"
    >
      <a-spin :spinning="confirmLoading">
        <a-form v-if="type=='edit'" :form="form">
          <a-form-item v-show="false" label="客户类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input placeholder="请输入客户类型" v-decorator="['customerType']" />
          </a-form-item>
           <a-form-item label="所属上层节点:" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <p>{{detailDatas.length>0?formData.nodeName:'--'}}</p>
          </a-form-item>
           <a-form-item v-if="formData.nodeLevel!=2" label="节点名称:" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="true" placeholder="请输入节点名称"  v-decorator="[ 'businessName', validatorRules.businessName]" />
          </a-form-item>
          <a-form-item v-if="formData.nodeLevel==2" label="业务线名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-select
            placeholder="请选择业务线"
            @change="value => handleChange(value,{type:'businessNo'})"
            v-decorator="[ 'businessNo',  validatorRules.businessNo]"
          >
            <a-select-option :disabled="true"
              v-for="(item, index) in productList"
              :key="index"
              :value="item.businessChannelNo"
            >{{item.businessChannelName}}</a-select-option>
            </a-select>
          </a-form-item>
          <a-form-item label="授信类型:" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-select  @change="value => handleCreditChange(value)" v-decorator="[ 'nodeCreditType', validatorRules.nodeCreditType]" placeholder="请选择授信类型">
              <!-- <a-select-option value>请选择</a-select-option> -->
              <a-select-option :value="1">直接授信</a-select-option>
              <a-select-option :value="2">继承上层百分比</a-select-option>
            </a-select>
          </a-form-item>
           <a-form-item label="占上层比例:" v-if="zhanbiFlag" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input-number
              style="width:30%"
              id="inputNumber"
              placeholder="请输入占上层比例"
              :min="1" :max="100"
              v-decorator="[ 'nodeExtendsRatio',validatorRules.nodeExtendsRatio]"
            />  % 
          </a-form-item> 
          <a-form-item label="分期类型:" v-if="formData.nodeLevel==3" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-select v-decorator="[ 'productType', {rules: [
            {
              required:true,
              message: '请选择分期类型'
            }
          ]}]" placeholder="请选择分期类型">
              <!-- <a-select-option value>请选择</a-select-option> -->
              <a-select-option :value="1">未分期</a-select-option>
              <a-select-option :value="2">分期</a-select-option>
            </a-select>
          </a-form-item>
        </a-form>
        <!-- 添加模板 -->
        <a-form :form="form" v-if="type=='add'">
          <a-form-item v-show="false" label="客户类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input placeholder="请输入客户类型" v-decorator="['customerType']" />
          </a-form-item>
           <a-form-item label="所属上层节点:" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <p>{{detailDatas.length>0?formData.nodeName:'--'}}</p>
          </a-form-item>
           <a-form-item v-if="formData.nodeLevel!=3" label="节点名称:" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input placeholder="请输入节点名称"  v-decorator="[ 'businessName', validatorRules.businessName]" />
          </a-form-item>
          <a-form-item label="业务线名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-select
            placeholder="请选择业务线"
            @change="value => handleChange(value,{type:'businessNo'})"
            v-decorator="[ 'businessNo',  validatorRules.businessNo]"
          >
            <a-select-option
              v-for="(item, index) in productList"
              :key="index"
              :value="item.businessChannelNo"
            >{{item.businessChannelName}}</a-select-option>
            </a-select>
          </a-form-item>
          <a-form-item label="授信类型:" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-select  @change="value => handleCreditChange(value)" v-decorator="[ 'nodeCreditType', validatorRules.nodeCreditType]" placeholder="请选择授信类型">
              <!-- <a-select-option value>请选择</a-select-option> -->
              <a-select-option :value="1">直接授信</a-select-option>
              <a-select-option :value="2">继承上层百分比</a-select-option>
            </a-select>
          </a-form-item>
           <a-form-item label="占上层比例:" v-if="zhanbiFlag" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input-number
              style="width:30%"
              id="inputNumber"
              placeholder="请输入占上层比例"
              :min="1" :max="100"
              v-decorator="[ 'nodeExtendsRatio',validatorRules.nodeExtendsRatio]"
            />  % 
          </a-form-item> 
          <a-form-item label="分期类型:" v-if="formData.nodeLevel==3" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-select  v-decorator="[ 'productType', validatorRules.productType]" placeholder="请选择分期类型">
              <!-- <a-select-option value>请选择</a-select-option> -->
              <a-select-option :value="1">未分期</a-select-option>
              <a-select-option :value="2">分期</a-select-option>
            </a-select>
          </a-form-item>
        </a-form>
      </a-spin>
    </a-modal>
  
  </div>
</template>

<script>
import { postAction, updateCreditModelConfig,getBusinessChannelSelect,
  saveCreditModelConfig } from '@/api/configApi'
export default {
  name: 'PasswordModal',
  props:['detailDatas'],
  data() {
    return {
      visible: false,
      detailFlag:false,
      formData:{},//基础信息
      zhanbiFlag:false,//占比显示
      title: '',
       productList:[],
       type:'add',
      confirmLoading: false,
      confirmDirty: false,
      validatorRules: {
        businessNo: {
          rules: [
            {
              required: true,
              message: '请选择业务线'
            }
          ]
        },
        businessName: {
          rules: [
            {
              required: true,
              message: '请输入节点名称'
              // pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
              // message: '密码由8位数字、大小写字母和特殊符号组成!'
            },
            // {
            //   validator: this.validateToNextPassword
            // }
          ]
        },
        parentNodeId: {
          rules: [
            {
              required: true,
              message: '请选择所属上层节点'
            }
          ]
        },
        nodeCreditType: {
          rules: [
            {
              required: true,
              message: '请选择授信类型'
            }
          ]
        },
        nodeExtendsRatio:{
          rules: [
            {
              required: true,
              message: '请填写占上层比例'
            }
          ]
        },
       
      },

      model: {},

      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      form: this.$form.createForm(this)
    }
  },
  created() {
    
    let _params = {
        pageNo: 1,
        pageSize: 10000,
        params: {}
      }
    postAction('/config/admin/getBusinessChannelSelect', _params).then(r => {
        this.productList = r.result
        console.log("ssssss")
      })
  },
  computed:{},
  watch:{},
  methods: {
     handleChange(value,params) {
    //  console.log(value,params)
     for(var i=0,len= this.productList.length;i<len;i++){
       if(value == this.productList[i].businessChannelNo){
         this.model.businessNo=value
         this.model.businessName=this.productList[i].businessChannelName
         console.log(this.model)
         return '';
       }
     }
       
     
    },
    handleCreditChange(value){
      console.log(value)
      this.zhanbiFlag = value==1?false:true
    },
    edit(record) {
      this.type = "edit"
      this.title='修改节点信息'
      this.formData = record
       this.zhanbiFlag = record.nodeCreditType==1?false:true
       console.log('修改',this.formData)
      //  this.model = record
      this.form.resetFields();
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(record);
        });
    },

    add(record) {
      this.form.resetFields()
      console.log(record)
      if(!record){
        this.formData.customerType=this.detailDatas.customerType
      }
      this.type = "add"
      this.visible = true
      this.$nextTick(() => {
        this.form.setFieldsValue()
      })
    },

    onChange() {},

    close() {
      this.$emit('close')
      this.visible = false
      this.detailFlag = false
      this.disableSubmit = false
      this.selectedRole = []
    },
    handleSubmit() {
      // 触发表单验证
      this.form.validateFields((err, values) => {
        console.log(err, values);
        // this.close()
        if (!err) {
          this.confirmLoading = true
          let formData = Object.assign(this.model, values);
         
          // formData.businessName =this.model.businessName
          if(this.formData.nodeLevel==2){
             formData.businessName =this.formData.businessName
            formData.nodeName =this.formData.nodeName
            formData.customerType =this.formData.customerType
            formData.id =this.formData.id
          }else{
            formData.customerType =this.formData.customerType
            formData.id =this.formData.id
          }
           console.log(formData)
          //  return '';
          if(this.type!='edit'){
             saveCreditModelConfig(formData)
            .then(res => {
              if (res.status.statusCode == 0) {
                this.$message.success(res.status.statusReason)
                this.$emit('ok')
              } else {
                this.$message.warning(res.status.statusReason)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
          }else{
             updateCreditModelConfig(formData)
            .then(res => {
              if (res.status.statusCode == 0) {
                this.$message.success(res.status.statusReason)
                this.$emit('getModle')
                this.$emit('ok')
              } else {
                this.$message.warning(res.status.statusReason)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
          }
         
        }
      })
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>