Sfoglia il codice sorgente

💊 按要求增加审核层级

快乐的梦鱼 1 mese fa
parent
commit
60b7b2cfc7

+ 15 - 0
src/api/auth/UserApi.ts

@@ -64,12 +64,27 @@ export class UserInfo extends DataModel<UserInfo> {
       userId: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
       mainBodyId: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
       loginTime: { clientSide: 'date', serverSide: 'string' },
+      adminGroup: {
+        customToClientFn: (data: any) => {
+          const adminGroup = [] as { id: number, name: string }[];
+          for (const key in data) {
+            if (data[key])
+              adminGroup.push({ 
+              id: data[key].group_id as number, 
+              name: data[key].name as string 
+            });
+          }
+          console.log(data, adminGroup);
+          return adminGroup;
+        },
+      },
     }
   }
 
   id = 0;
   userId = 0;
   mainBodyId = 0;
+  adminGroup = [] as { id: number, name: string }[];
   nickname = '';
   avatar = '';
   intro = '';

+ 66 - 39
src/pages/collect/assessment/evaluation-form-review.vue

@@ -12,10 +12,10 @@
           <FlexCol v-else gap="gap.lg">
             <Alert type="info" :message="progressHint" />
             <SelfAssessmentFormDisplay
-              :current-form="currentForm"
+              :current-form="(currentForm as SelfAssessmentDetail)"
               :form-options="formOptions"
-              :check-item-list="checkItemList"
-              :current-form-check-items="currentFormCheckItems"
+              :check-item-list="(checkItemList as CheckItemInfo[])"
+              :current-form-check-items="(currentFormCheckItems as SelfAssessmentCheckItemAnswer[])"
               :readonly="true"
             />
             <Divider />
@@ -35,6 +35,12 @@
             </FlexCol>
             <Divider />
             <H3>审核提交</H3>
+            <Alert
+              v-if="!canSubmitReview"
+              type="warning"
+              message="当前账号用户组无权在此环节审核"
+              description="仅项目保护单位(9)、县(区)文旅部门(5)、设区市文旅部门/省非遗中心(10)、省文化和旅游厅(11) 可提交。"
+            />
             <FlexCol gap="gap.md">
               <Text bold :text="`审核环节:${reviewLevelLabel}`" />
               <Text fontConfig="subText" text="审核意见(必选)" />
@@ -58,18 +64,14 @@
                 @update:model-value="reviewPoints = $event"
               />
               <Text fontConfig="subText" text="提交后进度" />
-              <FlexRow wrap gap="gap.sm">
-                <Button
-                  v-for="o in progressSubmitOptions"
-                  :key="o.value"
-                  :type="submitProgress === o.value ? 'primary' : 'default'"
-                  size="small"
-                  @click="submitProgress = o.value"
-                >
-                  {{ o.label }}
-                </Button>
-              </FlexRow>
-              <Button type="primary" block :loading="submitLoading" @click="submitReview">
+              <Text :text="progressSubmitLabel" />
+              <Button
+                type="primary"
+                block
+                :loading="submitLoading"
+                :touchable="canSubmitReview"
+                @click="submitReview"
+              >
                 提交审核
               </Button>
             </FlexCol>
@@ -108,10 +110,14 @@ import Stepper from '@/components/form/Stepper.vue';
 import Alert from '@/components/feedback/Alert.vue';
 import XBarSpace from '@/components/layout/space/XBarSpace.vue';
 import { useLoadQuerys } from '@/components/composeabe/LoadQuerys';
+import { useAuthStore } from '@/store/auth';
 
 const signUploadCo = useImageSimpleUploadCo();
 const formOptions = buildSelfAssessmentFormOptions(signUploadCo);
 
+const authStore = useAuthStore();
+const currentUserGroups = computed(() => authStore.userInfo?.adminGroup || []);
+
 const currentForm = ref<SelfAssessmentDetail | null>(null);
 const currentFormCheckItems = ref<SelfAssessmentCheckItemAnswer[]>([]);
 const checkItemList = ref<CheckItemInfo[]>([]);
@@ -120,7 +126,21 @@ const annexLinks = ref<{ id: number; name: string; url: string }[]>([]);
 const submitLoading = ref(false);
 const reviewOpinion = ref<number | null>(null);
 const reviewPoints = ref<number | null>(null);
-const submitProgress = ref(2);
+
+/** 用户组 → 本环节提交后的 progress */
+const GROUP_TO_REVIEW_PROGRESS: Record<number, number> = {
+  9: 2, // 项目保护单位
+  5: 3, // 县(区)文旅部门
+  10: 4, // 设区市文旅部门、省非遗中心
+  11: 5, // 省文化和旅游厅
+};
+
+const PROGRESS_SUBMIT_LABELS: Record<number, string> = {
+  2: '2 — 项目保护单位审核完成',
+  3: '3 — 县(区)文旅部门审核完成',
+  4: '4 — 设区市文旅部门、省非遗中心审核完成',
+  5: '5 — 省文化和旅游厅审核完成',
+};
 
 const opinionSelectOptions = [
   { label: '优秀', value: 1 },
@@ -130,12 +150,20 @@ const opinionSelectOptions = [
   { label: '取消资格', value: 5 },
 ];
 
-const progressSubmitOptions = [
-  { label: '2 保护单位完成', value: 2 },
-  { label: '3 县区完成', value: 3 },
-  { label: '4 市/省中心完成', value: 4 },
-  { label: '5 省厅完成', value: 5 },
-];
+const reviewProgress = computed(() => {
+  const currentUserGroup = currentUserGroups.value.find(
+    (group) => GROUP_TO_REVIEW_PROGRESS[group.id],
+  );
+  return GROUP_TO_REVIEW_PROGRESS[currentUserGroup?.id ?? 0] ?? 0;
+});
+
+const canSubmitReview = computed(
+  () => reviewProgress.value >= 2 && reviewProgress.value <= 5,
+);
+
+const progressSubmitLabel = computed(
+  () => PROGRESS_SUBMIT_LABELS[reviewProgress.value] ?? '—',
+);
 
 const { querys } = useLoadQuerys({
   id: 0,
@@ -150,17 +178,8 @@ const listProgress = computed(() => {
   return Number.isFinite(p) ? p : Number.NaN;
 });
 
-const targetProgressDefault = computed(() => {
-  const p = listProgress.value;
-  if (!Number.isFinite(p) || p < 1)
-    return 2;
-  if (p >= 5)
-    return 5;
-  return p + 1;
-});
-
 const reviewLevelLabel = computed(() => {
-  switch (submitProgress.value) {
+  switch (reviewProgress.value) {
     case 2:
       return '项目保护单位';
     case 3:
@@ -178,8 +197,11 @@ const progressHint = computed(() => {
   const id = querys.value.id;
   const uid = querys.value.userId;
   const lp = listProgress.value;
-  const lpText = Number.isFinite(lp) ? `列表进度:${lp}` : '未传列表进度,已按默认环节';
-  return `自查表 ${id},传承人用户 ${uid}。${lpText}。提交后进度:${submitProgress.value}。`;
+  const lpText = Number.isFinite(lp) ? `列表进度:${lp}` : '未传列表进度参数';
+  const roleText = canSubmitReview.value
+    ? `当前账号审核环节:${reviewLevelLabel.value}(提交后 progress=${reviewProgress.value})`
+    : `当前用户组 ${currentUserGroups.value.map((group) => group.name).join('、') || '—'} 无对应审核环节`;
+  return `自查表 ${id},传承人用户 ${uid}。${lpText}。${roleText}。`;
 });
 
 const currentYear = new Date().getFullYear();
@@ -217,7 +239,9 @@ async function loadAnnexLinks(formId: number) {
 }
 
 function applyPrefillFromDetail(f: SelfAssessmentDetail) {
-  const t = submitProgress.value;
+  const t = reviewProgress.value;
+  if (!canSubmitReview.value)
+    return;
   if (t === 2) {
     reviewOpinion.value = f.ichUnit ?? null;
     reviewPoints.value = f.unitPoints || null;
@@ -257,15 +281,14 @@ const loader = useSimpleDataLoader(async () => {
     await loadAnnexLinks(detail.id);
   else
     annexLinks.value = [];
-  submitProgress.value = targetProgressDefault.value;
   applyPrefillFromDetail(detail);
   return detail;
 }, false);
 
-watch(submitProgress, () => {
+watch(reviewProgress, () => {
   const f = currentForm.value;
   if (f)
-    applyPrefillFromDetail(f);
+    applyPrefillFromDetail(f as SelfAssessmentDetail);
 });
 
 async function submitReview() {
@@ -274,11 +297,15 @@ async function submitReview() {
     toast('缺少自查表 ID');
     return;
   }
+  if (!canSubmitReview.value) {
+    toast('当前账号用户组无权提交审核');
+    return;
+  }
   if (reviewOpinion.value == null) {
     toast('请选择审核意见');
     return;
   }
-  const t = submitProgress.value;
+  const t = reviewProgress.value;
   const base = { id: f.id, progress: t };
   const points = reviewPoints.value != null && reviewPoints.value >= 0 ? reviewPoints.value : undefined;
   const op = reviewOpinion.value;