feat organize staff management by role
This commit is contained in:
@@ -38,10 +38,18 @@
|
||||
<a-table-column v-if="definition.accountManagement" title="账户数" :width="90">
|
||||
<template #cell="{ record }">{{ accountCounts[String(record.identity)] ?? 0 }}</template>
|
||||
</a-table-column>
|
||||
<a-table-column v-if="definition.name === 'staff_account'" title="审批状态" :width="100">
|
||||
<template #cell="{ record }">
|
||||
<a-tag :color="Number(record.status) === 1 ? 'green' : Number(record.status) === 2 ? 'red' : 'orange'">
|
||||
{{ Number(record.status) === 1 ? '已通过' : Number(record.status) === 2 ? '已禁用' : '待审批' }}
|
||||
</a-tag>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column title="操作" :width="definition.accountManagement ? 350 : 280" fixed="right">
|
||||
<template #cell="{ record }">
|
||||
<a-space>
|
||||
<a-button v-if="definition.accountManagement" size="mini" type="primary" @click="manageAccounts(record)">账户管理</a-button>
|
||||
<a-button v-if="definition.name === 'staff_account'" size="mini" @click="viewCredentials(record)">查看资质</a-button>
|
||||
<a-button size="mini" @click="openDetail(record)">详情</a-button>
|
||||
<a-button v-if="canEdit" size="mini" :disabled="isProtectedRecord(record)" @click="openEdit(record)">编辑</a-button>
|
||||
<a-button v-if="canChangeStatus" size="mini" :disabled="isProtectedRecord(record)" @click="openStatus(record)">审核</a-button>
|
||||
@@ -175,6 +183,9 @@ const managedOwnerIdentity = computed(() =>
|
||||
const managedRelationKey = computed(() =>
|
||||
typeof route.query.relation_key === 'string' ? route.query.relation_key : '',
|
||||
);
|
||||
const staffType = computed(() =>
|
||||
typeof route.meta.staffType === 'string' ? route.meta.staffType : '',
|
||||
);
|
||||
const platformRootWriteResources = new Set([
|
||||
'platform_account',
|
||||
'platform_role',
|
||||
@@ -275,7 +286,20 @@ function resetForm(data?: Row) {
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
if (managedOwnerIdentity.value && managedRelationKey.value) {
|
||||
if (staffType.value) {
|
||||
const staff = await loadAllRows(props.definition.resource);
|
||||
const keyword = filters.keyword.trim().toLowerCase();
|
||||
const filtered = staff.filter(
|
||||
(row) =>
|
||||
String(row.role_code ?? '') === staffType.value &&
|
||||
(!keyword ||
|
||||
['username', 'name', 'phone'].some((key) =>
|
||||
String(row[key] ?? '').toLowerCase().includes(keyword),
|
||||
)),
|
||||
);
|
||||
list.value = filtered.slice((page.value - 1) * pageSize, page.value * pageSize);
|
||||
total.value = filtered.length;
|
||||
} else if (managedOwnerIdentity.value && managedRelationKey.value) {
|
||||
const accounts = await loadAllRows(props.definition.resource);
|
||||
const keyword = filters.keyword.trim().toLowerCase();
|
||||
const filtered = accounts.filter(
|
||||
@@ -345,6 +369,16 @@ function manageAccounts(row: Row) {
|
||||
});
|
||||
}
|
||||
|
||||
function viewCredentials(row: Row) {
|
||||
router.push({
|
||||
name: 'staff-credential',
|
||||
query: {
|
||||
owner_identity: String(row.identity ?? ''),
|
||||
relation_key: 'staff_account_identity',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function syncQuery() {
|
||||
const query: Record<string, string> = {};
|
||||
if (managedOwnerIdentity.value) query.owner_identity = managedOwnerIdentity.value;
|
||||
@@ -371,6 +405,7 @@ function openCreate() {
|
||||
if (managedOwnerIdentity.value && managedRelationKey.value) {
|
||||
form[managedRelationKey.value] = managedOwnerIdentity.value;
|
||||
}
|
||||
if (staffType.value) form.role_code = staffType.value;
|
||||
formVisible.value = true;
|
||||
}
|
||||
|
||||
@@ -680,6 +715,7 @@ onMounted(async () => {
|
||||
(role) => !role.is_system && role.status === 1,
|
||||
);
|
||||
}
|
||||
if (route.meta.createMode) openCreate();
|
||||
});
|
||||
|
||||
watch(
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<TreePage
|
||||
v-if="definition.pageKind === 'tree'"
|
||||
:key="definition.resource"
|
||||
:key="String(route.name)"
|
||||
:definition="definition"
|
||||
/>
|
||||
<CrudListPage
|
||||
v-else
|
||||
:key="definition.resource"
|
||||
:key="String(route.name)"
|
||||
:definition="definition"
|
||||
/>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user