index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div class="device-manager-box">
  3. <BasicTable @register="registerTable" :rowSelection="rowSelection">
  4. <template #tableTitle>
  5. <a-button preIcon="ant-design:plus-outlined" type="primary" @click="handleAdd" style="margin-right: 5px">新增</a-button>
  6. <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
  7. <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
  8. <a-dropdown v-if="selectedRowKeys.length > 0">
  9. <template #overlay>
  10. <a-menu>
  11. <a-menu-item key="1" @click="batchHandleDelete">
  12. <Icon icon="ant-design:delete-outlined" />
  13. 删除
  14. </a-menu-item>
  15. </a-menu>
  16. </template>
  17. <a-button
  18. >批量操作
  19. <Icon icon="mdi:chevron-down" />
  20. </a-button>
  21. </a-dropdown>
  22. </template>
  23. <template #action="{ record }">
  24. <div class="vent-row-center">
  25. <a-popconfirm v-if="record.status == -1" title="是否启动选中任务?" @confirm="handlerResume(record)" style="display: inline-block">
  26. <a class="table-action-link">启动</a>
  27. </a-popconfirm>
  28. <a-popconfirm v-if="record.status == 0" title="是否暂停选中任务?" @confirm="handlerPause(record)" style="display: inline-block">
  29. <a class="table-action-link">停止</a>
  30. </a-popconfirm>
  31. <TableAction :dropDownActions="getDropDownAction(record)" />
  32. </div>
  33. </template>
  34. </BasicTable>
  35. <QuartzModal @register="registerModal" @success="reload" />
  36. </div>
  37. </template>
  38. <script lang="ts" name="monitor-quartz" setup>
  39. import { ref } from 'vue';
  40. import { BasicTable, TableAction } from '/@/components/Table';
  41. import { useModal } from '/@/components/Modal';
  42. import { useListPage } from '/@/hooks/system/useListPage';
  43. import {
  44. getQuartzList,
  45. deleteQuartz,
  46. batchDeleteQuartz,
  47. executeImmediately,
  48. resumeJob,
  49. pauseJob,
  50. getExportUrl,
  51. getImportUrl,
  52. collectJob,
  53. monitorJob,
  54. computeJob,
  55. } from './quartz.api';
  56. import { columns, searchFormSchema } from './quartz.data';
  57. import QuartzModal from './QuartzModal.vue';
  58. import { useMessage } from '/@/hooks/web/useMessage';
  59. const { createMessage } = useMessage();
  60. const [registerModal, { openModal }] = useModal();
  61. // 列表页面公共参数、方法
  62. const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
  63. designScope: 'quartz-template',
  64. tableProps: {
  65. title: '任务列表',
  66. api: getQuartzList,
  67. columns: columns,
  68. actionColumn: {
  69. width: 180,
  70. },
  71. formConfig: {
  72. labelWidth: 120,
  73. schemas: searchFormSchema,
  74. fieldMapToTime: [['fieldTime', ['beginDate', 'endDate'], 'YYYY-MM-DD HH:mm:ss']],
  75. },
  76. },
  77. exportConfig: {
  78. name: '定时任务列表',
  79. url: getExportUrl,
  80. },
  81. importConfig: {
  82. url: getImportUrl,
  83. },
  84. });
  85. const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
  86. /**
  87. * 操作列定义
  88. * @param record
  89. */
  90. function getActions(record) {
  91. return [
  92. {
  93. label: '启动',
  94. popConfirm: {
  95. title: '是否启动选中任务?',
  96. confirm: handlerResume.bind(null, record),
  97. },
  98. ifShow: (_action) => {
  99. return record.status == -1;
  100. },
  101. },
  102. {
  103. label: '停止',
  104. popConfirm: {
  105. title: '是否暂停选中任务?',
  106. confirm: handlerPause.bind(null, record),
  107. },
  108. ifShow: (_action) => {
  109. return record.status == 0;
  110. },
  111. },
  112. ];
  113. }
  114. /**
  115. * 下拉操作栏
  116. */
  117. function getDropDownAction(record) {
  118. return [
  119. {
  120. label: '立即执行',
  121. popConfirm: {
  122. title: '是否立即执行任务?',
  123. confirm: handlerExecute.bind(null, record),
  124. },
  125. },
  126. {
  127. label: '编辑',
  128. onClick: handleEdit.bind(null, record),
  129. },
  130. {
  131. label: '删除',
  132. popConfirm: {
  133. title: '是否确认删除',
  134. confirm: handleDelete.bind(null, record),
  135. },
  136. },
  137. ];
  138. }
  139. /**
  140. * 新增事件
  141. */
  142. function handleAdd() {
  143. openModal(true, {
  144. isUpdate: false,
  145. });
  146. }
  147. /**
  148. * 编辑事件
  149. */
  150. function handleEdit(record) {
  151. openModal(true, {
  152. record,
  153. isUpdate: true,
  154. });
  155. }
  156. /**
  157. * 删除事件
  158. */
  159. async function handleDelete(record) {
  160. await deleteQuartz({ id: record.id }, reload);
  161. }
  162. /**
  163. * 立即执行
  164. */
  165. async function handlerExecute(record) {
  166. await executeImmediately({ id: record.id }, reload);
  167. }
  168. /**
  169. * 暂停
  170. */
  171. async function handlerPause(record) {
  172. await pauseJob({ id: record.id }, reload);
  173. }
  174. /**
  175. * 启动
  176. */
  177. async function handlerResume(record) {
  178. // if (record.ntype === 'dataCenter') {
  179. console.log(record.ntype, '类型');
  180. // await collectJob({ id: record.id }, reload);
  181. // } else await resumeJob({ id: record.id }, reload);
  182. }
  183. /**
  184. * 批量删除事件
  185. */
  186. async function batchHandleDelete() {
  187. await batchDeleteQuartz({ ids: selectedRowKeys.value }, reload);
  188. }
  189. </script>