修改产品部分内容

This commit is contained in:
qingyu 2025-06-28 10:52:56 +08:00
parent ad849ad26a
commit 564de084a4
6 changed files with 85 additions and 62 deletions

View File

@ -106,6 +106,9 @@ const handlePreview = async (file) => {
// handleChange
const handleChange = ({ file, fileList: updatedList }) => {
console.log(111)
console.log(file.status)
console.log(updatedList)
//
if (file.status === 'done') {
const response = file.response;
@ -123,6 +126,12 @@ const handleChange = ({ file, fileList: updatedList }) => {
.map(item => item.url);
emit('update:modelValue', urls);
}
} else if (file.status === 'removed') {
//
const urls = updatedList
.filter(item => item.status === 'done')
.map(item => item.url);
emit('update:modelValue', urls);
} else if (file.status === 'error') {
message.error(`${file.name} 上传失败`);
}

View File

@ -20,6 +20,7 @@ import UploadVideo from './Upload/UploadVideo.vue'
import UploadInput from './Upload/UploadInput.vue'
import Scrollbar from './Scrollbar/Scrollbar.vue'
import Cascader from './Cascader/Cascader.vue'
import GxUpload from './GxUpload/index.vue'
import { setupLoadingDirective } from './Loading/directive'
const componentList = [
@ -43,6 +44,7 @@ const componentList = [
UploadInput,
Scrollbar,
Cascader,
GxUpload,
]
export const loading = Loading

View File

@ -262,7 +262,7 @@ const handlePreview = (videoUrl) => {
ElMessage.error('视频地址无效')
return
}
currentVideoUrl.value = videoUrl
currentVideoUrl.value = config('http.apiBasic') + videoUrl
dialogVisible.value = true
}

View File

@ -6,12 +6,18 @@
<a-card class="mb-8-2">
<a-row :gutter="12">
<a-col :span="24">
<a-form-item :label="'产品名称'" name="title">
<a-input :placeholder="'请输入产品名称'" v-model:value="formData.title"></a-input>
<a-form-item :label="'产品名称'" name="code">
<a-input :placeholder="'请输入产品名称'" v-model:value="formData.code"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'产品类别名称'" name="title">
<a-input :placeholder="'请输入产品类别名称'" v-model:value="formData.title"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'产品类别'" name="categoryID">
<!-- <a-input :placeholder="'请输入产品类别名称'" v-model:value="formData.categoryID"></a-input>-->
<div style="display: flex;justify-content: space-between;">
<a-select v-model:value="formData.categoryID" allowClear>
<a-select-option v-for="item in areaList" :value="item.code">{{ item.categoryIDName }}</a-select-option>
@ -22,34 +28,40 @@
</a-col>
<a-col :span="24">
<a-form-item :label="'原料组成'" name="compose">
<a-textarea :placeholder="'请输入岗位要求'" v-model:value="formData.compose"></a-textarea>
<a-textarea :placeholder="'请输入原料组成'" v-model:value="formData.compose"></a-textarea>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'适用对象'" name="target">
<div style="display: flex;justify-content: space-between;">
<a-select v-model:value="formData.target" allowClear>
<a-select-option v-for="item in areaList" :value="item.code">{{ item.targetName }}</a-select-option>
</a-select>
<a-button type="primary" @click="childOpen = true">新增适用对象</a-button>
</div>
<a-input :placeholder="'请输入适用对象'" v-model:value="formData.target"></a-input>
<!-- <div style="display: flex;justify-content: space-between;">-->
<!-- <a-select v-model:value="formData.target" allowClear>-->
<!-- <a-select-option v-for="item in areaList" :value="item.code">{{ item.targetName }}</a-select-option>-->
<!-- </a-select>-->
<!--&lt;!&ndash; <a-button type="primary" @click="childOpen = true">新增适用对象</a-button>&ndash;&gt;-->
<!-- </div>-->
</a-form-item>
<!-- <a-form-item :label="'适用对象'" name="target">-->
<!-- <a-textarea :placeholder="'请输入岗位职责'" v-model:value="formData.target"></a-textarea>-->
<!-- </a-form-item>-->
</a-col>
<a-col :span="24">
<a-form-item :label="'功能特点'" name="feature">
<a-select
v-model:value="formData.feature"
mode="tags"
:placeholder="'请输入功能特点,按回车分隔'"
:token-separators="[',']"
style="width: 100%;"
/>
<a-form-item :label="'原料组成'" name="feature">
<a-textarea :placeholder="'请输入原料组成'" v-model:value="formData.feature"></a-textarea>
</a-form-item>
</a-col>
<!-- <a-col :span="24">-->
<!-- <a-form-item :label="'功能特点'" name="feature">-->
<!-- <a-select-->
<!-- v-model:value="formData.feature"-->
<!-- mode="tags"-->
<!-- :placeholder="'请输入功能特点,按回车分隔'"-->
<!-- :token-separators="[',']"-->
<!-- style="width: 100%;"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </a-col>-->
<a-col :span="24">
<a-form-item
v-for="(item, index) in formData.standard"
@ -84,15 +96,10 @@
</a-col>
<a-col :span="24">
<a-form-item v-for="(img, index) in formData.images" :key="index" :label="`产品图片 ${index + 1}`">
<x-upload-image v-model="formData.images[index]" @imgChange="(value) => imgChange(index, value)" />
<a-button danger @click="removeImage(index)" size="small" style="margin: 10px 0" >删除</a-button>
</a-form-item>
<a-form-item>
<a-button type="dashed" block @click="addImage">
新增产品图片
</a-button>
<a-form-item :label="'产品图片'" name="images">
<gx-upload v-model="formData.images" accept-types=".jpg,.png,.webp" :fileNumber="2" />
</a-form-item>
</a-col>
@ -171,10 +178,12 @@ const areaList = ref([])
const childOpen = ref(false)
const formArea = ref({ name: '', status: 'enabled' })
formRules.value = {
title: { required: true, message: '请输入产品名称' },
title: { required: true, message: '请输入产品类别名称' },
code: { required: true, message: '请输入产品名称' },
categoryID: { required: true, message: '请选择产品类别', trigger: 'change' },
compose: { required: true, message: '请选择产品适用对象', trigger: 'change' },
feature: [{ required: true, message: '请输入产品功能特点' }],
feature: { required: true, message: '请输入产品功能特点', trigger: 'change' },
// feature: [{ required: true, message: '' }],
standard: [{ required: true, message: '请输入产品标准' }],
images: [{ required: true, message: '请上传产品图片' }],
sequence: [{ required: true, message: '请输入产品排序' }],
@ -182,7 +191,7 @@ 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) => {
@ -218,11 +227,11 @@ initDataBatch([
nameKey: 'name',
resultKey: 'categoryIDName'
},
{
apiFunc: apis.products.getProductObj,
nameKey: 'name',
resultKey: 'targetName'
}
// {
// apiFunc: apis.products.getProductObj,
// nameKey: 'name',
// resultKey: 'targetName'
// }
])
/**
@ -295,7 +304,11 @@ async function handleEdit(record = {}) {
hideModal()
return
}
formData.value = { ...data }
formData.value = {
...data,
standard:data.standard||[{ label: '', value: '' }],
images:data.images || ['']
}
imgUrl.value = config('http.apiBasic') + data.img
}
@ -303,14 +316,15 @@ async function handleEdit(record = {}) {
* 确定
*/
function handleOk() {
console.log(formData.value)
formRef.value.validateFields().then(async (values) => {
try {
showLoading()
const params = {
...values,
img: formData.value.img,
pushAt: dayjs().format('YYYY-MM-DD'),
type: 'news'
sequence:'1',
standard:formData.value.standard||[{ label: '', value: '' }],
}
let result = null
switch (modal.value.type) {
@ -374,16 +388,7 @@ function removeStandard(index) {
formData.value.standard.splice(index, 1)
}
}
//
function addImage() {
formData.value.images.push('')
}
//
function removeImage(index) {
if (formData.value.images.length > 1) {
formData.value.images.splice(index, 1)
}
}
</script>
<style lang="less" scoped>

View File

@ -4,10 +4,15 @@
<a-form :model="searchFormData" layout="inline">
<a-row :gutter="gutter">
<a-col v-bind="colSpan">
<a-form-item label="产品名称" name="title">
<a-form-item label="产品类别名称" name="title">
<a-input placeholder="请输入产品名称" v-model:value="searchFormData.title"></a-input>
</a-form-item>
</a-col>
<a-col v-bind="colSpan">
<a-form-item label="产品名称" name="code">
<a-input placeholder="请输入产品名称" v-model:value="searchFormData.code"></a-input>
</a-form-item>
</a-col>
<a-col v-bind="colSpan">
<a-form-item label="状态" name="status">
@ -108,7 +113,8 @@ defineOptions({
})
const { t } = useI18n() // t
const columns = [
{ title: '产品名称', dataIndex: 'title', width: 120 },
{ 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: '适用对象', dataIndex: 'target', width: 120 },
@ -118,7 +124,7 @@ const columns = [
dataIndex: 'feature',
width: 120,
align: 'center',
customRender: ({ text }) => Array.isArray(text) ? text.join(', ') : ''
// customRender: ({ text }) => Array.isArray(text) ? text.join(', ') : ''
},
{

View File

@ -91,6 +91,7 @@ const reportNum = ref(null)
const socialMedia = ref([{ name: '', image: '', link: '' }])
const imgChange = (index, value) => {
socialMedia.value[index].image = value
reportImage.value = value
}
//
getPageList()