From 0865529e1085836696bb0d26ce23b959b46fb7d0 Mon Sep 17 00:00:00 2001 From: Huakk <1751826683@qq.com> Date: Wed, 29 May 2024 16:09:35 +0800 Subject: [PATCH] feat(custom): --- src/views/business/mer_class/index.vue | 43 ++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/views/business/mer_class/index.vue b/src/views/business/mer_class/index.vue index 9356609..70db7f4 100644 --- a/src/views/business/mer_class/index.vue +++ b/src/views/business/mer_class/index.vue @@ -3,7 +3,7 @@ 新增商户分类 - + + + + + @@ -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) }