提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<!-- 搜索 --> |
|
3 |
<ContentWrap> |
|
4 |
<el-form |
|
5 |
class="-mb-15px" |
|
6 |
:model="queryParams" |
|
7 |
ref="queryFormRef" |
|
8 |
:inline="true" |
|
9 |
label-width="68px" |
|
10 |
> |
|
11 |
<el-form-item label="租户名" prop="name"> |
|
12 |
<el-input |
|
13 |
v-model="queryParams.name" |
|
14 |
placeholder="请输入租户名" |
|
15 |
clearable |
|
16 |
@keyup.enter="handleQuery" |
|
17 |
class="!w-240px" |
|
18 |
/> |
|
19 |
</el-form-item> |
|
20 |
<el-form-item label="联系人" prop="contactName"> |
|
21 |
<el-input |
|
22 |
v-model="queryParams.contactName" |
|
23 |
placeholder="请输入联系人" |
|
24 |
clearable |
|
25 |
@keyup.enter="handleQuery" |
|
26 |
class="!w-240px" |
|
27 |
/> |
|
28 |
</el-form-item> |
|
29 |
<el-form-item label="联系手机" prop="contactMobile"> |
|
30 |
<el-input |
|
31 |
v-model="queryParams.contactMobile" |
|
32 |
placeholder="请输入联系手机" |
|
33 |
clearable |
|
34 |
@keyup.enter="handleQuery" |
|
35 |
class="!w-240px" |
|
36 |
/> |
|
37 |
</el-form-item> |
|
38 |
<el-form-item label="租户状态" prop="status"> |
|
39 |
<el-select |
|
40 |
v-model="queryParams.status" |
|
41 |
placeholder="请选择租户状态" |
|
42 |
clearable |
|
43 |
class="!w-240px" |
|
44 |
> |
|
45 |
<el-option |
|
46 |
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" |
|
47 |
:key="dict.value" |
|
48 |
:label="dict.label" |
|
49 |
:value="dict.value" |
|
50 |
/> |
|
51 |
</el-select> |
|
52 |
</el-form-item> |
|
53 |
<el-form-item label="创建时间" prop="createTime"> |
|
54 |
<el-date-picker |
|
55 |
v-model="queryParams.createTime" |
|
56 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
57 |
type="daterange" |
|
58 |
start-placeholder="开始日期" |
|
59 |
end-placeholder="结束日期" |
|
60 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
61 |
class="!w-240px" |
|
62 |
/> |
|
63 |
</el-form-item> |
|
64 |
|
|
65 |
<el-form-item> |
|
66 |
<el-button @click="handleQuery"> |
|
67 |
<Icon icon="ep:search" class="mr-5px" /> |
|
68 |
搜索 |
|
69 |
</el-button> |
|
70 |
<el-button @click="resetQuery"> |
|
71 |
<Icon icon="ep:refresh" class="mr-5px" /> |
|
72 |
重置 |
|
73 |
</el-button> |
|
74 |
<el-button |
|
75 |
type="primary" |
|
76 |
plain |
|
77 |
@click="openForm('create')" |
|
78 |
v-hasPermi="['system:tenant:create']" |
|
79 |
> |
|
80 |
<Icon icon="ep:plus" class="mr-5px" /> |
|
81 |
新增 |
|
82 |
</el-button> |
|
83 |
<el-button |
|
84 |
type="success" |
|
85 |
plain |
|
86 |
@click="handleExport" |
|
87 |
:loading="exportLoading" |
|
88 |
v-hasPermi="['system:tenant:export']" |
|
89 |
> |
|
90 |
<Icon icon="ep:download" class="mr-5px" /> |
|
91 |
导出 |
|
92 |
</el-button> |
|
93 |
</el-form-item> |
|
94 |
</el-form> |
|
95 |
</ContentWrap> |
|
96 |
|
|
97 |
<!-- 列表 --> |
|
98 |
<ContentWrap> |
|
99 |
<el-table v-loading="loading" :data="list"> |
|
100 |
<el-table-column label="租户编号" align="center" prop="id" /> |
|
101 |
<el-table-column label="租户名" align="center" prop="name" /> |
fd13b0
|
102 |
<el-table-column label="租户套餐" align="center" prop="packageId" width="180" > |
820397
|
103 |
<template #default="scope"> |
H |
104 |
<el-tag v-if="scope.row.packageId === 0" type="danger">系统租户</el-tag> |
|
105 |
<template v-else v-for="item in packageList"> |
|
106 |
<el-tag type="success" :key="item.id" v-if="item.id === scope.row.packageId"> |
|
107 |
{{ item.name }} |
|
108 |
</el-tag> |
|
109 |
</template> |
|
110 |
</template> |
|
111 |
</el-table-column> |
|
112 |
<el-table-column label="联系人" align="center" prop="contactName" /> |
|
113 |
<el-table-column label="联系手机" align="center" prop="contactMobile" /> |
|
114 |
<el-table-column label="账号额度" align="center" prop="accountCount"> |
|
115 |
<template #default="scope"> |
|
116 |
<el-tag>{{ scope.row.accountCount }}</el-tag> |
|
117 |
</template> |
|
118 |
</el-table-column> |
|
119 |
<el-table-column |
|
120 |
label="过期时间" |
|
121 |
align="center" |
|
122 |
prop="expireTime" |
|
123 |
width="180" |
|
124 |
:formatter="dateFormatter" |
|
125 |
/> |
|
126 |
<el-table-column label="绑定域名" align="center" prop="website" width="180" /> |
|
127 |
<el-table-column label="租户状态" align="center" prop="status"> |
|
128 |
<template #default="scope"> |
|
129 |
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> |
|
130 |
</template> |
|
131 |
</el-table-column> |
|
132 |
<el-table-column |
|
133 |
label="创建时间" |
|
134 |
align="center" |
|
135 |
prop="createTime" |
|
136 |
width="180" |
|
137 |
:formatter="dateFormatter" |
|
138 |
/> |
|
139 |
<el-table-column label="操作" align="center" min-width="110" fixed="right"> |
|
140 |
<template #default="scope"> |
|
141 |
<el-button |
|
142 |
link |
|
143 |
type="primary" |
|
144 |
@click="openForm('update', scope.row.id)" |
|
145 |
v-hasPermi="['system:tenant:update']" |
|
146 |
> |
|
147 |
编辑 |
|
148 |
</el-button> |
|
149 |
<el-button |
|
150 |
link |
|
151 |
type="danger" |
|
152 |
@click="handleDelete(scope.row.id)" |
|
153 |
v-hasPermi="['system:tenant:delete']" |
|
154 |
> |
|
155 |
删除 |
|
156 |
</el-button> |
|
157 |
</template> |
|
158 |
</el-table-column> |
|
159 |
</el-table> |
|
160 |
<!-- 分页 --> |
|
161 |
<Pagination |
|
162 |
:total="total" |
|
163 |
v-model:page="queryParams.pageNo" |
|
164 |
v-model:limit="queryParams.pageSize" |
|
165 |
@pagination="getList" |
|
166 |
/> |
|
167 |
</ContentWrap> |
|
168 |
|
|
169 |
<!-- 表单弹窗:添加/修改 --> |
|
170 |
<TenantForm ref="formRef" @success="getList" /> |
|
171 |
</template> |
|
172 |
<script lang="ts" setup> |
|
173 |
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
|
174 |
import { dateFormatter } from '@/utils/formatTime' |
|
175 |
import download from '@/utils/download' |
|
176 |
import * as TenantApi from '@/api/system/tenant' |
|
177 |
import * as TenantPackageApi from '@/api/system/tenantPackage' |
|
178 |
import TenantForm from './TenantForm.vue' |
|
179 |
|
|
180 |
defineOptions({ name: 'SystemTenant' }) |
|
181 |
|
|
182 |
const message = useMessage() // 消息弹窗 |
|
183 |
const { t } = useI18n() // 国际化 |
|
184 |
|
|
185 |
const loading = ref(true) // 列表的加载中 |
|
186 |
const total = ref(0) // 列表的总页数 |
|
187 |
const list = ref([]) // 列表的数据 |
|
188 |
const queryParams = reactive({ |
|
189 |
pageNo: 1, |
|
190 |
pageSize: 10, |
|
191 |
name: undefined, |
|
192 |
contactName: undefined, |
|
193 |
contactMobile: undefined, |
|
194 |
status: undefined, |
|
195 |
createTime: [] |
|
196 |
}) |
|
197 |
const queryFormRef = ref() // 搜索的表单 |
|
198 |
const exportLoading = ref(false) // 导出的加载中 |
|
199 |
const packageList = ref([] as TenantPackageApi.TenantPackageVO[]) //租户套餐列表 |
|
200 |
|
|
201 |
/** 查询列表 */ |
|
202 |
const getList = async () => { |
|
203 |
loading.value = true |
|
204 |
try { |
|
205 |
const data = await TenantApi.getTenantPage(queryParams) |
|
206 |
list.value = data.list |
|
207 |
total.value = data.total |
|
208 |
} finally { |
|
209 |
loading.value = false |
|
210 |
} |
|
211 |
} |
|
212 |
|
|
213 |
/** 搜索按钮操作 */ |
|
214 |
const handleQuery = () => { |
|
215 |
queryParams.pageNo = 1 |
|
216 |
getList() |
|
217 |
} |
|
218 |
|
|
219 |
/** 重置按钮操作 */ |
|
220 |
const resetQuery = () => { |
|
221 |
queryFormRef.value.resetFields() |
|
222 |
handleQuery() |
|
223 |
} |
|
224 |
|
|
225 |
/** 添加/修改操作 */ |
|
226 |
const formRef = ref() |
|
227 |
const openForm = (type: string, id?: number) => { |
|
228 |
formRef.value.open(type, id) |
|
229 |
} |
|
230 |
|
|
231 |
/** 删除按钮操作 */ |
|
232 |
const handleDelete = async (id: number) => { |
|
233 |
try { |
|
234 |
// 删除的二次确认 |
|
235 |
await message.delConfirm() |
|
236 |
// 发起删除 |
|
237 |
await TenantApi.deleteTenant(id) |
|
238 |
message.success(t('common.delSuccess')) |
|
239 |
// 刷新列表 |
|
240 |
await getList() |
|
241 |
} catch {} |
|
242 |
} |
|
243 |
|
|
244 |
/** 导出按钮操作 */ |
|
245 |
const handleExport = async () => { |
|
246 |
try { |
|
247 |
// 导出的二次确认 |
|
248 |
await message.exportConfirm() |
|
249 |
// 发起导出 |
|
250 |
exportLoading.value = true |
|
251 |
const data = await TenantApi.exportTenant(queryParams) |
|
252 |
download.excel(data, '租户列表.xls') |
|
253 |
} catch { |
|
254 |
} finally { |
|
255 |
exportLoading.value = false |
|
256 |
} |
|
257 |
} |
|
258 |
|
|
259 |
/** 初始化 **/ |
|
260 |
onMounted(async () => { |
|
261 |
await getList() |
|
262 |
packageList.value = await TenantPackageApi.getTenantPackageList() |
|
263 |
}) |
|
264 |
</script> |