UserPicker.vue
3.88 KB
1
2
3
4
5
6
7
8
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<template>
<!--查询栏-->
<m-pagination-query-render title="" :fields="pagination.filterFields" :form="pagination.queryForm" @onSearch="pageReload" @onReset="pageReset" :simpleFieldNum="4"/>
<!--查询栏end-->
<a-table :columns="columns" :data-source="pagination.content" :loading="loading" :bordered="false" @change="pageRefresh" @resizeColumn="this.$filters.tableResizeColumn"
:row-selection="{ selectedRowKeys: selectIds, onChange: onSelectChange, type: 'checkbox', preserveSelectedRowKeys:true,getCheckboxProps:getCheckboxProps}"
size="small" :pagination="pageState" :row-key="record => record.userId" :scroll="{y: '446px'}">
<template #bodyCell="{column,record}">
<template v-if="column.key === 'roles'">
<a-tag v-for="role in record?.roles" :key="role.roleId">{{ role.roleName }}</a-tag>
</template>
</template>
<!--库存车辆列表end-->
</a-table>
</template>
<script lang="ts">
import {Component, Emit, Prop} from "vue-facing-decorator";
import AccountTypeTag from "@/views/account/account/tag/AccountTypeTag.vue";
import {PaginationComponent} from "@/components/PaginationComponent";
import {Account} from "lib/src/entity/account/entity/Account";
import {User} from "lib/src/entity/security/entity/User";
import {TableColumnsType} from "ant-design-vue";
import {SecurityController} from "@/api/SecurityController";
import {Operator, Order} from "lib/src/core/page/Pagination";
import {Vehicle} from "lib/src/entity/vehicle/entity/Vehicle";
@Component({
components: {AccountTypeTag}
})
export default class UserPicker extends PaginationComponent<User> {
columns: TableColumnsType = [
{title: "账号", dataIndex: 'userName', key: 'userName', width: 140, resizable: true},
{title: "真实姓名", dataIndex: 'realName', key: 'realName', width: 140, resizable: true, ellipsis: true},
{title: "角色", dataIndex: 'roles', key: 'roles', width: 200, resizable: true, ellipsis: true},
{title: "性别", dataIndex: 'gender', key: 'gender', width: 50, align: 'center'},
{title: "邮箱", dataIndex: 'email', key: 'email', width: 140, resizable: true, ellipsis: true},
{title: "电话", dataIndex: 'mobile', key: 'mobile', width: 140, resizable: true, ellipsis: true},
{title: "创建时间", dataIndex: 'createTime', key: 'createTime', width: 160, sorter: true, resizable: true, ellipsis: true, align: 'center'},
];
@Prop({type: Array, default: []})
ids: number[]
selectIds: number[] = [];
selectedItems: Account[] = [];
created(): void {
this.init(this.axios, SecurityController.PAGE_USER);
this.buildQueryForm({
userName: [null, {label: "账号", field: 'userName', operator: Operator.like}],
realName: [null, {label: "真实姓名", field: 'realName', operator: Operator.eq}],
mobile: [null, {label: "电话", field: 'mobile', operator: Operator.eq}],
email: [null, {label: "邮箱", field: 'email', operator: Operator.like}],
createTime: [null, {label: "创建时间", field: 'createTime', operator: Operator.dateBetween, type: 'date-range'}],
});
this.pagination.setDefaultSort('createTime', Order.desc);
this.pagination.addDefaultFilter('enabled', true);
this.pageReload();
}
getCheckboxProps(record: Vehicle): Vehicle {
record.disabled = this.hasSelected(record.vehicleId);
return record;
}
hasSelected(vehicleId: number): boolean {
return this.ids?.some(id => id === vehicleId);
}
onSelectChange(selectedRowKeys: number[], selectedRows: Account[]): void {
this.selectIds = selectedRowKeys;
this.selectedItems = selectedRows;
}
@Emit('handleOk')
selectUsers(): Account[] {
return this.selectedItems;
}
}
</script>
<style lang="less" scoped>
</style>