htui-yllkbz 1.3.83 → 1.3.85
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/lib/htui.common.js +1126 -71
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.css +1 -1
- package/lib/htui.umd.js +1126 -71
- package/lib/htui.umd.js.gz +0 -0
- package/lib/htui.umd.min.js +15 -15
- package/lib/htui.umd.min.js.gz +0 -0
- package/package.json +1 -1
- package/src/App.vue +16 -1
- package/src/packages/HtBaseData/index.vue +0 -1
- package/src/packages/HtMore/index.ts +15 -0
- package/src/packages/HtMore/index.vue +78 -0
- package/src/packages/HtSelectCron/index.ts +14 -0
- package/src/packages/HtSelectCron/index.vue +193 -0
- package/src/packages/HtSelectCron/selectDays.vue +58 -0
- package/src/packages/HtSelectCron/selectHours.vue +58 -0
- package/src/packages/HtSelectCron/selectMin.vue +60 -0
- package/src/packages/HtSelectCron/selectMonth.vue +58 -0
- package/src/packages/HtSelectCron/selectWeekDay.vue +76 -0
- package/src/packages/HtSelectTimeSlot/index.ts +14 -0
- package/src/packages/HtSelectTimeSlot/index.vue +186 -0
- package/src/packages/HtTable/index.vue +2 -2
- package/src/packages/HtUpload/index.vue +95 -83
- package/src/packages/common.ts +65 -2
- package/src/packages/index.ts +5 -3
- package/src/packages/style.scss +1 -1
- package/src/packages/type.ts +21 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Descripttion:
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2022-06-07 10:26:42
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2023-01-03 17:13:38
|
|
8
|
+
-->
|
|
9
|
+
<template>
|
|
10
|
+
<div style="display:flex">
|
|
11
|
+
<span v-if="readonly">{{ state.data.years }}</span>
|
|
12
|
+
|
|
13
|
+
<el-input-number
|
|
14
|
+
v-else
|
|
15
|
+
:step="1"
|
|
16
|
+
:style="`width:calc(40px + ${width || 'auto'})`"
|
|
17
|
+
:readonly="readonly"
|
|
18
|
+
:disabled="disabled"
|
|
19
|
+
style="margin-left:90px"
|
|
20
|
+
v-model="state.data.years"
|
|
21
|
+
controls-position="right"
|
|
22
|
+
@change="changeData($event, 'years')"
|
|
23
|
+
:min="0"
|
|
24
|
+
:max="9999"
|
|
25
|
+
></el-input-number>
|
|
26
|
+
<span>年</span>
|
|
27
|
+
<select-month
|
|
28
|
+
:width="width"
|
|
29
|
+
:readonly="readonly"
|
|
30
|
+
:disabled="disabled"
|
|
31
|
+
v-model="state.data.months"
|
|
32
|
+
@change="changeData($event, 'months')"
|
|
33
|
+
></select-month>
|
|
34
|
+
<span v-if="!readonly">月</span>
|
|
35
|
+
<select-days
|
|
36
|
+
:width="width"
|
|
37
|
+
:readonly="readonly"
|
|
38
|
+
:disabled="disabled"
|
|
39
|
+
v-model="state.data.days"
|
|
40
|
+
@change="changeData($event, 'days')"
|
|
41
|
+
></select-days>
|
|
42
|
+
|
|
43
|
+
<span v-if="!readonly">天</span>
|
|
44
|
+
<select-hours
|
|
45
|
+
:width="width"
|
|
46
|
+
:disabled="disabled"
|
|
47
|
+
:readonly="readonly"
|
|
48
|
+
v-model="state.data.hours"
|
|
49
|
+
@change="changeData($event, 'hours')"
|
|
50
|
+
></select-hours>
|
|
51
|
+
<span v-if="!readonly">时</span>
|
|
52
|
+
<select-min
|
|
53
|
+
:width="width"
|
|
54
|
+
:readonly="readonly"
|
|
55
|
+
:disabled="disabled"
|
|
56
|
+
v-model="state.data.min"
|
|
57
|
+
@change="changeData($event, 'min')"
|
|
58
|
+
></select-min>
|
|
59
|
+
<span v-if="!readonly">分</span>
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
|
62
|
+
<script lang="ts">
|
|
63
|
+
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
|
|
64
|
+
import SelectDays from '../HtSelectCron/selectDays.vue';
|
|
65
|
+
import SelectHours from '../HtSelectCron/selectHours.vue';
|
|
66
|
+
import SelectMin from '../HtSelectCron/selectMin.vue';
|
|
67
|
+
import SelectMonth from '../HtSelectCron/selectMonth.vue';
|
|
68
|
+
interface State {
|
|
69
|
+
/** 数据状态 */
|
|
70
|
+
loading: boolean;
|
|
71
|
+
data: {
|
|
72
|
+
months?: string;
|
|
73
|
+
years?: string;
|
|
74
|
+
days?: string;
|
|
75
|
+
hours?: string;
|
|
76
|
+
min?: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
@Component({
|
|
80
|
+
name: 'HtSelectTimeSlot',
|
|
81
|
+
components: {
|
|
82
|
+
SelectDays,
|
|
83
|
+
SelectHours,
|
|
84
|
+
SelectMin,
|
|
85
|
+
SelectMonth,
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
export default class Index extends Vue {
|
|
89
|
+
@Prop() value?: string;
|
|
90
|
+
@Prop() readonly?: boolean;
|
|
91
|
+
@Prop() disabled?: boolean;
|
|
92
|
+
@Prop() width?: number | string;
|
|
93
|
+
/** 数据 */
|
|
94
|
+
state: State = {
|
|
95
|
+
loading: false,
|
|
96
|
+
data: {
|
|
97
|
+
months: '0',
|
|
98
|
+
years: '0',
|
|
99
|
+
days: '0',
|
|
100
|
+
hours: '0',
|
|
101
|
+
min: '0',
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
/** 数据变化 */
|
|
105
|
+
changeData(e: string, key: 'years' | 'months' | 'days' | 'hours' | 'min') {
|
|
106
|
+
if (!/(^[0-9]\d*$)/.test(e)) {
|
|
107
|
+
this.$notify.error('只能输入非负的整数');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.state.data[key] = e;
|
|
111
|
+
this.setValue();
|
|
112
|
+
}
|
|
113
|
+
setValue() {
|
|
114
|
+
let data: string | undefined = 'P';
|
|
115
|
+
const { months, years, days, hours, min } = this.state.data;
|
|
116
|
+
if (years && years !== '0') {
|
|
117
|
+
data = data + years + 'Y';
|
|
118
|
+
}
|
|
119
|
+
if (months && months !== '0') {
|
|
120
|
+
data = data + months + 'M';
|
|
121
|
+
}
|
|
122
|
+
if (days && days !== '0') {
|
|
123
|
+
data = data + days + 'D';
|
|
124
|
+
}
|
|
125
|
+
if (hours && hours !== '0') {
|
|
126
|
+
data = data + 'T' + hours + 'H';
|
|
127
|
+
}
|
|
128
|
+
if (min && min !== '0') {
|
|
129
|
+
if (data.includes('T')) {
|
|
130
|
+
data = data + min + 'M';
|
|
131
|
+
} else {
|
|
132
|
+
data = data + 'T' + min + 'M';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (data === 'P') {
|
|
136
|
+
data = undefined;
|
|
137
|
+
}
|
|
138
|
+
this.$emit('input', data);
|
|
139
|
+
this.$emit('change', data);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@Watch('value', { immediate: true })
|
|
143
|
+
getValue(value?: string) {
|
|
144
|
+
if (value) {
|
|
145
|
+
const data = value.replace('P', '');
|
|
146
|
+
let d1 = data.split('T')[0];
|
|
147
|
+
let d2 = data.split('T')[1];
|
|
148
|
+
if (d1.includes('Y')) {
|
|
149
|
+
this.state.data.years = d1.split('Y')[0];
|
|
150
|
+
d1 = d1.split('Y')[1];
|
|
151
|
+
}
|
|
152
|
+
if (d1.includes('M')) {
|
|
153
|
+
this.state.data.months = d1.split('M')[0];
|
|
154
|
+
d1 = d1.split('M')[1];
|
|
155
|
+
}
|
|
156
|
+
if (d1.includes('D')) {
|
|
157
|
+
this.state.data.days = d1.split('D')[0];
|
|
158
|
+
d1 = d1.split('D')[1];
|
|
159
|
+
}
|
|
160
|
+
if (d2 && d2.includes('H')) {
|
|
161
|
+
this.state.data.hours = d2.split('H')[0];
|
|
162
|
+
d2 = d2.split('H')[1];
|
|
163
|
+
}
|
|
164
|
+
if (d2 && d2.includes('M')) {
|
|
165
|
+
this.state.data.min = d2.split('M')[0];
|
|
166
|
+
d2 = d2.split('M')[1];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//
|
|
170
|
+
} else {
|
|
171
|
+
this.state.data = {
|
|
172
|
+
years: '0',
|
|
173
|
+
months: '0',
|
|
174
|
+
days: '0',
|
|
175
|
+
hours: '0',
|
|
176
|
+
min: '0',
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/** 生命周期 */
|
|
181
|
+
/** 方法 */
|
|
182
|
+
/** 监听 */
|
|
183
|
+
/** 计算属性 */
|
|
184
|
+
}
|
|
185
|
+
</script>
|
|
186
|
+
<style lang="scss" scoped></style>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-11-11 11:23:24
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime:
|
|
7
|
+
* @LastEditTime: 2023-01-09 11:01:05
|
|
8
8
|
-->
|
|
9
9
|
<template>
|
|
10
10
|
<div v-loading="state.loading" style="background:#fff">
|
|
@@ -417,7 +417,7 @@ import HtUploadFiles from '@/packages/HtUploadFiles/index.vue';
|
|
|
417
417
|
import HtShowBaseData from '@/packages/HtShowBaseData';
|
|
418
418
|
import HtOrgInfo from '@/packages/HtOrgInfo';
|
|
419
419
|
import ElmentUI from 'element-ui';
|
|
420
|
-
Vue.use(ElmentUI
|
|
420
|
+
Vue.use(ElmentUI);
|
|
421
421
|
interface State {
|
|
422
422
|
pageInfo: PageInfoType;
|
|
423
423
|
loading: boolean;
|
|
@@ -1,72 +1,82 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="files-view">
|
|
3
|
-
<el-upload
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
<el-upload
|
|
4
|
+
action="/files/api/filing/file/upload"
|
|
5
|
+
:on-success="handleSuccess"
|
|
6
|
+
:accept="state.accept"
|
|
7
|
+
:before-upload="handelBeforeLoad"
|
|
8
|
+
:headers="headers"
|
|
9
|
+
:file-list="state.fileData.fileList"
|
|
10
|
+
list-type="picture-card"
|
|
11
|
+
multiple
|
|
12
|
+
:disabled="onlyShow"
|
|
13
|
+
:class="{ 'only-show': onlyShow }"
|
|
14
|
+
>
|
|
15
|
+
<i slot="default" class="el-icon-plus"></i>
|
|
16
|
+
<div slot="file" slot-scope="{ file }" :title="file.fileName">
|
|
17
|
+
<img
|
|
18
|
+
class="el-upload-list__item-thumbnail"
|
|
19
|
+
v-if="file.fileType && file.fileType.includes('image')"
|
|
20
|
+
:src="`/files/api/filing/file/download/${file.fileToken}`"
|
|
21
|
+
:alt="file.fileName"
|
|
22
|
+
fit="fill"
|
|
23
|
+
/>
|
|
24
|
+
<img
|
|
25
|
+
class="el-upload-list__item-thumbnail"
|
|
26
|
+
v-else
|
|
27
|
+
:src="showIcon(file)"
|
|
28
|
+
:alt="file.fileName"
|
|
29
|
+
fit="fill"
|
|
30
|
+
/>
|
|
28
31
|
|
|
29
32
|
<span class="el-upload-list__item-actions">
|
|
30
|
-
<span
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
<span
|
|
34
|
+
class="el-upload-list__item-preview"
|
|
35
|
+
v-if="file.fileType && file.fileType.includes('image')"
|
|
36
|
+
@click="handlePictureCardPreview(file)"
|
|
37
|
+
>
|
|
33
38
|
<i class="el-icon-zoom-in"></i>
|
|
34
39
|
</span>
|
|
35
|
-
<span
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
<span
|
|
41
|
+
v-if="!state.disabled"
|
|
42
|
+
class="el-upload-list__item-delete"
|
|
43
|
+
@click="handleDownload(file)"
|
|
44
|
+
>
|
|
38
45
|
<i class="el-icon-download"></i>
|
|
39
46
|
</span>
|
|
40
|
-
<span
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
<span
|
|
48
|
+
v-if="!state.disabled && !onlyShow"
|
|
49
|
+
class="el-upload-list__item-delete"
|
|
50
|
+
@click="handleRemove(file)"
|
|
51
|
+
>
|
|
43
52
|
<i class="el-icon-delete"></i>
|
|
44
53
|
</span>
|
|
45
54
|
</span>
|
|
46
55
|
</div>
|
|
47
56
|
</el-upload>
|
|
48
|
-
<el-dialog
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
<el-dialog
|
|
58
|
+
:visible.sync="state.dialogVisible"
|
|
59
|
+
:modal-append-to-body="false"
|
|
60
|
+
:modal="false"
|
|
61
|
+
:append-to-body="true"
|
|
62
|
+
>
|
|
52
63
|
<article style="height: calc(100vh - 200px); overflow: auto;">
|
|
53
|
-
<img :src="state.dialogImageUrl"
|
|
54
|
-
alt="" />
|
|
64
|
+
<img :src="state.dialogImageUrl" alt="" />
|
|
55
65
|
</article>
|
|
56
66
|
</el-dialog>
|
|
57
67
|
</div>
|
|
58
68
|
</template>
|
|
59
69
|
<script lang="ts">
|
|
60
|
-
import { Vue, Component, Prop, Watch } from
|
|
61
|
-
import { baseConfig } from
|
|
62
|
-
import Video from
|
|
63
|
-
import Pdf from
|
|
64
|
-
import Word from
|
|
65
|
-
import Txt from
|
|
66
|
-
import Ppt from
|
|
67
|
-
import Excel from
|
|
68
|
-
import OtherPng from
|
|
69
|
-
import { InFile, UploadType } from
|
|
70
|
+
import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
|
|
71
|
+
import { baseConfig } from 'vue-kst-auth';
|
|
72
|
+
import Video from '@/icon/vedio.png';
|
|
73
|
+
import Pdf from '@/icon/pdf.png';
|
|
74
|
+
import Word from '@/icon/word.png';
|
|
75
|
+
import Txt from '@/icon/txt.png';
|
|
76
|
+
import Ppt from '@/icon/ppt.png';
|
|
77
|
+
import Excel from '@/icon/excel.png';
|
|
78
|
+
import OtherPng from '@/icon/other.png';
|
|
79
|
+
import { InFile, UploadType } from '../type';
|
|
70
80
|
|
|
71
81
|
interface State {
|
|
72
82
|
/** 数据状态 */
|
|
@@ -96,13 +106,13 @@ export default class HtUpload extends Vue {
|
|
|
96
106
|
state: State = {
|
|
97
107
|
loading: false,
|
|
98
108
|
accept:
|
|
99
|
-
|
|
109
|
+
'.png, .jpg, .jpeg,.mp4,.pdf,.doc,.docx,.txt,.ppt,.pptx,.xls,.xlsx,.gif',
|
|
100
110
|
fileData: {
|
|
101
111
|
file: undefined,
|
|
102
112
|
fileList: [],
|
|
103
113
|
},
|
|
104
114
|
|
|
105
|
-
dialogImageUrl:
|
|
115
|
+
dialogImageUrl: '',
|
|
106
116
|
dialogVisible: false,
|
|
107
117
|
disabled: false,
|
|
108
118
|
};
|
|
@@ -117,21 +127,21 @@ export default class HtUpload extends Vue {
|
|
|
117
127
|
}
|
|
118
128
|
/** 方法 */
|
|
119
129
|
showIcon(file: InFile, name?: string) {
|
|
120
|
-
const fileName = file.fileName ||
|
|
130
|
+
const fileName = file.fileName || '';
|
|
121
131
|
const fileType = file.fileType;
|
|
122
132
|
let url = OtherPng;
|
|
123
133
|
|
|
124
|
-
if (fileName?.lastIndexOf(
|
|
125
|
-
if (fileName?.lastIndexOf(
|
|
134
|
+
if (fileName?.lastIndexOf('.docx') > -1) url = Word;
|
|
135
|
+
if (fileName?.lastIndexOf('.pptx') > -1) url = Ppt;
|
|
126
136
|
if (!fileType) {
|
|
127
137
|
return url;
|
|
128
138
|
}
|
|
129
|
-
if (fileType.includes(
|
|
130
|
-
if (fileType.includes(
|
|
131
|
-
if (fileType.includes(
|
|
132
|
-
if (fileType.includes(
|
|
133
|
-
if (fileType.includes(
|
|
134
|
-
if (fileType.includes(
|
|
139
|
+
if (fileType.includes('video')) url = Video;
|
|
140
|
+
if (fileType.includes('doc')) url = Word;
|
|
141
|
+
if (fileType.includes('excel') || fileType.includes('sheet')) url = Excel;
|
|
142
|
+
if (fileType.includes('pdf')) url = Pdf;
|
|
143
|
+
if (fileType.includes('text')) url = Txt;
|
|
144
|
+
if (fileType.includes('ppt')) url = Ppt;
|
|
135
145
|
|
|
136
146
|
return url;
|
|
137
147
|
}
|
|
@@ -156,7 +166,7 @@ export default class HtUpload extends Vue {
|
|
|
156
166
|
}
|
|
157
167
|
}
|
|
158
168
|
});
|
|
159
|
-
this.$emit(
|
|
169
|
+
this.$emit('change', this.state.fileData);
|
|
160
170
|
}
|
|
161
171
|
handleRemove(file: InFile) {
|
|
162
172
|
const index = this.state.fileData.fileList.findIndex(
|
|
@@ -165,7 +175,7 @@ export default class HtUpload extends Vue {
|
|
|
165
175
|
if (index >= 0) {
|
|
166
176
|
this.state.fileData.file = { ...file };
|
|
167
177
|
this.state.fileData.fileList.splice(index, 1);
|
|
168
|
-
this.$emit(
|
|
178
|
+
this.$emit('change', this.state.fileData);
|
|
169
179
|
}
|
|
170
180
|
}
|
|
171
181
|
handlePictureCardPreview(file: InFile) {
|
|
@@ -174,26 +184,26 @@ export default class HtUpload extends Vue {
|
|
|
174
184
|
}
|
|
175
185
|
/** 上传文件之前的判断 */
|
|
176
186
|
handelBeforeLoad(file: any) {
|
|
177
|
-
const ff = file.name.lastIndexOf(
|
|
187
|
+
const ff = file.name.lastIndexOf('.');
|
|
178
188
|
const type = file.name.slice(ff + 1);
|
|
179
189
|
const uploadTyps = [
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
'mp4',
|
|
191
|
+
'avi',
|
|
192
|
+
'pdf',
|
|
193
|
+
'doc',
|
|
194
|
+
'docx',
|
|
195
|
+
'txt',
|
|
196
|
+
'ppt',
|
|
197
|
+
'pptx',
|
|
198
|
+
'png',
|
|
199
|
+
'gif',
|
|
200
|
+
'jpg',
|
|
201
|
+
'xls',
|
|
202
|
+
'xlsx',
|
|
193
203
|
];
|
|
194
204
|
|
|
195
205
|
if (!uploadTyps.includes(type)) {
|
|
196
|
-
this.$notify.warning(
|
|
206
|
+
this.$notify.warning('上传格式不正确');
|
|
197
207
|
return false;
|
|
198
208
|
}
|
|
199
209
|
// const type=file.name.lastIndex;
|
|
@@ -205,7 +215,7 @@ export default class HtUpload extends Vue {
|
|
|
205
215
|
const downloadHref = `/files/api/filing/file/download/${file.fileToken}`;
|
|
206
216
|
|
|
207
217
|
/** 创建a标签并为其添加属性 */
|
|
208
|
-
const downloadLink = document.createElement(
|
|
218
|
+
const downloadLink = document.createElement('a');
|
|
209
219
|
downloadLink.href = downloadHref;
|
|
210
220
|
downloadLink.download = `${file.fileName}`;
|
|
211
221
|
/** 触发点击事件执行下载 */
|
|
@@ -214,16 +224,18 @@ export default class HtUpload extends Vue {
|
|
|
214
224
|
window.URL.revokeObjectURL(downloadHref);
|
|
215
225
|
}
|
|
216
226
|
/** 监听 */
|
|
217
|
-
@Watch(
|
|
227
|
+
@Watch('tokens')
|
|
218
228
|
onToken() {
|
|
219
|
-
|
|
229
|
+
if (Array.isArray(this.tokens)) {
|
|
230
|
+
this.state.fileData.fileList = [...this.tokens];
|
|
231
|
+
}
|
|
220
232
|
}
|
|
221
233
|
/** 计算属性 */
|
|
222
234
|
/** 获取授权头部信息 */
|
|
223
235
|
get headers() {
|
|
224
236
|
return {
|
|
225
|
-
_tenant: baseConfig.getCookie(
|
|
226
|
-
Authorization:
|
|
237
|
+
_tenant: baseConfig.getCookie('__tenant'),
|
|
238
|
+
Authorization: 'Bearer' + baseConfig.getCookie('Abp.AuthToken'),
|
|
227
239
|
};
|
|
228
240
|
}
|
|
229
241
|
}
|
package/src/packages/common.ts
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2022-07-18 15:01:02
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime:
|
|
7
|
+
* @LastEditTime: 2023-01-03 14:20:57
|
|
8
8
|
*/
|
|
9
9
|
import moment from "moment";
|
|
10
|
+
import { FormValues, TimeModes } from "./type";
|
|
10
11
|
|
|
11
12
|
/** 生成唯一Id
|
|
12
13
|
* @params e 生成的id位数 默认32
|
|
@@ -151,7 +152,69 @@ export function getCommDataItem(type: "users" | "organizationUnit" | "dictionary
|
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
|
|
155
|
+
|
|
155
156
|
|
|
156
157
|
|
|
157
158
|
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
export const getCronExpressionByPartition = ({
|
|
162
|
+
minute,
|
|
163
|
+
month,
|
|
164
|
+
hour,
|
|
165
|
+
weekDay,
|
|
166
|
+
periodUnit,
|
|
167
|
+
day,
|
|
168
|
+
}: FormValues) => {
|
|
169
|
+
switch (periodUnit as TimeModes) {
|
|
170
|
+
case TimeModes.Minute:
|
|
171
|
+
return `0 */${minute || 0} * * * ?`;
|
|
172
|
+
case TimeModes.Hour:
|
|
173
|
+
return `0 ${minute || 0} * * * ?`;
|
|
174
|
+
case TimeModes.Day:
|
|
175
|
+
return `0 ${minute || 0} ${hour || 0} * * ?`;
|
|
176
|
+
case TimeModes.Week:
|
|
177
|
+
return `0 ${minute || 0} ${hour || 0} ? * ${weekDay || 0}`;
|
|
178
|
+
case TimeModes.Month:
|
|
179
|
+
return `0 ${minute || 0} ${hour || 0} ${day || 0} * ?`;
|
|
180
|
+
case TimeModes.Year:
|
|
181
|
+
return `0 ${minute || 0} ${hour || 0} ${day || 0} ${month || 0} ?`;
|
|
182
|
+
default:
|
|
183
|
+
return '0 */10 * * * ?';
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const computePeriodUnit = (cronExpression: string) => {
|
|
188
|
+
const partitions = cronExpression.split(' ');
|
|
189
|
+
const stars = partitions.filter(item => item === '*').length;
|
|
190
|
+
switch (stars) {
|
|
191
|
+
case 3:
|
|
192
|
+
return partitions[1].includes('/') ? TimeModes.Minute : TimeModes.Hour;
|
|
193
|
+
case 2:
|
|
194
|
+
return TimeModes.Day;
|
|
195
|
+
case 1:
|
|
196
|
+
return partitions[partitions.length - 1] === '?'
|
|
197
|
+
? TimeModes.Month
|
|
198
|
+
: TimeModes.Week;
|
|
199
|
+
case 0:
|
|
200
|
+
return TimeModes.Year;
|
|
201
|
+
default:
|
|
202
|
+
return TimeModes.Minute;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
export const getTimeValues = (cronExpression: string) => {
|
|
206
|
+
const partitions = cronExpression.split(' ');
|
|
207
|
+
const currentPeriodUnit = computePeriodUnit(cronExpression);
|
|
208
|
+
let minute = +((partitions[1] || ([] as string[])).includes('/')
|
|
209
|
+
? partitions[1].slice(2) // slice(2) to remove */
|
|
210
|
+
: partitions[1]);
|
|
211
|
+
// min minute duration is 10
|
|
212
|
+
if (currentPeriodUnit === 'Minute' && minute < 10) {
|
|
213
|
+
minute = 10;
|
|
214
|
+
}
|
|
215
|
+
const hour = +partitions[2] || 0;
|
|
216
|
+
const day = +partitions[3] || 1;
|
|
217
|
+
const month = +partitions[4] || 1;
|
|
218
|
+
const weekDay = +partitions[5] || 1;
|
|
219
|
+
return { minute, hour, day, month, weekDay, periodUnit: currentPeriodUnit };
|
|
220
|
+
};
|
package/src/packages/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-10-21 10:08:41
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime:
|
|
7
|
+
* @LastEditTime: 2023-01-03 15:01:27
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
// 导入组件
|
|
@@ -27,12 +27,14 @@ import HtOrgInfo from './HtOrgInfo/index'
|
|
|
27
27
|
import HtBaseData from './HtBaseData/index'
|
|
28
28
|
import HtShowBaseType from './HtShowBaseType'
|
|
29
29
|
import HtDrawer from './HtDrawer'
|
|
30
|
+
import HtSelectCron from './HtSelectCron'
|
|
31
|
+
import HtSelectTimeSlot from './HtSelectTimeSlot'
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
|
|
34
36
|
// 存储组件列表
|
|
35
|
-
const components = [HtBaseData, HtDrawer, HtShowBaseType, HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtUploadFiles, HtSelectBaseData, HtSelectOrg, HtSelectUser, HtShowBaseData, HtOrgInfo]
|
|
37
|
+
const components = [HtSelectTimeSlot, HtSelectCron, HtBaseData, HtDrawer, HtShowBaseType, HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtUploadFiles, HtSelectBaseData, HtSelectOrg, HtSelectUser, HtShowBaseData, HtOrgInfo]
|
|
36
38
|
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
|
|
37
39
|
const install = function (Vue: any) {
|
|
38
40
|
// 判断是否安装
|
|
@@ -49,6 +51,6 @@ export default {
|
|
|
49
51
|
install,
|
|
50
52
|
// 以下是具体的组件列表
|
|
51
53
|
HtSelectTable, HtPagination, HtShowBaseType, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtUploadFiles,
|
|
52
|
-
HtSelectBaseData, HtSelectOrg, HtSelectUser, HtShowBaseData, HtOrgInfo, HtBaseData, HtDrawer
|
|
54
|
+
HtSelectBaseData, HtSelectOrg, HtSelectUser, HtShowBaseData, HtOrgInfo, HtBaseData, HtDrawer, HtSelectCron, HtSelectTimeSlot
|
|
53
55
|
}
|
|
54
56
|
|
package/src/packages/style.scss
CHANGED
package/src/packages/type.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-10-25 17:05:17
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime:
|
|
7
|
+
* @LastEditTime: 2023-01-03 14:20:13
|
|
8
8
|
*/
|
|
9
9
|
/** 初始的默认条数 */
|
|
10
10
|
export const defalutPageSize = 10
|
|
@@ -98,6 +98,26 @@ export interface PageType {
|
|
|
98
98
|
skipCount: number;
|
|
99
99
|
totalCount: number;
|
|
100
100
|
|
|
101
|
+
}
|
|
102
|
+
/** cron表达式相关类型 */
|
|
103
|
+
export enum TimeModes {
|
|
104
|
+
Minute = 'Minute',
|
|
105
|
+
Hour = 'Hour',
|
|
106
|
+
Day = 'Day',
|
|
107
|
+
Week = 'Week',
|
|
108
|
+
Month = 'Month',
|
|
109
|
+
Year = 'Year',
|
|
110
|
+
}
|
|
111
|
+
export interface FormValues {
|
|
112
|
+
|
|
113
|
+
periodUnit?: TimeModes;
|
|
114
|
+
month?: number;
|
|
115
|
+
day?: number;
|
|
116
|
+
hour?: number;
|
|
117
|
+
minute?: number;
|
|
118
|
+
weekDay?: number;
|
|
119
|
+
cronExpression?: string;
|
|
120
|
+
|
|
101
121
|
}
|
|
102
122
|
/** 附件相关配置 */
|
|
103
123
|
export interface InFile {
|