whiteListDeaileModal.vue 8.43 KB
<template>
  <a-modal
    :title="title"
    :width="800"
    :centered="true"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
    cancelText="关闭"
    style="top:20px;"
    :maskClosable="false"  
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <!-- <a-form-item label="业务线编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
         
          <a-select
            mode="multiple"
            placeholder="请选择业务线编号"
            @change="handleChange"
            v-decorator="[ 'cooperationPlatformNo', validatorRules.businessChannelNo]"
          >
            <a-select-option
              v-for="(item, index) in productList"
              :key="index"
              :value="item.productNo"
            >{{item.productName}}</a-select-option>
          </a-select>
        </a-form-item> -->

        <a-form-item label="业务线名称" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback>
           <a-select
            placeholder="请选择业务线名称"
            @change="value => handleChange(value,{type:'businessChannelNo'})"
            v-decorator="[ 'businessChannelNo', validatorRules.businessChannelNo]"
            :disabled="type=='edit'?true:false"
          >
            <a-select-option
              v-for="(item, index) in productList"
              :key="index"
              :value="item.businessChannelNo"
            >{{item.businessChannelName}}</a-select-option>
          </a-select>
        </a-form-item>
        <template v-if="type=='add'">
          <a-form-item label="白名单分类" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-radio-group @change="changeType" >
            <a-radio value="1">用户ID</a-radio>
            <a-radio value="2">手机号</a-radio>
            <a-radio value="3">企业名称</a-radio>
          </a-radio-group>
        </a-form-item>
        <a-form-item v-if="typeShow=='1'" label="用户ID号" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback>
          <a-input
            placeholder="请输入用户ID号"
            v-decorator="[ 'userId',{rules:[{required: true,
              message: '请输入用户ID号'}]}]"
          />
        </a-form-item>
        <a-form-item v-if="typeShow=='2'" label="手机号码" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback>
          <a-input
            placeholder="请输入手机号码"
            v-decorator="[ 'phoneNumber',{rules:[{required: true,
              message: '请输入手机号码'}]}]"
          />
        </a-form-item>
        <a-form-item v-if="typeShow=='3'" label="企业名称" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback>
          <a-input
            placeholder="请输入企业名称"
            v-decorator="[ 'enterpriseName',{rules:[{required: true,
              message: '请输入企业名称'}]}]"
          />
        </a-form-item>
        </template>
        
        <a-form-item label="进件流名称" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback>
          <a-select
            placeholder="请选择进件流名称"
            @change="value => handleChange(value,{type:'collectionNo'})"
           v-decorator="[ 'collectionNo', validatorRules.collectionNo]"
          >
            <a-select-option
              v-for="(item, index) in jinJianList" :key="index"
              
              :value="item.collectionNo"
            >{{item.collectionName}}</a-select-option>
          </a-select>
        </a-form-item>
        
        
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import { postAction, saveWhiteListDetail,updateWhiteListDetail } from '@/api/configApi'

export default {
  name: 'PasswordModal',
  props:{
    jinjianList: {
      type: Array,
      required: true,
      default: () => []
    },
    yewuList:{
      type: Array,
      required: true,
      default: () => []
    },
  },
  data() {
    return {
      visible: false,
      confirmLoading: false,
      confirmDirty: false,
      title: '',
      type:'add',
      typeShow:false,
      productList: [],
      jinJianList:[],
      validatorRules: {
        businessChannelNo: {
          rules: [
            {
              required: true,
              message: '选择业务线编号'
            }
          ]
        },
        collectionNo:{
          rules: [
            {
              required: true,
              message: '选择进件流名称'
            }
          ]
        },
        upload: {
          rules: [
            // {
            //   required: true,
            //   message: '请上传文件'
            // },
            // { valuePropName: 'fileList', getValueFromEvent: this.normFile }
          ]
        }
      },

      model: {},

      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      form: this.$form.createForm(this)
    }
  },
  created() {
    this.initPrudect();
    
  },

  methods: {
    handleChange(value,params) {
     console.log(value,params)
     if(params.type=="collectionNo"){
       
       for(var i=0,len= this.jinJianList.length;i<len;i++){
       if(value == this.jinJianList[i].collectionNo){
         this.model.collectionNo=value
         this.model.collectionName=this.jinJianList[i].collectionName
         console.log(this.model)
         return '';
       }
     }
     }else if(params.type=="businessChannelNo"){
        for(var i=0,len= this.productList.length;i<len;i++){
       if(value == this.productList[i].businessChannelNo){
         this.model.businessChannelNo=value
         this.model.businessChannelName=this.productList[i].businessChannelName
         console.log(this.model)
         return '';
       }
     }
     }
    },
    changeType(value){
      console.log(value.target.value)
      this.typeShow = value.target.value
    },
    initPrudect() {
      let _params = {
        pageNo: 1,
        pageSize: 10000,
        params: {}
      }
      postAction('/config/admin/getBusinessChannelSelect', _params).then(r => {
        this.productList = r.data
      })
      postAction('/config/admin/queryCollectionInfoList', _params).then(r => {
        this.jinJianList = r.data
      })
      
    },
    edit(records) {
      console.log(this.jinjianList)
      this.form.resetFields()
      this.visible = true
      this.type = 'edit'
      this.model = records
      this.$nextTick(() => {
        this.form.setFieldsValue(records)
      })
    },

    add(records) {
      this.form.resetFields()
      this.visible = true
       this.type = 'add'
       this.typeShow = false
      this.model = {}
      this.$nextTick(() => {
        this.form.setFieldsValue()
      })
    },

    onChange() {},

    close() {
      this.$emit('close')
      this.visible = false
      this.disableSubmit = false
      this.selectedRole = []
    },
    // 文件上传回调
    normFile(e) {
      console.log('Upload event:', e)
      if (Array.isArray(e)) {
        return e
      }
      return e && e.fileList
    },
    handleSubmit() {
      // 触发表单验证
      this.form.validateFields((err, values) => {
        console.log(err, values)
        if (!err) {
          this.confirmLoading = true
          let formData = Object.assign(this.model, values)
          console.log(formData);
          // return '';
          if(this.type=='add'){
            saveWhiteListDetail(formData)
            .then(res => {
              if (res.status.statusCode == 0) {
                this.$message.success(res.status.statusReason)
                // this.$emit('loadData')
                this.$emit('ok')
              } else {
                this.$message.warning(res.status.statusReason)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
          }else{
            updateWhiteListDetail(formData)
            .then(res => {
              if (res.status.statusCode == 0) {
                this.$message.success(res.status.statusReason)
                //  this.$emit('loadData')
                this.$emit('ok')
              } else {
                this.$message.warning(res.status.statusReason)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
          }
          
        }
      })
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>