浏览代码

org: PC 前端 institution 出参对齐后端 model.Institution

- InstitutionDTO 字段对齐 GORM 出参:id→institutionId、name→institutionName、
  creditCode→institutionCode(可选)、新增 address/phone(可选)、status 由 number(0/1)
  改为字符串枚举 'active'|'disabled'、补 updatedAt
- InstitutionFilter.status 由 number 改为 'active'|'disabled'
- list.vue 列 prop 改 institutionName/institutionCode,状态筛选值改字符串枚举
- formatStatus 入参 number→string,匹配 VARCHAR(16) status
- ListPage.vue 文档示例同步更新
Q 3 天之前
父节点
当前提交
c8d23a1327
共有 4 个文件被更改,包括 30 次插入 和 24 次删除
  1. 17 11
      src/api/org/institution.ts
  2. 3 3
      src/components/ListPage.vue
  3. 6 6
      src/utils/format.ts
  4. 4 4
      src/views/org/institution/list.vue

+ 17 - 11
src/api/org/institution.ts

@@ -14,26 +14,32 @@
 import { http } from '@/api/http';
 import type { PageR } from '@/types/api';
 
-/** 机构 DTO(字段与后端 org 域 Institution 出参逐字段对齐,camelCase) */
+/** 机构 DTO(字段与后端 org 域 model.Institution 出参逐字段对齐,camelCase;status 为字符串枚举) */
 export interface InstitutionDTO {
-  /** 机构 id(int,旧系统 school 概念归一) */
-  id: number;
+  /** 机构 id(int64 自增,主键;旧系统 school 概念归一,作用域根) */
+  institutionId: number;
   /** 机构名称 */
-  name: string;
-  /** 统一社会信用代码(可空 → 后端空串) */
-  creditCode: string;
-  /** 状态:1 启用 / 0 停用 */
-  status: number;
-  /** 创建时间(RFC3339,后端 BaseModel.CreatedAt) */
+  institutionName: string;
+  /** 机构编码(可空 → 后端 omitempty,可能缺省) */
+  institutionCode?: string;
+  /** 地址(可空 → omitempty,可能缺省) */
+  address?: string;
+  /** 电话(可空 → omitempty,可能缺省) */
+  phone?: string;
+  /** 状态:"active" 正常 / "disabled" 停用(VARCHAR(16),字符串枚举,非 0/1) */
+  status: 'active' | 'disabled';
+  /** 创建时间(RFC3339,后端 GORM CreatedAt) */
   createdAt: string;
+  /** 更新时间(RFC3339,后端 GORM UpdatedAt) */
+  updatedAt: string;
 }
 
 /** 机构列表筛选条件(作用域字段由 useScope().toQuery() 并入,见 README §3.3-4) */
 export interface InstitutionFilter {
   /** 机构名称模糊搜索(可空) */
   keyword?: string;
-  /** 状态筛选(可空 = 全部) */
-  status?: number;
+  /** 状态筛选(可空 = 全部;字符串枚举 "active"|"disabled",与后端 VARCHAR status 对齐) */
+  status?: 'active' | 'disabled';
 }
 
 /** 机构列表完整查询参数 = 作用域 + 筛选 + 分页(作用域缺失时后端返回 1004 越界拒绝) */

+ 3 - 3
src/components/ListPage.vue

@@ -21,9 +21,9 @@
  *     :loading="lp.loading"
  *     :error="lp.error"
  *     :columns="[
- *       { prop: 'name', label: '机构名称', minWidth: 200 },
- *       { prop: 'creditCode', label: '信用代码' },
- *       { prop: 'status', label: '状态', formatter: (row) => (row.status === 1 ? '启用' : '停用') },
+ *       { prop: 'institutionName', label: '机构名称', minWidth: 200 },
+ *       { prop: 'institutionCode', label: '机构编码' },
+ *       { prop: 'status', label: '状态', formatter: (row) => (row.status === 'active' ? '启用' : '停用') },
  *     ]"
  *   >
  *     <template #toolbar><el-input v-model="filters.keyword" placeholder="搜索机构名称" /></template>

+ 6 - 6
src/utils/format.ts

@@ -49,19 +49,19 @@ export function formatDateTime(iso: string): string {
 }
 
 /**
- * 状态码 → 中文文案(后端 status 枚举 1 启用 / 0 停用)。
+ * 状态码 → 中文文案(后端 status 字符串枚举 "active" 启用 / "disabled" 停用,org 域 VARCHAR(16))。
  *
  * 入参:
- *   - status number:状态码;未知值返回 '-'(不臆造文案)。
+ *   - status string:状态枚举;未知值返回 '-'(不臆造文案)。
  *
  * 出参:
  *   - string:"启用" / "停用" / "-"。
  *
  * 异常场景:
- *   - status 非 0/1:返回 '-'(后端字典变化时此处是唯一定点,便于全局排查)。
+ *   - status 非 "active"/"disabled":返回 '-'(后端字典变化时此处是唯一定点,便于全局排查)。
  */
-export function formatStatus(status: number): string {
-  if (status === 1) return '启用';
-  if (status === 0) return '停用';
+export function formatStatus(status: string): string {
+  if (status === 'active') return '启用';
+  if (status === 'disabled') return '停用';
   return '-';
 }

+ 4 - 4
src/views/org/institution/list.vue

@@ -35,8 +35,8 @@ const { rows, total, page, pageSize, loading, error, fetchList } = useListPage<I
 
 /** 列定义(数据驱动;formatter 返回字符串,README §3.3-6) */
 const columns: ListColumn<InstitutionDTO>[] = [
-  { prop: 'name', label: '机构名称', minWidth: 200 },
-  { prop: 'creditCode', label: '统一社会信用代码', minWidth: 200 },
+  { prop: 'institutionName', label: '机构名称', minWidth: 200 },
+  { prop: 'institutionCode', label: '机构编码', minWidth: 200 },
   { prop: 'status', label: '状态', formatter: (row) => formatStatus(row.status) },
   { prop: 'createdAt', label: '创建时间', formatter: (row) => formatDateTime(row.createdAt) },
 ];
@@ -68,8 +68,8 @@ onMounted(() => {
       <template #toolbar>
         <el-input v-model="filters.keyword" placeholder="搜索机构名称" clearable class="toolbar-input" />
         <el-select v-model="filters.status" placeholder="状态" clearable class="toolbar-select">
-          <el-option :value="1" label="启用" />
-          <el-option :value="0" label="停用" />
+          <el-option value="active" label="启用" />
+          <el-option value="disabled" label="停用" />
         </el-select>
       </template>
     </ListPage>