Commit e187e7a016453e98a223d9721283e1c4c95b2251
1 parent
0a6d93fe
fix: tenant package select
Showing
2 changed files
with
42 additions
and
38 deletions
yudao-ui-admin-vue3/src/views/system/tenant/index.vue
| @@ -19,10 +19,10 @@ | @@ -19,10 +19,10 @@ | ||
| 19 | @click="handleExport()" | 19 | @click="handleExport()" |
| 20 | /> | 20 | /> |
| 21 | </template> | 21 | </template> |
| 22 | - <template #accountCount="{ row }"> | 22 | + <template #accountCount_default="{ row }"> |
| 23 | <el-tag> {{ row.accountCount }} </el-tag> | 23 | <el-tag> {{ row.accountCount }} </el-tag> |
| 24 | </template> | 24 | </template> |
| 25 | - <template #packageId="{ row }"> | 25 | + <template #packageId_default="{ row }"> |
| 26 | <el-tag v-if="row.packageId === 0" type="danger">系统租户</el-tag> | 26 | <el-tag v-if="row.packageId === 0" type="danger">系统租户</el-tag> |
| 27 | <el-tag v-else type="success"> {{ getPackageName(row.packageId) }} </el-tag> | 27 | <el-tag v-else type="success"> {{ getPackageName(row.packageId) }} </el-tag> |
| 28 | </template> | 28 | </template> |
| @@ -58,18 +58,7 @@ | @@ -58,18 +58,7 @@ | ||
| 58 | :schema="allSchemas.formSchema" | 58 | :schema="allSchemas.formSchema" |
| 59 | :rules="rules" | 59 | :rules="rules" |
| 60 | ref="formRef" | 60 | ref="formRef" |
| 61 | - > | ||
| 62 | - <template #packageId> | ||
| 63 | - <el-select v-model="tenantPackageId"> | ||
| 64 | - <el-option | ||
| 65 | - v-for="item in tenantPackageOptions" | ||
| 66 | - :key="item.id" | ||
| 67 | - :label="item.name" | ||
| 68 | - :value="item.id" | ||
| 69 | - /> | ||
| 70 | - </el-select> | ||
| 71 | - </template> | ||
| 72 | - </Form> | 61 | + /> |
| 73 | <!-- 对话框(详情) --> | 62 | <!-- 对话框(详情) --> |
| 74 | <Descriptions | 63 | <Descriptions |
| 75 | v-if="actionType === 'detail'" | 64 | v-if="actionType === 'detail'" |
| @@ -97,16 +86,15 @@ | @@ -97,16 +86,15 @@ | ||
| 97 | </XModal> | 86 | </XModal> |
| 98 | </template> | 87 | </template> |
| 99 | <script setup lang="ts" name="Tenant"> | 88 | <script setup lang="ts" name="Tenant"> |
| 100 | -import { ref, unref, onMounted } from 'vue' | 89 | +import { ref, unref } from 'vue' |
| 101 | import { useI18n } from '@/hooks/web/useI18n' | 90 | import { useI18n } from '@/hooks/web/useI18n' |
| 102 | import { useMessage } from '@/hooks/web/useMessage' | 91 | import { useMessage } from '@/hooks/web/useMessage' |
| 103 | import { useVxeGrid } from '@/hooks/web/useVxeGrid' | 92 | import { useVxeGrid } from '@/hooks/web/useVxeGrid' |
| 104 | import { VxeGridInstance } from 'vxe-table' | 93 | import { VxeGridInstance } from 'vxe-table' |
| 105 | -import { ElTag, ElSelect, ElOption } from 'element-plus' | 94 | +import { ElTag } from 'element-plus' |
| 106 | import { FormExpose } from '@/components/Form' | 95 | import { FormExpose } from '@/components/Form' |
| 107 | import * as TenantApi from '@/api/system/tenant' | 96 | import * as TenantApi from '@/api/system/tenant' |
| 108 | -import { rules, allSchemas } from './tenant.data' | ||
| 109 | -import { getTenantPackageList, TenantPackageVO } from '@/api/system/tenantPackage' | 97 | +import { rules, allSchemas, tenantPackageOption } from './tenant.data' |
| 110 | 98 | ||
| 111 | const { t } = useI18n() // 国际化 | 99 | const { t } = useI18n() // 国际化 |
| 112 | const message = useMessage() // 消息弹窗 | 100 | const message = useMessage() // 消息弹窗 |
| @@ -125,17 +113,10 @@ const dialogVisible = ref(false) // 是否显示弹出层 | @@ -125,17 +113,10 @@ const dialogVisible = ref(false) // 是否显示弹出层 | ||
| 125 | const dialogTitle = ref('edit') // 弹出层标题 | 113 | const dialogTitle = ref('edit') // 弹出层标题 |
| 126 | const formRef = ref<FormExpose>() // 表单 Ref | 114 | const formRef = ref<FormExpose>() // 表单 Ref |
| 127 | const detailRef = ref() // 详情 Ref | 115 | const detailRef = ref() // 详情 Ref |
| 128 | -const tenantPackageId = ref() // 套餐 | ||
| 129 | -const tenantPackageOptions = ref<TenantPackageVO[]>([]) //套餐列表 | ||
| 130 | - | ||
| 131 | -const getTenantPackageOptions = async () => { | ||
| 132 | - const res = await getTenantPackageList() | ||
| 133 | - tenantPackageOptions.value.push(...res) | ||
| 134 | -} | ||
| 135 | const getPackageName = (packageId: number) => { | 116 | const getPackageName = (packageId: number) => { |
| 136 | - for (let item of tenantPackageOptions.value) { | ||
| 137 | - if (item.id === packageId) { | ||
| 138 | - return item.name | 117 | + for (let item of tenantPackageOption) { |
| 118 | + if (item.value === packageId) { | ||
| 119 | + return item.label | ||
| 139 | } | 120 | } |
| 140 | } | 121 | } |
| 141 | return '未知套餐' | 122 | return '未知套餐' |
| @@ -151,7 +132,6 @@ const setDialogTile = (type: string) => { | @@ -151,7 +132,6 @@ const setDialogTile = (type: string) => { | ||
| 151 | // 新增操作 | 132 | // 新增操作 |
| 152 | const handleCreate = () => { | 133 | const handleCreate = () => { |
| 153 | // 重置表单 | 134 | // 重置表单 |
| 154 | - tenantPackageId.value = '' | ||
| 155 | setDialogTile('create') | 135 | setDialogTile('create') |
| 156 | } | 136 | } |
| 157 | 137 | ||
| @@ -160,7 +140,6 @@ const handleUpdate = async (rowId: number) => { | @@ -160,7 +140,6 @@ const handleUpdate = async (rowId: number) => { | ||
| 160 | setDialogTile('update') | 140 | setDialogTile('update') |
| 161 | // 设置数据 | 141 | // 设置数据 |
| 162 | const res = await TenantApi.getTenantApi(rowId) | 142 | const res = await TenantApi.getTenantApi(rowId) |
| 163 | - tenantPackageId.value = res.packageId | ||
| 164 | unref(formRef)?.setValues(res) | 143 | unref(formRef)?.setValues(res) |
| 165 | } | 144 | } |
| 166 | 145 | ||
| @@ -168,7 +147,6 @@ const handleUpdate = async (rowId: number) => { | @@ -168,7 +147,6 @@ const handleUpdate = async (rowId: number) => { | ||
| 168 | const handleDetail = async (rowId: number) => { | 147 | const handleDetail = async (rowId: number) => { |
| 169 | // 设置数据 | 148 | // 设置数据 |
| 170 | const res = await TenantApi.getTenantApi(rowId) | 149 | const res = await TenantApi.getTenantApi(rowId) |
| 171 | - tenantPackageId.value = res.packageId | ||
| 172 | detailRef.value = res | 150 | detailRef.value = res |
| 173 | setDialogTile('detail') | 151 | setDialogTile('detail') |
| 174 | } | 152 | } |
| @@ -193,7 +171,6 @@ const submitForm = async () => { | @@ -193,7 +171,6 @@ const submitForm = async () => { | ||
| 193 | // 提交请求 | 171 | // 提交请求 |
| 194 | try { | 172 | try { |
| 195 | const data = unref(formRef)?.formModel as TenantApi.TenantVO | 173 | const data = unref(formRef)?.formModel as TenantApi.TenantVO |
| 196 | - data.packageId = tenantPackageId.value | ||
| 197 | if (actionType.value === 'create') { | 174 | if (actionType.value === 'create') { |
| 198 | await TenantApi.createTenantApi(data) | 175 | await TenantApi.createTenantApi(data) |
| 199 | message.success(t('common.createSuccess')) | 176 | message.success(t('common.createSuccess')) |
| @@ -211,9 +188,4 @@ const submitForm = async () => { | @@ -211,9 +188,4 @@ const submitForm = async () => { | ||
| 211 | } | 188 | } |
| 212 | }) | 189 | }) |
| 213 | } | 190 | } |
| 214 | - | ||
| 215 | -// ========== 初始化 ========== | ||
| 216 | -onMounted(async () => { | ||
| 217 | - await getTenantPackageOptions() | ||
| 218 | -}) | ||
| 219 | </script> | 191 | </script> |
yudao-ui-admin-vue3/src/views/system/tenant/tenant.data.ts
| @@ -3,7 +3,23 @@ import { useI18n } from '@/hooks/web/useI18n' | @@ -3,7 +3,23 @@ import { useI18n } from '@/hooks/web/useI18n' | ||
| 3 | import { required } from '@/utils/formRules' | 3 | import { required } from '@/utils/formRules' |
| 4 | import { DICT_TYPE } from '@/utils/dict' | 4 | import { DICT_TYPE } from '@/utils/dict' |
| 5 | import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas' | 5 | import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas' |
| 6 | +import { getTenantPackageList, TenantPackageVO } from '@/api/system/tenantPackage' | ||
| 7 | +import { ComponentOptions } from '@/types/components' | ||
| 6 | const { t } = useI18n() // 国际化 | 8 | const { t } = useI18n() // 国际化 |
| 9 | +export const tenantPackageOption: ComponentOptions[] = [] | ||
| 10 | +const getTenantPackageOptions = async () => { | ||
| 11 | + const res = await getTenantPackageList() | ||
| 12 | + res.forEach((tenantPackage: TenantPackageVO) => { | ||
| 13 | + tenantPackageOption.push({ | ||
| 14 | + key: tenantPackage.id, | ||
| 15 | + value: tenantPackage.id, | ||
| 16 | + label: tenantPackage.name | ||
| 17 | + }) | ||
| 18 | + }) | ||
| 19 | + | ||
| 20 | + return tenantPackageOption | ||
| 21 | +} | ||
| 22 | +getTenantPackageOptions() | ||
| 7 | 23 | ||
| 8 | // 表单校验 | 24 | // 表单校验 |
| 9 | export const rules = reactive({ | 25 | export const rules = reactive({ |
| @@ -30,7 +46,18 @@ const crudSchemas = reactive<VxeCrudSchema>({ | @@ -30,7 +46,18 @@ const crudSchemas = reactive<VxeCrudSchema>({ | ||
| 30 | }, | 46 | }, |
| 31 | { | 47 | { |
| 32 | title: '租户套餐', | 48 | title: '租户套餐', |
| 33 | - field: 'packageId' | 49 | + field: 'packageId', |
| 50 | + table: { | ||
| 51 | + slots: { | ||
| 52 | + default: 'packageId_default' | ||
| 53 | + } | ||
| 54 | + }, | ||
| 55 | + form: { | ||
| 56 | + component: 'Select', | ||
| 57 | + componentProps: { | ||
| 58 | + options: tenantPackageOption | ||
| 59 | + } | ||
| 60 | + } | ||
| 34 | }, | 61 | }, |
| 35 | { | 62 | { |
| 36 | title: '联系人', | 63 | title: '联系人', |
| @@ -60,6 +87,11 @@ const crudSchemas = reactive<VxeCrudSchema>({ | @@ -60,6 +87,11 @@ const crudSchemas = reactive<VxeCrudSchema>({ | ||
| 60 | { | 87 | { |
| 61 | title: '账号额度', | 88 | title: '账号额度', |
| 62 | field: 'accountCount', | 89 | field: 'accountCount', |
| 90 | + table: { | ||
| 91 | + slots: { | ||
| 92 | + default: 'accountCount_default' | ||
| 93 | + } | ||
| 94 | + }, | ||
| 63 | form: { | 95 | form: { |
| 64 | component: 'InputNumber' | 96 | component: 'InputNumber' |
| 65 | } | 97 | } |