frequentlyEvent.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="statistics-center-frequently-event-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 label-width="100px">
  16. <el-row :gutter="10">
  17. <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  18. <el-form-item label="受理时间" prop="crTime">
  19. <el-date-picker
  20. v-model="state.queryParams.crTime"
  21. type="daterange"
  22. unlink-panels
  23. range-separator="至"
  24. start-placeholder="开始时间"
  25. end-placeholder="结束时间"
  26. :shortcuts="shortcuts"
  27. @change="handleQuery"
  28. value-format="YYYY-MM-DD"
  29. :clearable="false"
  30. />
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  34. <el-form-item label="受理类型" prop="AcceptType">
  35. <el-select v-model="state.queryParams.AcceptType" placeholder="请选择受理类型" clearable class="w100" @change="handleQuery">
  36. <el-option v-for="item in acceptTypeOptions" :value="item.dicDataValue" :key="item.dicDataValue" :label="item.dicDataName" />
  37. </el-select>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  41. <el-form-item label="热点分类" prop="Hotspot">
  42. <el-input v-model="state.queryParams.Hotspot" placeholder="热点分类名称" clearable @keyup.enter="handleQuery" />
  43. </el-form-item>
  44. </el-col>
  45. <transition name="el-zoom-in-top" v-show="!searchCol">
  46. <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  47. <el-form-item label="事发地址" prop="AreaCode">
  48. <el-cascader
  49. :options="areaOptions"
  50. filterable
  51. :props="{ checkStrictly: true, value: 'id', label: 'areaName',emitPath:false }"
  52. placeholder="请选择事发地址"
  53. clearable
  54. class="w100"
  55. v-model="state.queryParams.AreaCode"
  56. @change="handleQuery"
  57. ref="areaRef"
  58. >
  59. </el-cascader>
  60. </el-form-item>
  61. </el-col>
  62. </transition>
  63. <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  64. <el-form-item label=" ">
  65. <div class="flex-end w100">
  66. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  67. <el-button @click="resetQuery(ruleFormRef)" class="default-button" :loading="state.loading">
  68. <SvgIcon name="ele-Refresh" class="mr5" />重置
  69. </el-button>
  70. <el-button link type="primary" @click="closeSearch" :loading="state.loading">
  71. {{ searchCol ? '展开' : '收起' }}
  72. <SvgIcon :class="{ 'is-reverse': searchCol }" name="ele-ArrowUp" class="mr5 arrow" size="18px" />
  73. </el-button>
  74. </div>
  75. </el-form-item>
  76. </el-col>
  77. </el-row>
  78. </el-form>
  79. </template>
  80. <template #tableHeader="scope">
  81. <el-button type="primary" @click="onAnalysis" :disabled="!scope.isSelected">
  82. <SvgIcon name="ele-Document" class="mr5" />生成分析报告
  83. </el-button>
  84. </template>
  85. </ProTable>
  86. </div>
  87. <el-dialog v-model="state.dialogVisible" width="600px" draggable title="生成分析报告" @close="close" destroy-on-close>
  88. <el-form :model="state.ruleForm" label-width="100px" ref="ruleFormRef">
  89. <el-form-item label="报告名称" prop="employee" :rules="[{ required: true, message: '请填写报告名称', trigger: 'blur' }]">
  90. <el-input placeholder="请填写报告名称" v-model="state.ruleForm.employee"/>
  91. </el-form-item>
  92. <el-form-item label="备注" prop="remark" :rules="[{ required: false, message: '请填写备注', trigger: 'blur' }]">
  93. <el-input type="textarea" placeholder="请填写备注" v-model="state.ruleForm.remark"/>
  94. </el-form-item>
  95. </el-form>
  96. <template #footer>
  97. <span class="dialog-footer">
  98. <el-button @click="state.dialogVisible = false" class="default-button">取 消</el-button>
  99. <el-button type="primary" @click="onSubmit(ruleFormRef)" :loading="state.loading">确 定</el-button>
  100. </span>
  101. </template>
  102. </el-dialog>
  103. </div>
  104. </template>
  105. <script setup lang="tsx" name="statisticsCenterFrequentlyEvent">
  106. import { onMounted, reactive, ref } from 'vue';
  107. import { ElMessageBox, FormInstance } from 'element-plus';
  108. import { defaultDate, shortcuts } from '@/utils/constants';
  109. import { treeArea } from '@/api/auxiliary/area';
  110. import { departmentHighFrequencyEvent } from '@/api/statistics/center';
  111. import { useRouter } from 'vue-router';
  112. import Other from '@/utils/other';
  113. import { throttle } from '@/utils/tools';
  114. import { returnBase } from '@/api/business/return';
  115. const proTableRef = ref<RefType>(); // 表格ref
  116. // 表格配置项
  117. const columns = ref<any[]>([
  118. { type: 'selection', fixed: 'left', width: 40, align: 'center' },
  119. { prop: 'areaName', label: '事发地址' },
  120. { prop: 'title', label: '标题' },
  121. { prop: 'acceptType', label: '受理类型' },
  122. { prop: 'hotspotName', label: '热点分类' },
  123. {
  124. prop: 'sumCount',
  125. label: '预警次数',
  126. render: (scope) => {
  127. return (
  128. <el-button type="primary" link onClick={() => linkDetail(scope.row)}>
  129. {scope.row.sumCount}
  130. </el-button>
  131. );
  132. },
  133. },
  134. ]);
  135. // 定义变量内容
  136. const ruleFormRef = ref<RefType>(); // 表单ref
  137. const state = reactive<any>({
  138. queryParams: {
  139. // 查询条件
  140. AreaCode: null, // 事发地址
  141. AcceptType: null, // 受理类型
  142. Hotspot: null, // 热点分类
  143. crTime: defaultDate,
  144. StartTime: null,
  145. EndTime: null,
  146. PageIndex: 1,
  147. PageSize: 20,
  148. },
  149. tableData: [], //表单
  150. loading: false, // 加载
  151. total: 0, // 总数
  152. dialogVisible:false, // 弹框
  153. ruleForm:{
  154. employee:null,
  155. remark:null
  156. }
  157. });
  158. // 展开/收起
  159. const searchCol = ref(true); // 展开/收起
  160. const closeSearch = () => {
  161. searchCol.value = !searchCol.value;
  162. };
  163. // 基础信息
  164. const acceptTypeOptions = ref([]); // 受理类型
  165. const areaOptions = ref([]); // 事发地址
  166. const getBaseData = async () => {
  167. const [acceptType, area] = await Promise.all([returnBase(), treeArea()]);
  168. acceptTypeOptions.value = acceptType.result?.acceptTypeOptions;
  169. areaOptions.value = area.result ?? [];
  170. };
  171. /** 搜索按钮操作 */
  172. const handleQuery = () => {
  173. state.queryParams.PageIndex = 1;
  174. queryList();
  175. };
  176. /** 获取列表 */
  177. const queryList = () => {
  178. state.loading = true;
  179. let request = Other.deepClone(state.queryParams);
  180. request.StartTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[0];
  181. request.EndTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[1];
  182. Reflect.deleteProperty(request, 'crTime');
  183. departmentHighFrequencyEvent(request)
  184. .then((res: any) => {
  185. state.tableData = res.result?.items ?? [];
  186. state.total = res.result?.total ?? 0;
  187. state.loading = false;
  188. })
  189. .catch(() => {
  190. state.loading = false;
  191. });
  192. };
  193. /** 重置按钮操作 */
  194. const resetQuery = (formEl: FormInstance | undefined) => {
  195. if (!formEl) return;
  196. formEl.resetFields();
  197. queryList();
  198. };
  199. // 查看详情
  200. const router = useRouter();
  201. const linkDetail = (row: any) => {
  202. const StartTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[0];
  203. const EndTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[1];
  204. router.push({
  205. name: 'eventFrequentlyDetail',
  206. query: {
  207. StartTime,
  208. EndTime,
  209. HotspotId: row.hotspotId,
  210. AreaCode: row.areaCode,
  211. AcceptTypeCode: row.acceptTypeCode,
  212. id: row.id,
  213. },
  214. });
  215. };
  216. // 生成分析报告
  217. const onAnalysis = () => {
  218. state.dialogVisible = true;
  219. };
  220. const close = ()=>{
  221. ruleFormRef.value?.clearValidate();
  222. ruleFormRef.value?.resetFields();
  223. }
  224. const onSubmit = throttle((formEl: FormInstance | undefined) => {
  225. if (!formEl) return;
  226. formEl.validate((valid: boolean) => {
  227. if (!valid) return;
  228. state.dialogVisible = false;
  229. ElMessageBox.confirm('分析报告已提交,可进入【报告管理】进行查看和下载','提示',{
  230. autofocus: false,
  231. draggable: true,
  232. type: 'success',
  233. showClose:false,
  234. distinguishCancelAndClose: true,
  235. confirmButtonText: '查看报告',
  236. cancelButtonText: '我知道了',
  237. }) .then(() => {
  238. queryList();
  239. router.push({
  240. path:'/statistics/center/reportManage'
  241. })
  242. })
  243. .catch(() => {
  244. queryList();
  245. })
  246. });
  247. }, 300);
  248. onMounted(() => {
  249. getBaseData();
  250. queryList();
  251. });
  252. </script>
  253. <style scoped lang="scss">
  254. .statistics-center-frequently-event-container {
  255. .arrow {
  256. transition: transform var(--el-transition-duration);
  257. cursor: pointer;
  258. }
  259. .arrow.is-reverse {
  260. transform: rotateZ(-180deg);
  261. }
  262. }
  263. </style>