1
2
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
99
100
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
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
217
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
| <template>
| <div>
| <el-table
| :data="tableData"
| :class="{tableTopLevel1: topLevel === 1, tableTopLevel2: topLevel === 2, tableTopLevel3: topLevel === 3, tableTopLevelDefault: topLevel === -1}"
| row-key="id"
| border
| max-height="510"
| @selection-change="handleSelectionChange">
| <el-table-column
| fixed
| type="selection"
| width="55">
| </el-table-column>
| <el-table-column
| fixed
| prop="jobKey"
| label="任务key"
| sortable
| width="160">
| </el-table-column>
| <el-table-column
| prop="jobGroup"
| label="任务分组"
| sortable
| width="120">
| </el-table-column>
| <el-table-column
| prop="jobClass"
| label="job类"
| width="120">
| </el-table-column>
| <el-table-column
| prop="cronExpress"
| label="Cron表达式"
| sortable
| width="120">
| </el-table-column>
| <el-table-column
| prop="remark"
| label="备注"
| sortable
| width="120">
| </el-table-column>
| <el-table-column
| prop="jobStatus"
| label="任务状态"
| :formatter="formatStatus"
| width="100">
| </el-table-column>
| <el-table-column
| prop="gmtCreate"
| label="创建时间"
| width="160">
| </el-table-column>
| <el-table-column
| prop="createBy"
| label="创建人"
| width="140">
| </el-table-column>
| <el-table-column
| fixed="right"
| width="300"
| label="操作">
| <template slot-scope="scope">
| <el-button v-if="editShow" type="primary" @click="editQuartz(scope.row.id)" size="mini">修改</el-button>
| <el-button v-if="delShow" type="primary" @click="deleteQuartz(scope.row.id)" size="mini">删除</el-button>
| <el-button v-if="onceShow" type="primary" @click="executeOnce(scope.row)" size="mini">执行一次</el-button>
| <el-button v-if="pauseShow && scope.row.jobStatus === '0'" type="primary" @click="stopQuartz(scope.row)" size="mini">暂停</el-button>
| <el-button v-if="pauseShow && scope.row.jobStatus === '1'" type="primary" @click="startQuartz(scope.row)" size="mini">启用</el-button>
| </template>
| </el-table-column>
| </el-table>
| <PageC
| :top-level="topLevel"
| :handleSizeChange="handleSizeChange"
| :handleCurrentChange="handleCurrentChange"
| :pageSize="pageSize"
| :total="total"
| :currentPage="currentPage"></PageC>
| </div>
| </template>
|
| <script>
| import PageC from "@/components/PageC";
| import {deleteQuartzById, getQuartzs, executeOnce, stopQuartz, startQuartz} from "@/api/quartz";
| import {Message} from "element-ui";
| export default {
| name: "QuartzTable",
| components: {PageC},
| props: {
| topLevel: {
| required: false,
| default: -1,
| type: Number
| },
| editShow: {
| required: true,
| default: false,
| type: Boolean
| },
| delShow: {
| required: true,
| default: false,
| type: Boolean
| },
| pauseShow: {
| required: true,
| default: false,
| type: Boolean
| },
| onceShow: {
| required: true,
| default: false,
| type: Boolean
| },
| runShow: {
| required: true,
| default: false,
| type: Boolean
| },
| },
| computed: {
| tableData: {
| get() {
| return this.$store.state.quartz.tableData;
| },
| set(value) {
| this.$store.state.quartz.tableData = value;
| }
| },
| // 选中行id
| multipleSelection: {
| get() {
| return this.$store.state.quartz.multipleSelection;
| },
| set(value) {
| this.$store.state.quartz.multipleSelection = value;
| }
| },
| total: {
| get() {
| return this.$store.state.quartz.total;
| },
| set(value) {
| this.$store.state.quartz.total = value;
| }
| },
| pageSize: {
| get() {
| return this.$store.state.quartz.pageSize;
| },
| set(value) {
| this.$store.state.quartz.pageSize = value;
| }
| },
| currentPage: {
| get() {
| return this.$store.state.quartz.currentPage;
| },
| set(value) {
| this.$store.state.quartz.currentPage = value;
| }
| }
| },
| methods: {
| formatStatus(row) {
| return row.jobStatus === '0' ? "启用中" : "暂停中";
| },
| startQuartz(form) {
| this.$confirm('确定要启用该定时任务吗?', '提示', {
| confirmButtonText: '确定',
| cancelButtonText: '取消',
| type: 'warning'
| }).then(() => {
| startQuartz(form).then((res) => {
| Message.success(res.data.msg);
| this.getQuartzs();
| })
| }).catch(() => {
| this.$message({
| type: 'info',
| message: '已取消'
| });
| });
| },
| stopQuartz(form) {
| this.$confirm('确定要暂停该定时任务吗?', '提示', {
| confirmButtonText: '确定',
| cancelButtonText: '取消',
| type: 'warning'
| }).then(() => {
| stopQuartz(form).then((res) => {
| Message.success(res.data.msg);
| this.getQuartzs();
| })
| }).catch(() => {
| this.$message({
| type: 'info',
| message: '已取消'
| });
| });
| },
| executeOnce(form) {
| executeOnce(form).then((res) => {
| Message.success(res.data.msg);
| })
| },
| handleSelectionChange(val) {
| this.multipleSelection = val.map((item) => {return item.id;})
| },
| getQuartzs() {
| let params = {
| currentPage: this.currentPage,
| pageSize: this.pageSize
| };
| // 刷新
| getQuartzs(params).then((res) => {
| this.tableData = res.data.data;
| this.total = res.data.total;
| })
| },
| editQuartz(id) {
| this.$store.dispatch("quartz/editQuartz", id);
| },
| deleteQuartz(id) {
| this.$confirm('此操作将永久删除该定时任务, 是否继续?', '提示', {
| confirmButtonText: '确定',
| cancelButtonText: '取消',
| type: 'warning'
| }).then(() => {
| deleteQuartzById(id).then((res) => {
| Message.success(res.data.msg);
| this.getQuartzs();
| })
| }).catch(() => {
| this.$message({
| type: 'info',
| message: '已取消删除'
| });
| });
| },
| handleSizeChange(val) {
| this.pageSize = val;
| this.getQuartzs();
| },
| handleCurrentChange(val) {
| this.currentPage = val;
| this.getQuartzs();
| }
| },
| created() {
| if (this.$getButtonAuth("job:page")) {
| this.getQuartzs();
| }
| }
| }
| </script>
|
| <style scoped>
|
| </style>
|
|