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