Эх сурвалжийг харах

修复角色管理添加角色员工列表无法筛选的问题
新增套餐管理查询套餐企业分页功能

zhontai 2 жил өмнө
parent
commit
f83d82678c

+ 1 - 1
src/api/admin/Permission.ts

@@ -161,7 +161,7 @@ export class PermissionApi<SecurityDataType = unknown> extends HttpClient<Securi
    *
    * @tags permission
    * @name GetPermissionList
-   * @summary 查询角色权限-权限列表
+   * @summary 查询授权权限列表
    * @request GET:/api/admin/permission/get-permission-list
    * @secure
    */

+ 22 - 1
src/api/admin/Pkg.ts

@@ -12,6 +12,7 @@
 import { AxiosResponse } from 'axios'
 import {
   PageInputPkgGetPageDto,
+  PageInputPkgGetPkgTenantListInput,
   PkgAddInput,
   PkgAddPkgTenantListInput,
   PkgSetPkgPermissionsInput,
@@ -21,6 +22,7 @@ import {
   ResultOutputListPkgGetListOutput,
   ResultOutputListPkgGetPkgTenantListOutput,
   ResultOutputPageOutputPkgGetPageOutput,
+  ResultOutputPageOutputPkgGetPkgTenantListOutput,
   ResultOutputPkgGetOutput,
 } from './data-contracts'
 import { ContentType, HttpClient, RequestParams } from './http-client'
@@ -122,6 +124,25 @@ export class PkgApi<SecurityDataType = unknown> extends HttpClient<SecurityDataT
       format: 'json',
       ...params,
     })
+  /**
+   * No description
+   *
+   * @tags pkg
+   * @name GetPkgTenantPage
+   * @summary 查询套餐租户分页
+   * @request POST:/api/admin/pkg/get-pkg-tenant-page
+   * @secure
+   */
+  getPkgTenantPage = (data: PageInputPkgGetPkgTenantListInput, params: RequestParams = {}) =>
+    this.request<ResultOutputPageOutputPkgGetPkgTenantListOutput, any>({
+      path: `/api/admin/pkg/get-pkg-tenant-page`,
+      method: 'POST',
+      body: data,
+      secure: true,
+      type: ContentType.Json,
+      format: 'json',
+      ...params,
+    })
   /**
    * No description
    *
@@ -208,7 +229,7 @@ export class PkgApi<SecurityDataType = unknown> extends HttpClient<SecurityDataT
    *
    * @tags pkg
    * @name Add
-   * @summary 添加
+   * @summary 新增
    * @request POST:/api/admin/pkg/add
    * @secure
    */

+ 1 - 1
src/api/admin/Role.ts

@@ -162,7 +162,7 @@ export class RoleApi<SecurityDataType = unknown> extends HttpClient<SecurityData
    *
    * @tags role
    * @name Add
-   * @summary 添加
+   * @summary 新增
    * @request POST:/api/admin/role/add
    * @secure
    */

+ 61 - 0
src/api/admin/data-contracts.ts

@@ -1351,6 +1351,22 @@ export interface PageInputPkgGetPageDto {
   filter?: PkgGetPageDto
 }
 
+/** 分页信息输入 */
+export interface PageInputPkgGetPkgTenantListInput {
+  /**
+   * 当前页标
+   * @format int32
+   */
+  currentPage?: number
+  /**
+   * 每页大小
+   * @format int32
+   */
+  pageSize?: number
+  dynamicFilter?: DynamicFilterInfo
+  filter?: PkgGetPkgTenantListInput
+}
+
 /** 分页信息输入 */
 export interface PageInputRoleGetPageDto {
   /**
@@ -1509,6 +1525,17 @@ export interface PageOutputPkgGetPageOutput {
   list?: PkgGetPageOutput[] | null
 }
 
+/** 分页信息输出 */
+export interface PageOutputPkgGetPkgTenantListOutput {
+  /**
+   * 数据总数
+   * @format int64
+   */
+  total?: number
+  /** 数据 */
+  list?: PkgGetPkgTenantListOutput[] | null
+}
+
 /** 分页信息输出 */
 export interface PageOutputRoleGetPageOutput {
   /**
@@ -2216,6 +2243,13 @@ export interface PkgGetListOutput {
   sort?: number
   /** 描述 */
   description?: string | null
+  /** 启用 */
+  enabled?: boolean
+  /**
+   * 创建时间
+   * @format date-time
+   */
+  createdTime?: string | null
 }
 
 export interface PkgGetOutput {
@@ -2261,6 +2295,11 @@ export interface PkgGetPageOutput {
   code?: string | null
   /** 说明 */
   description?: string | null
+  /**
+   * 排序
+   * @format int32
+   */
+  sort?: number
   /** 启用 */
   enabled?: boolean
   /**
@@ -2270,6 +2309,16 @@ export interface PkgGetPageOutput {
   createdTime?: string | null
 }
 
+export interface PkgGetPkgTenantListInput {
+  /** 租户名 */
+  tenantName?: string | null
+  /**
+   * 套餐Id
+   * @format int64
+   */
+  pkgId?: number | null
+}
+
 export interface PkgGetPkgTenantListOutput {
   /**
    * 主键Id
@@ -2787,6 +2836,18 @@ export interface ResultOutputPageOutputPkgGetPageOutput {
   data?: PageOutputPkgGetPageOutput
 }
 
+/** 结果输出 */
+export interface ResultOutputPageOutputPkgGetPkgTenantListOutput {
+  /** 是否成功标记 */
+  success?: boolean
+  /** 编码 */
+  code?: string | null
+  /** 消息 */
+  msg?: string | null
+  /** 分页信息输出 */
+  data?: PageOutputPkgGetPkgTenantListOutput
+}
+
 /** 结果输出 */
 export interface ResultOutputPageOutputRoleGetPageOutput {
   /** 是否成功标记 */

+ 110 - 52
src/views/admin/pkg/index.vue

@@ -4,8 +4,8 @@
       <div class="my-flex-column w100 h100">
         <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
           <el-form :inline="true" @submit.stop.prevent>
-            <el-form-item label="套餐名">
-              <el-input v-model="state.filter.pkgName" placeholder="套餐名" @keyup.enter="onQuery" />
+            <el-form-item label="套餐名">
+              <el-input v-model="state.filter.pkgName" placeholder="套餐名" @keyup.enter="onQuery" />
             </el-form-item>
             <el-form-item>
               <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
@@ -18,15 +18,13 @@
           <el-table
             ref="pkgTableRef"
             v-loading="state.loading"
-            :data="state.pkgTreeData"
-            row-key="id"
+            :data="state.pkgData"
             default-expand-all
-            :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
             highlight-current-row
             style="width: 100%"
-            @current-change="onCurrentChange"
+            @current-change="onTableCurrentChange"
           >
-            <el-table-column prop="name" label="套餐名" min-width="120" show-overflow-tooltip />
+            <el-table-column prop="name" label="套餐名" min-width="120" show-overflow-tooltip />
             <el-table-column prop="sort" label="排序" width="80" align="center" show-overflow-tooltip />
             <el-table-column label="操作" width="100" fixed="right" header-align="center" align="center">
               <template #default="{ row }">
@@ -45,6 +43,19 @@
               </template>
             </el-table-column>
           </el-table>
+          <div class="my-flex my-flex-end" style="margin-top: 20px">
+            <el-pagination
+              v-model:currentPage="state.pageInput.currentPage"
+              v-model:page-size="state.pageInput.pageSize"
+              :total="state.total"
+              :page-sizes="[10, 20, 50, 100]"
+              small
+              background
+              @size-change="onSizeChange"
+              @current-change="onCurrentChange"
+              layout="total, sizes, prev, pager, next, jumper"
+            />
+          </div>
         </el-card>
       </div>
     </pane>
@@ -52,13 +63,13 @@
       <div class="my-flex-column w100 h100">
         <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
           <el-form :inline="true" @submit.stop.prevent>
-            <el-form-item label="租户名">
-              <el-input v-model="state.filter.name" placeholder="租户名" @keyup.enter="onGetPkgTenantList" />
+            <el-form-item label="企业名">
+              <el-input v-model="state.filter.name" placeholder="企业名" @keyup.enter="onGetPkgTenantList" />
             </el-form-item>
             <el-form-item>
               <el-button type="primary" icon="ele-Search" @click="onGetPkgTenantList"> 查询 </el-button>
-              <el-button v-auth="'api:admin:pkg:add-pkg-tenant'" type="primary" icon="ele-Plus" @click="onAddTenant"> 添加租户 </el-button>
-              <el-button v-auth="'api:admin:pkg:remove-pkg-tenant'" type="danger" icon="ele-Delete" @click="onRemoveTenant"> 移除租户 </el-button>
+              <el-button v-auth="'api:admin:pkg:add-pkg-tenant'" type="primary" icon="ele-Plus" @click="onAddTenant"> 添加企业 </el-button>
+              <el-button v-auth="'api:admin:pkg:remove-pkg-tenant'" type="danger" icon="ele-Delete" @click="onRemoveTenant"> 移除企业 </el-button>
             </el-form-item>
           </el-form>
         </el-card>
@@ -67,23 +78,36 @@
           <el-table
             ref="tenantTableRef"
             v-loading="state.tenantListLoading"
-            :data="state.tenantListData"
+            :data="state.tenantData"
             row-key="id"
             style="width: 100%"
             @row-click="onTenantRowClick"
           >
             <el-table-column type="selection" width="55" />
-            <el-table-column prop="name" label="租户名" min-width="120" show-overflow-tooltip />
-            <el-table-column prop="code" label="租户编码" min-width="120" show-overflow-tooltip />
+            <el-table-column prop="name" label="企业名" min-width="120" show-overflow-tooltip />
+            <el-table-column prop="code" label="企业编码" min-width="120" show-overflow-tooltip />
           </el-table>
+          <div class="my-flex my-flex-end" style="margin-top: 20px">
+            <el-pagination
+              v-model:currentPage="state.pageInput.currentPage"
+              v-model:page-size="state.pageInput.pageSize"
+              :total="state.tenantTotal"
+              :page-sizes="[10, 20, 50, 100]"
+              small
+              background
+              @size-change="onTenantSizeChange"
+              @current-change="onTenantCurrentChange"
+              layout="total, sizes, prev, pager, next, jumper"
+            />
+          </div>
         </el-card>
       </div>
     </pane>
 
-    <pkg-form ref="pkgFormRef" :title="state.pkgFormTitle" :pkg-tree-data="state.pkgFormTreeData"></pkg-form>
+    <pkg-form ref="pkgFormRef" :title="state.pkgFormTitle"></pkg-form>
     <tenant-select
       ref="tenantSelectRef"
-      :title="`添加【${state.pkgName}】租户`"
+      :title="`添加【${state.pkgName}】企业`"
       multiple
       :sure-loading="state.sureLoading"
       @sure="onSureTenant"
@@ -94,11 +118,15 @@
 
 <script lang="ts" setup name="admin/pkg">
 import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, nextTick, defineAsyncComponent } from 'vue'
-import { PkgGetListOutput, PkgGetPkgTenantListOutput, PkgGetPageOutput, PkgAddPkgTenantListInput } from '/@/api/admin/data-contracts'
+import {
+  PageInputPkgGetPageDto,
+  PkgGetPkgTenantListOutput,
+  PkgGetPageOutput,
+  PkgAddPkgTenantListInput,
+  PageInputPkgGetPkgTenantListInput,
+} from '/@/api/admin/data-contracts'
 import { PkgApi } from '/@/api/admin/Pkg'
-import { listToTree, filterTree } from '/@/utils/tree'
 import { ElTable } from 'element-plus'
-import { cloneDeep } from 'lodash-es'
 import eventBus from '/@/utils/mitt'
 import { auth } from '/@/utils/authFunction'
 import { Pane } from 'splitpanes'
@@ -127,9 +155,25 @@ const state = reactive({
     name: '',
     pkgName: '',
   },
-  pkgTreeData: [] as any,
-  pkgFormTreeData: [] as any,
-  tenantListData: [] as PkgGetPkgTenantListOutput[],
+  total: 0,
+  pageInput: {
+    currentPage: 1,
+    pageSize: 20,
+    filter: {
+      name: '',
+    },
+  } as PageInputPkgGetPageDto,
+  pkgData: [] as any,
+  tenantPageInput: {
+    currentPage: 1,
+    pageSize: 20,
+    filter: {
+      pkgId: null,
+      tenantName: '',
+    },
+  } as PageInputPkgGetPkgTenantListInput,
+  tenantData: [] as PkgGetPkgTenantListOutput[],
+  tenantTotal: 0,
   pkgId: undefined as number | undefined,
   pkgName: '' as string | null | undefined,
 })
@@ -148,36 +192,52 @@ onBeforeMount(() => {
 
 const onQuery = async () => {
   state.loading = true
-  const res = await new PkgApi().getList().catch(() => {
+  if (state.pageInput.filter) state.pageInput.filter.name = state.filter.pkgName
+  const res = await new PkgApi().getPage(state.pageInput).catch(() => {
     state.loading = false
   })
-  if (res && res.data && res.data.length > 0) {
-    state.pkgTreeData = filterTree(listToTree(cloneDeep(res.data)), state.filter.pkgName)
-    state.pkgFormTreeData = listToTree(cloneDeep(res.data).filter((a) => a.parentId === 0))
-    if (state.pkgTreeData.length > 0) {
-      nextTick(() => {
-        pkgTableRef.value!.setCurrentRow(state.pkgTreeData[0])
-      })
-    }
-  } else {
-    state.pkgTreeData = []
-    state.pkgFormTreeData = []
-  }
+
+  state.pkgData = res?.data?.list ?? []
+  state.total = res?.data?.total ?? 0
+
+  nextTick(() => {
+    pkgTableRef.value!.setCurrentRow(state.pkgData[0])
+  })
 
   state.loading = false
 }
 
-const onAdd = (row: PkgGetListOutput | undefined = undefined) => {
+const onSizeChange = (val: number) => {
+  state.pageInput.pageSize = val
+  onQuery()
+}
+
+const onCurrentChange = (val: number) => {
+  state.pageInput.currentPage = val
+  onQuery()
+}
+
+const onTableCurrentChange = (currentRow: PkgGetPageOutput) => {
+  if (!currentRow) {
+    return
+  }
+
+  state.pkgId = currentRow.id
+  state.pkgName = currentRow.name
+  onGetPkgTenantList()
+}
+
+const onAdd = () => {
   state.pkgFormTitle = '新增套餐'
-  pkgFormRef.value.open({ parentId: row?.id })
+  pkgFormRef.value.open({ enabled: true })
 }
 
-const onEdit = (row: PkgGetListOutput) => {
+const onEdit = (row: PkgGetPageOutput) => {
   state.pkgFormTitle = '编辑套餐'
   pkgFormRef.value.open(row)
 }
 
-const onDelete = (row: PkgGetListOutput) => {
+const onDelete = (row: PkgGetPageOutput) => {
   proxy.$modal
     .confirmDelete(`确定要删除套餐【${row.name}】?`)
     .then(async () => {
@@ -189,26 +249,24 @@ const onDelete = (row: PkgGetListOutput) => {
 
 const onGetPkgTenantList = async () => {
   state.tenantListLoading = true
-  const res = await new PkgApi().getPkgTenantList({ PkgId: state.pkgId, TenantName: state.filter.name }).catch(() => {
+  state.tenantPageInput.filter = { pkgId: state.pkgId, tenantName: state.filter.name }
+  const res = await new PkgApi().getPkgTenantPage(state.tenantPageInput).catch(() => {
     state.tenantListLoading = false
   })
   state.tenantListLoading = false
   if (res?.success) {
-    if (res.data && res.data.length > 0) {
-      state.tenantListData = res.data
-    } else {
-      state.tenantListData = []
-    }
+    state.tenantData = res?.data?.list ?? []
+    state.tenantTotal = res?.data?.total ?? 0
   }
 }
 
-const onCurrentChange = (currentRow: PkgGetListOutput) => {
-  if (!currentRow) {
-    return
-  }
+const onTenantSizeChange = (val: number) => {
+  state.tenantPageInput.pageSize = val
+  onGetPkgTenantList()
+}
 
-  state.pkgId = currentRow.id
-  state.pkgName = currentRow.name
+const onTenantCurrentChange = (val: number) => {
+  state.tenantPageInput.currentPage = val
   onGetPkgTenantList()
 }
 
@@ -268,7 +326,7 @@ const onSureTenant = async (tenants: PkgGetPageOutput[]) => {
   onGetPkgTenantList()
 }
 
-const onSetPkgMenu = (pkg: PkgGetListOutput) => {
+const onSetPkgMenu = (pkg: PkgGetPageOutput) => {
   if (!((pkg?.id as number) > 0)) {
     proxy.$modal.msgWarning('请选择套餐')
     return

+ 10 - 6
src/views/admin/tenant/components/tenant-select.vue

@@ -11,9 +11,9 @@
   >
     <div style="padding: 0px 0px 8px 8px; background-color: var(--ba-bg-color)">
       <el-card shadow="never" :body-style="{ paddingBottom: '0' }" style="margin-top: 8px">
-        <el-form :model="state.filterModel" :inline="true" @submit.stop.prevent>
-          <el-form-item label="租户名" prop="name">
-            <el-input v-model="state.filterModel.name" placeholder="租户名" @keyup.enter="onQuery" />
+        <el-form :model="state.filter" :inline="true" @submit.stop.prevent>
+          <el-form-item label="企业名" prop="name">
+            <el-input v-model="state.filter.name" placeholder="企业名" @keyup.enter="onQuery" />
           </el-form-item>
           <el-form-item>
             <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
@@ -35,8 +35,8 @@
           @row-dblclick="onRowDbClick"
         >
           <el-table-column v-if="multiple" type="selection" width="55" />
-          <el-table-column prop="name" label="租户名" min-width="80" show-overflow-tooltip />
-          <el-table-column prop="code" label="租户编码" min-width="120" show-overflow-tooltip />
+          <el-table-column prop="name" label="企业名" min-width="80" show-overflow-tooltip />
+          <el-table-column prop="code" label="企业编码" min-width="120" show-overflow-tooltip />
           <!-- <el-table-column prop="email" label="邮箱" min-width="120" show-overflow-tooltip /> -->
         </el-table>
         <div class="my-flex my-flex-end" style="margin-top: 20px">
@@ -91,13 +91,16 @@ const tenantTableRef = ref<InstanceType<typeof ElTable>>()
 const state = reactive({
   showDialog: false,
   loading: false,
-  filterModel: {
+  filter: {
     name: '',
   },
   total: 0,
   pageInput: {
     currentPage: 1,
     pageSize: 20,
+    filter: {
+      name: '',
+    },
   } as PageInputTenantGetPageDto,
   tenantListData: [] as Array<TenantListOutput>,
 })
@@ -116,6 +119,7 @@ const close = () => {
 
 const onQuery = async () => {
   state.loading = true
+  state.pageInput.filter = state.filter
   const res = await new TenantApi().getPage(state.pageInput).catch(() => {
     state.loading = false
   })

+ 8 - 3
src/views/admin/user/components/user-select.vue

@@ -18,9 +18,9 @@
         </el-col>
         <el-col :xs="24" :sm="15">
           <el-card shadow="never" :body-style="{ paddingBottom: '0' }" style="margin-top: 8px">
-            <el-form :model="state.filterModel" :inline="true" @submit.stop.prevent>
+            <el-form :model="state.filter" :inline="true" @submit.stop.prevent>
               <el-form-item label="姓名" prop="name">
-                <el-input v-model="state.filterModel.name" placeholder="姓名" @keyup.enter="onQuery" />
+                <el-input v-model="state.filter.name" placeholder="姓名" @keyup.enter="onQuery" />
               </el-form-item>
               <el-form-item>
                 <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
@@ -103,7 +103,7 @@ const userTableRef = ref<InstanceType<typeof ElTable>>()
 const state = reactive({
   showDialog: false,
   loading: false,
-  filterModel: {
+  filter: {
     name: '',
   },
   total: 0,
@@ -134,6 +134,11 @@ const close = () => {
 
 const onQuery = async () => {
   state.loading = true
+  state.pageInput.dynamicFilter = {
+    field: 'name',
+    operator: 0,
+    value: state.filter.name,
+  }
   const res = await new UserApi().getPage(state.pageInput).catch(() => {
     state.loading = false
   })