This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<n-button v-perms="['/admin/store/classify/edit']" type="primary" @click="handleAdd(1)">
|
||||
新增商户分类
|
||||
</n-button>
|
||||
<!-- {{ formValue }} -->
|
||||
|
||||
<n-data-table
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
@@ -23,7 +23,15 @@
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
>
|
||||
<!-- {{ formValue }} -->
|
||||
<n-form ref="formRef" label-placement="left" :model="formValue" :rules="rules">
|
||||
<n-form-item label="上级分类:" path="sid">
|
||||
<n-select
|
||||
v-model:value="formValue.sid"
|
||||
:options="options"
|
||||
placeholder="请选择上级分类"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="分类图标:" path="icon">
|
||||
<Upload v-model:list="formValue.icon" />
|
||||
</n-form-item>
|
||||
@@ -123,6 +131,8 @@ const columns = ref([
|
||||
},
|
||||
])
|
||||
|
||||
const options = ref([])
|
||||
|
||||
const data = ref([])
|
||||
|
||||
const formRef = ref(null)
|
||||
@@ -137,10 +147,15 @@ const rules = {
|
||||
type: 'array',
|
||||
message: '请上传分类图标',
|
||||
},
|
||||
sid: {
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择分类',
|
||||
},
|
||||
}
|
||||
|
||||
const formValue = ref({
|
||||
ID: 0,
|
||||
sid: null,
|
||||
name: '',
|
||||
status: 1,
|
||||
icon: [],
|
||||
@@ -165,6 +180,7 @@ const pagination = ref({
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
getOptions()
|
||||
})
|
||||
|
||||
const getList = async () => {
|
||||
@@ -182,6 +198,25 @@ const getList = async () => {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const getOptions = async () => {
|
||||
const res = await api.getList({
|
||||
pageNum: 1,
|
||||
pageSize: 9999999999,
|
||||
})
|
||||
options.value = [
|
||||
{
|
||||
label: '顶级分类',
|
||||
value: 0,
|
||||
},
|
||||
]
|
||||
res.data.data.forEach((item) => {
|
||||
options.value.push({
|
||||
label: item.name,
|
||||
value: item.ID,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const modelTitle = ref('')
|
||||
|
||||
const handleAdd = (e) => {
|
||||
@@ -191,7 +226,7 @@ const handleAdd = (e) => {
|
||||
|
||||
const clear = () => {
|
||||
formValue.value = {
|
||||
ID: 0,
|
||||
sid: 0,
|
||||
name: '',
|
||||
status: 1,
|
||||
icon: [],
|
||||
@@ -204,6 +239,7 @@ const handleValidateClick = async (e) => {
|
||||
formRef.value?.validate(async (errors) => {
|
||||
if (!errors) {
|
||||
try {
|
||||
console.log(formValue.value)
|
||||
await api.addClass({
|
||||
...formValue.value,
|
||||
icon: formValue.value.icon[0].url,
|
||||
@@ -211,6 +247,7 @@ const handleValidateClick = async (e) => {
|
||||
$message.success('成功')
|
||||
clear()
|
||||
getList()
|
||||
getOptions()
|
||||
} catch (error) {
|
||||
$message.error(error.msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user