reportManage.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="statistics-center-report-manage-container layout-padding">
  3. <div class="layout-padding-auto layout-padding-view pd20">
  4. <ProTable
  5. ref="proTableRef"
  6. :columns="columns"
  7. :data="state.tableData"
  8. @updateTable="queryList"
  9. :loading="state.loading"
  10. :total="state.total"
  11. v-model:page-index="state.queryParams.PageIndex"
  12. v-model:page-size="state.queryParams.PageSize"
  13. >
  14. <template #table-search>
  15. <el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent inline>
  16. <el-form-item prop="crTime">
  17. <statistical-time v-model="state.queryParams.crTime" @change="handleQuery" ref="statisticalTimeRef"/>
  18. </el-form-item>
  19. <el-form-item label="报告名称" prop="AnalysisName">
  20. <el-input v-model="state.queryParams.AnalysisName" placeholder="报告名称" clearable @keyup.enter="handleQuery" class="keyword-input" />
  21. </el-form-item>
  22. <el-form-item label="">
  23. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  24. <el-button @click="resetQuery(ruleFormRef)" class="default-button" :loading="state.loading">
  25. <SvgIcon name="ele-Refresh" class="mr5" />重置
  26. </el-button>
  27. </el-form-item>
  28. </el-form>
  29. </template>
  30. <template #title="{ row }">
  31. <order-detail :order="row" @updateList="queryList">{{ row.title }}</order-detail>
  32. </template>
  33. <template #operation="{ row }">
  34. <el-button type="primary" link @click="viewEvent(row)">查看预警事件</el-button>
  35. <el-button type="primary" link @click="viewReport(row)">查看报告</el-button>
  36. <el-button type="primary" link @click="deleteReport(row)">删除</el-button>
  37. </template>
  38. </ProTable>
  39. </div>
  40. <el-dialog title="预警事件明细" v-model="state.eventDialogVisible" draggable destroy-on-close append-to-body>
  41. <ProTable
  42. :columns="eventColumns"
  43. :data="state.eventTableData"
  44. :toolButton="false"
  45. :loading="state.eventLoading"
  46. :total="state.eventTotal"
  47. v-model:page-index="state.queryEvent.PageIndex"
  48. v-model:page-size="state.queryEvent.PageSize"
  49. max-height="400px"
  50. @updateTable="queryEventList"
  51. >
  52. <template #title="{ row }">
  53. <order-detail :order="row" @updateList="queryList">{{ row.title }}</order-detail>
  54. </template>
  55. </ProTable>
  56. </el-dialog>
  57. </div>
  58. </template>
  59. <script setup lang="tsx" name="statisticsCenterReportManage">
  60. import { onMounted, reactive, ref, defineAsyncComponent } from 'vue';
  61. import { ElMessageBox, FormInstance, ElMessage } from 'element-plus';
  62. import { centerAnalysisReportDetail, centerAnalysisReportList, centerDeleteAnalysisReport } from '@/api/statistics/center';
  63. import { defaultDate } from '@/utils/constants';
  64. import Other from '@/utils/other';
  65. import { formatDate } from '@/utils/formatTime';
  66. import router from '@/router';
  67. // 引入组件
  68. const OrderDetail = defineAsyncComponent(() => import('@/components/OrderDetail/index.vue')); // 工单详情
  69. const StatisticalTime = defineAsyncComponent(() => import('@/components/StatisticalTime/index.vue')); // 日期类型选择组件
  70. // 表格配置项
  71. const columns = ref<any[]>([
  72. { prop: 'analysisName', label: '报告名称', minWidth: 140 },
  73. { prop: 'remark', label: '备注', minWidth: 200 },
  74. {
  75. prop: 'generatedTime',
  76. label: '生成时间',
  77. minWidth: 160,
  78. render: (scope) => {
  79. return <span>{formatDate(scope.row?.generatedTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  80. },
  81. },
  82. { prop: 'operation', label: '操作', fixed: 'right', width: 240, align: 'center' },
  83. ]);
  84. //
  85. const eventColumns = ref<any[]>([
  86. { prop: 'no', label: '工单编码' },
  87. { prop: 'title', label: '工单标题', minWidth: 200 },
  88. { prop: 'acceptType', label: '受理类型' },
  89. { prop: 'hotspotName', label: '热点分类' },
  90. { prop: 'fullAddress', label: '事发地址' },
  91. ]);
  92. // 定义变量内容
  93. const ruleFormRef = ref<RefType>(); // 表单ref
  94. const state = reactive<any>({
  95. queryParams: {
  96. // 查询条件
  97. PageIndex: 1,
  98. PageSize: 20,
  99. AnalysisName: null, // 关键词
  100. crTime: defaultDate, // 生成时间
  101. GeneratedStartTime: null,
  102. GeneratedEndTime: null,
  103. },
  104. tableData: [], //表单
  105. loading: false, // 加载
  106. total: 0, // 总数
  107. eventDialogVisible: false,
  108. eventLoading: false,
  109. eventTotal: 0,
  110. queryEvent: {
  111. PageIndex: 1,
  112. PageSize: 10,
  113. AnalysisId: null,
  114. },
  115. eventTableData: [],
  116. });
  117. /** 搜索按钮操作 */
  118. const handleQuery = () => {
  119. state.queryParams.PageIndex = 1;
  120. queryList();
  121. };
  122. /** 获取列表 */
  123. const requestParams = ref<EmptyObjectType>({});
  124. const queryList = () => {
  125. state.loading = true;
  126. requestParams.value = Other.deepClone(state.queryParams);
  127. requestParams.value.GeneratedStartTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[0];
  128. requestParams.value.GeneratedEndTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[1];
  129. Reflect.deleteProperty(requestParams.value, 'crTime');
  130. centerAnalysisReportList(requestParams.value)
  131. .then((res: any) => {
  132. state.tableData = res.result?.items ?? [];
  133. state.total = res.result?.total ?? 0;
  134. state.loading = false;
  135. })
  136. .catch(() => {
  137. state.loading = false;
  138. });
  139. };
  140. /** 重置按钮操作 */
  141. const statisticalTimeRef = ref<RefType>();
  142. const resetQuery = (formEl: FormInstance | undefined) => {
  143. if (!formEl) return;
  144. formEl.resetFields();
  145. statisticalTimeRef.value.reset();
  146. queryList();
  147. };
  148. // 查看预警事件
  149. const viewEvent = (row: any) => {
  150. state.queryEvent.AnalysisId = row.analysisId;
  151. queryEventList();
  152. };
  153. const queryEventList = () => {
  154. state.eventDialogVisible = true;
  155. state.eventLoading = true;
  156. centerAnalysisReportDetail(state.queryEvent)
  157. .then((res: any) => {
  158. state.eventTableData = res.result?.items ?? [];
  159. state.eventTotal = res.result?.total ?? 0;
  160. state.eventLoading = false;
  161. })
  162. .catch(() => {
  163. state.eventLoading = false;
  164. });
  165. };
  166. // 查看报告
  167. const viewReport = (row: any) => {
  168. router.push({
  169. name: 'statisticsCenterDetailReport',
  170. params: {
  171. id: row.analysisId
  172. },
  173. });
  174. };
  175. // 删除报告
  176. const deleteReport = (row: any) => {
  177. ElMessageBox.confirm('确定删除该报告吗?', '提示', {
  178. confirmButtonText: '确定',
  179. cancelButtonText: '取消',
  180. type: 'warning',
  181. })
  182. .then(() => {
  183. centerDeleteAnalysisReport({ analysisIds: [row.analysisId] })
  184. .then(() => {
  185. ElMessage({
  186. type: 'success',
  187. message: '删除成功',
  188. });
  189. queryList();
  190. })
  191. .catch(() => {
  192. queryList();
  193. });
  194. })
  195. .catch(() => {});
  196. };
  197. onMounted(() => {
  198. queryList();
  199. });
  200. </script>