feat(platform): improve admin data workflows
This commit is contained in:
35
frontend/delivery_admin/src/components/IdentityText.vue
Normal file
35
frontend/delivery_admin/src/components/IdentityText.vue
Normal 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>
|
||||
@@ -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%;"
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 }>();
|
||||
|
||||
35
frontend/gas_admin/src/components/IdentityText.vue
Normal file
35
frontend/gas_admin/src/components/IdentityText.vue
Normal 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>
|
||||
@@ -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%;"
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 }>();
|
||||
|
||||
35
frontend/platform_admin/src/components/IdentityText.vue
Normal file
35
frontend/platform_admin/src/components/IdentityText.vue
Normal 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>
|
||||
@@ -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%;"
|
||||
|
||||
@@ -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">
|
||||
@@ -93,21 +96,21 @@
|
||||
<a-button @click="loadManagedAccounts">刷新</a-button>
|
||||
<a-button type="primary" @click="openAccountCreate">新建账户</a-button>
|
||||
</div>
|
||||
<a-table :data="accountList" :loading="accountLoading" :pagination="false" row-key="identity">
|
||||
<a-table :data="accountList" :loading="accountLoading" :pagination="false" row-key="identity" table-layout-fixed>
|
||||
<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="90">
|
||||
<a-table-column title="ID" data-index="id" :width="60" />
|
||||
<a-table-column title="唯一标识" :width="140"><template #cell="{ record }"><IdentityText :value="String(record.identity)" /></template></a-table-column>
|
||||
<a-table-column title="用户名" data-index="username" :width="115" ellipsis tooltip />
|
||||
<a-table-column title="显示名称" data-index="display_name" :width="115" ellipsis tooltip />
|
||||
<a-table-column title="角色编码" data-index="role_code" :width="90" ellipsis tooltip />
|
||||
<a-table-column title="状态" :width="75">
|
||||
<template #cell="{ record }">
|
||||
<a-tag :color="Number(record.status) === 1 ? 'green' : 'red'">
|
||||
{{ Number(record.status) === 1 ? '启用' : '停用' }}
|
||||
</a-tag>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column title="操作" :width="240">
|
||||
<a-table-column title="操作" :width="190">
|
||||
<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 : '',
|
||||
@@ -382,20 +373,44 @@ const displayFields = computed(() =>
|
||||
field.key !== 'password' &&
|
||||
!(
|
||||
props.definition.name === 'gas_basic' &&
|
||||
(field.key === 'longitude' || field.key === 'latitude')
|
||||
['credit_code', 'address', 'longitude', 'latitude'].includes(field.key)
|
||||
),
|
||||
)
|
||||
.slice(0, 6),
|
||||
);
|
||||
const detailEntries = computed(() => {
|
||||
const entries = Object.entries(detail.value).filter(
|
||||
([key, value]) =>
|
||||
key !== 'id' &&
|
||||
!(props.definition.name === 'gas_basic' && key === 'status') &&
|
||||
!key.endsWith('_id') &&
|
||||
!Array.isArray(value) &&
|
||||
!(value && typeof value === 'object' && key !== 'order' && key !== 'contract'),
|
||||
);
|
||||
const visibleEntry = ([key, value]: [string, unknown]) =>
|
||||
!key.endsWith('_id') &&
|
||||
!Array.isArray(value) &&
|
||||
!(
|
||||
value &&
|
||||
typeof value === 'object' &&
|
||||
key !== 'order' &&
|
||||
key !== 'contract' &&
|
||||
!['deleted_at', 'DeletedAt'].includes(key)
|
||||
) &&
|
||||
!(['deleted_at', 'DeletedAt'].includes(key) && isEmptyDeletedAt(value));
|
||||
let entries: Array<[string, unknown]>;
|
||||
if (props.definition.name === 'gas_basic') {
|
||||
const modelOrder = [
|
||||
'id', 'identity', 'created_at', 'updated_at', 'deleted_at', 'DeletedAt',
|
||||
'status', 'code', 'name', 'credit_code', 'principal', 'address', 'longitude', 'latitude',
|
||||
];
|
||||
const orderedKeys = new Set(modelOrder);
|
||||
entries = modelOrder
|
||||
.filter((key) => Object.prototype.hasOwnProperty.call(detail.value, key))
|
||||
.map((key) => [key, detail.value[key]] as [string, unknown])
|
||||
.filter(visibleEntry);
|
||||
entries.push(
|
||||
...Object.entries(detail.value)
|
||||
.filter(([key]) => !orderedKeys.has(key))
|
||||
.filter(visibleEntry),
|
||||
);
|
||||
} else {
|
||||
entries = Object.entries(detail.value).filter(
|
||||
([key, value]) => key !== 'id' && visibleEntry([key, value]),
|
||||
);
|
||||
}
|
||||
if (props.definition.walletOwnerType) {
|
||||
const wallet = walletByOwner.value[String(detail.value.identity ?? '')];
|
||||
entries.push(['wallet', wallet ? {
|
||||
@@ -407,6 +422,14 @@ const detailEntries = computed(() => {
|
||||
}
|
||||
return entries;
|
||||
});
|
||||
|
||||
function isEmptyDeletedAt(value: unknown) {
|
||||
if (value == null || value === '') return true;
|
||||
if (typeof value === 'object' && value && 'Valid' in value) {
|
||||
return !(value as { Valid?: boolean }).Valid;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const detailCollections = computed(() =>
|
||||
Object.entries(detail.value)
|
||||
.filter(([, value]) => Array.isArray(value) && value.length > 0)
|
||||
@@ -785,7 +808,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 +834,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;
|
||||
@@ -995,9 +993,13 @@ function formatValue(value: unknown) {
|
||||
|
||||
function fieldLabel(key: string) {
|
||||
const aliases: Record<string, string> = {
|
||||
identity: '标识',
|
||||
identity: '唯一标识',
|
||||
id: 'ID',
|
||||
created_at: '创建时间',
|
||||
updated_at: '更新时间',
|
||||
deleted_at: '删除时间',
|
||||
DeletedAt: '删除时间',
|
||||
status: '状态',
|
||||
version: '版本',
|
||||
items: '订单明细',
|
||||
assignments: '分配记录',
|
||||
@@ -1045,6 +1047,18 @@ function displayFieldValue(field: ResourceField, row: Row) {
|
||||
function displayValue(key: string, value: unknown) {
|
||||
if (value == null || value === '') return '-';
|
||||
if (typeof value === 'boolean') return value ? '是' : '否';
|
||||
if (
|
||||
['deleted_at', 'DeletedAt'].includes(key) &&
|
||||
typeof value === 'object' &&
|
||||
value &&
|
||||
'Time' in value
|
||||
) {
|
||||
const date = dayjs(String((value as { Time?: unknown }).Time ?? ''));
|
||||
return date.isValid() ? date.format('YYYY-MM-DD HH:mm:ss') : '-';
|
||||
}
|
||||
if (props.definition.name === 'gas_basic' && key === 'status') {
|
||||
return recordStatusLabel(Number(value));
|
||||
}
|
||||
if (
|
||||
key === 'amount' ||
|
||||
key.endsWith('_amount') ||
|
||||
@@ -1059,7 +1073,8 @@ function displayValue(key: string, value: unknown) {
|
||||
if (
|
||||
key.endsWith('_at') ||
|
||||
key === 'created_at' ||
|
||||
key === 'updated_at'
|
||||
key === 'updated_at' ||
|
||||
key === 'DeletedAt'
|
||||
) {
|
||||
const date = dayjs(String(value));
|
||||
return date.isValid() ? date.format('YYYY-MM-DD HH:mm:ss') : String(value);
|
||||
@@ -1133,6 +1148,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 +1217,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);
|
||||
}
|
||||
|
||||
@@ -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 }>();
|
||||
|
||||
Reference in New Issue
Block a user