木星 1 month ago
parent
commit
53779f08dd
2 changed files with 92 additions and 1 deletions
  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
 export const getMaterial = (params: any) => {
12
 export const getMaterial = (params: any) => {
13
   params.page = params.page - 1
13
   params.page = params.page - 1
14
+  params.materialType = 1
14
   return request.post({ url: '/material/pageQuery', params })
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
 export const saveResource = (params: any) => {
24
 export const saveResource = (params: any) => {
25
+  params.materialType = 1
24
   return request.post({ url: '/material/save', data: params })
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
 export const deleteResource = (params: any) => {
34
 export const deleteResource = (params: any) => {
28
   return request.post({ url: '/material/batchDelete', params })
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
 import { useI18n } from '@/hooks/web/useI18n'
14
 import { useI18n } from '@/hooks/web/useI18n'
15
 import { Table, TableColumn, TableSlotDefault } from '@/components/Table'
15
 import { Table, TableColumn, TableSlotDefault } from '@/components/Table'
16
 import { upTemplate, saveTemplate } from '@/api/table'
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
 import { reactive, unref } from 'vue'
18
 import { reactive, unref } from 'vue'
19
 import { ElButton, ElMessageBox, ElMessage, ElIcon } from 'element-plus'
19
 import { ElButton, ElMessageBox, ElMessage, ElIcon } from 'element-plus'
20
 import { useTable } from '@/hooks/web/useTable'
20
 import { useTable } from '@/hooks/web/useTable'
@@ -121,6 +121,7 @@ const deletetab = async (data: TableSlotDefault) => {
121
 }
121
 }
122
 
122
 
123
 const dialogVisible = ref(false)
123
 const dialogVisible = ref(false)
124
+const dialogVisible2 = ref(false)
124
 
125
 
125
 const token = userStore.getToken
126
 const token = userStore.getToken
126
 const Authorization = `Bearer ${token}`
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
 const edittab = async (data: TableSlotDefault) => {
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
 const getSelections = async () => {
344
 const getSelections = async () => {
@@ -313,6 +377,9 @@ const tianjia = async () => {
313
   schema[2].componentProps.fileList = []
377
   schema[2].componentProps.fileList = []
314
   dialogVisible.value = true
378
   dialogVisible.value = true
315
 }
379
 }
380
+const batchtianjia = async () => {
381
+  dialogVisible2.value = true
382
+}
316
 </script>
383
 </script>
317
 
384
 
318
 <template>
385
 <template>
@@ -320,6 +387,7 @@ const tianjia = async () => {
320
     <div style="margin-bottom: 10px">
387
     <div style="margin-bottom: 10px">
321
       <ElButton type="success" size="large" @click="tianjia" :icon="Edit">添加</ElButton>
388
       <ElButton type="success" size="large" @click="tianjia" :icon="Edit">添加</ElButton>
322
       <ElButton type="danger" size="large" @click="getSelections" :icon="Delete">删除</ElButton>
389
       <ElButton type="danger" size="large" @click="getSelections" :icon="Delete">删除</ElButton>
390
+      <ElButton type="success" size="large" @click="batchtianjia" :icon="Edit">批量上传</ElButton>
323
     </div>
391
     </div>
324
 
392
 
325
     <Table
393
     <Table
@@ -356,6 +424,22 @@ const tianjia = async () => {
356
       </div>
424
       </div>
357
     </template>
425
     </template>
358
   </Dialog>
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
 </template>
443
 </template>
360
 
444
 
361
 <style>
445
 <style>