Bläddra i källkod

修改材质页面

木星 1 månad sedan
förälder
incheckning
4ba9e85a0c
3 ändrade filer med 74 tillägg och 64 borttagningar
  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 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, getResource, deleteResource } from '@/api/resource'
17
+import { saveResource, getMaterial, deleteResource } 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'
@@ -34,20 +34,20 @@ defineOptions({
34 34
   name: 'TemplateManage'
35 35
 })
36 36
 
37
-const compare = ref('')
38
-
39 37
 const { tableRegister, tableState, tableMethods } = useTable({
40 38
   fetchDataApi: async () => {
41 39
     const { currentPage, pageSize } = tableState
42
-    const res = await getResource({
40
+    const res = await getMaterial({
43 41
       page: unref(currentPage),
44 42
       pageSize: unref(pageSize),
45 43
       name: unref(text)
46 44
     })
47 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 51
     return {
52 52
       list: res.data.content,
53 53
       total: res.data.totalElements
@@ -72,19 +72,14 @@ const columns = reactive<TableColumn[]>([
72 72
     type: 'index'
73 73
   },
74 74
   {
75
-    field: 'categoryName',
76
-    label: '资源库分类'
75
+    field: 'materialName',
76
+    label: '材质名称'
77 77
   },
78 78
   {
79 79
     field: 'icon',
80 80
     label: '图标'
81 81
   },
82 82
   {
83
-    field: 'modelCount',
84
-    label: '对象数量'
85
-  },
86
-
87
-  {
88 83
     field: 'action',
89 84
     label: t('tableDemo.action'),
90 85
     slots: {
@@ -110,7 +105,7 @@ const deletetab = async (data: TableSlotDefault) => {
110 105
   ElMessageBox.confirm('确定删除该数据?')
111 106
     .then(async () => {
112 107
       let arr = {
113
-        categoryId: [data.row.categoryId]
108
+        materialIds: data.row.materialId
114 109
       }
115 110
       const res = await deleteResource(arr)
116 111
       refresh()
@@ -136,8 +131,8 @@ const { getElFormExpose, getFormData } = formMethods
136 131
 
137 132
 const schema = reactive<FormSchema[]>([
138 133
   {
139
-    field: 'categoryName',
140
-    label: '资源分类',
134
+    field: 'materialName',
135
+    label: '材质名称',
141 136
     component: 'Input',
142 137
     colProps: {
143 138
       span: 24
@@ -146,14 +141,14 @@ const schema = reactive<FormSchema[]>([
146 141
       style: {
147 142
         width: '100%'
148 143
       },
149
-      placeholder: '请输入资源名称'
144
+      placeholder: '请输入材质名称'
150 145
     },
151 146
     formItemProps: {
152 147
       rules: [required()]
153 148
     }
154 149
   },
155 150
   {
156
-    field: 'icon',
151
+    field: 'materialIcon',
157 152
     component: 'Upload',
158 153
     colProps: {
159 154
       span: 24
@@ -169,7 +164,7 @@ const schema = reactive<FormSchema[]>([
169 164
       onSuccess: async (_response, uploadFile) => {
170 165
         imageUrl.value = URL.createObjectURL(uploadFile.raw!)
171 166
         const formData = await getFormData()
172
-        formData.icon = _response.data
167
+        formData.materialIcon = _response.data
173 168
       },
174 169
       beforeUpload: (rawFile) => {
175 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 194
     component: 'Upload',
200
-    label: '资源内容',
195
+    label: '材质内容',
201 196
     colProps: {
202 197
       span: 24
203 198
     },
204 199
     componentProps: {
205 200
       limit: 1,
206
-      action: PATH_URL + '/resource/manage/addModelCompress',
201
+      action: PATH_URL + '/resource/v1/addJsonFile',
207 202
       headers: headers,
208 203
       fileList: [],
209 204
       multiple: true,
@@ -212,14 +207,14 @@ const schema = reactive<FormSchema[]>([
212 207
       },
213 208
       onRemove: async (file) => {
214 209
         const formData = await getFormData()
215
-        formData.compressFilePath = ''
210
+        formData.jsonPath = ''
216 211
         formData.compressFileName = ''
217 212
         formData.uploadCompress = false
218 213
       },
219 214
       onSuccess: async (_response, uploadFile) => {
220 215
         console.log('kankan_response', uploadFile)
221 216
         const formData = await getFormData()
222
-        formData.compressFilePath = _response.data
217
+        formData.jsonPath = _response.data
223 218
         formData.compressFileName = uploadFile.name
224 219
       },
225 220
       beforeRemove: (uploadFile) => {},
@@ -228,11 +223,11 @@ const schema = reactive<FormSchema[]>([
228 223
       },
229 224
       beforeUpload: (rawFile) => {
230 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 232
       slots: {
238 233
         default: () => <BaseButton type="primary">点击上传</BaseButton>,
@@ -249,17 +244,17 @@ const edittab = async (data: TableSlotDefault) => {
249 244
   dialogVisible.value = true
250 245
   const formRef = await getElFormExpose()
251 246
   const formData = await getFormData()
252
-  formData.categoryName = data.row.categoryName
247
+  formData.materialName = data.row.materialName
253 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 254
   schema[2].componentProps.fileList = [
260 255
     {
261 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 262
 const signIn = async () => {
268 263
   const formRef = await getElFormExpose()
269 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 266
   //如果是编辑去掉icon的拼接
281 267
   console.log('kakkkkak', formData)
282 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 280
 const getSelections = async () => {
301 281
   const elTableRef = await getElTableExpose()
302 282
   const selections = elTableRef?.getSelectionRows()
303 283
 
304 284
   let arr = {
305
-    categoryId: []
285
+    materialIds: []
306 286
   }
307 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 293
     ElMessageBox.confirm('确定删除所选数据?')
314 294
       .then(async () => {
315 295
         console.log('kankan', arr)
@@ -332,20 +312,12 @@ const tianjia = async () => {
332 312
   isedit.value = '添加'
333 313
   schema[2].componentProps.fileList = []
334 314
   dialogVisible.value = true
335
-  compare.value = ''
336 315
 }
337 316
 </script>
338 317
 
339 318
 <template>
340 319
   <ContentWrap>
341 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 321
       <ElButton type="success" size="large" @click="tianjia" :icon="Edit">添加</ElButton>
350 322
       <ElButton type="danger" size="large" @click="getSelections" :icon="Delete">删除</ElButton>
351 323
     </div>