groundingDetail.vue
9.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<!-- 查看上架 -->
<template>
<d2-container class="edit-commodity">
<div class="" v-if="show">
<detail ref="d2GroundingDetail" :rules="rules" form-name="grounding" :origin-data="editData" :form-list="editForm"
:product-service-item-list="productServiceItemList" @handleAddConfirm="handleAddConfirm"
@handleClose="handleAddClose"></detail>
</div>
</d2-container>
</template>
<script>
import { getMerchantGoodsInfo, batchReviewAPI } from '@api/grounding'
import detail from './components/detail.vue'
import { sceneList, BaseData } from '@/common/constants.js'
import { mapActions } from 'vuex'
import { deepClone, Util } from '@/common/util'
import { productList, baseSupplyModeList, upgradeSupplyModeList, crowdUpgradeSupplyModeList } from './constants/data'
import { baseConfig } from "@/main"
import { filterSpecsStr } from '../filterOption'
export default {
name: 'GroundingDetail',
components: {
detail
},
data() {
return {
extendedPosiType: baseConfig.extendedPosiType || [], // 延保类
rules: {
merchantGoodsRefList: [{ required: true }],
sceneName: [{ required: true }],
goodsName: [{ required: true }],
productTypeStr: [{ required: true }],
baseSupplyModeStr: [{ required: true }],
upgradeSupplyModeStr: [{ required: true }],
sellPrice: [{ required: true }],
minSellPrice: [{ required: true }],
upgradeProductCost: [{ required: true }],
giftCost: [{ required: true }],
recoveryCost: [{ required: true }],
virtualAccountCost: [{ required: true }],
warrantyTypeStr: [{ required: true }],
djCost: [{ required: true }],
thirdPartyCost: [{ required: true }],
financeCheckFlagStr: [{ required: true }]
},
editForm: [{
title: '商品信息',
formBlock: [{
name: 'goodsName',
label: '上架商品',
type: 'incidBox',
key: 'goodsType',
detailInfo: [{
label: '商品名称',
value: 'upgradeGoodsName'
}, {
label: '规格',
value: 'specificationData'
}, {
label: '商品编码',
value: 'type'
}, {
label: '第三方编码',
value: 'thirdPartyCode'
}, {
label: '采购价',
value: 'purchasePrice',
unit: true
}, {
label: '参考售价',
value: 'upgradePrice',
unit: true
}, {
label: '适用车型',
value: 'carTypeConfigName'
}, {
label: '所属系列',
value: 'goodsName'
}, {
label: '所属分类',
value: 'tempGoodsTypeName'
}, {
label: '商品ID',
value: 'upgradeCommodityCode'
}]
}, {
name: 'positionStr',
label: '上架部位'
}, {
name: 'goodsAlias',
label: '商品别名'
}, {
name: 'warrantyTypeStr',
label: '质保卡类型'
}, {
name: 'productTypeStr',
label: '产品类型'
}, {
name: 'baseSupplyModeStr',
label: '基础产品供货模式'
}, {
name: 'upgradeSupplyModeStr',
label: '升级产品供货模式'
}, {
name: 'sellPrice',
label: '售价',
unit: true
}, {
name: 'minSellPrice',
label: '最低售价',
unit: true
}, {
name: 'upgradeProductCost',
label: '产品、升级成本',
unit: true
}, {
name: 'giftCost',
label: '赠送成本',
unit: true
}, {
name: 'recoveryCost',
label: '回收成本',
unit: true
}, {
name: 'virtualAccountCost',
label: '虚拟对账成本',
unit: true
}, {
name: 'djCost',
label: '嘀加成本',
unit: true
}, {
name: 'thirdPartyCost',
label: '第三方成本',
unit: true
}, {
name: 'financeCheckFlagStr',
label: '财务规则校验'
}]
}, {
title: '门店信息',
formBlock: [{
name: 'sceneName',
label: '业务场景'
}, {
name: 'merchantGoodsRefList',
label: '上架门店',
type: 'table'
}, {
name: 'voucherList',
label: '上架凭证',
type: 'upload'
}]
}, {
title: '操作信息',
formBlock: [{
type: 'checkView',
name: 'reviewLogList'
}]
}],
show: false,
editData: {},
examineFlag: false,
warrantyTypeShow: {
0: '质保卡',
1: '质保权益卡'
},
detailId: '',
productServiceItemList: [],
filterSpecsStr
}
},
mounted() {
this.getBaseData()
// 获取商品详情
const id = this.$route.params.id
this.detailId = id
if (!id) return this.show = true
this.getDetailInfo(id)
},
methods: {
...mapActions({
get: 'd2admin/base/get',
close: 'd2admin/page/close'
}),
async getBaseData() {
this.positionTypeList = await this.get(BaseData.positionTypeList)
},
getDetailInfo(id) {
getMerchantGoodsInfo({ id }).then(res => {
const productType = []
if (res?.upgradeProductFlag == 'Y') productType.push(2)
if (res?.baseProductFlag == 'Y') productType.push(1)
const { goodsTypeName, secondaryGoodsTypeName, thirdLevelGoodsTypeName } = res.goodsInfo || {}
const types = [goodsTypeName, secondaryGoodsTypeName, thirdLevelGoodsTypeName]
const result = types.filter(type => type).join('-')
const productTypeTextArr = []
// 太阳膜/延保类回显部位
const positionNamesArr = deepClone(this.positionTypeList).filter(val => (res?.upgradeGoods.position?.split(','))?.includes(val.position + '')) || []
// 产品类型
productList.forEach(v => {
if (productType.includes(v.confId)) productTypeTextArr.push(v.confName)
})
res.reviewLogList?.forEach(val => {
val.updatedDateStr = val.updatedDate ? Util.dateFormate(val.updatedDate, 'YYYY-MM-DD HH:mm:ss') : ''
})
let arr = []
if (res.sceneType == 3) { // 1.3场景 升级产品供货模式
arr = crowdUpgradeSupplyModeList
}
if (res.goodsType == 1) { // 太阳膜类 升级产品供货模式(优先级高)
arr = upgradeSupplyModeList
}
res.productTypeStr = productTypeTextArr?.length ? productTypeTextArr.join(';') : '-'
res.warrantyTypeStr = this.warrantyTypeShow[res?.warrantyType] || '-'
res.baseSupplyModeStr = baseSupplyModeList?.filter(v => v.confId == res.baseSupplyMode)[0]?.confName || ''
res.upgradeSupplyModeStr = arr?.filter(v => v.confId == res.upgradeSupplyMode)[0]?.confName || ''
res.sceneName = sceneList[res.sceneType] || '-'
res.productType = productType
res.merchantGoodsRefList = res.merchantGoodsRefList || []
res.voucherList = res?.voucherList || []
res.positionStr = deepClone(this.positionTypeList)?.filter(val => res?.position == val.position)[0]?.confName || ''
res.supplierCode = res?.goodsInfo?.supplierCode
res.financeCheckFlagStr = res?.financeCheckFlag == 'Y' ? '开启' : res?.financeCheckFlag == 'N' ? '关闭' : '-'
res.upgradeGoods = {
...res.upgradeGoods,
goodsName: res.goodsInfo.goodsName,
tempGoodsTypeName: result,
serviceItemNames: res?.upgradeGoods?.upgradeGoodsServiceItemsList?.map(item => { return `${item.serviceName}-${item.serviceGrade}/${item.servicePeriod}` })?.join(','), // 服务项目
positionNames: positionNamesArr.length ? positionNamesArr.map(subItem => { return subItem?.confName }).join('/') : '',
specificationData: this.filterSpecsStr(res?.upgradeGoods),
carTypeConfigName: res?.upgradeGoods?.carTypeConfigList?.map(item => item.seriesName).join('/'),
upgradeCommodityCode: res?.upgradeGoods?.commodityCode
}
this.editData = res || {}
this.$nextTick(() => {
this.show = true
})
})
},
filterEmpty(data) {
return (data ?? '') === ''
},
handleAddConfirm() {
this.$confirm('<p>审核通过后,商品完成上架,对应的门店可使用该商品</p>是否确定审核?', '提示', {
confirmButtonText: '确定',
dangerouslyUseHTMLString: true,
type: 'warning'
}).then(() => {
batchReviewAPI({ ids: [this.detailId] }).then(res => {
this.notice.okTips()
this.handleClose(true)
})
}).catch(err => {
console.log(err)
})
},
handleClose(isRefresh = false) {
if (isRefresh) {
this.close({ tagName: '/grounding' })
this.$router.push({ name: 'grounding' })
this.close({ tagName: '/grounding' })
} else {
this.$confirm('内容未保存,是否返回?', '提示', {
confirmButtonText: '确定',
type: 'warning'
}).then(() => {
this.close({ tagName: '/grounding' })
this.$router.push({ name: 'grounding' })
this.close({ tagName: '/grounding' })
}).catch(err => {
console.log(err)
})
}
},
handleAddClose() {
this.handleClose(true)
}
}
}
</script>
<style lang="scss" scoped></style>