木星 3 місяців тому
батько
коміт
53779f08dd
2 змінених файлів з 92 додано та 1 видалено
  1. 7 0
      src/api/material/index.ts
  2. 85 1
      src/views/Material/MaterialMange.vue

+ 7 - 0
src/api/material/index.ts

@@ -11,6 +11,7 @@ import request from '@/axios'
11 11
 //资源管理分页接口
12 12
 export const getMaterial = (params: any) => {
13 13
   params.page = params.page - 1
14
+  params.materialType = 1
14 15
   return request.post({ url: '/material/pageQuery', params })
15 16
 }
16 17
 
@@ -21,8 +22,14 @@ export const upIcon = (params: any) => {
21 22
 
22 23
 //保存材质接口
23 24
 export const saveResource = (params: any) => {
25
+  params.materialType = 1
24 26
   return request.post({ url: '/material/save', data: params })
25 27
 }
28
+//批量保存材质接口
29
+export const batchsavecz = (params: any) => {
30
+  return request.post({ url: '/material/batchAdd', params })
31
+}
32
+
26 33
 //删除材质接口
27 34
 export const deleteResource = (params: any) => {
28 35
   return request.post({ url: '/material/batchDelete', params })

+ 85 - 1
src/views/Material/MaterialMange.vue

@@ -14,7 +14,7 @@ import { ContentWrap } from '@/components/ContentWrap'
14 14
 import { useI18n } from '@/hooks/web/useI18n'
15 15
 import { Table, TableColumn, TableSlotDefault } from '@/components/Table'
16 16
 import { upTemplate, saveTemplate } from '@/api/table'
17
-import { saveResource, getMaterial, deleteResource } from '@/api/material'
17
+import { saveResource, getMaterial, deleteResource, batchsavecz } from '@/api/material'
18 18
 import { reactive, unref } from 'vue'
19 19
 import { ElButton, ElMessageBox, ElMessage, ElIcon } from 'element-plus'
20 20
 import { useTable } from '@/hooks/web/useTable'
@@ -121,6 +121,7 @@ const deletetab = async (data: TableSlotDefault) => {
121 121
 }
122 122
 
123 123
 const dialogVisible = ref(false)
124
+const dialogVisible2 = ref(false)
124 125
 
125 126
 const token = userStore.getToken
126 127
 const Authorization = `Bearer ${token}`
@@ -236,6 +237,52 @@ const schema = reactive<FormSchema[]>([
236 237
     }
237 238
   }
238 239
 ])
240
+const schema2 = reactive<FormSchema[]>([
241
+  {
242
+    field: 'jsonPath',
243
+    component: 'Upload',
244
+    label: '材质内容',
245
+    colProps: {
246
+      span: 24
247
+    },
248
+    componentProps: {
249
+      limit: 1,
250
+      action: PATH_URL + '/resource/manage/addModelCompress',
251
+      headers: headers,
252
+      fileList: [],
253
+      multiple: true,
254
+      onPreview: (uploadFile) => {
255
+        console.log(uploadFile)
256
+      },
257
+      onRemove: async (file) => {
258
+        const formData = await getFormData()
259
+        formData.jsonPath = ''
260
+        formData.compressFileName = ''
261
+        formData.uploadCompress = false
262
+      },
263
+      onSuccess: async (_response, uploadFile) => {
264
+        console.log('kankan_response', uploadFile)
265
+        const formData = await getFormData()
266
+        formData.compressFilePath = _response.data
267
+      },
268
+      beforeRemove: (uploadFile) => {},
269
+      onExceed: (files, uploadFiles) => {
270
+        ElMessage.warning('只能上传一个资源,请移除后重新上传')
271
+      },
272
+      beforeUpload: (rawFile) => {
273
+        if (rawFile.type !== 'application/x-zip-compressed' && rawFile.name.indexOf('.rar') == -1) {
274
+          ElMessage.error('只能上传RAR、ZIP文件')
275
+          return false
276
+        }
277
+        return true
278
+      },
279
+      slots: {
280
+        default: () => <BaseButton type="primary">点击上传</BaseButton>,
281
+        tip: () => <div class="el-upload__tip">文件类型:RAR\ZIP</div>
282
+      }
283
+    }
284
+  }
285
+])
239 286
 
240 287
 //编辑
241 288
 const edittab = async (data: TableSlotDefault) => {
@@ -275,6 +322,23 @@ const signIn = async () => {
275 322
     }
276 323
   })
277 324
 }
325
+// 批量添加材质
326
+const signIn2 = async () => {
327
+  const formRef = await getElFormExpose()
328
+  const formData = await getFormData()
329
+
330
+  //如果是编辑去掉icon的拼接
331
+  console.log('kakkkkak', formData)
332
+  await formRef?.validate(async (isValid) => {
333
+    if (isValid) {
334
+      const res = await batchsavecz(formData)
335
+      if (res) {
336
+        dialogVisible2.value = false
337
+        refresh()
338
+      }
339
+    }
340
+  })
341
+}
278 342
 
279 343
 //多选删除
280 344
 const getSelections = async () => {
@@ -313,6 +377,9 @@ const tianjia = async () => {
313 377
   schema[2].componentProps.fileList = []
314 378
   dialogVisible.value = true
315 379
 }
380
+const batchtianjia = async () => {
381
+  dialogVisible2.value = true
382
+}
316 383
 </script>
317 384
 
318 385
 <template>
@@ -320,6 +387,7 @@ const tianjia = async () => {
320 387
     <div style="margin-bottom: 10px">
321 388
       <ElButton type="success" size="large" @click="tianjia" :icon="Edit">添加</ElButton>
322 389
       <ElButton type="danger" size="large" @click="getSelections" :icon="Delete">删除</ElButton>
390
+      <ElButton type="success" size="large" @click="batchtianjia" :icon="Edit">批量上传</ElButton>
323 391
     </div>
324 392
 
325 393
     <Table
@@ -356,6 +424,22 @@ const tianjia = async () => {
356 424
       </div>
357 425
     </template>
358 426
   </Dialog>
427
+
428
+  <Dialog v-model="dialogVisible2" maxHeight="390px" width="35rem" :title="isedit">
429
+    <Form :schema="schema2" @register="formRegister" />
430
+    <template #footer>
431
+      <div style="width: 100%; display: flex; justify-content: center">
432
+        <BaseButton
433
+          style="font-size: 1rem; height: 2.2rem; margin: auto"
434
+          type="primary"
435
+          class="w-[15%]"
436
+          @click="signIn2"
437
+        >
438
+          确定
439
+        </BaseButton>
440
+      </div>
441
+    </template>
442
+  </Dialog>
359 443
 </template>
360 444
 
361 445
 <style>