From 26fd822328b4bb39e3432ecc19767fcc98262a8a Mon Sep 17 00:00:00 2001 From: qingyu <14049064+qingyuya123@user.noreply.gitee.com> Date: Mon, 30 Jun 2025 11:05:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=A7=E5=93=81=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=86=85=E5=AE=B9--=E5=8A=9F=E8=83=BD=E7=89=B9?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/product/components/EditDialog.vue | 190 ++++++++++---------- src/views/product/index.vue | 21 ++- 2 files changed, 103 insertions(+), 108 deletions(-) diff --git a/src/views/product/components/EditDialog.vue b/src/views/product/components/EditDialog.vue index ba87c93..afb0e6e 100644 --- a/src/views/product/components/EditDialog.vue +++ b/src/views/product/components/EditDialog.vue @@ -11,18 +11,38 @@ - - - - - - +
- {{ item.categoryIDName }} + {{ item.categoryIDName }} - + 新增产品类别 +
+
+
+ + + + + + + + + + + + + + + + + +
+ + {{ item.targetName }} + + 新增产品适用对象类别
@@ -31,25 +51,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - - @@ -190,16 +171,41 @@ - + - + - + + + + + + + + + + + + + + + + + + + + @@ -245,12 +251,15 @@ const okText = ref(t('button.confirm')) const rolesValue = ref([]) const roles = ref([]) const imgUrl = ref('') -const areaList = ref([]) +const categoryList = ref([]) +const targetList = ref([]) const images = ref([]) const mainImage = ref([]) const contentImage = ref([]) const childOpen = ref(false) const formArea = ref({ name: '', status: 'enabled' }) +const categoryForm = ref({ name: '', status: 'enabled' }) +const targetForm = ref({ name: '', status: 'enabled' }) formRules.value = { title: { required: true, message: '请输入产品类别名称' }, code: { required: true, message: '请输入产品名称' }, @@ -267,52 +276,33 @@ formRules.value = { } const areaFormRules = { categoryIDName: [{ required: true, message: '请输入产品类别' }], - // targetName: [{ required: true, message: '请输入产品适用对象' }], + targetName: [{ required: true, message: '请输入产品适用对象' }], status: [{ required: true, message: '请选择状态', trigger: 'change' }], } -const initDataBatch = async (configs) => { +const initData = async () => { try { - showSpining() - const responses = await Promise.all( - configs.map(({ apiFunc }) => apiFunc({ pageSize: 999, page: 1 })) - ) - configs.forEach(({ nameKey, resultKey }, index) => { - const { success, data } = responses[index] + showSpining(); - if (config('http.code.success') === success) { - const mapped = data.map(item => { - return { - value: item.value, - children:item.children, - [resultKey]: item.label,// e.g. item['label'] - } - }) + const { success: catSuccess, data: catData } = await apis.products.getProductCategory({ pageSize: 999, page: 1 }); + if (config('http.code.success') === catSuccess) { + categoryList.value = catData + .filter(item => item.status === 'enabled') + .map(item => ({ code: item.id, name: item.name })); + } - areaList.value = [...areaList.value, ...mapped] - console.log(areaList.value) - console.log('after merge:', areaList.value) - } - }) + const { success: prodSuccess, data: prodData } = await apis.products.getProductObj({ pageSize: 999, page: 1 }); + if (config('http.code.success') === prodSuccess) { + targetList.value = prodData + .filter(item => item.status === 'enabled') + .map(item => ({ code: item.id, name: item.name })); + } } catch (error) { - message.error({ content: error.message }) + message.error({ content: error.message }); } finally { - hideSpining() + hideSpining(); } } -initDataBatch([ - { - apiFunc: apis.products.getProductCategory, - nameKey: 'name', - resultKey: 'categoryIDName' - }, - // { - // apiFunc: apis.products.getProductObj, - // nameKey: 'name', - // resultKey: 'targetName' - // } -]) - /** * 新建 */ @@ -329,9 +319,9 @@ function handleCreate() { target: '', feature: [{ label:'功能特点', - data:[{ - msg:[''], - }] + data:[ + // { msg:[''], } + ] }], standard: [{ label: '', @@ -361,11 +351,11 @@ function handleCreate() { const childHandleOk = async () => { areaFormRef.value.validateFields().then(async (values) => { try { - const params = { ...formArea.value } + const params = { ...categoryForm.value } const { success } = await apis.products.createProductCategory(params) if (success) message.success('新增成功') childOpen.value = false - formArea.value = { categoryIDName: '', status: 'enabled' } + categoryForm.value = { categoryIDName: '', status: 'enabled' } initData() } catch (error) { message.error(error.message) @@ -376,11 +366,11 @@ const childHandleOk = async () => { const childHandleObjOk = async () => { areaFormRef.value.validateFields().then(async (values) => { try { - const params = { ...formArea.value } + const params = { ...targetForm.value } const { success } = await apis.products.createProductObj(params) if (success) message.success('新增成功') childOpen.value = false - formArea.value = { targetName: '', status: 'enabled' } + targetForm.value = { targetName: '', status: 'enabled' } initData() } catch (error) { message.error(error.message) @@ -414,9 +404,9 @@ async function handleEdit(record = {}) { }], feature:data.feature|| [{ label:'功能特点', - data:[{ - msg:[''], - }] + data:[ + // {msg:[''],} + ] }], // images:data.images || [''], mainImage: data.images?[config('http.apiBasic')+data.images[0]]:[''], @@ -447,9 +437,9 @@ function handleOk() { }], feature:formData.value.feature|| [{ label:'功能特点', - data:[{ - msg:[''], - }] + data:[ + // { msg:[''], } + ] }], images: [ ...(Array.isArray(formData.value.mainImage) diff --git a/src/views/product/index.vue b/src/views/product/index.vue index 44b1f38..618f23c 100644 --- a/src/views/product/index.vue +++ b/src/views/product/index.vue @@ -60,17 +60,21 @@
{{ record.categoryID }}
- - + + @@ -121,9 +125,10 @@ const { t } = useI18n() // 解构出t方法 const columns = [ { title: '产品名称', dataIndex: 'code', width: 120 }, { title: '产品类别名称', dataIndex: 'title', width: 120 }, - { title: '产品类别', dataIndex: 'categoryID', key: 'categoryID', width: 120 }, - { title: '原料组成', dataIndex: 'compose', key: 'compose', width: 120 }, + { title: '产品类别ID', dataIndex: 'categoryID', key: 'categoryID', width: 120 }, { title: '适用对象', dataIndex: 'target', width: 120 }, + { title: '产品适用类别ID', dataIndex: 'CategoryRootID', key: 'CategoryRootID', width: 120 }, + { title: '原料组成', dataIndex: 'compose', key: 'compose', width: 120 }, { title: '功能特点', dataIndex: 'feature',