修复编辑商品详情的bug

This commit is contained in:
weipengfei 2023-10-14 10:51:13 +08:00
parent 48f7c566b7
commit f1139b29b5

View File

@ -127,7 +127,7 @@
@click="modalPicTap('1')" @click="modalPicTap('1')"
> >
<div v-if="formValidate.image" class="pictrue"> <div v-if="formValidate.image" class="pictrue">
<img :src="formValidate.image"> <img :src="formValidate.image" />
</div> </div>
<div v-else class="upLoad"> <div v-else class="upLoad">
<i class="el-icon-camera cameraIconfont" /> <i class="el-icon-camera cameraIconfont" />
@ -148,7 +148,7 @@
@dragenter="handleDragEnter($event, item)" @dragenter="handleDragEnter($event, item)"
@dragend="handleDragEnd($event, item)" @dragend="handleDragEnd($event, item)"
> >
<img :src="item"> <img :src="item" />
<i <i
class="el-icon-error btndel" class="el-icon-error btndel"
@click="handleRemove(index)" @click="handleRemove(index)"
@ -178,9 +178,9 @@
<input <input
ref="refid" ref="refid"
type="file" type="file"
style="display:none" style="display: none"
@change="zh_uploadFile_change" @change="zh_uploadFile_change"
> />
<el-button <el-button
type="primary" type="primary"
icon="ios-cloud-upload-outline" icon="ios-cloud-upload-outline"
@ -195,13 +195,17 @@
:percentage="progress" :percentage="progress"
:text-inside="true" :text-inside="true"
:stroke-width="20" :stroke-width="20"
style="margin-top: 10px;" style="margin-top: 10px"
/> />
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<div v-if="formValidate.video_link" class="iview-video-style"> <div v-if="formValidate.video_link" class="iview-video-style">
<video <video
style="width:100%;height: 100%!important;border-radius: 10px;" style="
width: 100%;
height: 100% !important;
border-radius: 10px;
"
:src="formValidate.video_link" :src="formValidate.video_link"
controls="controls" controls="controls"
> >
@ -255,11 +259,9 @@
@close="handleCloseCoupon(tag)" @close="handleCloseCoupon(tag)"
>{{ tag.title }} >{{ tag.title }}
</el-tag> </el-tag>
<el-button <el-button class="mr15" size="mini" @click="addCoupon"
class="mr15" >选择优惠券</el-button
size="mini" >
@click="addCoupon"
>选择优惠券</el-button>
</div> </div>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -325,12 +327,11 @@
class="ml15" class="ml15"
size="small" size="small"
@click="confirm" @click="confirm"
>确认</el-button> >确认</el-button
<el-button >
class="ml15" <el-button class="ml15" size="small" @click="addRule"
size="small" >添加规格模板</el-button
@click="addRule" >
>添加规格模板</el-button>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item v-if="formValidate.attr.length > 0"> <el-form-item v-if="formValidate.attr.length > 0">
@ -369,7 +370,8 @@
class="button-new-tag" class="button-new-tag"
size="small" size="small"
@click="showInput(item)" @click="showInput(item)"
>+ 添加</el-button> >+ 添加</el-button
>
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
@ -392,11 +394,9 @@
</el-col> </el-col>
<el-col :xl="12" :lg="6" :md="6" :sm="24" :xs="24"> <el-col :xl="12" :lg="6" :md="6" :sm="24" :xs="24">
<el-form-item class="noLeft"> <el-form-item class="noLeft">
<el-button <el-button type="primary" class="mr15" @click="createAttrName"
type="primary" >确定</el-button
class="mr15" >
@click="createAttrName"
>确定</el-button>
<el-button @click="offAttrName">取消</el-button> <el-button @click="offAttrName">取消</el-button>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -407,7 +407,8 @@
icon="md-add" icon="md-add"
class="mr15" class="mr15"
@click="addBtn" @click="addBtn"
>添加新规格</el-button> >添加新规格</el-button
>
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- 批量设置--> <!-- 批量设置-->
@ -431,7 +432,7 @@
@click="modalPicTap('1', 'pi')" @click="modalPicTap('1', 'pi')"
> >
<div v-if="scope.row.image" class="pictrue tabPic"> <div v-if="scope.row.image" class="pictrue tabPic">
<img :src="scope.row.image"> <img :src="scope.row.image" />
</div> </div>
<div v-else class="upLoad tabPic"> <div v-else class="upLoad tabPic">
<i class="el-icon-camera cameraIconfont" /> <i class="el-icon-camera cameraIconfont" />
@ -451,7 +452,6 @@
<el-input <el-input
v-if="formThead[iii].title === '付费会员价'" v-if="formThead[iii].title === '付费会员价'"
v-model="scope.row[iii]" v-model="scope.row[iii]"
:disabled="formValidate.svip_price_type == 1" :disabled="formValidate.svip_price_type == 1"
class="priceBox" class="priceBox"
controls-position="right" controls-position="right"
@ -525,11 +525,9 @@
</template> </template>
<el-table-column align="center" label="操作" min-width="80"> <el-table-column align="center" label="操作" min-width="80">
<template> <template>
<el-button <el-button type="text" class="submission" @click="batchAdd"
type="text" >批量添加</el-button
class="submission" >
@click="batchAdd"
>批量添加</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -551,7 +549,7 @@
@click="modalPicTap('1', 'dan', 'pi')" @click="modalPicTap('1', 'dan', 'pi')"
> >
<div v-if="formValidate.image" class="pictrue tabPic"> <div v-if="formValidate.image" class="pictrue tabPic">
<img :src="scope.row.image"> <img :src="scope.row.image" />
</div> </div>
<div v-else class="upLoad tabPic"> <div v-else class="upLoad tabPic">
<i class="el-icon-camera cameraIconfont" /> <i class="el-icon-camera cameraIconfont" />
@ -677,7 +675,7 @@
@click="modalPicTap('1', 'duo', scope.$index)" @click="modalPicTap('1', 'duo', scope.$index)"
> >
<div v-if="scope.row.image" class="pictrue tabPic"> <div v-if="scope.row.image" class="pictrue tabPic">
<img :src="scope.row.image"> <img :src="scope.row.image" />
</div> </div>
<div v-else class="upLoad tabPic"> <div v-else class="upLoad tabPic">
<i class="el-icon-camera cameraIconfont" /> <i class="el-icon-camera cameraIconfont" />
@ -779,7 +777,8 @@
type="text" type="text"
class="submission" class="submission"
@click="delAttrTable(scope.$index)" @click="delAttrTable(scope.$index)"
>删除</el-button> >删除</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -808,8 +807,13 @@
title="750*750px" title="750*750px"
@click="modalPicTap('3')" @click="modalPicTap('3')"
> >
<div v-for="(item, index) in formValidate.content.image" class="pictrue details_pictrue"> <div
<img :src="item" :key="index"> v-for="(item, index) in formValidate.content.image"
class="pictrue details_pictrue"
@click.stop="deleteContentImg(index)"
:key="index + item"
>
<img :src="item" :key="index" />
</div> </div>
<div class="upLoad details_pictrue"> <div class="upLoad details_pictrue">
<i class="el-icon-camera cameraIconfont" /> <i class="el-icon-camera cameraIconfont" />
@ -939,11 +943,9 @@
:value="item.shipping_template_id" :value="item.shipping_template_id"
/> />
</el-select> </el-select>
<el-button <el-button class="ml15" size="small" @click="addTem"
class="ml15" >添加运费模板</el-button
size="small" >
@click="addTem"
>添加运费模板</el-button>
</div> </div>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -1009,11 +1011,9 @@
:value="item.guarantee_template_id" :value="item.guarantee_template_id"
/> />
</el-select> </el-select>
<el-button <el-button class="ml15" size="small" @click="addServiceTem"
class="ml15" >添加服务说明模板</el-button
size="small" >
@click="addServiceTem"
>添加服务说明模板</el-button>
</div> </div>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -1080,7 +1080,8 @@
type="text" type="text"
class="submission" class="submission"
@click.native.prevent="delSpecs(scope.$index)" @click.native.prevent="delSpecs(scope.$index)"
>删除</el-button> >删除</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -1090,7 +1091,8 @@
size="small" size="small"
class="mt20" class="mt20"
@click="addSpecs" @click="addSpecs"
>添加参数</el-button> >添加参数</el-button
>
<el-select <el-select
v-model="customSpecs" v-model="customSpecs"
multiple multiple
@ -1103,7 +1105,6 @@
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -1166,7 +1167,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-form-item style="margin-top:30px;"> <el-form-item style="margin-top: 30px">
<el-button <el-button
v-show="currentTab > 1" v-show="currentTab > 1"
type="primary" type="primary"
@ -1345,7 +1346,7 @@ export default {
taoBao, taoBao,
copyRecord copyRecord
}, },
data() { data () {
const url = const url =
SettingMer.https + '/upload/image/0/file?ueditor=1&token=' + getToken() SettingMer.https + '/upload/image/0/file?ueditor=1&token=' + getToken()
return { return {
@ -1553,11 +1554,11 @@ export default {
} }
}, },
computed: { computed: {
attrValue() { attrValue () {
const obj = Object.assign({}, this.attrVal) const obj = Object.assign({}, this.attrVal)
return obj return obj
}, },
oneFormBatch() { oneFormBatch () {
const obj = [Object.assign({}, defaultObj.attrValue[0])] const obj = [Object.assign({}, defaultObj.attrValue[0])]
if (this.OneattrValue[0] && this.OneattrValue[0]['image']) { obj[0]['image'] = this.OneattrValue[0]['image'] } if (this.OneattrValue[0] && this.OneattrValue[0]['image']) { obj[0]['image'] = this.OneattrValue[0]['image'] }
delete obj[0].bar_code delete obj[0].bar_code
@ -1566,28 +1567,28 @@ export default {
}, },
watch: { watch: {
'formValidate.attr': { 'formValidate.attr': {
handler: function(val) { handler: function (val) {
if (this.formValidate.spec_type === 1) this.watCh(val) if (this.formValidate.spec_type === 1) this.watCh(val)
}, },
immediate: false, immediate: false,
deep: true deep: true
}, },
currentTab(newVal) { currentTab (newVal) {
if (newVal == 5) { if (newVal == 5) {
this.$nextTick(e=>{ this.$nextTick(e => {
this.setSort() this.setSort()
}) })
} }
} }
}, },
created() { created () {
this.tempRoute = Object.assign({}, this.$route) this.tempRoute = Object.assign({}, this.$route)
if (this.$route.params.id && this.formValidate.spec_type === 1) { if (this.$route.params.id && this.formValidate.spec_type === 1) {
this.$watch('formValidate.attr', this.watCh) this.$watch('formValidate.attr', this.watCh)
} }
}, },
mounted() { mounted () {
this.formValidate.slider_image = [] this.formValidate.slider_image = []
if (this.$route.params.id) { if (this.$route.params.id) {
this.setTagsViewTitle() this.setTagsViewTitle()
@ -1615,18 +1616,18 @@ export default {
this.getLabelLst() this.getLabelLst()
this.$store.dispatch('settings/setEdit', true) this.$store.dispatch('settings/setEdit', true)
}, },
destroyed() { destroyed () {
window.removeEventListener('popstate', this.goBack, false) window.removeEventListener('popstate', this.goBack, false)
}, },
methods: { methods: {
setSort() { setSort () {
// reftableref // reftableref
const el = this.$refs.tableParameter.$el.querySelectorAll( const el = this.$refs.tableParameter.$el.querySelectorAll(
'.el-table__body-wrapper > table > tbody' '.el-table__body-wrapper > table > tbody'
)[0] )[0]
this.sortable = Sortable.create(el, { this.sortable = Sortable.create(el, {
ghostClass: 'sortable-ghost', ghostClass: 'sortable-ghost',
setData: function(dataTransfer) { setData: function (dataTransfer) {
dataTransfer.setData('Text', '') dataTransfer.setData('Text', '')
}, },
// //
@ -1635,17 +1636,17 @@ export default {
} }
}) })
}, },
elChangeExForArray(index1, index2, array) { elChangeExForArray (index1, index2, array) {
const temp = array[index1] const temp = array[index1]
array[index1] = array[index2] array[index1] = array[index2]
array[index2] = temp array[index2] = temp
return array return array
}, },
goBack() { goBack () {
sessionStorage.clear() sessionStorage.clear()
window.history.back() window.history.back()
}, },
handleCloseCoupon(tag) { handleCloseCoupon (tag) {
this.formValidate.couponData.splice( this.formValidate.couponData.splice(
this.formValidate.couponData.indexOf(tag), this.formValidate.couponData.indexOf(tag),
1 1
@ -1656,7 +1657,7 @@ export default {
}) })
}, },
// //
getSpecsLst(id) { getSpecsLst (id) {
let cate_id = id ? id : this.formValidate.cate_id let cate_id = id ? id : this.formValidate.cate_id
specsSelectedApi({ cate_id: cate_id }) specsSelectedApi({ cate_id: cate_id })
.then(res => { .then(res => {
@ -1667,7 +1668,7 @@ export default {
this.$message.error(res.message) this.$message.error(res.message)
}) })
}, },
productCon() { productCon () {
productConfigApi() productConfigApi()
.then(res => { .then(res => {
this.extensionStatus = res.data.extension_status this.extensionStatus = res.data.extension_status
@ -1696,7 +1697,7 @@ export default {
}) })
}, },
// //
getLabelLst() { getLabelLst () {
getProductLabelApi() getProductLabelApi()
.then(res => { .then(res => {
this.labelList = res.data this.labelList = res.data
@ -1705,14 +1706,14 @@ export default {
this.$message.error(res.message) this.$message.error(res.message)
}) })
}, },
addCoupon() { addCoupon () {
const _this = this const _this = this
this.$modalCoupon( this.$modalCoupon(
this.formValidate.couponData, this.formValidate.couponData,
'wu', 'wu',
_this.formValidate.give_coupon_ids, _this.formValidate.give_coupon_ids,
(this.keyNum += 1), (this.keyNum += 1),
function(row) { function (row) {
_this.formValidate.give_coupon_ids = [] _this.formValidate.give_coupon_ids = []
_this.formValidate.couponData = row _this.formValidate.couponData = row
row.map(item => { row.map(item => {
@ -1721,16 +1722,16 @@ export default {
} }
) )
}, },
delSpecs(index) { delSpecs (index) {
this.formValidate.params.splice(index, 1) this.formValidate.params.splice(index, 1)
}, },
addSpecs() { addSpecs () {
this.formValidate.params.push({ name: '', value: '', sort: 0 }) this.formValidate.params.push({ name: '', value: '', sort: 0 })
}, },
// //
getSpecsList() { getSpecsList () {
let merParams = [...this.customSpecs],sysParams = [...[this.formValidate.param_temp_id]] let merParams = [...this.customSpecs], sysParams = [...[this.formValidate.param_temp_id]]
let params = [...merParams,...sysParams] let params = [...merParams, ...sysParams]
console.log(params) console.log(params)
console.log(this.customSpecs) console.log(this.customSpecs)
if (params.length <= 0) { if (params.length <= 0) {
@ -1748,19 +1749,19 @@ export default {
}) })
} }
}, },
setTagsViewTitle() { setTagsViewTitle () {
const title = '编辑商品' const title = '编辑商品'
const route = Object.assign({}, this.tempRoute, { const route = Object.assign({}, this.tempRoute, {
title: `${title}-${this.$route.params.id}` title: `${title}-${this.$route.params.id}`
}) })
this.$store.dispatch('tagsView/updateVisitedView', route) this.$store.dispatch('tagsView/updateVisitedView', route)
}, },
onChangeGroup() { onChangeGroup () {
this.checkboxGroup.includes('is_good') this.checkboxGroup.includes('is_good')
? (this.formValidate.is_good = 1) ? (this.formValidate.is_good = 1)
: (this.formValidate.is_good = 0) : (this.formValidate.is_good = 0)
}, },
watCh(val) { watCh (val) {
const tmp = {} const tmp = {}
const tmpTab = {} const tmpTab = {}
this.formValidate.attr.forEach((o, i) => { this.formValidate.attr.forEach((o, i) => {
@ -1789,17 +1790,17 @@ export default {
this.manyTabDate = tmpTab this.manyTabDate = tmpTab
this.formThead = Object.assign({}, this.formThead, tmp) this.formThead = Object.assign({}, this.formThead, tmp)
}, },
attrFormat(arr) { attrFormat (arr) {
let data = [] let data = []
const res = [] const res = []
return format(arr) return format(arr)
function format(arr) { function format (arr) {
if (arr.length > 1) { if (arr.length > 1) {
arr.forEach((v, i) => { arr.forEach((v, i) => {
if (i === 0) data = arr[i]['detail'] if (i === 0) data = arr[i]['detail']
const tmp = [] const tmp = []
data.forEach(function(vv) { data.forEach(function (vv) {
arr[i + 1] && arr[i + 1] &&
arr[i + 1]['detail'] && arr[i + 1]['detail'] &&
arr[i + 1]['detail'].forEach(g => { arr[i + 1]['detail'].forEach(g => {
@ -1872,29 +1873,29 @@ export default {
} }
}, },
// //
addTem() { addTem () {
const _this = this const _this = this
this.$modalTemplates(0, function() { this.$modalTemplates(0, function () {
_this.getShippingList() _this.getShippingList()
}) })
}, },
// //
addServiceTem() { addServiceTem () {
this.$refs.serviceGuarantee.add() this.$refs.serviceGuarantee.add()
}, },
// //
delVideo() { delVideo () {
const that = this const that = this
that.$set(that.formValidate, 'video_link', '') that.$set(that.formValidate, 'video_link', '')
}, },
zh_uploadFile() { zh_uploadFile () {
if (this.videoLink) { if (this.videoLink) {
this.formValidate.video_link = this.videoLink this.formValidate.video_link = this.videoLink
} else { } else {
this.$refs.refid.click() this.$refs.refid.click()
} }
}, },
zh_uploadFile_change(evfile) { zh_uploadFile_change (evfile) {
const that = this const that = this
that.progress = 10 that.progress = 10
const suffix = evfile.target.files[0].name.substr( const suffix = evfile.target.files[0].name.substr(
@ -1909,7 +1910,7 @@ export default {
type: res.data.type, type: res.data.type,
evfile: evfile, evfile: evfile,
res: res, res: res,
uploading(status, progress) { uploading (status, progress) {
that.upload.videoIng = status that.upload.videoIng = status
} }
}) })
@ -1925,18 +1926,18 @@ export default {
}) })
}, },
// //
addRule() { addRule () {
const _this = this const _this = this
this.$modalAttr(this.formDynamics, function() { this.$modalAttr(this.formDynamics, function () {
_this.productGetRule() _this.productGetRule()
}) })
}, },
// //
onChangeSpec(num) { onChangeSpec (num) {
if (num === 1) this.productGetRule() if (num === 1) this.productGetRule()
}, },
// //
changeIntergral(e) { changeIntergral (e) {
if (e == -1) { if (e == -1) {
this.formValidate.integral_rate = -1 this.formValidate.integral_rate = -1
} else { } else {
@ -1944,7 +1945,7 @@ export default {
} }
}, },
// //
confirm() { confirm () {
if (!this.selectRule) { if (!this.selectRule) {
return this.$message.warning('请选择属性') return this.$message.warning('请选择属性')
} }
@ -1955,7 +1956,7 @@ export default {
}) })
}, },
// //
getCategorySelect() { getCategorySelect () {
categorySelectApi() categorySelectApi()
.then(res => { .then(res => {
this.merCateList = res.data this.merCateList = res.data
@ -1965,7 +1966,7 @@ export default {
}) })
}, },
// //
getCategoryList() { getCategoryList () {
categoryListApi() categoryListApi()
.then(res => { .then(res => {
this.categoryList = res.data this.categoryList = res.data
@ -1975,7 +1976,7 @@ export default {
}) })
}, },
// //
getBrandListApi() { getBrandListApi () {
categoryBrandListApi() categoryBrandListApi()
.then(res => { .then(res => {
this.BrandList = res.data this.BrandList = res.data
@ -1985,39 +1986,39 @@ export default {
}) })
}, },
// //
productGetRule() { productGetRule () {
templateLsitApi().then(res => { templateLsitApi().then(res => {
this.ruleList = res.data this.ruleList = res.data
}) })
}, },
// //
getShippingList() { getShippingList () {
shippingListApi().then(res => { shippingListApi().then(res => {
this.shippingList = res.data this.shippingList = res.data
}) })
}, },
// //
getGuaranteeList() { getGuaranteeList () {
guaranteeListApi().then(res => { guaranteeListApi().then(res => {
this.guaranteeList = res.data this.guaranteeList = res.data
}) })
}, },
showInput(item) { showInput (item) {
this.$set(item, 'inputVisible', true) this.$set(item, 'inputVisible', true)
}, },
virtualbtn(id, type) { virtualbtn (id, type) {
if (this.$route.params.id) { if (this.$route.params.id) {
return this.$message.warning('商品类型不能切换!') return this.$message.warning('商品类型不能切换!')
} }
this.formValidate.type = id this.formValidate.type = id
this.productCon() this.productCon()
}, },
customMessBtn(e) { customMessBtn (e) {
if (!e) { if (!e) {
this.formValidate.extend = [] this.formValidate.extend = []
} }
}, },
addcustom() { addcustom () {
if (this.formValidate.extend.length > 9) { if (this.formValidate.extend.length > 9) {
this.$message.warning('最多添加10条') this.$message.warning('最多添加10条')
} else { } else {
@ -2029,10 +2030,10 @@ export default {
}) })
} }
}, },
delcustom(index) { delcustom (index) {
this.formValidate.extend.splice(index, 1) this.formValidate.extend.splice(index, 1)
}, },
onChangetype(item) { onChangetype (item) {
if (item === 1) { if (item === 1) {
this.OneattrValue.map(item => { this.OneattrValue.map(item => {
this.$set(item, 'extension_one', null) this.$set(item, 'extension_one', null)
@ -2055,7 +2056,7 @@ export default {
}) })
} }
}, },
onChangeSpecs(item) { onChangeSpecs (item) {
if (item == 1 || item == 2) { if (item == 1 || item == 2) {
this.attrVal = { this.attrVal = {
price: null, price: null,
@ -2087,72 +2088,72 @@ export default {
} }
} }
}, },
memberPrice(formHead, row) { memberPrice (formHead, row) {
if (formHead.title == '售价') { if (formHead.title == '售价') {
row.svip_price = this.accMul(row.price, this.svip_rate) row.svip_price = this.accMul(row.price, this.svip_rate)
} }
}, },
// //
accMul(arg1, arg2) { accMul (arg1, arg2) {
var max = 0 var max = 0
var s1 = arg1.toString() var s1 = arg1.toString()
var s2 = arg2.toString() var s2 = arg2.toString()
try { try {
max += s1.split('.')[1].length max += s1.split('.')[1].length
} catch (e) {} } catch (e) { }
try { try {
max += s2.split('.')[1].length max += s2.split('.')[1].length
} catch (e) {} } catch (e) { }
return ( return (
(Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) / (Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) /
Math.pow(10, max) Math.pow(10, max)
) )
}, },
// //
delAttrTable(index) { delAttrTable (index) {
this.ManyAttrValue.splice(index, 1) this.ManyAttrValue.splice(index, 1)
}, },
// //
batchAdd() { batchAdd () {
for (const val of this.ManyAttrValue) { for (const val of this.ManyAttrValue) {
console.log(this.oneFormBatch[0]) console.log(this.oneFormBatch[0])
if(this.oneFormBatch[0].image!= '')this.$set(val, 'image', this.oneFormBatch[0].image) if (this.oneFormBatch[0].image != '') this.$set(val, 'image', this.oneFormBatch[0].image)
if(this.oneFormBatch[0].price!= null)this.$set(val, 'price', this.oneFormBatch[0].price) if (this.oneFormBatch[0].price != null) this.$set(val, 'price', this.oneFormBatch[0].price)
if(this.oneFormBatch[0].cost!= null)this.$set(val, 'cost', this.oneFormBatch[0].cost) if (this.oneFormBatch[0].cost != null) this.$set(val, 'cost', this.oneFormBatch[0].cost)
if(this.oneFormBatch[0].ot_price!= null)this.$set(val, 'ot_price', this.oneFormBatch[0].ot_price) if (this.oneFormBatch[0].ot_price != null) this.$set(val, 'ot_price', this.oneFormBatch[0].ot_price)
if(this.oneFormBatch[0].svip_price!= null)this.$set(val, 'svip_price', this.oneFormBatch[0].svip_price) if (this.oneFormBatch[0].svip_price != null) this.$set(val, 'svip_price', this.oneFormBatch[0].svip_price)
if(this.oneFormBatch[0].stock!= null)this.$set(val, 'stock', this.oneFormBatch[0].stock) if (this.oneFormBatch[0].stock != null) this.$set(val, 'stock', this.oneFormBatch[0].stock)
if(this.oneFormBatch[0].bar_code!= null)this.$set(val, 'bar_code', this.oneFormBatch[0].bar_code) if (this.oneFormBatch[0].bar_code != null) this.$set(val, 'bar_code', this.oneFormBatch[0].bar_code)
if(this.oneFormBatch[0].weight!= null)this.$set(val, 'weight', this.oneFormBatch[0].weight) if (this.oneFormBatch[0].weight != null) this.$set(val, 'weight', this.oneFormBatch[0].weight)
if(this.oneFormBatch[0].volume!= null)this.$set(val, 'volume', this.oneFormBatch[0].volume) if (this.oneFormBatch[0].volume != null) this.$set(val, 'volume', this.oneFormBatch[0].volume)
if(this.oneFormBatch[0].extension_one!= null)this.$set(val, 'extension_one', this.oneFormBatch[0].extension_one) if (this.oneFormBatch[0].extension_one != null) this.$set(val, 'extension_one', this.oneFormBatch[0].extension_one)
if(this.oneFormBatch[0].extension_two!= null)this.$set(val, 'extension_two', this.oneFormBatch[0].extension_two) if (this.oneFormBatch[0].extension_two != null) this.$set(val, 'extension_two', this.oneFormBatch[0].extension_two)
} }
}, },
// //
addBtn() { addBtn () {
this.clearAttr() this.clearAttr()
this.isBtn = true this.isBtn = true
}, },
// //
offAttrName() { offAttrName () {
this.isBtn = false this.isBtn = false
}, },
clearAttr() { clearAttr () {
this.formDynamic.attrsName = '' this.formDynamic.attrsName = ''
this.formDynamic.attrsVal = '' this.formDynamic.attrsVal = ''
}, },
// //
handleRemoveAttr(index) { handleRemoveAttr (index) {
this.formValidate.attr.splice(index, 1) this.formValidate.attr.splice(index, 1)
this.manyFormValidate.splice(index, 1) this.manyFormValidate.splice(index, 1)
}, },
// //
handleClose(item, index) { handleClose (item, index) {
item.splice(index, 1) item.splice(index, 1)
}, },
// //
createAttrName() { createAttrName () {
if (this.formDynamic.attrsName && this.formDynamic.attrsVal) { if (this.formDynamic.attrsName && this.formDynamic.attrsVal) {
const data = { const data = {
value: this.formDynamic.attrsName, value: this.formDynamic.attrsName,
@ -2160,7 +2161,7 @@ export default {
} }
this.formValidate.attr.push(data) this.formValidate.attr.push(data)
var hash = {} var hash = {}
this.formValidate.attr = this.formValidate.attr.reduce(function( this.formValidate.attr = this.formValidate.attr.reduce(function (
item, item,
next next
) { ) {
@ -2176,13 +2177,13 @@ export default {
} }
}, },
// //
createAttr(num, idx) { createAttr (num, idx) {
if (num) { if (num) {
this.formValidate.attr[idx].detail.push(num); this.formValidate.attr[idx].detail.push(num);
var hash = {}; var hash = {};
this.formValidate.attr[idx].detail = this.formValidate.attr[ this.formValidate.attr[idx].detail = this.formValidate.attr[
idx idx
].detail.reduce(function(item, next) { ].detail.reduce(function (item, next) {
/* eslint-disable */ /* eslint-disable */
hash[next] ? "" : (hash[next] = true && item.push(next)); hash[next] ? "" : (hash[next] = true && item.push(next));
return item; return item;
@ -2193,11 +2194,11 @@ export default {
} }
}, },
// //
getInfo() { getInfo () {
this.fullscreenLoading = true; this.fullscreenLoading = true;
productDetailApi(this.$route.params.id) productDetailApi(this.$route.params.id)
.then(async res => { .then(async res => {
if(res.data.content_arr)res.data.content = res.data.content_arr; if (res.data.content_arr && res.data.content_arr.length > 0) res.data.content = res.data.content_arr;
let info = res.data; let info = res.data;
this.infoData(info); this.infoData(info);
this.getSpecsLst(info.cate_id); this.getSpecsLst(info.cate_id);
@ -2207,7 +2208,7 @@ export default {
this.$message.error(res.message); this.$message.error(res.message);
}); });
}, },
infoData(info) { infoData (info) {
this.deduction_set = info.integral_rate == -1 ? -1 : 1; this.deduction_set = info.integral_rate == -1 ? -1 : 1;
this.formValidate = { this.formValidate = {
image: info.image, image: info.image,
@ -2287,18 +2288,18 @@ export default {
this.fullscreenLoading = false; this.fullscreenLoading = false;
}, },
// //
onClose(data) { onClose (data) {
this.modals = false; this.modals = false;
this.infoData(data); this.infoData(data);
}, },
handleRemove(i) { handleRemove (i) {
this.formValidate.slider_image.splice(i, 1); this.formValidate.slider_image.splice(i, 1);
}, },
// //
modalPicTap(tit, num, i) { modalPicTap (tit, num, i) {
const _this = this; const _this = this;
const attr = []; const attr = [];
this.$modalUpload(function(img) { this.$modalUpload(function (img) {
if (tit === "1" && !num) { if (tit === "1" && !num) {
_this.formValidate.image = img[0]; _this.formValidate.image = img[0];
_this.OneattrValue[0].image = img[0]; _this.OneattrValue[0].image = img[0];
@ -2321,15 +2322,25 @@ export default {
if (tit === "1" && num === "pi") { if (tit === "1" && num === "pi") {
_this.oneFormBatch[0].image = img[0]; _this.oneFormBatch[0].image = img[0];
} }
if (tit === "3"){ if (tit === "3") {
_this.formValidate.content.image = img; // console.log('', _this.formValidate?.content, img)
let image = _this.formValidate.content.image ? _this.formValidate.content.image : [];
_this.formValidate.content = {
image: [...image, ...img],
title: _this.formValidate.content.title
}
console.log('选择好的', _this.formValidate.content)
} }
}, tit); }, tit);
}, },
handleSubmitUp() { //
deleteContentImg (index) {
this.formValidate.content.image.splice(index, 1)
},
handleSubmitUp () {
this.currentTab = (Number(this.currentTab) - 1).toString(); this.currentTab = (Number(this.currentTab) - 1).toString();
}, },
handleSubmitNest(name) { handleSubmitNest (name) {
this.$refs[name].validate(valid => { this.$refs[name].validate(valid => {
if (valid) { if (valid) {
this.currentTab = (Number(this.currentTab) + 1).toString(); this.currentTab = (Number(this.currentTab) + 1).toString();
@ -2337,7 +2348,7 @@ export default {
}); });
}, },
// //
handleSubmit(name) { handleSubmit (name) {
this.$store.dispatch("settings/setEdit", false); this.$store.dispatch("settings/setEdit", false);
this.onChangeGroup(); this.onChangeGroup();
if (this.formValidate.spec_type === 1) { if (this.formValidate.spec_type === 1) {
@ -2401,7 +2412,7 @@ export default {
}); });
}, },
// //
handlePreview(name) { handlePreview (name) {
this.onChangeGroup(); this.onChangeGroup();
if (this.formValidate.spec_type === 1) { if (this.formValidate.spec_type === 1) {
this.formValidate.attrValue = this.ManyAttrValue; this.formValidate.attrValue = this.ManyAttrValue;
@ -2419,13 +2430,13 @@ export default {
}); });
}, },
// //
validate(prop, status, error) { validate (prop, status, error) {
if (status === false) { if (status === false) {
this.$message.warning(error); this.$message.warning(error);
} }
}, },
// //
specPicValidate(ManyAttrValue) { specPicValidate (ManyAttrValue) {
for (let i = 0; i < ManyAttrValue.length; i++) { for (let i = 0; i < ManyAttrValue.length; i++) {
if (ManyAttrValue[i].image === "" || !ManyAttrValue[i].image) { if (ManyAttrValue[i].image === "" || !ManyAttrValue[i].image) {
this.$message.warning("请上传商品规格图!"); this.$message.warning("请上传商品规格图!");
@ -2435,16 +2446,16 @@ export default {
} }
}, },
// //
handleDragStart(e, item) { handleDragStart (e, item) {
this.dragging = item; this.dragging = item;
}, },
handleDragEnd(e, item) { handleDragEnd (e, item) {
this.dragging = null; this.dragging = null;
}, },
handleDragOver(e) { handleDragOver (e) {
e.dataTransfer.dropEffect = "move"; e.dataTransfer.dropEffect = "move";
}, },
handleDragEnter(e, item) { handleDragEnter (e, item) {
e.dataTransfer.effectAllowed = "move"; e.dataTransfer.effectAllowed = "move";
if (item === this.dragging) { if (item === this.dragging) {
return; return;
@ -2456,10 +2467,10 @@ export default {
this.formValidate.slider_image = newItems; this.formValidate.slider_image = newItems;
}, },
// //
addCustomDialog(editorId) { addCustomDialog (editorId) {
window.UE.registerUI( window.UE.registerUI(
"test-dialog", "test-dialog",
function(editor, uiName) { function (editor, uiName) {
// dialog // dialog
let dialog = new window.UE.ui.Dialog({ let dialog = new window.UE.ui.Dialog({
iframeUrl: roterPre + "/admin/widget/image?field=dialog", iframeUrl: roterPre + "/admin/widget/image?field=dialog",
@ -2473,7 +2484,7 @@ export default {
name: "dialog-button", name: "dialog-button",
title: "上传图片", title: "上传图片",
cssRules: `background-image: url(../../../assets/images/icons.png);background-position: -726px -77px;`, cssRules: `background-image: url(../../../assets/images/icons.png);background-position: -726px -77px;`,
onclick: function() { onclick: function () {
// dialog // dialog
dialog.render(); dialog.render();
dialog.open(); dialog.open();
@ -2485,7 +2496,7 @@ export default {
); );
window.UE.registerUI( window.UE.registerUI(
"video-dialog", "video-dialog",
function(editor, uiName) { function (editor, uiName) {
let dialog = new window.UE.ui.Dialog({ let dialog = new window.UE.ui.Dialog({
iframeUrl: roterPre + "/admin/widget/video?fodder=video", iframeUrl: roterPre + "/admin/widget/video?fodder=video",
editor: editor, editor: editor,
@ -2498,7 +2509,7 @@ export default {
name: "video-button", name: "video-button",
title: "上传视频", title: "上传视频",
cssRules: `background-image: url(../../../assets/images/icons.png);background-position: -320px -20px;`, cssRules: `background-image: url(../../../assets/images/icons.png);background-position: -320px -20px;`,
onclick: function() { onclick: function () {
// dialog // dialog
dialog.render(); dialog.render();
dialog.open(); dialog.open();
@ -2698,7 +2709,7 @@ export default {
height: 100%; height: 100%;
} }
} }
.details_pictrue{ .details_pictrue {
width: 120px; width: 120px;
height: 120px; height: 120px;
} }