Procházet zdrojové kódy

📦 审核员列表状态显示

快乐的梦鱼 před 1 týdnem
rodič
revize
1da8eecdd1

+ 27 - 0
src/api/inheritor/InheritorContent.ts

@@ -485,6 +485,25 @@ export class InheritorAccountInfo extends DataModel<InheritorAccountInfo> {
   password = '' as string;
   nickname = '' as string;
 }
+export class InheritorSubmitInfo extends DataModel<InheritorSubmitInfo> {
+  constructor() {
+    super(InheritorSubmitInfo, "传承人采集数据信息");
+    this.setNameMapperCase('Camel', 'Snake');
+    this._convertTable = {
+      progress: { clientSide: 'number', serverSide: 'undefined' },
+    };
+  }
+
+  id = 0 as number;
+  title = '' as string;
+  userId = 0 as number;
+  nickname = '' as string;
+  logintime = '' as string;
+  updatedAt = '' as string;
+  collectTotal = 0 as number;
+  progress = 0 as number;
+}
+
 
 export class InheritorContentApi extends AppServerRequestModule<DataModel> {
 
@@ -544,6 +563,14 @@ export class InheritorContentApi extends AppServerRequestModule<DataModel> {
       return transformDataModel(InheritorAccountInfo, arr[0]);
     })
   }
+  async getInheritorSubmtList(modelId: number) {
+    return this.post('/ich/inheritor/list', {
+      model_id: modelId
+    }, '获取传承人采集数据列表', undefined).then((res) => {
+      return transformArrayDataModel<InheritorSubmitInfo>(InheritorSubmitInfo, transformSomeToArray(res.data2), 'data2');
+    })
+  }
+  
 
   async getIchInfo(id: number|undefined) {
     return await this.getBaseInfo(id, IchInfo);

+ 1 - 1
src/components/content/CommonListBlock.vue

@@ -33,7 +33,7 @@
             style="max-width: 150px"
             @update:selectedValue="(v) => handleChangeDropDownValue(k, v)"
           />
-          <SimpleInput v-if="showSearch" v-model="searchText" placeholder="请输入关键词" @enter="handleSearch">
+          <SimpleInput v-if="showSearch" v-model="searchText" placeholder="请输入关键词" @search="handleSearch">
             <template #suffix>
               <IconSearch
                 class="search-icon"

+ 9 - 53
src/composeable/SimpleDataLoader.ts

@@ -3,6 +3,7 @@ import type { ILoaderCommon, LoaderLoadType } from "./LoaderCommon";
 
 export interface ISimpleDataLoader<T, P> extends ILoaderCommon<P> {
   content: Ref<T|null>;
+  currentPromise: Ref<Promise<any>|null>;
   getLastParams: () => P | undefined;
 }
 
@@ -16,10 +17,11 @@ export function useSimpleDataLoader<T, P = any>(
   const content = ref<T|null>(null) as Ref<T|null>;
   const loadStatus = ref<LoaderLoadType>('loading');
   const loadError = ref('');
+  const currentPromise = ref<Promise<any>|null>(null);
 
   let lastParams: P | undefined;
 
-  async function loadData(params?: P) {
+  async function _loadData(params?: P) {
     if (params)
       lastParams = params;
     loadStatus.value = 'loading';
@@ -39,6 +41,11 @@ export function useSimpleDataLoader<T, P = any>(
     }
   }
 
+  function loadData(params?: P) {
+    currentPromise.value = _loadData(params);
+    return currentPromise.value;
+  }
+
   onMounted(() => {
     if (loadWhenMounted) {
       setTimeout(() => {
@@ -51,58 +58,7 @@ export function useSimpleDataLoader<T, P = any>(
     content,
     loadStatus,
     loadError,
-    loadData,
-    getLastParams: () => lastParams,
-  }
-}
-
-export async function useSSrSimpleDataLoader<T, P = any>(
-  name: string,
-  loader: (params?: P) => Promise<T>,
-  params : P|undefined = undefined,
-  emptyIfArrayEmpty = true,
-)  : Promise<ISimpleDataLoader<T, P>>
- {
-  const route = useRoute();
-
-  let lastParams: P | undefined = params;
-  const loadStatus = ref<LoaderLoadType>('finished');
-  const loadError = ref('');
-  const { data: content, error } = (await useAsyncData(route.fullPath + '/' + name, () => loader(lastParams)))
-
-
-  async function loadData(params?: P, refresh: boolean = false) {
-    if (!import.meta.client)
-      return;
-    if (params)
-      lastParams = params;
-    loadStatus.value = 'loading';
-    try {
-      const res = await loader(params ?? lastParams) as T;
-      content.value = res as any;
-      if (Array.isArray(res) && emptyIfArrayEmpty && (res as any[]).length === 0)
-        loadStatus.value = 'nomore';
-      else
-        loadStatus.value = 'finished';
-      loadError.value = '';
-    } catch(e) {
-      loadError.value = '' + e;
-      loadStatus.value = 'error';
-      console.log(e);
-    }
-  }
-
-  watch(error, (e) => {
-    if (e) {
-      loadError.value = '' + e;
-      loadStatus.value = 'error';
-    }
-  }, { immediate: true });
-  
-  return {
-    content: content as Ref<T|null>,
-    loadStatus,
-    loadError,
+    currentPromise,
     loadData,
     getLastParams: () => lastParams,
   }

+ 23 - 8
src/pages/admin.vue

@@ -36,6 +36,7 @@
                 :showDetail="(item) => router.push({ name: 'FormInheritor', query: { id: item.id } })"
               >
                 <template #itemRight="{ item }">
+                  <AdminItemState :item="item" />
                   <a-button type="link">编辑</a-button>
                   <a-button type="link" @click.stop="handleCopyAccount(item)">传承人账号</a-button>
                 </template>
@@ -67,6 +68,7 @@
                 :showDetail="(item) => router.push({ name: 'FormIch', query: { id: item.id } })"
                >
                 <template #itemRight="{ item }">
+                  <AdminItemState :item="item" />
                   <a-button type="link" @click.stop="router.push({ name: 'FormIch', query: { id: item.id } })">编辑</a-button>
                 </template>
               </CommonListBlock>
@@ -91,6 +93,7 @@ import CommonListBlock from '@/components/content/CommonListBlock.vue';
 import type { GetContentListItem } from '@/api/CommonContent';
 import InheritorContent from '@/api/inheritor/InheritorContent';
 import { message, Modal } from 'ant-design-vue';
+import AdminItemState from './components/AdminItemState.vue';
 
 const { toClipboard } = useClipboard();
 const router = useRouter();
@@ -116,6 +119,7 @@ const categoryData = useSimpleDataLoader(async () => {
 })
 
 async function loadInheritorData(page: number, pageSize: number, dropDownValues: number[], searchText: string) {
+  const submitList = await InheritorContent.getInheritorSubmtList(7);
   const res = await CommonContent.getContentList(
     new GetContentListParams()
       .setModelId(7)
@@ -131,13 +135,19 @@ async function loadInheritorData(page: number, pageSize: number, dropDownValues:
   return {
     page,
     total: res.total,
-    data: res.list.map((item) => ({
-      ...item,
-      desc: `${item.ichName} ${item.levelText} ${item.batchText}`
-    })),
+    data: res.list.map((item) => {
+      const submitInfo = submitList.find((item2) => item2.id == item.id);
+      return {
+        ...item,
+        desc: `${item.ichName} ${item.levelText} ${item.batchText}`,
+        hasSubmit: Boolean(submitInfo),
+        ...submitInfo,
+      }
+    }),
   }
 }
 async function loadIchData(page: number, pageSize: number, dropDownValues: number[], searchText: string) {
+  const submitList = await InheritorContent.getInheritorSubmtList(2);
   const res = await CommonContent.getContentList(
     new GetContentListParams()
       .setModelId(2)
@@ -152,10 +162,15 @@ async function loadIchData(page: number, pageSize: number, dropDownValues: numbe
   return {
     page,
     total: res.total,
-    data: res.list.map((item) => ({
-      ...item,
-      desc: `${item.ichTypeText} - ${item.levelText} ${item.batchText}`
-    })),
+    data: res.list.map((item) => {
+      const submitInfo = submitList.find((item2) => item2.id == item.id);
+      return {
+        ...item,
+        desc: `${item.ichTypeText} - ${item.levelText} ${item.batchText}`,
+        hasSubmit: Boolean(submitInfo),
+        ...submitInfo,
+      }
+    }),
   }
 }
 

+ 30 - 0
src/pages/components/AdminItemState.vue

@@ -0,0 +1,30 @@
+<template>
+  <div class="d-flex flex-row align-items-center gap-3">
+
+    <div class="d-flex flex-column">
+      <a-badge v-if="item.progress === 0" status="error" text="待审核" />
+      <a-badge v-else-if="item.progress === 1" status="processing" text="初审" />
+      <a-badge v-else-if="item.progress === 2" status="warning" text="专家审核" />
+      <a-badge v-else-if="item.progress === 3" status="success" text="审核通过" />
+
+      <span v-if="item.logintime" class="text-secondary">传承人上次登录:{{ item.logintime }}</span>
+      <span v-if="item.updatedAt" class="text-secondary">上次更新时间:{{ item.updatedAt }}</span>
+      <span v-if="item.collectTotal" class="text-secondary">采集版本总数:{{ item.collectTotal }}</span>
+    </div>
+
+    <a-tag v-if="!item.hasSubmit" color="#ff4d4f">未提交</a-tag>
+    <a-tag v-else color="#409e11">已提交</a-tag>
+  </div>
+</template>
+
+<script setup lang="ts">
+import { ref } from 'vue';
+import type { GetContentListItem } from '@/api/CommonContent';
+
+const props = defineProps({
+  item: {
+    type: Object as () => GetContentListItem,
+    required: true,
+  },
+})
+</script>

+ 0 - 1
src/pages/forms/ich.vue

@@ -259,7 +259,6 @@ const formOptions = ref<IDynamicFormOptions>({
     level: [{ required: true, message: '请选择级别' }],
     ichType: [{ required: true, message: '请选择非遗类型' }],
     batch: [{ required: true, message: '请输入批次' }],
-    progress: [{ required: true, message: '请选择初审状态' }],
   }
 });
 

+ 0 - 1
src/pages/forms/inheritor.vue

@@ -266,7 +266,6 @@ const formOptions = ref<IDynamicFormOptions>({
     level: [{ required: true, message: '请选择级别' }],
     batch: [{ required: true, message: '请输入批次' }],
     ichType: [{ required: true, message: '请选择非遗类型' }],
-    progress: [{ required: true, message: '请选择初审状态' }],
   }
 });