detailComp.vue
3.69 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
<template>
<h-dialog ref="myDialog" :title="title" :isVisible="isVisible" :hideCancelBtn="hideBtn" :hideConfirmBtn="hideBtn" :showCloseBtn="hideBtn" @confirm="handleSubmit" @cancel="handleCancel">
<div class="formObj">
<div class="cell" v-for="(item, index) in editFormData" :key="index">
<div class="label">
{{ item.label }}
</div>
<div class="value">{{ item.formatter ? item.formatter(infoData) : (infoData[item.prop] || '-') }}</div>
</div>
</div>
</h-dialog>
</template>
<script>
import hDialog from './dialog'
import { Toast } from 'vant'
import purchaseApi from '@/api/purchase'
export default {
components: { hDialog },
data() {
return {
name: this.$route.query.name,
title: '商品详情',
hideBtn: true,
editFormData: [
{
label: '产品名称',
prop: 'upgradeGoodsName'
},
{ label: '产品编码', prop: 'type', width: '100px' },
{ label: '规格', prop: 'specificationData', width: '90px' },
{
label: '采购数量',
prop: 'goodsNumber',
width: '100px',
formatter: (row) => {
const unit = row.conversionValue ? '卷' : '件'
return (row.goodsNumber || 0) + unit
}
},
{
label: '库存总量',
prop: 'inventoryTotal',
width: '100px',
formatter: (row) => {
const total = (row.goodsNumber || 0) * (row.conversionValue || 1)
if (!row.conversionValue) {
return (row.goodsNumber || 0) + '件'
} else {
// 乘法可能存在精度问题,简单处理
return ((row.goodsNumber || 0) * row.conversionValue).toFixed(2) + '米'
}
}
},
{
label: '已发货数量', prop: 'purchaseNumber', width: '100px',
formatter: (row) => {
const unit = row.conversionValue ? '卷' : '件'
return (row.purchaseNumber || 0) + unit
}
},
{
label: '单价', prop: 'upgradePurchasePrice', width: '90px',
formatter: (row) => {
return '¥' + row.upgradePurchasePrice
}
},
{
label: '总价', prop: 'goodsTotalPrice', width: '90px',
formatter: (row) => {
return '¥' + row.goodsTotalPrice
}
},
{
label: '备注',
prop: 'remark'
}
]
}
},
props: {
isVisible: {
type: Boolean,
default: false
},
infoData: {
type: Object,
default: () => ({})
}
},
mounted() {
console.log('mounted', this.infoData)
},
methods: {
handleSubmit() {
},
handleCancel() {
this.$emit('cancel')
// this.isVisible = false
}
}
}
</script>
<style lang="scss" scoped>
.formObj {
margin: 0 12px;
font-size: 14px;
.cell {
display: flex;
align-items: flex-start;
margin-top: 14px;
color: #222222;
// height: 52px;
// border-bottom: 1px solid #eff0f2;
}
.label {
width: 72px;
color: #999999;
font-size: 14px;
display: flex;
align-items: center;
white-space: nowrap;
line-height: 17px;
margin-right: 10px;
flex-shrink: 0;
.require {
color: #f24724;
font-size: 14px;
margin-left: 4px;
line-height: 52px;
margin-top: 5px;
}
}
.value {
word-break: break-all;
}
.line-feed {
.label {
line-height: 52px;
}
.textarea {
border-radius: 8px;
border: 1px solid #eff0f2;
// height: 220px;
}
}
.explain {
color: #999999;
font-size: 14px;
margin-top: 10px;
}
}
</style>