560cad24ce7243733eb4e4939ba13b577adcefc0.svn-base 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model layout="inline" :model="queryParam" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :md="6" :sm="10">
  8. <a-form-model-item label="任务类名" prop="jobClassName">
  9. <a-input placeholder="请输入任务类名" v-model="queryParam.jobClassName"></a-input>
  10. </a-form-model-item>
  11. </a-col>
  12. <a-col :md="6" :sm="10">
  13. <a-form-model-item label="任务状态" prop="status">
  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-model-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-model>
  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="executeImmediately(record)">立即执行</a></a-menu-item>
  76. <a-menu-item><a @click="handleEdit(record)">编辑</a></a-menu-item>
  77. <a-menu-item>
  78. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  79. <a>删除</a>
  80. </a-popconfirm>
  81. </a-menu-item>
  82. </a-menu>
  83. </a-dropdown>
  84. </span>
  85. <!-- 状态渲染模板 -->
  86. <template slot="customRenderStatus" slot-scope="status">
  87. <a-tag v-if="status==0" color="green">已启动</a-tag>
  88. <a-tag v-if="status==-1" color="orange">已暂停</a-tag>
  89. </template>
  90. </a-table>
  91. </div>
  92. <!-- table区域-end -->
  93. <!-- 表单区域 -->
  94. <quartzJob-modal ref="modalForm" @ok="modalFormOk"></quartzJob-modal>
  95. </a-card>
  96. </template>
  97. <script>
  98. import QuartzJobModal from './modules/QuartzJobModal'
  99. import { getAction } from '@/api/manage'
  100. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  101. import JEllipsis from "@/components/jeecg/JEllipsis";
  102. export default {
  103. name: "QuartzJobList",
  104. mixins:[JeecgListMixin],
  105. components: {
  106. QuartzJobModal,
  107. JEllipsis
  108. },
  109. data () {
  110. return {
  111. description: '定时任务在线管理',
  112. // 查询条件
  113. queryParam: {},
  114. // 表头
  115. columns: [
  116. {
  117. title: '#',
  118. dataIndex: '',
  119. key:'rowIndex',
  120. width:60,
  121. align:"center",
  122. customRender:function (t,r,index) {
  123. return parseInt(index)+1;
  124. }
  125. },
  126. {
  127. title: '任务类名',
  128. align:"center",
  129. dataIndex: 'jobClassName',
  130. sorter: true,
  131. /* customRender:function (text) {
  132. return "*"+text.substring(9,text.length);
  133. }*/
  134. },
  135. {
  136. title: 'cron表达式',
  137. align:"center",
  138. dataIndex: 'cronExpression'
  139. },
  140. {
  141. title: '参数',
  142. align:"center",
  143. width: 150,
  144. dataIndex: 'parameter',
  145. scopedSlots: {customRender: 'parameterRender'},
  146. },
  147. {
  148. title: '描述',
  149. align:"center",
  150. width: 250,
  151. dataIndex: 'description',
  152. scopedSlots: {customRender: 'description'},
  153. },
  154. {
  155. title: '状态',
  156. align:"center",
  157. dataIndex: 'status',
  158. scopedSlots: { customRender: 'customRenderStatus' },
  159. filterMultiple: false,
  160. filters: [
  161. { text: '已启动', value: '0' },
  162. { text: '已暂停', value: '-1' },
  163. ]
  164. },
  165. {
  166. title: '操作',
  167. dataIndex: 'action',
  168. align:"center",
  169. width:180,
  170. scopedSlots: { customRender: 'action' },
  171. }
  172. ],
  173. url: {
  174. list: "/sys/quartzJob/list",
  175. delete: "/sys/quartzJob/delete",
  176. deleteBatch: "/sys/quartzJob/deleteBatch",
  177. pause: "/sys/quartzJob/pause",
  178. resume: "/sys/quartzJob/resume",
  179. exportXlsUrl: "sys/quartzJob/exportXls",
  180. importExcelUrl: "sys/quartzJob/importExcel",
  181. execute: "sys/quartzJob/execute"
  182. },
  183. }
  184. },
  185. computed: {
  186. importExcelUrl: function () {
  187. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  188. }
  189. },
  190. methods: {
  191. //筛选需要重写handleTableChange
  192. handleTableChange(pagination, filters, sorter) {
  193. //分页、排序、筛选变化时触发
  194. //TODO 筛选
  195. if (Object.keys(sorter).length > 0) {
  196. this.isorter.column = sorter.field;
  197. this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
  198. }
  199. //这种筛选方式只支持单选
  200. // update-begin-author:liusq date:20210624 for:前台定时任务无法翻页 #2666
  201. if(filters && Object.keys(filters).length>0 && filters.status){
  202. this.filters.status = filters.status[0];
  203. }
  204. // update-end-author:liusq date:20210624 for:前台定时任务无法翻页 #2666
  205. this.ipagination = pagination;
  206. this.loadData();
  207. },
  208. pauseJob: function(record){
  209. var that = this;
  210. //暂停定时任务
  211. this.$confirm({
  212. title:"确认暂停",
  213. content:"是否暂停选中任务?",
  214. onOk: function(){
  215. getAction(that.url.pause,{id:record.id}).then((res)=>{
  216. if(res.success){
  217. that.$message.success(res.message);
  218. that.loadData();
  219. that.onClearSelected();
  220. }else{
  221. that.$message.warning(res.message);
  222. }
  223. });
  224. }
  225. });
  226. },
  227. resumeJob: function(record){
  228. var that = this;
  229. //恢复定时任务
  230. this.$confirm({
  231. title:"确认启动",
  232. content:"是否启动选中任务?",
  233. onOk: function(){
  234. getAction(that.url.resume,{id:record.id}).then((res)=>{
  235. if(res.success){
  236. that.$message.success(res.message);
  237. that.loadData();
  238. that.onClearSelected();
  239. }else{
  240. that.$message.warning(res.message);
  241. }
  242. });
  243. }
  244. });
  245. },
  246. executeImmediately(record){
  247. var that = this;
  248. //立即执行定时任务
  249. this.$confirm({
  250. title:"确认提示",
  251. content:"是否立即执行任务?",
  252. onOk: function(){
  253. getAction(that.url.execute,{id:record.id}).then((res)=>{
  254. if(res.success){
  255. that.$message.success(res.message);
  256. that.loadData();
  257. that.onClearSelected();
  258. }else{
  259. that.$message.warning(res.message);
  260. }
  261. });
  262. }
  263. });
  264. }
  265. }
  266. }
  267. </script>
  268. <style scoped>
  269. @import '~@assets/less/common.less'
  270. </style>