TenantPackUserModal.vue
5.1 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
87
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<template>
<BasicModal @register="registerModal" destroyOnClose :title="title" :width="1000" :footer="null">
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #departNames="{ text, record }">
<template v-if="text && text.length > 0">
{{ getName(text) }}
</template>
</template>
<template #positionNames="{ text, record }">
<template v-if="text && text.length > 0">
{{ getName(text) }}
</template>
</template>
<template #tableTitle>
<a-button preIcon="ant-design:usergroup-add-outlined" type="primary" @click="addUser">邀请成员</a-button>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" />
</template>
</BasicTable>
<tenant-user-select-modal :multi="true" @register="registerUserModal" @on-select="onSelected" :tenantId="getTenantId"></tenant-user-select-modal>
</BasicModal>
</template>
<script lang="ts">
import { computed, defineComponent, reactive, ref } from 'vue';
import { BasicModal, useModal, useModalInner } from '/@/components/Modal';
import { BasicTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { tenantPackUserColumns } from '../tenant.data';
import { queryTenantPackUserList, deleteTenantPackUser, addTenantPackUser } from '../tenant.api';
import TenantUserSelectModal from '../components/TenantUserSelectModal.vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { useUserStore } from '/@/store/modules/user';
export default defineComponent({
name: 'TenantPackUserModal',
components: { BasicModal, BasicTable, TableAction, TenantUserSelectModal },
setup() {
//获取租户id
const getTenantId = computed(()=>{
return tenantPackData.tenantId;
})
//套餐包信息
const tenantPackData = reactive<any>({});
//表单赋值
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
setModalProps({ confirmLoading: false, showCancelBtn: true, showOkBtn: false });
Object.assign(tenantPackData, data.record);
await reload();
});
const { createMessage } = useMessage();
//设置标题
const title = ref<string>('用户');
//注册table数据
const { tableContext } = useListPage({
tableProps: {
api: queryTenantPackUserList,
immediate: false,
columns: tenantPackUserColumns,
canResize: false,
useSearchForm: false,
beforeFetch: (params) => {
params.tenantId = tenantPackData.tenantId;
params.packId = tenantPackData.id;
params.status = 1;
return params;
},
actionColumn: {
width: 120,
fixed: 'right',
},
},
});
const [registerUserModal, { openModal: openUserModal, closeModal: closeUserModal }] = useModal();
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
/**
* 获取部门/职务名称
* @param value
*/
function getName(value) {
return value.join(',');
}
/**
* 表格操作列
* @param record
*/
function getTableAction(record) {
return [
{
label: '移除',
popConfirm: {
title: '是否确认移除',
confirm: handleDelete.bind(null, record),
}
},
];
}
/**
* 删除
*/
async function handleDelete(record) {
let params = {
packId: record.packId,
packName: record.packName,
tenantId: tenantPackData.tenantId,
userId: record.id,
realname: record.realname,
};
await deleteTenantPackUser(params);
await reload();
}
/**
* 添加用户弹窗
*/
function addUser() {
openUserModal(true, {
list: [],
});
}
/**
* 邀请人回调事件
* @param arr
*/
async function onSelected(arr) {
if (arr && arr.length > 0) {
let names: any[] = [];
let ids: any[] = [];
for (let u of arr) {
names.push(u.realname);
ids.push(u.id);
}
console.log(tenantPackData);
let params = {
packId: tenantPackData.id,
packName: tenantPackData.packName,
tenantId: tenantPackData.tenantId,
userId: ids.join(','),
realname: names.join(','),
};
await addTenantPackUser(params);
await reload();
}
closeUserModal();
}
return {
title,
registerModal,
registerTable,
rowSelection,
getName,
getTableAction,
registerUserModal,
addUser,
onSelected,
getTenantId,
};
},
});
</script>
<style lang="less" scoped></style>