diff --git a/src/api/qy/qyUser.ts b/src/api/qy/qyUser.ts index 268b50a..c4c8e83 100644 --- a/src/api/qy/qyUser.ts +++ b/src/api/qy/qyUser.ts @@ -4,6 +4,13 @@ import { UserDTO } from "../system/user"; /** * 企业微信用户信息 */ +export interface QyUserStatsDTO { + /** 用户余额 */ + balance?: number; + /** 已使用余额 */ + useBalance?: number; +} + export interface QyUserDTO { /** 用户ID(导出列:用户ID) */ id?: number; @@ -131,7 +138,7 @@ export const getQyUserDetailApi = (id: number) => { }; export const getTotalBalanceApi = (corpid: string) => { - return http.request>("get", `/qywx/users/getTotalBalance`, { + return http.request>("get", `/qywx/users/getTotalBalance`, { params: { corpid } }); }; \ No newline at end of file diff --git a/src/api/system/role.ts b/src/api/system/role.ts index 41771a9..55f9df6 100644 --- a/src/api/system/role.ts +++ b/src/api/system/role.ts @@ -30,6 +30,16 @@ export function getRoleListApi(params: RoleQuery) { ); } +export function getRoleAllApi(params: RoleQuery) { + return http.request>( + "get", + "/system/role/all", + { + params + } + ); +} + export function getRoleInfoApi(roleId: number) { return http.request>("get", "/system/role/" + roleId); } diff --git a/src/views/qy/balance/index.vue b/src/views/qy/balance/index.vue index d10929f..bdd8383 100644 --- a/src/views/qy/balance/index.vue +++ b/src/views/qy/balance/index.vue @@ -34,13 +34,13 @@ const pagination = ref({ const loading = ref(false); const dataList = ref([]); -const totalBalance = ref(0); const balanceData = ref([ { - name: '用户总余额', value: - totalBalance.value.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) - + '元' + name: '用户总借呗', value: '0元', + }, + { + name: '已用总借呗', value: '0元', }, ]); @@ -93,8 +93,10 @@ const handlePaginationChange = () => getList(); const getTotalBalance = async () => { try { const { data } = await getTotalBalanceApi(wxStore.corpid); - totalBalance.value = data; - balanceData.value[0].value = data.toLocaleString('en-US', + balanceData.value[0].value = data.balance.toLocaleString('en-US', + { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + + '元'; + balanceData.value[1].value = data.useBalance.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + '元'; } catch (error) { @@ -156,8 +158,16 @@ getList().then(() => getTotalBalance()); - - + + + + + diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index a1a216c..3cb82eb 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -81,6 +81,9 @@ const rules: FormRules = { watch(activeTab, async (val) => { console.log("activeTab", val); // 输出当前选中的标签的 key 或其他标识符 opRow.value = dataList.value.find(item => item.roleKey == val); + if (!opRow.value) { + return; + } await getRoleInfo("update", opRow.value); Object.assign(formData, opRow.value); formData.menuIds = opRow.value.selectedMenuList; @@ -154,6 +157,7 @@ async function handleConfirm() { try { await formRef.value?.validate(); loading.value = true; + console.log("opType", opType.value); if (opType.value === 'add') { await addRoleApi(formData as AddRoleCommand); } else { diff --git a/src/views/system/role/utils/hook.tsx b/src/views/system/role/utils/hook.tsx index fad3bd6..989f5f7 100644 --- a/src/views/system/role/utils/hook.tsx +++ b/src/views/system/role/utils/hook.tsx @@ -2,6 +2,7 @@ import dayjs from "dayjs"; import { message } from "@/utils/message"; import { deleteRoleApi, + getRoleAllApi, getRoleListApi, RoleDTO, RoleQuery @@ -150,10 +151,16 @@ export function useRole() { async function onSearch() { try { loading.value = true; - const { data } = await getRoleListApi(toRaw(form)); + const { data } = await getRoleAllApi(toRaw(form)); console.log("role list", data); - dataList.value = data.rows; - pagination.total = data.total; + // 重新排序:base排第一,admin排最后 + dataList.value = data.sort((a, b) => { + if (a.roleKey === 'base') return -1; + if (b.roleKey === 'base') return 1; + if (a.roleKey === 'admin') return 1; + if (b.roleKey === 'admin') return -1; + return 0; + }); } catch (e) { console.error(e); ElMessage.error((e as Error)?.message || "加载失败"); @@ -190,7 +197,7 @@ export function useRole() { form, loading, columns, - dataList, + dataList, activeTab, pagination, onSearch,