Browse Source

优化材质和审核

木星 1 month ago
parent
commit
8a2380568d

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

@@ -11,7 +11,6 @@ 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
15
   return request.post({ url: '/material/pageQuery', params })
14
   return request.post({ url: '/material/pageQuery', params })
16
 }
15
 }
17
 
16
 
@@ -22,7 +21,6 @@ export const upIcon = (params: any) => {
22
 
21
 
23
 //保存材质接口
22
 //保存材质接口
24
 export const saveResource = (params: any) => {
23
 export const saveResource = (params: any) => {
25
-  params.materialType = 1
26
   return request.post({ url: '/material/save', data: params })
24
   return request.post({ url: '/material/save', data: params })
27
 }
25
 }
28
 //批量保存材质接口
26
 //批量保存材质接口

+ 10 - 2
src/views/Audit/AuditManage.vue

@@ -120,7 +120,11 @@ const deletetab = async (data: TableSlotDefault) => {
120
     const res = await deleteAudit(arr)
120
     const res = await deleteAudit(arr)
121
     refresh()
121
     refresh()
122
     if (res.code == 200) {
122
     if (res.code == 200) {
123
-      ElMessage.success('删除成功')
123
+      if (res.message.includes('成功')) {
124
+        ElMessage.success(res.message)
125
+      } else {
126
+        ElMessage.error(res.message)
127
+      }
124
     }
128
     }
125
     refresh()
129
     refresh()
126
   })
130
   })
@@ -145,7 +149,11 @@ const getSelections = async () => {
145
         const res = await deleteAudit(arr)
149
         const res = await deleteAudit(arr)
146
         console.log('kkkkkkss', res)
150
         console.log('kkkkkkss', res)
147
         if (res.code == 200) {
151
         if (res.code == 200) {
148
-          ElMessage.success('删除成功')
152
+          if (res.message.includes('成功')) {
153
+            ElMessage.success(res.message)
154
+          } else {
155
+            ElMessage.error(res.message)
156
+          }
149
         }
157
         }
150
         refresh()
158
         refresh()
151
       })
159
       })

+ 1 - 1
src/views/Login/components/LoginForm.vue

@@ -77,7 +77,7 @@ const schema = reactive<FormSchema[]>([
77
       span: 24
77
       span: 24
78
     },
78
     },
79
     componentProps: {
79
     componentProps: {
80
-      placeholder: '请输入用户名',
80
+      placeholder: '请输入账号',
81
       prefixIcon: <Icon icon="mdi:account" />
81
       prefixIcon: <Icon icon="mdi:account" />
82
     }
82
     }
83
   },
83
   },

+ 187 - 38
src/views/Material/MaterialMange.vue

@@ -7,7 +7,7 @@
7
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
7
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
 -->
8
 -->
9
 <script setup lang="tsx">
9
 <script setup lang="tsx">
10
-import { ElInput } from 'element-plus'
10
+import { ElInput, ElSelect, ElOption } from 'element-plus'
11
 import { ref } from 'vue'
11
 import { ref } from 'vue'
12
 import { Dialog } from '@/components/Dialog'
12
 import { Dialog } from '@/components/Dialog'
13
 import { ContentWrap } from '@/components/ContentWrap'
13
 import { ContentWrap } from '@/components/ContentWrap'
@@ -25,10 +25,13 @@ import { useForm } from '@/hooks/web/useForm'
25
 import { BaseButton } from '@/components/Button'
25
 import { BaseButton } from '@/components/Button'
26
 import { useUserStore } from '@/store/modules/user'
26
 import { useUserStore } from '@/store/modules/user'
27
 import { log } from 'console'
27
 import { log } from 'console'
28
+import { json } from 'stream/consumers'
28
 const PATH_URL = window.VITE_API_BASE_PATH
29
 const PATH_URL = window.VITE_API_BASE_PATH
29
-
30
+const tietu = ref('')
30
 const { required } = useValidator()
31
 const { required } = useValidator()
31
 const text = ref('')
32
 const text = ref('')
33
+const materialType = ref('')
34
+
32
 const userStore = useUserStore()
35
 const userStore = useUserStore()
33
 defineOptions({
36
 defineOptions({
34
   name: 'TemplateManage'
37
   name: 'TemplateManage'
@@ -40,7 +43,8 @@ const { tableRegister, tableState, tableMethods } = useTable({
40
     const res = await getMaterial({
43
     const res = await getMaterial({
41
       page: unref(currentPage),
44
       page: unref(currentPage),
42
       pageSize: unref(pageSize),
45
       pageSize: unref(pageSize),
43
-      name: unref(text)
46
+      name: unref(text),
47
+      materialType: unref(materialType)
44
     })
48
     })
45
     res.data.content.map((item) => {
49
     res.data.content.map((item) => {
46
       item.materialIcon = PATH_URL + item.materialIcon
50
       item.materialIcon = PATH_URL + item.materialIcon
@@ -72,6 +76,17 @@ const columns = reactive<TableColumn[]>([
72
     type: 'index'
76
     type: 'index'
73
   },
77
   },
74
   {
78
   {
79
+    field: 'materialName',
80
+    label: '材质名称'
81
+  },
82
+  {
83
+    field: 'materialType',
84
+    label: '材质类型',
85
+    formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
86
+      return cellValue === 1 ? '贴图' : cellValue === 2 ? '颜色' : ''
87
+    }
88
+  },
89
+  {
75
     field: 'icon',
90
     field: 'icon',
76
     label: '图标'
91
     label: '图标'
77
   },
92
   },
@@ -95,6 +110,7 @@ const columns = reactive<TableColumn[]>([
95
   }
110
   }
96
 ])
111
 ])
97
 const imageUrl = ref('')
112
 const imageUrl = ref('')
113
+const imageUrl2 = ref('')
98
 const isedit = ref('添加')
114
 const isedit = ref('添加')
99
 //删除
115
 //删除
100
 const deletetab = async (data: TableSlotDefault) => {
116
 const deletetab = async (data: TableSlotDefault) => {
@@ -128,6 +144,48 @@ const { getElFormExpose, getFormData } = formMethods
128
 
144
 
129
 const schema = reactive<FormSchema[]>([
145
 const schema = reactive<FormSchema[]>([
130
   {
146
   {
147
+    field: 'materialType',
148
+    label: '材质类型',
149
+    component: 'Select',
150
+    colProps: {
151
+      span: 24
152
+    },
153
+    componentProps: {
154
+      options: [
155
+        { label: '贴图', value: 1 },
156
+        { label: '颜色', value: 2 }
157
+      ],
158
+      placeholder: '请选择材质类型',
159
+      onChange: (value) => {
160
+        if (value === 2) {
161
+          schema.find((item) => item.field === 'TIETU').colProps.span = 0
162
+        } else {
163
+          schema.find((item) => item.field === 'TIETU').colProps.span = 24
164
+        }
165
+      }
166
+    },
167
+    formItemProps: {
168
+      rules: [required()]
169
+    }
170
+  },
171
+  {
172
+    field: 'materialName',
173
+    label: '材质名称',
174
+    component: 'Input',
175
+    colProps: {
176
+      span: 24
177
+    },
178
+    componentProps: {
179
+      style: {
180
+        width: '100%'
181
+      },
182
+      placeholder: '请输入材质名称'
183
+    },
184
+    formItemProps: {
185
+      rules: [required()]
186
+    }
187
+  },
188
+  {
131
     field: 'materialIcon',
189
     field: 'materialIcon',
132
     component: 'Upload',
190
     component: 'Upload',
133
     colProps: {
191
     colProps: {
@@ -170,50 +228,62 @@ const schema = reactive<FormSchema[]>([
170
     }
228
     }
171
   },
229
   },
172
   {
230
   {
173
-    field: 'jsonPath',
231
+    field: 'TIETU',
174
     component: 'Upload',
232
     component: 'Upload',
175
-    label: '材质内容',
176
     colProps: {
233
     colProps: {
177
       span: 24
234
       span: 24
178
     },
235
     },
236
+    label: '贴图图片',
237
+    formItemProps: {},
179
     componentProps: {
238
     componentProps: {
180
-      limit: 1,
181
-      action: PATH_URL + '/resource/v1/addJsonFile',
239
+      action: PATH_URL + '/resource/manage/uploadImg',
182
       headers: headers,
240
       headers: headers,
183
-      fileList: [],
184
-      multiple: true,
185
-      onPreview: (uploadFile) => {
186
-        console.log(uploadFile)
187
-      },
188
-      onRemove: async (file) => {
189
-        const formData = await getFormData()
190
-        formData.jsonPath = ''
191
-        formData.compressFileName = ''
192
-        formData.uploadCompress = false
193
-      },
241
+      showFileList: false,
194
       onSuccess: async (_response, uploadFile) => {
242
       onSuccess: async (_response, uploadFile) => {
195
-        console.log('kankan_response', uploadFile)
243
+        imageUrl2.value = URL.createObjectURL(uploadFile.raw!)
196
         const formData = await getFormData()
244
         const formData = await getFormData()
197
-        formData.jsonPath = _response.data
198
-        formData.compressFileName = uploadFile.name
199
-      },
200
-      beforeRemove: (uploadFile) => {},
201
-      onExceed: (files, uploadFiles) => {
202
-        ElMessage.warning('只能上传一个资源,请移除后重新上传')
245
+        formData.TIETU = _response.data
246
+        console.log('asdhjasdkj', formData)
203
       },
247
       },
204
       beforeUpload: (rawFile) => {
248
       beforeUpload: (rawFile) => {
205
-        console.log('kokokoko', rawFile)
206
-        // if (rawFile.type !== 'application/x-zip-compressed' && rawFile.name.indexOf('.rar') == -1) {
207
-        //   ElMessage.error('只能上传RAR、ZIP文件')
208
-        //   return false
209
-        // }
210
-        // return true
249
+        console.log('kankangeshi', rawFile)
250
+        if (rawFile.type !== 'image/png' && rawFile.type !== 'image/jpeg') {
251
+          ElMessage.error('上传格式:png、jpg!')
252
+          return false
253
+        }
254
+        return true
211
       },
255
       },
212
       slots: {
256
       slots: {
213
-        default: () => <BaseButton type="primary">点击上传</BaseButton>,
214
-        tip: () => <div class="el-upload__tip">文件类型:JSON</div>
257
+        default: () => (
258
+          <>
259
+            {imageUrl2.value ? <img src={imageUrl2.value} class="avatar" /> : null}
260
+            {!imageUrl2.value ? (
261
+              <ElIcon class="avatar-uploader-icon" size="large" style="font-size: 50px">
262
+                +
263
+              </ElIcon>
264
+            ) : null}
265
+          </>
266
+        ),
267
+        tip: () => <div class="el-upload__tip">上传格式:png、jpg,大小:56x56px;</div>
215
       }
268
       }
216
     }
269
     }
270
+  },
271
+  {
272
+    field: 'jsonValue',
273
+    label: '材质内容',
274
+    component: 'Input',
275
+    colProps: {
276
+      span: 24
277
+    },
278
+    componentProps: {
279
+      type: 'textarea',
280
+      rows: 4,
281
+      placeholder: '请输入材质内容'
282
+    },
283
+
284
+    formItemProps: {
285
+      rules: [required()]
286
+    }
217
   }
287
   }
218
 ])
288
 ])
219
 const schema2 = reactive<FormSchema[]>([
289
 const schema2 = reactive<FormSchema[]>([
@@ -272,10 +342,21 @@ const edittab = async (data: TableSlotDefault) => {
272
   const formData = await getFormData()
342
   const formData = await getFormData()
273
   formData.compressFileName = data.row.compressFileName
343
   formData.compressFileName = data.row.compressFileName
274
   formData.jsonPath = data.row.jsonPath
344
   formData.jsonPath = data.row.jsonPath
345
+  formData.TIETU = data.row.jsonValue.texture
346
+
275
   formData.materialName = data.row.materialName
347
   formData.materialName = data.row.materialName
276
 
348
 
349
+  let a = JSON.parse(JSON.stringify(data.row.jsonValue))
350
+  tietu.value = a.texture
351
+  imageUrl2.value = PATH_URL + data.row.jsonValue.texture
352
+  delete a.texture
353
+  formData.jsonValue = JSON.stringify(a)
354
+
355
+  formData.materialType = data.row.materialType
356
+
277
   formData.materialIcon = data.row.materialIcon.replace(PATH_URL, '')
357
   formData.materialIcon = data.row.materialIcon.replace(PATH_URL, '')
278
   imageUrl.value = data.row.materialIcon
358
   imageUrl.value = data.row.materialIcon
359
+
279
   formData.materialId = data.row.materialId
360
   formData.materialId = data.row.materialId
280
   schema[1].componentProps.fileList = [
361
   schema[1].componentProps.fileList = [
281
     {
362
     {
@@ -283,12 +364,33 @@ const edittab = async (data: TableSlotDefault) => {
283
       url: data.row.jsonPath
364
       url: data.row.jsonPath
284
     }
365
     }
285
   ]
366
   ]
367
+
368
+  // 如果材质类型是颜色,不显示贴图图标
369
+  if (formData.materialType === 2) {
370
+    schema.find((item) => item.field === 'TIETU').colProps.span = 0
371
+  } else {
372
+    schema.find((item) => item.field === 'TIETU').colProps.span = 24
373
+  }
286
 }
374
 }
287
 // 添加编辑模板管理
375
 // 添加编辑模板管理
288
 const signIn = async () => {
376
 const signIn = async () => {
289
   const formRef = await getElFormExpose()
377
   const formRef = await getElFormExpose()
290
   const formData = await getFormData()
378
   const formData = await getFormData()
379
+  console.log('asdhajgsh', formData.jsonValue)
380
+
381
+  if (!formData.TIETU && formData.materialType == 1) {
382
+    ElMessage.warning('请上传贴图图标')
383
+    return
384
+  }
385
+
386
+  formData.jsonValue = JSON.parse(formData.jsonValue)
291
 
387
 
388
+  console.log('shdjasd1', formData.TIETU)
389
+  if (formData.TIETU) {
390
+    formData.jsonValue.texture = formData.TIETU
391
+  } else {
392
+    formData.jsonValue.texture = tietu.value
393
+  }
292
   //如果是编辑去掉icon的拼接
394
   //如果是编辑去掉icon的拼接
293
   console.log('kakkkkak', formData)
395
   console.log('kakkkkak', formData)
294
   await formRef?.validate(async (isValid) => {
396
   await formRef?.validate(async (isValid) => {
@@ -296,6 +398,7 @@ const signIn = async () => {
296
       const res = await saveResource(formData)
398
       const res = await saveResource(formData)
297
       if (res) {
399
       if (res) {
298
         dialogVisible.value = false
400
         dialogVisible.value = false
401
+        ElMessage.success('保存成功')
299
         refresh()
402
         refresh()
300
       }
403
       }
301
     }
404
     }
@@ -350,23 +453,69 @@ const getSelections = async () => {
350
     ElMessage.warning('请选择数据')
453
     ElMessage.warning('请选择数据')
351
   }
454
   }
352
 }
455
 }
456
+
457
+const options = [
458
+  {
459
+    value: 1,
460
+    label: '贴图'
461
+  },
462
+  {
463
+    value: 2,
464
+    label: '颜色'
465
+  }
466
+]
467
+
468
+//搜索
469
+const handersearch = function () {
470
+  tableState.currentPage.value = 1
471
+  refresh()
472
+}
473
+
353
 const tianjia = async () => {
474
 const tianjia = async () => {
354
   imageUrl.value = ''
475
   imageUrl.value = ''
476
+  imageUrl2.value = ''
355
   isedit.value = '添加'
477
   isedit.value = '添加'
356
   schema[1].componentProps.fileList = []
478
   schema[1].componentProps.fileList = []
357
   dialogVisible.value = true
479
   dialogVisible.value = true
358
 }
480
 }
359
-const batchtianjia = async () => {
360
-  dialogVisible2.value = true
361
-}
362
 </script>
481
 </script>
363
 
482
 
364
 <template>
483
 <template>
365
   <ContentWrap>
484
   <ContentWrap>
366
     <div style="margin-bottom: 10px">
485
     <div style="margin-bottom: 10px">
486
+      <span style="color: #606266"> 材质名称:</span>
487
+      <el-input
488
+        v-model="text"
489
+        style="width: 200px; height: 43px; margin: 7px"
490
+        placeholder="请输入材质名称"
491
+      />
492
+      <span style="color: #606266"> 材质状态:</span>
493
+      <el-select
494
+        v-model="materialType"
495
+        clearable
496
+        placeholder="全部"
497
+        size="large"
498
+        style="width: 240px"
499
+      >
500
+        <el-option
501
+          v-for="item in options"
502
+          :key="item.value"
503
+          :label="item.label"
504
+          :value="item.value"
505
+        />
506
+      </el-select>
507
+
508
+      <ElButton
509
+        style="margin-left: 20px"
510
+        type="primary"
511
+        size="large"
512
+        @click="handersearch"
513
+        :icon="Search"
514
+        >搜索</ElButton
515
+      >
516
+
367
       <ElButton type="success" size="large" @click="tianjia" :icon="Edit">添加</ElButton>
517
       <ElButton type="success" size="large" @click="tianjia" :icon="Edit">添加</ElButton>
368
       <ElButton type="danger" size="large" @click="getSelections" :icon="Delete">删除</ElButton>
518
       <ElButton type="danger" size="large" @click="getSelections" :icon="Delete">删除</ElButton>
369
-      <ElButton type="success" size="large" @click="batchtianjia" :icon="Edit">批量上传</ElButton>
370
     </div>
519
     </div>
371
 
520
 
372
     <Table
521
     <Table
@@ -388,7 +537,7 @@ const batchtianjia = async () => {
388
     />
537
     />
389
   </ContentWrap>
538
   </ContentWrap>
390
 
539
 
391
-  <Dialog v-model="dialogVisible" maxHeight="390px" width="35rem" :title="isedit">
540
+  <Dialog v-model="dialogVisible" maxHeight="580px" width="35rem" :title="isedit">
392
     <Form :schema="schema" @register="formRegister" />
541
     <Form :schema="schema" @register="formRegister" />
393
     <template #footer>
542
     <template #footer>
394
       <div style="width: 100%; display: flex; justify-content: center">
543
       <div style="width: 100%; display: flex; justify-content: center">