cell-price.vue
1.89 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
<template>
<div class="cell-price">
<div v-if="canChange">
<p class="retail-price">吊牌价:{{retailPrice}}</p>
<p v-if="!showChange">
<i-button type="info" size="small" @click="changeClick">改</i-button>
销售价:{{salesPrice}}
</p>
<p v-else>
<i-button type="warning" size="small" @click="saveClick">存</i-button>
销售价:<span class="price-input">
<Input v-model.number="newPrice"></Input></span>
</p>
</div>
<div v-else>
<p>吊牌价:{{retailPrice}}</p>
<p>销售价:{{salesPrice}}</p>
</div>
</div>
</template>
<script>
export default {
name: 'CellPrice',
props: {
currentRow: {
type: Object
},
showChange: {
type: Boolean,
default: false
},
canChange: {
type: Boolean,
default: false
},
retailPrice: {
type: [String, Number]
},
salesPrice: {
type: [String, Number]
}
},
data() {
return {
newPrice: this.salesPrice
};
},
methods: {
changeClick() {
this.$emit('click-change');
},
saveClick() {
const row = this.currentRow;
const price = this.newPrice;
this.$emit('click-save', row, price);
}
}
};
</script>
<style lang="scss" scoped>
.cell-price {
text-align: left;
.retail-price {
margin-left: 30px;
}
.price-input {
display: inline-block;
width: 60px;
}
}
</style>