|
|
|
|
@@ -21,7 +21,7 @@
|
|
|
|
|
<el-row v-show="currentTab === 0" :gutter="24">
|
|
|
|
|
<!-- 商品信息-->
|
|
|
|
|
<el-col v-bind="grid2">
|
|
|
|
|
<el-form-item label="商品分类:" prop="categorys" :rules="[{ required: true, message: '请选择商品分类', trigger: ['blur', 'change'] }]">
|
|
|
|
|
<el-form-item label="商品分类:" prop="categorys" :rules="[{ required: true, message: '请选择商品分类', trigger: ['blur'] }]">
|
|
|
|
|
<el-cascader
|
|
|
|
|
@change="cascaderChange"
|
|
|
|
|
v-model="formValidate.categorys"
|
|
|
|
|
@@ -35,7 +35,7 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-bind="grid2">
|
|
|
|
|
<el-form-item label="商品名称:" prop="productName" :rules="[{ required: true, message: '请输入商品名称', trigger: ['blur', 'change'] }]">
|
|
|
|
|
<el-form-item label="商品名称:" prop="productName" :rules="[{ required: true, message: '请输入商品名称', trigger: ['blur'] }]">
|
|
|
|
|
<el-input v-model="formValidate.productName" maxlength="249" placeholder="请输入商品名称" :disabled="isDisabled" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
@@ -45,7 +45,7 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-bind="grid2">
|
|
|
|
|
<el-form-item label="商品品牌:" prop="brandId" :rules="[{ required: true, message: '请选择商品品牌', trigger: ['blur', 'change'] }]">
|
|
|
|
|
<el-form-item label="商品品牌:" prop="brandId" :rules="[{ required: true, message: '请选择商品品牌', trigger: ['blur'] }]">
|
|
|
|
|
<el-select style="width: 100%;" v-model="formValidate.brandId" placeholder="请选择">
|
|
|
|
|
<el-option v-for="item in brandOptions" :key="item.id" :label="item.brandName" :value="item.id"> </el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
@@ -57,12 +57,12 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-bind="grid2">
|
|
|
|
|
<el-form-item label="商品售价" prop="price" :rules="[{ required: true, message: '请输入商品售价', trigger: ['blur', 'change'] }]">
|
|
|
|
|
<el-form-item label="商品售价" prop="price" :rules="[{ required: true, message: '请输入商品售价', trigger: ['blur'] }]">
|
|
|
|
|
<el-input v-model="formValidate.price" maxlength="249" type="number" placeholder="请输入商品售价" :disabled="isDisabled" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-bind="grid2">
|
|
|
|
|
<el-form-item label="商品类型:" prop="productType" :rules="[{ required: true, message: '请选择商品类型', trigger: ['blur', 'change'] }]">
|
|
|
|
|
<el-form-item label="商品类型:" prop="productType" :rules="[{ required: true, message: '请选择商品类型', trigger: ['blur'] }]">
|
|
|
|
|
<el-select style="width: 100%;" v-model="formValidate.productType" placeholder="请选择商品类型">
|
|
|
|
|
<el-option label="店铺商品" value="2"> </el-option>
|
|
|
|
|
<el-option label="平台商品" value="1"> </el-option>
|
|
|
|
|
@@ -76,9 +76,8 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col> -->
|
|
|
|
|
<el-col v-bind="grid2">
|
|
|
|
|
<el-form-item label="自提油站" prop="siteIds" :rules="[{ required: true, message: '请选择自提油站', trigger: ['blur', 'change'] }]">
|
|
|
|
|
<el-form-item label="自提油站" prop="siteIds">
|
|
|
|
|
<el-tag
|
|
|
|
|
v-model="formValidate.siteIds"
|
|
|
|
|
style="margin-left: 10px;"
|
|
|
|
|
:key="tagIndex"
|
|
|
|
|
v-for="(tag, tagIndex) in OilStationSelectionList"
|
|
|
|
|
@@ -129,7 +128,7 @@
|
|
|
|
|
<el-form-item
|
|
|
|
|
label="选择规格:"
|
|
|
|
|
prop="attributesTypeId"
|
|
|
|
|
:rules="[{ required: true, message: '请选择规格', trigger: ['blur', 'change'] }]"
|
|
|
|
|
:rules="[{ required: true, message: '请选择规格', trigger: ['blur'] }]"
|
|
|
|
|
>
|
|
|
|
|
<div class="acea-row">
|
|
|
|
|
<el-select v-model="formValidate.attributesTypeId">
|
|
|
|
|
@@ -555,29 +554,30 @@ export default {
|
|
|
|
|
console.log(from.path) //从哪来
|
|
|
|
|
console.log(to.path, to.params) //到哪去
|
|
|
|
|
},
|
|
|
|
|
'formValidate.content': function(n) {
|
|
|
|
|
console.log(n, '++++++++++++++++++++++')
|
|
|
|
|
},
|
|
|
|
|
'formValidate.content': function(n) { },
|
|
|
|
|
ManyAttrValue(n) {},
|
|
|
|
|
'formValidate.attr': {
|
|
|
|
|
handler: function(val) {
|
|
|
|
|
if (this.isAttr) this.watCh(val) //重要!!!
|
|
|
|
|
handler: function(val,o) {
|
|
|
|
|
if (this.isAttr) this.watCh(val,o) //重要!!!
|
|
|
|
|
},
|
|
|
|
|
immediate: false,
|
|
|
|
|
deep: true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.chenkId()
|
|
|
|
|
this.getCategorySelect()
|
|
|
|
|
this.productGetRule()
|
|
|
|
|
this.brandGetAll()
|
|
|
|
|
async created() {
|
|
|
|
|
await this.chenkId()
|
|
|
|
|
await this.getCategorySelect()
|
|
|
|
|
await this.productGetRule()
|
|
|
|
|
await this.brandGetAll()
|
|
|
|
|
},
|
|
|
|
|
mounted() {},
|
|
|
|
|
deactivated() {
|
|
|
|
|
this.$destroy();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
chenkId() {
|
|
|
|
|
if (this.$route.params && this.$route.params.id) {
|
|
|
|
|
this.getproductInfo(this.$route.params.id)
|
|
|
|
|
async chenkId() {
|
|
|
|
|
if (this.$route.query && this.$route.query.id) {
|
|
|
|
|
await this.getproductInfo(this.$route.query.id)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
productAddGetSites(ids) {
|
|
|
|
|
@@ -590,19 +590,23 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
async inverseAnalysis(data) {
|
|
|
|
|
let { categoryOneId, categoryTwoId } = data
|
|
|
|
|
let categorys = [categoryOneId, categoryTwoId]
|
|
|
|
|
this.OilStationSelectionList = data.siteInfos
|
|
|
|
|
Object.assign(this.formValidate, {
|
|
|
|
|
let { categoryOneId, categoryTwoId } = data;
|
|
|
|
|
let categorys = [categoryOneId, categoryTwoId];
|
|
|
|
|
this.OilStationSelectionList = data.siteInfos;
|
|
|
|
|
this.formValidate = {
|
|
|
|
|
...this.formValidate,
|
|
|
|
|
categorys,
|
|
|
|
|
...data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// Object.assign(this.formValidate, {
|
|
|
|
|
// categorys,
|
|
|
|
|
// ...data
|
|
|
|
|
// })
|
|
|
|
|
this.$refs.CustomUpload.fileList = [...this.formValidate.images.filter(item => item.mainMark == '1')]
|
|
|
|
|
this.$refs.CustomLBUpload.fileList = [...this.formValidate.images.filter(item => item.mainMark != '1')]
|
|
|
|
|
await this.confirm()
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.formValidate.attr = this.formValidate.attr
|
|
|
|
|
.map(item => {
|
|
|
|
|
this.formValidate.attr = this.formValidate.attr.map(item => {
|
|
|
|
|
let align = this.formValidate.checkedList.find(i => item.id == i.attributeId)
|
|
|
|
|
if (align) {
|
|
|
|
|
return {
|
|
|
|
|
@@ -615,22 +619,24 @@ export default {
|
|
|
|
|
} else {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.filter(item => item)
|
|
|
|
|
}).filter(item => item);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.ManyAttrValue.forEach((item, index) => {
|
|
|
|
|
let data = this.formValidate.stockList.find(i => i.attributeJson == JSON.stringify(item.data))
|
|
|
|
|
let data = this.formValidate.stockList.find(i => i.attributeJson == JSON.stringify(item.data));
|
|
|
|
|
if (data) {
|
|
|
|
|
Object.assign(item, data)
|
|
|
|
|
Object.assign(item, data,{delect:false})
|
|
|
|
|
}else{
|
|
|
|
|
Object.assign(item, data,{delect:true})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.ManyAttrValue = this.ManyAttrValue.filter(item=>!item.delect)
|
|
|
|
|
}, 1000)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getproductInfo(id) {
|
|
|
|
|
productApi.productAddGetEdit(id).then(res => {
|
|
|
|
|
async getproductInfo(id) {
|
|
|
|
|
await productApi.productAddGetEdit(id).then( async res => {
|
|
|
|
|
if (res.code == 20000) {
|
|
|
|
|
this.inverseAnalysis(res.data)
|
|
|
|
|
await this.inverseAnalysis(res.data)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
@@ -645,8 +651,8 @@ export default {
|
|
|
|
|
this.isOilStationSelection = false
|
|
|
|
|
this.formValidate.siteIds = e.map(item => item.siteId)
|
|
|
|
|
},
|
|
|
|
|
brandGetAll() {
|
|
|
|
|
productApi.brandGetAll().then(res => {
|
|
|
|
|
async brandGetAll() {
|
|
|
|
|
await productApi.brandGetAll().then(res => {
|
|
|
|
|
if (res.code == 20000) {
|
|
|
|
|
this.brandOptions = res.data
|
|
|
|
|
}
|
|
|
|
|
@@ -709,7 +715,7 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
setTagsViewTitle() {
|
|
|
|
|
const title = this.isDisabled ? '商品详情' : '编辑商品'
|
|
|
|
|
const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.$route.params.id}` })
|
|
|
|
|
const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.$route.query.id}` })
|
|
|
|
|
this.$store.dispatch('tagsView/updateVisitedView', route)
|
|
|
|
|
},
|
|
|
|
|
onChangeGroup() {
|
|
|
|
|
@@ -720,7 +726,7 @@ export default {
|
|
|
|
|
this.checkboxGroup.includes('isHot') ? (this.formValidate.isHot = true) : (this.formValidate.isHot = false)
|
|
|
|
|
},
|
|
|
|
|
// sku算法
|
|
|
|
|
watCh(val) {
|
|
|
|
|
watCh(val,o) {
|
|
|
|
|
let arr = []
|
|
|
|
|
this.manyTabDate = []
|
|
|
|
|
for (let i = 0; i < val.length; i++) {
|
|
|
|
|
@@ -747,7 +753,8 @@ export default {
|
|
|
|
|
return res
|
|
|
|
|
},
|
|
|
|
|
[{}]
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
console.log(this.ManyAttrValue ,"this.ManyAttrValue ")
|
|
|
|
|
},
|
|
|
|
|
attrFormat(arr) {
|
|
|
|
|
let data = []
|
|
|
|
|
@@ -852,8 +859,8 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 商品分类;
|
|
|
|
|
getCategorySelect() {
|
|
|
|
|
productApi.getClassificationTree().then(res => {
|
|
|
|
|
async getCategorySelect() {
|
|
|
|
|
await productApi.getClassificationTree().then(res => {
|
|
|
|
|
if (res.code == 20000) {
|
|
|
|
|
this.merCateList = res.data
|
|
|
|
|
}
|
|
|
|
|
@@ -961,6 +968,7 @@ export default {
|
|
|
|
|
} else {
|
|
|
|
|
item.splice(index, 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
// 添加规则名称
|
|
|
|
|
createAttrName() {
|
|
|
|
|
@@ -1012,7 +1020,7 @@ export default {
|
|
|
|
|
// 详情
|
|
|
|
|
getInfo() {
|
|
|
|
|
this.fullscreenLoading = true
|
|
|
|
|
productDetailApi(this.$route.params.id)
|
|
|
|
|
productDetailApi(this.$route.query.id)
|
|
|
|
|
.then(async res => {
|
|
|
|
|
// this.isAttr = true;
|
|
|
|
|
let info = res
|
|
|
|
|
@@ -1172,6 +1180,7 @@ export default {
|
|
|
|
|
if (this.currentTab-- < 0) this.currentTab = 0
|
|
|
|
|
},
|
|
|
|
|
handleSubmitNest(name) {
|
|
|
|
|
console.log(this.formValidate,"handleSubmitNest")
|
|
|
|
|
this.$refs[name].validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
if (this.currentTab++ > 2) this.currentTab = 0
|
|
|
|
|
@@ -1198,7 +1207,10 @@ export default {
|
|
|
|
|
let [categoryOneId, categoryTwoId] = this.formValidate.categorys
|
|
|
|
|
let isRecommendOrNewMark = this.formValidate.recommendOrNewMark == '1' ? 'newMark' : 'recommend'
|
|
|
|
|
let siteIds = this.OilStationSelectionList.map(item => item.siteId)
|
|
|
|
|
|
|
|
|
|
if(siteIds.length==0){
|
|
|
|
|
this.$message.error('请选择油站')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
let checkedList = this.formValidate.attr.map(item => {
|
|
|
|
|
let attributeId = item.id
|
|
|
|
|
let checked = item.sku.value.join(',')
|
|
|
|
|
@@ -1224,18 +1236,11 @@ export default {
|
|
|
|
|
id
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
console.log(this.formValidate, 'formValidate')
|
|
|
|
|
console.log(categoryOneId, categoryTwoId, 'categoryOneId categoryTwoId')
|
|
|
|
|
console.log(isRecommendOrNewMark, 'isRecommendOrNewMark')
|
|
|
|
|
console.log(siteIds, 'siteIds')
|
|
|
|
|
console.log(checkedList, 'checkedList')
|
|
|
|
|
console.log(images, 'images')
|
|
|
|
|
console.log(stockList, 'stockList')
|
|
|
|
|
this.formValidate[isRecommendOrNewMark] = '1'
|
|
|
|
|
loadingFn.call(
|
|
|
|
|
this,
|
|
|
|
|
'loading',
|
|
|
|
|
productApi[this.$route.params.id ? 'addUpdate' : 'addSave'](
|
|
|
|
|
productApi[this.$route.query.id ? 'addUpdate' : 'addSave'](
|
|
|
|
|
Object.assign(this.formValidate, {
|
|
|
|
|
categoryOneId,
|
|
|
|
|
categoryTwoId,
|
|
|
|
|
@@ -1249,7 +1254,7 @@ export default {
|
|
|
|
|
this.$message.success('操作成功')
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.$router.push({ path: 'productList' })
|
|
|
|
|
this.$destroy()
|
|
|
|
|
// this.$destroy()
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|