Merge branch 'dev' into test
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-05-29 16:09:52 +08:00

View File

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