modal-unstock.vue
2.41 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
<template>
<Modal
v-model="visiable"
:loading="fetchingNoSale"
:transfer="true"
sure-text="不卖了"
cancel-text="继续出售"
@on-sure="onSure"
>
<div class="change-price-modal" v-if="skc.storageNum > 1">
<p class="modal-title">选择你要下架的数量</p>
<InputUfo v-model="unStockNum" :maxlength="8" :readonly="true" class="inp-unstock">
<i slot="prepend" class="iconfont iconplus-minus" @touchend="onChangeNum(-1)"></i>
<i slot="append" class="iconfont iconi-add" @touchend="onChangeNum(1)"></i>
</InputUfo>
<p class="stock-txt">
目前还有{{storageNum}}个库存
</p>
<p class="tips">
下架商品保证金会被释放
</p>
</div>
<div class="change-price-modal" v-else>
<p class="modal-title">您确定不卖此商品吗?</p>
</div>
</Modal>
</template>
<script>
import Modal from './modal';
import InputUfo from './input-ufo';
import {createNamespacedHelpers} from 'vuex';
const {mapState} = createNamespacedHelpers('order/priceChange');
export default {
name: 'ModalUnstock',
components: {Modal, InputUfo},
data() {
return {
visiable: false,
skc: {},
unStockNum: 1,
storageNum: 1
};
},
computed: {
...mapState(['fetchingNoSale'])
},
methods: {
show({skc}) {
// console.log(skc);
this.skc = skc;
this.unStockNum = 1;
this.storageNum = skc.storageNum;
this.visiable = true;
},
hide() {
this.skc = {};
this.storageNum = 1;
this.unStockNum = 1;
this.visiable = false;
},
onSure() {
this.$emit('on-no-sale', {skc: this.skc, num: this.unStockNum});
},
onInput(val) {
this.$emit('input', val);
},
onChangeNum(num) {
const value = this.unStockNum + num;
if (value <= 0 || value > this.storageNum) {
return;
}
this.unStockNum = value;
}
}
};
</script>
<style lang="scss" scoped>
.change-price-modal {
.stock-txt {
margin: 20px 0 10px 0;
}
.tips {
margin-bottom: 10px;
color: #999;
}
.inp-unstock {
margin-bottom: 10px;
/deep/ .iconfont {
padding: 34px 40px;
width: 112px;
font-size: 32px;
color: #999;
font-weight: 600;
}
/deep/ .cube-input-field {
text-align: center;
}
}
.modal-title {
line-height: 100px;
text-align: center;
}
}
</style>