Browse Source

修改材质页面

木星 1 month ago
parent
commit
4ba9e85a0c
3 changed files with 74 additions and 64 deletions
  1. 29 0
      src/api/material/index.ts
  2. 9 0
      src/api/material/types.ts
  3. 36 64
      src/views/Material/MaterialMange.vue

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

@@ -0,0 +1,29 @@
1
+/*
2
+ * @Author: 半生瓜 1515706227@qq.com
3
+ * @Date: 2024-05-07 10:39:27
4
+ * @LastEditors: 半生瓜 1515706227@qq.com
5
+ * @LastEditTime: 2024-05-13 20:58:53
6
+ * @FilePath: \vue-element-plus-admin-mini\src\api\table\index.ts
7
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
+ */
9
+import request from '@/axios'
10
+
11
+//资源管理分页接口
12
+export const getMaterial = (params: any) => {
13
+  params.page = params.page - 1
14
+  return request.post({ url: '/material/pageQuery', params })
15
+}
16
+
17
+//上传资源图标接口
18
+export const upIcon = (params: any) => {
19
+  return request.post({ url: '/resource/manage/uploadImg', params })
20
+}
21
+
22
+//保存材质接口
23
+export const saveResource = (params: any) => {
24
+  return request.post({ url: '/material/save', data: params })
25
+}
26
+//删除材质接口
27
+export const deleteResource = (params: any) => {
28
+  return request.post({ url: '/material/batchDelete', params })
29
+}

+ 9 - 0
src/api/material/types.ts

@@ -0,0 +1,9 @@
1
+export type TableData = {
2
+  id: string
3
+  author: string
4
+  title: string
5
+  content: string
6
+  importance: number
7
+  display_time: string
8
+  pageviews: number
9
+}

+ 36 - 64
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, getResource, deleteResource } from '@/api/resource'
17
+import { saveResource, getMaterial, deleteResource } 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'
@@ -34,20 +34,20 @@ defineOptions({
34
   name: 'TemplateManage'
34
   name: 'TemplateManage'
35
 })
35
 })
36
 
36
 
37
-const compare = ref('')
38
-
39
 const { tableRegister, tableState, tableMethods } = useTable({
37
 const { tableRegister, tableState, tableMethods } = useTable({
40
   fetchDataApi: async () => {
38
   fetchDataApi: async () => {
41
     const { currentPage, pageSize } = tableState
39
     const { currentPage, pageSize } = tableState
42
-    const res = await getResource({
40
+    const res = await getMaterial({
43
       page: unref(currentPage),
41
       page: unref(currentPage),
44
       pageSize: unref(pageSize),
42
       pageSize: unref(pageSize),
45
       name: unref(text)
43
       name: unref(text)
46
     })
44
     })
47
     res.data.content.map((item) => {
45
     res.data.content.map((item) => {
48
-      console.log('opopopop', item)
49
-      item.icon = PATH_URL + item.icon
46
+      item.materialIcon = PATH_URL + item.materialIcon
47
+      item.icon = item.materialIcon
50
     })
48
     })
49
+    console.log('kankan2232', res.data.content)
50
+
51
     return {
51
     return {
52
       list: res.data.content,
52
       list: res.data.content,
53
       total: res.data.totalElements
53
       total: res.data.totalElements
@@ -72,19 +72,14 @@ const columns = reactive<TableColumn[]>([
72
     type: 'index'
72
     type: 'index'
73
   },
73
   },
74
   {
74
   {
75
-    field: 'categoryName',
76
-    label: '资源库分类'
75
+    field: 'materialName',
76
+    label: '材质名称'
77
   },
77
   },
78
   {
78
   {
79
     field: 'icon',
79
     field: 'icon',
80
     label: '图标'
80
     label: '图标'
81
   },
81
   },
82
   {
82
   {
83
-    field: 'modelCount',
84
-    label: '对象数量'
85
-  },
86
-
87
-  {
88
     field: 'action',
83
     field: 'action',
89
     label: t('tableDemo.action'),
84
     label: t('tableDemo.action'),
90
     slots: {
85
     slots: {
@@ -110,7 +105,7 @@ const deletetab = async (data: TableSlotDefault) => {
110
   ElMessageBox.confirm('确定删除该数据?')
105
   ElMessageBox.confirm('确定删除该数据?')
111
     .then(async () => {
106
     .then(async () => {
112
       let arr = {
107
       let arr = {
113
-        categoryId: [data.row.categoryId]
108
+        materialIds: data.row.materialId
114
       }
109
       }
115
       const res = await deleteResource(arr)
110
       const res = await deleteResource(arr)
116
       refresh()
111
       refresh()
@@ -136,8 +131,8 @@ const { getElFormExpose, getFormData } = formMethods
136
 
131
 
137
 const schema = reactive<FormSchema[]>([
132
 const schema = reactive<FormSchema[]>([
138
   {
133
   {
139
-    field: 'categoryName',
140
-    label: '资源分类',
134
+    field: 'materialName',
135
+    label: '材质名称',
141
     component: 'Input',
136
     component: 'Input',
142
     colProps: {
137
     colProps: {
143
       span: 24
138
       span: 24
@@ -146,14 +141,14 @@ const schema = reactive<FormSchema[]>([
146
       style: {
141
       style: {
147
         width: '100%'
142
         width: '100%'
148
       },
143
       },
149
-      placeholder: '请输入资源名称'
144
+      placeholder: '请输入材质名称'
150
     },
145
     },
151
     formItemProps: {
146
     formItemProps: {
152
       rules: [required()]
147
       rules: [required()]
153
     }
148
     }
154
   },
149
   },
155
   {
150
   {
156
-    field: 'icon',
151
+    field: 'materialIcon',
157
     component: 'Upload',
152
     component: 'Upload',
158
     colProps: {
153
     colProps: {
159
       span: 24
154
       span: 24
@@ -169,7 +164,7 @@ const schema = reactive<FormSchema[]>([
169
       onSuccess: async (_response, uploadFile) => {
164
       onSuccess: async (_response, uploadFile) => {
170
         imageUrl.value = URL.createObjectURL(uploadFile.raw!)
165
         imageUrl.value = URL.createObjectURL(uploadFile.raw!)
171
         const formData = await getFormData()
166
         const formData = await getFormData()
172
-        formData.icon = _response.data
167
+        formData.materialIcon = _response.data
173
       },
168
       },
174
       beforeUpload: (rawFile) => {
169
       beforeUpload: (rawFile) => {
175
         console.log('kankangeshi', rawFile)
170
         console.log('kankangeshi', rawFile)
@@ -195,15 +190,15 @@ const schema = reactive<FormSchema[]>([
195
     }
190
     }
196
   },
191
   },
197
   {
192
   {
198
-    field: 'compressFilePath',
193
+    field: 'jsonPath',
199
     component: 'Upload',
194
     component: 'Upload',
200
-    label: '资源内容',
195
+    label: '材质内容',
201
     colProps: {
196
     colProps: {
202
       span: 24
197
       span: 24
203
     },
198
     },
204
     componentProps: {
199
     componentProps: {
205
       limit: 1,
200
       limit: 1,
206
-      action: PATH_URL + '/resource/manage/addModelCompress',
201
+      action: PATH_URL + '/resource/v1/addJsonFile',
207
       headers: headers,
202
       headers: headers,
208
       fileList: [],
203
       fileList: [],
209
       multiple: true,
204
       multiple: true,
@@ -212,14 +207,14 @@ const schema = reactive<FormSchema[]>([
212
       },
207
       },
213
       onRemove: async (file) => {
208
       onRemove: async (file) => {
214
         const formData = await getFormData()
209
         const formData = await getFormData()
215
-        formData.compressFilePath = ''
210
+        formData.jsonPath = ''
216
         formData.compressFileName = ''
211
         formData.compressFileName = ''
217
         formData.uploadCompress = false
212
         formData.uploadCompress = false
218
       },
213
       },
219
       onSuccess: async (_response, uploadFile) => {
214
       onSuccess: async (_response, uploadFile) => {
220
         console.log('kankan_response', uploadFile)
215
         console.log('kankan_response', uploadFile)
221
         const formData = await getFormData()
216
         const formData = await getFormData()
222
-        formData.compressFilePath = _response.data
217
+        formData.jsonPath = _response.data
223
         formData.compressFileName = uploadFile.name
218
         formData.compressFileName = uploadFile.name
224
       },
219
       },
225
       beforeRemove: (uploadFile) => {},
220
       beforeRemove: (uploadFile) => {},
@@ -228,11 +223,11 @@ const schema = reactive<FormSchema[]>([
228
       },
223
       },
229
       beforeUpload: (rawFile) => {
224
       beforeUpload: (rawFile) => {
230
         console.log('kokokoko', rawFile)
225
         console.log('kokokoko', rawFile)
231
-        if (rawFile.type !== 'application/x-zip-compressed' && rawFile.name.indexOf('.rar') == -1) {
232
-          ElMessage.error('只能上传RAR、ZIP文件')
233
-          return false
234
-        }
235
-        return true
226
+        // if (rawFile.type !== 'application/x-zip-compressed' && rawFile.name.indexOf('.rar') == -1) {
227
+        //   ElMessage.error('只能上传RAR、ZIP文件')
228
+        //   return false
229
+        // }
230
+        // return true
236
       },
231
       },
237
       slots: {
232
       slots: {
238
         default: () => <BaseButton type="primary">点击上传</BaseButton>,
233
         default: () => <BaseButton type="primary">点击上传</BaseButton>,
@@ -249,17 +244,17 @@ const edittab = async (data: TableSlotDefault) => {
249
   dialogVisible.value = true
244
   dialogVisible.value = true
250
   const formRef = await getElFormExpose()
245
   const formRef = await getElFormExpose()
251
   const formData = await getFormData()
246
   const formData = await getFormData()
252
-  formData.categoryName = data.row.categoryName
247
+  formData.materialName = data.row.materialName
253
   formData.compressFileName = data.row.compressFileName
248
   formData.compressFileName = data.row.compressFileName
254
-  formData.compressFilePath = data.row.compressFilePath
255
-  compare.value = data.row.compressFilePath
256
-  formData.icon = data.row.icon.replace(PATH_URL, '')
257
-  imageUrl.value = data.row.icon
258
-  formData.categoryId = data.row.categoryId
249
+  formData.jsonPath = data.row.jsonPath
250
+
251
+  formData.materialIcon = data.row.materialIcon.replace(PATH_URL, '')
252
+  imageUrl.value = data.row.materialIcon
253
+  formData.materialId = data.row.materialId
259
   schema[2].componentProps.fileList = [
254
   schema[2].componentProps.fileList = [
260
     {
255
     {
261
       name: data.row.compressFileName,
256
       name: data.row.compressFileName,
262
-      url: data.row.compressFilePath
257
+      url: data.row.jsonPath
263
     }
258
     }
264
   ]
259
   ]
265
 }
260
 }
@@ -267,16 +262,7 @@ const edittab = async (data: TableSlotDefault) => {
267
 const signIn = async () => {
262
 const signIn = async () => {
268
   const formRef = await getElFormExpose()
263
   const formRef = await getElFormExpose()
269
   const formData = await getFormData()
264
   const formData = await getFormData()
270
-  console.log('lplplp', formData.compressFilePath)
271
-  if (
272
-    formData.compressFilePath !== compare.value &&
273
-    formData.compressFilePath !== '' &&
274
-    formData.compressFilePath
275
-  ) {
276
-    formData.uploadCompress = true
277
-  } else {
278
-    formData.uploadCompress = false
279
-  }
265
+
280
   //如果是编辑去掉icon的拼接
266
   //如果是编辑去掉icon的拼接
281
   console.log('kakkkkak', formData)
267
   console.log('kakkkkak', formData)
282
   await formRef?.validate(async (isValid) => {
268
   await formRef?.validate(async (isValid) => {
@@ -290,26 +276,20 @@ const signIn = async () => {
290
   })
276
   })
291
 }
277
 }
292
 
278
 
293
-//搜索
294
-const handersearch = function () {
295
-  tableState.currentPage.value = 1
296
-  refresh()
297
-}
298
-
299
 //多选删除
279
 //多选删除
300
 const getSelections = async () => {
280
 const getSelections = async () => {
301
   const elTableRef = await getElTableExpose()
281
   const elTableRef = await getElTableExpose()
302
   const selections = elTableRef?.getSelectionRows()
282
   const selections = elTableRef?.getSelectionRows()
303
 
283
 
304
   let arr = {
284
   let arr = {
305
-    categoryId: []
285
+    materialIds: []
306
   }
286
   }
307
   if (selections) {
287
   if (selections) {
308
-    arr.categoryId = selections.map((item) => {
309
-      return item.categoryId
288
+    arr.materialIds = selections.map((item) => {
289
+      return item.materialId
310
     })
290
     })
311
   }
291
   }
312
-  if (arr.categoryId.length !== 0) {
292
+  if (arr.materialIds.length !== 0) {
313
     ElMessageBox.confirm('确定删除所选数据?')
293
     ElMessageBox.confirm('确定删除所选数据?')
314
       .then(async () => {
294
       .then(async () => {
315
         console.log('kankan', arr)
295
         console.log('kankan', arr)
@@ -332,20 +312,12 @@ const tianjia = async () => {
332
   isedit.value = '添加'
312
   isedit.value = '添加'
333
   schema[2].componentProps.fileList = []
313
   schema[2].componentProps.fileList = []
334
   dialogVisible.value = true
314
   dialogVisible.value = true
335
-  compare.value = ''
336
 }
315
 }
337
 </script>
316
 </script>
338
 
317
 
339
 <template>
318
 <template>
340
   <ContentWrap>
319
   <ContentWrap>
341
     <div style="margin-bottom: 10px">
320
     <div style="margin-bottom: 10px">
342
-      <span style="color: #606266"> 资源分类:</span>
343
-      <el-input
344
-        v-model="text"
345
-        style="width: 200px; height: 43px; margin: 7px"
346
-        placeholder="请输入资源分类名称"
347
-      />
348
-      <ElButton type="primary" size="large" @click="handersearch" :icon="Search">搜索</ElButton>
349
       <ElButton type="success" size="large" @click="tianjia" :icon="Edit">添加</ElButton>
321
       <ElButton type="success" size="large" @click="tianjia" :icon="Edit">添加</ElButton>
350
       <ElButton type="danger" size="large" @click="getSelections" :icon="Delete">删除</ElButton>
322
       <ElButton type="danger" size="large" @click="getSelections" :icon="Delete">删除</ElButton>
351
     </div>
323
     </div>