index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <ele-page flex-table>
  3. <page-search @search="reload"></page-search>
  4. <common-table ref="pageRef" :pageConfig="pageConfig" :columns="columns">
  5. <template #toolbar>
  6. <el-button type="primary" plain :icon="PlusOutlined" v-permission="'recycle:remindArea:add'"
  7. @click="handleUpdate()">
  8. 新增
  9. </el-button>
  10. <el-button type="danger" plain :icon="DeleteOutlined" v-permission="'recycle:remindArea:batchDelete'"
  11. @click="handleBatchDelete()">
  12. 批量删除
  13. </el-button>
  14. </template>
  15. <template #action="{ row }">
  16. <div>
  17. <el-button type="primary" link v-permission="'recycle:remindArea:update'"
  18. @click="handleUpdate(row)">
  19. 编辑
  20. </el-button>
  21. <el-button type="danger" link v-permission="'recycle:remindArea:delete'" @click="handleDelete(row)">
  22. 删除
  23. </el-button>
  24. <el-button :type="row.useStatus == 2 ? 'success' : 'warning'" link
  25. v-permission="'recycle:remindArea:changeStatus'" @click="handleChangeStatus(row)">
  26. {{ row.useStatus == 2 ? '启用' : '停用' }}
  27. </el-button>
  28. </div>
  29. </template>
  30. </common-table>
  31. <page-edit ref="editRef" @success="reload()"></page-edit>
  32. </ele-page>
  33. </template>
  34. <script setup>
  35. import { ref, reactive, getCurrentInstance } from 'vue';
  36. import { PlusOutlined, DeleteOutlined } from '@/components/icons';
  37. import CommonTable from '@/components/CommonPage/CommonTable.vue';
  38. import pageSearch from './components/page-search.vue';
  39. import pageEdit from './components/page-edit.vue';
  40. import { useDictData } from '@/utils/use-dict-data';
  41. import request from '@/utils/request';
  42. const { proxy } = getCurrentInstance();
  43. defineOptions({ name: 'remindArea' });
  44. /** 表格列配置 */
  45. const columns = ref([
  46. {
  47. type: 'selection',
  48. columnKey: 'selection',
  49. width: 50,
  50. align: 'center',
  51. fixed: 'left'
  52. },
  53. {
  54. label: '提醒地区',
  55. prop: 'areaInfo',
  56. align: 'center',
  57. },
  58. { label: '推送人', prop: 'createName', align: 'center' },
  59. {
  60. label: '状态',
  61. prop: 'schoolLevel',
  62. align: 'center',
  63. formatter: (row) => "生效中"
  64. },
  65. { label: '添加时间', prop: 'createTime', align: 'center' },
  66. {
  67. columnKey: 'action',
  68. label: '操作',
  69. width: 240,
  70. align: 'center',
  71. slot: 'action'
  72. }
  73. ]);
  74. /** 页面组件实例 */
  75. const pageRef = ref(null);
  76. const pageConfig = reactive({
  77. pageUrl: '/book/checkWarn/getAreaPageList',
  78. exportUrl: '',
  79. fileName: '审核提醒地区',
  80. cacheKey: 'remindAreaTable'
  81. });
  82. //刷新表格
  83. function reload(where) {
  84. delete where.time;
  85. pageRef.value?.reload(where);
  86. }
  87. //批量删除
  88. function handleBatchDelete(row) {
  89. let selections = row ? [row] : pageRef.value?.getSelections();
  90. let ids = selections.map((item) => item.id);
  91. let url = `/book/checkWarn/deleteCheckWarnArea`;
  92. pageRef.value?.operatBatch({
  93. title: '确认删除?',
  94. method: 'post',
  95. url,
  96. row,
  97. data: {
  98. idList: ids
  99. }
  100. });
  101. }
  102. //启用停用
  103. function handleChangeStatus(row) {
  104. let message = row.useStatus == 1 ? '确认停用?' : '确认启用?';
  105. let data = {
  106. id: row.id,
  107. useStatus: row.useStatus == 1 ? 2 : 1
  108. }
  109. pageRef.value?.messageBoxConfirm({
  110. message,
  111. fetch: () => request.post('/book/checkWarn/setAreaStatus', data)
  112. });
  113. }
  114. //删除
  115. function handleDelete(row){
  116. pageRef.value?.messageBoxConfirm({
  117. message: '确认删除?',
  118. fetch: () => proxy.$http.post(`/book/checkWarn/deleteCheckWarnArea`, { idList: [row.id] })
  119. });
  120. }
  121. //编辑页面
  122. const editRef = ref(null);
  123. function handleUpdate(row) {
  124. editRef.value?.handleOpen(row);
  125. }
  126. </script>