Commit 09c7e5c9 by zhangxw

新增商品选择素材方式修改

1 parent c148e877
......@@ -65,3 +65,9 @@ export function editBrandSupplyMerchant(data) {
data.method = `${path}goods.type.editGoodsRelatedParty`
return request(data, 'post')
}
// 获取素材详情
export function getProductInfo(data) {
data.method = `${path}goodsinfo.get.byId`
return request(data, 'post')
}
......@@ -91,6 +91,8 @@
:placeholder="'请选择' + item.label"
:style="{'width': item.width || formItemWidth}"
@change="selectAddAttr($event, item)"
@blur="selectBlur"
@focus="selectFocus"
filterable
:disabled="item.isDisabled">
<el-option
......@@ -99,19 +101,30 @@
:label="subItem[item.optionLabel]"
:value="subItem[item.optionId]"
>
<div class="flex-option">
<el-input v-show="editOptionIndex == subIndex" class="add-option-input" :autofocus="true" @click.stop.native="editOptionFocus" v-model="editOptionValue" size="small" placeholder="请输入"></el-input>
<span v-show="!editOptionIndex || editOptionIndex != subIndex" class="add-option-input">{{ subItem[item.optionLabel] }}</span>
<!-- 供应方 -->
<div class="flex-option" v-if="item.partitionFlag == 1">
<el-input v-show="editOptionIndex == subIndex" :maxlength="10" class="add-option-input" :autofocus="true" @click.stop.native="editOptionFocus" v-model.trim="editOptionValue" size="small" placeholder="请输入"></el-input>
<span v-show="editOptionIndex == -1 || editOptionIndex != subIndex" class="add-option-input">{{ subItem[item.optionLabel] }}</span>
<div>
<i v-show="subIndex > (item.partitionFlag == 2 ? 1 : -1) && !editOptionIndex" class="el-icon-edit edit_icon" @click.stop="editOption(subIndex, subItem[item.optionLabel], item.partitionFlag)"></i>
<i v-show="subIndex > (item.partitionFlag == 2 ? 1 : -1) && editOptionIndex == subIndex" class="el-icon-check option_icon add_icon" @click.stop="editOptionConfirm(subItem[item.optionId], index, item.partitionFlag)"></i>
<i v-if="subIndex > (item.partitionFlag == 2 ? 1 : -1)" class="el-icon-close del_icon" @click.stop="delOption(subItem[item.optionId], index, item.partitionFlag, item)"></i>
<i v-show="item.optionList.length > 1 && (editOptionIndex != subIndex)" class="el-icon-edit edit_icon" @click.stop="editOption(subIndex, subItem[item.optionLabel], item.partitionFlag)"></i>
<i v-show="item.optionList.length > 1 && editOptionIndex == subIndex" class="el-icon-check option_icon add_icon" @click.stop="editOptionConfirm(subItem[item.optionId], index, item.partitionFlag)"></i>
<i v-if="item.optionList.length > 1" class="el-icon-close del_icon" @click.stop="delOption(subItem[item.optionId], index, item.partitionFlag, item)"></i>
</div>
</div>
<!-- 服务方 -->
<div class="flex-option" v-else>
<el-input v-show="editOptionIndex == subIndex" :maxlength="10" class="add-option-input" :autofocus="true" @click.stop.native="editOptionFocus" v-model.trim="editOptionValue" size="small" placeholder="请输入"></el-input>
<span v-show="editOptionIndex == -1 || editOptionIndex != subIndex" class="add-option-input">{{ subItem[item.optionLabel] }}</span>
<div>
<i v-show="subItem[item.optionId] !== 12 && subItem[item.optionId] !== 13 && (editOptionIndex != subIndex)" class="el-icon-edit edit_icon" @click.stop="editOption(subIndex, subItem[item.optionLabel], item.partitionFlag)"></i>
<i v-show="subItem[item.optionId] !== 12 && subItem[item.optionId] !== 13 && editOptionIndex == subIndex" class="el-icon-check option_icon add_icon" @click.stop="editOptionConfirm(subItem[item.optionId], index, item.partitionFlag)"></i>
<i v-if="subItem[item.optionId] !== 12 && subItem[item.optionId] !== 13" class="el-icon-close del_icon" @click.stop="delOption(subItem[item.optionId], index, item.partitionFlag, item)"></i>
</div>
</div>
</el-option>
<div class="add-option">
<div v-if="showOptionInput" class="flex-option">
<el-input class="add-option-input" v-model="addOptionValue" size="small" placeholder="请输入"></el-input>
<el-input class="add-option-input" :maxlength="10" v-model.trim="addOptionValue" size="small" placeholder="请输入"></el-input>
<div>
<i v-if="addOptionValue" class="el-icon-check option_icon add_icon" @click.stop="addOptionConfirm(item.partitionFlag)"></i>
<i class="el-icon-close option_icon del_icon" @click.stop="delOption(undefined)"></i>
......@@ -568,7 +581,7 @@ export default {
showOptionInput: false,
addOptionValue: '',
editOptionValue: '',
editOptionIndex: undefined,
editOptionIndex: -1,
selectedValue: '',
dialogObj: {
url: '',
......@@ -660,8 +673,17 @@ export default {
},
methods: {
selectBlur() {
this.editOptionIndex = -1
this.showOptionInput = false
},
selectFocus() {
this.editOptionIndex = -1
this.showOptionInput = false
},
addOption() {
this.showOptionInput = true
this.addOptionValue = ''
},
addOptionConfirm(partitionFlag) {
let data = {
......@@ -688,7 +710,7 @@ export default {
partitionFlag: partitionFlag
}
this.$emit('handleEditBrandSupplyConfirm', data)
this.editOptionIndex = undefined
this.editOptionIndex = -1
this.editOptionValue = ''
},
delOption(e, index, partitionFlag, item) {
......@@ -733,7 +755,7 @@ export default {
this.formData.sapCode = tempVal.sapCode
}
this.selectedValue = value
this.editOptionIndex = undefined
this.editOptionIndex = -1
if (targetItem.name == 'sceneType') {
this.$emit('handleChangeSelect', value)
}
......
......@@ -270,7 +270,7 @@ export default {
}, {
label: '所属场景',
parentProp: 'goodsInfo',
prop: 'goodsTypeName',
prop: 'sceneName',
width: '100'
}, {
label: '类目',
......
......@@ -200,7 +200,7 @@ export default {
})
arr.push({
id: val.id,
specificationData: val.specificationData,
// specificationData: val.specificationData,
merchantList: merchantList
})
})
......
......@@ -413,7 +413,7 @@
</td>
<td :style="{ width: specsWidth }">
<span v-if="!showBatchInput">质保</span>
<el-input style="width: 80px;" v-else size="small" placeholder="质保" v-model="batchObj.warrantyTime" :class="{ 'w-100-per': true }" @input="handleBatchWarrantyTimeInput" @blur="handleBatchWarrantyTimeInputBlur"></el-input>
<el-input style="width: 80px;" v-else size="small" placeholder="质保" v-model="batchObj.warrantyPeriod" :class="{ 'w-100-per': true }" @input="handleBatchwarrantyPeriodInput" @blur="handleBatchwarrantyPeriodInputBlur"></el-input>
</td>
<td style="width: 100px;display: inline-block;line-height: 60px;"><el-button type="text" @click="batchFilling">{{ !showBatchInput ? '批量填充' : '取消'}}</el-button></td>
</tr>
......@@ -456,7 +456,7 @@
</td>
<td :style="{ width: specsWidth }">
<div style="transform: translateX(10px);">
<el-input style="width: 80px;" placeholder="质保" size="small" v-model="subItem.warrantyTime" :class="{ 'w-100-per': true }" @input="handleWarrantyTimeInput($event, subIndex)">
<el-input style="width: 80px;" placeholder="质保" size="small" v-model="subItem.warrantyPeriod" :class="{ 'w-100-per': true }" @input="handlewarrantyPeriodInput($event, subIndex)">
</el-input><span style="margin-left: 5px;">年</span>
</div>
</td>
......@@ -599,6 +599,7 @@ import relateProDialog from './relateProDialog'
import relateStoreDialog from './relateStoreDialog'
import assiRelateStoreDialog from './assiRelateStoreDialog'
import { getGoodsList, getSpecDataByMerchent, saveAssignByMerchant, saveAssignBySpec } from '@/api/commodity'
import { getProductInfo } from '@/api/product'
// import { getParkStore } from '@api/editCustomer'
import { uploadImg } from '@/api/sys.base'
import { mapActions } from 'vuex'
......@@ -673,7 +674,7 @@ export default {
upgradePrice: '',
shopMinPrice: '',
stock: '',
warrantyTime: '',
warrantyPeriod: '',
},
batchSubmitted: {
shopPriceSub: false,
......@@ -851,28 +852,32 @@ export default {
},
// 选择框-添加其他属性
selectAddAttr(value, targetItem) {
if (targetItem.name === 'goodsCode') {
let materialList = []
targetItem.optionList.forEach(val => {
val.children.forEach(v => {
v.children.forEach(it => {
materialList.push(it)
})
})
if (targetItem.name === 'goodsId') {
// let materialList = []
// targetItem.optionList.forEach(val => {
// val.children.forEach(v => {
// v.children.forEach(it => {
// materialList.push(it)
// })
// })
// })
// 获取素材详情数据
getProductInfo({
id: value.constructor === Array ? value[value.length - 1] : value
}).then(tempVal => {
this.formData.goodsTypeName = tempVal.goodsTypeName
this.formData.goodsImgList = tempVal.goodsImgList || []
this.formData.thumbUrl = [tempVal.thumbUrl]
this.formData.sapCode = tempVal.sapCode
this.formData.sceneName = tempVal.sceneName
this.formData.brandMerchantName = tempVal.brandMerchantName
this.formData.supplierName = tempVal.supplierName
this.formData.baseGoodsName = tempVal.goodsName
this.showSpanText = Object.keys(tempVal).length
this.shopName = tempVal.goodsName
this.selectedSceneCode = tempVal.sceneType
this.formData.goodsCode = tempVal.goodsCode
})
let goodsCode = value.constructor === Array ? value[value.length - 1] : value
var tempVal = materialList.find(item => item.goodsCode === goodsCode)
this.formData.goodsTypeName = tempVal.goodsTypeName
this.formData.goodsImgList = tempVal.goodsImgList || []
this.formData.thumbUrl = [tempVal.thumbUrl]
this.formData.sapCode = tempVal.sapCode
this.formData.sceneName = tempVal.sceneName
this.formData.brandMerchantName = tempVal.brandMerchantName
this.formData.supplierName = tempVal.supplierName
this.formData.baseGoodsName = tempVal.goodsName
this.showSpanText = Object.keys(tempVal).length
this.shopName = tempVal.goodsName
this.selectedSceneCode = tempVal.sceneType
}
},
handleAddPro(targetItem) {
......@@ -1016,9 +1021,8 @@ export default {
if (this.formData.speciLinkMerchants.length) {
getSpecDataByMerchent({ baseGoodsId: this.formData.baseGoodsId }).then(res => {
let arr = []
let merchantIds = []
let speciId = ''
res.forEach(val => {
let merchantIds = []
let specsValueList = []
this.formData.upgradeGoodsList && this.formData.upgradeGoodsList.forEach(item => {
if (item.id == val.id) {
......@@ -1026,13 +1030,12 @@ export default {
specsValueList.push(it.split('-')[1])
})
}
speciId = item.id
})
val.merchantList.forEach(i => {
merchantIds.push(i.merchantId)
})
arr.push({
id: speciId,
id: val.id,
specsValueList: specsValueList,
selectedMerchantIds: merchantIds,
selectedMerchantList: val.merchantList
......@@ -1153,6 +1156,12 @@ export default {
item.upgradePriceSub = true
return item
})
if (!this.specificationValueList.length) {
return this.$message({
message: '请添加规格',
type: 'error'
})
}
this.specificationValueList = arr
this.rules['linkMerchants'][0].required = false
this.rules['speciLinkMerchants'][0].required = false
......@@ -1195,8 +1204,7 @@ export default {
this.saveAssignByMerchantEvent(this.formData.linkMerchants)
} else {
// 按规格直接返回
this.notice.okTips()
this.handleAddClose(true)
this.saveAssignByMerchantEvent(this.formData.speciLinkMerchants)
}
} else {
var needRuleList = Object.keys(options)
......@@ -1240,6 +1248,7 @@ export default {
}
saveAssignByMerchant({
baseGoodsId: this.formData.baseGoodsId,
distributionType: Number(this.formData.distributionType),
upgradeGoodsMerchantRefList: arrData
}).then(res => {
if (isDelete) {
......@@ -1399,7 +1408,7 @@ export default {
upgradePrice: '',
shopMinPrice: '',
stock: '',
warrantyTime: '',
warrantyPeriod: '',
}
this.batchSubmitted = {
shopPriceSub: false,
......@@ -1454,7 +1463,7 @@ export default {
shopPrice: '',
shopMinPrice: '',
stock: '',
warrantyTime: ''
warrantyPeriod: ''
})
} else {
var targetValLen = this.formData['specificationDetailList'][i].specificationValueList.length
......@@ -1484,7 +1493,7 @@ export default {
upgradePrice: '',
shopMinPrice: '',
stock: '',
warrantyTime: '',
warrantyPeriod: '',
}
this.specificationValueList.forEach((item, index) => {
var specificationObj = {}
......@@ -1549,13 +1558,13 @@ export default {
this.batchSetValue('stock', newValue)
},
// 批量质保
handleBatchWarrantyTimeInput(newValue) {
handleBatchwarrantyPeriodInput(newValue) {
var oldValue = newValue
this.$set(this.batchObj, 'warrantyTime', limitPrice(newValue, oldValue, 6, 2))
this.$set(this.batchObj, 'warrantyPeriod', limitPrice(newValue, oldValue, 6, 2))
},
handleBatchWarrantyTimeInputBlur(e) {
handleBatchwarrantyPeriodInputBlur(e) {
let newValue = e.target.value
if (newValue) this.batchSetValue('warrantyTime', newValue)
if (newValue) this.batchSetValue('warrantyPeriod', newValue)
},
// 校验零售价
handleUpgradePrice(newValue, index) {
......@@ -1602,9 +1611,9 @@ export default {
}
},
// 质保
handleWarrantyTimeInput(newValue, index) {
handlewarrantyPeriodInput(newValue, index) {
var oldValue = newValue
this.$set(this.specificationValueList[index], 'warrantyTime', limitPrice(newValue, oldValue, 6, 2))
this.$set(this.specificationValueList[index], 'warrantyPeriod', limitPrice(newValue, oldValue, 6, 2))
}
}
}
......
......@@ -136,13 +136,13 @@
<el-table-column prop="merchantId"
label="商户编号"
align="center" />
<el-table-column prop="userType"
<!-- <el-table-column prop="userType"
label="商户类型"
align="center">
<template slot-scope="scope">
<span>{{ baseData[scope.row.channelType === 2 ? 'ghUserTypeList' : 'userTypeList'][scope.row.userType] }}</span>
</template>
</el-table-column>
</el-table-column> -->
<el-table-column prop="warrantyType"
label="质保类型"
align="center">
......@@ -218,7 +218,7 @@ export default {
getInfo(id) {
getGoodsInfoById({ id: id }).then(res => {
this.commodityInfo = res
this.commodityInfo.linkMerchants = res.merchantRefList ? res.merchantRefList.map(item => Object.assign(item, item.merchantInfo)) : []
this.commodityInfo.linkMerchants = res.upgradeGoodsMerchantRefList ? res.upgradeGoodsMerchantRefList : []
})
},
......
......@@ -42,7 +42,8 @@ export default {
commodityAddSeviceMerchant: commodityAddSeviceMerchant,
getMerchantListByScene: getMerchantListByScene,
editData: {
// goodsCode: '',
goodsCode: '',
goodsId: '',
goodsName: '',
baseGoodsName: '',
goodsTypeName: '',
......@@ -64,7 +65,7 @@ export default {
},
rules: {
// yqMerchantId: [{ required: true, message: '请选择园区店', trigger: 'change' }],
goodsCode: [{ required: true, message: '请选择素材', trigger: 'change' }],
goodsId: [{ required: true, message: '请选择素材', trigger: 'change' }],
shopPrice: [{ required: true, message: '请输入产品成本', trigger: 'blur' }],
retailPrice: [
{ required: true, message: '请输入零售价格', trigger: 'blur' },
......@@ -79,7 +80,7 @@ export default {
linkMerchants: [{ required: true, message: '请选择关联门店', trigger: 'change' }],
speciLinkMerchants: [{ required: true, message: '请选择关联门店', trigger: 'change' }],
specificationDetailList: [{ required: true, message: '请添加规格并保存', trigger: 'change' }],
baseGoodsName: [{ required:true, message: '请输入商品名称', trigger: ['blur', 'change'] }]
baseGoodsName: [{ required: true, message: '请输入商品名称', trigger: ['blur', 'change'] }]
},
comFormRef: 'com',
editForm: [{
......@@ -90,13 +91,13 @@ export default {
// },
formBlock: [
{
name: 'goodsCode',
name: 'goodsId',
label: '选择素材',
isRequired: true,
type: 'cascader',
isClear: false,
optionList: [],
optionId: 'goodsCode',
optionId: 'goodsId',
optionLabel: 'goodsName',
width: '400px'
},
......@@ -178,13 +179,6 @@ export default {
}, {
title: '配规格',
formBlock: [
// {
// name: 'upgradeGoods',
// label: '',
// type: 'relatePro',
// optionValue: 'goodsCode',
// relateAttr: 'goodsCode'
// }
{
name: 'specificationDetailList',
label: '',
......@@ -229,7 +223,6 @@ export default {
this.addOrEdit = this.$route.params.addOrEdit
if (this.addOrEdit === 'edit') {
this.getGoodsInfo(this.$route.params.row.id)
// 编辑回显不可编辑 回显用select
} else {
this.getGoodsList()
this.editForm[0].formBlock[0].isDisabled = false
......@@ -242,9 +235,6 @@ export default {
methods: {
...mapActions({ close: 'd2admin/page/close' }),
getGoodsList() {
// getGoodsList({}).then(res => {
// this.editForm[0].formBlock[0].optionList = res
// })
getThiredMaterialList({}).then(res => {
res && res.forEach(item => {
item.value = item.sceneType
......@@ -258,8 +248,9 @@ export default {
})
let threeChildren = []
val.threeMenu && val.threeMenu.forEach(v => {
v.value = v.goodsCode
v.label = v.goodsName
v.value = v.id
v.label = v.goods_name
threeChildren.push(v)
})
twoChildren[index].children = threeChildren
......@@ -315,7 +306,8 @@ export default {
goodsSpecificationNameList: res.goodsSpecificationNameList,
// linkMerchants: res.merchantRefList ? res.merchantRefList.map(item => Object.assign(item, item.merchantInfo)) : [],
linkMerchants: res.upgradeGoodsMerchantRefList ? res.upgradeGoodsMerchantRefList : [],
speciLinkMerchants: res.upgradeGoodsMerchantRefList ? res.upgradeGoodsMerchantRefList : []
speciLinkMerchants: res.upgradeGoodsMerchantRefList ? res.upgradeGoodsMerchantRefList : [],
goodsId: res.goodsInfo.goodsCode
}
this.editForm[0].formBlock[0].type = 'select'
this.markOldVal.shopPrice = res.shopPrice
......@@ -359,7 +351,6 @@ export default {
let data = deepClone(e)
let [goodsSpecificationNameList, goodsSpecificationList] = [[], []]
data.goodsCode = data.goodsCode.constructor === Array ? data.goodsCode[data.goodsCode.length - 1] : data.goodsCode
data.specificationDetailList.length && data.specificationDetailList.map(val => {
let goodsSpecificationValueList = []
val.specificationValueList.forEach(v => {
......@@ -391,7 +382,7 @@ export default {
upgradePrice: item.upgradePrice,
shopMinPrice: item.shopMinPrice,
stock: item.stock,
warrantyPeriod: item.warrantyTime
warrantyPeriod: item.warrantyPeriod
})
})
var params = {
......
......@@ -207,14 +207,6 @@ export default {
this.getBrandSupplyList(2)
this.getBaseData()
this.editForm[0].formBlock[1].optionList = scenCodeList
// this.editForm[0].formBlock[4].optionList = brandMerchantList
// this.editForm[0].formBlock[5].optionList = [{
// confId: 1,
// confValue: '广联直营'
// }, {
// confId: 2,
// confValue: '供应商供应'
// }]
},
methods: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!