sh-view 2.1.0 → 2.3.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 +9 -13
- package/packages/components/global-components/sh-alert/index.vue +175 -173
- package/packages/components/global-components/sh-badge/index.vue +57 -43
- package/packages/components/global-components/sh-card/index.vue +24 -16
- package/packages/components/global-components/sh-code-editor/index.vue +250 -260
- package/packages/components/global-components/sh-col/index.vue +44 -36
- package/packages/components/global-components/sh-corner/index.vue +230 -228
- package/packages/components/global-components/sh-count-to/index.vue +60 -51
- package/packages/components/global-components/sh-drawer/index.vue +209 -182
- package/packages/components/global-components/sh-drawer/scrollbar.js +44 -42
- package/packages/components/global-components/sh-empty/index.vue +0 -1
- package/packages/components/global-components/sh-form/form.vue +110 -0
- package/packages/components/global-components/sh-form/js/props.js +76 -63
- package/packages/components/global-components/sh-form/js/useForm.js +236 -0
- package/packages/components/global-components/sh-form/query.vue +70 -0
- package/packages/components/global-components/sh-header/index.vue +35 -50
- package/packages/components/global-components/sh-icon/css/index.scss +44 -0
- package/packages/components/global-components/sh-icon/index.vue +24 -11
- package/packages/components/global-components/sh-image/index.vue +47 -38
- package/packages/components/global-components/sh-list/index.vue +42 -37
- package/packages/components/global-components/sh-loading/index.vue +12 -8
- package/packages/components/global-components/sh-modal/index.vue +49 -40
- package/packages/components/global-components/sh-noticebar/index.vue +68 -54
- package/packages/components/global-components/sh-poptip/index.vue +247 -130
- package/packages/components/global-components/sh-progress/index.vue +71 -69
- package/packages/components/global-components/sh-pull-refresh/index.vue +156 -157
- package/packages/components/global-components/sh-result/index.vue +37 -28
- package/packages/components/global-components/sh-row/index.vue +21 -18
- package/packages/components/global-components/sh-split/index.vue +115 -109
- package/packages/components/global-components/sh-table/components/importModal.vue +95 -86
- package/packages/components/global-components/sh-table/components/sh-column.vue +62 -0
- package/packages/components/global-components/sh-table/{index.vue → grid.vue} +34 -145
- package/packages/components/global-components/sh-table/js/tableMethods.js +175 -0
- package/packages/components/global-components/sh-table/js/useTable.js +592 -0
- package/packages/components/global-components/sh-table/table.vue +266 -0
- package/packages/components/global-components/sh-tabs/index.vue +118 -93
- package/packages/components/global-components/sh-tag/index.vue +52 -51
- package/packages/components/global-components/sh-toolbar/index.vue +53 -47
- package/packages/components/global-components/sh-tree/components/table-tree.vue +152 -139
- package/packages/components/global-components/sh-tree/index.vue +218 -195
- package/packages/components/global-components/sh-tree/mixin/treeProps.js +118 -120
- package/packages/components/global-components/sh-upload/index.vue +308 -51
- package/packages/components/global-components/sh-water-fall/index.vue +4 -11
- package/packages/components/index.js +5 -3
- package/packages/components/other-components/sh-cron-modal/components/cron-content.vue +140 -129
- package/packages/components/other-components/sh-cron-modal/css/index.scss +0 -5
- package/packages/components/other-components/sh-cron-modal/index.vue +81 -67
- package/packages/components/other-components/sh-cron-modal/mixin/cron-emits.js +1 -0
- package/packages/components/other-components/sh-cron-modal/mixin/cron-hooks.js +179 -0
- package/packages/components/other-components/sh-cron-modal/mixin/cron-props.js +9 -0
- package/packages/components/other-components/sh-cron-modal/tabs/cron-day-box.vue +101 -92
- package/packages/components/other-components/sh-cron-modal/tabs/cron-hour-box.vue +68 -56
- package/packages/components/other-components/sh-cron-modal/tabs/cron-minute-box.vue +68 -56
- package/packages/components/other-components/sh-cron-modal/tabs/cron-month-box.vue +68 -56
- package/packages/components/other-components/sh-cron-modal/tabs/cron-second-box.vue +68 -56
- package/packages/components/other-components/sh-cron-modal/tabs/cron-week-box.vue +126 -115
- package/packages/components/other-components/sh-cron-modal/tabs/cron-year-box.vue +59 -46
- package/packages/components/other-components/sh-menu/index.vue +73 -60
- package/packages/components/other-components/sh-menu/menu-group-content.vue +71 -59
- package/packages/components/other-components/sh-menu/menu-item-content.vue +40 -30
- package/packages/components/other-components/sh-menu-card/index.vue +70 -64
- package/packages/components/other-components/sh-menu-card/menu-box.vue +50 -44
- package/packages/components/other-components/sh-preview/components/sh-excel.vue +182 -0
- package/packages/components/other-components/sh-preview/components/sh-word.vue +73 -0
- package/packages/components/other-components/sh-preview/index.vue +86 -85
- package/packages/components/other-components/sh-preview/js/data-hook.js +37 -0
- package/packages/components/other-components/sh-preview/js/data-props.js +11 -0
- package/packages/components/other-components/sh-system-tip/index.vue +28 -24
- package/packages/css/index.js +4 -4
- package/packages/directive/module/prevent-click.js +1 -1
- package/packages/directive/module/resize.js +11 -154
- package/packages/index.js +39 -39
- package/packages/mixin/index.js +86 -87
- package/packages/vxeTable/render/cell/vxe-render-checkbox.vue +14 -5
- package/packages/vxeTable/render/cell/vxe-render-checkgroup.vue +43 -36
- package/packages/vxeTable/render/cell/vxe-render-code.vue +14 -5
- package/packages/vxeTable/render/cell/vxe-render-goption.vue +34 -24
- package/packages/vxeTable/render/cell/vxe-render-href.vue +21 -11
- package/packages/vxeTable/render/cell/vxe-render-img.vue +16 -10
- package/packages/vxeTable/render/cell/vxe-render-input.vue +83 -79
- package/packages/vxeTable/render/cell/vxe-render-money.vue +14 -6
- package/packages/vxeTable/render/cell/vxe-render-progress.vue +28 -19
- package/packages/vxeTable/render/cell/vxe-render-radio.vue +14 -5
- package/packages/vxeTable/render/cell/vxe-render-radiogroup.vue +43 -36
- package/packages/vxeTable/render/cell/vxe-render-select.vue +44 -36
- package/packages/vxeTable/render/cell/vxe-render-switch.vue +14 -5
- package/packages/vxeTable/render/cell/vxe-render-table.vue +51 -78
- package/packages/vxeTable/render/cell/vxe-render-textarea.vue +14 -5
- package/packages/vxeTable/render/cell/vxe-render-time.vue +23 -13
- package/packages/vxeTable/render/cell/vxe-render-tree.vue +23 -27
- package/packages/vxeTable/render/cell/vxe-render-upload.vue +11 -7
- package/packages/vxeTable/render/filters/vxe-filter-input.vue +25 -43
- package/packages/vxeTable/render/footer/vxe-footer-input.vue +23 -13
- package/packages/vxeTable/render/footer/vxe-footer-money.vue +30 -20
- package/packages/vxeTable/render/globalRenders.jsx +1 -1
- package/packages/vxeTable/render/header/vxe-header-money.vue +31 -21
- package/packages/vxeTable/render/mixin/cell-hooks.js +162 -0
- package/packages/vxeTable/render/mixin/cell-props.js +23 -0
- package/packages/vxeTable/render/mixin/filter-hooks.js +28 -0
- package/packages/components/global-components/sh-form/components/form-item.vue +0 -25
- package/packages/components/global-components/sh-form/css/index.scss +0 -55
- package/packages/components/global-components/sh-form/index.vue +0 -114
- package/packages/components/global-components/sh-form/js/methods.js +0 -146
- package/packages/components/global-components/sh-form/mixin/defaultData.js +0 -32
- package/packages/components/global-components/sh-icon/css/default/index.scss +0 -27
- package/packages/components/global-components/sh-icon/css/font/index.scss +0 -16
- package/packages/components/global-components/sh-icon/icon-default.vue +0 -32
- package/packages/components/global-components/sh-icon/icon-font.vue +0 -32
- package/packages/components/global-components/sh-poptip/popper.js +0 -115
- package/packages/components/global-components/sh-query/index.vue +0 -317
- package/packages/components/global-components/sh-table/js/methods.js +0 -549
- package/packages/components/global-components/sh-table/mixin/defaultData.js +0 -94
- package/packages/components/global-components/sh-upload/js/mixin.js +0 -257
- package/packages/components/other-components/sh-cron-modal/mixin/cron-box.js +0 -169
- package/packages/vxeTable/render/mixin/cell-mixin.js +0 -195
- /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.svg → ionicons.svg} +0 -0
- /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.ttf → ionicons.ttf} +0 -0
- /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.woff → ionicons.woff} +0 -0
- /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.woff2 → ionicons.woff2} +0 -0
- /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.js → iconfont.js} +0 -0
- /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.json → iconfont.json} +0 -0
- /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.ttf → iconfont.ttf} +0 -0
- /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.woff → iconfont.woff} +0 -0
- /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.woff2 → iconfont.woff2} +0 -0
- /package/packages/{assets/css → css}/animated.scss +0 -0
- /package/packages/{assets/css → css}/loader.scss +0 -0
- /package/packages/{assets/css → css}/main.scss +0 -0
- /package/packages/{assets/css → css}/theme.scss +0 -0
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
</template>
|
|
41
41
|
|
|
42
42
|
<script>
|
|
43
|
+
import { defineComponent, computed, getCurrentInstance, ref, reactive, watch, onBeforeMount } from 'vue'
|
|
43
44
|
import cronSecondBox from '../tabs/cron-second-box.vue'
|
|
44
45
|
import cronMinuteBox from '../tabs/cron-minute-box.vue'
|
|
45
46
|
import cronHourBox from '../tabs/cron-hour-box.vue'
|
|
@@ -48,7 +49,7 @@ import cronMonthBox from '../tabs/cron-month-box.vue'
|
|
|
48
49
|
import cronWeekBox from '../tabs/cron-week-box.vue'
|
|
49
50
|
import cronYearBox from '../tabs/cron-year-box.vue'
|
|
50
51
|
import cronUtils from '../utils'
|
|
51
|
-
export default {
|
|
52
|
+
export default defineComponent({
|
|
52
53
|
name: 'CronContent',
|
|
53
54
|
components: {
|
|
54
55
|
cronSecondBox,
|
|
@@ -78,39 +79,39 @@ export default {
|
|
|
78
79
|
}
|
|
79
80
|
},
|
|
80
81
|
emits: ['update:modelValue', 'change'],
|
|
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
|
-
cronTabList() {
|
|
82
|
+
setup(props, context) {
|
|
83
|
+
const { proxy } = getCurrentInstance()
|
|
84
|
+
const { $vUtils } = proxy
|
|
85
|
+
const { emit, slots } = context
|
|
86
|
+
|
|
87
|
+
const activeKey = ref(props.hideSecond ? 'minute' : 'second')
|
|
88
|
+
const second = ref('*')
|
|
89
|
+
const minute = ref('*')
|
|
90
|
+
const hour = ref('*')
|
|
91
|
+
const day = ref('*')
|
|
92
|
+
const month = ref('*')
|
|
93
|
+
const week = ref('*')
|
|
94
|
+
const year = ref('*')
|
|
95
|
+
const tableConfig = reactive({
|
|
96
|
+
align: 'center',
|
|
97
|
+
columns: [
|
|
98
|
+
{ title: '秒', field: 'second', editRender: { name: '$input' } },
|
|
99
|
+
{ title: '分', field: 'minute', editRender: { name: '$input' } },
|
|
100
|
+
{ title: '时', field: 'hour', editRender: { name: '$input' } },
|
|
101
|
+
{ title: '日', field: 'day', editRender: { name: '$input' } },
|
|
102
|
+
{ title: '月', field: 'month', editRender: { name: '$input' } },
|
|
103
|
+
{ title: '周', field: 'week', editRender: { name: '$input' } },
|
|
104
|
+
{ title: '年', field: 'year', editRender: { name: '$input' } }
|
|
105
|
+
],
|
|
106
|
+
data: [],
|
|
107
|
+
editConfig: {
|
|
108
|
+
enable: !props.disabled
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
const preTimeList = ref('执行预览,会忽略年份参数。')
|
|
112
|
+
const errMessage = ref('')
|
|
113
|
+
|
|
114
|
+
const cronTabList = computed(() => {
|
|
114
115
|
let list = [
|
|
115
116
|
{ value: 'second', label: '秒' },
|
|
116
117
|
{ value: 'minute', label: '分' },
|
|
@@ -120,112 +121,82 @@ export default {
|
|
|
120
121
|
{ value: 'week', label: '周' },
|
|
121
122
|
{ value: 'year', label: '年' }
|
|
122
123
|
]
|
|
123
|
-
if (
|
|
124
|
+
if (props.hideSecond) {
|
|
124
125
|
list = list.filter(item => !['second', 'year'].includes(item.value))
|
|
125
|
-
} else if (
|
|
126
|
+
} else if (props.hideYear) {
|
|
126
127
|
list = list.filter(item => !['year'].includes(item.value))
|
|
127
128
|
}
|
|
128
129
|
return list
|
|
129
|
-
}
|
|
130
|
-
cronValueInner() {
|
|
131
|
-
let { hideSecond, hideYear, second, minute, hour, day, month, week, year } = this
|
|
130
|
+
})
|
|
131
|
+
const cronValueInner = computed(() => {
|
|
132
132
|
let result = []
|
|
133
|
-
if (!hideSecond) {
|
|
134
|
-
result.push(second
|
|
133
|
+
if (!props.hideSecond) {
|
|
134
|
+
result.push(second.value || '*')
|
|
135
135
|
}
|
|
136
|
-
result.push(minute
|
|
137
|
-
result.push(hour
|
|
138
|
-
result.push(day
|
|
139
|
-
result.push(month
|
|
140
|
-
result.push(week
|
|
141
|
-
if (!hideYear && !hideSecond) result.push(year
|
|
136
|
+
result.push(minute.value || '*')
|
|
137
|
+
result.push(hour.value || '*')
|
|
138
|
+
result.push(day.value || '*')
|
|
139
|
+
result.push(month.value || '*')
|
|
140
|
+
result.push(week.value || '?')
|
|
141
|
+
if (!props.hideYear && !props.hideSecond) result.push(year.value || '*')
|
|
142
142
|
return result.join(' ')
|
|
143
|
-
}
|
|
144
|
-
cronValueNoYear() {
|
|
145
|
-
const v =
|
|
146
|
-
if (
|
|
143
|
+
})
|
|
144
|
+
const cronValueNoYear = computed(() => {
|
|
145
|
+
const v = cronValueInner.value
|
|
146
|
+
if (props.hideYear || props.hideSecond) return v
|
|
147
147
|
const vs = v.split(' ')
|
|
148
148
|
if (vs.length >= 6) {
|
|
149
149
|
// 转成 Quartz 的规则
|
|
150
|
-
vs[5] =
|
|
150
|
+
vs[5] = convertWeekToQuartz(vs[5])
|
|
151
151
|
}
|
|
152
152
|
return vs.slice(0, vs.length - 1).join(' ')
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
const formatValue = () => {
|
|
156
|
+
let { modelValue, hideSecond } = props
|
|
176
157
|
if (!modelValue) return
|
|
177
158
|
const values = modelValue.split(' ').filter(item => !!item)
|
|
178
159
|
if (!values || values.length <= 0) return
|
|
179
160
|
let i = 0
|
|
180
|
-
if (!hideSecond)
|
|
181
|
-
if (values.length > i)
|
|
182
|
-
if (values.length > i)
|
|
183
|
-
if (values.length > i)
|
|
184
|
-
if (values.length > i)
|
|
185
|
-
if (values.length > i)
|
|
186
|
-
if (values.length > i)
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
assignTable() {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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 = ''
|
|
161
|
+
if (!hideSecond) second.value = values[i++]
|
|
162
|
+
if (values.length > i) minute.value = values[i++]
|
|
163
|
+
if (values.length > i) hour.value = values[i++]
|
|
164
|
+
if (values.length > i) day.value = values[i++]
|
|
165
|
+
if (values.length > i) month.value = values[i++]
|
|
166
|
+
if (values.length > i) week.value = values[i++]
|
|
167
|
+
if (values.length > i) year.value = values[i]
|
|
168
|
+
assignTable()
|
|
169
|
+
}
|
|
170
|
+
const assignTable = () => {
|
|
171
|
+
tableConfig.data = [{ second: second.value, minute: minute.value, hour: hour.value, day: day.value, month: month.value, week: week.value, year: year.value }]
|
|
172
|
+
}
|
|
173
|
+
const calTriggerListInner = () => {
|
|
174
|
+
errMessage.value = ''
|
|
204
175
|
// 设置了回调函数
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
|
|
176
|
+
if (props.remote) {
|
|
177
|
+
props.remote(cronValueInner.value, +new Date(), v => {
|
|
178
|
+
preTimeList.value = v
|
|
208
179
|
})
|
|
209
180
|
return
|
|
210
181
|
}
|
|
211
182
|
try {
|
|
212
183
|
const format = 'yyyy-MM-dd hh:mm:ss'
|
|
213
184
|
const options = {
|
|
214
|
-
currentDate:
|
|
185
|
+
currentDate: $vUtils.toDateString(new Date(), format)
|
|
215
186
|
}
|
|
216
|
-
const iter = cronUtils.parse(
|
|
187
|
+
const iter = cronUtils.parse(cronValueNoYear.value, options)
|
|
217
188
|
const result = []
|
|
218
189
|
for (let i = 1; i <= 10; i++) {
|
|
219
|
-
result.push(
|
|
190
|
+
result.push($vUtils.toDateString(new Date(iter.next()), format))
|
|
220
191
|
}
|
|
221
|
-
|
|
192
|
+
preTimeList.value = result.length > 0 ? result.join('\n') : '无执行时间'
|
|
222
193
|
} catch (e) {
|
|
223
|
-
|
|
194
|
+
errMessage.value = e
|
|
224
195
|
}
|
|
225
|
-
}
|
|
196
|
+
}
|
|
226
197
|
// Quartz 的规则:
|
|
227
198
|
// 1 = 周日,2 = 周一,3 = 周二,4 = 周三,5 = 周四,6 = 周五,7 = 周六
|
|
228
|
-
convertWeekToQuartz
|
|
199
|
+
const convertWeekToQuartz = week => {
|
|
229
200
|
let convert = v => {
|
|
230
201
|
if (v === '0') {
|
|
231
202
|
return '1'
|
|
@@ -256,28 +227,68 @@ export default {
|
|
|
256
227
|
.join(',')
|
|
257
228
|
}
|
|
258
229
|
return week
|
|
259
|
-
}
|
|
260
|
-
onTableHeaderClick({ column }) {
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
onTableEditClosed({ row, column }) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
230
|
+
}
|
|
231
|
+
const onTableHeaderClick = ({ column }) => {
|
|
232
|
+
activeKey.value = column.property
|
|
233
|
+
}
|
|
234
|
+
const onTableEditClosed = ({ row, column }) => {
|
|
235
|
+
second.value = row.second
|
|
236
|
+
minute.value = row.minute
|
|
237
|
+
hour.value = row.hour
|
|
238
|
+
day.value = row.day
|
|
239
|
+
month.value = row.month
|
|
240
|
+
week.value = row.week
|
|
241
|
+
year.value = row.year
|
|
242
|
+
}
|
|
243
|
+
const emitValue = value => {
|
|
244
|
+
emit('change', value)
|
|
245
|
+
emit('update:modelValue', value)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const calTriggerList = $vUtils.debounce(calTriggerListInner, 500)
|
|
249
|
+
|
|
250
|
+
watch(
|
|
251
|
+
() => props.modelValue,
|
|
252
|
+
nv => {
|
|
253
|
+
if (nv === cronValueInner.value) {
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
formatValue()
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
watch(
|
|
260
|
+
() => cronValueInner.value,
|
|
261
|
+
nv => {
|
|
262
|
+
calTriggerList()
|
|
263
|
+
emitValue(nv)
|
|
264
|
+
assignTable()
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
onBeforeMount(() => {
|
|
269
|
+
assignTable()
|
|
270
|
+
formatValue()
|
|
271
|
+
calTriggerListInner()
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
activeKey,
|
|
276
|
+
cronTabList,
|
|
277
|
+
second,
|
|
278
|
+
minute,
|
|
279
|
+
hour,
|
|
280
|
+
day,
|
|
281
|
+
month,
|
|
282
|
+
week,
|
|
283
|
+
year,
|
|
284
|
+
tableConfig,
|
|
285
|
+
errMessage,
|
|
286
|
+
preTimeList,
|
|
287
|
+
onTableEditClosed,
|
|
288
|
+
onTableHeaderClick
|
|
278
289
|
}
|
|
279
290
|
}
|
|
280
|
-
}
|
|
291
|
+
})
|
|
281
292
|
</script>
|
|
282
293
|
|
|
283
294
|
<style scoped></style>
|
|
@@ -1,67 +1,81 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<sh-modal v-bind="modalConfig" @close="onModalClose" @confirm="onModalConfim">
|
|
3
|
-
<cron-content v-model="cronValue" :disabled="disabled"></cron-content>
|
|
4
|
-
</sh-modal>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
import
|
|
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
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<sh-modal v-bind="modalConfig" @close="onModalClose" @confirm="onModalConfim">
|
|
3
|
+
<cron-content v-model="cronValue" :disabled="disabled"></cron-content>
|
|
4
|
+
</sh-modal>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { defineComponent, computed, getCurrentInstance, ref, reactive, watch, onBeforeMount } from 'vue'
|
|
9
|
+
import cronContent from './components/cron-content.vue'
|
|
10
|
+
export default defineComponent({
|
|
11
|
+
name: 'ShCronModal',
|
|
12
|
+
components: {
|
|
13
|
+
cronContent
|
|
14
|
+
},
|
|
15
|
+
props: {
|
|
16
|
+
modelValue: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: ''
|
|
19
|
+
},
|
|
20
|
+
visible: {
|
|
21
|
+
type: Boolean
|
|
22
|
+
},
|
|
23
|
+
disabled: {
|
|
24
|
+
type: Boolean
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
emits: ['update:modelValue', 'update:visible', 'submit'],
|
|
28
|
+
setup(props, context) {
|
|
29
|
+
const { proxy } = getCurrentInstance()
|
|
30
|
+
const { $vUtils } = proxy
|
|
31
|
+
const { emit, slots } = context
|
|
32
|
+
|
|
33
|
+
const cronValue = ref('')
|
|
34
|
+
const modalConfig = reactive({
|
|
35
|
+
loading: false,
|
|
36
|
+
width: '70%',
|
|
37
|
+
title: 'cron表达式',
|
|
38
|
+
visible: props.visible
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const emitValue = () => {
|
|
42
|
+
emit('update:modelValue', cronValue.value)
|
|
43
|
+
emit('submit', cronValue.value)
|
|
44
|
+
}
|
|
45
|
+
// 提交
|
|
46
|
+
const onModalConfim = () => {
|
|
47
|
+
emitValue()
|
|
48
|
+
onModalClose()
|
|
49
|
+
}
|
|
50
|
+
// 关闭
|
|
51
|
+
const onModalClose = () => {
|
|
52
|
+
emit('update:visible', false)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
watch(
|
|
56
|
+
() => props.modelValue,
|
|
57
|
+
nv => {
|
|
58
|
+
cronValue.value = nv
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
watch(
|
|
62
|
+
() => props.visible,
|
|
63
|
+
nv => {
|
|
64
|
+
modalConfig.visible = nv
|
|
65
|
+
cronValue.value = props.modelValue
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
modalConfig,
|
|
71
|
+
cronValue,
|
|
72
|
+
onModalClose,
|
|
73
|
+
onModalConfim
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<style lang="scss">
|
|
80
|
+
@import './css/index.scss';
|
|
81
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default ['update:modelValue', 'change']
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { computed, ref, reactive } from 'vue'
|
|
2
|
+
|
|
3
|
+
const TypeEnum = {
|
|
4
|
+
unset: 'UNSET',
|
|
5
|
+
every: 'EVERY',
|
|
6
|
+
range: 'RANGE',
|
|
7
|
+
loop: 'LOOP',
|
|
8
|
+
work: 'WORK',
|
|
9
|
+
last: 'LAST',
|
|
10
|
+
specify: 'SPECIFY'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function (props, context, proxy, state) {
|
|
14
|
+
const { emit, slots } = context
|
|
15
|
+
const { $vUtils } = proxy
|
|
16
|
+
|
|
17
|
+
const type = ref(TypeEnum.every)
|
|
18
|
+
const defaultValue = ref(state.defaultValue)
|
|
19
|
+
const minValue = ref(state.minValue)
|
|
20
|
+
const maxValue = ref(state.maxValue)
|
|
21
|
+
const valueRange = reactive(state.valueRange)
|
|
22
|
+
const valueLoop = reactive(state.valueLoop)
|
|
23
|
+
const valueWork = ref(1)
|
|
24
|
+
const valueList = ref([])
|
|
25
|
+
|
|
26
|
+
const beforeRadioAttrs = computed(() => {
|
|
27
|
+
return {
|
|
28
|
+
class: ['choice'],
|
|
29
|
+
disabled: props.disabled
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
const inputNumberAttrs = computed(() => {
|
|
33
|
+
return {
|
|
34
|
+
class: ['cron-item-input'],
|
|
35
|
+
type: 'integer',
|
|
36
|
+
size: 'mini'
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
const typeRangeAttrs = computed(() => {
|
|
40
|
+
return {
|
|
41
|
+
...inputNumberAttrs.value,
|
|
42
|
+
disabled: type.value !== TypeEnum.range || props.disabled
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
const typeLoopAttrs = computed(() => {
|
|
46
|
+
return {
|
|
47
|
+
...inputNumberAttrs.value,
|
|
48
|
+
disabled: type.value !== TypeEnum.loop || props.disabled
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
const typeSpecifyAttrs = computed(() => {
|
|
52
|
+
return {
|
|
53
|
+
class: ['list-check-item'],
|
|
54
|
+
disabled: type.value !== TypeEnum.specify || props.disabled
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
const specifyRange = computed(() => {
|
|
58
|
+
let range = []
|
|
59
|
+
if (maxValue.value != null) {
|
|
60
|
+
for (let i = minValue.value; i <= maxValue.value; i++) {
|
|
61
|
+
range.push(i)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return range
|
|
65
|
+
})
|
|
66
|
+
// 根据不同的类型计算出的value
|
|
67
|
+
const computeValue = computed(() => {
|
|
68
|
+
let valueArray = []
|
|
69
|
+
switch (type.value) {
|
|
70
|
+
case TypeEnum.unset:
|
|
71
|
+
valueArray.push('?')
|
|
72
|
+
break
|
|
73
|
+
case TypeEnum.every:
|
|
74
|
+
valueArray.push('*')
|
|
75
|
+
break
|
|
76
|
+
case TypeEnum.range:
|
|
77
|
+
valueArray.push(`${valueRange.start}-${valueRange.end}`)
|
|
78
|
+
break
|
|
79
|
+
case TypeEnum.loop:
|
|
80
|
+
valueArray.push(`${valueLoop.start}/${valueLoop.interval}`)
|
|
81
|
+
break
|
|
82
|
+
case TypeEnum.work:
|
|
83
|
+
valueArray.push(`${valueWork.value}W`)
|
|
84
|
+
break
|
|
85
|
+
case TypeEnum.last:
|
|
86
|
+
valueArray.push('L')
|
|
87
|
+
break
|
|
88
|
+
case TypeEnum.specify:
|
|
89
|
+
if (valueList.value.length === 0) {
|
|
90
|
+
valueList.value.push(minValue)
|
|
91
|
+
}
|
|
92
|
+
valueArray.push(valueList.value.join(','))
|
|
93
|
+
break
|
|
94
|
+
default:
|
|
95
|
+
valueArray.push(defaultValue.value)
|
|
96
|
+
break
|
|
97
|
+
}
|
|
98
|
+
return valueArray.length > 0 ? valueArray.join('') : defaultValue.value
|
|
99
|
+
})
|
|
100
|
+
const parseValue = value => {
|
|
101
|
+
if (value === computeValue.value) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
if (!value || value === defaultValue.value) {
|
|
106
|
+
type.value = TypeEnum.every
|
|
107
|
+
} else if (value.indexOf('?') >= 0) {
|
|
108
|
+
type.value = TypeEnum.unset
|
|
109
|
+
} else if (value.indexOf('-') >= 0) {
|
|
110
|
+
type.value = TypeEnum.range
|
|
111
|
+
const values = value.split('-')
|
|
112
|
+
if (values.length >= 2) {
|
|
113
|
+
valueRange.start = parseInt(values[0])
|
|
114
|
+
valueRange.end = parseInt(values[1])
|
|
115
|
+
}
|
|
116
|
+
} else if (value.indexOf('/') >= 0) {
|
|
117
|
+
type.value = TypeEnum.loop
|
|
118
|
+
const values = value.split('/')
|
|
119
|
+
if (values.length >= 2) {
|
|
120
|
+
valueLoop.start = value[0] === '*' ? 0 : parseInt(values[0])
|
|
121
|
+
valueLoop.interval = parseInt(values[1])
|
|
122
|
+
}
|
|
123
|
+
} else if (value.indexOf('W') >= 0) {
|
|
124
|
+
type.value = TypeEnum.work
|
|
125
|
+
const values = value.split('W')
|
|
126
|
+
if (!values[0] && !isNaN(values[0])) {
|
|
127
|
+
valueWork.value = parseInt(values[0])
|
|
128
|
+
}
|
|
129
|
+
} else if (value.indexOf('L') >= 0) {
|
|
130
|
+
type.value = TypeEnum.last
|
|
131
|
+
} else if (value.indexOf(',') >= 0 || !isNaN(value)) {
|
|
132
|
+
type.value = TypeEnum.specify
|
|
133
|
+
valueList.value = value.split(',').map(item => parseInt(item))
|
|
134
|
+
} else {
|
|
135
|
+
type.value = TypeEnum.every
|
|
136
|
+
}
|
|
137
|
+
} catch (e) {
|
|
138
|
+
type.value = TypeEnum.every
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const updateValue = value => {
|
|
142
|
+
emit('change', value)
|
|
143
|
+
emit('update:modelValue', value)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
watch(
|
|
147
|
+
() => props.modelValue,
|
|
148
|
+
val => {
|
|
149
|
+
if (val !== computeValue.value) {
|
|
150
|
+
parseValue(val)
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{ immediate: true }
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
watch(
|
|
157
|
+
() => computeValue.value,
|
|
158
|
+
val => {
|
|
159
|
+
updateValue(v)
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
TypeEnum,
|
|
165
|
+
type,
|
|
166
|
+
valueRange,
|
|
167
|
+
valueLoop,
|
|
168
|
+
valueWork,
|
|
169
|
+
valueList,
|
|
170
|
+
specifyRange,
|
|
171
|
+
computeValue,
|
|
172
|
+
inputNumberAttrs,
|
|
173
|
+
beforeRadioAttrs,
|
|
174
|
+
typeRangeAttrs,
|
|
175
|
+
typeLoopAttrs,
|
|
176
|
+
typeSpecifyAttrs,
|
|
177
|
+
updateValue
|
|
178
|
+
}
|
|
179
|
+
}
|