n20-common-lib 2.2.30 → 2.2.31
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.
- package/package.json +1 -1
- package/src/assets/css/cl-date-quarter.scss +10 -0
- package/src/components/SelectDatePickerPro/index.vue +44 -34
- package/src/components/SelectDatePickerPro/quarterDatePicker.vue +61 -4
- package/style/index.css +3 -3
- package/theme/blue.css +2 -2
- package/theme/cctcRed.css +2 -2
- package/theme/green.css +2 -2
- package/theme/lightBlue.css +2 -2
- package/theme/orange.css +2 -2
- package/theme/purple.css +2 -2
- package/theme/red.css +2 -2
- package/theme/yellow.css +2 -2
package/package.json
CHANGED
|
@@ -96,6 +96,16 @@
|
|
|
96
96
|
.n20-quarter-date-picker__btn {
|
|
97
97
|
color: var(--color-text-regular);
|
|
98
98
|
}
|
|
99
|
+
|
|
100
|
+
.n20-quarter-date-picker__btn.isactive {
|
|
101
|
+
color: var(--color-primary);
|
|
102
|
+
}
|
|
103
|
+
|
|
99
104
|
.n20-quarter-date-picker.el-popover {
|
|
100
105
|
padding: 0;
|
|
101
106
|
}
|
|
107
|
+
|
|
108
|
+
.el-button.el-button--text.is-disabled,
|
|
109
|
+
.el-button.el-button--text.is-disabled:hover {
|
|
110
|
+
color: #333;
|
|
111
|
+
}
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
value-format="yyyy-MM-dd"
|
|
14
14
|
type="daterange"
|
|
15
15
|
clearable
|
|
16
|
+
v-bind="$attrs"
|
|
16
17
|
:placeholder="'选择日' | $lc"
|
|
18
|
+
v-on="$listeners"
|
|
17
19
|
/>
|
|
18
20
|
<date-picker
|
|
19
21
|
v-if="type === '周' && selectList.includes(type)"
|
|
@@ -21,7 +23,7 @@
|
|
|
21
23
|
v-model="week"
|
|
22
24
|
format="yyyy 第 WW 周"
|
|
23
25
|
type="week"
|
|
24
|
-
:picker-options="
|
|
26
|
+
:picker-options="attrs"
|
|
25
27
|
:default-time="['00:00:00', '23:59:59']"
|
|
26
28
|
:placeholder="'选择周' | $lc"
|
|
27
29
|
/>
|
|
@@ -34,15 +36,22 @@
|
|
|
34
36
|
format="yyyy-MM"
|
|
35
37
|
value-format="yyyy-MM"
|
|
36
38
|
:editable="false"
|
|
39
|
+
v-bind="$attrs"
|
|
37
40
|
:placeholder="'选择月' | $lc"
|
|
38
41
|
/>
|
|
39
|
-
<quarter-date-picker
|
|
42
|
+
<quarter-date-picker
|
|
43
|
+
v-if="type === '季'"
|
|
44
|
+
key="quarter"
|
|
45
|
+
v-model="quarter"
|
|
46
|
+
:disabled-date="this.attrs.disabledDate"
|
|
47
|
+
/>
|
|
40
48
|
<date-picker
|
|
41
49
|
v-if="type === '年' && selectList.includes(type)"
|
|
42
50
|
key="year"
|
|
43
51
|
v-model="year"
|
|
44
52
|
type="year"
|
|
45
53
|
format="yyyy"
|
|
54
|
+
v-bind="$attrs"
|
|
46
55
|
value-format="yyyy"
|
|
47
56
|
:editable="false"
|
|
48
57
|
:placeholder="'选择年' | $lc"
|
|
@@ -51,7 +60,7 @@
|
|
|
51
60
|
</template>
|
|
52
61
|
|
|
53
62
|
<script>
|
|
54
|
-
// TODO:
|
|
63
|
+
// TODO: 双向绑定数值格式不统一
|
|
55
64
|
import datePicker from '../DatePicker/index.vue'
|
|
56
65
|
import quarterDatePicker from './quarterDatePicker'
|
|
57
66
|
import dayjs from 'dayjs'
|
|
@@ -89,6 +98,7 @@ export default {
|
|
|
89
98
|
}
|
|
90
99
|
},
|
|
91
100
|
data() {
|
|
101
|
+
this.attrs = Object.assign({ firstDayOfWeek: 1 }, this.$attrs['picker-options'])
|
|
92
102
|
return {}
|
|
93
103
|
},
|
|
94
104
|
computed: {
|
|
@@ -124,38 +134,38 @@ export default {
|
|
|
124
134
|
return this.value.startDate
|
|
125
135
|
},
|
|
126
136
|
set(value) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
if (value) {
|
|
138
|
+
let todayDay = value ? new Date(value) : new Date()
|
|
139
|
+
let todayOfWeek = todayDay.getDay()
|
|
140
|
+
let spendDay = 1
|
|
141
|
+
if (todayOfWeek !== 0) {
|
|
142
|
+
spendDay = 7 - todayOfWeek // 开始时间到结束时间还有几天
|
|
143
|
+
}
|
|
144
|
+
// 86400000为一天的毫秒数
|
|
145
|
+
let startTimeNum = todayDay.valueOf() - (6 - spendDay) * 86400000 // 开始时间时间戳
|
|
146
|
+
let endTimeNum = todayDay.valueOf() + spendDay * 86400000 // 结束时间时间戳
|
|
147
|
+
let startTimeStr = this.timestampToTime(startTimeNum) // 时间戳转字符串
|
|
148
|
+
let endTimeStr = this.timestampToTime(endTimeNum)
|
|
149
|
+
let weekTime = {
|
|
150
|
+
startDate: startTimeStr,
|
|
151
|
+
endDate: endTimeStr,
|
|
152
|
+
typeDate: this.value.typeDate
|
|
153
|
+
} // 选择的范围
|
|
144
154
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
this.$emit('input', weekTime)
|
|
156
|
+
this.$emit('change', weekTime)
|
|
157
|
+
} else {
|
|
158
|
+
this.$emit('input', {
|
|
159
|
+
startDate: '',
|
|
160
|
+
endDate: '',
|
|
161
|
+
typeDate: this.value.typeDate
|
|
162
|
+
})
|
|
163
|
+
this.$emit('change', {
|
|
164
|
+
startDate: '',
|
|
165
|
+
endDate: '',
|
|
166
|
+
typeDate: this.value.typeDate
|
|
167
|
+
})
|
|
168
|
+
}
|
|
159
169
|
}
|
|
160
170
|
},
|
|
161
171
|
month: {
|
|
@@ -27,16 +27,40 @@
|
|
|
27
27
|
|
|
28
28
|
<div class="el-picker-panel__content">
|
|
29
29
|
<div v-if="isQuarter" class="n20-quarter-date-picker__grid">
|
|
30
|
-
<el-button
|
|
30
|
+
<el-button
|
|
31
|
+
type="text"
|
|
32
|
+
:disabled="isDisabled(year, '1')"
|
|
33
|
+
size="medium"
|
|
34
|
+
class="n20-quarter-date-picker__btn"
|
|
35
|
+
:class="this.season == 1 ? 'isactive' : ''"
|
|
36
|
+
@click="selectSeason(0)"
|
|
31
37
|
>{{ year }}年 第一季度</el-button
|
|
32
38
|
>
|
|
33
|
-
<el-button
|
|
39
|
+
<el-button
|
|
40
|
+
type="text"
|
|
41
|
+
:disabled="isDisabled(year, '2')"
|
|
42
|
+
size="medium"
|
|
43
|
+
class="n20-quarter-date-picker__btn"
|
|
44
|
+
:class="this.season == 2 ? 'isactive' : ''"
|
|
45
|
+
@click="selectSeason(1)"
|
|
34
46
|
>{{ year }}年 第二季度</el-button
|
|
35
47
|
>
|
|
36
|
-
<el-button
|
|
48
|
+
<el-button
|
|
49
|
+
type="text"
|
|
50
|
+
:disabled="isDisabled(year, '3')"
|
|
51
|
+
size="medium"
|
|
52
|
+
class="n20-quarter-date-picker__btn"
|
|
53
|
+
:class="this.season == 3 ? 'isactive' : ''"
|
|
54
|
+
@click="selectSeason(2)"
|
|
37
55
|
>{{ year }}年 第三季度</el-button
|
|
38
56
|
>
|
|
39
|
-
<el-button
|
|
57
|
+
<el-button
|
|
58
|
+
:disabled="isDisabled(year, '4')"
|
|
59
|
+
type="text"
|
|
60
|
+
size="medium"
|
|
61
|
+
class="n20-quarter-date-picker__btn"
|
|
62
|
+
:class="this.season == 4 ? 'isactive' : ''"
|
|
63
|
+
@click="selectSeason(3)"
|
|
40
64
|
>{{ year }}年 第四季度</el-button
|
|
41
65
|
>
|
|
42
66
|
</div>
|
|
@@ -81,6 +105,10 @@ export default {
|
|
|
81
105
|
return {}
|
|
82
106
|
}
|
|
83
107
|
},
|
|
108
|
+
disabledDate: {
|
|
109
|
+
type: Function,
|
|
110
|
+
default: () => false
|
|
111
|
+
},
|
|
84
112
|
valueArr: {
|
|
85
113
|
default: () => {
|
|
86
114
|
return ['01-01 - 03-31', '04-01 - 06-30', '07-01 - 09-30', '10-01 - 12-31']
|
|
@@ -185,6 +213,35 @@ export default {
|
|
|
185
213
|
this.showValue = `${this.year} 年 ${this.season} 季度`
|
|
186
214
|
that.$emit('input', { startDate: this.year + '-' + arr[0], endDate: this.year + '-' + arr[1] })
|
|
187
215
|
that.$emit('change', { startDate: this.year + '-' + arr[0], endDate: this.year + '-' + arr[1] }) // 每次选择时间都将当前选择时间发送到父组件
|
|
216
|
+
},
|
|
217
|
+
isDisabled(year, type) {
|
|
218
|
+
let quarterDate
|
|
219
|
+
switch (type) {
|
|
220
|
+
case '1':
|
|
221
|
+
quarterDate = dayjs(year + '03')
|
|
222
|
+
.endOf('month')
|
|
223
|
+
.toDate()
|
|
224
|
+
break
|
|
225
|
+
case '2':
|
|
226
|
+
quarterDate = dayjs(year + '06')
|
|
227
|
+
.endOf('month')
|
|
228
|
+
.toDate()
|
|
229
|
+
break
|
|
230
|
+
case '3':
|
|
231
|
+
quarterDate = dayjs(year + '09')
|
|
232
|
+
.endOf('month')
|
|
233
|
+
.toDate()
|
|
234
|
+
break
|
|
235
|
+
case '4':
|
|
236
|
+
quarterDate = dayjs(year + '12')
|
|
237
|
+
.endOf('month')
|
|
238
|
+
.toDate()
|
|
239
|
+
break
|
|
240
|
+
}
|
|
241
|
+
if (this.disabledDate) {
|
|
242
|
+
return this.disabledDate(quarterDate)
|
|
243
|
+
}
|
|
244
|
+
return false
|
|
188
245
|
}
|
|
189
246
|
}
|
|
190
247
|
}
|