大宝管理后台代码
ne1
zzzz
2024-04-07 69ff731fbacf2f2ae16f98a355506bfeb01dd567
src/views/userlist/components/EditUserinfodialog.vue
@@ -6,13 +6,13 @@
      :visible="editUserdialog"
      :confirmLoading="editUserDialogloading"
      @ok="OkeditUserdialog"
      @cancel="CanceleditUserdialog">
      @cancel="CanceleditUserdialog"
    >
      <a-form :form="editUserform" ref="editUserform">
        <a-form-item label="所属代理" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-select placeholder="请选择所属代理" v-decorator="['agentId', {}]">
            <a-select-option v-for="(item, index) in agentlist" :key="index" :value="item.id">{{
              item.agentName
            }}
            <a-select-option v-for="(item, index) in agentlist" :key="index" :value="item.id"
              >{{ item.agentName }}
            </a-select-option>
          </a-select>
        </a-form-item>
@@ -48,68 +48,67 @@
import { userupdate } from '@/api/home'
import pick from 'lodash.pick'
export default {
    components: {},
    props: {
        getinit: {
            type: Function,
            default: function () {
            }
        },
        agentlist: {
            type: Array
        }
  components: {},
  props: {
    getinit: {
      type: Function,
      default: function () {},
    },
    data () {
        return {
            labelCol: {
                xs: { span: 24 },
                sm: { span: 7 }
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 13 }
            },
            editUserform: this.$form.createForm(this),
            editUserdialog: false,
            editUserDialogloading: false,
            fields: ['agentId', 'phone', 'realName', 'pwd', 'idCard', 'isLogin', 'isLock'],
            currentDetails: {}
        }
    agentlist: {
      type: Array,
    },
    methods: {
        getEditorder (val) {
            this.currentDetails = val
            this.editUserdialog = true
            this.fields.forEach(v => this.editUserform.getFieldDecorator(v))
            this.editUserform.setFieldsValue(pick(val, this.fields))
        },
        // 新增用户取消弹窗
        CanceleditUserdialog () {
            this.editUserdialog = false
            const form = this.$refs.editUserform.form
            form.resetFields()
        },
        // 新增用户确定
        OkeditUserdialog () {
            const form = this.$refs.editUserform.form
            form.validateFields((errors, values) => {
                if (!errors) {
                    values.id = this.currentDetails.id
                    this.editUserDialogloading = true
                    userupdate(values).then(res => {
                        if (res.status == 0) {
                            this.editUserdialog = false
                            this.$message.success({ content: res.msg, duration: 2 })
                            form.resetFields()
                            this.getinit()
                        } else {
                            this.$message.error({ content: res.msg })
                        }
                        this.editUserDialogloading = false
                    })
                }
            })
        }
  },
  data() {
    return {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 13 },
      },
      editUserform: this.$form.createForm(this),
      editUserdialog: false,
      editUserDialogloading: false,
      fields: ['agentId', 'phone', 'realName', 'pwd', 'idCard', 'isLogin', 'isLock'],
      currentDetails: {},
    }
  },
  methods: {
    getEditorder(val) {
      this.currentDetails = val
      this.editUserdialog = true
      this.fields.forEach((v) => this.editUserform.getFieldDecorator(v))
      this.editUserform.setFieldsValue(pick(val, this.fields))
    },
    // 新增用户取消弹窗
    CanceleditUserdialog() {
      this.editUserdialog = false
      const form = this.$refs.editUserform.form
      form.resetFields()
    },
    // 新增用户确定
    OkeditUserdialog() {
      const form = this.$refs.editUserform.form
      form.validateFields((errors, values) => {
        if (!errors) {
          values.id = this.currentDetails.id
          this.editUserDialogloading = true
          userupdate(values).then((res) => {
            if (res.status == 0) {
              this.editUserdialog = false
              this.$message.success(res.msg)
              form.resetFields()
              this.getinit()
            } else {
              this.$message.error(res.msg)
            }
            this.editUserDialogloading = false
          })
        }
      })
    },
  },
}
</script>