OneByOneAuditDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <div class="safety-platform-container">
  3. <header class="safety-platform-container__header">
  4. <div class="breadcrumb-title">{{ detailData?.problem || '-' }}</div>
  5. <div class="detail-content">
  6. <span>创建人:{{ detailData?.creatorName || '-' }}</span>
  7. <span>创建时间:{{ detailData?.createdAt || '-' }}</span>
  8. </div>
  9. </header>
  10. <main class="safety-platform-container__main">
  11. <div class="audit-content">
  12. <h4 class="section-title">
  13. <el-icon class="section-title__icon"><Document /></el-icon>
  14. <span>基本信息</span>
  15. </h4>
  16. <div class="detail-ct detail-ct--table">
  17. <div class="row">
  18. <div class="col">
  19. <div class="label">隐患问题:</div>
  20. <div class="value">{{ detailData?.problem || '-' }}</div>
  21. </div>
  22. <div class="col">
  23. <div class="label">状态:</div>
  24. <div class="value">{{ detailData?.statusName || '-' }}</div>
  25. </div>
  26. </div>
  27. <div class="row">
  28. <div class="col">
  29. <div class="label">下发数:</div>
  30. <div class="value">{{ detailData?.issueCount ?? '-' }}</div>
  31. </div>
  32. <div class="col">
  33. <div class="label">反馈数:</div>
  34. <div class="value">{{ detailData?.feedbackCount ?? '-' }}</div>
  35. </div>
  36. </div>
  37. <div class="row">
  38. <div class="col">
  39. <div class="label">计划开始日期:</div>
  40. <div class="value">{{ detailData?.planStartDate || detailData?.dangerProposeDate || '-' }}</div>
  41. </div>
  42. <div class="col">
  43. <div class="label">计划完成日期:</div>
  44. <div class="value">{{ detailData?.associationOtTimeLimit || '-' }}</div>
  45. </div>
  46. </div>
  47. </div>
  48. <h4 class="section-title">
  49. <el-icon class="section-title__icon"><Document /></el-icon>
  50. <span>举一反三要求</span>
  51. </h4>
  52. <div class="detail-ct requirement-block">
  53. <div class="value value-text">{{ detailData?.associationOneThree || '-' }}</div>
  54. </div>
  55. <h4 class="section-title">
  56. <el-icon class="section-title__icon"><Document /></el-icon>
  57. <span>材料上传</span>
  58. </h4>
  59. <div class="detail-ct detail-ct--table attachment-row">
  60. <div class="row">
  61. <div class="col">
  62. <div class="label">上传附件:</div>
  63. <div class="value value--attachment">
  64. <template v-if="attachmentFileList.length">
  65. <div
  66. class="file-container--div"
  67. v-for="item in attachmentFileList"
  68. :key="item.fileUrl || item.fileName"
  69. >
  70. <img
  71. class="file-container--div__icon"
  72. :src="FILE_TYPE_ICON[item.fileType]"
  73. @click="previewOnline(item.fileUrl, item.fileType)"
  74. />
  75. <span
  76. class="file-container--div__name"
  77. @click="previewOnline(item.fileUrl, item.fileType)"
  78. >
  79. {{ item.fileName }}
  80. </span>
  81. <img
  82. class="file-container--div__download"
  83. :src="DownloadIcon"
  84. @click="downloadFile(item.fileUrl, item.fileName)"
  85. />
  86. </div>
  87. </template>
  88. <span v-else class="empty-text">-</span>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </main>
  95. <footer class="safety-platform-container__footer">
  96. <el-button @click="router.back()">返回</el-button>
  97. <el-button type="primary" @click="handleReject" v-if="!isViewMode">审核不通过</el-button>
  98. <el-button type="primary" @click="handleApprove" v-if="!isViewMode">审核通过</el-button>
  99. </footer>
  100. <el-dialog
  101. v-model="showRejectDialog"
  102. title="审核不通过原因"
  103. width="560px"
  104. :close-on-click-modal="false"
  105. destroy-on-close
  106. @close="rejectReason = ''"
  107. >
  108. <el-input
  109. v-model="rejectReason"
  110. type="textarea"
  111. :rows="6"
  112. maxlength="300"
  113. show-word-limit
  114. placeholder="请填写审核不通过原因(限300字)"
  115. />
  116. <template #footer>
  117. <el-button @click="showRejectDialog = false">取消</el-button>
  118. <el-button type="primary" @click="handleRejectSubmit">确定</el-button>
  119. </template>
  120. </el-dialog>
  121. <PreviewOnline ref="previewOnlineRef" />
  122. </div>
  123. </template>
  124. <script setup lang="ts">
  125. import { computed, onMounted, ref } from 'vue';
  126. import { useRoute, useRouter } from 'vue-router';
  127. import { ElMessage } from 'element-plus';
  128. import { Document } from '@element-plus/icons-vue';
  129. import PreviewOnline from '@/views/disaster/components/PreviewOnline.vue';
  130. import { getDrawLessonsAdminTowDetail, approveDrawLessons } from '@/api/drawLessons';
  131. import { FILE_TYPE_ICON } from '@/components/UploadFiles/constants';
  132. import DownloadIcon from '@/views/disaster/disaster-control/src/svg/download.svg';
  133. import { downloadFile } from '@/views/disaster/utils';
  134. const router = useRouter();
  135. const route = useRoute();
  136. const id = computed(() => Number(route.query.id));
  137. const operate = computed(() => (route.query.operate as string) || 'one-by-one-audit-detail');
  138. const isViewMode = computed(() => operate.value === 'one-by-one-audit-view');
  139. const detailData = ref<{
  140. problem?: string;
  141. creatorName?: string;
  142. createdAt?: string;
  143. statusName?: string;
  144. issueCount?: number;
  145. feedbackCount?: number;
  146. planStartDate?: string;
  147. dangerProposeDate?: string;
  148. associationOtTimeLimit?: string;
  149. associationOneThree?: string;
  150. attachments?: string;
  151. attachmentList?: Array<{ fileName?: string; fileUrl?: string; fileNameOrUrl?: string; url?: string }>;
  152. issueId?: number;
  153. } | null>(null);
  154. const showRejectDialog = ref(false);
  155. const rejectReason = ref('');
  156. const submitting = ref(false);
  157. const previewOnlineRef = ref<InstanceType<typeof PreviewOnline>>();
  158. const attachmentFileList = computed(() => {
  159. const d = detailData.value;
  160. if (!d) return [];
  161. const normalize = (items: Array<{ fileUrl?: string; url?: string; fileName?: string; fileNameOrUrl?: string }>) => {
  162. return items.map((raw, index) => {
  163. const url = raw.fileUrl || raw.url || raw.fileNameOrUrl || '';
  164. const nameFromData = raw.fileName || raw.fileNameOrUrl;
  165. const fileName = nameFromData || (url ? url.split('/').pop() || `附件${index + 1}` : `附件${index + 1}`);
  166. const ext = fileName.split('.').pop()?.toLowerCase() || '';
  167. let fileType: 'pdf' | 'word' | 'excel' | 'ppt' = 'pdf';
  168. if (ext === 'doc' || ext === 'docx') fileType = 'word';
  169. else if (ext === 'xls' || ext === 'xlsx') fileType = 'excel';
  170. else if (ext === 'ppt' || ext === 'pptx') fileType = 'ppt';
  171. return {
  172. fileUrl: url,
  173. fileName,
  174. fileType,
  175. };
  176. });
  177. };
  178. if (Array.isArray(d.attachmentList) && d.attachmentList.length) {
  179. return normalize(d.attachmentList);
  180. }
  181. if (!d.attachments) return [];
  182. try {
  183. const parsed = JSON.parse(d.attachments);
  184. if (Array.isArray(parsed) && parsed.length) {
  185. return normalize(parsed as Array<{ fileUrl?: string; url?: string; fileName?: string; fileNameOrUrl?: string }>);
  186. }
  187. } catch {
  188. const list = d.attachments
  189. .split(',')
  190. .map((s) => s.trim())
  191. .filter(Boolean)
  192. .map((s) => ({ fileNameOrUrl: s, fileUrl: s }));
  193. if (list.length) return normalize(list);
  194. }
  195. return [];
  196. });
  197. const getDetail = async () => {
  198. if (!id.value) return;
  199. try {
  200. const res = await getDrawLessonsAdminTowDetail(id.value);
  201. const data = (res as any)?.data ?? res;
  202. if (data && typeof data === 'object') {
  203. const records = Array.isArray(data.issueRecords) ? data.issueRecords : [];
  204. detailData.value = {
  205. problem: data.problem,
  206. creatorName: data.creatorName,
  207. createdAt: data.createdAt,
  208. statusName: data.statusName,
  209. issueCount: data.issueCount,
  210. feedbackCount: data.feedbackCount ?? records.filter((r: any) => r.statusId === 5 || r.statusName === '已完成' || r.feedbackAt).length,
  211. planStartDate: data.planStartDate,
  212. dangerProposeDate: data.dangerProposeDate,
  213. associationOtTimeLimit: data.associationOtTimeLimit,
  214. associationOneThree: data.associationOneThree,
  215. attachments: data.attachments,
  216. attachmentList: data.attachmentList,
  217. issueId: data.issueId,
  218. };
  219. }
  220. } catch (e) {
  221. console.error('获取举一反三详情失败:', e);
  222. ElMessage.error(e?.message || e?.data || '获取详情失败');
  223. }
  224. };
  225. const previewOnline = (url: string | undefined, type: string) => {
  226. if (url) previewOnlineRef.value?.open(url, type);
  227. };
  228. const handleReject = () => {
  229. showRejectDialog.value = true;
  230. };
  231. const handleRejectSubmit = async () => {
  232. if (!rejectReason.value?.trim()) {
  233. ElMessage.warning('请填写审核不通过原因');
  234. return;
  235. }
  236. if (!id.value) return;
  237. submitting.value = true;
  238. try {
  239. await approveDrawLessons({
  240. id: id.value,
  241. statusId: 6,
  242. statusName: '已作废',
  243. reviewReason: rejectReason.value?.trim() || undefined,
  244. });
  245. ElMessage.success('审核不通过操作成功');
  246. showRejectDialog.value = false;
  247. rejectReason.value = '';
  248. router.back();
  249. } catch (e) {
  250. console.error('审核不通过失败:', e);
  251. ElMessage.error(e?.message || e?.data || '操作失败,请重试');
  252. } finally {
  253. submitting.value = false;
  254. }
  255. };
  256. const handleApprove = async () => {
  257. if (!id.value) return;
  258. submitting.value = true;
  259. try {
  260. await approveDrawLessons({
  261. id: detailData.value.issueId ?? '',
  262. statusId: 5,
  263. statusName: '已完成',
  264. });
  265. ElMessage.success('审核通过操作成功');
  266. router.back();
  267. } catch (e) {
  268. console.error('审核通过失败:', e);
  269. ElMessage.error(e?.message || e?.data || '操作失败,请重试');
  270. } finally {
  271. submitting.value = false;
  272. }
  273. };
  274. onMounted(() => {
  275. getDetail();
  276. });
  277. </script>
  278. <style scoped lang="scss">
  279. @use '@/styles/page-details-layout.scss' as *;
  280. @use '@/styles/page-main-layout.scss' as *;
  281. @use '@/styles/basic-table-file.scss' as *;
  282. .detail-content {
  283. display: flex;
  284. gap: 30px;
  285. margin: 10px 0;
  286. font-size: 14px;
  287. }
  288. .audit-content {
  289. padding: 0 16px;
  290. .section-title {
  291. display: flex;
  292. align-items: center;
  293. gap: 8px;
  294. margin: 20px 0 12px 0;
  295. font-size: 16px;
  296. font-weight: 600;
  297. color: #333;
  298. .section-title__icon {
  299. font-size: 18px;
  300. color: #333;
  301. }
  302. }
  303. .section-title:first-child {
  304. margin-top: 0;
  305. }
  306. .detail-ct {
  307. font-size: 14px;
  308. margin-bottom: 20px;
  309. &--table {
  310. border: 1px solid #dcdfe6;
  311. .row {
  312. display: flex;
  313. border-bottom: 1px solid #dcdfe6;
  314. &:last-child {
  315. border-bottom: none;
  316. }
  317. }
  318. .col {
  319. display: flex;
  320. flex: 1;
  321. min-height: 40px;
  322. align-items: stretch;
  323. &.col--wide {
  324. flex: 2;
  325. }
  326. .label {
  327. display: flex;
  328. align-items: center;
  329. justify-content: flex-end;
  330. flex-shrink: 0;
  331. width: 140px;
  332. padding: 0 12px;
  333. background-color: #f5f5f5;
  334. border-right: 1px solid #dcdfe6;
  335. color: #333;
  336. }
  337. .value {
  338. flex: 1;
  339. display: flex;
  340. align-items: center;
  341. padding: 10px 20px;
  342. background-color: #fff;
  343. border-right: 1px solid #dcdfe6;
  344. color: #333;
  345. }
  346. }
  347. .row .col:last-child .value {
  348. border-right: none;
  349. }
  350. .row .col:nth-child(2) .label {
  351. border-left: 1px solid #dcdfe6;
  352. }
  353. }
  354. &.requirement-block {
  355. border: 1px solid #e0e0e0;
  356. background-color: #fff;
  357. padding: 16px 20px;
  358. min-height: 60px;
  359. .value-text {
  360. white-space: pre-wrap;
  361. word-break: break-word;
  362. color: #333;
  363. line-height: 1.5;
  364. }
  365. }
  366. &.attachment-row .value--attachment {
  367. flex-wrap: wrap;
  368. align-items: flex-start;
  369. .empty-text {
  370. color: #999;
  371. }
  372. }
  373. }
  374. }
  375. </style>