From c80ec21465b160251bfeba98977765e14ffaed3d Mon Sep 17 00:00:00 2001
From: qingyu <14049064+qingyuya123@user.noreply.gitee.com>
Date: Sat, 28 Jun 2025 15:12:12 +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?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/product/components/EditDialog.vue | 163 ++++++++++++++------
src/views/product/index.vue | 38 +++--
2 files changed, 142 insertions(+), 59 deletions(-)
diff --git a/src/views/product/components/EditDialog.vue b/src/views/product/components/EditDialog.vue
index d77387d..0a64306 100644
--- a/src/views/product/components/EditDialog.vue
+++ b/src/views/product/components/EditDialog.vue
@@ -20,9 +20,9 @@
- {{ item.categoryIDName }}
+ {{ item.value }}
-
新增产品类别
+
@@ -45,23 +45,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
@@ -95,12 +107,31 @@
-
-
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -175,6 +206,7 @@ const rolesValue = ref([])
const roles = ref([])
const imgUrl = ref('')
const areaList = ref([])
+const images = ref([])
const childOpen = ref(false)
const formArea = ref({ name: '', status: 'enabled' })
formRules.value = {
@@ -182,10 +214,12 @@ formRules.value = {
code: { required: true, message: '请输入产品名称' },
categoryID: { required: true, message: '请选择产品类别', trigger: 'change' },
compose: { required: true, message: '请选择产品适用对象', trigger: 'change' },
- feature: { required: true, message: '请输入产品功能特点', trigger: 'change' },
+ feature: [{ required: true, message: '请输入产品功能特点', trigger: 'change' }],
// feature: [{ required: true, message: '请输入产品功能特点' }],
standard: [{ required: true, message: '请输入产品标准' }],
images: [{ required: true, message: '请上传产品图片' }],
+ mainImage: { required: true, message: '请上传产品图片' },
+ contentImage: { required: true, message: '请上传产品内容图片' },
sequence: [{ required: true, message: '请输入产品排序' }],
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
}
@@ -200,21 +234,23 @@ const initDataBatch = async (configs) => {
const responses = await Promise.all(
configs.map(({ apiFunc }) => apiFunc({ pageSize: 999, page: 1 }))
)
-
configs.forEach(({ nameKey, resultKey }, index) => {
const { success, data } = responses[index]
+
if (config('http.code.success') === success) {
- areaList.value = [
- ...areaList.value,
- ...data
- .filter(item => item.status === 'enabled')
- .map(item => ({
- code: item.id,
- [resultKey]: item[nameKey],
- }))
- ]
+ const mapped = data.map(item => {
+ return {
+ value: item.value,
+ children:item.children,
+ [resultKey]: item.label,// e.g. item['label']
+ }
+ })
+
+ areaList.value = [...areaList.value, ...mapped]
+ console.log('after merge:', areaList.value)
}
})
+
} catch (error) {
message.error({ content: error.message })
} finally {
@@ -249,10 +285,26 @@ function handleCreate() {
compose: '',
target: '',
feature: [],
- standard: [{ label: '', value: '' }],
- images: [''],
- sequence: 1,
- status: 'enabled'
+ standard: [{
+ label: '',
+ val: '' ,
+ fu_hoao: '' ,
+ prx: '' ,
+ }],
+ images: [
+ ...(Array.isArray(formData.value.mainImage)
+ ? formData.value.mainImage
+ : [formData.value.mainImage]
+ ).filter(Boolean).map(item => String(item)),
+
+ ...(Array.isArray(formData.value.contentImage)
+ ? formData.value.contentImage
+ : [formData.value.contentImage]
+ ).filter(Boolean).map(item => String(item))
+ ],
+
+ sequence: null,
+ status: 'enabled',
}
initData()
}
@@ -306,25 +358,48 @@ async function handleEdit(record = {}) {
}
formData.value = {
...data,
- standard:data.standard||[{ label: '', value: '' }],
- images:data.images || ['']
+ standard:data.standard|| [{
+ label: '',
+ val: '' ,
+ fu_hoao: '' ,
+ prx: '' ,
+ }],
+ // images:data.images || [''],
+ mainImage: data.images?.[0] || '',
+ contentImage: data.images?.[1] || '',
}
imgUrl.value = config('http.apiBasic') + data.img
+ console.log('编辑产品数据:',formData.value);
}
/**
* 确定
*/
function handleOk() {
- console.log(formData.value)
+ console.log('编辑产品列表', formData.value)
formRef.value.validateFields().then(async (values) => {
try {
showLoading()
const params = {
...values,
- sequence:'1',
- standard:formData.value.standard||[{ label: '', value: '' }],
+ standard:formData.value.standard||
+ [{
+ label: '',
+ val: '' ,
+ fu_hoao: '' ,
+ prx: '' ,
+ }],
+ images: [
+ ...(Array.isArray(formData.value.mainImage)
+ ? formData.value.mainImage
+ : [formData.value.mainImage]
+ ).filter(Boolean).map(item => String(item)),
+ ...(Array.isArray(formData.value.contentImage)
+ ? formData.value.contentImage
+ : [formData.value.contentImage]
+ ).filter(Boolean).map(item => String(item))
+ ],
}
let result = null
switch (modal.value.type) {
diff --git a/src/views/product/index.vue b/src/views/product/index.vue
index d6d130b..44b1f38 100644
--- a/src/views/product/index.vue
+++ b/src/views/product/index.vue
@@ -71,6 +71,12 @@
{{ record.target }}
+
+
+
+
+
+
启用
停用
@@ -118,44 +124,39 @@ const columns = [
{ title: '产品类别', dataIndex: 'categoryID', key: 'categoryID', width: 120 },
{ title: '原料组成', dataIndex: 'compose', key: 'compose', width: 120 },
{ title: '适用对象', dataIndex: 'target', width: 120 },
-
{
title: '功能特点',
dataIndex: 'feature',
width: 120,
align: 'center',
- // customRender: ({ text }) => Array.isArray(text) ? text.join(', ') : ''
+ customRender: ({ text }) => Array.isArray(text) ? text.join(', ') : ''
},
-
{
title: '产品标准',
dataIndex: 'standard',
width: 120,
align: 'center',
customRender: ({ text }) => Array.isArray(text)
- ? text.map(item => `${item.label}: ${item.value}`).join(', ')
+ ? text.map(item => `${item.label}: ${item.fu_hoao}${item.val}${item.prx}`).join(', ')
: ''
},
-
{
title: '产品图片',
- dataIndex: 'images',
+ dataIndex: 'mainImage',
+ width: 120,
+ align: 'center',
+ },
+ {
+ title: '产品内容图片',
+ dataIndex: 'contentImage',
width: 120,
align: 'center',
- customRender: ({ text }) => {
- if (Array.isArray(text) && text.length > 0) {
- return `
`
- }
- return '-'
- }
},
{ title: '产品排序', dataIndex: 'sequence', width: 120, align: 'center' },
{ title: '产品状态', dataIndex: 'status', width: 120, align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
]
-
-
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
usePagination()
@@ -180,7 +181,14 @@ async function getPageList() {
})
hideLoading()
if (config('http.code.success') === success) {
- listData.value = data
+ listData.value = data.map(item => ({
+ ...item,
+ mainImage: item.images?.[0] || '',
+ contentImage: item.images?.[1] || '',
+ }))
+
+ console.log('接口数据', data)
+ console.log('接口过滤数据', listData.value)
paginationState.total = total
}
} catch (error) {