瀏覽代碼

feat: 用户新增编辑不能选全部

chenhao 2 年之前
父節點
當前提交
93e882e9cc
共有 3 個文件被更改,包括 9 次插入12 次删除
  1. 5 5
      src/hooks/useOptions.ts
  2. 1 1
      src/modules/admin-data/export/index.vue
  3. 3 6
      src/modules/analysis/monitoring/index.vue

+ 5 - 5
src/hooks/useOptions.ts

@@ -93,20 +93,20 @@ const useOptions = (
   })
 
   const groupList = computed<Group[]>(() => {
-    const list =
+    return (
       groupListResult?.value?.map((n) => {
         return {
           value: n,
           label: `第${n}组`,
         }
       }) || []
-    return list?.length && (isAdmin.value || isChief.value)
-      ? [{ label: '全部', value: void 0 } as unknown as Group].concat(list)
-      : list
+    )
   })
 
   const groupListWithAll = computed(() => {
-    return groupList.value
+    return groupList.value?.length && (isAdmin.value || isChief.value)
+      ? [{ label: '全部', value: void 0 } as unknown as Group].concat(groupList.value)
+      : groupList.value
   })
 
   watch(

+ 1 - 1
src/modules/admin-data/export/index.vue

@@ -83,7 +83,7 @@ const columns: EpTableColumn[] = [
 ]
 
 function onSearch() {
-  Object.assign(requestModel, model)
+  Object.assign(requestModel, { ...model })
 }
 
 onOptionInit(onSearch)

+ 3 - 6
src/modules/analysis/monitoring/index.vue

@@ -75,11 +75,8 @@ import type { ExtractApiParams, ExtractApiResponse } from '@/api/api'
 
 const { push } = useRouter()
 
-const { subjectList, mainQuestionList, groupList, dataModel, changeModelValue, initFinish, onOptionInit } = useOptions([
-  'subject',
-  'question',
-  'group',
-])
+const { subjectList, mainQuestionList, groupListWithAll, dataModel, changeModelValue, initFinish, onOptionInit } =
+  useOptions(['subject', 'question', 'group'])
 
 const model = reactive<
   Omit<ExtractApiParams<'getStatistics'>, 'markingGroupNumbers'> & {
@@ -140,7 +137,7 @@ const formItems = computed<EpFormItem[]>(() => [
     slotType: 'select',
     prop: 'markingGroupNumbers',
     slot: {
-      options: groupList.value,
+      options: groupListWithAll.value,
       onChange: changeModelValue('group'),
     },
   },