index.vue
6.59 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
<template>
<div class="table-wrap">
<table>
<tr>
<th rowspan="2">规格</th>
<th rowspan="2">价格区间(万元)</th>
<th rowspan="2">价格系数</th>
<th colspan="2" v-for="(item, index) in tableData.salePeriodData" :key="index">{{ item.servicePeriod }}年版</th>
</tr>
<tr>
<template v-for="(item, index) in tableData.salePeriodData">
<th :key="index">
上架成本
<!-- <el-tooltip class="item" effect="dark" content="提示待运营提供" placement="top">
<img class="tip" :src="require('@/assets/tip.png')" />
</el-tooltip> -->
</th>
<th :key="index">
销售成本
<!-- <el-tooltip class="item" effect="dark" content="提示待运营提供" placement="top">
<img class="tip" :src="require('@/assets/tip.png')" />
</el-tooltip> -->
</th>
</template>
</tr>
<tr>
<td rowspan="4">{{ tableData.serviceGrade }}</td>
<td>标准</td>
<td>-</td>
<template v-for="(item, index) in tableData.salePeriodData">
<td :key="index"><el-input :placeholder="placeholder" @input="changePrice($event, item, 'standardShelfCost')" :disabled="disabled" v-model="item.standardShelfCost"></el-input></td>
<td :key="index"><el-input :placeholder="placeholder" @input="changePrice($event, item, 'standardSalesCost')" :disabled="disabled" v-model="item.standardSalesCost"></el-input></td>
</template>
</tr>
<tr v-for="(item, index) in tableData.gradeConfigList" :key="index">
<td class="price">
<el-input :placeholder="placeholder" @input="changePrice($event, item, 'minPrice')" @blur="formatPrice($event, item, 'minPrice', 200)" :disabled="disabled" v-model="item.minPrice"></el-input>
<span class="sign">-</span>
<el-input :placeholder="placeholder" @input="changePrice($event, item, 'maxPrice')" @blur="formatPrice($event, item, 'maxPrice', 200)" :disabled="disabled" v-model="item.maxPrice"></el-input>
</td>
<td><el-input :placeholder="placeholder" @input="changePrice($event, item, 'priceCoefficient')" :disabled="disabled" @blur="formatPrice($event, item, 'priceCoefficient', 100)" v-model="item.priceCoefficient"></el-input></td>
<template v-for="(ele, eIdx) in tableData.salePeriodData">
<td :key="eIdx">{{ calcPrice(ele.standardShelfCost, item.priceCoefficient) }}</td>
<td :key="eIdx">{{ calcPrice(ele.standardSalesCost, item.priceCoefficient) }}</td>
</template>
</tr>
<tr class="desc-wrap">
<td class="desc-td" :colspan="tableData.salePeriodData.length * 2 + 3">
<div class="desc">
<label for="">服务条款概述:</label>
<Editor :disabled="disabled" :hasTool="false" :editorOption="overviewOption" v-model="tableData.serviceOverview"></Editor>
</div>
</td>
</tr>
<tr class="desc-wrap">
<td class="desc-td" :colspan="tableData.salePeriodData.length * 2 + 3">
<div class="desc">
<label for="">规格详细描述:</label>
<Editor :disabled="disabled" :hasTool="false" :editorOption="DetailOption" v-model="tableData.serviceDetail"></Editor>
</div>
</td>
</tr>
</table>
</div>
</template>
<script>
import Editor from '@/components/Editor'
export default {
name: 'ServicesTable',
components: {
Editor
},
props: {
name: {
type: String,
default: ''
},
tableData: {
type: String,
default: () => {
return {}
}
},
disabled: {
type: Boolean,
default: false
},
url: {
type: String,
default: ''
},
key: {
type: String,
default: ''
}
},
data() {
return {
placeholder: '请输入',
overviewOption: {
placeholder: '请输入服务条款概述',
modules: {
toolbar: false,
clipboard: {
// 粘贴版,处理粘贴时候的自带样式
matchers: [[Node.ELEMENT_NODE, this.HandleCustomMatcher]]
}
}
},
DetailOption: {
placeholder: '请输入规格详细描述',
modules: {
toolbar: false,
clipboard: {
// 粘贴版,处理粘贴时候的自带样式
matchers: [[Node.ELEMENT_NODE, this.HandleCustomMatcher]]
}
}
}
}
},
methods: {
changePrice(value, item, key) {
item[key] = value
? value
.replace(/^0\d/g, '0')
.replace(/[^\d.]/g, '')
.replace(/^\./g, '')
.replace(/^\d{6}\d+(\.\d+)?/g, value.substr(0, 6))
.replace(/\.{2,}/g, '')
.replace('.', '$#$')
.replace(/\./g, '')
.replace('$#$', '.')
.replace(/^(-)*(\d+)\.(\d\d).*$/, '$1$2.$3')
: ''
},
formatPrice(e, item, key, maxNum) {
let num = e.target.value
if (num > maxNum) {
item[key] = maxNum
}
},
calcPrice(price1, price2) {
price1 = price1 || 0
price2 = price2 || 0
return Number((price1 * price2).toFixed(2))
},
HandleCustomMatcher(node, Delta) {
// 文字、图片等,从别处复制而来,清除自带样式,转为纯文本
let ops = []
Delta.ops.forEach(op => {
if (op.insert && typeof op.insert === 'string') {
ops.push({
insert: op.insert
})
}
})
Delta.ops = ops
return Delta
}
}
}
</script>
<style lang="scss" scoped>
.table-wrap {
.tip {
width: 14px;
vertical-align: middle;
margin-bottom: 2px;
cursor: pointer;
}
/deep/ .el-input__inner {
padding: 0 2px;
text-align: center;
}
th,
td {
border: 1px solid #e5e5e5;
padding: 0 16px;
vertical-align: middle;
text-align: center;
}
th {
background: #f4f6fc;
font-weight: 600;
font-size: 14px;
color: #333333;
}
td {
font-weight: 400;
height: 56px;
font-size: 14px;
color: #666666;
}
.price {
width: 136px;
.sign {
margin: 0 6px;
}
.el-input {
width: 50px;
}
}
.desc-wrap {
height: 88px;
.desc-td {
padding: 12px 16px;
}
.desc {
display: flex;
height: 100%;
label {
white-space: nowrap;
}
/deep/ .editor {
width: 100%;
text-align: left;
border-radius: 4px;
.w-e-text-container {
border-radius: 4px;
}
}
}
}
}
</style>