Commit e1b1f52b by zhangxw

bug修改

1 parent 4615ebe1
......@@ -47,4 +47,10 @@ export function getSceneTypeListByMerchantId(data) {
export function getAllGroupByCategory(data) {
data.method = `${path}productManager.getAllGroupByCategory`
return request(data)
}
// 获取所有上架商品
export function getAllGoodsList(data) {
data.method = `${path}productManager.search`
return request(data, 'post')
}
\ No newline at end of file
......@@ -36,7 +36,7 @@
<!-- 商品分类 权益升级 (线上126) -->
<div class="item" v-if="equitySceneType.includes(formData[item.key]) || formData['sceneType'] == 0">
<div class="label">服务项目:</div>
<div class="value">{{ serviceItems }}</div>
<div class="value">{{ formData['serviceItemNames'] }}</div>
</div>
</div>
</el-form-item>
......@@ -97,8 +97,7 @@ export default {
formData: {},
selectedValue: '',
show: false,
examineFlag: false,
serviceItems: ''
examineFlag: false
}
},
......@@ -120,10 +119,6 @@ export default {
formList: {
type: Array,
default: () => { }
},
productServiceItemList: {
type: Array,
default: () => { }
}
},
......@@ -157,8 +152,6 @@ export default {
this.examineFlag = true
}
})
// 默认显示所有服务项目 (暂时不可配置 显示全部)
this.serviceItems = this.productServiceItemList?.map(v => { return v.serviceName })?.join(',') || ''
this.filterEditForm()
},
......
......@@ -28,7 +28,7 @@
</el-form-item>
</div>
<!-- 商品附带信息 -->
<div v-if="formData['goodsId'].length && item.type === 'incidBox'">
<div v-if="formData['upgradeGoodsId'] && item.type === 'incidBox'">
<div class="incid_box">
<div class="item" v-for="(subItem, subIndex) in item.detailInfo" :key="subIndex">
<div class="label">{{ subItem.label }}:</div>
......@@ -47,12 +47,12 @@
<!-- 商品分类 权益升级 (线上126) -->
<div class="item" v-if="equitySceneType.includes(formData['goodsType']) || formData['sceneType'] == 0">
<div class="label">服务项目:</div>
<div class="value">{{ serviceItems }}</div>
<div class="value">{{ formData['serviceItemNames'] }}</div>
</div>
</div>
</div>
<!-- 下拉框/输入框 -->
<div v-if="item.type === 'input' || item.type === 'select' || item.type === 'cascader'">
<div v-if="item.type === 'input' || item.type === 'select' || item.type === 'searchSelect'">
<el-form-item :prop="item.name"
:label="item.label ? item.label + ':' : ''"
:id="item.name"
......@@ -84,15 +84,23 @@
:label="subItem[item.optionLabel]"
:value="subItem[item.optionId]" />
</el-select>
<!-- 联级选择框 -->
<el-cascader v-else-if="item.type === 'cascader'"
ref="goods-cascader"
v-model="formData[item.name]"
:options="secondGoodsList"
:style="{'width': item.width || formItemWidth}"
:placeholder="'请选择' + item.label"
filterable
@change="changeSelect" />
<el-select v-else-if="item.type === 'searchSelect'"
v-model="formData[item.name]"
:clearable="item.isClear"
:placeholder="'请选择' + item.label"
@change="selectAddAttr($event, item)"
:style="{'width': item.width || formItemWidth}"
remote
reserve-keyword
@visible-change="visibleChange"
:remote-method="remoteMethod"
v-el-select-loadmore="interestsLoadmore"
filterable>
<el-option v-for="subItem in item.optionList"
:key="subItem[item.optionId]"
:label="subItem[item.optionLabel]"
:value="subItem[item.optionId]" />
</el-select>
</el-form-item>
</div>
<!-- 多选 -->
......@@ -135,8 +143,8 @@
plain
class="width_100"
@click="handleUp(2)"
v-if="!formData.status || formData.status == 3">
保存
v-if="filterEmpty(formData.status) || formData.status == 3">
存草稿
</el-button>
<el-button class="width_100 cancel-btn" @click="handleClose">
取消
......@@ -150,9 +158,8 @@
import { deepClone } from '@/common/util'
import { limitPrice } from '@/common/format'
import { mapActions } from 'vuex'
import { commodityAddSeviceMerchant } from '@api/commodity'
import { getSceneTypeListByMerchantId } from '@api/grounding'
import { sceneCodeList } from '@/common/constants.js'
import { sceneCodeList, positionTypeList } from '@/common/constants.js'
import { upgradeSupplyModeList, crowdUpgradeSupplyModeList } from "../constants/data"
import { baseConfig } from "@/main"
export default {
......@@ -166,11 +173,10 @@ export default {
priceReg: /^\d[\d\.]*$/
},
show: false,
serviceItems: '',
rules: {
merchantId: [{ required: true, message: '请选择上架门店', trigger: 'change' }],
sceneType: [{ required: true, message: '请选择业务场景', trigger: 'change' }],
goodsId: [{ required: true, message: '请选择上架商品', trigger: 'change' }],
upgradeGoodsId: [{ required: true, message: '请选择上架商品', trigger: 'change' }],
productType: [{ required: true, message: '请选择产品类型', trigger: 'change' }],
baseSupplyMode: [{ required: true, message: '请选择基础产品供货模式', trigger: 'change' }],
upgradeSupplyMode: [{ required: true, message: '请选择升级/产品供货模式', trigger: 'change' }],
......@@ -221,10 +227,6 @@ export default {
secondGoodsList: {
type: Array,
default: () => {}
},
productServiceItemList: {
type: Array,
default: () => { }
}
},
......@@ -253,12 +255,27 @@ export default {
}
},
directives: {
'el-select-loadmore': {
bind (el, binding) {
const SELECTWRAP_DOM = el.querySelector(
'.el-select-dropdown .el-select-dropdown__wrap'
)
SELECTWRAP_DOM.addEventListener('scroll', function () {
const condition =
this.scrollHeight - this.scrollTop <= this.clientHeight
if (condition) {
binding.value()
}
})
}
}
},
mounted() {
this.formData = deepClone(this.originData)
this.copyFormList = deepClone(this.formList)
this.filterEditForm()
// 默认显示所有服务项目 (暂时不可配置 显示全部)
this.serviceItems = this.productServiceItemList.map(v => { return v.serviceName })?.join(',') || ''
},
methods: {
......@@ -303,6 +320,15 @@ export default {
this.$refs[this.formRef + 'd2FormRuleForm'] && this.$refs[this.formRef + 'd2FormRuleForm'].clearValidate()
})
},
visibleChange(data) {
this.$emit('visibleChange', data)
},
interestsLoadmore() {
this.$emit('interestsLoadmore')
},
remoteMethod(query) {
this.$emit('remoteMethod', query)
},
// 获取门店开通的场景
getSceneTypeList(e) {
getSceneTypeListByMerchantId({ merchantId: e }).then(res => {
......@@ -310,21 +336,6 @@ export default {
this.$set(this.formList[0].formBlock[1], 'optionList', arr)
})
},
// 搜索上架门店
// remoteMethod(queryString) {
// if (queryString) {
// this.loading = true
// setTimeout(() => {
// this.loading = false
// var params = { currentPage: 1, pageSize: 1000, merchantName: queryString }
// commodityAddSeviceMerchant(params).then(res => {
// this.formList[0].formBlock[0].optionList = res.list || []
// })
// }, 600);
// } else {
// this.formList[0].formBlock[0].optionList = []
// }
// },
// 修复直接调用可以会因为没有对应方法报错的问题
input(event, item) {
item.handleInput && this.handleInput(event, item)
......@@ -342,20 +353,24 @@ export default {
},
// 选择框-添加其他属性
selectAddAttr(value, targetItem) {
let _formData = this.formData
if (targetItem.name == 'merchantId') {
var tempVal = targetItem.optionList.find(item => item.merchantId === value)
this.formData.merchantName = tempVal.merchantName
var _tempVal = targetItem.optionList.find(item => item.merchantId === value)
_formData.merchantName = _tempVal.merchantName
}
},
// 联级选择框
changeSelect(value) {
this.formData.upgradeGoodsId = value.constructor === Array ? value[value.length - 1] : value
this.formData.goodsType = value.constructor === Array ? value[0] : ''
// 回显商品附带信息
let noodObj = this.$refs['goods-cascader'][0].getCheckedNodes()[0] || {}
this.formData = {
...this.formData,
...noodObj?.data?.valueObj
// 带出上架商品的附带信息
if (targetItem.name === 'upgradeGoodsId') {
let _valueObj = targetItem.optionList.filter(v => v.confId == value)[0]?.valueObj || {}
let _positionNamesArr = _valueObj?.goodsType == 1 ? deepClone(positionTypeList).filter(it => _valueObj?.position == it.position) : []
_formData.upgradeGoodsId = value
_formData.upgradeGoodsName = _valueObj?.upgradeGoodsName
_formData.type = _valueObj?.type
_formData.upgradePrice = _valueObj?.upgradePrice
_formData.positionNames = _positionNamesArr.length ? _positionNamesArr[0]?.confName : '' // 部位
_formData.goodsName = _valueObj?.goodsName
_formData.goodsTypeName = _valueObj?.goodsTypeName
_formData.goodsType = _valueObj?.goodsType
_formData.serviceItemNames = _valueObj?.serviceItemNames
}
},
handleClose() {
......@@ -415,6 +430,7 @@ export default {
.item{
flex: 0 0 33%;
display: flex;
align-items: start;
margin: 10px 0;
.label{
flex-shrink: 0;
......
......@@ -9,8 +9,10 @@
:origin-data="editData"
:form-list="editForm"
:secondGoodsList="secondGoodsList"
:productServiceItemList="productServiceItemList"
@handleAddConfirm="handleAddConfirm"
@visibleChange="visibleChange"
@interestsLoadmore="interestsLoadmore"
@remoteMethod="remoteMethod"
@handleClose="handleAddClose"></grounding-form>
</div>
</d2-container>
......@@ -19,10 +21,10 @@
import { productList, baseSupplyModeList, upgradeSupplyModeList } from "./constants/data"
import { getMerchantGoodsInfo } from '@api/grounding'
import groundingForm from "./components/groundingForm.vue"
import { BaseData, positionTypeList } from '@/common/constants.js'
import { positionTypeList } from '@/common/constants.js'
import { mapActions } from 'vuex'
import { deepClone } from '@/common/util'
import { addOrUpdateAPI, getAllGroupByCategory } from '@api/grounding'
import { addOrUpdateAPI, getAllGoodsList } from '@api/grounding'
import { getShopMerchantList } from '@api/deviceManage'
export default {
name: 'editGrounding',
......@@ -60,14 +62,14 @@ export default {
}, {
title: '商品信息',
formBlock: [{
name: 'goodsId',
name: 'upgradeGoodsId',
label: '上架商品',
isRequired: true,
type: 'cascader',
isClear: false,
type: 'searchSelect',
optionList: [],
optionId: 'categoryType',
optionLabel: 'categoryName',
isClear: false,
optionId: 'confId',
optionLabel: 'confValue',
width: '432px'
}, {
type: 'incidBox',
......@@ -82,7 +84,7 @@ export default {
label: '参考售价/元',
value: 'upgradePrice'
}, {
label: '所属素材',
label: '所属系列',
value: 'goodsName'
}, {
label: '所属分类',
......@@ -167,7 +169,7 @@ export default {
editData: {
merchantId: '',
sceneCode: '',
goodsId: [],
upgradeGoodsId: '',
goodsCode: '',
positionNames: '',
goodsType: '',
......@@ -182,17 +184,22 @@ export default {
reconcilyCostPrice: ''
},
secondGoodsList: [],
merchantServiceList: []
merchantServiceList: [],
goodsNameKeyword: '',
currentPage: 1,
pageSize: 20
}
},
mounted() {
this.getProductServiceItemList()
this.getBaseData()
let id = this.$route.params.id
// 获取全部上架门店
this.getAllShopMerchantList()
if (!id) {
this.getGoodsList()
// 获取全部上架商品
this.getSelectingList()
} else {
// 获取商品详情
this.getDetailInfo(id)
}
},
......@@ -201,82 +208,84 @@ export default {
get: 'd2admin/base/get',
close: 'd2admin/page/close'
}),
// 获取权益升级类目 服务项目
async getProductServiceItemList() {
this.productServiceItemList = await this.get(BaseData.productServiceItemList)
},
// 获取全部4s店
getAllShopMerchantList() {
getShopMerchantList({}).then(res => {
let formList = this.editForm[0].formBlock
formList[formList.findIndex(val => val.name == 'merchantId')].optionList = res || []
let editForm = this.editForm[0].formBlock
editForm[editForm.findIndex(val => val.name == 'merchantId')].optionList = res || []
})
},
// 获取上架商品数据
getGoodsList(flag) {
getAllGroupByCategory({}).then(res => {
res && res.forEach(item => {
item.value = item.categoryType
item.label = item.categoryName
const twoChildren = []
item.baseGoods && item.baseGoods.forEach(val => {
val.upgradeGoodsList && val.upgradeGoodsList.forEach(v => {
let positionNamesArr = val.goodsInfo?.goodsType == 1 ? deepClone(positionTypeList).filter(it => v.position == it.position) : []
twoChildren.push({
value: v.id,
label: v.upgradeGoodsName,
valueObj: {
upgradeGoodsName: v.upgradeGoodsName,
goodsName: val.goodsInfo?.goodsName,
type: v.type,
goodsTypeName: val.goodsInfo?.goodsTypeName,
upgradePrice: v.upgradePrice,
purchasePrice: v.purchasePrice,
positionNames: positionNamesArr.length ? positionNamesArr[0]?.confName : '' // 部位
}
})
// 获取上架数据
remoteMethod(query) {
this.goodsNameKeyword = query
this.currentPage = 1
this.$set(this.editForm[1].formBlock[0], 'optionList', [])
this.getSelectingList() // 请求接口
},
visibleChange(data) {
// 获取焦点重新渲染下拉框数据
if (data) {
if (this.goodsNameKeyword) {
this.goodsNameKeyword = ''
this.currentPage = 1
this.$set(this.editForm[1].formBlock[0], 'optionList', [])
this.getSelectingList()
}
}
},
// 获取更多上架商品
interestsLoadmore() {
setTimeout(() => {
this.currentPage = this.currentPage + 1
if (this.allPages < this.currentPage) {
this.currentPage = this.allPages
return
}
this.getSelectingList()
}, 10)
},
getSelectingList(defaultSelect) {
getAllGoodsList({
goodsNameKeyword: this.goodsNameKeyword,
currentPage: this.currentPage,
pageSize: this.pageSize
}).then(res => {
this.copyFormList = deepClone(this.editForm)
this.allPages = res.pages
let resArr = []
res.list && res.list.forEach(val => {
val.upgradeGoodsList.forEach(v => {
resArr.push({
confId: v.id,
confValue: `${v?.upgradeGoodsName} / ${val?.goodsInfo?.goodsTypeName} / ${val?.goodsInfo?.goodsName}`,
valueObj: {
upgradeGoodsName: v?.upgradeGoodsName,
goodsName: val?.goodsInfo?.goodsName,
goodsTypeName: val?.goodsInfo?.goodsTypeName,
upgradePrice: v?.upgradePrice,
type: v?.type,
goodsType: val?.goodsInfo?.goodsType,
position: v?.position,
serviceItemNames: v?.upgradeGoodsServiceItemsList?.map(item => {return item.serviceName})?.join(',')
}
})
})
item.children = twoChildren
})
this.secondGoodsList = res
if (flag) {
this.decorate(flag, res)
}
let arr = this.editForm[1].formBlock[0].optionList.concat(resArr)
if (defaultSelect?.length) arr = arr.concat(defaultSelect)
this.$set(this.editForm[1].formBlock[0], 'optionList', this.unique(arr))
this.$nextTick(() => {
this.show = true
})
}).catch(() => {
this.$nextTick(() => {
this.show = true
})
})
},
decorate(upgradeGoodsId, treeData) {
let arr = this.changeDetSelect(
upgradeGoodsId,
treeData
)
this.editData.goodsId = arr
},
changeDetSelect(key, treeData) {
let arr = [] // 在递归时操作的数组
let returnArr = [] // 存放结果的数组
let depth = 0 // 定义全局层级
// 定义递归函数
function childrenEach(treeData, depthN) {
for (var j = 0; j < treeData.length; j++) {
depth = depthN // 将执行的层级赋值 到 全局层级
arr[depthN] = treeData[j].value
if (treeData[j].value == key && depthN == 1) { // depthN == 1只匹配子商品id
returnArr = arr.slice(0, depthN + 1) // 将目前匹配的数组,截断并保存到结果数组,
break
} else {
if (treeData[j].children) {
depth++
childrenEach(treeData[j].children, depth)
}
}
}
return returnArr
}
return childrenEach(treeData, depth)
unique(arr){
const res= new Map()
return arr.filter((a)=> !res.has(a.confId) && res.set(a.confId,1))
},
getBaseData() {
this.editForm.forEach(item => {
......@@ -302,8 +311,12 @@ export default {
res.productType = productType
res.upgradePrice = res.upgradeGoods?.upgradePrice || '-'
res.positionNames = positionNamesArr.length ? positionNamesArr[0]?.confName : ''
let defaultSelect = [{
confId: res?.upgradeGoodsId,
confValue: `${res?.upgradeGoodsName} / ${res?.goodsTypeName} / ${res?.goodsName})`
}]
this.editData = res || {}
this.getGoodsList(res.upgradeGoodsId)
this.getSelectingList(defaultSelect)
})
},
handleAddClose() {
......@@ -325,10 +338,6 @@ export default {
formObj.baseProductFlag = data[v.name].includes(1) ? 'Y' : 'N'
formObj.upgradeProductFlag = data[v.name].includes(2) ? 'Y' : 'N'
}
if (v.name == 'goodsId') {
formObj.upgradeGoodsId = data[v.name].constructor === Array ? data[v.name][data[v.name].length - 1] : data[v.name]
delete formObj[v.name]
}
})
})
delete formObj?.productType
......
......@@ -20,7 +20,7 @@ import detail from './components/detail.vue'
import { sceneList } from '@/common/constants.js'
import { mapActions } from 'vuex'
import { deepClone, Util } from '@/common/util'
import { BaseData, positionTypeList } from '@/common/constants'
import { positionTypeList } from '@/common/constants'
import { productList, baseSupplyModeList, upgradeSupplyModeList, crowdUpgradeSupplyModeList} from './constants/data'
export default {
name: 'groundingDetail',
......@@ -70,7 +70,7 @@ export default {
label: '参考售价/元',
value: 'upgradePrice'
}, {
label: '所属素材',
label: '所属系列',
value: 'goodsName'
}, {
label: '所属分类',
......@@ -132,7 +132,6 @@ export default {
// 获取商品详情
let id = this.$route.params.id
this.detailId = id
this.getProductServiceItemList()
if (!id) return
this.getDetailInfo(id)
},
......@@ -141,9 +140,6 @@ export default {
get: 'd2admin/base/get',
close: 'd2admin/page/close'
}),
async getProductServiceItemList() {
this.productServiceItemList = await this.get(BaseData.productServiceItemList)
},
getDetailInfo(id) {
getMerchantGoodsInfo({ id }).then(res => {
let productType = []
......@@ -174,6 +170,7 @@ export default {
res.upgradePrice = res.upgradeGoods?.upgradePrice || '-'
res.positionNames = positionNamesArr.length ? positionNamesArr[0]?.confName : ''
res.productType = productType
res.serviceItemNames = res.upgradeGoods?.upgradeGoodsServiceItemsList?.map(v => {return v.serviceName})?.join(',')
this.editData = res || {}
this.$nextTick(() => {
......
......@@ -274,39 +274,39 @@ export default {
label: '售价/元',
prop: 'sellPrice',
formatter: (cellValue) => {
return cellValue.sellPrice ? this.priceFilter(cellValue.sellPrice) : '-'
return this.priceFilter(cellValue.sellPrice)
}
}, {
label: '最低售价/元',
prop: 'minSellPrice',
formatter: (cellValue) => {
return cellValue.minSellPrice ? this.priceFilter(cellValue.minSellPrice) : '-'
return this.priceFilter(cellValue.minSellPrice)
},
width: 100
}, {
label: '产品/升级成本',
prop: 'upgradeProductCost',
formatter: (cellValue) => {
return cellValue.upgradeProductCost ? this.priceFilter(cellValue.upgradeProductCost) : '-'
return this.priceFilter(cellValue.upgradeProductCost)
},
width: 110
}, {
label: '赠送成本',
prop: 'giftCost',
formatter: (cellValue) => {
return cellValue.giftCost ? this.priceFilter(cellValue.giftCost) : '-'
return this.priceFilter(cellValue.giftCost)
}
}, {
label: '回收成本',
prop: 'recoveryCost',
formatter: (cellValue) => {
return cellValue.recoveryCost ? this.priceFilter(cellValue.recoveryCost) : '-'
return this.priceFilter(cellValue.recoveryCost)
}
}, {
label: '虚拟对账成本',
prop: 'virtualAccountCost',
formatter: (cellValue) => {
return cellValue.virtualAccountCost ? this.priceFilter(cellValue.virtualAccountCost) : '-'
return this.priceFilter(cellValue.virtualAccountCost)
},
width: 110
}, {
......@@ -417,6 +417,7 @@ export default {
// 处理金额补零
priceFilter(num) {
var pow = Math.pow(10, 2)
if (this.filterEmpty(num)) return '-'
return (Math.round(num * pow) / pow).toFixed(2)
},
// 联动或许对应分类下的素材
......@@ -449,6 +450,8 @@ export default {
yqMerchantId: '',
goodsSource: 0
}
// 重新查询
this.$refs.groundingIndexTable.refreshTable(true, true)
},
beforeSearchFn() {
return new Promise(resolve => {
......@@ -505,6 +508,10 @@ export default {
]
this.actionSetDownloadList({ list, type: 'dowloadList' })
},
// 校验是否为空 不包含0
filterEmpty(data) {
return data instanceof Array ? data.length <= 0 : (data ?? '') === ''
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v[j]))
},
......
......@@ -264,7 +264,7 @@ export default {
})
},
keyDowmGetList() {
this.$refs.commodityTable.refreshTable()
this.$refs.productManageTable.refreshTable()
},
handleReset() {
this.searchForm = {
......@@ -274,6 +274,7 @@ export default {
baseGoodsStatus: '',
type: ''
}
this.$refs.productManageTable.refreshTable(true, true)
},
handleAdd(form) {
this.close({ tagName: '/editProductManage' })
......
......@@ -347,7 +347,7 @@ export default {
specialList = ['purchasePrice', 'warrantyPeriod']
}
// 仅分发至单店时,隐藏采购价/卷,无需填写
if (this.goodsInfoData.shoppingMallFlag === '0') specialList.splice(specialList.indexOf('purchasePrice'), 1)
if (this.goodsInfoData.shoppingMallFlag === '0' && specialList.indexOf('purchasePrice') > 0) specialList.splice(specialList.indexOf('purchasePrice'), 1)
let requiredList = ['specificationData', 'upgradePrice', ...specialList]
for (var i = 0; i < confirmShopData.length; i++) {
const item = confirmShopData[i]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!