index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <script lang="ts" setup name="GroupCatIndex">
  2. import { ElMessage, ElMessageBox } from 'element-plus'
  3. import JobComponent from './components/JobClass.vue'
  4. import { deleteJobClassById, getJobClassByList } from '@/api/system/jobClassApi'
  5. const state = reactive({
  6. loading: false,
  7. // 表格是否自适应高度
  8. tableAutoHeight: false,
  9. // 搜索
  10. search: {
  11. keywords: '',
  12. },
  13. // 列表数据
  14. dataList: [],
  15. })
  16. const jobRef = ref()
  17. const getData = async () => {
  18. state.loading = true
  19. const { data } = await getJobClassByList(state.search)
  20. state.dataList = data
  21. state.loading = false
  22. }
  23. onMounted(() => {
  24. getData()
  25. })
  26. function onJobAdd() {
  27. jobRef.value.showAddModel()
  28. }
  29. function onJobClassEdit(row: any) {
  30. const jobClassId = row.jobClassId
  31. jobRef.value.showEditModel(jobClassId)
  32. }
  33. function onJobClassDel(row: any) {
  34. const { jobClassId, jobClassTitle } = row
  35. ElMessageBox.confirm(`确认删除「${jobClassTitle}」吗?`, '确认信息').then(async () => {
  36. const { msg } = await deleteJobClassById(jobClassId)
  37. ElMessage.success(msg)
  38. await getData()
  39. }).catch(() => {})
  40. }
  41. </script>
  42. <template>
  43. <div :class="{ 'absolute-container': state.tableAutoHeight }">
  44. <page-header title="系统作业">
  45. <template #content>
  46. <div>
  47. 系统支持设定定时器作业
  48. </div>
  49. </template>
  50. <el-button-group>
  51. <el-button type="primary" size="large" @click="onJobAdd">
  52. <template #icon>
  53. <el-icon>
  54. <svg-icon name="ep:plus" />
  55. </el-icon>
  56. </template>
  57. 新增
  58. </el-button>
  59. </el-button-group>
  60. </page-header>
  61. <page-main>
  62. <el-table v-loading="state.loading" class="list-table" :data="state.dataList" border stripe highlight-current-row height="100%">
  63. <el-table-column type="index" label="序号" width="60" header-align="center" align="center" />
  64. <el-table-column label="类名称" align="center">
  65. <template #default="scope">
  66. <span>{{ scope.row.jobClassTitle }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="JOB Class" align="center" width="300">
  70. <template #default="scope">
  71. <span>{{ scope.row.jobClass }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="说明" header-align="left" align="left">
  75. <template #default="scope">
  76. <span>{{ scope.row.jobClassDesc }}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="操作" width="250" align="center" fixed="right">
  80. <template #default="scope">
  81. <el-button type="primary" size="small" plain @click="onJobClassEdit(scope.row)">
  82. 编辑
  83. </el-button>
  84. <el-button v-if="!scope.row.isFixed" type="danger" size="small" plain @click="onJobClassDel(scope.row)">
  85. 删除
  86. </el-button>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. </page-main>
  91. <JobComponent ref="jobRef" @success="getData" />
  92. </div>
  93. </template>
  94. <style lang="scss" scoped>
  95. .absolute-container {
  96. position: absolute;
  97. width: 100%;
  98. height: 100%;
  99. display: flex;
  100. flex-direction: column;
  101. .page-header {
  102. margin-bottom: 0;
  103. }
  104. .page-main {
  105. // 让 page-main 的高度自适应
  106. flex: 1;
  107. overflow: auto;
  108. display: flex;
  109. flex-direction: column;
  110. .search-container {
  111. margin-bottom: 0;
  112. }
  113. }
  114. }
  115. </style>