TenantPackList.vue
6.6 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
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
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" @ok="handleSubmit" width="800px" :showCancelBtn="false" :showOkBtn="false">
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button preIcon="ant-design:plus-outlined" type="primary" @click="handleAdd" style="margin-right: 5px" v-if="showPackAddAndEdit">新增 </a-button>
<a-button
v-if="selectedRowKeys.length > 0"
preIcon="ant-design:delete-outlined"
type="primary"
@click="handlePackBatch"
style="margin-right: 5px"
>批量删除
</a-button>
<a-button
preIcon="ant-design:sync-outlined"
type="primary"
@click="handleSyncDefaultPack"
style="margin-right: 5px"
>初始化默认套餐
</a-button>
</template>
<template #action="{ record }">
<TableAction :actions="getActions(record)" :dropDownActions="getDropDownAction(record)" />
</template>
</BasicTable>
</BasicModal>
<TenantPackMenuModal @register="registerPackMenu" @success="success" />
<TenantPackUserModal @register="registerPackUser" @success="success" />
</template>
<script lang="ts" setup name="tenant-pack-modal">
import { reactive, ref, unref } from 'vue';
import { BasicModal, useModal, useModalInner } from '/@/components/Modal';
import { packColumns, userColumns, packFormSchema } from '../tenant.data';
import { getTenantUserList, leaveTenant, packList, deleteTenantPack, syncDefaultTenantPack } from '../tenant.api';
import { useListPage } from '/@/hooks/system/useListPage';
import { BasicTable, TableAction } from '/@/components/Table';
import TenantPackMenuModal from './TenantPackMenuModal.vue';
import {Modal} from "ant-design-vue";
import TenantPackUserModal from './TenantPackUserModal.vue';
import {useMessage} from "/@/hooks/web/useMessage";
const [registerPackMenu, { openModal }] = useModal();
const [registerPackUser, { openModal: packUserOpenModal }] = useModal();
const tenantId = ref<number>(0);
// 列表页面公共参数、方法
const { prefixCls, tableContext } = useListPage({
designScope: 'tenant-template',
tableProps: {
api: packList,
columns: packColumns,
immediate: false,
formConfig: {
schemas: packFormSchema,
labelCol: {
xxl: 8,
},
actionColOptions: {
xs: 24,
sm: 8,
md: 8,
lg: 8,
xl: 8,
xxl: 8,
},
},
beforeFetch: (params) => {
return Object.assign(params, { tenantId: unref(tenantId), packType:'custom' });
},
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys, selectedRows }] = tableContext;
// Emits声明
const emit = defineEmits(['register', 'success']);
//是否显示新增和编辑套餐包
const showPackAddAndEdit = ref<boolean>(false);
//表单赋值
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
tenantId.value = data.tenantId;
showPackAddAndEdit.value = data.showPackAddAndEdit;
success();
});
//设置标题
const title = '租户个性化套餐包';
//表单提交事件
async function handleSubmit(v) {
closeModal();
}
function getActions(record) {
return [
{
label: '用户',
onClick: seeTenantPackUser.bind(null, record),
},
{
label: '编辑',
onClick: handleEdit.bind(null, record),
ifShow: ()=>{ return showPackAddAndEdit.value }
},
];
}
/**
* 成功
*/
function success() {
(selectedRowKeys.value = []) && reload();
}
/**
* 编辑
* @param record
*/
async function handleEdit(record) {
openModal(true, {
isUpdate: true,
record: record,
tenantId: unref(tenantId),
packType:'custom',
showFooter: true
});
}
//默认系统套餐包不允许删除,包含(超级管理员、组织账户管理员、组织应用管理员)
const packCode = reactive<any>(['superAdmin','accountAdmin','appAdmin']);
const { createMessage } = useMessage();
/**
* 删除套餐包
* @param 删除
*/
async function handleDelete(record) {
//update-begin---author:wangshuai ---date:20230222 for:系统默认套餐包不允许删除------------
if(packCode.indexOf(record.packCode) != -1){
createMessage.warning("默认系统套餐包不允许删除");
return;
}
//update-end---author:wangshuai ---date:20230222 for:系统默认套餐包不允许删除------------
await deleteTenantPack({ ids: record.id }, success);
}
/**
* 批量删除套餐包
*/
async function handlePackBatch() {
let value = selectedRows.value;
if(value && value.length>0){
for (let i = 0; i < value.length; i++) {
if(packCode.indexOf(value[i].packCode) != -1){
createMessage.warning("默认系统套餐包不允许删除");
return;
}
}
}
Modal.confirm({
title: '删除租户套餐包',
content: '是否删除租户套餐包',
okText: '确认',
cancelText: '取消',
onOk: async () => {
await deleteTenantPack({ ids: selectedRowKeys.value.join(',')}, success);
}
})
}
async function handleSyncDefaultPack() {
Modal.confirm({
title: '初始化默认套餐包',
content: '是否初始化默认套餐包',
okText: '确认',
cancelText: '取消',
onOk: async () => {
await syncDefaultTenantPack({tenantId: unref(tenantId)}, success);
},
});
}
/**
*
* 新增表单
*/
function handleAdd() {
openModal(true, {
isUpdate: false,
tenantId: unref(tenantId),
packType:'custom',
showFooter: true
});
}
/**
* 套餐包下面的用户
* @param record
*/
function seeTenantPackUser(record) {
packUserOpenModal(true,{
record:record
})
}
/**
* 更多
* @param record
*/
function getDropDownAction(record) {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
},
{
label: '删除',
popConfirm: {
title: '是否确认删除租户套餐包',
confirm: handleDelete.bind(null, record),
},
},
]
}
/**
* 详情
* @param record
*/
function handleDetail(record) {
openModal(true, {
isUpdate: true,
record: record,
tenantId: unref(tenantId),
packType:'custom',
showFooter: false
});
}
</script>