sh-view 2.0.7 → 2.1.0
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 +2 -2
- package/packages/assets/css/main.scss +2 -50
- package/packages/assets/css/theme.scss +35 -16
- package/packages/components/global-components/sh-drawer/index.vue +7 -1
- package/packages/components/other-components/sh-cron-modal/components/cron-content.vue +283 -287
- package/packages/components/other-components/sh-menu/index.vue +2 -0
- package/packages/components/other-components/sh-menu/menu-item-content.vue +61 -61
- package/packages/components/other-components/sh-menu-card/index.vue +19 -3
- package/packages/components/other-components/sh-menu-card/menu-box.vue +81 -68
- package/packages/components/other-components/sh-system-tip/index.vue +111 -113
- package/packages/vxeTable/css/index.scss +27 -0
- package/packages/vxeTable/render/cell/vxe-render-input.vue +35 -7
- package/packages/vxeTable/render/mixin/cell-mixin.js +195 -195
|
@@ -1,287 +1,283 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="sh-cron-content">
|
|
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
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
50
|
-
import
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
type:
|
|
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
|
-
{ title: '
|
|
99
|
-
{ title: '
|
|
100
|
-
{ title: '
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
{
|
|
120
|
-
{
|
|
121
|
-
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
result.push(
|
|
141
|
-
result.push(
|
|
142
|
-
result.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
this.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
let
|
|
180
|
-
if (!
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
if (values.length > i) this.
|
|
186
|
-
if (values.length > i) this.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
this.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
this.
|
|
269
|
-
this.
|
|
270
|
-
this.
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
this.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
this
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
</script>
|
|
286
|
-
|
|
287
|
-
<style scoped></style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="sh-cron-content">
|
|
3
|
+
<sh-tabs v-model="activeKey" size="small" :options="cronTabList" :is-content="false"></sh-tabs>
|
|
4
|
+
<template v-if="activeKey === 'second'">
|
|
5
|
+
<cronSecondBox v-model="second" :disabled="disabled" />
|
|
6
|
+
</template>
|
|
7
|
+
<template v-else-if="activeKey === 'minute'">
|
|
8
|
+
<cronMinuteBox v-model="minute" :disabled="disabled" />
|
|
9
|
+
</template>
|
|
10
|
+
<template v-else-if="activeKey === 'hour'">
|
|
11
|
+
<cronHourBox v-model="hour" :disabled="disabled" />
|
|
12
|
+
</template>
|
|
13
|
+
<template v-else-if="activeKey === 'day'">
|
|
14
|
+
<cronDayBox v-model="day" :week="week" :disabled="disabled" />
|
|
15
|
+
</template>
|
|
16
|
+
<template v-else-if="activeKey === 'month'">
|
|
17
|
+
<cronMonthBox v-model="month" :disabled="disabled" />
|
|
18
|
+
</template>
|
|
19
|
+
<template v-else-if="activeKey === 'week'">
|
|
20
|
+
<cronWeekBox v-model="week" :day="day" :disabled="disabled" />
|
|
21
|
+
</template>
|
|
22
|
+
<template v-else-if="activeKey === 'year'">
|
|
23
|
+
<cronYearBox v-model="year" :disabled="disabled" />
|
|
24
|
+
</template>
|
|
25
|
+
<!-- 执行时间预览 -->
|
|
26
|
+
<vxe-grid v-bind="tableConfig" @edit-closed="onTableEditClosed" @header-cell-click="onTableHeaderClick">
|
|
27
|
+
<template #bottom>
|
|
28
|
+
<!-- cron错误提示 -->
|
|
29
|
+
<sh-alert v-if="errMessage" type="error" show-icon>
|
|
30
|
+
<span>表达式错误,请检查</span>
|
|
31
|
+
<template #desc>{{ errMessage }}</template>
|
|
32
|
+
</sh-alert>
|
|
33
|
+
<template v-else>
|
|
34
|
+
<div class="cron-title">近十次执行时间(不含年)</div>
|
|
35
|
+
<vxe-textarea v-model="preTimeList" :rows="5" disabled />
|
|
36
|
+
</template>
|
|
37
|
+
</template>
|
|
38
|
+
</vxe-grid>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script>
|
|
43
|
+
import cronSecondBox from '../tabs/cron-second-box.vue'
|
|
44
|
+
import cronMinuteBox from '../tabs/cron-minute-box.vue'
|
|
45
|
+
import cronHourBox from '../tabs/cron-hour-box.vue'
|
|
46
|
+
import cronDayBox from '../tabs/cron-day-box.vue'
|
|
47
|
+
import cronMonthBox from '../tabs/cron-month-box.vue'
|
|
48
|
+
import cronWeekBox from '../tabs/cron-week-box.vue'
|
|
49
|
+
import cronYearBox from '../tabs/cron-year-box.vue'
|
|
50
|
+
import cronUtils from '../utils'
|
|
51
|
+
export default {
|
|
52
|
+
name: 'CronContent',
|
|
53
|
+
components: {
|
|
54
|
+
cronSecondBox,
|
|
55
|
+
cronMinuteBox,
|
|
56
|
+
cronHourBox,
|
|
57
|
+
cronDayBox,
|
|
58
|
+
cronMonthBox,
|
|
59
|
+
cronWeekBox,
|
|
60
|
+
cronYearBox
|
|
61
|
+
},
|
|
62
|
+
props: {
|
|
63
|
+
modelValue: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: ''
|
|
66
|
+
},
|
|
67
|
+
disabled: {
|
|
68
|
+
type: Boolean
|
|
69
|
+
},
|
|
70
|
+
hideSecond: {
|
|
71
|
+
type: Boolean
|
|
72
|
+
},
|
|
73
|
+
hideYear: {
|
|
74
|
+
type: Boolean
|
|
75
|
+
},
|
|
76
|
+
remote: {
|
|
77
|
+
type: Function
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
emits: ['update:modelValue', 'change'],
|
|
81
|
+
data() {
|
|
82
|
+
return {
|
|
83
|
+
activeKey: this.hideSecond ? 'minute' : 'second',
|
|
84
|
+
second: '*',
|
|
85
|
+
minute: '*',
|
|
86
|
+
hour: '*',
|
|
87
|
+
day: '*',
|
|
88
|
+
month: '*',
|
|
89
|
+
week: '?',
|
|
90
|
+
year: '*',
|
|
91
|
+
tableConfig: {
|
|
92
|
+
align: 'center',
|
|
93
|
+
columns: [
|
|
94
|
+
{ title: '秒', field: 'second', editRender: { name: '$input' } },
|
|
95
|
+
{ title: '分', field: 'minute', editRender: { name: '$input' } },
|
|
96
|
+
{ title: '时', field: 'hour', editRender: { name: '$input' } },
|
|
97
|
+
{ title: '日', field: 'day', editRender: { name: '$input' } },
|
|
98
|
+
{ title: '月', field: 'month', editRender: { name: '$input' } },
|
|
99
|
+
{ title: '周', field: 'week', editRender: { name: '$input' } },
|
|
100
|
+
{ title: '年', field: 'year', editRender: { name: '$input' } }
|
|
101
|
+
],
|
|
102
|
+
data: [],
|
|
103
|
+
editConfig: {
|
|
104
|
+
enable: !this.disabled
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
preTimeList: '执行预览,会忽略年份参数。',
|
|
108
|
+
errMessage: '',
|
|
109
|
+
calTriggerList: this.$vUtils.debounce(this.calTriggerListInner, 500)
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
computed: {
|
|
113
|
+
cronTabList() {
|
|
114
|
+
let list = [
|
|
115
|
+
{ value: 'second', label: '秒' },
|
|
116
|
+
{ value: 'minute', label: '分' },
|
|
117
|
+
{ value: 'hour', label: '时' },
|
|
118
|
+
{ value: 'day', label: '日' },
|
|
119
|
+
{ value: 'month', label: '月' },
|
|
120
|
+
{ value: 'week', label: '周' },
|
|
121
|
+
{ value: 'year', label: '年' }
|
|
122
|
+
]
|
|
123
|
+
if (this.hideSecond) {
|
|
124
|
+
list = list.filter(item => !['second', 'year'].includes(item.value))
|
|
125
|
+
} else if (this.hideYear) {
|
|
126
|
+
list = list.filter(item => !['year'].includes(item.value))
|
|
127
|
+
}
|
|
128
|
+
return list
|
|
129
|
+
},
|
|
130
|
+
cronValueInner() {
|
|
131
|
+
let { hideSecond, hideYear, second, minute, hour, day, month, week, year } = this
|
|
132
|
+
let result = []
|
|
133
|
+
if (!hideSecond) {
|
|
134
|
+
result.push(second ? second : '*')
|
|
135
|
+
}
|
|
136
|
+
result.push(minute ? minute : '*')
|
|
137
|
+
result.push(hour ? hour : '*')
|
|
138
|
+
result.push(day ? day : '*')
|
|
139
|
+
result.push(month ? month : '*')
|
|
140
|
+
result.push(week ? week : '?')
|
|
141
|
+
if (!hideYear && !hideSecond) result.push(year ? year : '*')
|
|
142
|
+
return result.join(' ')
|
|
143
|
+
},
|
|
144
|
+
cronValueNoYear() {
|
|
145
|
+
const v = this.cronValueInner
|
|
146
|
+
if (this.hideYear || this.hideSecond) return v
|
|
147
|
+
const vs = v.split(' ')
|
|
148
|
+
if (vs.length >= 6) {
|
|
149
|
+
// 转成 Quartz 的规则
|
|
150
|
+
vs[5] = this.convertWeekToQuartz(vs[5])
|
|
151
|
+
}
|
|
152
|
+
return vs.slice(0, vs.length - 1).join(' ')
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
watch: {
|
|
156
|
+
modelValue(nv) {
|
|
157
|
+
if (nv === this.cronValueInner) {
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
this.formatValue()
|
|
161
|
+
},
|
|
162
|
+
cronValueInner(nv) {
|
|
163
|
+
this.calTriggerList()
|
|
164
|
+
this.emitValue(nv)
|
|
165
|
+
this.assignTable()
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
created() {
|
|
169
|
+
this.assignTable()
|
|
170
|
+
this.formatValue()
|
|
171
|
+
this.calTriggerListInner()
|
|
172
|
+
},
|
|
173
|
+
methods: {
|
|
174
|
+
formatValue() {
|
|
175
|
+
let { modelValue, hideSecond } = this
|
|
176
|
+
if (!modelValue) return
|
|
177
|
+
const values = modelValue.split(' ').filter(item => !!item)
|
|
178
|
+
if (!values || values.length <= 0) return
|
|
179
|
+
let i = 0
|
|
180
|
+
if (!hideSecond) this.second = values[i++]
|
|
181
|
+
if (values.length > i) this.minute = values[i++]
|
|
182
|
+
if (values.length > i) this.hour = values[i++]
|
|
183
|
+
if (values.length > i) this.day = values[i++]
|
|
184
|
+
if (values.length > i) this.month = values[i++]
|
|
185
|
+
if (values.length > i) this.week = values[i++]
|
|
186
|
+
if (values.length > i) this.year = values[i]
|
|
187
|
+
this.assignTable()
|
|
188
|
+
},
|
|
189
|
+
assignTable() {
|
|
190
|
+
this.tableConfig.data = [
|
|
191
|
+
{
|
|
192
|
+
second: this.second,
|
|
193
|
+
minute: this.minute,
|
|
194
|
+
hour: this.hour,
|
|
195
|
+
day: this.day,
|
|
196
|
+
month: this.month,
|
|
197
|
+
week: this.week,
|
|
198
|
+
year: this.year
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
calTriggerListInner() {
|
|
203
|
+
this.errMessage = ''
|
|
204
|
+
// 设置了回调函数
|
|
205
|
+
if (this.remote) {
|
|
206
|
+
this.remote(this.cronValueInner, +new Date(), v => {
|
|
207
|
+
this.preTimeList = v
|
|
208
|
+
})
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
const format = 'yyyy-MM-dd hh:mm:ss'
|
|
213
|
+
const options = {
|
|
214
|
+
currentDate: this.$vUtils.toDateString(new Date(), format)
|
|
215
|
+
}
|
|
216
|
+
const iter = cronUtils.parse(this.cronValueNoYear, options)
|
|
217
|
+
const result = []
|
|
218
|
+
for (let i = 1; i <= 10; i++) {
|
|
219
|
+
result.push(this.$vUtils.toDateString(new Date(iter.next()), format))
|
|
220
|
+
}
|
|
221
|
+
this.preTimeList = result.length > 0 ? result.join('\n') : '无执行时间'
|
|
222
|
+
} catch (e) {
|
|
223
|
+
this.errMessage = e
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
// Quartz 的规则:
|
|
227
|
+
// 1 = 周日,2 = 周一,3 = 周二,4 = 周三,5 = 周四,6 = 周五,7 = 周六
|
|
228
|
+
convertWeekToQuartz(week) {
|
|
229
|
+
let convert = v => {
|
|
230
|
+
if (v === '0') {
|
|
231
|
+
return '1'
|
|
232
|
+
}
|
|
233
|
+
if (v === '1') {
|
|
234
|
+
return '0'
|
|
235
|
+
}
|
|
236
|
+
return (Number.parseInt(v) - 1).toString()
|
|
237
|
+
}
|
|
238
|
+
// 匹配示例 1-7 or 1/7
|
|
239
|
+
let patten1 = /^([0-7])([-/])([0-7])$/
|
|
240
|
+
// 匹配示例 1,4,7
|
|
241
|
+
let patten2 = /^([0-7])(,[0-7])+$/
|
|
242
|
+
if (/^[0-7]$/.test(week)) {
|
|
243
|
+
return convert(week)
|
|
244
|
+
} else if (patten1.test(week)) {
|
|
245
|
+
return week.replace(patten1, ($0, before, separator, after) => {
|
|
246
|
+
if (separator === '/') {
|
|
247
|
+
return convert(before) + separator + after
|
|
248
|
+
} else {
|
|
249
|
+
return convert(before) + separator + convert(after)
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
} else if (patten2.test(week)) {
|
|
253
|
+
return week
|
|
254
|
+
.split(',')
|
|
255
|
+
.map(v => convert(v))
|
|
256
|
+
.join(',')
|
|
257
|
+
}
|
|
258
|
+
return week
|
|
259
|
+
},
|
|
260
|
+
onTableHeaderClick({ column }) {
|
|
261
|
+
this.activeKey = column.property
|
|
262
|
+
},
|
|
263
|
+
onTableEditClosed({ row, column }) {
|
|
264
|
+
this.second = row.second
|
|
265
|
+
this.minute = row.minute
|
|
266
|
+
this.hour = row.hour
|
|
267
|
+
this.day = row.day
|
|
268
|
+
this.month = row.month
|
|
269
|
+
this.week = row.week
|
|
270
|
+
this.year = row.year
|
|
271
|
+
},
|
|
272
|
+
onInputCronBlur(event) {
|
|
273
|
+
this.emitValue(event.target.value)
|
|
274
|
+
},
|
|
275
|
+
emitValue(value) {
|
|
276
|
+
this.$emit('change', value)
|
|
277
|
+
this.$emit('update:modelValue', value)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
</script>
|
|
282
|
+
|
|
283
|
+
<style scoped></style>
|