LwarningDisp.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. <template>
  2. <div class="app-container warning-disposal-page" v-loading="loading">
  3. <el-card shadow="never" class="page-card header-card">
  4. <div class="page-header">
  5. <div>
  6. <div class="page-title">预警处置</div>
  7. </div>
  8. <el-button type="primary" icon="Refresh" @click="loadList">刷新</el-button>
  9. </div>
  10. </el-card>
  11. <el-card shadow="never" class="page-card">
  12. <el-form :model="queryParams" :inline="true">
  13. <el-form-item label="预警编号">
  14. <el-input v-model="queryParams.warningNo" placeholder="请输入预警编号" clearable style="width: 220px" @keyup.enter="handleQuery" />
  15. </el-form-item>
  16. <el-form-item label="预警类型">
  17. <el-select v-model="queryParams.warningType" clearable placeholder="请选择预警类型" style="width: 180px">
  18. <el-option
  19. v-for="item in warningTypeOptions"
  20. :key="item.dictValue"
  21. :label="item.dictLabel"
  22. :value="item.dictValue"
  23. />
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="预警级别">
  27. <el-select v-model="queryParams.warningLevel" clearable placeholder="请选择预警级别" style="width: 180px">
  28. <el-option
  29. v-for="item in warningLevelOptions"
  30. :key="item.dictValue"
  31. :label="item.dictLabel"
  32. :value="item.dictValue"
  33. />
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="状态">
  37. <el-select v-model="queryParams.status" clearable placeholder="请选择状态" style="width: 180px">
  38. <el-option v-for="item in warningStatusOptions" :key="item.value" :label="item.label" :value="item.value" />
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item label="处置人">
  42. <el-input v-model="queryParams.handler" placeholder="请输入处置人" clearable style="width: 180px" />
  43. </el-form-item>
  44. <el-form-item label="设备编码">
  45. <el-input v-model="queryParams.deviceCode" placeholder="请输入设备编码" clearable style="width: 180px" />
  46. </el-form-item>
  47. <el-form-item label="发布时间">
  48. <el-date-picker
  49. v-model="queryParams.dateRange"
  50. type="datetimerange"
  51. value-format="YYYY-MM-DD HH:mm:ss"
  52. range-separator="至"
  53. start-placeholder="开始时间"
  54. end-placeholder="结束时间"
  55. style="width: 360px"
  56. />
  57. </el-form-item>
  58. <el-form-item>
  59. <el-button type="primary" icon="Search" @click="handleQuery">查询</el-button>
  60. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  61. </el-form-item>
  62. </el-form>
  63. </el-card>
  64. <el-card shadow="never" class="page-card">
  65. <el-table :data="warningList">
  66. <el-table-column label="序号" width="70" align="center">
  67. <template #default="scope">
  68. {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="预警编号" prop="warningNo" width="170" />
  72. <el-table-column label="预警类型" prop="warningTypeText" width="120" />
  73. <el-table-column label="预警级别" width="110" align="center">
  74. <template #default="scope">
  75. <el-tag :type="getLevelTagType(scope.row.warningLevel)">
  76. {{ scope.row.warningLevelText }}
  77. </el-tag>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="处置人" prop="handler" width="120" />
  81. <el-table-column label="设备名称" prop="deviceName" min-width="140" show-overflow-tooltip />
  82. <el-table-column label="设备编码" prop="deviceCode" width="160" show-overflow-tooltip />
  83. <el-table-column label="发布人" prop="publisher" width="120" />
  84. <el-table-column label="权属单位" prop="ownershipUnit" width="160" show-overflow-tooltip />
  85. <el-table-column label="状态" width="120" align="center">
  86. <template #default="scope">
  87. <el-tag :type="getStatusTagType(scope.row.status)">
  88. {{ getStatusText(scope.row.status) }}
  89. </el-tag>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="发布时间" width="180">
  93. <template #default="scope">{{ formatDateTime(scope.row.publishTime) }}</template>
  94. </el-table-column>
  95. <el-table-column label="操作" fixed="right" width="330" align="center">
  96. <template #default="scope">
  97. <el-button link type="primary" @click="openDetail(scope.row)">详情</el-button>
  98. <el-button v-if="canReview(scope.row)" v-hasPermi="['warning:warning:handle']" link type="success" @click="openResolve(scope.row)">核查解除</el-button>
  99. <el-button v-if="canUpgrade(scope.row)" v-hasPermi="['warning:warning:handle']" link type="warning" @click="openUpgrade(scope.row)">升级</el-button>
  100. <el-button v-if="canManage(scope.row)" v-hasPermi="['warning:warning:supervision']" link type="primary" @click="openSupervision(scope.row)">督办</el-button>
  101. <el-button v-if="canManage(scope.row)" v-hasPermi="['warning:warning:instruction']" link type="info" @click="openInstruction(scope.row)">批示</el-button>
  102. <el-button v-if="canReview(scope.row)" v-hasPermi="['warning:warning:handle']" link type="danger" @click="openReturn(scope.row)">退回</el-button>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. <pagination
  107. v-show="total > 0"
  108. :total="total"
  109. v-model:page="queryParams.pageNum"
  110. v-model:limit="queryParams.pageSize"
  111. @pagination="loadList"
  112. />
  113. </el-card>
  114. <el-drawer v-model="detailVisible" title="预警详情" size="820px" append-to-body direction="rtl" class="detail-drawer">
  115. <template v-if="detailData.basicInfo">
  116. <WarningItemSummary :warning="detailData.basicInfo" />
  117. <el-descriptions :column="2" border>
  118. <el-descriptions-item label="预警编号">{{ detailBasic.warningNo || "-" }}</el-descriptions-item>
  119. <el-descriptions-item label="预警专项">{{ detailBasic.warningSpecial || "-" }}</el-descriptions-item>
  120. <el-descriptions-item label="预警类型">{{ detailBasic.warningTypeText || "-" }}</el-descriptions-item>
  121. <el-descriptions-item label="预警级别">{{ detailBasic.warningLevelText || "-" }}</el-descriptions-item>
  122. <el-descriptions-item label="状态">{{ getStatusText(detailBasic.status) }}</el-descriptions-item>
  123. <el-descriptions-item label="处置人">{{ detailBasic.handler || "-" }}</el-descriptions-item>
  124. <el-descriptions-item label="设备名称">{{ detailBasic.deviceName || "-" }}</el-descriptions-item>
  125. <el-descriptions-item label="设备编码">{{ detailBasic.deviceCode || "-" }}</el-descriptions-item>
  126. <el-descriptions-item label="发布人">{{ detailBasic.publisher || "-" }}</el-descriptions-item>
  127. <el-descriptions-item label="核查人">{{ detailBasic.reviewer || detailBasic.publisher || "-" }}</el-descriptions-item>
  128. <el-descriptions-item label="权属单位">{{ detailBasic.ownershipUnit || "-" }}</el-descriptions-item>
  129. <el-descriptions-item label="发布时间">{{ formatDateTime(detailBasic.publishTime) }}</el-descriptions-item>
  130. <el-descriptions-item label="预警内容" :span="2"><span class="warning-content">{{ detailBasic.warningContent || "-" }}</span></el-descriptions-item>
  131. </el-descriptions>
  132. <el-divider content-position="left">处置记录</el-divider>
  133. <el-timeline v-if="(detailData.disposalHistory || []).length">
  134. <el-timeline-item
  135. v-for="(item, index) in detailData.disposalHistory"
  136. :key="index"
  137. :timestamp="formatDateTime(item.createTime || item.create_time || item.disposalTime || item.disposal_time)"
  138. >
  139. {{ item.disposalTypeName || item.disposal_type_name || item.disposalType || item.disposal_type || "处置记录" }}
  140. <span v-if="item.oldLevel || item.old_level">:{{ warningLevelLabelMap[item.oldLevel || item.old_level] || item.oldLevel || item.old_level }} → {{ warningLevelLabelMap[item.newLevel || item.new_level] || item.newLevel || item.new_level }}</span>
  141. <span v-if="item.disposalContent || item.disposal_content || item.content">:{{ item.disposalContent || item.disposal_content || item.content }}</span>
  142. <span v-if="item.disposalUser || item.disposal_user">({{ item.disposalUser || item.disposal_user }})</span>
  143. <WarningDisposalReasons :record="item" />
  144. <WarningAttachments :attachments="attachmentsForDisposal(item, detailData.attachmentList)" />
  145. </el-timeline-item>
  146. </el-timeline>
  147. <el-empty v-else description="暂无处置记录" />
  148. <template v-if="unlinkedWarningAttachments(detailData.disposalHistory, detailData.attachmentList).length">
  149. <el-divider content-position="left">其他预警附件</el-divider>
  150. <WarningAttachments :attachments="unlinkedWarningAttachments(detailData.disposalHistory, detailData.attachmentList)" />
  151. </template>
  152. </template>
  153. </el-drawer>
  154. <el-dialog v-model="resolveVisible" title="预警解除" width="520px" append-to-body>
  155. <el-form label-width="100px">
  156. <el-form-item label="预警编号">
  157. <el-input :model-value="currentRow?.warningNo || '-'" disabled />
  158. </el-form-item>
  159. <el-form-item label="核查说明">
  160. <el-input v-model="resolveForm.disposalContent" type="textarea" :rows="4" placeholder="请输入预警解除说明" />
  161. </el-form-item>
  162. </el-form>
  163. <template #footer>
  164. <el-button @click="resolveVisible = false">取 消</el-button>
  165. <el-button type="primary" :loading="submitLoading" @click="submitResolve">确 定</el-button>
  166. </template>
  167. </el-dialog>
  168. <el-dialog v-model="upgradeVisible" title="预警升级" width="560px" append-to-body>
  169. <el-form label-width="100px">
  170. <el-form-item label="预警编号">
  171. <el-input :model-value="currentRow?.warningNo || '-'" disabled />
  172. </el-form-item>
  173. <el-form-item label="新预警级别">
  174. <el-select v-model="upgradeForm.newLevel" placeholder="请选择新预警级别" style="width: 100%">
  175. <el-option
  176. v-for="item in upgradeLevelOptions"
  177. :key="item.dictValue"
  178. :label="item.dictLabel"
  179. :value="item.dictValue"
  180. />
  181. </el-select>
  182. </el-form-item>
  183. <el-form-item label="升级说明">
  184. <el-input v-model="upgradeForm.disposalContent" type="textarea" :rows="4" placeholder="请输入预警升级说明" />
  185. </el-form-item>
  186. </el-form>
  187. <template #footer>
  188. <el-button @click="upgradeVisible = false">取 消</el-button>
  189. <el-button type="primary" :loading="submitLoading" @click="submitUpgrade">确 定</el-button>
  190. </template>
  191. </el-dialog>
  192. <el-dialog v-model="supervisionVisible" title="预警督办" width="620px" append-to-body>
  193. <el-form label-width="100px">
  194. <el-form-item label="督办人员">
  195. <el-select v-model="supervisionForm.supervisionUser" filterable :filter-method="filterSupervisionUser" placeholder="请选择督办人员" style="width: 100%" :loading="usersLoading">
  196. <el-option v-for="user in filteredEnabledUsers" :key="user.userId" :label="supervisionUserLabel(user)" :value="user.userName">
  197. <span>{{ supervisionUserLabel(user) }}</span>
  198. <span v-if="user.dept?.deptName" class="user-dept">{{ user.dept.deptName }}</span>
  199. </el-option>
  200. </el-select>
  201. <div class="notification-hint">短信和系统通知均发送给此处选定的人员,请选择通知接收人。</div>
  202. </el-form-item>
  203. <el-form-item label="督办意见">
  204. <el-input v-model="supervisionForm.supervisionContent" type="textarea" :rows="3" placeholder="请输入督办意见" />
  205. </el-form-item>
  206. <el-form-item label="通知方式">
  207. <el-select v-model="supervisionForm.notificationType" placeholder="请选择通知方式" style="width: 100%">
  208. <el-option label="短信" value="短信" />
  209. <el-option label="系统通知" value="系统通知" />
  210. </el-select>
  211. </el-form-item>
  212. <el-form-item label="通知内容">
  213. <el-input v-model="supervisionForm.notificationContent" type="textarea" :rows="3" maxlength="180" show-word-limit placeholder="不填时使用督办意见" />
  214. </el-form-item>
  215. <el-form-item label="附件">
  216. <el-upload v-model:file-list="supervisionFiles" :auto-upload="false" :limit="1" :on-exceed="() => ElMessage.warning('最多上传一个附件')" accept=".jpg,.jpeg,.png,.gif,.webp,.pdf,.xls,.xlsx,.doc,.docx">
  217. <el-button :icon="Upload">选取文件</el-button>
  218. <template #tip><div class="el-upload__tip">图片、PDF、Excel 或 Word,最大 20 MB</div></template>
  219. </el-upload>
  220. </el-form-item>
  221. </el-form>
  222. <template #footer>
  223. <el-button @click="supervisionVisible = false">取 消</el-button>
  224. <el-button type="primary" :loading="submitLoading" @click="submitSupervision">确 定</el-button>
  225. </template>
  226. </el-dialog>
  227. <el-dialog v-model="instructionVisible" title="添加领导批示" width="620px" append-to-body>
  228. <el-form label-width="100px">
  229. <el-form-item label="领导姓名">
  230. <el-input v-model="instructionForm.leaderName" placeholder="请输入领导姓名" />
  231. </el-form-item>
  232. <el-form-item label="批示内容">
  233. <el-input v-model="instructionForm.instructionContent" type="textarea" :rows="4" placeholder="请输入领导批示内容" />
  234. </el-form-item>
  235. </el-form>
  236. <template #footer>
  237. <el-button @click="instructionVisible = false">取 消</el-button>
  238. <el-button type="primary" :loading="submitLoading" @click="submitInstruction">确 定</el-button>
  239. </template>
  240. </el-dialog>
  241. <el-dialog v-model="returnVisible" title="预警退回" width="520px" append-to-body>
  242. <el-form label-width="100px">
  243. <el-form-item label="预警编号">
  244. <el-input :model-value="currentRow?.warningNo || '-'" disabled />
  245. </el-form-item>
  246. <el-form-item label="退回说明">
  247. <el-input v-model="returnForm.disposalContent" type="textarea" :rows="4" placeholder="请输入退回重办说明" />
  248. </el-form-item>
  249. </el-form>
  250. <template #footer>
  251. <el-button @click="returnVisible = false">取 消</el-button>
  252. <el-button type="primary" :loading="submitLoading" @click="submitReturn">确 定</el-button>
  253. </template>
  254. </el-dialog>
  255. </div>
  256. </template>
  257. <script setup>
  258. import { useWarningStatuses } from '@/views/subSystem/lifeCompany/warningWorkflow'
  259. const { warningStatusOptions, databaseStatusLabels } = useWarningStatuses()
  260. import { computed, onMounted, reactive, ref } from "vue";
  261. import { ElMessage } from "element-plus";
  262. import { Upload } from "@element-plus/icons-vue";
  263. import { parseTime } from "@/utils/ruoyi";
  264. import useUserStore from "@/store/modules/user";
  265. import { enabledAll } from "@/api/system/user";
  266. import WarningItemSummary from '../components/WarningItemSummary.vue';
  267. import WarningDisposalReasons from '../components/WarningDisposalReasons.vue';
  268. import WarningAttachments from "../components/WarningAttachments.vue";
  269. import { attachmentsForDisposal, unlinkedWarningAttachments } from "../warningAttachments";
  270. import {
  271. getAlertTypeDictionaryData,
  272. getWarningDetailData,
  273. getdbyjlistData,
  274. instructionWarningData,
  275. resolveWarningData,
  276. returnWarningData,
  277. supervisionWarningData,
  278. upgradeWarningData
  279. } from "@/api/smxyjldczxt/yjxxfb/yjfb.js";
  280. const loading = ref(false);
  281. const userStore = useUserStore();
  282. const submitLoading = ref(false);
  283. const usersLoading = ref(false);
  284. const enabledUsers = ref([]);
  285. const filteredEnabledUsers = ref([]);
  286. const supervisionFiles = ref([]);
  287. const warningList = ref([]);
  288. const total = ref(0);
  289. const warningTypeOptions = ref([]);
  290. const warningLevelOptions = ref([]);
  291. const currentRow = ref(null);
  292. const detailVisible = ref(false);
  293. const detailData = ref({});
  294. const resolveVisible = ref(false);
  295. const upgradeVisible = ref(false);
  296. const supervisionVisible = ref(false);
  297. const instructionVisible = ref(false);
  298. const returnVisible = ref(false);
  299. const queryParams = reactive({
  300. pageNum: 1,
  301. pageSize: 10,
  302. warningNo: "",
  303. warningType: "",
  304. warningLevel: "",
  305. status: "",
  306. handler: "",
  307. deviceCode: "",
  308. dateRange: []
  309. });
  310. const resolveForm = reactive({
  311. disposalContent: ""
  312. });
  313. const upgradeForm = reactive({
  314. newLevel: "",
  315. disposalContent: ""
  316. });
  317. const supervisionForm = reactive({
  318. supervisionUser: "",
  319. supervisionContent: "",
  320. notificationType: "",
  321. notificationContent: ""
  322. });
  323. const instructionForm = reactive({
  324. leaderName: "",
  325. instructionContent: ""
  326. });
  327. const returnForm = reactive({
  328. disposalContent: ""
  329. });
  330. const warningTypeLabelMap = computed(() => {
  331. return warningTypeOptions.value.reduce((acc, item) => {
  332. acc[item.dictValue] = item.dictLabel;
  333. return acc;
  334. }, {});
  335. });
  336. const warningLevelLabelMap = computed(() => {
  337. return warningLevelOptions.value.reduce((acc, item) => {
  338. acc[item.dictValue] = item.dictLabel;
  339. return acc;
  340. }, {});
  341. });
  342. const upgradeLevelOptions = computed(() => warningLevelOptions.value.filter(
  343. item => Number(item.dictValue) < Number(currentRow.value?.warningLevel)
  344. ));
  345. const canManage = row => ["PENDING", "RECEIVED", "PROCESSING", "HANDLED"].includes(row.status);
  346. const canUpgrade = row => canManage(row) && Number(row.warningLevel) > 1 && Number(row.warningLevel) <= 4;
  347. const canReview = row => row.status === "HANDLED" && (row.reviewer || row.publisher) === userStore.name;
  348. function formatDateTime(value) {
  349. if (!value) return "-";
  350. const date = new Date(value);
  351. return parseTime(Number.isNaN(date.getTime()) ? value : date) || "-";
  352. }
  353. const detailBasic = computed(() => {
  354. const basic = detailData.value.basicInfo || {};
  355. const warningType = basic.warningType || basic.warning_type || "";
  356. const warningLevel = basic.warningLevel || basic.warning_level || "";
  357. return {
  358. warningNo: basic.warningNo || basic.warning_no || "",
  359. warningSpecial: basic.warningSpecial || basic.warning_special || "",
  360. warningTypeText: basic.warning_type_name || basic.warningTypeName || warningTypeLabelMap.value[warningType] || "-",
  361. warningLevelText: warningLevelLabelMap.value[warningLevel] || "-",
  362. status: basic.status || "",
  363. handler: basic.handler || "",
  364. deviceCode: basic.deviceCode || basic.device_code || "",
  365. deviceName: basic.deviceName || basic.device_name || "",
  366. publisher: basic.publisher || "",
  367. reviewer: basic.reviewer || "",
  368. ownershipUnit: basic.ownershipUnit || basic.ownership_unit || "",
  369. publishTime: basic.publishTime || basic.publish_time || "",
  370. warningContent: basic.warningContent || basic.warning_content || ""
  371. };
  372. });
  373. function getLevelTagType(level) {
  374. return {
  375. "1": "danger",
  376. "2": "warning",
  377. "3": "success",
  378. "4": "info"
  379. }[level] || "info";
  380. }
  381. function getStatusText(status) {
  382. return databaseStatusLabels.value[status] || status || "-"
  383. }
  384. function getStatusTagType(status) {
  385. return {
  386. DRAFT: "info",
  387. RECEIVED: "warning",
  388. PENDING: "warning",
  389. PROCESSING: "warning",
  390. HANDLED: "success",
  391. CLOSED: "info"
  392. }[status] || "info";
  393. }
  394. function normalizeWarningRow(item) {
  395. const warningType = item.warningType || item.warning_type || "";
  396. const warningLevel = item.warningLevel || item.warning_level || "";
  397. return {
  398. warningId: item.warningId || item.warning_id,
  399. warningNo: item.warningNo || item.warning_no || "",
  400. warningType,
  401. warningTypeText: item.warning_type_name || item.warningTypeName || warningTypeLabelMap.value[warningType] || "-",
  402. warningLevel,
  403. warningLevelText: warningLevelLabelMap.value[warningLevel] || "-",
  404. handler: item.handler || "",
  405. deviceCode: item.deviceCode || item.device_code || "",
  406. deviceName: item.deviceName || item.device_name || "",
  407. publisher: item.publisher || "",
  408. reviewer: item.reviewer || "",
  409. ownershipUnit: item.ownershipUnit || item.ownership_unit || "",
  410. publishTime: item.publishTime || item.publish_time || "",
  411. status: item.status || ""
  412. };
  413. }
  414. function resetActionForms() {
  415. resolveForm.disposalContent = "";
  416. upgradeForm.newLevel = "";
  417. upgradeForm.disposalContent = "";
  418. supervisionForm.supervisionUser = "";
  419. supervisionForm.supervisionContent = "";
  420. supervisionForm.notificationType = "";
  421. supervisionForm.notificationContent = "";
  422. supervisionFiles.value = [];
  423. instructionForm.leaderName = "";
  424. instructionForm.instructionContent = "";
  425. returnForm.disposalContent = "";
  426. }
  427. function filterSupervisionUser(keyword) {
  428. const text = String(keyword || "").trim().toLowerCase();
  429. filteredEnabledUsers.value = !text
  430. ? enabledUsers.value
  431. : enabledUsers.value.filter(user => [user.nickName, user.userName, user.dept?.deptName]
  432. .filter(Boolean)
  433. .some(value => String(value).toLowerCase().includes(text)));
  434. }
  435. function supervisionUserLabel(user) {
  436. const name = user.nickName || user.userName || "未命名用户";
  437. return user.userName && user.userName !== name ? `${name}(${user.userName})` : name;
  438. }
  439. async function loadDicts() {
  440. const [typeRes, levelRes] = await Promise.all([
  441. getAlertTypeDictionaryData({ dictType: "alert_type" }),
  442. getAlertTypeDictionaryData({ dictType: "alert_level" })
  443. ]);
  444. warningTypeOptions.value = typeRes.rows || [];
  445. warningLevelOptions.value = levelRes.rows || [];
  446. }
  447. async function loadList() {
  448. loading.value = true;
  449. try {
  450. const res = await getdbyjlistData({
  451. pageNum: queryParams.pageNum,
  452. pageSize: queryParams.pageSize,
  453. warningNo: queryParams.warningNo || undefined,
  454. warningType: queryParams.warningType || undefined,
  455. warningLevel: queryParams.warningLevel || undefined,
  456. status: queryParams.status || undefined,
  457. handler: queryParams.handler || undefined,
  458. deviceCode: queryParams.deviceCode || undefined,
  459. startTime: queryParams.dateRange?.[0] || undefined,
  460. endTime: queryParams.dateRange?.[1] || undefined
  461. });
  462. warningList.value = (res.data?.records || []).map(normalizeWarningRow);
  463. total.value = res.data?.total || 0;
  464. } finally {
  465. loading.value = false;
  466. }
  467. }
  468. function handleQuery() {
  469. queryParams.pageNum = 1;
  470. loadList();
  471. }
  472. function resetQuery() {
  473. queryParams.pageNum = 1;
  474. queryParams.pageSize = 10;
  475. queryParams.warningNo = "";
  476. queryParams.warningType = "";
  477. queryParams.warningLevel = "";
  478. queryParams.status = "";
  479. queryParams.handler = "";
  480. queryParams.deviceCode = "";
  481. queryParams.dateRange = [];
  482. loadList();
  483. }
  484. async function openDetail(row) {
  485. const res = await getWarningDetailData(row.warningId);
  486. detailData.value = res.data || {};
  487. detailVisible.value = true;
  488. }
  489. function openResolve(row) {
  490. currentRow.value = row;
  491. resetActionForms();
  492. resolveVisible.value = true;
  493. }
  494. function openUpgrade(row) {
  495. currentRow.value = row;
  496. resetActionForms();
  497. upgradeVisible.value = true;
  498. }
  499. function openSupervision(row) {
  500. currentRow.value = row;
  501. resetActionForms();
  502. supervisionVisible.value = true;
  503. usersLoading.value = true;
  504. enabledUsers.value = [];
  505. filteredEnabledUsers.value = [];
  506. enabledAll().then(res => {
  507. enabledUsers.value = res.data || [];
  508. filteredEnabledUsers.value = enabledUsers.value;
  509. }).catch(() => {
  510. ElMessage.error("督办人员加载失败");
  511. }).finally(() => {
  512. usersLoading.value = false;
  513. });
  514. }
  515. function openInstruction(row) {
  516. currentRow.value = row;
  517. resetActionForms();
  518. instructionVisible.value = true;
  519. }
  520. function openReturn(row) {
  521. currentRow.value = row;
  522. resetActionForms();
  523. returnVisible.value = true;
  524. }
  525. async function submitResolve() {
  526. if (!resolveForm.disposalContent) {
  527. ElMessage.warning("请输入解除说明");
  528. return;
  529. }
  530. submitLoading.value = true;
  531. try {
  532. const res = await resolveWarningData({
  533. warningId: currentRow.value.warningId,
  534. disposalContent: resolveForm.disposalContent
  535. });
  536. if (res.code !== 200) {
  537. ElMessage.error(res.msg || "解除失败");
  538. return;
  539. }
  540. ElMessage.success("解除成功");
  541. resolveVisible.value = false;
  542. loadList();
  543. } finally {
  544. submitLoading.value = false;
  545. }
  546. }
  547. async function submitUpgrade() {
  548. if (!upgradeForm.newLevel) {
  549. ElMessage.warning("请选择新预警级别");
  550. return;
  551. }
  552. if (!upgradeForm.disposalContent) {
  553. ElMessage.warning("请输入升级说明");
  554. return;
  555. }
  556. if (!canUpgrade(currentRow.value) || Number(upgradeForm.newLevel) >= Number(currentRow.value.warningLevel)) {
  557. ElMessage.warning("只能升级至更严重的级别");
  558. return;
  559. }
  560. submitLoading.value = true;
  561. try {
  562. const res = await upgradeWarningData({
  563. warningId: currentRow.value.warningId,
  564. newLevel: upgradeForm.newLevel,
  565. disposalContent: upgradeForm.disposalContent
  566. });
  567. if (res.code !== 200) {
  568. ElMessage.error(res.msg || "升级失败");
  569. return;
  570. }
  571. ElMessage.success("升级成功");
  572. upgradeVisible.value = false;
  573. loadList();
  574. } finally {
  575. submitLoading.value = false;
  576. }
  577. }
  578. async function submitSupervision() {
  579. if (!supervisionForm.supervisionUser || !supervisionForm.supervisionContent || !supervisionForm.notificationType) {
  580. ElMessage.warning("请完善督办信息");
  581. return;
  582. }
  583. if ((supervisionForm.notificationContent.trim() || supervisionForm.supervisionContent.trim()).length > 180) {
  584. ElMessage.warning("通知内容不能超过 180 字");
  585. return;
  586. }
  587. const attachment = supervisionFiles.value[0]?.raw;
  588. if (attachment && attachment.size > 20 * 1024 * 1024) {
  589. ElMessage.warning("附件不能超过 20 MB");
  590. return;
  591. }
  592. const data = new FormData();
  593. data.append("warningId", currentRow.value.warningId);
  594. data.append("supervisionUser", supervisionForm.supervisionUser);
  595. data.append("supervisionContent", supervisionForm.supervisionContent);
  596. data.append("notificationType", supervisionForm.notificationType);
  597. data.append("notificationContent", supervisionForm.notificationContent);
  598. if (attachment) data.append("attachment", attachment);
  599. submitLoading.value = true;
  600. try {
  601. const res = await supervisionWarningData(data);
  602. if (res.code !== 200) {
  603. ElMessage.error(res.msg || "督办失败");
  604. return;
  605. }
  606. if (res.data?.notificationStatus === "FAILED") {
  607. ElMessage.warning("督办已保存,但短信发送失败,请联系管理员核查,勿重复提交");
  608. } else {
  609. ElMessage.success(res.msg || "督办通知已发送");
  610. }
  611. supervisionVisible.value = false;
  612. loadList();
  613. } finally {
  614. submitLoading.value = false;
  615. }
  616. }
  617. async function submitInstruction() {
  618. if (!instructionForm.leaderName || !instructionForm.instructionContent) {
  619. ElMessage.warning("请完善领导批示信息");
  620. return;
  621. }
  622. submitLoading.value = true;
  623. try {
  624. const res = await instructionWarningData({
  625. warningId: currentRow.value.warningId,
  626. leaderName: instructionForm.leaderName,
  627. instructionContent: instructionForm.instructionContent
  628. });
  629. if (res.code !== 200) {
  630. ElMessage.error(res.msg || "批示失败");
  631. return;
  632. }
  633. ElMessage.success("添加批示成功");
  634. instructionVisible.value = false;
  635. loadList();
  636. } finally {
  637. submitLoading.value = false;
  638. }
  639. }
  640. async function submitReturn() {
  641. if (!returnForm.disposalContent) {
  642. ElMessage.warning("请输入退回说明");
  643. return;
  644. }
  645. submitLoading.value = true;
  646. try {
  647. const res = await returnWarningData({
  648. warningId: currentRow.value.warningId,
  649. disposalContent: returnForm.disposalContent
  650. });
  651. if (res.code !== 200) {
  652. ElMessage.error(res.msg || "退回失败");
  653. return;
  654. }
  655. ElMessage.success("退回成功");
  656. returnVisible.value = false;
  657. loadList();
  658. } finally {
  659. submitLoading.value = false;
  660. }
  661. }
  662. onMounted(async () => {
  663. await loadDicts();
  664. await loadList();
  665. });
  666. </script>
  667. <style scoped>
  668. .warning-disposal-page {
  669. background: #f5f7fb;
  670. }
  671. .page-card {
  672. border-radius: 16px;
  673. margin-bottom: 16px;
  674. }
  675. .header-card {
  676. background: linear-gradient(135deg, #eff6ff, #f8fbff);
  677. border: 1px solid #dbeafe;
  678. }
  679. .page-header {
  680. display: flex;
  681. justify-content: space-between;
  682. align-items: center;
  683. gap: 16px;
  684. }
  685. .page-title {
  686. font-size: 22px;
  687. font-weight: 700;
  688. color: #1e3a8a;
  689. }
  690. .user-dept {
  691. float: right;
  692. margin-left: 16px;
  693. color: #94a3b8;
  694. font-size: 12px;
  695. }
  696. .notification-hint {
  697. margin-top: 6px;
  698. color: #909399;
  699. font-size: 12px;
  700. line-height: 20px;
  701. }
  702. @media (max-width: 768px) {
  703. .page-header {
  704. flex-direction: column;
  705. align-items: flex-start;
  706. }
  707. }
  708. </style>