Form.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <div class="report-list">
  3. <BasicTable
  4. :columns="reportDataCol"
  5. :data-source="formList"
  6. :row-key="(row) => row.id"
  7. :action-column="actionColumn"
  8. :tableSetting="{
  9. size: false,
  10. redo: false,
  11. fullscreen: false,
  12. striped: false,
  13. setting: false,
  14. }"
  15. :striped="true"
  16. ref="tableRef"
  17. >
  18. <template #tableTitle>
  19. <el-button type="primary" :icon="Plus" @click="CreateReport(type)" v-permission="{ action: [PERM_NOTICE.REPORT_ADD] }" >新建报表配置</el-button>
  20. </template>
  21. <template #empty>
  22. <div class="empty-content flex flex-col items-center">
  23. <span class="empty-text">暂无数据</span>
  24. </div>
  25. </template>
  26. </BasicTable>
  27. <el-dialog
  28. v-model="logFormVisible"
  29. title="推送记录"
  30. width="800"
  31. align-center
  32. :close-on-click-modal="false"
  33. :destroy-on-close="true"
  34. >
  35. <LogForm :statisticType="statisticType" />
  36. </el-dialog>
  37. </div>
  38. </template>
  39. <script lang="ts" setup>
  40. import { h, ref, reactive, watch, onUnmounted } from 'vue';
  41. import { BasicTable, TableActionIcons, BasicColumn } from '@/components/Table';
  42. import { reportDataCol } from '../overviewColumns';
  43. import { Plus } from '@element-plus/icons-vue';
  44. import logIcon from '@/assets/icons/log.svg';
  45. import viewIcon from '@/assets/icons/view.svg';
  46. import editIcon from '@/assets/icons/edit.svg';
  47. import deleteIcon from '@/assets/icons/delete.svg';
  48. import { ElMessage, ElMessageBox } from 'element-plus';
  49. import LogForm from './LogForm.vue';
  50. import { storeToRefs } from 'pinia';
  51. import useFormList from '../store/useFormList';
  52. import { deleteReportConfig } from '@/api/message/report-message';
  53. import { PERM_NOTICE } from '@/types/permission/constants';
  54. import { useUserStore } from '@/store/modules/user';
  55. const userStore = useUserStore();
  56. const formStore = useFormList();
  57. const { getForm } = formStore;
  58. const { type, formList } = storeToRefs(formStore);
  59. const logFormVisible = ref(false);
  60. const actionColumn: BasicColumn = reactive({
  61. width: 224,
  62. title: '操作',
  63. prop: 'action',
  64. key: 'action',
  65. fixed: 'right',
  66. render(record) {
  67. return h(TableActionIcons as any, {
  68. space: 20,
  69. color: '#629bf9',
  70. iconStyle: 'img',
  71. size: 16,
  72. actionIcons: [
  73. {
  74. label: '推送记录',
  75. icon: logIcon,
  76. onClick: handleLog.bind(null, record.row),
  77. },
  78. {
  79. label: '查看',
  80. icon: viewIcon,
  81. onClick: handleView.bind(null, record.row),
  82. },
  83. {
  84. label: '编辑',
  85. icon: editIcon,
  86. onClick: handleEdit.bind(null, record.row),
  87. ifShow: userStore.checkPermission(PERM_NOTICE.REPORT_EDIT)
  88. },
  89. {
  90. label: '删除',
  91. icon: deleteIcon,
  92. onClick: handleDelete.bind(null, record.row),
  93. ifShow: userStore.checkPermission(PERM_NOTICE.REPORT_DELETE)
  94. },
  95. ],
  96. });
  97. },
  98. });
  99. import { useRouter } from 'vue-router';
  100. const router = useRouter();
  101. const CreateReport = (type) => {
  102. router.push(`/message/report-config?type=${type}&operationType=1`);
  103. };
  104. const statisticType = ref<number>(0);
  105. const handleLog = (record: Recordable) => {
  106. logFormVisible.value = true;
  107. statisticType.value = record.statisticType;
  108. };
  109. const handleView = (record: Recordable) => {
  110. router.push(`/message/report-config?type=${type.value}&statisticType=${record.statisticType}&operationType=2`
  111. );
  112. };
  113. const handleEdit = (record: Recordable) => {
  114. router.push(
  115. `/message/report-config?type=${type.value}&statisticType=${record.statisticType}&operationType=3`,
  116. );
  117. };
  118. const handleDelete = (record: Recordable) => {
  119. ElMessageBox.confirm('删除之后,这条数据无法恢复', '请确认是否删除', {
  120. confirmButtonText: '确定',
  121. cancelButtonText: '取消',
  122. type: 'warning',
  123. })
  124. .then(() => {
  125. deleteReportConfig(type.value, record.statisticType).then(() => {
  126. ElMessage.success('删除成功');
  127. getForm(type.value);
  128. });
  129. })
  130. .catch(() => {});
  131. };
  132. onUnmounted(() => {
  133. type.value = 1;
  134. formList.value = [];
  135. });
  136. watch(
  137. type,
  138. (newType) => {
  139. getForm(newType);
  140. },
  141. { immediate: true },
  142. );
  143. </script>
  144. <style lang="scss" scoped>
  145. .report-list {
  146. position: relative;
  147. width: 100%;
  148. }
  149. ::v-deep .el-dialog__body {
  150. height: 600px;
  151. }
  152. </style>