feat:【system】租户管理:100%

This commit is contained in:
YunaiV
2025-12-21 10:02:30 +08:00
parent 0193a408c7
commit ba84f64e37
10 changed files with 78 additions and 15 deletions

View File

@@ -56,10 +56,10 @@
</template>
<script lang="ts" setup>
import type { TenantPackage } from '@/api/system/tenant-package'
import type { TenantPackage } from '@/api/system/tenant/package'
import type { LoadMoreState } from '@/http/types'
import { onMounted, ref } from 'vue'
import { getTenantPackagePage } from '@/api/system/tenant-package'
import { getTenantPackagePage } from '@/api/system/tenant/package'
import { useAccess } from '@/hooks/useAccess'
import { DICT_TYPE } from '@/utils/constants'
import { formatDateTime } from '@/utils/date'

View File

@@ -22,6 +22,10 @@
<text class="mr-8rpx shrink-0 text-[#999]">联系人</text>
<text class="min-w-0 flex-1 truncate">{{ item.contactName || '-' }}</text>
</view>
<view class="mb-12rpx flex items-center text-28rpx text-[#666]">
<text class="mr-8rpx text-[#999]">租户套餐</text>
<text>{{ getPackageName(item.packageId) }}</text>
</view>
<view class="mb-12rpx flex items-center text-28rpx text-[#666]">
<text class="mr-8rpx text-[#999]">联系手机</text>
<text>{{ item.contactMobile || '-' }}</text>
@@ -65,9 +69,11 @@
<script lang="ts" setup>
import type { Tenant } from '@/api/system/tenant'
import type { TenantPackage } from '@/api/system/tenant/package'
import type { LoadMoreState } from '@/http/types'
import { onMounted, ref } from 'vue'
import { getTenantPage } from '@/api/system/tenant'
import { getTenantPackageList } from '@/api/system/tenant/package'
import { useAccess } from '@/hooks/useAccess'
import { DICT_TYPE } from '@/utils/constants'
import { formatDateTime } from '@/utils/date'
@@ -76,12 +82,27 @@ import TenantSearchForm from './tenant-search-form.vue'
const { hasAccessByCodes } = useAccess()
const total = ref(0)
const list = ref<Tenant[]>([])
const packageList = ref<TenantPackage[]>([])
const loadMoreState = ref<LoadMoreState>('loading')
const queryParams = ref({
pageNo: 1,
pageSize: 10,
})
/** 获取套餐名称 */
function getPackageName(packageId?: number) {
if (packageId === 0) {
return '系统租户'
}
const pkg = packageList.value.find(item => item.id === packageId)
return pkg?.name || '-'
}
/** 加载租户套餐列表 */
async function loadPackageList() {
packageList.value = await getTenantPackageList()
}
/** 查询租户列表 */
async function getList() {
loadMoreState.value = 'loading'
@@ -141,7 +162,8 @@ onReachBottom(() => {
})
/** 初始化 */
onMounted(() => {
onMounted(async () => {
await loadPackageList()
getList()
})
</script>

View File

@@ -24,8 +24,8 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { navigateBackPlus } from '@/utils'
import TenantList from './components/tenant-list.vue'
import PackageList from './components/package-list.vue'
import TenantList from './components/tenant-list.vue'
definePage({
style: {

View File

@@ -41,10 +41,10 @@
</template>
<script lang="ts" setup>
import type { TenantPackage } from '@/api/system/tenant-package'
import type { TenantPackage } from '@/api/system/tenant/package'
import { onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { deleteTenantPackage, getTenantPackage } from '@/api/system/tenant-package'
import { deleteTenantPackage, getTenantPackage } from '@/api/system/tenant/package'
import { useAccess } from '@/hooks/useAccess'
import { navigateBackPlus } from '@/utils'
import { DICT_TYPE } from '@/utils/constants'

View File

@@ -57,10 +57,10 @@
</template>
<script lang="ts" setup>
import type { TenantPackage } from '@/api/system/tenant-package'
import type { TenantPackage } from '@/api/system/tenant/package'
import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { createTenantPackage, getTenantPackage, updateTenantPackage } from '@/api/system/tenant-package'
import { createTenantPackage, getTenantPackage, updateTenantPackage } from '@/api/system/tenant/package'
import { getIntDictOptions } from '@/hooks/useDict'
import { navigateBackPlus } from '@/utils'
import { DICT_TYPE } from '@/utils/constants'
@@ -130,6 +130,7 @@ async function handleSubmit() {
}
/** 初始化 */
// TODO @芋艿:这里有个租户套餐的设置;只支持 pc 操作;
onMounted(() => {
getDetail()
})

View File

@@ -47,11 +47,11 @@
<script lang="ts" setup>
import type { Tenant } from '@/api/system/tenant'
import type { TenantPackage } from '@/api/system/tenant-package'
import type { TenantPackage } from '@/api/system/tenant/package'
import { onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { deleteTenant, getTenant } from '@/api/system/tenant'
import { getTenantPackageList } from '@/api/system/tenant-package'
import { getTenantPackageList } from '@/api/system/tenant/package'
import { useAccess } from '@/hooks/useAccess'
import { navigateBackPlus } from '@/utils'
import { DICT_TYPE } from '@/utils/constants'

View File

@@ -60,7 +60,7 @@
label="用户密码"
label-width="200rpx"
prop="password"
type="password"
show-password
clearable
placeholder="请输入用户密码"
/>
@@ -111,11 +111,11 @@
<script lang="ts" setup>
import type { Tenant } from '@/api/system/tenant'
import type { TenantPackage } from '@/api/system/tenant-package'
import type { TenantPackage } from '@/api/system/tenant/package'
import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { createTenant, getTenant, updateTenant } from '@/api/system/tenant'
import { getTenantPackageList } from '@/api/system/tenant-package'
import { getTenantPackageList } from '@/api/system/tenant/package'
import { getIntDictOptions } from '@/hooks/useDict'
import { navigateBackPlus } from '@/utils'
import { DICT_TYPE } from '@/utils/constants'
@@ -135,7 +135,7 @@ const toast = useToast()
const getTitle = computed(() => props.id ? '编辑租户' : '新增租户')
const formLoading = ref(false)
const packageOptions = ref<TenantPackage[]>([])
const formData = ref<Tenant & { username?: string; password?: string }>({
const formData = ref<Tenant & { username?: string, password?: string }>({
id: undefined,
name: '',
packageId: 0,