businessChannelsModal.vue 4.65 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-input
            placeholder="请输入业务线编号"
            v-decorator="[ 'businessChannelNo', validatorRules.businessChannelNo]"
          />
        </a-form-item>

        <a-form-item label="业务线名称:" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback>
          <a-input
            placeholder="请输入业务线名称"
            v-decorator="[ 'businessChannelName', validatorRules.businessChannelName]"
          />
        </a-form-item>
        <!-- <a-form-item label="是否设置白名单:" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-radio-group v-decorator="[ 'setWhiteFlag', validatorRules.setWhiteFlag]">
            <a-radio :value="true">是</a-radio>
            <a-radio :value="false">否</a-radio>
          </a-radio-group>
        </a-form-item> -->
        <a-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-textarea rows="4" placeholder="备注" v-decorator="['remark']" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import { changPassword } from '@/api/api'
import { setBusinessChannelStatus, updateBusinessChannel, saveBusinessChannel } from '@/api/configApi'
export default {
  name: 'PasswordModal',
  data() {
    return {
      visible: false,
      confirmLoading: false,
      confirmDirty: false,
      title: '',
      validatorRules: {
        businessChannelNo: {
          rules: [
            {
              required: true,
              message: '请输入业务线编号'
            }
          ]
        },
        businessChannelName: {
          rules: [
            {
              required: true,
              message: '请输入业务线名称'
            }
          ]
        },
        setWhiteFlag: {
          rules: [
            {
              required: true,
              message: '请选择是否设置白名单'
            }
          ]
        }
      },
      type: 'add',
      model: {
        
      },

      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      form: this.$form.createForm(this),
      id:''
    }
  },
  created() {
    console.log('created')
  },

  methods: {
    edit(username) {
      console.log(username)
      this.id = username.id
      this.type = 'edit'
      this.form.resetFields()
      this.visible = true
      this.model = username
      this.$nextTick(() => {
        this.form.setFieldsValue(username)
      })
    },

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

    onChange() {},

    close() {
      this.$emit('close')
      this.visible = false
      this.disableSubmit = false
      this.selectedRole = []
    },
    handleSubmit() {
      // 触发表单验证
      this.form.validateFields((err, values) => {
        console.log(err, values)
        if (!err) {
          this.confirmLoading = true
          let l = {id:this.id}
          let formData = Object.assign(values,l)
          // let formData = values
          if (this.type == 'add') {
            saveBusinessChannel(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 {
            updateBusinessChannel(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()
              })
          }
        }
      })
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>