Blame view

ant-design-vue-jeecg/src/components/jeecgbiz/modal/SelectUserListModal.vue 2.48 KB
肖超群 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<template>
  <a-modal
    title="用户列表"
    :width="1000"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">

    <a-table
      ref="table"
      bordered
      size="middle"
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"></a-table>
  </a-modal>
</template>

<script>
肖超群 authored
24
25
import {getUserList} from '@/api/api'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
肖超群 authored
26
肖超群 authored
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
export default {
  name: "SelectUserListModal",
  mixins: [JeecgListMixin],
  data() {
    return {
      title: "操作",
      visible: false,
      model: {},
      confirmLoading: false,
      url: {
        add: "/act/model/create",
        list: "/sys/user/list"
      },
      columns: [
        {
          title: '用户账号',
          align: "center",
          dataIndex: 'username',
          fixed: 'left',
          width: 200
        },
        {
          title: '用户姓名',
          align: "center",
          dataIndex: 'realname',
        },
        {
          title: '性别',
          align: "center",
          dataIndex: 'sex_dictText'
肖超群 authored
57
        },
肖超群 authored
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
        {
          title: '手机号码',
          align: "center",
          dataIndex: 'phone'
        },
        {
          title: '邮箱',
          align: "center",
          dataIndex: 'email'
        },
        {
          title: '状态',
          align: "center",
          dataIndex: 'status_dictText'
        }
      ]
    }
  },
  created() {
    //Step.2 加载用户数据
    getUserList().then((res) => {
      if (res.success) {
        this.dataSource = res.result.records;
        this.ipagination.total = res.result.total;
肖超群 authored
82
      }
肖超群 authored
83
84
85
86
87
88
89
90
91
    })
  },
  methods: {
    open() {
      this.visible = true;

      //Step.1 清空选中用户
      this.selectedRowKeys = []
      this.selectedRows = []
肖超群 authored
92
    },
肖超群 authored
93
94
95
    close() {
      this.$emit('close');
      this.visible = false;
肖超群 authored
96
    },
肖超群 authored
97
98
99
100
101
    handleChange(info) {
      let file = info.file;
      if (file.response.success) {
        this.$message.success(file.response.message);
        this.$emit('ok');
肖超群 authored
102
        this.close()
肖超群 authored
103
104
      } else {
        this.$message.warn(file.response.message);
肖超群 authored
105
        this.close()
肖超群 authored
106
107
108
109
110
111
112
113
114
115
      }

    },
    handleCancel() {
      this.close()
    },
    handleSubmit() {
      this.$emit('ok', this.selectionRows);
      this.close()
    },
肖超群 authored
116
  }
肖超群 authored
117
}
肖超群 authored
118
119
120
121
122
</script>

<style>

</style>