QuartzJobList.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :md="6" :sm="10">
  8. <a-form-item label="任务类名">
  9. <a-input placeholder="请输入任务类名" v-model="queryParam.jobClassName"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="10">
  13. <a-form-item label="任务状态">
  14. <a-select style="width: 220px" v-model="queryParam.status" placeholder="请选择状态">
  15. <a-select-option value="">全部</a-select-option>
  16. <a-select-option value="0">正常</a-select-option>
  17. <a-select-option value="-1">停止</a-select-option>
  18. </a-select>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="6" :sm="10" >
  22. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  23. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  24. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  25. </span>
  26. </a-col>
  27. </a-row>
  28. </a-form>
  29. </div>
  30. <!-- 操作按钮区域 -->
  31. <div class="table-operator">
  32. <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  33. <a-button type="primary" icon="download" @click="handleExportXls('定时任务信息')">导出</a-button>
  34. <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
  35. <a-button type="primary" icon="import">导入</a-button>
  36. </a-upload>
  37. <a-dropdown v-if="selectedRowKeys.length > 0">
  38. <a-menu slot="overlay">
  39. <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
  40. </a-menu>
  41. <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
  42. </a-dropdown>
  43. </div>
  44. <!-- table区域-begin -->
  45. <div>
  46. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  47. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
  48. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  49. </div>
  50. <a-table
  51. ref="table"
  52. size="middle"
  53. bordered
  54. rowKey="id"
  55. :columns="columns"
  56. :dataSource="dataSource"
  57. :pagination="ipagination"
  58. :loading="loading"
  59. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  60. @change="handleTableChange">
  61. <!-- 字符串超长截取省略号显示-->
  62. <span slot="description" slot-scope="text">
  63. <j-ellipsis :value="text" :length="20" />
  64. </span>
  65. <span slot="parameterRender" slot-scope="text">
  66. <j-ellipsis :value="text" :length="20" />
  67. </span>
  68. <span slot="action" slot-scope="text, record">
  69. <a @click="resumeJob(record)" v-if="record.status==-1">启动</a>
  70. <a @click="pauseJob(record)" v-if="record.status==0">停止</a>
  71. <a-divider type="vertical" />
  72. <a-dropdown>
  73. <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
  74. <a-menu slot="overlay">
  75. <a-menu-item><a @click="handleEdit(record)">编辑</a></a-menu-item>
  76. <a-menu-item>
  77. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  78. <a>删除</a>
  79. </a-popconfirm>
  80. </a-menu-item>
  81. </a-menu>
  82. </a-dropdown>
  83. </span>
  84. <!-- 状态渲染模板 -->
  85. <template slot="customRenderStatus" slot-scope="status">
  86. <a-tag v-if="status==0" color="green">已启动</a-tag>
  87. <a-tag v-if="status==-1" color="orange">已暂停</a-tag>
  88. </template>
  89. </a-table>
  90. </div>
  91. <!-- table区域-end -->
  92. <!-- 表单区域 -->
  93. <quartzJob-modal ref="modalForm" @ok="modalFormOk"></quartzJob-modal>
  94. </a-card>
  95. </template>
  96. <script>
  97. import QuartzJobModal from './modules/QuartzJobModal'
  98. import { getAction } from '@/api/manage'
  99. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  100. import JEllipsis from "@/components/jeecg/JEllipsis";
  101. export default {
  102. name: "QuartzJobList",
  103. mixins:[JeecgListMixin],
  104. components: {
  105. QuartzJobModal,
  106. JEllipsis
  107. },
  108. data () {
  109. return {
  110. description: '定时任务在线管理',
  111. // 查询条件
  112. queryParam: {},
  113. // 表头
  114. columns: [
  115. {
  116. title: '#',
  117. dataIndex: '',
  118. key:'rowIndex',
  119. width:60,
  120. align:"center",
  121. customRender:function (t,r,index) {
  122. return parseInt(index)+1;
  123. }
  124. },
  125. {
  126. title: '任务类名',
  127. align:"center",
  128. dataIndex: 'jobClassName',
  129. sorter: true,
  130. /* customRender:function (text) {
  131. return "*"+text.substring(9,text.length);
  132. }*/
  133. },
  134. {
  135. title: 'cron表达式',
  136. align:"center",
  137. dataIndex: 'cronExpression'
  138. },
  139. {
  140. title: '参数',
  141. align:"center",
  142. width: 150,
  143. dataIndex: 'parameter',
  144. scopedSlots: {customRender: 'parameterRender'},
  145. },
  146. {
  147. title: '描述',
  148. align:"center",
  149. width: 250,
  150. dataIndex: 'description',
  151. scopedSlots: {customRender: 'description'},
  152. },
  153. {
  154. title: '状态',
  155. align:"center",
  156. dataIndex: 'status',
  157. scopedSlots: { customRender: 'customRenderStatus' },
  158. filterMultiple: false,
  159. filters: [
  160. { text: '已启动', value: '0' },
  161. { text: '已暂停', value: '-1' },
  162. ]
  163. },
  164. {
  165. title: '操作',
  166. dataIndex: 'action',
  167. align:"center",
  168. width:180,
  169. scopedSlots: { customRender: 'action' },
  170. }
  171. ],
  172. url: {
  173. list: "/sys/quartzJob/list",
  174. delete: "/sys/quartzJob/delete",
  175. deleteBatch: "/sys/quartzJob/deleteBatch",
  176. pause: "/sys/quartzJob/pause",
  177. resume: "/sys/quartzJob/resume",
  178. exportXlsUrl: "sys/quartzJob/exportXls",
  179. importExcelUrl: "sys/quartzJob/importExcel",
  180. },
  181. }
  182. },
  183. computed: {
  184. importExcelUrl: function () {
  185. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  186. }
  187. },
  188. methods: {
  189. //筛选需要重写handleTableChange
  190. handleTableChange(pagination, filters, sorter) {
  191. //分页、排序、筛选变化时触发
  192. //TODO 筛选
  193. if (Object.keys(sorter).length > 0) {
  194. this.isorter.column = sorter.field;
  195. this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
  196. }
  197. //这种筛选方式只支持单选
  198. this.filters.status = filters.status[0];
  199. this.ipagination = pagination;
  200. this.loadData();
  201. },
  202. pauseJob: function(record){
  203. var that = this;
  204. //暂停定时任务
  205. this.$confirm({
  206. title:"确认暂停",
  207. content:"是否暂停选中任务?",
  208. onOk: function(){
  209. getAction(that.url.pause,{jobClassName:record.jobClassName}).then((res)=>{
  210. if(res.success){
  211. that.$message.success(res.message);
  212. that.loadData();
  213. that.onClearSelected();
  214. }else{
  215. that.$message.warning(res.message);
  216. }
  217. });
  218. }
  219. });
  220. },
  221. resumeJob: function(record){
  222. var that = this;
  223. //恢复定时任务
  224. this.$confirm({
  225. title:"确认启动",
  226. content:"是否启动选中任务?",
  227. onOk: function(){
  228. getAction(that.url.resume,{jobClassName:record.jobClassName}).then((res)=>{
  229. if(res.success){
  230. that.$message.success(res.message);
  231. that.loadData();
  232. that.onClearSelected();
  233. }else{
  234. that.$message.warning(res.message);
  235. }
  236. });
  237. }
  238. });
  239. },
  240. }
  241. }
  242. </script>
  243. <style scoped>
  244. @import '~@assets/less/common.less'
  245. </style>