Commit 96085441 by 李伟康

feat(OrderPopup): 新增商品列表组件并优化员工列表选择逻辑

- 新增 GoodsList 组件,用于展示和选择商品列表
- 在 EmployeeList 组件中增加判断,防止选择同一人作为不同角色
- 在 popupApi 中添加 getGoodsList 方法获取商品列表数据
- 更新 config.js,添加新的商品列表配置项
- 修改 index.vue,集成新组件并提供所需数据
- 在 store 中添加 boutique 模块管理基础配置数据
1 parent e2861af4
......@@ -53,4 +53,14 @@ module.exports = {
...data
})
},
/**
* 获取商品列表
*/
getGoodsList (data) {
return http.post({
method: 'dj.api.smartcarlife.selectOrderGoods.list',
projectName: 'boutique',
...data
})
},
}
\ No newline at end of file
......@@ -56,6 +56,16 @@ export default {
this.getList(searchValue, true)
},
choose (i) {
let { params: { idKey }, data } = this,
value = {
userId: data.deliveryUserId,
deliveryUserId: data.userId
}[idKey]
if ((idKey == 'userId' || idKey == 'deliveryUserId') && value == i.uuid) return uni.showToast({
title: '销售顾问/录单员与交付专员不能选取同一人',
icon: 'none',
mask: true
})
this.currentId = i.uuid
this.$emit('choose', i)
}
......
<template>
<view class="goods-list">
<!-- <template v-if="list.length"> -->
<template v-for="(i, index) in (searchStatus ? searchList : list)">
<view
:key="index"
@click="choose(i)"
:class="['item flex',{active: checkActive(i)}]"
>
<view class="sprite-icon icon-tag-checked"></view>
<text class="goods-name text-hide">
{{replaceItemText(i.goods,'goodsAlias') ||replaceItemText(i.goods,'upgradeGoodsName') || replaceItemText(i.goodsInfo,'goodsName')}}
</text>
<template v-if="i.goods.merchantGoodsPosition && (i.goods.goodsInfo.goodsType == 1 || i.goods.goodsInfo.goodsType == baseConfigData.selfBuildFilmType)">
<text>「{{ i.goods.positionStr}}」</text>
</template>
<text class="price">¥{{i.goods.price}}</text>
</view>
</template>
<!-- </template> -->
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'GoodsList',
inject: ['userInfo', 'baseConfigData'],
data () {
return {
list: [],
currentIds: [],
chooseList: [],
searchStatus: false,
searchList: [],
}
},
props: {
params: Object,
data: [Object, Array],
cacheData: Array
},
mounted () {
},
methods: {
async getList (searchValue) {
const { userInfo, params } = this,
{ cacheData } = params
this.currentIds = []
this.chooseList = []
if (cacheData && cacheData.length) {
this.list = this.initGoodsList(cacheData)
if (searchValue) this.handleSearch(searchValue)
return
}
const { shopMerchantId, sceneType } = userInfo,
response = await uni.$api.popupApi.getGoodsList({
merchantId: shopMerchantId,
sceneType
})
if (response && response.length) {
this.list = this.initGoodsList(response)
params.cacheData = response
this.$emit('update:params', params)
}
},
handleSearch (searchValue) {
if (!searchValue) this.searchStatus = false
else {
let { list } = this,
goodsList = JSON.parse(JSON.stringify(list)),
arr = []
goodsList.map(c => {
let name = ''
if (c.goodsFlag == 1 && c.goods) name = c.goods.goodsAlias || c.goods.upgradeGoodsName || c.goods.goodsName || ''
if (name.indexOf(searchValue) != -1) {
arr.push(c)
}
})
console.log(arr)
this.searchList = arr
this.searchStatus = true
}
},
initGoodsList (goodsData) {
let { goodsType } = this.params,
{ data } = this,
arr = []
goodsData.map(val => {
if (val.goodsFlag == 1) {
let subVal = val.goods
subVal.positionStr = subVal.position
subVal.upgradePrice = subVal.sellPrice
subVal.price = subVal.sellPrice
subVal.goodsId = subVal.merchantGoodsId
if (goodsType.includes(subVal.merchantGoodsPosition)) arr.push(val)
}
})
if (data.length) data.map(e => {
this.currentIds.push(e.goods.goodsId)
this.chooseList.push(e)
})
return arr
},
choose (i) {
let { goodsId } = i.goods,
{ currentIds } = this,
index = currentIds.indexOf(goodsId)
if (index == -1) {
this.currentIds.push(goodsId)
this.chooseList.push(i)
}
else {
this.currentIds.splice(index, 1)
this.chooseList.splice(index, 1)
}
this.$emit('choose', this.chooseList)
},
replaceItemText (item, key) {
let reg = getRegExp(';~;', 'g'),
value = item[key]
return value ? value.replace(reg, ' ') : ''
},
checkActive (i) {
let { currentIds } = this,
active = false
if (currentIds.length) active = currentIds.includes(i.goods.goodsId)
return active
}
}
}
</script>
<style scoped lang='scss'>
.goods-list {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 32rpx;
margin: 0 48rpx;
.item {
justify-content: center;
height: 72rpx;
border-radius: 8rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
box-sizing: border-box;
padding: 0 32rpx;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
.price {
margin-left: auto;
}
.goods-name {
max-width: 600rpx;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
\ No newline at end of file
......@@ -5,6 +5,15 @@
* 2:二级流量方
* 3:转化人员
* 4:车品牌
* 5: 礼券
* 6:前档
* 7:前侧窗玻璃
* 8:后侧窗玻璃
* 9:后档
* 10:天窗
* 11:套餐
* 12:其他精品
* 13:时间选择
*/
const componentConfig = {
......@@ -43,13 +52,49 @@ const componentConfig = {
title: '选择礼券',
placeholder: '查找',
idKey: 'customerCouponCode'
}
},
6: {
name: 'GoodsList',
title: '选择商品(可多选)',
placeholder: '请输入名称',
idKey: 'goodsId',
goodsType: [1]//前档
},
7: {
name: 'GoodsList',
title: '选择商品(可多选)',
placeholder: '请输入名称',
idKey: 'goodsId',
goodsType:[2] // 前侧窗玻璃
},
8: {
name: 'GoodsList',
title: '选择商品(可多选)',
placeholder: '请输入名称',
idKey: 'goodsId',
goodsType: [3] // 后侧窗玻璃
},
9: {
name: 'GoodsList',
title: '选择商品(可多选)',
placeholder: '请输入名称',
idKey: 'goodsId',
goodsType: [5, 6, 7] // 后档
},
10: {
name: 'GoodsList',
title: '选择商品(可多选)',
placeholder: '请输入名称',
idKey: 'goodsId',
goodsType: 'skylight' // 天窗
},
}
import EmployeeList from './components/EmployeeList.vue'
import DiversionMerchant from './components/DiversionMerchant.vue'
import CarModelList from './components/CarModelList.vue'
import CouponList from './components/CouponList.vue'
import GoodsList from './components/GoodsList.vue'
export default {
data () {
return {
......@@ -60,6 +105,7 @@ export default {
EmployeeList,
DiversionMerchant,
CarModelList,
CouponList
CouponList,
GoodsList
},
}
\ No newline at end of file
......@@ -86,25 +86,17 @@ export default {
type: Boolean,
default: false
},
/**
* 0:销售顾问/录单员
* 1:交付专员
* 2:二级流量方
* 3:转化专员
*/
popupType: {
type: [Number, String],
default: 0
},
data: {
type: Object,
default: () => ({})
},
data: [Object, Array],
externalData: null
},
provide () {
return {
userInfo: this.userInfo
userInfo: this.userInfo,
baseConfigData: this.baseConfigData
}
},
data () {
......@@ -136,6 +128,9 @@ export default {
userInfo () {
return uni.$storage.get("userInfo")
},
baseConfigData () {
return this.$store.state.boutique.baseConfigData
}
},
mounted () {
},
......
......@@ -222,7 +222,9 @@ export default {
},
// 查询素材
async getSoure () {
let { moduleList, toolList, defaultCarId } = await uni.$api.systemApi.getBoutiqueMockData(true)
let baseConfigData = await uni.$api.systemApi.getBoutiqueMockData(true),
{moduleList, toolList, defaultCarId } = baseConfigData
this.$store.state.boutique.baseConfigData = configData
this.moduleList = moduleList
this.toolList = toolList
this.defaultCarId = defaultCarId
......
......@@ -14,6 +14,7 @@ import audio from './modules/audio'
import update from './modules/update'
import sys from './modules/sys'
import point from './modules/point'
import boutique from './modules/boutique'
Vue.use(Vuex)
const store = new Vuex.Store({
......@@ -22,7 +23,8 @@ const store = new Vuex.Store({
audio,
update,
sys,
point
point,
boutique
},
getters
})
......
export default {
state() {
return {
baseConfigData:{}
}
},
mutations: {
},
actions: {
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!