Commit 6401a60d by cwq0219

编辑商品-描述

1 parent 03f30932
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="glsx-combi-form"> <div class="glsx-combi-form">
<el-form :ref="formRef" :inline="true" :model="formObj" :label-width="labelWidth" :rules="formRules" size="small" class="glsx-combi-form-block"> <el-form :ref="formRef" :inline="true" :model="formObj" :label-width="labelWidth" :rules="formRules" size="small" class="glsx-combi-form-block">
<template v-for="(item, index) in formData"> <template v-for="(item, index) in formData">
<el-form-item v-if="!item.isHide" :key="index" :class="{ 'no-label': !item.label, isBlock: isBlock }" :label="item.label ? item.label + ':' : ''" :prop="item.name"> <el-form-item v-if="!item.isHide" :key="index" :class="{ 'no-label': !item.label, isBlock: isBlock }" :style="{ ...item.style }" :label="item.label ? item.label + ':' : ''" :prop="item.name">
<span v-if="!item.isHide && item.tips" class="tips-block" slot="label"> <span v-if="!item.isHide && item.tips" class="tips-block" slot="label">
<span class="tips-label">{{ item.label }}</span> <span class="tips-label">{{ item.label }}</span>
<el-tooltip popper-class="tooltip-class" effect="dark" :content="item.tips" :placement="item.placement || 'top'"> <el-tooltip popper-class="tooltip-class" effect="dark" :content="item.tips" :placement="item.placement || 'top'">
......
...@@ -64,38 +64,38 @@ ...@@ -64,38 +64,38 @@
<div v-for="(item, index) in externalFormList" :key="index"> <div v-for="(item, index) in externalFormList" :key="index">
<p class="edit-sub-title">{{ item.title }}</p> <p class="edit-sub-title">{{ item.title }}</p>
<glsx-combi-form class="edit-form-container" ref="editFormRef" :labelWidth="labelWidth" :isBlock="true" :formRef="item.editChildRef" :formObj="editForm" :formData="item.editFormData" :formRules="item.editRule"> <glsx-combi-form class="edit-form-container" ref="editFormRef" :labelWidth="labelWidth" :isBlock="true" :formRef="item.editChildRef" :formObj="editForm" :formData="item.editFormData" :formRules="item.editRule">
<template slot="bannerBtn"> <template slot="describeBtn">
<el-button type="primary" @click="handleBannerAdd">新增banner</el-button> <el-button type="primary" @click="handleDescribeImgAdd">添加图片</el-button>
</template> </template>
<div :style="{ 'margin-left': labelWidth }" slot="bannerList" slot-scope="scope"> <div :style="{ 'margin-left': labelWidth }" slot="descImgs" slot-scope="scope">
<div v-for="(subItem, subIndex) in editForm[scope.scope.name]" :key="subIndex" class="flex"> <div v-for="(subItem, subIndex) in editForm[scope.scope.name]" :key="subIndex" class="flex">
<!-- 上传图片 --> <!-- 上传图片 -->
<div class="banner-upload-box"> <div class="banner-upload-box">
<div class="p-t-12"> <div class="p-t-12">
<div class="flex"> <div class="flex">
<div v-show="!subItem.bannerImg" class="activity-img img-w-h" style="margin-bottom: 11px;"> <div v-show="!subItem.content" class="activity-img img-w-h" style="margin-bottom: 11px;">
<div class="add">+</div> <div class="add">+</div>
<span class="number">上传</span> <span class="number">上传</span>
<input type="file" style="opacity: 0;" ref="file" class="activity-img img-w-h" accept="image/png, image/jpeg, image/gif, image/jpg" @change="e => handleImgChange(e, subIndex)" /> <input type="file" style="opacity: 0;" ref="file" class="activity-img img-w-h" accept="image/png, image/jpeg, image/gif, image/jpg" @change="e => handleImgChange(e, subIndex)" />
</div> </div>
<div v-show="!subItem.bannerImg"> <div v-show="!subItem.content">
<el-button type="text" class="el-icon-delete" @click="handleBannerDelete(subIndex)"></el-button> <el-button type="text" class="el-icon-delete" @click="handleEmptyDelete(subIndex)"></el-button>
</div> </div>
</div> </div>
<span v-show="subItem.bannerImg" class="muti-imgs"> <span v-show="subItem.content" class="muti-imgs">
<img class="img-w-h" :src="subItem.bannerImg" /> <img class="img-w-h" :src="subItem.content" />
<span class="img-btns"> <span class="img-btns">
<span class="btn-item"> <span class="btn-item">
<i class="el-icon-delete" @click="handleImgDelete(scope.scope.name, subIndex)"></i> <i class="el-icon-delete" @click="handleImgDelete(scope.scope.name, subIndex)"></i>
<i class="el-icon-zoom-in" @click="handleImgLook(subItem.bannerImg)"></i> <i class="el-icon-zoom-in" @click="handleImgLook(subItem.content)"></i>
</span> </span>
</span> </span>
</span> </span>
</div> </div>
<p class="edit-tips">支持上传10MB以内的jpg,png,jpeg图片</p> <p class="edit-tips">支持上传20MB以内的jpg,png,jpeg图片</p>
</div> </div>
<!-- 选择商品 --> <!-- 选择商品 -->
<div v-show="subItem.bannerImg" class="flex-grow"> <!-- <div v-show="subItem.bannerImg" class="flex-grow">
<div> <div>
<span>商品链接:</span> <span>商品链接:</span>
<el-button v-show="!subItem.goodsId" type="text" class="btn-link" @click="handleSinglePro(scope.scope, subIndex)">选择</el-button> <el-button v-show="!subItem.goodsId" type="text" class="btn-link" @click="handleSinglePro(scope.scope, subIndex)">选择</el-button>
...@@ -106,19 +106,21 @@ ...@@ -106,19 +106,21 @@
<img class="img-60" :src="subItem.goods.goodsImage"> <img class="img-60" :src="subItem.goods.goodsImage">
<p class="pro-txt flex-grow one-line-ellipsis">{{ subItem.goods.goodsName }}</p> <p class="pro-txt flex-grow one-line-ellipsis">{{ subItem.goods.goodsName }}</p>
</div> </div>
</div> </div> -->
</div> </div>
</div> </div>
</glsx-combi-form> </glsx-combi-form>
</div> </div>
</div> </div>
<!-- <glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"></glsx-combi-form> -->
</div> </div>
</div> </div>
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }"> <div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<el-button type="primary" @click="handleConfirm">确定</el-button> <el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button> <el-button type="default" @click="handleCancel">取消</el-button>
</div> </div>
<el-dialog :visible.sync="isImgVisible">
<img class="dialog-img" width="100%" :src="dialogImageUrl" alt="" />
</el-dialog>
</div> </div>
</template> </template>
...@@ -149,7 +151,8 @@ export default { ...@@ -149,7 +151,8 @@ export default {
goodsDetailImageList: [], goodsDetailImageList: [],
goodsVideo: '', goodsVideo: '',
classifyIdList: [], classifyIdList: [],
zoneId: '' zoneId: '',
descImgList: []
}, },
labelWidth: '110px', labelWidth: '110px',
externalFormList: [ externalFormList: [
...@@ -241,23 +244,46 @@ export default { ...@@ -241,23 +244,46 @@ export default {
optionId: 'id', optionId: 'id',
optionLabel: 'zoneName', optionLabel: 'zoneName',
optionsName: 'zoneList' optionsName: 'zoneList'
}
]
}, },
{ {
title: 'Banner管理', label: '商品描述',
editFormData: [ name: '',
addHtml: 'describeBtn'
},
{ {
label: 'banner图片', label: '',
addHtml: 'bannerBtn' name: 'describeTxt',
type: 'input',
inputType: 'textarea',
width: '320px',
placeholder: '请输入商品描述',
rows: 5,
maxlength: '200',
style: {
'margin-left': '110px'
}
}, },
{ {
label: '', label: '',
name: 'bannerList', name: 'descImgList',
addHtml: 'bannerList' addHtml: 'descImgs'
} }
] ]
}, },
// {
// title: 'Banner管理',
// editFormData: [
// {
// label: 'banner图片',
// addHtml: 'bannerBtn'
// },
// {
// label: '',
// name: 'bannerList',
// addHtml: 'bannerList'
// }
// ]
// },
{ {
title: '公告管理', title: '公告管理',
editFormData: [ editFormData: [
...@@ -285,6 +311,15 @@ export default { ...@@ -285,6 +311,15 @@ export default {
] ]
} }
], ],
descImgItem: {
content: '',
// warning: '请上传20M以内的jpg、jpeg、png图片',
resType: 1,
bizType: 2
},
// 查看大图
isImgVisible: false,
dialogImageUrl: '',
baseData: { baseData: {
classifyList: [], classifyList: [],
zoneList: [] zoneList: []
...@@ -350,6 +385,60 @@ export default { ...@@ -350,6 +385,60 @@ export default {
}) })
} }
}, },
// 商品描述-图片
handleDescribeImgAdd() {
if (this.editForm.descImgList.length >= 10) {
this.$message({
message: '最多只允许添加10个',
type: 'error'
})
return true
}
this.editForm.descImgList.push(this.$common.utils.deepClone(this.descImgItem))
},
// 图片-描述-start
handleImgChange(e, idx) {
var reader = new FileReader()
var file = e.srcElement.files[0]
const isLt = file.size / 1024 / 1024 < 20
const isType = ['image/jpeg', 'image/png', 'image/jpg'].includes(file.type)
if (!isType) {
this.$message.error('上传图片不是jpg、jpeg或png的格式!')
return true
}
if (!isLt) {
this.$message.error('上传图片大小不能超过20MB!')
return true
}
reader.readAsDataURL(file)
reader.onload = e => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
this.$apis.common.uploadImgApi({ file: base64, fileType: 'image' }).then(res => {
this.editForm.descImgList[idx].content = res
})
}
},
handleEmptyDelete(idx) {
this.editForm.descImgList.splice(idx, 1)
},
handleImgDelete(attrName, subIndex) {
this.$messageBox.confirm('是否删除该图片?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
this.editForm[attrName].splice(subIndex, 1)
}
}
})
},
handleImgLook(src) {
this.isImgVisible = true
this.dialogImageUrl = src
},
// 图片-描述-end
handleConfirm() { handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => { this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) { if (valid) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!