houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-card shadow="never" class="aui-card--fill">
3     <div class="mod-job__schedule">
4       <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
5         <el-form-item>
6           <el-input v-model="dataForm.beanName" :placeholder="$t('schedule.beanName')" clearable></el-input>
7         </el-form-item>
8         <el-form-item>
9           <el-button @click="getDataList()">{{ $t('query') }}</el-button>
10         </el-form-item>
11         <el-form-item>
12           <el-button v-if="$hasPermission('sys:schedule:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
13         </el-form-item>
14         <el-form-item>
15           <el-button v-if="$hasPermission('sys:schedule:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
16         </el-form-item>
17         <el-form-item>
18           <el-button v-if="$hasPermission('sys:schedule:pause')" type="danger" @click="pauseHandle()">{{ $t('schedule.pauseBatch') }}</el-button>
19         </el-form-item>
20         <el-form-item>
21           <el-button v-if="$hasPermission('sys:schedule:resume')" type="danger" @click="resumeHandle()">{{ $t('schedule.resumeBatch') }}</el-button>
22         </el-form-item>
23         <el-form-item>
24           <el-button v-if="$hasPermission('sys:schedule:run')" type="danger" @click="runHandle()">{{ $t('schedule.runBatch') }}</el-button>
25         </el-form-item>
26         <el-form-item>
27           <el-button v-if="$hasPermission('sys:schedule:log')" type="success" @click="logHandle()">{{ $t('schedule.log') }}</el-button>
28         </el-form-item>
29       </el-form>
30       <el-table
31         v-loading="dataListLoading"
32         :data="dataList"
33         border
34         @selection-change="dataListSelectionChangeHandle"
35         @sort-change="dataListSortChangeHandle"
36         style="width: 100%;">
37         <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
38         <el-table-column prop="beanName" :label="$t('schedule.beanName')" header-align="center" align="center"></el-table-column>
39         <el-table-column prop="params" :label="$t('schedule.params')" header-align="center" align="center"></el-table-column>
40         <el-table-column prop="cronExpression" :label="$t('schedule.cronExpression')" header-align="center" align="center"></el-table-column>
41         <el-table-column prop="remark" :label="$t('schedule.remark')" header-align="center" align="center"></el-table-column>
42         <el-table-column prop="status" :label="$t('schedule.status')" sortable="custom" header-align="center" align="center">
43           <template slot-scope="scope">
44             <el-tag v-if="scope.row.status === 1" size="small">{{ $t('schedule.status1') }}</el-tag>
45             <el-tag v-else size="small" type="danger">{{ $t('schedule.status0') }}</el-tag>
46           </template>
47         </el-table-column>
48         <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
49           <template slot-scope="scope">
50             <el-button v-if="$hasPermission('sys:schedule:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
51             <el-button v-if="$hasPermission('sys:schedule:pause')" type="text" size="small" @click="pauseHandle(scope.row.id)">{{ $t('schedule.pause') }}</el-button>
52             <el-button v-if="$hasPermission('sys:schedule:resume')" type="text" size="small" @click="resumeHandle(scope.row.id)">{{ $t('schedule.resume') }}</el-button>
53             <el-button v-if="$hasPermission('sys:schedule:run')" type="text" size="small" @click="runHandle(scope.row.id)">{{ $t('schedule.run') }}</el-button>
54             <el-button v-if="$hasPermission('sys:schedule:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
55           </template>
56         </el-table-column>
57       </el-table>
58       <el-pagination
59         :current-page="page"
60         :page-sizes="[10, 20, 50, 100]"
61         :page-size="limit"
62         :total="total"
63         layout="total, sizes, prev, pager, next, jumper"
64         @size-change="pageSizeChangeHandle"
65         @current-change="pageCurrentChangeHandle">
66       </el-pagination>
67       <!-- 弹窗, 新增 / 修改 -->
68       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
69       <!-- 弹窗, 日志列表 -->
70       <log v-if="logVisible" ref="log"></log>
71     </div>
72   </el-card>
73 </template>
74
75 <script>
76 import mixinViewModule from '@/mixins/view-module'
77 import AddOrUpdate from './schedule-add-or-update'
78 import Log from './schedule-log'
79 export default {
80   mixins: [mixinViewModule],
81   data () {
82     return {
83       mixinViewModuleOptions: {
84         getDataListURL: '/iailab-ntt-system/sys/schedule/page',
85         getDataListIsPage: true,
86         deleteURL: '/iailab-ntt-system/sys/schedule',
87         deleteIsBatch: true
88       },
89       dataForm: {
90         beanName: ''
91       },
92       logVisible: false
93     }
94   },
95   components: {
96     AddOrUpdate,
97     Log
98   },
99   methods: {
100     // 暂停
101     pauseHandle (id) {
102       if (!id && this.dataListSelections.length <= 0) {
103         return this.$message({
104           message: this.$t('prompt.deleteBatch'),
105           type: 'warning',
106           duration: 500
107         })
108       }
109       this.$confirm(this.$t('prompt.info', { 'handle': this.$t('schedule.pause') }), this.$t('prompt.title'), {
110         confirmButtonText: this.$t('confirm'),
111         cancelButtonText: this.$t('cancel'),
112         type: 'warning'
113       }).then(() => {
114         this.$http.put('/iailab-ntt-system/sys/schedule/pause', id ? [id] : this.dataListSelections.map(item => item.id)).then(({ data: res }) => {
115           if (res.code !== 0) {
116             return this.$message.error(res.msg)
117           }
118           this.$message({
119             message: this.$t('prompt.success'),
120             type: 'success',
121             duration: 500,
122             onClose: () => {
123               this.getDataList()
124             }
125           })
126         }).catch(() => {})
127       }).catch(() => {})
128     },
129     // 恢复
130     resumeHandle (id) {
131       if (!id && this.dataListSelections.length <= 0) {
132         return this.$message({
133           message: this.$t('prompt.deleteBatch'),
134           type: 'warning',
135           duration: 500
136         })
137       }
138       this.$confirm(this.$t('prompt.info', { 'handle': this.$t('schedule.resume') }), this.$t('prompt.title'), {
139         confirmButtonText: this.$t('confirm'),
140         cancelButtonText: this.$t('cancel'),
141         type: 'warning'
142       }).then(() => {
143         this.$http.put('/iailab-ntt-system/sys/schedule/resume', id ? [id] : this.dataListSelections.map(item => item.id)).then(({ data: res }) => {
144           if (res.code !== 0) {
145             return this.$message.error(res.msg)
146           }
147           this.$message({
148             message: this.$t('prompt.success'),
149             type: 'success',
150             duration: 500,
151             onClose: () => {
152               this.getDataList()
153             }
154           })
155         }).catch(() => {})
156       }).catch(() => {})
157     },
158     // 执行
159     runHandle (id) {
160       if (!id && this.dataListSelections.length <= 0) {
161         return this.$message({
162           message: this.$t('prompt.deleteBatch'),
163           type: 'warning',
164           duration: 500
165         })
166       }
167       this.$confirm(this.$t('prompt.info', { 'handle': this.$t('schedule.run') }), this.$t('prompt.title'), {
168         confirmButtonText: this.$t('confirm'),
169         cancelButtonText: this.$t('cancel'),
170         type: 'warning'
171       }).then(() => {
172         this.$http.put('/iailab-ntt-system/sys/schedule/run', id ? [id] : this.dataListSelections.map(item => item.id)).then(({ data: res }) => {
173           if (res.code !== 0) {
174             return this.$message.error(res.msg)
175           }
176           this.$message({
177             message: this.$t('prompt.success'),
178             type: 'success',
179             duration: 500,
180             onClose: () => {
181               this.getDataList()
182             }
183           })
184         }).catch(() => {})
185       }).catch(() => {})
186     },
187     // 日志列表
188     logHandle () {
189       this.logVisible = true
190       this.$nextTick(() => {
191         this.$refs.log.init()
192       })
193     }
194   }
195 }
196 </script>