setPriceDialog.vue
2.68 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
<template>
<GLDialog :title="isConversionRate ? '兑换价' : '批量改价'" mode="small" :visible.sync="visible" :show-close="true" :before-close="handleClose" @onOk="confirmPriceChange" @onCancel="handleClose" okText="提交" cancelText="取消">
<div class="dialog-wrap">
<span>
{{ isConversionRate ? '兑换价 = ' : '兑换价 = 供货价1:1积分 +' }}
</span>
<el-input v-if="isConversionRate" size="small" type="text" onkeyup="value = value.replace(/[^\d]/g,'').replace(/^[0]+[0-9]*$/gi,'')" v-model="batchCount" placeholder="请输入积分">
<span slot="append">积分</span>
</el-input>
<el-input v-else size="small" type="text" onkeyup="value = value.replace(/[^\d]/g,'').replace(/^0\d/g, '0')" v-model="batchCount" placeholder="请输入积分">
<span slot="append">积分</span>
</el-input>
<span> +</span>
<el-input size="small" type="text" onkeyup="value = 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') : value" v-model="batchPrice" placeholder="请输入金额" disabled="true">
<span slot="append">元</span>
</el-input>
</div>
</GLDialog>
</template>
<script>
import { limitPrice } from '@/common/constant'
export default {
name: 'setPriceDialog',
props: {
isConversionRate: {
type: Boolean,
default: false
},
visible: {
type: Boolean,
default: false
},
echoParams: {
type: Object,
default: () => {
}
}
},
data() {
return {
batchCount: this.isConversionRate ? this.echoParams.redeemPoints : '',
batchPrice: this.isConversionRate ? this.echoParams.salePrice : '',
}
},
watch: {
batchCount(newValue, oldValue) {
this.batchCount = limitPrice(newValue, oldValue, 5, 0, 1, 99999)
}
},
methods: {
confirmPriceChange() {
const batchParams = {
batchPrice: this.batchPrice,
batchCount: this.batchCount
}
this.$emit('confirm', batchParams)
},
handleClose() {
this.$emit('handleClose')
}
}
}
</script>
<style lang="scss" scoped>
.dialog-wrap {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
span {
white-space: nowrap;
margin-right: 8px;
}
/deep/ .el-input {
&,
.el-input__inner {
width: 100px;
}
.el-input-group__append {
box-sizing: border-box;
padding: 0 11px;
span {
margin: 0;
}
}
}
}
</style>