generated from Leo_Ding/web-template
修改产品部分内容
This commit is contained in:
parent
ad849ad26a
commit
564de084a4
@ -2,14 +2,14 @@
|
|||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<a-upload list-type="picture-card" :multiple="multiple" v-model:file-list="fileList" @preview="handlePreview"
|
<a-upload list-type="picture-card" :multiple="multiple" v-model:file-list="fileList" @preview="handlePreview"
|
||||||
@change="handleChange" :customRequest="handleCustomRequest" :beforeUpload="beforeUpload">
|
@change="handleChange" :customRequest="handleCustomRequest" :beforeUpload="beforeUpload">
|
||||||
<div v-if="fileList.length < fileNumber" >
|
<div v-if="fileList.length < fileNumber">
|
||||||
<plus-outlined />
|
<plus-outlined />
|
||||||
<div class="ant-upload-text">上传</div>
|
<div class="ant-upload-text">上传</div>
|
||||||
</div>
|
</div>
|
||||||
</a-upload>
|
</a-upload>
|
||||||
<a-modal :open="previewVisible" :footer="null" @cancel="handleCancel">
|
<a-modal :open="previewVisible" :footer="null" @cancel="handleCancel">
|
||||||
<img alt="example" v-if="fileType==='img'" style="width: 100%" :src="previewImage" />
|
<img alt="example" v-if="fileType === 'img'" style="width: 100%" :src="previewImage" />
|
||||||
<video v-if="fileType==='video'" :src="previewImage" controls autoplay loop muted ></video>
|
<video v-if="fileType === 'video'" :src="previewImage" controls autoplay loop muted></video>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -25,7 +25,7 @@ import apis from '@/apis'
|
|||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'GxUpload',
|
name: 'GxUpload',
|
||||||
})
|
})
|
||||||
const fileType=ref('img')
|
const fileType = ref('img')
|
||||||
const previewVisible = ref(false)
|
const previewVisible = ref(false)
|
||||||
const previewImage = ref('')
|
const previewImage = ref('')
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -90,10 +90,10 @@ const getBase64 = (file) => {
|
|||||||
}
|
}
|
||||||
const handlePreview = async (file) => {
|
const handlePreview = async (file) => {
|
||||||
console.log(file.name)
|
console.log(file.name)
|
||||||
const list=['.avi','.mp4','.mov','.wmv','.mkv','.m4v']
|
const list = ['.avi', '.mp4', '.mov', '.wmv', '.mkv', '.m4v']
|
||||||
const fileSuffix=file.name.substring(file.name.lastIndexOf('.'))
|
const fileSuffix = file.name.substring(file.name.lastIndexOf('.'))
|
||||||
if(list.includes(fileSuffix)){
|
if (list.includes(fileSuffix)) {
|
||||||
fileType.value='video'
|
fileType.value = 'video'
|
||||||
}
|
}
|
||||||
if (!file.url && !file.preview) {
|
if (!file.url && !file.preview) {
|
||||||
file.preview = await getBase64(file.originFileObj)
|
file.preview = await getBase64(file.originFileObj)
|
||||||
@ -106,6 +106,9 @@ const handlePreview = async (file) => {
|
|||||||
|
|
||||||
// 修改handleChange方法
|
// 修改handleChange方法
|
||||||
const handleChange = ({ file, fileList: updatedList }) => {
|
const handleChange = ({ file, fileList: updatedList }) => {
|
||||||
|
console.log(111)
|
||||||
|
console.log(file.status)
|
||||||
|
console.log(updatedList)
|
||||||
// 处理上传成功的情况
|
// 处理上传成功的情况
|
||||||
if (file.status === 'done') {
|
if (file.status === 'done') {
|
||||||
const response = file.response;
|
const response = file.response;
|
||||||
@ -123,6 +126,12 @@ const handleChange = ({ file, fileList: updatedList }) => {
|
|||||||
.map(item => item.url);
|
.map(item => item.url);
|
||||||
emit('update:modelValue', urls);
|
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') {
|
} else if (file.status === 'error') {
|
||||||
message.error(`${file.name} 上传失败`);
|
message.error(`${file.name} 上传失败`);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import UploadVideo from './Upload/UploadVideo.vue'
|
|||||||
import UploadInput from './Upload/UploadInput.vue'
|
import UploadInput from './Upload/UploadInput.vue'
|
||||||
import Scrollbar from './Scrollbar/Scrollbar.vue'
|
import Scrollbar from './Scrollbar/Scrollbar.vue'
|
||||||
import Cascader from './Cascader/Cascader.vue'
|
import Cascader from './Cascader/Cascader.vue'
|
||||||
|
import GxUpload from './GxUpload/index.vue'
|
||||||
import { setupLoadingDirective } from './Loading/directive'
|
import { setupLoadingDirective } from './Loading/directive'
|
||||||
|
|
||||||
const componentList = [
|
const componentList = [
|
||||||
@ -43,6 +44,7 @@ const componentList = [
|
|||||||
UploadInput,
|
UploadInput,
|
||||||
Scrollbar,
|
Scrollbar,
|
||||||
Cascader,
|
Cascader,
|
||||||
|
GxUpload,
|
||||||
]
|
]
|
||||||
|
|
||||||
export const loading = Loading
|
export const loading = Loading
|
||||||
|
|||||||
@ -262,7 +262,7 @@ const handlePreview = (videoUrl) => {
|
|||||||
ElMessage.error('视频地址无效')
|
ElMessage.error('视频地址无效')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
currentVideoUrl.value = videoUrl
|
currentVideoUrl.value = config('http.apiBasic') + videoUrl
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,12 +6,18 @@
|
|||||||
<a-card class="mb-8-2">
|
<a-card class="mb-8-2">
|
||||||
<a-row :gutter="12">
|
<a-row :gutter="12">
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'产品名称'" name="title">
|
<a-form-item :label="'产品名称'" name="code">
|
||||||
<a-input :placeholder="'请输入产品名称'" v-model:value="formData.title"></a-input>
|
<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-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'产品类别'" name="categoryID">
|
<a-form-item :label="'产品类别'" name="categoryID">
|
||||||
|
<!-- <a-input :placeholder="'请输入产品类别名称'" v-model:value="formData.categoryID"></a-input>-->
|
||||||
<div style="display: flex;justify-content: space-between;">
|
<div style="display: flex;justify-content: space-between;">
|
||||||
<a-select v-model:value="formData.categoryID" allowClear>
|
<a-select v-model:value="formData.categoryID" allowClear>
|
||||||
<a-select-option v-for="item in areaList" :value="item.code">{{ item.categoryIDName }}</a-select-option>
|
<a-select-option v-for="item in areaList" :value="item.code">{{ item.categoryIDName }}</a-select-option>
|
||||||
@ -22,34 +28,40 @@
|
|||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'原料组成'" name="compose">
|
<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-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'适用对象'" name="target">
|
<a-form-item :label="'适用对象'" name="target">
|
||||||
<div style="display: flex;justify-content: space-between;">
|
<a-input :placeholder="'请输入适用对象'" v-model:value="formData.target"></a-input>
|
||||||
<a-select v-model:value="formData.target" allowClear>
|
<!-- <div style="display: flex;justify-content: space-between;">-->
|
||||||
<a-select-option v-for="item in areaList" :value="item.code">{{ item.targetName }}</a-select-option>
|
<!-- <a-select v-model:value="formData.target" allowClear>-->
|
||||||
</a-select>
|
<!-- <a-select-option v-for="item in areaList" :value="item.code">{{ item.targetName }}</a-select-option>-->
|
||||||
<a-button type="primary" @click="childOpen = true">新增适用对象</a-button>
|
<!-- </a-select>-->
|
||||||
</div>
|
<!--<!– <a-button type="primary" @click="childOpen = true">新增适用对象</a-button>–>-->
|
||||||
|
<!-- </div>-->
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<!-- <a-form-item :label="'适用对象'" name="target">-->
|
<!-- <a-form-item :label="'适用对象'" name="target">-->
|
||||||
<!-- <a-textarea :placeholder="'请输入岗位职责'" v-model:value="formData.target"></a-textarea>-->
|
<!-- <a-textarea :placeholder="'请输入岗位职责'" v-model:value="formData.target"></a-textarea>-->
|
||||||
<!-- </a-form-item>-->
|
<!-- </a-form-item>-->
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'功能特点'" name="feature">
|
<a-form-item :label="'原料组成'" name="feature">
|
||||||
<a-select
|
<a-textarea :placeholder="'请输入原料组成'" v-model:value="formData.feature"></a-textarea>
|
||||||
v-model:value="formData.feature"
|
|
||||||
mode="tags"
|
|
||||||
:placeholder="'请输入功能特点,按回车分隔'"
|
|
||||||
:token-separators="[',']"
|
|
||||||
style="width: 100%;"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
</a-col>
|
</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-col :span="24">
|
||||||
<a-form-item
|
<a-form-item
|
||||||
v-for="(item, index) in formData.standard"
|
v-for="(item, index) in formData.standard"
|
||||||
@ -84,15 +96,10 @@
|
|||||||
</a-col>
|
</a-col>
|
||||||
|
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item v-for="(img, index) in formData.images" :key="index" :label="`产品图片 ${index + 1}`">
|
<a-form-item :label="'产品图片'" name="images">
|
||||||
<x-upload-image v-model="formData.images[index]" @imgChange="(value) => imgChange(index, value)" />
|
<gx-upload v-model="formData.images" accept-types=".jpg,.png,.webp" :fileNumber="2" />
|
||||||
<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>
|
</a-form-item>
|
||||||
|
|
||||||
</a-col>
|
</a-col>
|
||||||
|
|
||||||
|
|
||||||
@ -171,10 +178,12 @@ const areaList = ref([])
|
|||||||
const childOpen = ref(false)
|
const childOpen = ref(false)
|
||||||
const formArea = ref({ name: '', status: 'enabled' })
|
const formArea = ref({ name: '', status: 'enabled' })
|
||||||
formRules.value = {
|
formRules.value = {
|
||||||
title: { required: true, message: '请输入产品名称' },
|
title: { required: true, message: '请输入产品类别名称' },
|
||||||
|
code: { required: true, message: '请输入产品名称' },
|
||||||
categoryID: { required: true, message: '请选择产品类别', trigger: 'change' },
|
categoryID: { required: true, message: '请选择产品类别', trigger: 'change' },
|
||||||
compose: { 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: '请输入产品标准' }],
|
standard: [{ required: true, message: '请输入产品标准' }],
|
||||||
images: [{ required: true, message: '请上传产品图片' }],
|
images: [{ required: true, message: '请上传产品图片' }],
|
||||||
sequence: [{ required: true, message: '请输入产品排序' }],
|
sequence: [{ required: true, message: '请输入产品排序' }],
|
||||||
@ -182,7 +191,7 @@ formRules.value = {
|
|||||||
}
|
}
|
||||||
const areaFormRules = {
|
const areaFormRules = {
|
||||||
categoryIDName: [{ required: true, message: '请输入产品类别' }],
|
categoryIDName: [{ required: true, message: '请输入产品类别' }],
|
||||||
targetName: [{ required: true, message: '请输入产品适用对象' }],
|
// targetName: [{ required: true, message: '请输入产品适用对象' }],
|
||||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||||
}
|
}
|
||||||
const initDataBatch = async (configs) => {
|
const initDataBatch = async (configs) => {
|
||||||
@ -218,11 +227,11 @@ initDataBatch([
|
|||||||
nameKey: 'name',
|
nameKey: 'name',
|
||||||
resultKey: 'categoryIDName'
|
resultKey: 'categoryIDName'
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
apiFunc: apis.products.getProductObj,
|
// apiFunc: apis.products.getProductObj,
|
||||||
nameKey: 'name',
|
// nameKey: 'name',
|
||||||
resultKey: 'targetName'
|
// resultKey: 'targetName'
|
||||||
}
|
// }
|
||||||
])
|
])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -295,7 +304,11 @@ async function handleEdit(record = {}) {
|
|||||||
hideModal()
|
hideModal()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
formData.value = { ...data }
|
formData.value = {
|
||||||
|
...data,
|
||||||
|
standard:data.standard||[{ label: '', value: '' }],
|
||||||
|
images:data.images || ['']
|
||||||
|
}
|
||||||
imgUrl.value = config('http.apiBasic') + data.img
|
imgUrl.value = config('http.apiBasic') + data.img
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,14 +316,15 @@ async function handleEdit(record = {}) {
|
|||||||
* 确定
|
* 确定
|
||||||
*/
|
*/
|
||||||
function handleOk() {
|
function handleOk() {
|
||||||
|
console.log(formData.value)
|
||||||
formRef.value.validateFields().then(async (values) => {
|
formRef.value.validateFields().then(async (values) => {
|
||||||
try {
|
try {
|
||||||
showLoading()
|
showLoading()
|
||||||
const params = {
|
const params = {
|
||||||
...values,
|
...values,
|
||||||
img: formData.value.img,
|
sequence:'1',
|
||||||
pushAt: dayjs().format('YYYY-MM-DD'),
|
standard:formData.value.standard||[{ label: '', value: '' }],
|
||||||
type: 'news'
|
|
||||||
}
|
}
|
||||||
let result = null
|
let result = null
|
||||||
switch (modal.value.type) {
|
switch (modal.value.type) {
|
||||||
@ -374,16 +388,7 @@ function removeStandard(index) {
|
|||||||
formData.value.standard.splice(index, 1)
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
@ -4,10 +4,15 @@
|
|||||||
<a-form :model="searchFormData" layout="inline">
|
<a-form :model="searchFormData" layout="inline">
|
||||||
<a-row :gutter="gutter">
|
<a-row :gutter="gutter">
|
||||||
<a-col v-bind="colSpan">
|
<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-input placeholder="请输入产品名称" v-model:value="searchFormData.title"></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</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-col v-bind="colSpan">
|
||||||
<a-form-item label="状态" name="status">
|
<a-form-item label="状态" name="status">
|
||||||
@ -108,7 +113,8 @@ defineOptions({
|
|||||||
})
|
})
|
||||||
const { t } = useI18n() // 解构出t方法
|
const { t } = useI18n() // 解构出t方法
|
||||||
const columns = [
|
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: 'categoryID', key: 'categoryID', width: 120 },
|
||||||
{ title: '原料组成', dataIndex: 'compose', key: 'compose', width: 120 },
|
{ title: '原料组成', dataIndex: 'compose', key: 'compose', width: 120 },
|
||||||
{ title: '适用对象', dataIndex: 'target', width: 120 },
|
{ title: '适用对象', dataIndex: 'target', width: 120 },
|
||||||
@ -118,7 +124,7 @@ const columns = [
|
|||||||
dataIndex: 'feature',
|
dataIndex: 'feature',
|
||||||
width: 120,
|
width: 120,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
customRender: ({ text }) => Array.isArray(text) ? text.join(', ') : ''
|
// customRender: ({ text }) => Array.isArray(text) ? text.join(', ') : ''
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@ -91,6 +91,7 @@ const reportNum = ref(null)
|
|||||||
const socialMedia = ref([{ name: '', image: '', link: '' }])
|
const socialMedia = ref([{ name: '', image: '', link: '' }])
|
||||||
const imgChange = (index, value) => {
|
const imgChange = (index, value) => {
|
||||||
socialMedia.value[index].image = value
|
socialMedia.value[index].image = value
|
||||||
|
reportImage.value = value
|
||||||
}
|
}
|
||||||
// 页面加载时获取声明内容
|
// 页面加载时获取声明内容
|
||||||
getPageList()
|
getPageList()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user