detail.vue
17.4 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<!-- 表单 -->
<template>
<div class="grounding-detail" v-if="show">
<el-form :model="formData"
:rules="rules"
:ref="formRef + 'd2FormRuleForm'"
v-loading="$store.state.d2admin.loading.value">
<slot name="title" />
<div v-for="(i, idx) in formList"
:key="idx"
class="grounding-form-block d2-container-content">
<p v-show="i.title"
class="edit-sub-title">
{{ i.title }}
</p>
<div class="flex_item">
<div v-for="(item, index) in i.formBlock" :key="index" :class="(item.type === 'incidBox' || item.type === 'table' || item.type === 'upload') ? 'item message-box' : 'item'">
<!-- 商品附带信息 -->
<div v-if="formData['upgradeGoodsName'] && item.type === 'incidBox'">
<el-form-item :prop="item.name"
:label="item.label ? item.label + ':' : ''"
:id="item.name"
:label-width="item.label ? '180px' : '0px'"
class="dis-in-block"
style="margin-bottom: 0">
<div class="incid_box">
<div class="item" v-for="(subItem, subIndex) in item.detailInfo" :key="subIndex">
<div class="label">{{ subItem.unit ? (membraneTypeList.includes(formData[item.key]) ? subItem.label + `(元)/${subItem.value == 'purchasePrice' ? '卷' : '车'}` : (subItem.label + '(元)/件')) : subItem.label }}:</div>
<div class="value">
<ellipsis-popover :content="subItem.unit ? priceFilter(formData.upgradeGoods[subItem.value]) : formData.upgradeGoods[subItem.value] || ''"></ellipsis-popover>
</div>
</div>
<!-- 权益/延保非第三方展示 -->
<div class="item" v-if="(equitySceneType.includes(formData[item.key]) || extendedPosiType.includes(formData[item.key])) && !baseConfig.supplierCode.includes(`${formData.supplierCode}`)">
<div class="label">嘀加成本元/件:</div>
<div class="value">
<ellipsis-popover :content="priceFilter(formData.upgradeGoods['djCost']) || ''"></ellipsis-popover>
</div>
</div>
<!-- 商品分类 1太阳膜 -->
<div class="item" v-if="formData[item.key] == '1'">
<div class="label">部位:</div>
<div class="value">
<ellipsis-popover :content="formData.upgradeGoods['positionNames'] || ''"></ellipsis-popover>
</div>
</div>
<!-- 商品分类 权益服务 非第三方 -->
<div class="item" v-if="equitySceneType.includes(formData[item.key]) && !baseConfig.supplierCode.includes(`${formData.supplierCode}`)">
<div class="label">服务项目:</div>
<div class="value">
<ellipsis-popover :content="formData.upgradeGoods['serviceItemNames'] || ''"></ellipsis-popover>
</div>
</div>
<!-- 商品分类 权益服务 -->
<div class="item" v-if="equitySceneType.includes(formData[item.key])">
<div class="label">实体卡:</div>
<div class="value">{{ formData.upgradeGoods['entityCardFlag'] == 'Y' ? '是' : '否' }}</div>
</div>
<!-- 质保年限 膜类展示-->
<div class="item" v-if="membraneTypeList.includes(formData[item.key])">
<div class="label">质保年限/年:</div>
<div class="value">
<ellipsis-popover :content="`${formData.upgradeGoods['warrantyPeriod']}年` || ''"></ellipsis-popover>
</div>
</div>
</div>
</el-form-item>
</div>
<!-- 审核信息 -->
<div v-else-if="item.type === 'checkView'">
<el-timeline v-show="formData[item.name]">
<el-timeline-item v-for="(reviewInfo,infoId) in formData[item.name]"
color="#0bbd87"
:key="infoId"
:timestamp="reviewInfo.updatedDateStr">
{{ reviewInfo.reviewMessage }}
</el-timeline-item>
</el-timeline>
</div>
<div v-else-if="item.type === 'table'">
<el-form-item :prop="item.name"
:label="item.label ? item.label + ':' : ''"
:id="item.name"
:label-width="item.label ? '180px' : '0px'"
class="dis-in-block"
style="margin-bottom: 0">
<relateStoreTable v-if="$$(formData['merchantGoodsRefList'], 'length')" :merchant-goods-ref-list="formData['merchantGoodsRefList']" :is-detail="true"></relateStoreTable>
</el-form-item>
</div>
<!-- 图片文件 -->
<div v-else-if="item.type === 'upload'">
<div v-if="$$(formData[item.name], 'length')">
<el-form-item :prop="item.name"
:label="item.label ? item.label + ':' : ''"
:id="item.name"
:label-width="item.label ? '180px' : '0px'"
class="dis-in-block"
style="margin-bottom: 0">
<div class="file_box">
<div class="file_item" v-for="(subItem, subIndex) in formData[item.name]" :key="subIndex">
<div class="item_box" @click="handleFileView(subItem)">
<img class="image_icon" v-if="subItem.voucherFileUrl.includes('.png') || subItem.voucherFileUrl.includes('.jpg')" src="../images/photo_thumbnail.png" />
<img class="image_icon" v-if="subItem.voucherFileUrl.includes('.pdf')" src="../images/PDF_thumbnail.png" />
<span class="file_size">文件大小:{{ formatSize(subItem.fileSize) }}</span>
</div>
</div>
</div>
</el-form-item>
</div>
</div>
<div v-else>
<el-form-item :prop="item.name"
:label="item.label ? (item.unit ? (membraneTypeList.includes(formData['goodsType']) ? item.label + `(元)/车` : (item.label + '(元)/件')) : item.label) + ':' : ''"
:id="item.name"
:label-width="item.label ? '180px' : '0px'"
class="dis-in-block"
style="margin-bottom: 0">
<div>
<span>{{ item.unit ? priceFilter(formData[item.name]) : formData[item.name] }}</span>
<span v-if="item.name == 'minSellPrice'">{{ formData['validMinSellPrice'] == 'Y' ? '(校验最低价)' : '(不校验最低价)' }}</span>
</div>
</el-form-item>
</div>
</div>
</div>
</div>
<el-form-item style="margin-top: 40px;text-align: center;">
<el-button type="primary"
@click="handleUp"
class="width_100"
v-if="examineFlag && formData.status == 4"
:disabled="$store.state.d2admin.loading.value">
审核
</el-button>
<el-button class="width_100 cancel-btn"
type="primary"
plain
@click="handleClose">
返回
</el-button>
</el-form-item>
</el-form>
<el-image-viewer
v-if="imgViewerVisible"
:on-close="closeImgViewer"
:url-list="imageFileArr"
:initial-index="initialIndex" />
</div>
</template>
<script>
import { deepClone } from '@/common/util'
import { mapActions } from 'vuex'
import { baseConfig } from "@/main"
import relateStoreTable from "./relateStoreTable.vue"
import ellipsisPopover from '../../components/ellipsisPopover.vue'
export default {
name: 'GroundingForm',
components: {
relateStoreTable,
'el-image-viewer': () => import('element-ui/packages/image/src/image-viewer'),
ellipsisPopover
},
data() {
return {
equitySceneType: baseConfig.equitySceneType || [], // 权益类目
extendedPosiType: baseConfig.extendedPosiType || [], // 延保类
userInfo: this.$store.state.d2admin.user.info,
formData: {},
selectedValue: '',
show: false,
examineFlag: false,
membraneTypeList: baseConfig.membraneTypeList,
dialogObj: {},
imageFileArr: [],
imgViewerVisible: false,
initialIndex: 0
}
},
props: {
formRef: {
type: String,
default: ''
},
rules: {
type: Object,
default: () => { }
},
originData: {
type: Object,
default: () => {
return {}
}
},
formList: {
type: Array,
default: () => { }
}
},
watch: {
originData: {
handler(newVal) {
if (newVal) {
this.formData = deepClone(this.originData)
}
},
deep: true
},
formData: {
handler(newVal) {
if (newVal) {
this.filterEditForm()
}
},
deep: true
},
// 获取所有文件中的图片
'formData.voucherList': {
handler(newVal) {
if (newVal) {
const imageFileArr = newVal.filter(v => v.voucherFileUrl && (v.voucherFileUrl.includes('.png') || v.voucherFileUrl.includes('jpg')))
this.imageFileArr = imageFileArr.map(item => { return item.voucherFileUrl })
}
},
deep: true
}
},
mounted() {
this.formData = deepClone(this.originData)
this.copyFormList = deepClone(this.formList)
this.$nextTick(() => {
const $store = this.$store.getters['d2admin/auth/curBtns']
const btnId = '9031101' // 审核权限ID
const _item = $store?.find(i => (i.authId === btnId))
if (_item) {
this.examineFlag = true
}
})
this.filterEditForm()
},
methods: {
...mapActions({
get: 'd2admin/base/get'
}),
// 出来form表单显示内容
filterEditForm() {
const { copyFormList, formData } = this
// 1 太阳膜 2 (1.3场景商品)
const shopType = formData?.goodsType == 1 ? '1' : formData?.sceneType == 3 ? '2' : ''
const shopForm = deepClone(copyFormList[0].formBlock)
// 太阳膜保留上架部位字段 positionStr
const spliceForm = shopType == '1'
? ['giftCost', 'recoveryCost', 'virtualAccountCost', 'djCost', 'thirdPartyCost']
: shopType == '2'
? ['positionStr', 'productTypeStr', 'warrantyTypeStr', 'baseSupplyModeStr', 'giftCost', 'recoveryCost', 'virtualAccountCost', 'djCost', 'thirdPartyCost']
: this.equitySceneType.includes(formData?.goodsType) || this.extendedPosiType.includes(formData?.goodsType)
? (this.extendedPosiType.includes(formData?.goodsType) && !this.baseConfig.supplierCode.includes(`${formData.supplierCode}`)
? ['positionStr', 'productTypeStr', 'warrantyTypeStr', 'baseSupplyModeStr', 'upgradeSupplyModeStr', 'giftCost', 'recoveryCost', 'virtualAccountCost', 'upgradeProductCost']
: ['positionStr', 'productTypeStr', 'warrantyTypeStr', 'baseSupplyModeStr', 'upgradeSupplyModeStr', 'giftCost', 'recoveryCost', 'virtualAccountCost', 'upgradeProductCost'])
: ['positionStr', 'productTypeStr', 'warrantyTypeStr', 'baseSupplyModeStr', 'upgradeSupplyModeStr', 'giftCost', 'recoveryCost', 'virtualAccountCost', 'djCost', 'thirdPartyCost']
// 未勾选基础商品类型
if (!this.formData.productType?.includes(1)) spliceForm.push('baseSupplyModeStr')
// 赠送成本:仅产品类型选择“基础产品”时展示
if (formData.productType?.includes(1)) spliceForm.indexOf('giftCost') > -1 && spliceForm.splice(spliceForm.indexOf('giftCost'), 1)
// 回收成本:仅产品类型选择“升级产品”且升级/产品供货模式选择“门店回收原厂+嘀加”时展示
if (formData.productType?.includes(2) && formData.upgradeSupplyMode == 4) {
spliceForm.indexOf('recoveryCost') > -1 && spliceForm.splice(spliceForm.indexOf('recoveryCost'), 1)
}
// 虚拟对账成本:仅产品类型选择“升级产品”且升级/产品供货模式选择“门店套码+嘀加”“ 服务商自采+嘀加”时展示
if ((formData.productType?.includes(2) && formData.upgradeSupplyMode == 3) || (formData.productType?.includes(2) && formData.upgradeSupplyMode == 5)) {
spliceForm.indexOf('virtualAccountCost') > -1 && spliceForm.splice(spliceForm.indexOf('virtualAccountCost'), 1)
}
// 仅选中基础产品类型 不展示 售价字段
if (formData.productType?.length == 1 && formData.productType?.includes(1)) spliceForm.push('sellPrice', 'minSellPrice', 'upgradeProductCost', 'upgradeSupplyModeStr')
const newForm = shopForm.filter(v => !spliceForm?.includes(v.name))
this.$set(this.formList[0], 'formBlock', newForm)
this.$nextTick(() => {
this.show = true
})
},
// 选择框-添加其他属性
selectAddAttr(value, targetItem) {
if (targetItem.name === 'goodsCode') {
var tempVal = targetItem.optionList.find(item => item.goodsCode === value)
this.formData.goodsTypeName = tempVal.goodsTypeName
this.formData.thumbUrl = tempVal.thumbUrl
this.formData.sapCode = tempVal.sapCode
}
this.selectedValue = value
},
// 文件预览
handleFileView(item) {
if (item?.voucherFileUrl?.includes('.pdf')) {
window.open(item.voucherFileUrl) // pdf文件新窗口打开直接预览
} else {
this.imgViewerVisible = true
this.imageFileArr.forEach((val, index) => { // 图片使用elementImage图片预览组件
if (val == item.voucherFileUrl) this.initialIndex = index
})
}
},
closeImgViewer() {
this.imgViewerVisible = false
},
// 文件大小格式化
formatSize(byte) {
let size = ""
if (byte < 0.1 * 1024) {
// 小于0.1KB,则转化成B
size = `${byte.toFixed(2)}B`
} else if (byte < 0.1 * 1024 * 1024) {
// 小于0.1MB,则转化成KB
size = `${(byte / 1024).toFixed(2)}KB`
} else if (byte < 0.1 * 1024 * 1024 * 1024) {
// 小于0.1GB,则转化成MB
size = `${(byte / (1024 * 1024)).toFixed(2)}MB`
}
const sizeStr = `${size}` // 转成字符串
const index = sizeStr.indexOf(".") // 获取小数点处的索引
const dou = sizeStr.substr(index + 1, 2) // 获取小数点后两位的值
if (dou == "00") {
// 判断后两位是否为00,如果是则删除00
return sizeStr.substring(0, index) + sizeStr.substr(index + 3, 2)
}
return size
},
// 处理金额补零
priceFilter(num) {
var pow = Math.pow(10, 2)
if (this.filterEmpty(num)) return '-'
return `${(Math.round(num * pow) / pow).toFixed(2)}元`
},
handleClose() {
this.$emit('handleClose')
},
jumpScroll(idName) {
document.getElementById(idName).scrollIntoView()
},
filterEmpty(data) {
return (data ?? '') === ''
},
handleUp(e) {
this.$emit('handleAddConfirm')
// this.$refs[this.formRef + 'd2FormRuleForm'].validate((valid, options) => {
// if (valid) {
// this.$emit('handleAddConfirm')
// } else {
// var needRuleList = Object.keys(options)
// this.jumpScroll(needRuleList[0])
// return true
// }
// })
}
}
}
</script>
<style lang="scss" scoped>
.grounding-detail{
.grounding-form-block {
padding: 20px 0px;
.flex_item{
display: flex;
flex-flow: wrap;
.item {
width: 33%;
margin-bottom: 10px;
}
.message-box{
width: 100%;
font-size: 14px;
.incid_box{
margin: 10px 0;
background: #F9F9F9;
border-radius: 8px;
display: flex;
flex-wrap: wrap;
padding: 15px;
.item{
width: 33%;
display: flex;
.label{
flex-shrink: 0;
color: #666666;
width: 150px;
text-align: right;
}
.value {
width: calc(100% - 150px);
}
.text-hide {
width: calc(100% - 150px);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.flex_1{
flex: 0 0 100%;
}
}
}
.file_box{
width: 100%;
display: flex;
flex-wrap: wrap;
.file_item{
flex: 0 0 20%;
display: flex;
.item_box{
display: flex;
align-items: center;
cursor: pointer;
.image_icon{
width: 24px;
height: 24px;
}
.file_size{
color: #999999;
font-size: 14px;
margin-left: 8px;
}
}
}
}
}
}
.width_100{
display: inline-block;
width: 100px;
}
}
</style>