fix(admin): standardize resource initialization and lists
This commit is contained in:
@@ -31,8 +31,9 @@
|
||||
</a-form>
|
||||
<a-table :data="list" :loading="loading" :pagination="false" row-key="identity">
|
||||
<template #columns>
|
||||
<a-table-column title="ID" data-index="id" :width="100" />
|
||||
<a-table-column v-for="field in displayFields" :key="field.key" :title="field.label" ellipsis tooltip>
|
||||
<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" :width="columnWidth(field)" ellipsis tooltip>
|
||||
<template #cell="{ record }">
|
||||
{{ displayFieldValue(field, record) }}
|
||||
</template>
|
||||
@@ -95,9 +96,11 @@
|
||||
</div>
|
||||
<a-table :data="accountList" :loading="accountLoading" :pagination="false" row-key="identity">
|
||||
<template #columns>
|
||||
<a-table-column title="用户名" data-index="username" />
|
||||
<a-table-column title="显示名称" data-index="display_name" />
|
||||
<a-table-column title="角色编码" data-index="role_code" />
|
||||
<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">
|
||||
<template #cell="{ record }">
|
||||
<a-tag :color="Number(record.status) === 1 ? 'green' : 'red'">
|
||||
@@ -282,7 +285,7 @@ const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const actionSubmitting = ref(false);
|
||||
const page = ref(Math.max(1, Number(route.query.page) || 1));
|
||||
const pageSize = 20;
|
||||
const pageSize = 50;
|
||||
const total = ref(0);
|
||||
const list = ref<Row[]>([]);
|
||||
const accountCounts = ref<Record<string, number>>({});
|
||||
@@ -292,7 +295,7 @@ const accountLoading = ref(false);
|
||||
const accountList = ref<Row[]>([]);
|
||||
const accountOwner = ref<Row>({});
|
||||
const accountPage = ref(1);
|
||||
const accountPageSize = 10;
|
||||
const accountPageSize = 50;
|
||||
const accountTotal = ref(0);
|
||||
const accountFormVisible = ref(false);
|
||||
const accountSaving = ref(false);
|
||||
@@ -362,6 +365,7 @@ const formMode = computed<'create' | 'edit'>(() =>
|
||||
const formFields = computed(() =>
|
||||
props.definition.fields.filter(
|
||||
(field) =>
|
||||
field.key !== 'identity' &&
|
||||
(formMode.value === 'create' || field.type !== 'password') &&
|
||||
!(
|
||||
formMode.value === 'edit' &&
|
||||
@@ -375,6 +379,7 @@ const displayFields = computed(() =>
|
||||
props.definition.fields
|
||||
.filter(
|
||||
(field) =>
|
||||
field.key !== 'identity' &&
|
||||
field.key !== 'password' &&
|
||||
!(
|
||||
props.definition.name === 'gas_basic' &&
|
||||
@@ -1128,12 +1133,26 @@ watch(
|
||||
function optionLabel(option: Row) {
|
||||
return String(option.name ?? option.title ?? option.code ?? option.username ?? option.contract_no ?? option.order_no ?? option.identity);
|
||||
}
|
||||
|
||||
function columnWidth(field: ResourceField) {
|
||||
if (field.key === 'identity') return 280;
|
||||
if (field.type === 'datetime' || field.type === 'date') return 180;
|
||||
if (field.type === 'money' || field.type === 'number') return 140;
|
||||
if (field.type === 'boolean') return 110;
|
||||
if (field.type === 'select') return 140;
|
||||
if (field.type === 'identity' || field.type === 'identity-list') return 240;
|
||||
if (field.type === 'textarea') return 280;
|
||||
if (field.key.includes('phone')) return 150;
|
||||
if (/(name|title|address|content|remark|reason|terms)$/.test(field.key)) return 220;
|
||||
return 180;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.filters {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.workflow-alert,
|
||||
.action-alert {
|
||||
margin-bottom: 16px;
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
</a-form>
|
||||
<a-table :data="list" :loading="loading" :pagination="false" row-key="identity">
|
||||
<template #columns>
|
||||
<a-table-column title="业务标识" data-index="identity" :width="220" ellipsis tooltip />
|
||||
<a-table-column v-for="field in displayFields" :key="field.key" :title="field.label" :data-index="field.key" ellipsis tooltip />
|
||||
<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="90"><template #cell="{ record }"><a-button size="mini" @click="openDetail(record)">详情</a-button></template></a-table-column>
|
||||
</template>
|
||||
</a-table>
|
||||
@@ -35,13 +36,13 @@ import { Message } from '@arco-design/web-vue';
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { resourceApi } from '@/api/resource';
|
||||
import { buildResourcePayload, isMissingField } from '@/api/resource-form';
|
||||
import type { DetailAction, ResourceUiDefinition } from '@/api/resources';
|
||||
import type { DetailAction, ResourceField, ResourceUiDefinition } from '@/api/resources';
|
||||
|
||||
type Row = Record<string, unknown>;
|
||||
const props = defineProps<{ definition: ResourceUiDefinition }>();
|
||||
const loading = ref(false);
|
||||
const page = ref(1);
|
||||
const pageSize = 20;
|
||||
const pageSize = 50;
|
||||
const total = ref(0);
|
||||
const list = ref<Row[]>([]);
|
||||
const filters = reactive({ keyword: '' });
|
||||
@@ -51,8 +52,20 @@ const actionVisible = ref(false);
|
||||
const activeAction = ref<DetailAction>();
|
||||
const actionForm = reactive<Record<string, any>>({});
|
||||
const displayFields = computed(() =>
|
||||
props.definition.fields.filter((field) => field.key !== 'status'),
|
||||
props.definition.fields.filter((field) => field.key !== 'identity' && field.key !== 'status'),
|
||||
);
|
||||
|
||||
function columnWidth(field: ResourceField) {
|
||||
if (field.type === 'datetime' || field.type === 'date') return 180;
|
||||
if (field.type === 'money' || field.type === 'number') return 140;
|
||||
if (field.type === 'boolean') return 110;
|
||||
if (field.type === 'select') return 140;
|
||||
if (field.type === 'identity' || field.type === 'identity-list') return 240;
|
||||
if (field.type === 'textarea') return 280;
|
||||
if (field.key.includes('phone')) return 150;
|
||||
if (/(name|title|address|content|remark|reason|terms)$/.test(field.key)) return 220;
|
||||
return 180;
|
||||
}
|
||||
const detailEntries = computed(() =>
|
||||
Object.entries(detail.value).filter(
|
||||
([key]) => key !== 'id' && !key.endsWith('_id'),
|
||||
|
||||
Reference in New Issue
Block a user