Blame view

ant-design-vue-jeecg/src/views/system/modules/SelectUserListModal.vue 8.61 KB
肖超群 authored
1
2
3
4
5
6
7
<template>
  <a-modal
    :title="title"
    :width="1200"
    :visible="visible"
    @ok="handleOk"
    @cancel="handleCancel"
谭毅彬 authored
8
    :cancelText="$t('button.close')">
肖超群 authored
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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

    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">

          <a-col :span="6">
            <a-form-item label="账号">
              <a-input placeholder="请输入账号" v-model="queryParam.username"></a-input>
            </a-form-item>
          </a-col>

          <a-col :span="6">
            <a-form-item label="性别">
              <a-select v-model="queryParam.sex" 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-col>

          <template v-if="toggleSearchStatus">
            <a-col :span="6">
              <a-form-item label="邮箱">
                <a-input placeholder="请输入邮箱" v-model="queryParam.email"></a-input>
              </a-form-item>
            </a-col>

            <a-col :span="6">
              <a-form-item label="手机号码">
                <a-input placeholder="请输入手机号码" v-model="queryParam.phone"></a-input>
              </a-form-item>
            </a-col>

            <a-col :span="6">
              <a-form-item label="状态">
                <a-select v-model="queryParam.status" 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-col>
          </template>
肖超群 authored
54
          <a-col :span="6">
肖超群 authored
55
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
56
57
              <a-button type="primary" @click="searchByquery" icon="search">{{ $t('button.search') }}</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">{{ $t('button.reset') }}</a-button>
肖超群 authored
58
              <a @click="handleToggleSearch" style="margin-left: 8px">
59
                {{ toggleSearchStatus ?  $t('button.collapse') : $t('button.expand') }}
肖超群 authored
60
61
62
63
64
65
66
67
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
肖超群 authored
68
    <!--    update-begin author:kangxiaolin   date:20190921   for:系统发送通知 用户多选失败 #513  -->
肖超群 authored
69
70
71
72
73
74
75
76
77
    <a-table
      ref="table"
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
      @change="handleTableChange"
    >
肖超群 authored
78
      <!--     update-end   author:kangxiaolin  date:20190921     for:系统发送通知 用户多选失败 #513 -->
肖超群 authored
79
80
81
82
83
    </a-table>
  </a-modal>
</template>

<script>
肖超群 authored
84
import {filterObj} from '@/utils/util';
肖超群 authored
85
肖超群 authored
86
import {getUserList} from '@/api/api'
肖超群 authored
87
肖超群 authored
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
export default {
  name: "SelectUserListModal",
  components: {},
  data() {
    return {
      title: "选择用户",
      queryParam: {},
      columns: [{
        title: '用户账号',
        align: "center",
        dataIndex: 'username',
        fixed: 'left',
        width: 200
      }, {
        title: '用户名称',
        align: "center",
        dataIndex: 'realname',
      }, {
        title: '性别',
        align: "center",
        dataIndex: 'sex',
        customRender: function (text) {
          if (text == 1) {
            return "男";
          } else if (text == 2) {
            return "女";
          } else {
            return text;
肖超群 authored
116
117
          }
        }
肖超群 authored
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
      }, {
        title: '手机号码',
        align: "center",
        dataIndex: 'phone'
      }, {
        title: '邮箱',
        align: "center",
        dataIndex: 'email'
      }, {
        title: '状态',
        align: "center",
        dataIndex: 'status',
        customRender: function (text) {
          if (text == 1) {
            return "正常";
          } else if (text == 2) {
            return "冻结";
          } else {
            return text;
肖超群 authored
137
138
          }
        }
肖超群 authored
139
140
141
142
143
144
145
      }],
      dataSource: [],
      ipagination: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
146
          return range[0] + "-" + range[1] + " " + this.$t('list.showing') + " " + total + " " + this.$t('list.records')
肖超群 authored
147
148
149
150
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
肖超群 authored
151
      },
肖超群 authored
152
153
154
      isorter: {
        column: 'createTime',
        order: 'desc',
肖超群 authored
155
      },
肖超群 authored
156
157
158
159
      selectedRowKeys: [],
      selectionRows: [],
      visible: false,
      toggleSearchStatus: false,
肖超群 authored
160
    }
肖超群 authored
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
  },
  created() {
    this.loadData();
  },
  methods: {
    add(selectUser, userIds) {
      this.visible = true;
      this.edit(selectUser, userIds);
    },
    edit(selectUser, userIds) {
      //控制台报错
      if (userIds && userIds.length > 0) {
        this.selectedRowKeys = userIds.split(',');
      } else {
        this.selectedRowKeys = []
      }
      if (!selectUser) {
        this.selectionRows = []
      } else {
        var that = this;
        that.selectionRows = [];
        selectUser.forEach(function (record, index) {
          console.log(record)
          that.selectionRows.push({id: that.selectedRowKeys[index], realname: record.label})
        })
        // this.selectionRows = selectUser;
      }
    },
    loadData(arg) {
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      let params = this.getQueryParams();//查询条件
      getUserList(params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records;
          this.ipagination.total = res.result.total;
        }
      })
    },
    getQueryParams() {
      let param = Object.assign({}, this.queryParam, this.isorter);
      param.field = this.getQueryField();
      //--update-begin----author:scott---date:20190818------for:新建公告时指定特定用户翻页错误SelectUserListModal #379----
      // param.current = this.ipagination.current;
      // param.pageSize = this.ipagination.pageSize;
      param.pageNo = this.ipagination.current;
      param.pageSize = this.ipagination.pageSize;
      //--update-end----author:scott---date:20190818------for:新建公告时指定特定用户翻页错误SelectUserListModal #379---
      return filterObj(param);
    },
    getQueryField() {
      let str = "id,";
      for (let a = 0; a < this.columns.length; a++) {
        str += "," + this.columns[a].dataIndex;
      }
      return str;
    },
    //--update-begin----author:kangxiaolin---date:20190921------for:系统发送通知 用户多选失败 #513----
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys;
      //update-begin---author:wangshuai ---date:20211227  for:全选不好用------------
      this.selectionRows = selectionRows;
      //update-end---author:wangshuai ---date:20211227  for:全选不好用------------
    },
    searchReset() {
      let that = this;
      Object.keys(that.queryParam).forEach(function (key) {
        that.queryParam[key] = '';
      });
      that.loadData(1);
    },
    handleTableChange(pagination, filters, sorter) {
      //TODO 筛选
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field;
        this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
      }
      this.ipagination = pagination;
      this.loadData();
    },
    handleCancel() {
      this.selectionRows = [];
      this.selectedRowKeys = [];
      this.visible = false;
    },
    handleOk() {
      this.$emit("choseUser", this.selectionRows);
      this.handleCancel();
    },
    searchByquery() {
      this.loadData(1);
    },
    handleToggleSearch() {
      this.toggleSearchStatus = !this.toggleSearchStatus;
    },
肖超群 authored
257
  }
肖超群 authored
258
}
肖超群 authored
259
260
</script>
<style scoped>
肖超群 authored
261
262
263
.ant-card-body .table-operator {
  margin-bottom: 18px;
}
肖超群 authored
264
肖超群 authored
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
.ant-table-tbody .ant-table-row td {
  padding-top: 15px;
  padding-bottom: 15px;
}

.anty-row-operator button {
  margin: 0 5px
}

.ant-btn-danger {
  background-color: #ffffff
}

.ant-modal-cust-warp {
  height: 100%
}

.ant-modal-cust-warp .ant-modal-body {
  height: calc(100% - 110px) !important;
  overflow-y: auto
}

.ant-modal-cust-warp .ant-modal-content {
  height: 90% !important;
  overflow-y: hidden
}
肖超群 authored
291
肖超群 authored
292
293
294
295
.anty-img-wrap {
  height: 25px;
  position: relative;
}
肖超群 authored
296
肖超群 authored
297
298
299
.anty-img-wrap > img {
  max-height: 100%;
}
肖超群 authored
300
</style>