feat(platform): improve admin data workflows

This commit is contained in:
2026-08-05 13:58:16 +08:00
parent 3b0188e9cf
commit 20e3071789
23 changed files with 666 additions and 296 deletions

View File

@@ -0,0 +1,35 @@
<template>
<a-tooltip :content="`${value}\n点击复制完整唯一标识`">
<button class="identity-text" type="button" :aria-label="`复制完整唯一标识 ${value}`" @click="copyIdentity">
{{ shortValue }}
</button>
</a-tooltip>
</template>
<script setup lang="ts">
import { Message } from '@arco-design/web-vue';
import { computed } from 'vue';
const props = defineProps<{ value: string }>();
const shortValue = computed(() => props.value.slice(-12));
async function copyIdentity() {
try {
await navigator.clipboard.writeText(props.value);
Message.success('完整唯一标识已复制');
} catch {
Message.error('复制失败,请从悬浮提示中复制');
}
}
</script>
<style scoped>
.identity-text {
padding: 0;
color: rgb(var(--primary-6));
font: inherit;
background: transparent;
border: 0;
cursor: pointer;
}
</style>

View File

@@ -133,7 +133,7 @@ export default defineComponent({
v-model:open-keys={openKeys.value}
show-collapse-button={appStore.device !== 'mobile'}
auto-open={false}
selected-keys={selectedKey.value}
selectedKeys={selectedKey.value}
auto-open-selected={true}
level-indent={34}
style="height: 100%;width:100%;"

View File

@@ -31,10 +31,13 @@
<a-table :data="list" :loading="loading" :pagination="false" row-key="identity">
<template #columns>
<a-table-column title="ID" data-index="id" :width="80" />
<a-table-column title="唯一标识" data-index="identity" :width="280" ellipsis tooltip />
<a-table-column title="唯一标识" :width="150">
<template #cell="{ record }"><IdentityText :value="String(record.identity)" /></template>
</a-table-column>
<a-table-column v-for="field in displayFields" :key="field.key" :title="field.label" :width="columnWidth(field)" ellipsis tooltip>
<template #cell="{ record }">
{{ displayFieldValue(field, record) }}
<IdentityText v-if="field.type === 'identity' && identityFieldValue(field, record)" :value="identityFieldValue(field, record)" />
<template v-else>{{ displayFieldValue(field, record) }}</template>
</template>
</a-table-column>
<a-table-column v-if="definition.accountManagement" title="账户数" :width="90">
@@ -96,10 +99,10 @@
<a-table :data="accountList" :loading="accountLoading" :pagination="false" row-key="identity">
<template #columns>
<a-table-column title="ID" data-index="id" :width="80" />
<a-table-column title="唯一标识" data-index="identity" :width="280" ellipsis tooltip />
<a-table-column title="用户名" data-index="username" :width="160" />
<a-table-column title="显示名称" data-index="display_name" :width="180" />
<a-table-column title="角色编码" data-index="role_code" :width="140" />
<a-table-column title="唯一标识" :width="150"><template #cell="{ record }"><IdentityText :value="String(record.identity)" /></template></a-table-column>
<a-table-column title="用户名" data-index="username" :width="130" ellipsis tooltip />
<a-table-column title="显示名称" data-index="display_name" :width="130" ellipsis tooltip />
<a-table-column title="角色编码" data-index="role_code" :width="100" ellipsis tooltip />
<a-table-column title="状态" :width="90">
<template #cell="{ record }">
<a-tag :color="Number(record.status) === 1 ? 'green' : 'red'">
@@ -107,7 +110,7 @@
</a-tag>
</template>
</a-table-column>
<a-table-column title="操作" :width="240">
<a-table-column title="操作" :width="210">
<template #cell="{ record }">
<a-space>
<a-button size="mini" @click="openAccountEdit(record)">编辑</a-button>
@@ -196,33 +199,22 @@
<a-switch
:model-value="Number(detail.status) === 1"
:loading="gasStatusSaving"
:disabled="![1, 2].includes(Number(detail.status))"
:disabled="![0, 1, 2].includes(Number(detail.status))"
checked-text="启用"
unchecked-text="停用"
@change="updateGasStatus"
/>
</template>
</div>
<div v-if="definition.name === 'gas_basic' && canChangeStatus && Number(detail.status) === 0" class="review-panel">
<div class="review-title">气站审核</div>
<a-space direction="vertical" fill>
<a-button type="primary" :loading="gasReviewSaving" @click="reviewGasStation(true)">审核通过</a-button>
<a-textarea
v-model="gasRejectReason"
:max-length="2000"
show-word-limit
placeholder="审核不通过时,请填写理由"
:auto-size="{ minRows: 2, maxRows: 5 }"
/>
<a-button status="danger" :loading="gasReviewSaving" @click="reviewGasStation(false)">审核不通过</a-button>
</a-space>
</div>
<a-tabs v-if="detailCollections.length" class="detail-collections">
<a-tab-pane v-for="collection in detailCollections" :key="collection.key" :title="collection.title">
<a-table :data="collection.rows" :pagination="false" size="small">
<template #columns>
<a-table-column v-for="column in collection.columns" :key="column" :title="fieldLabel(column)">
<template #cell="{ record }">{{ displayValue(column, record[column]) }}</template>
<template #cell="{ record }">
<IdentityText v-if="column.includes('identity') && record[column]" :value="String(record[column])" />
<template v-else>{{ displayValue(column, record[column]) }}</template>
</template>
</a-table-column>
</template>
</a-table>
@@ -274,6 +266,7 @@ import type {
ResourceUiDefinition,
} from '@/api/resources';
import { useUserStore } from '@/store';
import IdentityText from '@/components/IdentityText.vue';
type Row = Record<string, unknown>;
const props = defineProps<{ definition: ResourceUiDefinition }>();
@@ -301,8 +294,6 @@ const accountSaving = ref(false);
const accountEditingIdentity = ref('');
const accountForm = reactive<Record<string, any>>({});
const gasStatusSaving = ref(false);
const gasReviewSaving = ref(false);
const gasRejectReason = ref('');
const walletByOwner = ref<Record<string, Row>>({});
const filters = reactive({
keyword: typeof route.query.keyword === 'string' ? route.query.keyword : '',
@@ -785,7 +776,6 @@ async function openDetail(row: Row) {
props.definition.resource,
String(row.identity),
);
if (props.definition.name === 'gas_basic') gasRejectReason.value = '';
detailVisible.value = true;
} catch (error) {
Message.error((error as Error).message);
@@ -812,30 +802,6 @@ async function updateGasStatus(enabled: string | number | boolean) {
}
}
async function reviewGasStation(approved: boolean) {
const identity = String(detail.value.identity ?? '');
const reason = gasRejectReason.value.trim();
if (!identity) return;
if (!approved && !reason) {
Message.warning('请填写审核不通过理由');
return;
}
gasReviewSaving.value = true;
try {
await resourceApi.action(
`${props.definition.resource}/${identity}/review`,
'POST',
{ approved, reason },
);
Message.success(approved ? '审核已通过' : '审核已拒绝');
await Promise.all([openDetail({ identity }), load()]);
} catch (error) {
Message.error((error as Error).message);
} finally {
gasReviewSaving.value = false;
}
}
async function openDetailAction(action: DetailAction) {
activeAction.value = action;
for (const field of action.fields ?? []) actionForm[field.key] = undefined;
@@ -1133,6 +1099,10 @@ function optionLabel(option: Row) {
return String(option.name ?? option.title ?? option.code ?? option.username ?? option.contract_no ?? option.order_no ?? option.identity);
}
function identityFieldValue(field: ResourceField, row: Row) {
return String(row[field.key] ?? row[`${field.key}_masked`] ?? '');
}
function columnWidth(field: ResourceField) {
if (field.key === 'identity') return 280;
if (field.type === 'datetime' || field.type === 'date') return 180;
@@ -1198,16 +1168,6 @@ function columnWidth(field: ResourceField) {
margin-left: auto;
color: var(--color-text-2);
}
.review-panel {
margin-top: 12px;
padding: 16px;
background: var(--color-fill-1);
border-radius: 4px;
}
.review-title {
margin-bottom: 12px;
font-weight: 500;
}
.muted-text {
color: var(--color-text-3);
}

View File

@@ -10,8 +10,13 @@
<a-table :data="list" :loading="loading" :pagination="false" row-key="identity">
<template #columns>
<a-table-column title="ID" data-index="id" :width="80" />
<a-table-column title="唯一标识" data-index="identity" :width="280" ellipsis tooltip />
<a-table-column v-for="field in displayFields" :key="field.key" :title="field.label" :data-index="field.key" :width="columnWidth(field)" ellipsis tooltip />
<a-table-column title="唯一标识" :width="150"><template #cell="{ record }"><IdentityText :value="String(record.identity)" /></template></a-table-column>
<a-table-column v-for="field in displayFields" :key="field.key" :title="field.label" :width="columnWidth(field)" ellipsis tooltip>
<template #cell="{ record }">
<IdentityText v-if="field.type === 'identity' && record[field.key]" :value="String(record[field.key])" />
<template v-else>{{ record[field.key] }}</template>
</template>
</a-table-column>
<a-table-column title="操作" :width="90"><template #cell="{ record }"><a-button size="mini" @click="openDetail(record)">详情</a-button></template></a-table-column>
</template>
</a-table>
@@ -39,6 +44,7 @@ import { computed, onMounted, reactive, ref } from 'vue';
import { resourceApi } from '@/api/resource';
import { buildResourcePayload, isMissingField } from '@/api/resource-form';
import type { DetailAction, ResourceField, ResourceUiDefinition } from '@/api/resources';
import IdentityText from '@/components/IdentityText.vue';
type Row = Record<string, unknown>;
const props = defineProps<{ definition: ResourceUiDefinition }>();