fix(custom): 修复上传组件上传失败以及补全商户分类icon
This commit is contained in:
@@ -24,6 +24,9 @@
|
||||
aria-modal="true"
|
||||
>
|
||||
<n-form ref="formRef" label-placement="left" :model="formValue" :rules="rules">
|
||||
<n-form-item label="分类图标:" path="icon">
|
||||
<Upload v-model:list="formValue.icon" />
|
||||
</n-form-item>
|
||||
<n-form-item label="分类名称:" path="name">
|
||||
<n-input v-model:value="formValue.name" placeholder="请输入商户分类名称" />
|
||||
</n-form-item>
|
||||
@@ -53,6 +56,8 @@
|
||||
import { onMounted, h, withDirectives, resolveDirective } from 'vue'
|
||||
import api from './api'
|
||||
import { NButton } from 'naive-ui'
|
||||
import Upload from '@/components/Upload.vue'
|
||||
|
||||
const vPerms = resolveDirective('perms')
|
||||
|
||||
const loading = ref(false)
|
||||
@@ -93,7 +98,19 @@ const columns = ref([
|
||||
type: 'primary',
|
||||
size: 'small',
|
||||
onClick: () => {
|
||||
formValue.value = row
|
||||
formValue.value = {
|
||||
...row,
|
||||
icon:
|
||||
row.icon.length > 0
|
||||
? [
|
||||
{
|
||||
url: row.icon,
|
||||
name: '图片',
|
||||
status: 'finished',
|
||||
},
|
||||
]
|
||||
: [],
|
||||
}
|
||||
handleAdd(2)
|
||||
},
|
||||
},
|
||||
@@ -115,12 +132,18 @@ const rules = {
|
||||
required: true,
|
||||
message: '请输入商户分类名称',
|
||||
},
|
||||
icon: {
|
||||
required: true,
|
||||
type: 'array',
|
||||
message: '请上传分类图标',
|
||||
},
|
||||
}
|
||||
|
||||
const formValue = ref({
|
||||
ID: 0,
|
||||
name: '',
|
||||
status: 1,
|
||||
icon: [],
|
||||
})
|
||||
|
||||
const showModal = ref(false)
|
||||
@@ -171,6 +194,7 @@ const clear = () => {
|
||||
ID: 0,
|
||||
name: '',
|
||||
status: 1,
|
||||
icon: [],
|
||||
}
|
||||
showModal.value = false
|
||||
}
|
||||
@@ -180,7 +204,10 @@ const handleValidateClick = async (e) => {
|
||||
formRef.value?.validate(async (errors) => {
|
||||
if (!errors) {
|
||||
try {
|
||||
await api.addClass(formValue.value)
|
||||
await api.addClass({
|
||||
...formValue.value,
|
||||
icon: formValue.value.icon[0].url,
|
||||
})
|
||||
$message.success('成功')
|
||||
clear()
|
||||
getList()
|
||||
|
||||
Reference in New Issue
Block a user