Form.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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)">新建报表配置</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. const formStore = useFormList();
  54. const { getForm } = formStore;
  55. const { type, formList } = storeToRefs(formStore);
  56. const logFormVisible = ref(false);
  57. const actionColumn: BasicColumn = reactive({
  58. width: 224,
  59. title: '操作',
  60. prop: 'action',
  61. key: 'action',
  62. fixed: 'right',
  63. render(record) {
  64. return h(TableActionIcons as any, {
  65. space: 20,
  66. color: '#629bf9',
  67. style: 'img',
  68. size: 16,
  69. actionIcons: [
  70. {
  71. label: '推送记录',
  72. icon: logIcon,
  73. onClick: handleLog.bind(null, record.row),
  74. },
  75. {
  76. label: '查看',
  77. icon: viewIcon,
  78. onClick: handleView.bind(null, record.row),
  79. },
  80. {
  81. label: '编辑',
  82. icon: editIcon,
  83. onClick: handleEdit.bind(null, record.row),
  84. },
  85. {
  86. label: '删除',
  87. icon: deleteIcon,
  88. onClick: handleDelete.bind(null, record.row),
  89. },
  90. ],
  91. });
  92. },
  93. });
  94. import { useRouter } from 'vue-router';
  95. const router = useRouter();
  96. const CreateReport = (type) => {
  97. router.push(`/message/report-config?type=${type}&operationType=1`);
  98. };
  99. const statisticType = ref<number>(0);
  100. const handleLog = (record: Recordable) => {
  101. logFormVisible.value = true;
  102. statisticType.value = record.statisticType;
  103. };
  104. const handleView = (record: Recordable) => {
  105. router.push(`/message/report-config?type=${type.value}&statisticType=${record.statisticType}&operationType=2`
  106. );
  107. };
  108. const handleEdit = (record: Recordable) => {
  109. router.push(
  110. `/message/report-config?type=${type.value}&statisticType=${record.statisticType}&operationType=3`,
  111. );
  112. };
  113. const handleDelete = (record: Recordable) => {
  114. ElMessageBox.confirm('删除之后,这条数据无法恢复', '请确认是否删除', {
  115. confirmButtonText: '确定',
  116. cancelButtonText: '取消',
  117. type: 'warning',
  118. })
  119. .then(() => {
  120. deleteReportConfig(type.value, record.statisticType).then(() => {
  121. ElMessage.success('删除成功');
  122. getForm(type.value);
  123. });
  124. })
  125. .catch(() => {});
  126. };
  127. onUnmounted(() => {
  128. type.value = 1;
  129. formList.value = [];
  130. });
  131. watch(
  132. type,
  133. (newType) => {
  134. getForm(newType);
  135. },
  136. { immediate: true },
  137. );
  138. </script>
  139. <style lang="scss" scoped>
  140. .report-list {
  141. position: relative;
  142. width: 100%;
  143. }
  144. ::v-deep .el-dialog__body {
  145. height: 600px;
  146. }
  147. </style>