@weitutech/by-components 1.0.27 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,29 +1,29 @@
1
- <template>
2
- <div class="drawer_query_btn b-fold-search">
3
- <div @click="drawer">
4
- <template v-if="show == true">
5
- <span style="color: #3aa1ff; vertical-align:middle;">收起</span>&nbsp;&nbsp;<img style="vertical-align:middle;" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyBjbGFzcz0iaWNvbiIgd2lkdGg9IjIwMHB4IiBoZWlnaHQ9IjIwMC4wMHB4IiB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbD0iIzVjYWRmZiIgZD0iTTg3Ny41IDU2NS45bC0zNjcuNi0zNDAtMzY3LjYgMzQwYy0yMi41IDE0LjUtNTIuNSAxNC41LTY3LjUgMC0xNS0yMS43LTE1LTUwLjcgMC02NS4xTDQ5NSAxMTcuNWMwLTcuMiA3LjUtNy4yIDE1LTcuMnM3LjUgMCAxNSA3LjJsNDIwLjIgMzgzLjNjMjIuNSAyMS43IDE1IDUwLjYgMCA2NS4xLTIyLjcgMTQuNS01Mi43IDE0LjUtNjcuNyAwek00OTQuOCA0NTAuMWMwLTcuMiA3LjUtNy4yIDE1LTcuMnMxNSAwIDE1IDcuMkw5NDUgODMzLjRjMjIuNSAyMS43IDE1IDUwLjYgMCA2NS4xLTIyLjUgMTQuNC01Mi41IDE0LjQtNjcuNSAwTDUwOS44IDU1OC42IDE0Mi4yIDkwNS44Yy0yMi41IDE0LjUtNTIuNSAxNC41LTY3LjUgMC0xNS0yMS43LTE1LTUwLjcgMC02NS4xbDQyMC4xLTM5MC42eiBtMCAwIiAvPjwvc3ZnPg==" alt="收起">
6
- </template>
7
- <template v-else>
8
- <span style="color: #3aa1ff; vertical-align:middle;">展开更多</span>&nbsp;&nbsp;<img style="vertical-align:middle;" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyBjbGFzcz0iaWNvbiIgd2lkdGg9IjIwMHB4IiBoZWlnaHQ9IjIwMC4wMHB4IiB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbD0iIzVjYWRmZiIgZD0iTTE0NS40IDQ2MS4xbDM2Ny42IDM0MCAzNjcuNi0zNDBjMjIuNS0xNC41IDUyLjUtMTQuNSA2Ny41IDAgMTUgMjEuNyAxNSA1MC43IDAgNjUuMUw1MjcuOSA5MDkuNWMwIDcuMi03LjUgNy4yLTE1IDcuMnMtNy41IDAtMTUtNy4yTDc3LjcgNTI2LjJjLTIyLjUtMjEuNy0xNS01MC42IDAtNjUuMSAyMi42LTE0LjUgNTIuNi0xNC41IDY3LjcgMHpNNTI4IDU3Ni45YzAgNy4yLTcuNSA3LjItMTUgNy4ycy0xNSAwLTE1LTcuMkw3Ny44IDE5My42Yy0yMi41LTIxLjctMTUtNTAuNiAwLTY1LjEgMjIuNS0xNC40IDUyLjUtMTQuNCA2Ny41IDBMNTEzIDQ2OC40bDM2Ny42LTM0Ny4yYzIyLjUtMTQuNSA1Mi41LTE0LjUgNjcuNSAwIDE1IDIxLjcgMTUgNTAuNyAwIDY1LjFMNTI4IDU3Ni45eiBtMCAwIiAvPjwvc3ZnPg==" alt="展开更多">
9
- </template>
10
- </div>
11
- </div>
12
- </template>
13
- <script>
14
- export default {
15
- data() {
16
- return {
17
- show: false
18
- }
19
- },
20
- methods: {
21
- drawer(value) {
22
- this.show = !this.show
23
- this.$emit("change", this.show)
24
- }
25
-
26
- }
27
- }
28
- </script>
29
-
1
+ <template>
2
+ <div class="drawer_query_btn b-fold-search">
3
+ <div @click="drawer">
4
+ <template v-if="show == true">
5
+ <span style="color: #3aa1ff; vertical-align:middle;">收起</span>&nbsp;&nbsp;<img style="vertical-align:middle;" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyBjbGFzcz0iaWNvbiIgd2lkdGg9IjIwMHB4IiBoZWlnaHQ9IjIwMC4wMHB4IiB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbD0iIzVjYWRmZiIgZD0iTTg3Ny41IDU2NS45bC0zNjcuNi0zNDAtMzY3LjYgMzQwYy0yMi41IDE0LjUtNTIuNSAxNC41LTY3LjUgMC0xNS0yMS43LTE1LTUwLjcgMC02NS4xTDQ5NSAxMTcuNWMwLTcuMiA3LjUtNy4yIDE1LTcuMnM3LjUgMCAxNSA3LjJsNDIwLjIgMzgzLjNjMjIuNSAyMS43IDE1IDUwLjYgMCA2NS4xLTIyLjcgMTQuNS01Mi43IDE0LjUtNjcuNyAwek00OTQuOCA0NTAuMWMwLTcuMiA3LjUtNy4yIDE1LTcuMnMxNSAwIDE1IDcuMkw5NDUgODMzLjRjMjIuNSAyMS43IDE1IDUwLjYgMCA2NS4xLTIyLjUgMTQuNC01Mi41IDE0LjQtNjcuNSAwTDUwOS44IDU1OC42IDE0Mi4yIDkwNS44Yy0yMi41IDE0LjUtNTIuNSAxNC41LTY3LjUgMC0xNS0yMS43LTE1LTUwLjcgMC02NS4xbDQyMC4xLTM5MC42eiBtMCAwIiAvPjwvc3ZnPg==" alt="收起">
6
+ </template>
7
+ <template v-else>
8
+ <span style="color: #3aa1ff; vertical-align:middle;">展开更多</span>&nbsp;&nbsp;<img style="vertical-align:middle;" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyBjbGFzcz0iaWNvbiIgd2lkdGg9IjIwMHB4IiBoZWlnaHQ9IjIwMC4wMHB4IiB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbD0iIzVjYWRmZiIgZD0iTTE0NS40IDQ2MS4xbDM2Ny42IDM0MCAzNjcuNi0zNDBjMjIuNS0xNC41IDUyLjUtMTQuNSA2Ny41IDAgMTUgMjEuNyAxNSA1MC43IDAgNjUuMUw1MjcuOSA5MDkuNWMwIDcuMi03LjUgNy4yLTE1IDcuMnMtNy41IDAtMTUtNy4yTDc3LjcgNTI2LjJjLTIyLjUtMjEuNy0xNS01MC42IDAtNjUuMSAyMi42LTE0LjUgNTIuNi0xNC41IDY3LjcgMHpNNTI4IDU3Ni45YzAgNy4yLTcuNSA3LjItMTUgNy4ycy0xNSAwLTE1LTcuMkw3Ny44IDE5My42Yy0yMi41LTIxLjctMTUtNTAuNiAwLTY1LjEgMjIuNS0xNC40IDUyLjUtMTQuNCA2Ny41IDBMNTEzIDQ2OC40bDM2Ny42LTM0Ny4yYzIyLjUtMTQuNSA1Mi41LTE0LjUgNjcuNSAwIDE1IDIxLjcgMTUgNTAuNyAwIDY1LjFMNTI4IDU3Ni45eiBtMCAwIiAvPjwvc3ZnPg==" alt="展开更多">
9
+ </template>
10
+ </div>
11
+ </div>
12
+ </template>
13
+ <script>
14
+ export default {
15
+ data() {
16
+ return {
17
+ show: false
18
+ }
19
+ },
20
+ methods: {
21
+ drawer(value) {
22
+ this.show = !this.show
23
+ this.$emit("change", this.show)
24
+ }
25
+
26
+ }
27
+ }
28
+ </script>
29
+
@@ -1,109 +1,109 @@
1
- <template>
2
- <div class="b-picker wrapper">
3
- <el-date-picker
4
- style="width: 70%"
5
- :value="value"
6
- v-bind="dateOptions"
7
- @input="handleChange"
8
- />
9
- <div class="btn">
10
- <span
11
- v-for="item in shortcuts"
12
- :key="item.key"
13
- class="item"
14
- :class="{ item_active: item.key === active }"
15
- @click="handleClick(item)"
16
- >
17
- {{ item.label }}
18
- </span>
19
- </div>
20
- </div>
21
- </template>
22
-
23
- <script>
24
- import moment from "moment"
25
- export default {
26
- props: {
27
- value: {
28
- type: [Array, String],
29
- required: true,
30
- default: () => []
31
- },
32
- otherOption: {
33
- type: Object,
34
- default: () => ({
35
- startPlaceholder: "开始时间",
36
- endPlaceholder: "结束时间",
37
- type: "daterange",
38
- rangeSeparator: "-",
39
- size: "mini",
40
- active: ""
41
- })
42
- }
43
- },
44
-
45
- data() {
46
- return {
47
- shortcuts: [
48
- { label: "上月", start_time: moment().subtract(1, "months").startOf("month").format("YYYY-MM-DD"), end_time: moment().subtract(1, "months").endOf("month").format("YYYY-MM-DD"), key: "last_month" },
49
- { label: "昨天", start_time: moment().subtract(1, "days").format("YYYY-MM-DD"), end_time: moment().subtract(1, "days").format("YYYY-MM-DD"), key: "yesterday" },
50
- { label: "今天", start_time: moment().startOf("day").format("YYYY-MM-DD"), end_time: moment().startOf("day").format("YYYY-MM-DD"), key: "today" },
51
- { label: "本周", start_time: moment().startOf("week").format("YYYY-MM-DD"), end_time: moment().endOf("week").format("YYYY-MM-DD"), key: "week" },
52
- { label: "本月", start_time: moment().startOf("month").format("YYYY-MM-DD"), end_time: moment().endOf("month").format("YYYY-MM-DD"), key: "month" }
53
- ],
54
- active: ""
55
- }
56
- },
57
-
58
- computed: {
59
- dateOptions() {
60
- return {
61
- startPlaceholder: "开始时间",
62
- endPlaceholder: "结束时间",
63
- type: "daterange",
64
- rangeSeparator: "至",
65
- size: "mini",
66
- active: "",
67
- ...this.otherOption
68
- }
69
- }
70
- },
71
-
72
- watch: {
73
- value: {
74
- handler(newValue, oldValue) {
75
- if (newValue && newValue.length) {
76
- this.active = ""
77
- this.shortcuts.forEach(item => {
78
- if (item.start_time === newValue[0] && item.end_time === newValue[1]) {
79
- this.active = item.key
80
- }
81
- })
82
- } else {
83
- this.active = this.dateOptions.active
84
- const item = this.shortcuts.find(item => item.key === this.dateOptions.active) || {}
85
- if (item.start_time && item.end_time) {
86
- this.handleClick(item)
87
- }
88
- }
89
- },
90
- immediate: true
91
- }
92
- },
93
-
94
- methods: {
95
- handleChange(e) {
96
- if (!e) {
97
- this.$emit("input", [])
98
- } else {
99
- this.$emit("input", e.map(item => moment(item).format("YYYY-MM-DD")))
100
- }
101
- this.active = ""
102
- },
103
- handleClick(item) {
104
- this.active = item.key
105
- this.$emit("input", [item.start_time, item.end_time])
106
- }
107
- }
108
- }
109
- </script>
1
+ <template>
2
+ <div class="b-picker wrapper">
3
+ <el-date-picker
4
+ style="width: 70%"
5
+ :value="value"
6
+ v-bind="dateOptions"
7
+ @input="handleChange"
8
+ />
9
+ <div class="btn">
10
+ <span
11
+ v-for="item in shortcuts"
12
+ :key="item.key"
13
+ class="item"
14
+ :class="{ item_active: item.key === active }"
15
+ @click="handleClick(item)"
16
+ >
17
+ {{ item.label }}
18
+ </span>
19
+ </div>
20
+ </div>
21
+ </template>
22
+
23
+ <script>
24
+ import moment from "moment"
25
+ export default {
26
+ props: {
27
+ value: {
28
+ type: [Array, String],
29
+ required: true,
30
+ default: () => []
31
+ },
32
+ otherOption: {
33
+ type: Object,
34
+ default: () => ({
35
+ startPlaceholder: "开始时间",
36
+ endPlaceholder: "结束时间",
37
+ type: "daterange",
38
+ rangeSeparator: "-",
39
+ size: "mini",
40
+ active: ""
41
+ })
42
+ }
43
+ },
44
+
45
+ data() {
46
+ return {
47
+ shortcuts: [
48
+ { label: "上月", start_time: moment().subtract(1, "months").startOf("month").format("YYYY-MM-DD"), end_time: moment().subtract(1, "months").endOf("month").format("YYYY-MM-DD"), key: "last_month" },
49
+ { label: "昨天", start_time: moment().subtract(1, "days").format("YYYY-MM-DD"), end_time: moment().subtract(1, "days").format("YYYY-MM-DD"), key: "yesterday" },
50
+ { label: "今天", start_time: moment().startOf("day").format("YYYY-MM-DD"), end_time: moment().startOf("day").format("YYYY-MM-DD"), key: "today" },
51
+ { label: "本周", start_time: moment().startOf("week").format("YYYY-MM-DD"), end_time: moment().endOf("week").format("YYYY-MM-DD"), key: "week" },
52
+ { label: "本月", start_time: moment().startOf("month").format("YYYY-MM-DD"), end_time: moment().endOf("month").format("YYYY-MM-DD"), key: "month" }
53
+ ],
54
+ active: ""
55
+ }
56
+ },
57
+
58
+ computed: {
59
+ dateOptions() {
60
+ return {
61
+ startPlaceholder: "开始时间",
62
+ endPlaceholder: "结束时间",
63
+ type: "daterange",
64
+ rangeSeparator: "至",
65
+ size: "mini",
66
+ active: "",
67
+ ...this.otherOption
68
+ }
69
+ }
70
+ },
71
+
72
+ watch: {
73
+ value: {
74
+ handler(newValue, oldValue) {
75
+ if (newValue && newValue.length) {
76
+ this.active = ""
77
+ this.shortcuts.forEach(item => {
78
+ if (item.start_time === newValue[0] && item.end_time === newValue[1]) {
79
+ this.active = item.key
80
+ }
81
+ })
82
+ } else {
83
+ this.active = this.dateOptions.active
84
+ const item = this.shortcuts.find(item => item.key === this.dateOptions.active) || {}
85
+ if (item.start_time && item.end_time) {
86
+ this.handleClick(item)
87
+ }
88
+ }
89
+ },
90
+ immediate: true
91
+ }
92
+ },
93
+
94
+ methods: {
95
+ handleChange(e) {
96
+ if (!e) {
97
+ this.$emit("input", [])
98
+ } else {
99
+ this.$emit("input", e.map(item => moment(item).format("YYYY-MM-DD")))
100
+ }
101
+ this.active = ""
102
+ },
103
+ handleClick(item) {
104
+ this.active = item.key
105
+ this.$emit("input", [item.start_time, item.end_time])
106
+ }
107
+ }
108
+ }
109
+ </script>
@@ -1,78 +1,78 @@
1
- <template>
2
- <div class="b-picker wrapper">
3
- <el-date-picker
4
- style="width: 70%"
5
- v-model="value[config.field]"
6
- :start-placeholder="config.startPlaceholder || '开始时间'"
7
- :end-placeholder="config.endPlaceholder || '结束时间'"
8
- :range-separator="config.rangeSeparator || '-'"
9
- :size="config.size || 'mini'"
10
- type= "daterange"
11
- @input="handleChange"
12
- />
13
- <div class="btn">
14
- <span
15
- v-for="item in shortcuts"
16
- :key="item.key"
17
- class="item"
18
- :class="{ item_active: item.key === active }"
19
- @click="handleClick(item)"
20
- >
21
- {{ item.label }}
22
- </span>
23
- </div>
24
- </div>
25
- </template>
26
-
27
- <script>
28
- import moment from "moment"
29
- export default {
30
- name: 'ByDatePickerRange',
31
- props: {
32
- //绑定的表单数据
33
- value: {
34
- type: Object,
35
- default: null
36
- },
37
- //当前配置
38
- config: {
39
- type: Object,
40
- default: null
41
- }
42
- },
43
- data() {
44
- return {
45
- shortcuts: [
46
- { label: "上月", start_time: moment().subtract(1, "months").startOf("month").format("YYYY-MM-DD"), end_time: moment().subtract(1, "months").endOf("month").format("YYYY-MM-DD"), key: "last_month" },
47
- { label: "昨天", start_time: moment().subtract(1, "days").format("YYYY-MM-DD"), end_time: moment().subtract(1, "days").format("YYYY-MM-DD"), key: "yesterday" },
48
- { label: "今天", start_time: moment().startOf("day").format("YYYY-MM-DD"), end_time: moment().startOf("day").format("YYYY-MM-DD"), key: "today" },
49
- { label: "本周", start_time: moment().startOf("week").format("YYYY-MM-DD"), end_time: moment().endOf("week").format("YYYY-MM-DD"), key: "week" },
50
- { label: "本月", start_time: moment().startOf("month").format("YYYY-MM-DD"), end_time: moment().endOf("month").format("YYYY-MM-DD"), key: "month" }
51
- ],
52
- active: ""
53
- }
54
- },
55
- mounted() {
56
- this.active = this.config.active || 'today'
57
- const item = this.shortcuts.find(item => item.key === this.active) || {}
58
- if (item.start_time && item.end_time) {
59
- this.handleClick(item)
60
- }
61
- },
62
- methods: {
63
- handleChange(e) {
64
- if (!e) {
65
- this.$emit("input", [])
66
- } else {
67
- this.$emit("input", e.map(item => moment(item).format("YYYY-MM-DD")))
68
- }
69
- this.active = ""
70
- },
71
- handleClick(item) {
72
- this.active = item.key
73
- this.value[this.config.field] = [item.start_time, item.end_time]
74
- this.$emit("input", [item.start_time, item.end_time])
75
- }
76
- }
77
- }
78
- </script>
1
+ <template>
2
+ <div class="b-picker wrapper">
3
+ <el-date-picker
4
+ style="width: 70%"
5
+ v-model="value[config.field]"
6
+ :start-placeholder="config.startPlaceholder || '开始时间'"
7
+ :end-placeholder="config.endPlaceholder || '结束时间'"
8
+ :range-separator="config.rangeSeparator || '-'"
9
+ :size="config.size || 'mini'"
10
+ type= "daterange"
11
+ @input="handleChange"
12
+ />
13
+ <div class="btn">
14
+ <span
15
+ v-for="item in shortcuts"
16
+ :key="item.key"
17
+ class="item"
18
+ :class="{ item_active: item.key === active }"
19
+ @click="handleClick(item)"
20
+ >
21
+ {{ item.label }}
22
+ </span>
23
+ </div>
24
+ </div>
25
+ </template>
26
+
27
+ <script>
28
+ import moment from "moment"
29
+ export default {
30
+ name: 'ByDatePickerRange',
31
+ props: {
32
+ //绑定的表单数据
33
+ value: {
34
+ type: Object,
35
+ default: null
36
+ },
37
+ //当前配置
38
+ config: {
39
+ type: Object,
40
+ default: null
41
+ }
42
+ },
43
+ data() {
44
+ return {
45
+ shortcuts: [
46
+ { label: "上月", start_time: moment().subtract(1, "months").startOf("month").format("YYYY-MM-DD"), end_time: moment().subtract(1, "months").endOf("month").format("YYYY-MM-DD"), key: "last_month" },
47
+ { label: "昨天", start_time: moment().subtract(1, "days").format("YYYY-MM-DD"), end_time: moment().subtract(1, "days").format("YYYY-MM-DD"), key: "yesterday" },
48
+ { label: "今天", start_time: moment().startOf("day").format("YYYY-MM-DD"), end_time: moment().startOf("day").format("YYYY-MM-DD"), key: "today" },
49
+ { label: "本周", start_time: moment().startOf("week").format("YYYY-MM-DD"), end_time: moment().endOf("week").format("YYYY-MM-DD"), key: "week" },
50
+ { label: "本月", start_time: moment().startOf("month").format("YYYY-MM-DD"), end_time: moment().endOf("month").format("YYYY-MM-DD"), key: "month" }
51
+ ],
52
+ active: ""
53
+ }
54
+ },
55
+ mounted() {
56
+ this.active = this.config.active || 'today'
57
+ const item = this.shortcuts.find(item => item.key === this.active) || {}
58
+ if (item.start_time && item.end_time) {
59
+ this.handleClick(item)
60
+ }
61
+ },
62
+ methods: {
63
+ handleChange(e) {
64
+ if (!e) {
65
+ this.$emit("input", [])
66
+ } else {
67
+ this.$emit("input", e.map(item => moment(item).format("YYYY-MM-DD")))
68
+ }
69
+ this.active = ""
70
+ },
71
+ handleClick(item) {
72
+ this.active = item.key
73
+ this.value[this.config.field] = [item.start_time, item.end_time]
74
+ this.$emit("input", [item.start_time, item.end_time])
75
+ }
76
+ }
77
+ }
78
+ </script>
@@ -1,67 +1,67 @@
1
- <template>
2
- <div class="w-full flex">
3
- <el-input class="w-1/2" :value="value[0]" :placeholder="earliestPlaceholder" @input="(value) => handleInput(value, 'min')" @blur="(e) => handleBlur(+e.target.value, 'min')" />
4
- <span>~</span>
5
- <el-input class="w-1/2" :value="value[1]" :placeholder="latestPlaceholder" @input="(value) => handleInput(value, 'max')" @blur="(e) => handleBlur(+e.target.value, 'max')" />
6
- </div>
7
- </template>
8
-
9
- <script>
10
- export default {
11
- props: {
12
- value: {
13
- type: Array,
14
- required: true,
15
- default: () => ["", 0]
16
- },
17
- earliestPlaceholder: {
18
- type: String,
19
- default: ""
20
- },
21
- latestPlaceholder: {
22
- type: String,
23
- default: ""
24
- }
25
- },
26
-
27
- methods: {
28
- /**
29
- * 输入框输入回调,将其转换为数字,并反馈到父组件
30
- * @param { string } val 输入框的value值
31
- * @param { string } type 输入框的类型 min | max
32
- */
33
- handleInput(val, type) {
34
- if (type === "min") {
35
- const values = [val.replace(/\D+/, ""), this.value[1]]
36
-
37
- this.$emit("input", values)
38
- } else if (type === "max") {
39
- const values = [this.value[0], val.replace(/\D+/, "")]
40
-
41
- this.$emit("input", values)
42
- }
43
- },
44
-
45
- /**
46
- * 输入框失去焦点回调,判断最小输入框是否大于最大输入框和最大输入框小于最小输入框,并反馈到父组件
47
- * @param { number } val 输入框的value值
48
- * @param { string } type 输入框的类型 min | max
49
- */
50
- handleBlur(val, type) {
51
- if (type === "min") {
52
- if (val > this.value[1]) {
53
- const values = [this.value[1], this.value[1]]
54
-
55
- this.$emit("input", values)
56
- }
57
- } else if (type === "max") {
58
- if (val < this.value[0]) {
59
- const values = [this.value[0], this.value[0]]
60
-
61
- this.$emit("input", values)
62
- }
63
- }
64
- }
65
- }
66
- }
67
- </script>
1
+ <template>
2
+ <div class="w-full flex">
3
+ <el-input class="w-1/2" :value="value[0]" :placeholder="earliestPlaceholder" @input="(value) => handleInput(value, 'min')" @blur="(e) => handleBlur(+e.target.value, 'min')" />
4
+ <span>~</span>
5
+ <el-input class="w-1/2" :value="value[1]" :placeholder="latestPlaceholder" @input="(value) => handleInput(value, 'max')" @blur="(e) => handleBlur(+e.target.value, 'max')" />
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ export default {
11
+ props: {
12
+ value: {
13
+ type: Array,
14
+ required: true,
15
+ default: () => ["", 0]
16
+ },
17
+ earliestPlaceholder: {
18
+ type: String,
19
+ default: ""
20
+ },
21
+ latestPlaceholder: {
22
+ type: String,
23
+ default: ""
24
+ }
25
+ },
26
+
27
+ methods: {
28
+ /**
29
+ * 输入框输入回调,将其转换为数字,并反馈到父组件
30
+ * @param { string } val 输入框的value值
31
+ * @param { string } type 输入框的类型 min | max
32
+ */
33
+ handleInput(val, type) {
34
+ if (type === "min") {
35
+ const values = [val.replace(/\D+/, ""), this.value[1]]
36
+
37
+ this.$emit("input", values)
38
+ } else if (type === "max") {
39
+ const values = [this.value[0], val.replace(/\D+/, "")]
40
+
41
+ this.$emit("input", values)
42
+ }
43
+ },
44
+
45
+ /**
46
+ * 输入框失去焦点回调,判断最小输入框是否大于最大输入框和最大输入框小于最小输入框,并反馈到父组件
47
+ * @param { number } val 输入框的value值
48
+ * @param { string } type 输入框的类型 min | max
49
+ */
50
+ handleBlur(val, type) {
51
+ if (type === "min") {
52
+ if (val > this.value[1]) {
53
+ const values = [this.value[1], this.value[1]]
54
+
55
+ this.$emit("input", values)
56
+ }
57
+ } else if (type === "max") {
58
+ if (val < this.value[0]) {
59
+ const values = [this.value[0], this.value[0]]
60
+
61
+ this.$emit("input", values)
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ </script>