Commit 7e826a4e by 前端

更新月底版本代码

1 parent 00736a2f
......@@ -63,11 +63,22 @@ const getCaseDetailApi = params => {
})
}
const topCaseApi = params => {
params.method = 'scrm.api.shopmall.discover.case.updateToTop'
return http({
url,
method: 'post',
data: params,
sign: true
})
}
export default {
getCaseListApi,
getVideoListApi,
delCaseApi,
addCaseApi,
getCarSeriesApi,
getCaseDetailApi
getCaseDetailApi,
topCaseApi
}
\ No newline at end of file
......@@ -75,6 +75,62 @@ const getMerchantListApi = params => {
})
}
const getBrowseListApi = params => {
params.method = 'scrm.api.shopmall.discover.goods.browse.records'
return http({
url,
method: 'post',
data: params,
sign: true
})
}
const getVisitorListApi = params => {
params.method = 'scrm.api.shopmall.discover.goods.visitor.records'
return http({
url,
method: 'post',
data: params,
sign: true
})
}
const getSharedListApi = params => {
params.method = 'scrm.api.shopmall.discover.goods.shared.records'
return http({
url,
method: 'post',
data: params,
sign: true
})
}
const exportBrowseApi = (params, TYPE = 1) => {
//TYPE 1 浏览 2 访客 3 分享
params.method = {
1: 'scrm.api.shopmall.discover.goods.browse.records.export',
2: 'scrm.api.shopmall.discover.goods.visitor.records.export',
3: 'scrm.api.shopmall.discover.goods.shared.records.export'
}[TYPE]
return http({
url,
method: 'POST',
data: params,
sign: true
})
}
const exportGoodsApi = params => {
params.method = 'scrm.api.shopmall.goods.configuration.export'
return http({
url,
method: 'post',
data: params,
sign: true
})
}
export default {
getGoodsListApi,
updateGoodsStatusApi,
......@@ -82,5 +138,10 @@ export default {
getCarlifeGoodsApi,
addGoodsApi,
getGoodsDetail,
getMerchantListApi
getMerchantListApi,
getBrowseListApi,
getVisitorListApi,
getSharedListApi,
exportBrowseApi,
exportGoodsApi
}
\ No newline at end of file
......@@ -29,8 +29,47 @@ function limitPrice(newValue, oldValue, intergerDigit, pointDigit, minValue, max
} else {
return newValue ? oldValue : ''
}
};
function getExplorer() {
var ua = navigator.userAgent.toLocaleLowerCase()
var browserType = null
if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
browserType = 'IE'
} else if (ua.match(/firefox/) != null) {
browserType = '火狐'
} else if (ua.match(/ubrowser/) != null) {
browserType = 'UC'
} else if (ua.match(/opera/) != null) {
browserType = '欧朋'
} else if (ua.match(/bidubrowser/) != null) {
browserType = '百度'
} else if (ua.match(/metasr/) != null) {
browserType = '搜狗'
} else if (ua.match(/tencenttraveler/) != null || ua.match(/qqbrowse/) != null) {
browserType = 'QQ'
} else if (ua.match(/maxthon/) != null) {
browserType = '遨游'
} else {
browserType = '谷歌'
}
return browserType
}
function exportFn(url) {
let browserType = getExplorer()
if (browserType == 'QQ') {
window.open(url)
return
}
let iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = url
document.body.appendChild(iframe)
}
const orderManageStatusList = [
{ confId: '1', confName: '未支付' },
{ confId: '2', confName: '已支付' },
......@@ -149,6 +188,8 @@ const stateList = [{
},
]
export {
limitPrice,
orderManageStatusList,
......@@ -159,5 +200,7 @@ export {
memberTypeList,
stateList,
orderTypesList,
orderStatusList
orderStatusList,
getExplorer,
exportFn
}
\ No newline at end of file
......@@ -39,7 +39,7 @@
</el-dialog>
</div>
</template>
<script>
import url from '@/assets/empty.png'
import bigView from '@/components/big-view'
......@@ -60,6 +60,17 @@
buttonList: [
{
type: 'el-button',
name: '置顶',
attrs: {
type: 'text',
fn: '置顶'
},
listeners: {
click: row => this.topFn(row.scope)
}
},
{
type: 'el-button',
name: '预览',
attrs: {
type: 'text',
......@@ -159,12 +170,30 @@
created() {},
mounted() {},
methods: {
topFn({id, caseName}){
const h = this.$createElement
this.$confirm(h('div', [h('div',{ style: 'font-size: 18px;color:#333,margin-bottom:4px;margin-top:8px' }, '是否确定将此案例置顶?'),h('p', { style: 'color:#666;margin-top:4px' },'置顶后的案例会在小程序端优先置顶展示')]), '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.$apis.case.topCaseApi({id}).then(res => {
if(res){
this.$message.success('置顶成功')
this.handleSearch()
}
})
}
}
})
},
filterBrand({brandList}){
return brandList?.map(item => item.brandName) || []
},
previewFn(row){
console.log(this.previewVideoUrl)
this.previewVideoUrl = row?.mediaInfo?.mediaUrl
this.previewVideoUrl = row?.mediaInfo?.mediaUrl
this.previewVideoVisible = true
},
getParams() {
......@@ -223,7 +252,7 @@
}
}
</script>
<style scoped lang="scss">
.case-ctnr{
background-color: #fff;
......@@ -236,4 +265,3 @@
}
</style>
\ No newline at end of file
<template>
<div class="goods-ctnr">
<div class="global-title">{{!routeInfo.id ? '新增': disabled ? '查看' : '编辑'}}商品</div>
<div class="container">
<glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
<div slot="selectGoodsSlot">
<el-button :class="['el-icon-plus', {'disabled-class':disabled}]" size="small" @click="openGoodsDialog">{{formObj.smartcarlifeInfoId ? '重新选择': '选择商品'}}</el-button>
</div>
<div slot="goodsInfoSlot" class="goods-wrap">
<glsx-combi-form :isInline="false" ref="goodsInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="goodsFormData" :formRules="goodsRule">
<div slot="uploadSlot" class="upload-calss">
<glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.coverList" @change="changeChannelImg"></glsx-preview>
<span class="tip">建议尺寸750*750,图片格式为jpg,jpeg,png,大小2M以内</span>
</div>
</glsx-combi-form>
</div>
<div slot="paymentSlot">
<el-radio-group :disabled="disabled" v-model="formObj.paymentType">
<el-radio :label="1">全款</el-radio>
<el-radio :label="2">定金+尾款</el-radio>
</el-radio-group>
<div class="money-wrap" v-if="formObj.paymentType == 2">
<label class="label" for="">定金金额/元:</label>
<format-input :disabled="disabled" :intDigit="4" :precise="2" v-model="formObj.depositPrice"></format-input>
</div>
</div>
<div slot="saleStoreSlot">
<el-button v-if="!disabled" class="el-icon-plus" size="small" @click="closeDialog">选择门店</el-button>
<template v-if="saleMerchantList && saleMerchantList.length">
<GLTable class="selected-table" :hasPage="false" ref="selectedRef" :tableParams="selectedtableParams" :tableData="saleMerchantList">
<div slot="activityPriceSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入" v-model="scope.scope.activityPrice"></format-input>
</div>
<div slot="originalPriceSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入" v-model="scope.scope.originalPrice"></format-input>
</div>
<div slot="retainagePriceSlot" slot-scope="scope">
{{ retainagePriceFn(scope.scope.activityPrice) }}
</div>
<div slot="auth-button" slot-scope="scope">
<el-button v-if="!disabled" type="text" @click="handleDel(scope.scope)">删除</el-button>
</div>
</GLTable>
</template>
</div>
<div slot="carSeriesSlot">
<el-radio-group :disabled="disabled" v-model="formObj.vehicleSeriesType">
<el-radio :label="1">全部</el-radio>
<el-radio :label="2">部分</el-radio>
</el-radio-group>
<div v-if="formObj.vehicleSeriesType == 2">
<el-button type="default" v-if="!disabled" class="el-icon-plus" @click="handleCarSeriesClose">选择车系</el-button>
<div class="car-series-wrap" v-if="vehicleSeriesRequestList && vehicleSeriesRequestList.length">
<div class="car-series-item" v-for="item in vehicleSeriesRequestList" :key="item.vehicleSeriesId">{{ item.vehicleSeriesName }}</div>
</div>
</div>
</div>
<div slot="categorySlot">
<brandCascader :curInfo="curCategoryInfo" :disabled="disabled" @clickItem="selectCategory" class="category-class"></brandCascader>
<div class="goods-ctnr">
<div class="global-title">{{ !routeInfo.id ? '新增' : disabled ? '查看' : '编辑' }}商品</div>
<div class="container">
<glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px"
defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
<div slot="selectGoodsSlot">
<el-button :class="['el-icon-plus', {'disabled-class':disabled}]" size="small" @click="openGoodsDialog">
{{ formObj.smartcarlifeInfoId ? '重新选择' : '选择商品' }}
</el-button>
</div>
<div slot="goodsInfoSlot" class="goods-wrap">
<glsx-combi-form :isInline="false" ref="goodsInfoRef" labelWidth="154px" defaultWidth="432px"
:formObj.sync="formObj" :formData="goodsFormData" :formRules="goodsRule">
<div slot="uploadSlot" class="upload-calss">
<glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.coverList"
@change="changeChannelImg"></glsx-preview>
<span class="tip">建议尺寸750*750,图片格式为jpg,jpeg,png,大小2M以内</span>
</div>
</glsx-combi-form>
</div>
<div slot="paymentSlot">
<el-radio-group :disabled="disabled" v-model="formObj.paymentType">
<el-radio :label="1">全款</el-radio>
<el-radio :label="2">定金+尾款</el-radio>
</el-radio-group>
<div class="money-wrap" v-if="formObj.paymentType == 2">
<label class="label" for="">定金金额/元:</label>
<format-input :disabled="disabled" :intDigit="4" :precise="2" v-model="formObj.depositPrice"></format-input>
</div>
</div>
<div slot="saleStoreSlot">
<el-button v-if="!disabled" class="el-icon-plus" size="small" @click="closeDialog">选择门店</el-button>
<template v-if="saleMerchantList && saleMerchantList.length">
<GLTable class="selected-table" :hasPage="false" ref="selectedRef" :tableParams="selectedtableParams"
:tableData="saleMerchantList">
<div slot="activityPriceSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入"
v-model="scope.scope.activityPrice"></format-input>
</div>
<div slot="originalPriceSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入"
v-model="scope.scope.originalPrice"></format-input>
</div>
<div slot="retainagePriceSlot" slot-scope="scope">
{{ retainagePriceFn(scope.scope.activityPrice) }}videoUrl
</div>
<div slot="auth-button" slot-scope="scope">
<el-button v-if="!disabled" type="text" @click="handleDel(scope.scope)">删除</el-button>
</div>
</GLTable>
</template>
</div>
<div slot="productVideoSlot">
<el-form-item label="">
<template v-if="!formObj.goodsVideo">
<div class="upload-img">
<i class="el-icon-plus avatar-uploader-desc-icon"></i>
<div class="avatar-uploader-desc-word">上传视频</div>
<input type="file" class="upload-video" style="opacity: 0" accept=".mp4"
@change="e => handleVideoChange(e)"/>
</div>
</template>
<template v-else>
<div class="video-box">
<video id="video" width="100%" height="100%" preload loop muted>
<source :src="formObj.goodsVideo" type="video/mp4"/>
</video>
<div class="mask">
<div class="video-pane-close" @click="handleEnlarge(formObj.goodsVideo, 'video')">
<img src="../../assets/channel/view.png" alt=""/>
</div>
<div class="video-pane-close" @click="close('radio')">
<img src="../../assets/channel/dele.png" alt=""/>
</div>
</div>
</glsx-combi-form>
</div>
</template>
<div class="text-tip2">作为商品详情页顶部展示和详情展示,格式建议mp4,大小不超过20M</div>
</el-form-item>
</div>
<div slot="carSeriesSlot">
<el-radio-group :disabled="disabled" v-model="formObj.vehicleSeriesType">
<el-radio :label="1">全部</el-radio>
<el-radio :label="2">部分</el-radio>
</el-radio-group>
<div v-if="formObj.vehicleSeriesType == 2">
<el-button type="default" v-if="!disabled" class="el-icon-plus" @click="handleCarSeriesClose">选择车系
</el-button>
<div class="car-series-wrap" v-if="vehicleSeriesRequestList && vehicleSeriesRequestList.length">
<div class="car-series-item" v-for="item in vehicleSeriesRequestList" :key="item.vehicleSeriesId">
{{ item.vehicleSeriesName }}
</div>
</div>
</div>
</div>
<div slot="categorySlot">
<brandCascader :curInfo="curCategoryInfo" :disabled="disabled" @clickItem="selectCategory"
class="category-class"></brandCascader>
</div>
<GLFooter style="margin-top: 16px;">
<el-button @click="handleCancel">取消</el-button>
<el-button v-if="!disabled" type="primary" @click="handleSave">确定</el-button>
</GLFooter>
<selectCarDialog v-if="carDialogVisible" :echoData="vehicleSeriesRequestList" @handleClose="handleCarSeriesClose" @handleConfirm="handleConfirm" :dialogVisible="carDialogVisible"></selectCarDialog>
<selectGoods v-if="goodsVisible" :routeInfo="routeInfo" :dialogVisible="goodsVisible" @handleGoodsConfirm="handleGoodsConfirm" @handleGoodsClose="handleGoodsClose"></selectGoods>
<selectMerchantDialog @confirmDialog="confirmDialog" @closeDialog="closeDialog" :goodsId="formObj.smartcarlifeInfoId" :selectedList="saleMerchantList" v-if="merchantDialogVisible" :isVisible="merchantDialogVisible"></selectMerchantDialog>
</glsx-combi-form>
</div>
<GLFooter style="margin-top: 16px;">
<el-button @click="handleCancel">取消</el-button>
<el-button v-if="!disabled" type="primary" @click="handleSave">确定</el-button>
</GLFooter>
<selectCarDialog v-if="carDialogVisible" :echoData="vehicleSeriesRequestList" @handleClose="handleCarSeriesClose"
@handleConfirm="handleConfirm" :dialogVisible="carDialogVisible"></selectCarDialog>
<selectGoods v-if="goodsVisible" :routeInfo="routeInfo" :dialogVisible="goodsVisible"
@handleGoodsConfirm="handleGoodsConfirm" @handleGoodsClose="handleGoodsClose"></selectGoods>
<selectMerchantDialog @confirmDialog="confirmDialog" @closeDialog="closeDialog"
:goodsId="formObj.smartcarlifeInfoId" :selectedList="saleMerchantList"
v-if="merchantDialogVisible" :isVisible="merchantDialogVisible"></selectMerchantDialog>
<el-dialog class="image-dialog" :visible.sync="dialogVisibleImg" width="50%">
<img :src="dialogSrc" width="100%" v-if="dialogType == 'img'" />
<video width="100%" autoplay controls :src="dialogSrc" v-else></video>
</el-dialog>
</div>
</template>
<script>
const MerchantColumns = [
{
label: '门店名称',
prop: 'merchantName',
},
{
label: '门店原价(元)',
width: 220,
addHtml: 'originalPriceSlot'
},
{
label: '门店活动价(元)',
width: 220,
addHtml: 'activityPriceSlot'
},
{
label: '尾款金额(元)',
width: 150,
addHtml: 'retainagePriceSlot'
}
]
const MerchantColumns = [
{
label: '门店名称',
prop: 'merchantName',
},
{
label: '门店原价(元)',
width: 220,
addHtml: 'originalPriceSlot'
},
{
label: '门店活动价(元)',
width: 220,
addHtml: 'activityPriceSlot'
},
{
label: '尾款金额(元)',
width: 150,
addHtml: 'retainagePriceSlot'
}
]
const notPriceColumns = [
{
label: '门店名称',
prop: 'merchantName',
},
{
label: '门店原价(元)',
addHtml: 'originalPriceSlot'
},
{
label: '门店活动价(元)',
addHtml: 'activityPriceSlot'
}
const notPriceColumns = [
{
label: '门店名称',
prop: 'merchantName',
},
{
label: '门店原价(元)',
addHtml: 'originalPriceSlot'
},
{
label: '门店活动价(元)',
addHtml: 'activityPriceSlot'
}
]
import glsxCombiForm from '@/components/glsx-combi-form'
import brandCascader from './components/brandCascader'
import selectGoods from './components/selectGoods'
import selectCarDialog from '@/views/store/components/selectCarDialog'
import selectMerchantDialog from './components/selectMerchantDialog'
export default {
name: 'add',
components: {
glsxCombiForm,
brandCascader,
selectGoods,
selectCarDialog,
selectMerchantDialog
},
watch:{
'formObj.paymentType':{
handler(nVal, oVal){
if(nVal==1) {
this.selectedtableParams.tableColumns = notPriceColumns
}else{
this.selectedtableParams.tableColumns = MerchantColumns
}
},
deep: true
}
},
data() {
return {
goodsVisible: false,
carDialogVisible: false,
merchantDialogVisible: false,
disabled: false,
goodsInfo: {},
routeInfo: {},
defaultProps:{
children: 'categoryName',
label: 'childs'
},
curCategoryInfo:{},
posterOptions: {
width: '104px',
height: '104px',
key: 'posterImg',
isClose: true
},
goodsFormData:[
{
label: '商品图',
addHtml: 'uploadSlot',
isDisabled: false
},
{
label: '商品名称',
name: 'goodsName',
maxlength: 20,
showLimit: true,
type: 'input',
isDisabled: false
},
{
label: '售价(元)',
name: 'retailPrice',
type: 'showTxt'
},
{
label: '最低售价(元)',
name: 'minSellPrice',
type: 'showTxt'
},
],
formObj:{
smartcarlifeInfoId: '',
goodsName: '',
goodsType: '1',
goodsImage: '',
minSellPrice: '',
retailPrice: '',
coverList: [],
paymentType: 1,
depositPrice: '',
vehicleSeriesType: 1,
associationClassifyFirstId: '',
associationClassifySecondId: ''
},
saleMerchantList:[],
vehicleSeriesRequestList: [],
myRule: {
selectGoodsName: [
{
required: true,
validator: (rule, value, callback) => {
if(!this.formObj.smartcarlifeInfoId){
callback(new Error('请选择商品'))
}else{
callback()
}
},
trigger: 'change'
}
],
goodsInfoName: [{
required: true,
validator: (rule, value, callback) => {
if(!this.formObj.coverList && !this.formObj.coverList[0]){
callback(new Error('请上传商品图'))
}else if(!this.formObj.goodsName){
callback(new Error('请输入商品名称'))
}else{
callback()
}
},
trigger: 'change'
}],
paymentType: [{
required: true,
validator: (rule, value, callback) => {
if(this.formObj.paymentType == 2 && !this.formObj.depositPrice){
callback(new Error('请输入定金金额'))
}else{
callback()
}
this.validateField('saleStore')
},
trigger: 'change'
}],
saleStore: [{
required: true,
validator: (rule, value, callback) => {
const target = this.saleMerchantList.find(item => !item.activityPrice || !item.originalPrice)
const hasNegTarget = this.saleMerchantList.find(item => {
let activityPrice = item.activityPrice || 0
let depositPrice = this.formObj.depositPrice || 0
return +activityPrice < +depositPrice
})
const hasTarget = this.saleMerchantList.find(item => {
let originalPrice = item.originalPrice || 0
let activityPrice = item.activityPrice || 0
let minSellPrice = this.formObj.minSellPrice || 0
return (+activityPrice > +originalPrice || +originalPrice < minSellPrice)
})
if(!this.saleMerchantList.length){
callback(new Error('请选择门店'))
}else if(target){
callback(new Error('门店活动价和原价不能为空'))
}else if(this.formObj.paymentType == 2 && hasNegTarget){
callback(new Error('活动价不能小于定金'))
}else if(hasTarget){
callback(new Error('原价不能小于最低售价和活动价'))
}else{
callback()
}
},
trigger: 'change'
}],
carSeriesName: [{
required: true,
validator: (rule, value, callback) => {
if(this.formObj.vehicleSeriesType == 2 && !this.vehicleSeriesRequestList.length){
callback(new Error('请选择适用车系'))
}else{
callback()
}
},
trigger: 'change'
}],
categoryName: [{
required: true,
validator: (rule, value, callback) => {
if(!this.formObj.associationClassifyFirstId || !this.formObj.associationClassifySecondId){
callback(new Error('请选择关联商品分类'))
}else{
callback()
}
},
trigger: 'change'
}],
},
formData:[
{
label: '选择商品',
name: 'selectGoodsName',
addHtml: 'selectGoodsSlot',
type: 'input',
isDisabled: false
},
{
label: '商品信息',
name: 'goodsInfoName',
addHtml: 'goodsInfoSlot',
type: 'input',
isDisabled: false
},
{
label: '收款方式',
name: 'paymentType',
addHtml: 'paymentSlot'
},
{
label: '销售门店',
name: 'saleStore',
addHtml: 'saleStoreSlot'
},
{
label: '适用车系',
name: 'carSeriesName',
addHtml: 'carSeriesSlot',
},
{
label: '关联商品分类',
name: 'categoryName',
addHtml: 'categorySlot'
}
],
selectedtableParams: {
listName: 'list',
tableOption: {
width: 100
},
tableColumns: notPriceColumns
}
name: 'add',
components: {
glsxCombiForm,
brandCascader,
selectGoods,
selectCarDialog,
selectMerchantDialog
},
watch: {
'formObj.paymentType': {
handler(nVal, oVal) {
if (nVal == 1) {
this.selectedtableParams.tableColumns = notPriceColumns
} else {
this.selectedtableParams.tableColumns = MerchantColumns
}
},
created(){
// this.getCategory()
const urlParam = this.$route.params
this.routeInfo = JSON.parse(decodeURIComponent(urlParam.id))
const { id, type } = this.routeInfo
if(type == 1) {
this.disabled = true
this.posterOptions.isClose = false
const _target = this.goodsFormData.find(item => item.name == 'goodsName')
_target.isDisabled = true
this.selectedtableParams.tableOption = null
}
if(id){
this.getDetail()
}
},
methods:{
validateField(field){
if(Array.isArray(field)){
field.forEach(item => {
this.$refs.baseInfoRef.$refs.formRef.validateField(item)
})
}else{
this.$refs.baseInfoRef.$refs.formRef.validateField(field)
}
},
retainagePriceFn(price){
let depositPrice = this.formObj.paymentType==1 ? 0 : this.formObj.depositPrice
if(this.formObj.paymentType==1) return '--'
if(!price){
return '待计算'
}else{
return Number((price - depositPrice).toFixed(2))
}
},
openGoodsDialog(){
if(this.disabled) return
this.goodsVisible = true
},
deep: true
}
},
data() {
return {
dialogVisibleImg:false,
goodsVisible: false,
carDialogVisible: false,
merchantDialogVisible: false,
disabled: false,
dialogSrc:'',
goodsInfo: {},
routeInfo: {},
defaultProps: {
children: 'categoryName',
label: 'childs'
},
curCategoryInfo: {},
posterOptions: {
width: '104px',
height: '104px',
key: 'posterImg',
isClose: true
},
goodsFormData: [
{
label: '商品图',
addHtml: 'uploadSlot',
isDisabled: false
},
handleGoodsClose(){
this.goodsVisible = false
{
label: '商品名称',
name: 'goodsName',
maxlength: 20,
showLimit: true,
type: 'input',
isDisabled: false
},
handleGoodsConfirm(e){
if(this.formObj.smartcarlifeInfoId!=e?.id) this.saleMerchantList = []
let { id: smartcarlifeInfoId, goodsName, goodsImage, minSellPrice, retailPrice } = e || {}
minSellPrice = minSellPrice ? Number(Number(minSellPrice/100).toFixed(2)) : 0
retailPrice = retailPrice ? Number(Number(retailPrice/100).toFixed(2)) : 0
this.formObj = {...this.formObj, smartcarlifeInfoId, goodsName, goodsImage, coverList: [goodsImage], minSellPrice, retailPrice}
this.handleGoodsClose()
this.validateField(['selectGoodsName','goodsInfoName'])
{
label: '售价(元)',
name: 'retailPrice',
type: 'showTxt'
},
handleCarSeriesClose(){
this.carDialogVisible = !this.carDialogVisible
{
label: '最低售价(元)',
name: 'minSellPrice',
type: 'showTxt'
},
handleConfirm(e={}){
let carList = []
for(const key in e){
for(const sonKey in e[key]){
carList = [...carList, ...e[key][sonKey]]
}
],
formObj: {
smartcarlifeInfoId: '',
goodsName: '',
goodsType: '1',
goodsImage: '',
minSellPrice: '',
retailPrice: '',
coverList: [],
paymentType: 1,
depositPrice: '',
vehicleSeriesType: 1,
goodsVideo: '',
associationClassifyFirstId: '',
associationClassifySecondId: ''
},
saleMerchantList: [],
vehicleSeriesRequestList: [],
myRule: {
selectGoodsName: [
{
required: true,
validator: (rule, value, callback) => {
if (!this.formObj.smartcarlifeInfoId) {
callback(new Error('请选择商品'))
} else {
callback()
}
},
trigger: 'change'
}
],
goodsInfoName: [{
required: true,
validator: (rule, value, callback) => {
if (!this.formObj.coverList && !this.formObj.coverList[0]) {
callback(new Error('请上传商品图'))
} else if (!this.formObj.goodsName) {
callback(new Error('请输入商品名称'))
} else {
callback()
}
},
trigger: 'change'
}],
paymentType: [{
required: true,
validator: (rule, value, callback) => {
if (this.formObj.paymentType == 2 && !this.formObj.depositPrice) {
callback(new Error('请输入定金金额'))
} else {
callback()
}
this.vehicleSeriesRequestList = carList.map(item =>{
const {id, name, parentId, parentName, rootId, rootName} = item
return {
brandId: rootId,
brandName: rootName,
childBrandId: parentId,
childBrandName: parentName,
vehicleSeriesId: id,
vehicleSeriesName: name
}
})
this.handleCarSeriesClose()
this.validateField('carSeriesName')
},
confirmDialog(e){
this.saleMerchantList = e || []
this.closeDialog()
this.validateField('saleStore')
},
closeDialog(){
if(!this.merchantDialogVisible && !this.formObj.smartcarlifeInfoId){
return this.$message.error('请先选择商品')
},
trigger: 'change'
}],
saleStore: [{
required: true,
validator: (rule, value, callback) => {
const target = this.saleMerchantList.find(item => !item.activityPrice || !item.originalPrice)
const hasNegTarget = this.saleMerchantList.find(item => {
let activityPrice = item.activityPrice || 0
let depositPrice = this.formObj.depositPrice || 0
return +activityPrice < +depositPrice
})
const hasTarget = this.saleMerchantList.find(item => {
let originalPrice = item.originalPrice || 0
let activityPrice = item.activityPrice || 0
let minSellPrice = this.formObj.minSellPrice || 0
return (+activityPrice > +originalPrice || +originalPrice < minSellPrice)
})
if (!this.saleMerchantList.length) {
callback(new Error('请选择门店'))
} else if (target) {
callback(new Error('门店活动价和原价不能为空'))
} else if (this.formObj.paymentType == 2 && hasNegTarget) {
callback(new Error('活动价不能小于定金'))
} else if (hasTarget) {
callback(new Error('原价不能小于最低售价和活动价'))
} else {
callback()
}
},
trigger: 'change'
}],
carSeriesName: [{
required: true,
validator: (rule, value, callback) => {
if (this.formObj.vehicleSeriesType == 2 && !this.vehicleSeriesRequestList.length) {
callback(new Error('请选择适用车系'))
} else {
callback()
}
},
trigger: 'change'
}],
categoryName: [{
required: true,
validator: (rule, value, callback) => {
if (!this.formObj.associationClassifyFirstId || !this.formObj.associationClassifySecondId) {
callback(new Error('请选择关联商品分类'))
} else {
callback()
}
this.merchantDialogVisible = !this.merchantDialogVisible
},
trigger: 'change'
}],
},
formData: [
{
label: '选择商品',
name: 'selectGoodsName',
addHtml: 'selectGoodsSlot',
type: 'input',
isDisabled: false
},
handleDel(row) {
const idx = this.saleMerchantList.findIndex(item => item.merchantId == row.merchantId)
if( idx>-1 )this.saleMerchantList.splice(idx, 1)
{
label: '商品信息',
name: 'goodsInfoName',
addHtml: 'goodsInfoSlot',
type: 'input',
isDisabled: false
},
selectCategory(e){
this.formObj.associationClassifyFirstId = e?.parent?.id
this.formObj.associationClassifySecondId = e?.data?.id
this.validateField('categoryName')
{
label: '收款方式',
name: 'paymentType',
addHtml: 'paymentSlot'
},
getParams(){
let obj = JSON.parse(JSON.stringify(this.formObj))
obj.goodsImage = obj.coverList[0]
obj.depositPrice = obj.depositPrice ? Number(Number(obj.depositPrice*10*10).toFixed(0)) : 0
if(obj.paymentType == 1) delete obj.depositPrice
delete obj.minSellPrice
delete obj.retailPrice
delete obj.coverList
let saleMerchantList = this.saleMerchantList.map(item => {
let { merchantId, merchantName, activityPrice, originalPrice } = item
let price = this.formObj.paymentType==1 ? 0 : this.formObj.depositPrice
let retainagePrice = activityPrice - price
activityPrice = activityPrice ? Number(Number(activityPrice*10*10).toFixed(0)) : 0
retainagePrice = retainagePrice ? Number(Number(retainagePrice*10*10).toFixed(0)) : 0
originalPrice = originalPrice ? Number(Number(originalPrice*10*10).toFixed(0)) : 0
if(obj.paymentType == 1) {
return {merchantId , merchantName,activityPrice, originalPrice }
}else{
return {merchantId , merchantName,activityPrice, retainagePrice, originalPrice }
}
})
const params = {
saleMerchantList: saleMerchantList,
vehicleSeriesRequestList :this.vehicleSeriesRequestList,
...obj
}
if(this.routeInfo.id) params.id = this.routeInfo.id
return params
{
label: '销售门店',
name: 'saleStore',
addHtml: 'saleStoreSlot'
},
handleSave(){
this.$refs.baseInfoRef.$refs.formRef.validate(valid => {
if(valid){
const params = this.getParams()
this.$apis.goods.addGoodsApi(params).then(res =>{
if(res) {
this.$message.success('操作成功')
this.handleCancel()
}
})
}
})
{
label: '产品视频',
name: 'productVideo',
addHtml: 'productVideoSlot'
},
handleCancel(){
this.$router.back()
// {
// label: '产品视频',
// name: 'activityVideoList',
// type: 'upload',
// uploadType: 'video',
// suffixSlot: 'activityVideos',
// // tips: '大图下可以展示视频,不上传则不显示',
// limitSize: 20,
// maxPhotoNum: 1,
// handleDelete: idx => {
// this.formObj.activityVideoList = ''
// },
// handleUpload: (e, file, targetItem) => {
// const imgFile = e.target.result
// const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
// const fileSuffix = file.name.split('.')[file.name.split('.').length - 1]
// if (fileSuffix.toLowerCase() != 'mp4') {
// this.$message.error('上传视频不是MP4的格式!')
// return true
// }
// this.loading = true
// this.$apis.common
// .uploadVideoApi({ file: base64 })
// .then(res => {
// this.formObj.activityVideoList = res
// })
// .finally(() => {
// this.loading = false
// })
// }
// },
{
label: '适用车系',
name: 'carSeriesName',
addHtml: 'carSeriesSlot',
},
getDetail(){
const params = {
id: this.routeInfo.id
}
if(this.routeInfo.merchantId) params.merchantId= this.routeInfo.merchantId
this.$apis.goods.getGoodsDetail(params).then(res => {
if(res) {
for(const key in this.formObj){
const formatAttr = ['depositPrice', 'minSellPrice', 'retailPrice']
if(formatAttr.includes(key)){
this.formObj[key] = res[key] ? Number(Number(res[key]/100).toFixed(2)) : 0
}else{
this.formObj[key] = res[key]
}
}
this.curCategoryInfo = {
categoryName: res.associationClassifySecondName,
id: res.associationClassifySecondId
}
this.formObj.goodsType = '1'
this.formObj.coverList = [res.goodsImage]
this.saleMerchantList = res.saleMerchantList?.map(item => {
let activityPrice = item.activityPrice ? Number(Number(item.activityPrice/100).toFixed(2)) : 0
let originalPrice = item.originalPrice ? Number(Number(item.originalPrice/100).toFixed(2)) : 0
return {...item, activityPrice, originalPrice}
}) || []
this.vehicleSeriesRequestList = res?.vehicleSeriesList?.map(item => {
const {brandId, brandName, childBrandId,childBrandName , vehicleSeriesId, vehicleSeriesName } = item
return {brandId, brandName, childBrandId,childBrandName , vehicleSeriesId, vehicleSeriesName }
}) || []
}
{
label: '关联商品分类',
name: 'categoryName',
addHtml: 'categorySlot'
}
],
selectedtableParams: {
listName: 'list',
tableOption: {
width: 100
},
tableColumns: notPriceColumns
}
}
},
created() {
// this.getCategory()
const urlParam = this.$route.params
this.routeInfo = JSON.parse(decodeURIComponent(urlParam.id))
const {id, type} = this.routeInfo
if (type == 1) {
this.disabled = true
this.posterOptions.isClose = false
const _target = this.goodsFormData.find(item => item.name == 'goodsName')
_target.isDisabled = true
this.selectedtableParams.tableOption = null
}
if (id) {
this.getDetail()
}
},
methods: {
// 上传视频
handleVideoChange(e) {
let file = e.srcElement.files[0]
var reader = new FileReader()
// 默认30MB
const limitSize = 20
const isLt = file.size / 1024 / 1024 < limitSize
if (!isLt) {
this.$message.error('上传视频大小不能超过' + limitSize + 'MB!')
this.loading = false
return
}
this.$notify({
title: '提示',
message: '视频上传中,请稍后'
})
document.querySelector('.upload-video').value = ''
reader.readAsDataURL(file)
reader.onload = e => {
const videoFile = e.target.result
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + videoFile.split(',')[1]
this.$apis.common.uploadVideoApi({file: base64}).then(res => {
if (res) {
this.$notify({
title: '提示',
message: '视频上传成功',
type: 'success'
})
this.loading = false
this.formObj.goodsVideo = res
} else {
this.loading = false
}
})
}
},
// 预览图文
handleEnlarge(src, type) {
this.dialogVisibleImg = true
this.dialogSrc = src
this.dialogType = type ? type : 'img'
},
// 删除图片/视频
close(type, index) {
switch (type) {
case 'radio':
this.formObj.goodsVideo = ''
break
default:
this.formObj.goodsVideo = ''
}
},
validateField(field) {
if (Array.isArray(field)) {
field.forEach(item => {
this.$refs.baseInfoRef.$refs.formRef.validateField(item)
})
} else {
this.$refs.baseInfoRef.$refs.formRef.validateField(field)
}
}
,
retainagePriceFn(price) {
let depositPrice = this.formObj.paymentType == 1 ? 0 : this.formObj.depositPrice
if (this.formObj.paymentType == 1) return '--'
if (!price) {
return '待计算'
} else {
return Number((price - depositPrice).toFixed(2))
}
}
,
openGoodsDialog() {
if (this.disabled) return
this.goodsVisible = true
}
,
handleGoodsClose() {
this.goodsVisible = false
}
,
handleGoodsConfirm(e) {
if (this.formObj.smartcarlifeInfoId != e?.id) this.saleMerchantList = []
let {id: smartcarlifeInfoId, goodsName, goodsImage, minSellPrice, retailPrice,goodsVideo} = e || {}
minSellPrice = minSellPrice ? Number(Number(minSellPrice / 100).toFixed(2)) : 0
retailPrice = retailPrice ? Number(Number(retailPrice / 100).toFixed(2)) : 0
// 若选择的商品素材包含了视频,则带入对应的视频文件
if (goodsVideo) this.formObj.goodsVideo = goodsVideo
this.formObj = {
...this.formObj,
smartcarlifeInfoId,
goodsName,
goodsImage,
coverList: [goodsImage],
minSellPrice,
retailPrice
}
this.handleGoodsClose()
this.validateField(['selectGoodsName', 'goodsInfoName'])
}
,
handleCarSeriesClose() {
this.carDialogVisible = !this.carDialogVisible
}
,
handleConfirm(e = {}) {
let carList = []
for (const key in e) {
for (const sonKey in e[key]) {
carList = [...carList, ...e[key][sonKey]]
}
}
this.vehicleSeriesRequestList = carList.map(item => {
const {id, name, parentId, parentName, rootId, rootName} = item
return {
brandId: rootId,
brandName: rootName,
childBrandId: parentId,
childBrandName: parentName,
vehicleSeriesId: id,
vehicleSeriesName: name
}
})
this.handleCarSeriesClose()
this.validateField('carSeriesName')
}
}
</script>
<style scoped lang="scss">
.container{
.glsx-combi-form{
/deep/ .el-radio-group{
.el-radio__label{
padding-left: 8px;
,
confirmDialog(e) {
this.saleMerchantList = e || []
this.closeDialog()
this.validateField('saleStore')
}
,
closeDialog() {
if (!this.merchantDialogVisible && !this.formObj.smartcarlifeInfoId) {
return this.$message.error('请先选择商品')
}
this.merchantDialogVisible = !this.merchantDialogVisible
}
,
handleDel(row) {
const idx = this.saleMerchantList.findIndex(item => item.merchantId == row.merchantId)
if (idx > -1) this.saleMerchantList.splice(idx, 1)
}
,
selectCategory(e) {
this.formObj.associationClassifyFirstId = e?.parent?.id
this.formObj.associationClassifySecondId = e?.data?.id
this.validateField('categoryName')
}
,
getParams() {
let obj = JSON.parse(JSON.stringify(this.formObj))
obj.goodsImage = obj.coverList[0]
obj.depositPrice = obj.depositPrice ? Number(Number(obj.depositPrice * 10 * 10).toFixed(0)) : 0
if (obj.paymentType == 1) delete obj.depositPrice
delete obj.minSellPrice
delete obj.retailPrice
delete obj.coverList
let saleMerchantList = this.saleMerchantList.map(item => {
let {merchantId, merchantName, activityPrice, originalPrice} = item
let price = this.formObj.paymentType == 1 ? 0 : this.formObj.depositPrice
let retainagePrice = activityPrice - price
activityPrice = activityPrice ? Number(Number(activityPrice * 10 * 10).toFixed(0)) : 0
retainagePrice = retainagePrice ? Number(Number(retainagePrice * 10 * 10).toFixed(0)) : 0
originalPrice = originalPrice ? Number(Number(originalPrice * 10 * 10).toFixed(0)) : 0
if (obj.paymentType == 1) {
return {merchantId, merchantName, activityPrice, originalPrice}
} else {
return {merchantId, merchantName, activityPrice, retainagePrice, originalPrice}
}
})
const params = {
saleMerchantList: saleMerchantList,
vehicleSeriesRequestList: this.vehicleSeriesRequestList,
...obj
}
if (this.routeInfo.id) params.id = this.routeInfo.id
return params
}
,
handleSave() {
this.$refs.baseInfoRef.$refs.formRef.validate(valid => {
if (valid) {
const params = this.getParams()
this.$apis.goods.addGoodsApi(params).then(res => {
if (res) {
this.$message.success('操作成功')
this.handleCancel()
}
})
}
})
}
background-color: #fff;
.disabled-class{
cursor: not-allowed;
color: #666666;
,
handleCancel() {
this.$router.back()
}
.goods-wrap{
padding: 20px 20px 1px;
width: 1000px;
background: #F9F9F9;
border-radius: 4px;
.upload-calss{
display: flex;
.tip{
height: 20px;
line-height: 20px;
align-self: flex-end;
font-weight: 400;
font-size: 14px;
color: #999999;
margin-left: 10px;
,
getDetail() {
const params = {
id: this.routeInfo.id
}
if (this.routeInfo.merchantId) params.merchantId = this.routeInfo.merchantId
this.$apis.goods.getGoodsDetail(params).then(res => {
if (res) {
for (const key in this.formObj) {
const formatAttr = ['depositPrice', 'minSellPrice', 'retailPrice']
if (formatAttr.includes(key)) {
this.formObj[key] = res[key] ? Number(Number(res[key] / 100).toFixed(2)) : 0
} else {
this.formObj[key] = res[key]
}
}
this.curCategoryInfo = {
categoryName: res.associationClassifySecondName,
id: res.associationClassifySecondId
}
this.formObj.goodsType = '1'
this.formObj.coverList = [res.goodsImage]
this.saleMerchantList = res.saleMerchantList?.map(item => {
let activityPrice = item.activityPrice ? Number(Number(item.activityPrice / 100).toFixed(2)) : 0
let originalPrice = item.originalPrice ? Number(Number(item.originalPrice / 100).toFixed(2)) : 0
return {...item, activityPrice, originalPrice}
}) || []
this.vehicleSeriesRequestList = res?.vehicleSeriesList?.map(item => {
const {brandId, brandName, childBrandId, childBrandName, vehicleSeriesId, vehicleSeriesName} = item
return {brandId, brandName, childBrandId, childBrandName, vehicleSeriesId, vehicleSeriesName}
}) || []
}
})
}
.category-class{
width: 432px;
}
}
</script>
<style scoped lang="scss">
.container {
.glsx-combi-form {
/deep/ .el-radio-group {
.el-radio__label {
padding-left: 8px;
}
}
.money-wrap{
.label{
width: 92px;
height: 20px;
line-height: 20px;
font-weight: 400;
font-size: 14px;
color: #333333;
text-align: right;
}
.el-input{
width: 432px;
}
}
background-color: #fff;
.disabled-class {
cursor: not-allowed;
color: #666666;
}
.goods-wrap {
padding: 20px 20px 1px;
width: 1000px;
background: #F9F9F9;
border-radius: 4px;
.upload-calss {
display: flex;
.tip {
height: 20px;
line-height: 20px;
align-self: flex-end;
font-weight: 400;
font-size: 14px;
color: #999999;
margin-left: 10px;
}
}
.selected-table {
margin-top: 10px;
width: 100%;
max-width: 1000px;
.el-button--text{
padding: 0;
}
}
.category-class {
width: 432px;
}
.money-wrap {
.label {
width: 92px;
height: 20px;
line-height: 20px;
font-weight: 400;
font-size: 14px;
color: #333333;
text-align: right;
}
.car-series-wrap{
margin-top: 8px;
width: 580px;
height: 80px;
background: #FFFFFF;
border: 1px solid #E8E8EA;
border-radius: 4px;
padding: 6px 8px;
overflow-y: auto;
.car-series-item{
display: inline-block;
padding: 0 8px;
height: 24px;
color: #666666;
line-height: 24px;
background: #FAFBFE;
border: 1px solid #E5E5E5;
border-radius: 4px;
margin-right: 4px;
}
.el-input {
width: 432px;
}
}
.selected-table {
margin-top: 10px;
width: 100%;
max-width: 1000px;
.el-button--text {
padding: 0;
}
}
.car-series-wrap {
margin-top: 8px;
width: 580px;
height: 80px;
background: #FFFFFF;
border: 1px solid #E8E8EA;
border-radius: 4px;
padding: 6px 8px;
overflow-y: auto;
.car-series-item {
display: inline-block;
padding: 0 8px;
height: 24px;
color: #666666;
line-height: 24px;
background: #FAFBFE;
border: 1px solid #E5E5E5;
border-radius: 4px;
margin-right: 4px;
}
}
}
.upload-img {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 104px;
height: 104px;
background: rgba(0, 0, 0, 0.04);
border: 1px dashed rgba(0, 0, 0, 0.15);
border-radius: 4px;
input {
position: absolute;
// top: 0;
// left: 0;
width: 104px;
height: 104px;
}
}
.avatar-uploader-desc-word {
font-weight: 400;
font-size: 28 rpx;
color: #666666;
}
.video-box {
position: relative;
width: 104px;
height: 104px;
border-radius: 4px;
margin-right: 8px;
&:hover .mask {
opacity: 1;
}
.video {
position: absolute;
object-fit: fill;
}
.photo-activity {
position: absolute;
width: 104px;
height: 104px;
}
.mask {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
background: rgba(0, 0, 0, 0.5);
color: #ffffff;
opacity: 0;
top: 0;
right: 0;
width: 104px;
height: 104px;
z-index: 999;
.video-pane-close {
width: 14px;
height: 14px;
cursor: pointer;
margin-right: 8px;
}
}
}
.activity-img-box {
display: flex;
}
.text-tip2 {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 14 rpx;
color: #999999;
margin-bottom: -35px;
}
</style>
\ No newline at end of file
</style>
<template>
<div class="goods-ctnr">
<div class="global-title">{{!routeInfo.id ? '新增': disabled ? '查看' : '编辑'}}商品</div>
<div class="container">
<glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
<div slot="selectBtnSlot">
<el-button :class="['el-icon-plus', {'disabled-class':disabled}]" size="small" @click="openGoodsDialog">选择商品</el-button>
</div>
<div slot="goodsInfoSlot" class="goods-wrap">
<glsx-combi-form :isInline="false" ref="goodsInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="goodsFormData" :formRules="goodsRule">
<div slot="uploadSlot" class="upload-calss">
<glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.coverList" @change="changeChannelImg"></glsx-preview>
<span class="tip">建议尺寸750*750,图片格式为jpg,jpeg,png,大小2M以内</span>
</div>
</glsx-combi-form>
</div>
<div slot="saleStoreSlot">
<el-button v-if="!disabled" class="el-icon-plus" size="small" @click="closeDialog">选择门店</el-button>
<template v-if="saleMerchantList && saleMerchantList.length">
<GLTable class="selected-table" :hasPage="false" ref="selectedRef" :tableParams="selectedtableParams" :tableData="saleMerchantList">
<div slot="activityPriceSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入" v-model="scope.scope.activityPrice"></format-input>
</div>
<div slot="originalPriceSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入" v-model="scope.scope.originalPrice"></format-input>
</div>
<div slot="giveIntegralSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入" v-model="scope.scope.giveIntegral"></format-input>
</div>
<div slot="auth-button" slot-scope="scope">
<el-button v-if="!disabled" type="text" @click="handleDel(scope.scope)">删除</el-button>
</div>
</GLTable>
</template>
</div>
<div slot="expressFeeSlot">
<format-input class="expressFee-class" :disabled="disabled" :intDigit="4" :precise="2" v-model="formObj.expressFee"></format-input>
<div class="goods-ctnr">
<div class="global-title">{{ !routeInfo.id ? '新增' : disabled ? '查看' : '编辑' }}商品</div>
<div class="container">
<glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px"
defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
<div slot="selectBtnSlot">
<el-button :class="['el-icon-plus', {'disabled-class':disabled}]" size="small" @click="openGoodsDialog">
选择商品
</el-button>
</div>
<div slot="goodsInfoSlot" class="goods-wrap">
<glsx-combi-form :isInline="false" ref="goodsInfoRef" labelWidth="154px" defaultWidth="432px"
:formObj.sync="formObj" :formData="goodsFormData" :formRules="goodsRule">
<div slot="uploadSlot" class="upload-calss">
<glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.coverList"
@change="changeChannelImg"></glsx-preview>
<span class="tip">建议尺寸750*750,图片格式为jpg,jpeg,png,大小2M以内</span>
</div>
</glsx-combi-form>
</div>
<div slot="saleStoreSlot">
<el-button v-if="!disabled" class="el-icon-plus" size="small" @click="closeDialog">选择门店</el-button>
<template v-if="saleMerchantList && saleMerchantList.length">
<GLTable class="selected-table" :hasPage="false" ref="selectedRef" :tableParams="selectedtableParams"
:tableData="saleMerchantList">
<div slot="activityPriceSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入"
v-model="scope.scope.activityPrice"></format-input>
</div>
<div slot="originalPriceSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入"
v-model="scope.scope.originalPrice"></format-input>
</div>
<div slot="giveIntegralSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入"
v-model="scope.scope.giveIntegral"></format-input>
</div>
<div slot="auth-button" slot-scope="scope">
<el-button v-if="!disabled" type="text" @click="handleDel(scope.scope)">删除</el-button>
</div>
</GLTable>
</template>
</div>
<div slot="productVideoSlot">
<el-form-item label="">
<template v-if="!formObj.goodsVideo">
<div class="upload-img">
<i class="el-icon-plus avatar-uploader-desc-icon"></i>
<div class="avatar-uploader-desc-word">上传视频</div>
<input type="file" class="upload-video" style="opacity: 0" accept=".mp4"
@change="e => handleVideoChange(e)"/>
</div>
</template>
<template v-else>
<div class="video-box">
<video id="video" width="100%" height="100%" preload loop muted>
<source :src="formObj.goodsVideo" type="video/mp4"/>
</video>
<div class="mask">
<div class="video-pane-close" @click="handleEnlarge(formObj.goodsVideo, 'video')">
<img src="../../assets/channel/view.png" alt=""/>
</div>
<div class="video-pane-close" @click="close('radio')">
<img src="../../assets/channel/dele.png" alt=""/>
</div>
</div>
</glsx-combi-form>
</div>
</template>
<div class="text-tip2">作为商品详情页顶部展示和详情展示,格式建议mp4,大小不超过20M</div>
</el-form-item>
</div>
<div slot="expressFeeSlot">
<format-input class="expressFee-class" :disabled="disabled" :intDigit="4" :precise="2"
v-model="formObj.expressFee"></format-input>
</div>
<GLFooter style="margin-top: 16px;">
<el-button @click="handleCancel">取消</el-button>
<el-button v-if="!disabled" type="primary" @click="handleSave">确定</el-button>
</GLFooter>
<selectGoods v-if="goodsVisible" :routeInfo="routeInfo" :dialogVisible="goodsVisible" :goodsInfo="formObj" @handleGoodsConfirm="handleGoodsConfirm" @handleGoodsClose="handleGoodsClose"></selectGoods>
<selectMerchantDialog @confirmDialog="confirmDialog" @closeDialog="closeDialog" :goodsId="formObj.smartcarlifeInfoId" :selectedList="saleMerchantList" v-if="merchantDialogVisible" :isVisible="merchantDialogVisible"></selectMerchantDialog>
</glsx-combi-form>
</div>
<GLFooter style="margin-top: 16px;">
<el-button @click="handleCancel">取消</el-button>
<el-button v-if="!disabled" type="primary" @click="handleSave">确定</el-button>
</GLFooter>
<selectGoods v-if="goodsVisible" :routeInfo="routeInfo" :dialogVisible="goodsVisible" :goodsInfo="formObj"
@handleGoodsConfirm="handleGoodsConfirm" @handleGoodsClose="handleGoodsClose"></selectGoods>
<selectMerchantDialog @confirmDialog="confirmDialog" @closeDialog="closeDialog"
:goodsId="formObj.smartcarlifeInfoId" :selectedList="saleMerchantList"
v-if="merchantDialogVisible" :isVisible="merchantDialogVisible"></selectMerchantDialog>
<el-dialog class="image-dialog" :visible.sync="dialogVisibleImg" width="50%">
<img :src="dialogSrc" width="100%" v-if="dialogType == 'img'" />
<video width="100%" autoplay controls :src="dialogSrc" v-else></video>
</el-dialog>
</div>
</template>
<script>
const MerchantColumns = [
const MerchantColumns = [
{
label: '门店名称',
prop: 'merchantName'
},
{
label: '门店原价(元)',
addHtml: 'originalPriceSlot'
},
{
label: '门店价格(元)',
width: 220,
addHtml: 'activityPriceSlot'
},
{
label: '赠送积分',
width: 220,
addHtml: 'giveIntegralSlot'
}
]
import glsxCombiForm from '@/components/glsx-combi-form'
import selectGoods from './components/selectGoods'
import selectMerchantDialog from './components/selectMerchantDialog'
export default {
name: 'add',
components: {
glsxCombiForm,
selectGoods,
selectMerchantDialog
},
data() {
return {
dialogVisibleImg:false,
goodsVisible: false,
merchantDialogVisible: false,
disabled: false,
dialogSrc:'',
goodsInfo: {},
routeInfo: {},
posterOptions: {
width: '104px',
height: '104px',
key: 'posterImg',
isClose: true
},
goodsFormData: [
{
label: '门店名称',
prop: 'merchantName'
label: '商品图',
addHtml: 'uploadSlot',
isDisabled: false
},
{
label: '门店原价(元)',
addHtml: 'originalPriceSlot'
label: '商品名称',
name: 'goodsName',
maxlength: 20,
showLimit: true,
type: 'input',
isDisabled: false
},
{
label: '门店价格(元)',
width: 220,
addHtml: 'activityPriceSlot'
label: '售价(元)',
name: 'retailPrice',
type: 'showTxt'
},
{
label: '赠送积分',
width: 220,
addHtml: 'giveIntegralSlot'
}
]
import glsxCombiForm from '@/components/glsx-combi-form'
import selectGoods from './components/selectGoods'
import selectMerchantDialog from './components/selectMerchantDialog'
export default {
name: 'add',
components: {
glsxCombiForm,
selectGoods,
selectMerchantDialog
},
data() {
return {
goodsVisible: false,
merchantDialogVisible: false,
disabled: false,
goodsInfo: {},
routeInfo: {},
posterOptions: {
width: '104px',
height: '104px',
key: 'posterImg',
isClose: true
},
goodsFormData:[
{
label: '商品图',
addHtml: 'uploadSlot',
isDisabled: false
},
{
label: '商品名称',
name: 'goodsName',
maxlength: 20,
showLimit: true,
type: 'input',
isDisabled: false
},
{
label: '售价(元)',
name: 'retailPrice',
type: 'showTxt'
},
{
label: '最低售价(元)',
name: 'minSellPrice',
type: 'showTxt'
},
],
formObj:{
source: '2',
method: '2',
goodsType: '2',
expressFee: '',
smartcarlifeInfoId: '',
goodsName: '',
goodsImage: '',
minSellPrice: '',
retailPrice: '',
coverList: [],
associationClassifyFirstId: '',
introduction: ''
},
saleMerchantList:[],
goodsList: [],
myRule: {
selectBtnSlot: [
{
required: true,
validator: (rule, value, callback) => {
if(!this.formObj.smartcarlifeInfoId){
callback(new Error('请选择商品'))
}else{
callback()
}
},
trigger: 'change'
}
],
goodsInfoSlot: [{
required: true,
validator: (rule, value, callback) => {
if(!this.formObj.coverList && !this.formObj.coverList[0]){
callback(new Error('请上传商品图'))
}else if(!this.formObj.goodsName){
callback(new Error('请输入商品名称'))
}else{
callback()
}
},
trigger: 'change'
}],
saleStoreSlot: [{
required: true,
validator: (rule, value, callback) => {
const _target = this.saleMerchantList.find(item => !item.activityPrice || !item.originalPrice)
const _integralTarget = this.saleMerchantList.find(item => !item.giveIntegral)
const hasTarget = this.saleMerchantList.find(item => {
let originalPrice = item.originalPrice || 0
let activityPrice = item.activityPrice || 0
let minSellPrice = this.formObj.minSellPrice || 0
return (+activityPrice > +originalPrice || +originalPrice < minSellPrice)
})
if(!this.saleMerchantList.length){
callback(new Error('请选择门店'))
}else if(_target){
callback(new Error('门店活动价和原价不能为空'))
}else if(hasTarget){
callback(new Error('原价不能小于最低售价和活动价'))
}else if(_integralTarget){
callback(new Error('请输入赠送积分'))
}else{
callback()
}
},
trigger: 'change'
}],
associationClassifyFirstId: [{required: true, message: '请选择关联商品分类', trigger: 'change'}],
source: [{required: true, message: '请选择来源', trigger: 'change'}],
method: [{required: true, message: '请选择配送方式', trigger: 'change'}],
expressFee: [{required: true, message: '请输入运费', trigger: 'change'}],
label: '最低售价(元)',
name: 'minSellPrice',
type: 'showTxt'
},
],
formObj: {
source: '2',
method: '2',
goodsType: '2',
expressFee: '',
smartcarlifeInfoId: '',
goodsName: '',
goodsImage: '',
minSellPrice: '',
retailPrice: '',
goodsVideo: '',
coverList: [],
associationClassifyFirstId: '',
introduction: ''
},
saleMerchantList: [],
goodsList: [],
myRule: {
selectBtnSlot: [
{
required: true,
validator: (rule, value, callback) => {
if (!this.formObj.smartcarlifeInfoId) {
callback(new Error('请选择商品'))
} else {
callback()
}
},
formData:[
{
label: '关联商品分类',
name: 'associationClassifyFirstId',
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'categoryName',
isDisabled: false
},
{
label: '来源',
name: 'source',
type: 'radio',
optionList: [{
confId: '2',
confName: '嘀加智享平台'
}],
optionId: 'confId',
optionLabel: 'confName',
isDisabled: false
},
{
label: '选择商品',
name: 'selectBtnSlot',
addHtml: 'selectBtnSlot',
isDisabled: false
},
{
label: '商品信息',
name: 'goodsInfoSlot',
addHtml: 'goodsInfoSlot',
isDisabled: false
},
{
label: '销售门店',
name: 'saleStoreSlot',
addHtml: 'saleStoreSlot',
isDisabled: false
},
{
label: '配送方式',
name: 'method',
type: 'radio',
optionList: [{
confId: '2',
confName: '快递发货'
}],
optionId: 'confId',
optionLabel: 'confName',
isDisabled: false
},
{
label: '运费/元',
name: 'expressFee',
addHtml: 'expressFeeSlot',
isDisabled: false
},
{
label: '服务说明',
name: 'introduction',
type: 'input',
inputType: 'textarea',
isDisabled: false,
maxlength: 200
},
],
selectedtableParams: {
listName: 'list',
tableOption: {
width: 100
},
tableColumns: MerchantColumns
trigger: 'change'
}
],
goodsInfoSlot: [{
required: true,
validator: (rule, value, callback) => {
if (!this.formObj.coverList && !this.formObj.coverList[0]) {
callback(new Error('请上传商品图'))
} else if (!this.formObj.goodsName) {
callback(new Error('请输入商品名称'))
} else {
callback()
}
}
},
created(){
this.getCategory()
const urlParam = this.$route.params
this.routeInfo = JSON.parse(decodeURIComponent(urlParam.id))
const { id, type } = this.routeInfo
if(type == 1) {
this.disabled = true
this.posterOptions.isClose = false
const _target = this.goodsFormData.find(item => item.name == 'goodsName')
_target.isDisabled = true
const disabledList = ['associationClassifyFirstId', 'source', 'method', 'introduction']
disabledList.forEach(ele => {
const _disabledTarget = this.formData.find(item => item.name == ele)
_disabledTarget.isDisabled = true
},
trigger: 'change'
}],
saleStoreSlot: [{
required: true,
validator: (rule, value, callback) => {
const _target = this.saleMerchantList.find(item => !item.activityPrice || !item.originalPrice)
const _integralTarget = this.saleMerchantList.find(item => !item.giveIntegral)
const hasTarget = this.saleMerchantList.find(item => {
let originalPrice = item.originalPrice || 0
let activityPrice = item.activityPrice || 0
let minSellPrice = this.formObj.minSellPrice || 0
return (+activityPrice > +originalPrice || +originalPrice < minSellPrice)
})
this.selectedtableParams.tableOption = null
}
if(id){
this.getDetail()
}
},
methods:{
getCategory(){
const params = {
pageSize: 10000,
pageNum: 1,
categoryType: 2
}
this.$apis.category.getCategoryListApi(params).then(res => {
if(res?.list?.length){
const _target = this.formData.find(item => item.name == 'associationClassifyFirstId')
_target.optionList = res.list
}
})
},
validateField(field){
if(Array.isArray(field)){
field.forEach(item => {
this.$refs.baseInfoRef.$refs.formRef.validateField(item)
})
}else{
this.$refs.baseInfoRef.$refs.formRef.validateField(field)
if (!this.saleMerchantList.length) {
callback(new Error('请选择门店'))
} else if (_target) {
callback(new Error('门店活动价和原价不能为空'))
} else if (hasTarget) {
callback(new Error('原价不能小于最低售价和活动价'))
} else if (_integralTarget) {
callback(new Error('请输入赠送积分'))
} else {
callback()
}
},
trigger: 'change'
}],
associationClassifyFirstId: [{required: true, message: '请选择关联商品分类', trigger: 'change'}],
source: [{required: true, message: '请选择来源', trigger: 'change'}],
method: [{required: true, message: '请选择配送方式', trigger: 'change'}],
expressFee: [{required: true, message: '请输入运费', trigger: 'change'}],
},
formData: [
{
label: '关联商品分类',
name: 'associationClassifyFirstId',
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'categoryName',
isDisabled: false
},
openGoodsDialog(){
if(this.disabled) return
this.goodsVisible = true
{
label: '来源',
name: 'source',
type: 'radio',
optionList: [{
confId: '2',
confName: '嘀加智享平台'
}],
optionId: 'confId',
optionLabel: 'confName',
isDisabled: false
},
handleGoodsClose(){
this.goodsVisible = false
{
label: '选择商品',
name: 'selectBtnSlot',
addHtml: 'selectBtnSlot',
isDisabled: false
},
handleGoodsConfirm(e){
if(this.formObj.smartcarlifeInfoId!=e?.id) this.saleMerchantList = []
let { id: smartcarlifeInfoId, goodsName, goodsImage, minSellPrice, retailPrice } = e || {}
minSellPrice = minSellPrice ? Number(Number(minSellPrice/100).toFixed(2)) : 0
retailPrice = retailPrice ? Number(Number(retailPrice/100).toFixed(2)) : 0
this.formObj = {...this.formObj, smartcarlifeInfoId, goodsName, goodsImage, coverList: [goodsImage], minSellPrice, retailPrice}
this.handleGoodsClose()
this.validateField(['selectBtnSlot','goodsInfoSlot'])
{
label: '商品信息',
name: 'goodsInfoSlot',
addHtml: 'goodsInfoSlot',
isDisabled: false
},
confirmDialog(e){
this.saleMerchantList = e || []
this.saleMerchantList.map(item => this.$set(item, 'giveIntegral', ''))
this.validateField('saleStoreSlot')
this.closeDialog()
{
label: '销售门店',
name: 'saleStoreSlot',
addHtml: 'saleStoreSlot',
isDisabled: false
},
closeDialog(){
if(!this.merchantDialogVisible && !this.formObj.smartcarlifeInfoId){
return this.$message.error('请先选择商品')
}
this.merchantDialogVisible = !this.merchantDialogVisible
{
label: '产品视频',
name: 'productVideo',
addHtml: 'productVideoSlot'
},
handleDel(row) {
const idx = this.saleMerchantList.findIndex(item => item.merchantId == row.merchantId)
if(idx>-1) this.saleMerchantList.splice(idx, 1)
{
label: '配送方式',
name: 'method',
type: 'radio',
optionList: [{
confId: '2',
confName: '快递发货'
}],
optionId: 'confId',
optionLabel: 'confName',
isDisabled: false
},
getParams(){
let obj = JSON.parse(JSON.stringify(this.formObj))
obj.goodsImage = obj.coverList[0]
obj.expressFee = obj.expressFee ? Number(Number(obj.expressFee*10*10).toFixed(0)) : 0
delete obj.minSellPrice
delete obj.retailPrice
delete obj.coverList
delete obj.source
delete obj.method
let saleMerchantList = this.saleMerchantList.map(item => {
let { merchantId, merchantName, activityPrice, giveIntegral, originalPrice } = item
activityPrice = activityPrice ? Number(Number(activityPrice*10*10).toFixed(0)) : 0
originalPrice = originalPrice ? Number(Number(originalPrice*10*10).toFixed(0)) : 0
return {merchantId , merchantName, activityPrice, giveIntegral, originalPrice}
})
const params = {
saleMerchantList: saleMerchantList,
...obj
}
if(this.routeInfo.id) params.id = this.routeInfo.id
return params
{
label: '运费/元',
name: 'expressFee',
addHtml: 'expressFeeSlot',
isDisabled: false
},
handleSave(){
this.$refs.baseInfoRef.$refs.formRef.validate(valid => {
if(valid){
const params = this.getParams()
this.$apis.goods.addGoodsApi(params).then(res =>{
if(res) {
this.$message.success('操作成功')
this.handleCancel()
}
})
}
})
{
label: '服务说明',
name: 'introduction',
type: 'input',
inputType: 'textarea',
isDisabled: false,
maxlength: 200
},
handleCancel(){
this.$router.back()
],
selectedtableParams: {
listName: 'list',
tableOption: {
width: 100
},
getDetail(){
const params = {
id: this.routeInfo.id
}
if(this.routeInfo.merchantId) params.merchantId= this.routeInfo.merchantId
this.$apis.goods.getGoodsDetail(params).then(res => {
if(res) {
for(const key in this.formObj){
const formatAttr = ['depositPrice', 'minSellPrice', 'retailPrice','expressFee']
if(formatAttr.includes(key)){
this.formObj[key] = res[key] ? Number(Number(res[key]/100).toFixed(2)) : 0
}else{
this.formObj[key] = res[key]
}
}
this.curCategoryInfo = {
categoryName: res.associationClassifySecondName,
id: res.associationClassifySecondId
}
this.formObj.goodsType = '2'
this.formObj.source = '2',
this.formObj.method = '2',
this.formObj.coverList = [res.goodsImage]
this.saleMerchantList = res.saleMerchantList?.map(item => {
let activityPrice = item.activityPrice ? Number(Number(item.activityPrice/100).toFixed(2)) : 0
let originalPrice = item.originalPrice ? Number(Number(item.originalPrice/100).toFixed(2)) : 0
return {...item, activityPrice, originalPrice}
}) || []
}
tableColumns: MerchantColumns
}
}
},
created() {
this.getCategory()
const urlParam = this.$route.params
this.routeInfo = JSON.parse(decodeURIComponent(urlParam.id))
const {id, type} = this.routeInfo
if (type == 1) {
this.disabled = true
this.posterOptions.isClose = false
const _target = this.goodsFormData.find(item => item.name == 'goodsName')
_target.isDisabled = true
const disabledList = ['associationClassifyFirstId', 'source', 'method', 'introduction']
disabledList.forEach(ele => {
const _disabledTarget = this.formData.find(item => item.name == ele)
_disabledTarget.isDisabled = true
})
this.selectedtableParams.tableOption = null
}
if (id) {
this.getDetail()
}
},
methods: {
// 上传视频
handleVideoChange(e) {
let file = e.srcElement.files[0]
var reader = new FileReader()
// 默认30MB
const limitSize = 20
const isLt = file.size / 1024 / 1024 < limitSize
if (!isLt) {
this.$message.error('上传视频大小不能超过' + limitSize + 'MB!')
this.loading = false
return
}
this.$notify({
title: '提示',
message: '视频上传中,请稍后'
})
document.querySelector('.upload-video').value = ''
reader.readAsDataURL(file)
reader.onload = e => {
const videoFile = e.target.result
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + videoFile.split(',')[1]
this.$apis.common.uploadVideoApi({file: base64}).then(res => {
if (res) {
this.$notify({
title: '提示',
message: '视频上传成功',
type: 'success'
})
this.loading = false
this.formObj.goodsVideo = res
} else {
this.loading = false
}
})
}
},
// 预览图文
handleEnlarge(src, type) {
this.dialogVisibleImg = true
this.dialogSrc = src
this.dialogType = type ? type : 'img'
},
// 删除图片/视频
close(type, index) {
switch (type) {
case 'radio':
this.formObj.goodsVideo = ''
break
default:
this.formObj.goodsVideo = ''
}
},
getCategory() {
const params = {
pageSize: 10000,
pageNum: 1,
categoryType: 2
}
this.$apis.category.getCategoryListApi(params).then(res => {
if (res?.list?.length) {
const _target = this.formData.find(item => item.name == 'associationClassifyFirstId')
_target.optionList = res.list
}
})
},
validateField(field) {
if (Array.isArray(field)) {
field.forEach(item => {
this.$refs.baseInfoRef.$refs.formRef.validateField(item)
})
} else {
this.$refs.baseInfoRef.$refs.formRef.validateField(field)
}
},
openGoodsDialog() {
if (this.disabled) return
this.goodsVisible = true
},
handleGoodsClose() {
this.goodsVisible = false
},
handleGoodsConfirm(e) {
if (this.formObj.smartcarlifeInfoId != e?.id) this.saleMerchantList = []
let {id: smartcarlifeInfoId, goodsName, goodsImage, minSellPrice, retailPrice,goodsVideo} = e || {}
minSellPrice = minSellPrice ? Number(Number(minSellPrice / 100).toFixed(2)) : 0
retailPrice = retailPrice ? Number(Number(retailPrice / 100).toFixed(2)) : 0
// 若选择的商品素材包含了视频,则带入对应的视频文件
if (goodsVideo) this.formObj.goodsVideo = goodsVideo
this.formObj = {
...this.formObj,
smartcarlifeInfoId,
goodsName,
goodsImage,
coverList: [goodsImage],
minSellPrice,
retailPrice
}
this.handleGoodsClose()
this.validateField(['selectBtnSlot', 'goodsInfoSlot'])
},
confirmDialog(e) {
this.saleMerchantList = e || []
this.saleMerchantList.map(item => this.$set(item, 'giveIntegral', ''))
this.validateField('saleStoreSlot')
this.closeDialog()
},
closeDialog() {
if (!this.merchantDialogVisible && !this.formObj.smartcarlifeInfoId) {
return this.$message.error('请先选择商品')
}
this.merchantDialogVisible = !this.merchantDialogVisible
},
handleDel(row) {
const idx = this.saleMerchantList.findIndex(item => item.merchantId == row.merchantId)
if (idx > -1) this.saleMerchantList.splice(idx, 1)
},
getParams() {
let obj = JSON.parse(JSON.stringify(this.formObj))
obj.goodsImage = obj.coverList[0]
obj.expressFee = obj.expressFee ? Number(Number(obj.expressFee * 10 * 10).toFixed(0)) : 0
delete obj.minSellPrice
delete obj.retailPrice
delete obj.coverList
delete obj.source
delete obj.method
let saleMerchantList = this.saleMerchantList.map(item => {
let {merchantId, merchantName, activityPrice, giveIntegral, originalPrice} = item
activityPrice = activityPrice ? Number(Number(activityPrice * 10 * 10).toFixed(0)) : 0
originalPrice = originalPrice ? Number(Number(originalPrice * 10 * 10).toFixed(0)) : 0
return {merchantId, merchantName, activityPrice, giveIntegral, originalPrice}
})
const params = {
saleMerchantList: saleMerchantList,
...obj
}
if (this.routeInfo.id) params.id = this.routeInfo.id
return params
},
handleSave() {
this.$refs.baseInfoRef.$refs.formRef.validate(valid => {
if (valid) {
const params = this.getParams()
this.$apis.goods.addGoodsApi(params).then(res => {
if (res) {
this.$message.success('操作成功')
this.handleCancel()
}
})
}
})
},
handleCancel() {
this.$router.back()
},
getDetail() {
const params = {
id: this.routeInfo.id
}
if (this.routeInfo.merchantId) params.merchantId = this.routeInfo.merchantId
this.$apis.goods.getGoodsDetail(params).then(res => {
if (res) {
for (const key in this.formObj) {
const formatAttr = ['depositPrice', 'minSellPrice', 'retailPrice', 'expressFee']
if (formatAttr.includes(key)) {
this.formObj[key] = res[key] ? Number(Number(res[key] / 100).toFixed(2)) : 0
} else {
this.formObj[key] = res[key]
}
}
this.curCategoryInfo = {
categoryName: res.associationClassifySecondName,
id: res.associationClassifySecondId
}
this.formObj.goodsType = '2'
this.formObj.source = '2',
this.formObj.method = '2',
this.formObj.coverList = [res.goodsImage]
this.saleMerchantList = res.saleMerchantList?.map(item => {
let activityPrice = item.activityPrice ? Number(Number(item.activityPrice / 100).toFixed(2)) : 0
let originalPrice = item.originalPrice ? Number(Number(item.originalPrice / 100).toFixed(2)) : 0
return {...item, activityPrice, originalPrice}
}) || []
}
})
}
}
}
</script>
<style scoped lang="scss">
.container{
background-color: #fff;
.glsx-combi-form{
/deep/ .el-radio-group{
.el-radio__label{
padding-left: 2px;
}
}
}
.disabled-class{
cursor: not-allowed;
color: #666666;
.container {
background-color: #fff;
.glsx-combi-form {
/deep/ .el-radio-group {
.el-radio__label {
padding-left: 2px;
}
}
.goods-wrap{
padding: 20px 20px 1px;
width: 970px;
background: #F9F9F9;
border-radius: 4px;
.upload-calss{
display: flex;
.tip{
height: 20px;
line-height: 20px;
align-self: flex-end;
font-weight: 400;
font-size: 14px;
color: #999999;
margin-left: 10px;
}
}
}
.disabled-class {
cursor: not-allowed;
color: #666666;
}
.goods-wrap {
padding: 20px 20px 1px;
width: 970px;
background: #F9F9F9;
border-radius: 4px;
.upload-calss {
display: flex;
.tip {
height: 20px;
line-height: 20px;
align-self: flex-end;
font-weight: 400;
font-size: 14px;
color: #999999;
margin-left: 10px;
}
}
.selected-table {
margin-top: 10px;
width: 970px;
.el-button--text{
padding: 0;
}
}
.selected-table {
margin-top: 10px;
width: 970px;
.el-button--text {
padding: 0;
}
.expressFee-class{
width: 432px;
}
.expressFee-class {
width: 432px;
}
/deep/ #introduction {
.el-textarea__inner {
width: 580px;
height: 80px;
}
/deep/ #introduction{
.el-textarea__inner{
width: 580px;
height: 80px;
}
}
}
.upload-img {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 104px;
height: 104px;
background: rgba(0, 0, 0, 0.04);
border: 1px dashed rgba(0, 0, 0, 0.15);
border-radius: 4px;
input {
position: absolute;
// top: 0;
// left: 0;
width: 104px;
height: 104px;
}
}
.avatar-uploader-desc-word {
font-weight: 400;
font-size: 28 rpx;
color: #666666;
}
.video-box {
position: relative;
width: 104px;
height: 104px;
border-radius: 4px;
margin-right: 8px;
&:hover .mask {
opacity: 1;
}
.video {
position: absolute;
object-fit: fill;
}
.photo-activity {
position: absolute;
width: 104px;
height: 104px;
}
.mask {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
background: rgba(0, 0, 0, 0.5);
color: #ffffff;
opacity: 0;
top: 0;
right: 0;
width: 104px;
height: 104px;
z-index: 999;
.video-pane-close {
width: 14px;
height: 14px;
cursor: pointer;
margin-right: 8px;
}
}
}
.activity-img-box {
display: flex;
}
.text-tip2 {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 14 rpx;
color: #999999;
margin-bottom: -35px;
}
</style>
\ No newline at end of file
</style>
<!-- 明细 -->
<template>
<div class="edit-share marketing edit-box">
<div class=" container1 edit-container">
<p class="edit-title">{{ routeInfo.activityName }}</p>
<div class="p-20">
<GLCombiForm
ref="showSearch"
:rowNumber="1"
:formObj="searchForm"
:formData="searchFormData"
@handleOk="handleSearch"
@handleRest="handleReset"
></GLCombiForm>
<div class="flex m-b-10 w-100-percent">
<div class="table-title">
已累计
<template v-if="routeInfo.type != 2">{{ decodeURI(routeInfo.name) }} </template>
<span>{{total || routeInfo.count }}</span>
{{ routeInfo.type == 2 ? '位访客' : '次' }}
</div>
<el-button
:size="size"
class="default-blue-btn"
type="default"
@click="handleExport"
>导出</el-button>
</div>
<!-- 表格区域 开始 -->
<GLTable
ref="browserRef"
:getListApi="getListApi"
:noDataImg="url"
:searchForm="searchForm"
:tableParams="tableParams"
:pageConf="pageConf"
:beforeSearchFn="beforeSearchFn"
@setTableFinishFun="setTableFinishFun"
>
<div
slot="customerName"
class="flex-align"
slot-scope="scope"
>
<template v-if="scope.scope.customerAvatar">
<el-popover
placement="top"
width="160"
trigger="hover"
popper-class="table-popover-block"
>
<img
class="table-popover-img"
:src="scope.scope.customerAvatar"
/>
<img
class="img-36 pointer"
slot="reference"
:src="scope.scope.customerAvatar"
/>
</el-popover>
</template>
<span class="m-l-10">{{ scope.scope.customerName }}</span>
</div>
<div
slot="shareName"
class="flex-align"
slot-scope="scope"
>
<template v-if="scope.scope.shareAvatar">
<el-popover
placement="top"
width="160"
trigger="hover"
popper-class="table-popover-block"
>
<img
class="table-popover-img"
:src="scope.scope.shareAvatar"
/>
<img
class="img-36 pointer"
slot="reference"
:src="scope.scope.shareAvatar"
/>
</el-popover>
</template>
<span class="m-l-10">{{ scope.scope.shareName }}</span>
<span class="m-l-10">{{ scope.scope.sharePhone }}</span>
</div>
<div
slot="isBuy"
slot-scope="scope"
>
<span :class="['table-circle', 'm-r-8', scope.scope.isBuy == 'Y' ? 'back-green' : 'back-grey']"></span>
<span>
{{
{
Y: '已付款',
N: '未付款'
}[scope.scope.isBuy] || '--'
}}
</span>
</div>
</GLTable>
<!-- 表格区域 end -->
</div>
</div>
<div
class="footer"
:style="{ left: footerLeft + 'px', width: footerWidth + 'px' }"
>
<el-button
type="default"
@click="handleJump"
>返回</el-button>
</div>
</div>
</template>
<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
import { exportFn } from '@/common/constant'
export default {
name: 'browseList',
data () {
return {
size: 'small',
url: url,
footerLeft: '0',
footerWidth: '0',
routeInfo: {
id: '',
activityName: ''
},
searchForm: {
customerName: '',
mobile: ''
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// 搜索
searchFormData: [
{
label: '微信昵称',
name: 'customerName',
type: 'input',
maxlength: 50
},
{
label: '手机号',
name: 'mobile',
type: 'input',
maxlength: 11
},
{
label: '分享人',
name: 'shareName',
type: 'input',
maxlength: 50
}
],
// 表格
getListApi: null,
tableParams: {
listName: 'list',
tableColumns: [
{
label: '微信昵称',
prop: 'customerName',
addHtml: 'customerName'
},
{
label: '手机号',
prop: 'mobile'
},
{
label: '分享人',
prop: 'shareName',
addHtml: 'shareName',
width: 230
}
]
},
total: 0
}
},
created () {
console.log(this.$route.query)
const lastTableColumns = [
{
label: '浏览时长',
prop: 'browserTime'
},
{
label: '进入页面时间',
prop: 'operationDate',
width: '180'
},
{
label: '离开页面时间',
prop: 'leaveDate',
width: '180'
},
{
label: '订单状态',
prop: 'isBuy',
addHtml: 'isBuy'
}
],
{ query } = this.$route,
name = {
1: '浏览',
2: '访客',
3: '分享'
}[query.type],
[url] = window.location.href.split('%24title'),
apiName = this.$apis.goods[
{
1: 'getBrowseListApi',
2: 'getVisitorListApi',
3: 'getSharedListApi'
}[query.type]]
query.name = name
this.routeInfo = query
this.getListApi = apiName
if (query.type == 1) this.getTotal(apiName, query.id)
history.replaceState(null, null, `${url}&$title=${name}明细`)
// listName:
//1 浏览 2 访客 3 分享
if (query.type != 2) {
this.searchFormData.push({
label: '订单状态',
name: 'isBuy',
type: 'select',
width: '215px',
optionList: [
{
confId: '',
confName: '全部'
},
{
confId: 'Y',
confName: '已付款'
},
{
confId: 'N',
confName: '未付款'
}
],
optionId: 'confId',
optionLabel: 'confName'
})
if (query.type == 3)
this.tableParams.tableColumns.push({
label: '分享时间',
prop: 'sharedTime'
})
this.tableParams.tableColumns = [...this.tableParams.tableColumns, ...lastTableColumns]
} else
this.tableParams.tableColumns = [
...this.tableParams.tableColumns,
{
label: '浏览次数',
prop: 'browseCount'
},
{
label: '最后浏览时间',
prop: 'lastBrowseDate'
}
]
},
mounted () {
this.footerLeft = document.querySelector('.base-container-right').offsetLeft
this.footerWidth = document.documentElement.clientWidth - this.footerLeft
},
methods: {
beforeSearchFn () {
return new Promise(resolve => {
this.searchForm.id = this.routeInfo.id
resolve()
})
},
handleExport () {
var params = this.$common.utils.deepClone(this.searchForm)
let { type } = this.routeInfo
params.pageNum = 1
params.pageSize = 999999
this.$apis.goods.exportBrowseApi(params, type).then(res => {
exportFn(res)
})
},
handleJump (path, row = {}) {
// this.$router.push({
// path: '/gooods/crowdFundList'
// })
// this.$route.query.activeName= this.routeInfo.activeName;
this.$router.back()
},
setTableFinishFun () {
//接收到的数据为空
this.$refs.browserRef.data.length ? (this.$refs.browserRef.tableHeightValues = '') : this.$refs.browserRef.setTableHeightFun()
},
handleSearch () {
const { query } = this.$route
this.$refs.browserRef.refreshTable()
if (query.type == 1) this.getTotal(this.$apis.goods.getBrowseListApi, query.id)
},
handleReset () {
this.searchForm = {
id: this.routeInfo.id,
customerName: '',
mobile: ''
}
this.handleSearch()
},
async getTotal (apiName, id) {
const { customerName, mobile } = this.searchForm, { total } = await apiName({
pageSize: 10,
pageNum: 1,
id,
customerName,
mobile
})
this.total = total
}
}
}
</script>
<style scoped lang="scss">
.edit-container {
.table-title {
font-weight: 400;
font-size: 14px;
color: #333333;
line-height: 20px;
display: flex;
align-items: center;
span {
color: #5850ff;
}
}
}
.m-b-10{
margin-bottom: 10px;
}
.m-l-10{
margin-left: 10px;
}
.flex{
display:flex;
justify-content: space-between;
}
.flex-align{
display: flex;
align-items:center
}
.footer{
position: fixed;
bottom: 0;
width: 100%;
height: 64px;
text-align: center;
line-height: 64px;
background: #fff;
z-index: 999;
}
.marketing .edit-title{
font-size: 16px;
font-weight: 600;
height: 58px;
line-height: 58px;
border-bottom: 1px solid #e7eaec;
margin: 0 0;
padding: 0 0 0 20px;
}
.marketing .edit-container{
margin-bottom:30px;
}
.p-20{
padding: 20px;
}
.marketing .container1{
background: #fff;
}
</style>
......@@ -10,7 +10,11 @@
</GLCombiForm>
<div class="operate-wrap">
<span class="table-title">发现商品列表</span>
<div>
<el-button class="operate-btn" type="primary" size="small" @click="handleAdd">新增商品</el-button>
<el-button size="small" @click="handleExport">导出</el-button>
</div>
</div>
<GLTable ref="channelRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :beforeSearchFn="beforeSearchFn" :tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun">
<div slot="imageSlot" class="table-image" slot-scope="scope">
......@@ -41,6 +45,20 @@
<span v-else>{{ filterData(scope.scope).join('、') }}</span>
</template>
</div>
<div
slot="linkText"
slot-scope="scope"
>
<template v-if="scope.scope.incrementFlag == 'Y' || hideStatus">
{{ scope.scope[scope.prop] || 0 }}
</template>
<template v-else>
<p
class="cursor-pointer"
@click="handleDetail(scope)"
>{{ scope.scope[scope.prop] || 0 }}</p>
</template>
</div>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="4"></GLTableButton>
</div>
......@@ -48,11 +66,12 @@
</div>
</div>
</template>
<script>
import url from '@/assets/empty.png'
import brandCascader from './components/brandCascader'
import preferList from './preferList'
import { exportFn } from '@/common/constant'
export default {
name: 'App',
components: {
......@@ -60,8 +79,9 @@
preferList
},
beforeRouteEnter(to, from, next) {
console.log(from)
next(vm =>{
if(from.path.indexOf('/goods/addPrefer')==0) {vm.activeName='2'}
if(from.path.indexOf('/goods/addPrefer')==0 || (from.path.indexOf('/goods/browseList')==0 && from.query.activeName== 2)) {vm.activeName='2'}
})
},
data() {
......@@ -211,6 +231,26 @@
addHtml: 'merchantPriceSlot'
},
{
label: '浏览量(次)',
prop: 'viewAmount',
addHtml: 'linkText',
width: 140
},
{
label: '访客',
prop: 'fansAmount',
addHtml: 'linkText'
},
{
label: '分享',
prop: 'shareAmount',
addHtml: 'linkText'
},
{
label: '销量',
prop: 'saleAmount'
},
{
label: '分类',
width: 150,
formatter: cellValue => {
......@@ -244,6 +284,42 @@
created() {},
mounted() {},
methods: {
// 明细
handleDetail ({ prop, scope }) {
let data = {
viewAmount: {
type: 1,
count: scope.viewAmount
},
fansAmount: {
type: 2,
count: scope.fansAmount
},
shareAmount: {
type: 3,
count: scope.shareAmount
}
}[prop]
this.$router.push({
path: '/goods/browseList',
query: {
id: scope.id,
activityName: scope.goodsName,
type: data.type,
count: data.count,
activeName:this.activeName
}
})
},
handleExport () {
var params = this.$common.utils.deepClone(this.searchForm)
params.goodsType = 1
this.$apis.goods.exportGoodsApi(params).then(res => {
exportFn(res)
})
},
selectCategory(e){
this.tableSearchForm.associationClassifyFirstId = e?.parent?.id
this.tableSearchForm.associationClassifySecondId = e?.data?.id
......@@ -339,14 +415,14 @@
params.type = type
title = type == 1 ? '查看商品' : '编辑商品'
}
const queryStr = encodeURIComponent(JSON.stringify(params))
this.$router.push({ path: `/goods/add/`+queryStr,query: { $title: title }})
}
}
}
</script>
<style scoped lang="scss">
.goods-list-cntr{
.search-wrap{
......@@ -382,5 +458,8 @@
}
}
}
.cursor-pointer{
cursor:pointer;
color:#5850FF;
}
</style>
\ No newline at end of file
<template>
<div class="prefer-list-cntr">
<div class="table-wrap">
<GLCombiForm ref="showSearch" class="search-wrap" :rowNumber="1" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset">
</GLCombiForm>
<div class="operate-wrap">
<span class="table-title">车主优选商品列表</span>
<el-button class="operate-btn" type="primary" size="small" @click="handleAdd">新增商品</el-button>
</div>
<GLTable ref="channelRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :beforeSearchFn="beforeSearchFn" :tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun">
<div slot="imageSlot" class="table-image" slot-scope="scope">
<el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
<img class="table-popover-img" :src="scope.scope.goodsImage" />
<img class="img-36 pointer" slot="reference" :src="scope.scope.goodsImage" />
</el-popover>
</div>
<div slot="statusSlot" slot-scope="scope">
<span :class="['status', scope.scope.goodsStatus==1 ? 'success-status': 'error-status']"></span>
<span>{{scope.scope.goodsStatus==1 ? '上架' : '下架' }}</span>
</div>
<div slot="merchantPriceSlot" slot-scope="scope">
<template v-if="scope.scope.saleMerchantList && scope.scope.saleMerchantList.length > 1">
<span>{{ filterData(scope.scope).slice(0, 1).join('、') }}</span>
<el-popover
placement="top"
width="fit-content"
trigger="hover">
<div v-for="(item,index) in filterData(scope.scope)" :key="index">
{{item}}
</div>
<span class="more-info" slot="reference">...[{{ scope.scope.saleMerchantList.length }}]</span>
</el-popover>
</template>
<template v-else>
<span v-if="!scope.scope.saleMerchantList || !scope.scope.saleMerchantList.length">--</span>
<span v-else>{{ filterData(scope.scope).join('、') }}</span>
</template>
</div>
<div slot="giveIntegralSlot" slot-scope="scope">
<template v-if="scope.scope.saleMerchantList && scope.scope.saleMerchantList.length > 1">
<span>{{ filterData(scope.scope,1).slice(0, 1).join('、') }}</span>
<el-popover
placement="top"
width="400"
trigger="hover">
<div v-for="(item,index) in filterData(scope.scope,1)" :key="index">
{{item}}
</div>
<span class="more-info" slot="reference">...({{ scope.scope.saleMerchantList.length }})</span>
</el-popover>
</template>
<template v-else>
<span v-if="!scope.scope.saleMerchantList || !scope.scope.saleMerchantList.length">--</span>
<span v-else>{{ filterData(scope.scope,1).join('、') }}</span>
</template>
</div>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="4"></GLTableButton>
</div>
</GLTable>
<div class="prefer-list-cntr">
<div class="table-wrap">
<GLCombiForm ref="showSearch" class="search-wrap" :rowNumber="1" :formObj="tableSearchForm"
:formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset">
</GLCombiForm>
<div class="operate-wrap">
<span class="table-title">车主优选商品列表</span>
<div>
<el-button class="operate-btn" type="primary" size="small" @click="handleAdd">新增商品</el-button>
<el-button size="small" @click="handleExport">导出</el-button>
</div>
</div>
<GLTable ref="channelRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm"
:beforeSearchFn="beforeSearchFn" :tableParams="tableParams" :pageConf="pageConf"
@setTableFinishFun="setTableFinishFun">
<div slot="imageSlot" class="table-image" slot-scope="scope">
<el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
<img class="table-popover-img" :src="scope.scope.goodsImage"/>
<img class="img-36 pointer" slot="reference" :src="scope.scope.goodsImage"/>
</el-popover>
</div>
<div slot="statusSlot" slot-scope="scope">
<span :class="['status', scope.scope.goodsStatus==1 ? 'success-status': 'error-status']"></span>
<span>{{ scope.scope.goodsStatus == 1 ? '上架' : '下架' }}</span>
</div>
<div slot="merchantPriceSlot" slot-scope="scope">
<template v-if="scope.scope.saleMerchantList && scope.scope.saleMerchantList.length > 1">
<span>{{ filterData(scope.scope).slice(0, 1).join('、') }}</span>
<el-popover
placement="top"
width="fit-content"
trigger="hover">
<div v-for="(item,index) in filterData(scope.scope)" :key="index">
{{ item }}
</div>
<span class="more-info" slot="reference">...[{{ scope.scope.saleMerchantList.length }}]</span>
</el-popover>
</template>
<template v-else>
<span v-if="!scope.scope.saleMerchantList || !scope.scope.saleMerchantList.length">--</span>
<span v-else>{{ filterData(scope.scope).join('、') }}</span>
</template>
</div>
<div
slot="linkText"
slot-scope="scope"
>
<template v-if="scope.scope.incrementFlag == 'Y' || hideStatus">
{{ scope.scope[scope.prop] || 0 }}
</template>
<template v-else>
<p
class="cursor-pointer"
@click="handleDetail(scope)"
>{{ scope.scope[scope.prop] || 0 }}</p>
</template>
</div>
<div slot="giveIntegralSlot" slot-scope="scope">
<template v-if="scope.scope.saleMerchantList && scope.scope.saleMerchantList.length > 1">
<span>{{ filterData(scope.scope, 1).slice(0, 1).join('、') }}</span>
<el-popover
placement="top"
width="400"
trigger="hover">
<div v-for="(item,index) in filterData(scope.scope,1)" :key="index">
{{ item }}
</div>
<span class="more-info" slot="reference">...({{ scope.scope.saleMerchantList.length }})</span>
</el-popover>
</template>
<template v-else>
<span v-if="!scope.scope.saleMerchantList || !scope.scope.saleMerchantList.length">--</span>
<span v-else>{{ filterData(scope.scope, 1).join('、') }}</span>
</template>
</div>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="4"></GLTableButton>
</div>
</GLTable>
</div>
</template>
<script>
import url from '@/assets/empty.png'
export default {
name: 'App',
data() {
return {
tableSearchForm: {
channelName: '',
createDate: [],
associationClassifyFirstId: '',
associationClassifySecondId: '',
merchantName: '',
goodsType: '2',
</div>
</template>
<script>
import url from '@/assets/empty.png'
import { exportFn } from '@/common/constant'
export default {
name: 'App',
data() {
return {
tableSearchForm: {
channelName: '',
createDate: [],
associationClassifyFirstId: '',
associationClassifySecondId: '',
merchantName: '',
goodsType: '2',
},
tabPaneList: [{name: 'sa', label: '配置升级'}, {name: 'sa', label: '车主优选'}],
buttonList: [
{
type: 'el-button',
name: '查看',
attrs: {
type: 'text',
fn: '查看'
},
listeners: {
click: row => this.handleAdd(row.scope, 1)
}
},
tabPaneList: [{name: 'sa', label: '配置升级'}, {name: 'sa', label: '车主优选'}],
buttonList: [
{
type: 'el-button',
name: '查看',
attrs: {
type: 'text',
fn: '查看'
{
type: 'el-button',
name: '编辑',
attrs: {
type: 'text',
fn: '编辑'
},
listeners: {
click: row => this.handleAdd(row.scope, 2)
}
},
{
type: 'el-button',
name: '上架',
attrs: {
type: 'text',
fn: '上架'
},
condition: row => {
return row.scope.goodsStatus != 1
},
listeners: {
click: row => this.shelfGoodsFn(row.scope, 1)
}
},
{
type: 'el-button',
name: '下架',
attrs: {
type: 'text',
fn: '下架'
},
condition: row => {
return row.scope.goodsStatus == 1
},
listeners: {
click: row => this.shelfGoodsFn(row.scope, 0)
}
},
{
type: 'el-button',
name: '删除',
attrs: {
type: 'text',
fn: '删除'
},
condition: row => {
return row.scope.goodsStatus != 1
},
listeners: {
click: row => this.delGoodsFn(row.scope)
}
}
],
searchForm: {},
url: url,
searchFormData: [
{
label: '商品名称',
name: 'goodsName',
type: 'input'
},
{
label: '创建日期',
name: 'createDate',
type: 'datePicker',
isClear: true,
customPickerOptions: {
disabledDate(date) {
const yesterday = new Date(new Date().setDate(new Date().getDate()))
if (date > yesterday) {
return true
}
return false
}
}
},
{
label: '分类名称',
name: 'associationClassifyFirstId',
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'categoryName',
},
{
label: '来源',
name: 'source',
type: 'select',
optionList: [
{
id: '',
name: '全部'
},
listeners: {
click: row => this.handleAdd(row.scope, 1)
// {
// id: '1',
// name: '云中鹤'
// },
{
id: '2',
name: '嘀加智享'
},
],
optionId: 'id',
optionLabel: 'name'
},
],
getListApi: this.$apis.goods.getGoodsListApi,
tableParams: {
listName: 'list',
tableOption: {
width: 200
},
tableColumns: [
{
label: '来源',
prop: 'sourse',
width: 150,
formatter: cellValue => {
return '嘀加智享平台'
}
},
{
type: 'el-button',
name: '编辑',
attrs: {
type: 'text',
fn: '编辑'
},
listeners: {
click: row => this.handleAdd(row.scope, 2)
}
label: '商品名称',
width: 150,
prop: 'goodsName'
},
{
type: 'el-button',
name: '上架',
attrs: {
type: 'text',
fn: '上架'
},
condition: row => {
return row.scope.goodsStatus!=1
},
listeners: {
click: row => this.shelfGoodsFn(row.scope, 1)
}
label: '缩略图',
addHtml: 'imageSlot'
},
// {
// label: '供货价格(元)',
// formatter: cellValue => {
// return cellValue.paymentType==1 ? '全款' : '定金+尾款'
// }
// },
// {
// label: '市场价格(元)',
// formatter: cellValue => {
// return cellValue.depositPrice ? Number((Number(cellValue.depositPrice)/100).toFixed(2)) : '--'
// }
// },
{
type: 'el-button',
name: '下架',
attrs: {
type: 'text',
fn: '下架'
},
condition: row => {
return row.scope.goodsStatus==1
},
listeners: {
click: row => this.shelfGoodsFn(row.scope, 0)
}
label: '销售价格(元)',
width: 200,
addHtml: 'merchantPriceSlot'
},
{
type: 'el-button',
name: '删除',
attrs: {
type: 'text',
fn: '删除'
},
condition: row => {
return row.scope.goodsStatus!=1
},
listeners: {
click: row => this.delGoodsFn(row.scope)
}
}
],
searchForm: {},
url: url,
searchFormData: [
label: '浏览量(次)',
prop: 'viewAmount',
addHtml: 'linkText',
width: 140
},
{
label: '商品名称',
name: 'goodsName',
type: 'input'
label: '访客',
prop: 'fansAmount',
addHtml: 'linkText'
},
{
label: '创建日期',
name: 'createDate',
type: 'datePicker',
isClear: true,
customPickerOptions: {
disabledDate(date) {
const yesterday = new Date(new Date().setDate(new Date().getDate()))
if (date > yesterday) {
return true
}
return false
}
}
label: '分享',
prop: 'shareAmount',
addHtml: 'linkText'
},
{
label: '分类名称',
name: 'associationClassifyFirstId',
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'categoryName',
label: '销量',
prop: 'saleAmount'
},
{
label: '来源',
name: 'source',
type: 'select',
optionList: [
{
id: '',
name: '全部'
},
// {
// id: '1',
// name: '云中鹤'
// },
{
id: '2',
name: '嘀加智享'
},
],
optionId: 'id',
optionLabel: 'name'
label: '赠送积分',
width: 200,
addHtml: 'giveIntegralSlot'
},
],
getListApi: this.$apis.goods.getGoodsListApi,
tableParams: {
listName: 'list',
tableOption: {
width: 200
{
label: '商品分类',
width: 180,
prop: 'associationClassifyFirstName'
},
tableColumns: [
{
label: '来源',
prop: 'sourse',
width: 150,
formatter: cellValue => {
return '嘀加智享平台'
}
},
{
label: '商品名称',
width: 150,
prop: 'goodsName'
},
{
label: '缩略图',
addHtml: 'imageSlot'
},
// {
// label: '供货价格(元)',
// formatter: cellValue => {
// return cellValue.paymentType==1 ? '全款' : '定金+尾款'
// }
// },
// {
// label: '市场价格(元)',
// formatter: cellValue => {
// return cellValue.depositPrice ? Number((Number(cellValue.depositPrice)/100).toFixed(2)) : '--'
// }
// },
{
label: '销售价格(元)',
width: 200,
addHtml: 'merchantPriceSlot'
},
{
label: '赠送积分',
width: 200,
addHtml: 'giveIntegralSlot'
},
{
label: '商品分类',
width: 180,
prop: 'associationClassifyFirstName'
},
{
label: '状态',
addHtml: 'statusSlot'
},
{
label: '创建日期',
prop: 'createdDate',
width: 220
},
{
label: '更新时间',
prop: 'updatedDate',
width: 220
},
{
label: '操作人',
prop: 'updatedBy',
},
]
{
label: '状态',
addHtml: 'statusSlot'
},
{
label: '创建日期',
prop: 'createdDate',
width: 220
},
{
label: '更新时间',
prop: 'updatedDate',
width: 220
},
{
label: '操作人',
prop: 'updatedBy',
},
]
},
pageConf: {pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total'}
}
},
created() {
this.getCategory()
},
mounted() {
},
methods: {
// 明细
handleDetail({prop, scope}) {
let data = {
viewAmount: {
type: 1,
count: scope.viewAmount
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }
}
},
created() {
this.getCategory()
},
mounted() {},
methods: {
getCategory(){
const params = {
pageSize: 10000,
pageNum: 1,
categoryType: 2
fansAmount: {
type: 2,
count: scope.fansAmount
},
shareAmount: {
type: 3,
count: scope.shareAmount
}
this.$apis.category.getCategoryListApi(params).then(res => {
if(res?.list?.length){
const _target = this.searchFormData.find(item => item.name == 'associationClassifyFirstId')
_target && (_target.optionList = res.list)
console.log(this.searchFormData)
}
}[prop]
this.$router.push({
path: '/goods/browseList',
query: {
id: scope.id,
activityName: scope.goodsName,
type: data.type,
count: data.count,
activeName:'2'
}
})
},
handleExport () {
var params = this.$common.utils.deepClone(this.searchForm)
params.goodsType = 2
this.$apis.goods.exportGoodsApi(params).then(res => {
exportFn(res)
})
},
selectCategory(e){
this.tableSearchForm.associationClassifyFirstId = e?.parent?.id
this.tableSearchForm.associationClassifySecondId = e?.data?.id
},
shelfGoodsFn(item, type){
if(type==1){
this.updateStatus(item.id, type)
}else{
this.$confirm(`确定下架该商品吗`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.updateStatus(item.id, type)
}
}
})
getCategory() {
const params = {
pageSize: 10000,
pageNum: 1,
categoryType: 2
}
this.$apis.category.getCategoryListApi(params).then(res => {
if (res?.list?.length) {
const _target = this.searchFormData.find(item => item.name == 'associationClassifyFirstId')
_target && (_target.optionList = res.list)
console.log(this.searchFormData)
}
},
delGoodsFn(item){
this.$confirm(`确定删除该商品吗`, '提示', {
})
},
selectCategory(e) {
this.tableSearchForm.associationClassifyFirstId = e?.parent?.id
this.tableSearchForm.associationClassifySecondId = e?.data?.id
},
shelfGoodsFn(item, type) {
if (type == 1) {
this.updateStatus(item.id, type)
} else {
this.$confirm(`确定下架该商品吗`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.$apis.goods.delGoodsApi({id: item.id}).then(res =>{
if(res){
this.$message.success('删除成功')
this.handleSearch()
}
})
this.updateStatus(item.id, type)
}
}
})
},
updateStatus(id, goodsStatus){
this.$apis.goods.updateGoodsStatusApi({id, goodsStatus}).then(res =>{
if(res){
this.$message.success('操作成功')
this.handleSearch()
}
},
delGoodsFn(item) {
this.$confirm(`确定删除该商品吗`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.$apis.goods.delGoodsApi({id: item.id}).then(res => {
if (res) {
this.$message.success('删除成功')
this.handleSearch()
}
})
}
})
},
filterData({saleMerchantList: list},notFormat){
if(notFormat){
return list?.map(item => {
return `${item.merchantName || '--'}:${item.giveIntegral || '0'}`
}) || []
}else{
return list?.map(item => {
let activityPrice = item.activityPrice ? Number((Number(item.activityPrice)/100).toFixed(2)) : 0
return `${item.merchantName || '--'}:${activityPrice || '0'}`
}) || []
}
},
getParams() {
var params = JSON.parse(JSON.stringify(this.tableSearchForm))
if (this.tableSearchForm.createDate.length) {
params.startCreatedDate = new Date(this.tableSearchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.endCreatedDate = new Date(this.tableSearchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
})
},
updateStatus(id, goodsStatus) {
this.$apis.goods.updateGoodsStatusApi({id, goodsStatus}).then(res => {
if (res) {
this.$message.success('操作成功')
this.handleSearch()
}
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.searchForm = this.getParams()
delete this.searchForm.createDate
resolve()
})
},
handleSearch() {
this.$refs.channelRef.refreshTable()
},
handleReset() {
this.tableSearchForm = {
goodsType: '2',
createDate: [],
associationClassifyFirstId: '',
associationClassifySecondId: '',
merchantName: ''
},
this.$refs?.cascaderRef?.curBrand && (this.$refs.cascaderRef.curBrand = {})
this.searchForm = {}
this.handleSearch()
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.channelRef.data.length ? (this.$refs.channelRef.tableHeightValues = '') : this.$refs.channelRef.setTableHeightFun()
})
},
filterData({saleMerchantList: list}, notFormat) {
if (notFormat) {
return list?.map(item => {
return `${item.merchantName || '--'}:${item.giveIntegral || '0'}`
}) || []
} else {
return list?.map(item => {
let activityPrice = item.activityPrice ? Number((Number(item.activityPrice) / 100).toFixed(2)) : 0
return `${item.merchantName || '--'}:${activityPrice || '0'}`
}) || []
}
},
getParams() {
var params = JSON.parse(JSON.stringify(this.tableSearchForm))
if (this.tableSearchForm.createDate.length) {
params.startCreatedDate = new Date(this.tableSearchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.endCreatedDate = new Date(this.tableSearchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.searchForm = this.getParams()
delete this.searchForm.createDate
resolve()
})
},
handleSearch() {
this.$refs.channelRef.refreshTable()
},
handleReset() {
this.tableSearchForm = {
goodsType: '2',
createDate: [],
associationClassifyFirstId: '',
associationClassifySecondId: '',
merchantName: ''
},
handleAdd(row={},type){
const params = {
goodsType: '2'
}
let title = '新增商品'
if(type){
params.id = row.id
params.type = type
title = type == 1 ? '查看商品' : '编辑商品'
}
const queryStr = encodeURIComponent(JSON.stringify(params))
this.$router.push({ path: `/goods/addPrefer/`+queryStr,query: { $title: title }})
this.$refs?.cascaderRef?.curBrand && (this.$refs.cascaderRef.curBrand = {})
this.searchForm = {}
this.handleSearch()
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.channelRef.data.length ? (this.$refs.channelRef.tableHeightValues = '') : this.$refs.channelRef.setTableHeightFun()
},
handleAdd(row = {}, type) {
const params = {
goodsType: '2'
}
let title = '新增商品'
if (type) {
params.id = row.id
params.type = type
title = type == 1 ? '查看商品' : '编辑商品'
}
const queryStr = encodeURIComponent(JSON.stringify(params))
this.$router.push({path: `/goods/addPrefer/` + queryStr, query: {$title: title}})
}
}
</script>
}
</script>
<style scoped lang="scss">
.prefer-list-cntr{
.table-wrap{
margin-top: 16px;
padding: 20px;
background-color: #fff;
.status{
width: 6px;
height: 6px;
border-radius: 50%;
display: inline-block;
vertical-align: middle;
margin-right: 8px;
}
.success-status{
background-color: #37C67F;
}
.error-status{
background-color: #999999;
}
.more-info{
white-space: nowrap;
color: #5850FF;
cursor: pointer;
}
.prefer-list-cntr {
.table-wrap {
margin-top: 16px;
padding: 20px;
background-color: #fff;
.status {
width: 6px;
height: 6px;
border-radius: 50%;
display: inline-block;
vertical-align: middle;
margin-right: 8px;
}
.success-status {
background-color: #37C67F;
}
.error-status {
background-color: #999999;
}
.more-info {
white-space: nowrap;
color: #5850FF;
cursor: pointer;
}
}
}
.cursor-pointer{
cursor:pointer;
color:#5850FF;
}
</style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!