Showing
1 changed file
with
16 additions
and
3 deletions
@@ -13,7 +13,9 @@ | @@ -13,7 +13,9 @@ | ||
13 | <BasicForm @register="registerForm"> | 13 | <BasicForm @register="registerForm"> |
14 | <template #importType="{ model }"> | 14 | <template #importType="{ model }"> |
15 | <RadioGroup v-model:value="model.importType"> | 15 | <RadioGroup v-model:value="model.importType"> |
16 | - <Radio value="2">JSON导入</Radio> | 16 | + <Authority :value="['api:yt:things_model:category:import', 'api:yt:things_model:import']"> |
17 | + <Radio value="2">JSON导入</Radio> | ||
18 | + </Authority> | ||
17 | <Authority :value="['api:yt:things_model:excel_import']"> | 19 | <Authority :value="['api:yt:things_model:excel_import']"> |
18 | <Radio value="1">Excel导入</Radio> | 20 | <Radio value="1">Excel导入</Radio> |
19 | </Authority> | 21 | </Authority> |
@@ -42,6 +44,7 @@ | @@ -42,6 +44,7 @@ | ||
42 | import { useLoading } from '/@/components/Loading'; | 44 | import { useLoading } from '/@/components/Loading'; |
43 | import { BasicForm, useForm } from '/@/components/Form'; | 45 | import { BasicForm, useForm } from '/@/components/Form'; |
44 | import { Authority } from '/@/components/Authority'; | 46 | import { Authority } from '/@/components/Authority'; |
47 | + import { usePermission } from '/@/hooks/web/usePermission'; | ||
45 | 48 | ||
46 | const emits = defineEmits(['register', 'handleImportCSV', 'handleReload']); | 49 | const emits = defineEmits(['register', 'handleImportCSV', 'handleReload']); |
47 | 50 | ||
@@ -67,14 +70,21 @@ | @@ -67,14 +70,21 @@ | ||
67 | ImportInfo.value = data; | 70 | ImportInfo.value = data; |
68 | }); | 71 | }); |
69 | 72 | ||
70 | - const [registerForm, {}] = useForm({ | 73 | + const { hasPermission } = usePermission(); |
74 | + | ||
75 | + const [registerForm, { validate }] = useForm({ | ||
71 | schemas: [ | 76 | schemas: [ |
72 | { | 77 | { |
73 | field: 'importType', | 78 | field: 'importType', |
74 | label: '导入类型', | 79 | label: '导入类型', |
75 | component: 'RadioGroup', | 80 | component: 'RadioGroup', |
76 | - defaultValue: '2', | ||
77 | slot: 'importType', | 81 | slot: 'importType', |
82 | + defaultValue: hasPermission([ | ||
83 | + 'api:yt:things_model:category:import', | ||
84 | + 'api:yt:things_model:import', | ||
85 | + ]) | ||
86 | + ? '2' | ||
87 | + : '1', | ||
78 | helpMessage: | 88 | helpMessage: |
79 | 'JSON导入请使用从物模型TSL导出的JSON文件在进行导入,Excel导入请使用下载的模板编辑之后在进行导入', | 89 | 'JSON导入请使用从物模型TSL导出的JSON文件在进行导入,Excel导入请使用下载的模板编辑之后在进行导入', |
80 | required: true, | 90 | required: true, |
@@ -83,6 +93,7 @@ | @@ -83,6 +93,7 @@ | ||
83 | field: 'apiId', | 93 | field: 'apiId', |
84 | label: '', | 94 | label: '', |
85 | component: 'ApiUpload', | 95 | component: 'ApiUpload', |
96 | + ifShow: ({ model }) => model.importType, | ||
86 | componentProps: ({ formModel }) => { | 97 | componentProps: ({ formModel }) => { |
87 | return { | 98 | return { |
88 | maxFileLimit: 1, | 99 | maxFileLimit: 1, |
@@ -125,6 +136,7 @@ | @@ -125,6 +136,7 @@ | ||
125 | 136 | ||
126 | // JSON导入 | 137 | // JSON导入 |
127 | const handleImportModel = async (file: File) => { | 138 | const handleImportModel = async (file: File) => { |
139 | + await validate(); | ||
128 | const fileReader = new FileReader(); | 140 | const fileReader = new FileReader(); |
129 | const { isCateGory, id } = unref(ImportInfo); | 141 | const { isCateGory, id } = unref(ImportInfo); |
130 | 142 | ||
@@ -176,6 +188,7 @@ | @@ -176,6 +188,7 @@ | ||
176 | 188 | ||
177 | // CSV导入 | 189 | // CSV导入 |
178 | const handleCSVImport = async (file) => { | 190 | const handleCSVImport = async (file) => { |
191 | + await validate(); | ||
179 | const { isCateGory, id } = unref(ImportInfo); | 192 | const { isCateGory, id } = unref(ImportInfo); |
180 | 193 | ||
181 | try { | 194 | try { |