areaCheckPlanTaskDept.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <div class="safety-platform-container">
  3. <header class="safety-platform-container__header">
  4. <div class="breadcrumb-title">区域检查计划任务(部门)</div>
  5. </header>
  6. <main class="safety-platform-container__main">
  7. <div class="search-table-container">
  8. <header>
  9. <div class="act-search">
  10. <section class="select-box">
  11. <div class="select-box--item">
  12. <span>检查场所/检查人员:</span>
  13. <el-input
  14. v-model="tableQuery.queryParam.searchKey"
  15. placeholder="搜索检查场所或检查人员"
  16. class="act-search-input"
  17. style="min-width: 200px;"
  18. clearable
  19. />
  20. </div>
  21. <div class="select-box--item">
  22. <span>状态:</span>
  23. <el-select v-model="tableQuery.queryParam.status" placeholder="请选择状态" clearable>
  24. <el-option
  25. v-for="item in AREA_CHECK_PLAN_STATUS_OPTIONS"
  26. :key="String(item.value)"
  27. :label="item.label"
  28. :value="item.value"
  29. />
  30. </el-select>
  31. </div>
  32. <div class="select-box--item">
  33. <span>日期范围:</span>
  34. <el-date-picker
  35. v-model="dateRange"
  36. type="daterange"
  37. range-separator="-"
  38. start-placeholder="开始日期"
  39. end-placeholder="结束日期"
  40. value-format="YYYY-MM-DD"
  41. format="YYYY-MM-DD"
  42. />
  43. </div>
  44. </section>
  45. <section class="search-btn">
  46. <el-button type="primary" @click="handleSearch">查询</el-button>
  47. <el-button @click="handleReset">重置</el-button>
  48. <el-button plain @click="handleDownload"> 导出 </el-button>
  49. </section>
  50. </div>
  51. </header>
  52. <div class="batch-table">
  53. <BasicTable
  54. ref="basicTableRef"
  55. :tableData="tableData"
  56. :tableConfig="tableConfig"
  57. @update:pageSize="handleSizeChange"
  58. @update:pageNumber="handleCurrentChange"
  59. >
  60. <template #status="scope">
  61. <span>{{ AREA_CHECK_PLAN_STATUS_LABEL[String(scope.row.status)] ?? '-' }}</span>
  62. </template>
  63. <template #frequency="scope">
  64. <span>{{ FREQUENCY_TO_LABEL[scope.row.frequency] ?? '-' }}</span>
  65. </template>
  66. <template #sign="scope">
  67. <div class="file-list">
  68. <div class="file-item" v-for="item in scope.row.checkedPersonSign" :key="item.fileId">
  69. <span class="file-item--name">{{ item.fileName }}</span>
  70. <div class="file-item--footer">
  71. <el-button link type="primary" @click="previewOnline(item.fileUrl, item.fileType)"
  72. >预览</el-button
  73. >
  74. <el-button link type="primary" @click.stop="downloadFile(item.fileUrl, item.fileName)"
  75. >下载</el-button
  76. >
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <template #checkItemTotal="scope">
  82. <span>{{
  83. scope.row.checkItemTotal ? scope.row.checkItemTotal+'项' : '-'
  84. }}</span>
  85. </template>
  86. <template #qualifiedItemNum="scope">
  87. <span>{{ scope.row.qualifiedItemNum ? scope.row.qualifiedItemNum+'项' : '-' }}</span>
  88. </template>
  89. <template #unqualifiedItemNum="scope">
  90. <span>{{ scope.row.unqualifiedItemNum ? scope.row.unqualifiedItemNum+'项' : '-' }}</span>
  91. </template>
  92. <template #action="scope">
  93. <div class="action-container--div" style="justify-content: left">
  94. <template v-if="Number(scope.row.status) === 1">
  95. <ActionButton text="检查" @click="handleCheck(scope.row)" />
  96. </template>
  97. <template v-else>
  98. <ActionButton text="查看" @click="handleView(scope.row)" />
  99. </template>
  100. </div>
  101. </template>
  102. </BasicTable>
  103. </div>
  104. </div>
  105. </main>
  106. <PreviewOnline ref="previewOnlineRef" />
  107. </div>
  108. </template>
  109. <script setup lang="ts">
  110. import { onMounted, reactive, ref } from 'vue';
  111. import { ElMessage } from 'element-plus';
  112. import BasicTable from '@/components/BasicTable.vue';
  113. import useTableConfig from '@/hooks/useTableConfigHook';
  114. import ActionButton from '@/components/ActionButton.vue';
  115. import { Plus } from '@element-plus/icons-vue';
  116. import {
  117. TABLE_OPTIONS,
  118. AREA_CHECK_PLAN_TABLE_COLUMNS,
  119. AREA_CHECK_PLAN_STATUS_OPTIONS,
  120. AREA_CHECK_PLAN_STATUS_LABEL,
  121. } from './configs/tables';
  122. import { FREQUENCY_TO_LABEL } from './configs/form';
  123. import { useRouter } from 'vue-router';
  124. import type { QueryPageRequest } from '@/types/basic-query';
  125. import type { AreaCheckPlanQuery, AreaCheckPlanRecord } from './configs/types';
  126. import {
  127. queryAreaCheckPlanDetailPage,
  128. queryAreaInspectionPlanTask,
  129. mapAreaCheckPlanApiRecordToUi,
  130. exportAreaCheckPlanAdministration,
  131. exportRegionalInspectionPlanTaskDepartmentData,
  132. } from '@/api/production-safety-system';
  133. import { getAllDepartments } from '@/api/auth/dept';
  134. import type { DeptTree } from '@/types/dept/type';
  135. import { queryUserGroupPage } from '@/api/system/person-group';
  136. import type { PersonGroupListItem } from '@/types/person-group/type';
  137. import BatchImport from '@/components/batch-import/BatchImport.vue';
  138. import { useGlobSetting } from '@/hooks/setting';
  139. import urlJoin from 'url-join';
  140. import { downloadByData } from '@/utils/file/download';
  141. import { downloadFile } from '@/views/disaster/utils';
  142. import PreviewOnline from '@/views/disaster/components/PreviewOnline.vue';
  143. import { useUserInfoHook } from '@/views/disaster/hooks';
  144. import { template } from 'lodash-es';
  145. const router = useRouter();
  146. const { id } = useUserInfoHook();
  147. const basicTableRef = ref<InstanceType<typeof BasicTable>>();
  148. const { tableConfig, pagination } = useTableConfig(AREA_CHECK_PLAN_TABLE_COLUMNS, TABLE_OPTIONS);
  149. const tableData = ref<AreaCheckPlanRecord[]>([]);
  150. const dateRange = ref<[string, string] | null>(null);
  151. // 场所所属类别选项(示例数据,本页面不调用接口)
  152. const venueCategoryOptions = ref<Array<{ label: string; value: string }>>([]);
  153. // 预览
  154. const previewOnlineRef = ref<InstanceType<typeof PreviewOnline>>();
  155. const previewOnline = (url: string | undefined, type) => {
  156. if (url) {
  157. previewOnlineRef.value?.open(url, type);
  158. }
  159. };
  160. const tableQuery = reactive<QueryPageRequest<AreaCheckPlanQuery>>({
  161. pageNumber: pagination.pageNumber,
  162. pageSize: pagination.pageSize,
  163. queryParam: {
  164. searchKey: '',
  165. startDate: '',
  166. endDate: '',
  167. status: '' as AreaCheckPlanQuery['status'],
  168. userId: id // 当前登录人ID
  169. },
  170. });
  171. const handleSizeChange = (value: number) => {
  172. pagination.pageSize = value;
  173. tableQuery.pageSize = value;
  174. getTableData();
  175. };
  176. const handleCurrentChange = (value: number) => {
  177. pagination.pageNumber = value;
  178. tableQuery.pageNumber = value;
  179. getTableData();
  180. };
  181. // 判断是否有值, 如果有值就转换成JSON.parse
  182. const safeJsonParse = (str) => {
  183. // 判断是否有有效值
  184. if (str === null || str === undefined || str.trim() === '') {
  185. return [];
  186. }
  187. try {
  188. return JSON.parse(str);
  189. } catch (e) {
  190. console.warn('JSON 解析失败:', e);
  191. return [];
  192. }
  193. }
  194. async function getTableData() {
  195. tableConfig.loading = true;
  196. try {
  197. const res = await queryAreaInspectionPlanTask(tableQuery);
  198. const list = res?.records ?? [];
  199. tableData.value = list.map(item=>{
  200. // 附件转换格式
  201. item.checkedPersonSign = safeJsonParse(item.checkedPersonSign);
  202. return item;
  203. })
  204. pagination.total = res?.totalRow ?? 0;
  205. } catch (e) {
  206. console.error('查询区域检查计划列表失败:', e);
  207. tableData.value = [];
  208. pagination.total = 0;
  209. } finally {
  210. tableConfig.loading = false;
  211. }
  212. }
  213. const handleSearch = () => {
  214. if (dateRange.value && dateRange.value.length === 2) {
  215. tableQuery.queryParam.startDate = dateRange.value[0];
  216. tableQuery.queryParam.endDate = dateRange.value[1];
  217. } else {
  218. tableQuery.queryParam.startDate = '';
  219. tableQuery.queryParam.endDate = '';
  220. }
  221. pagination.pageNumber = 1;
  222. tableQuery.pageNumber = 1;
  223. getTableData();
  224. };
  225. const handleReset = () => {
  226. tableQuery.queryParam.searchKey = '';
  227. tableQuery.queryParam.status = '';
  228. tableQuery.queryParam.startDate = '';
  229. tableQuery.queryParam.endDate = '';
  230. dateRange.value = null;
  231. handleSearch();
  232. };
  233. const handleView = (row) => {
  234. router.push({
  235. name: 'areaCheckPlanTaskDeptItem',
  236. query: {
  237. recordId: row.id,
  238. planId: row.areaPlanId,
  239. checkType: row.checkType,
  240. operate: 'area-check-plan-view'
  241. },
  242. });
  243. };
  244. const handleCheck = (row: any) => {
  245. router.push({
  246. name: 'areaCheckPlanTaskDeptItem',
  247. query: {
  248. recordId: row.id,
  249. planId: row.areaPlanId,
  250. checkType: row.checkType, // 传递检查类型,后续根据检查类型区分检查项来源
  251. operate: 'area-check-plan-create' },
  252. });
  253. };
  254. const handleDownload = async () => {
  255. try {
  256. const response = await exportRegionalInspectionPlanTaskDepartmentData(tableQuery.queryParam);
  257. if (response) {
  258. const fileName = `区域检查计划任务_${new Date().toISOString().split('T')[0]}.xlsx`;
  259. downloadByData(response, fileName);
  260. ElMessage.success('导出成功');
  261. }
  262. } catch (e) {
  263. console.error('导出文件失败:', e);
  264. ElMessage.error('导出失败,请重试');
  265. }
  266. };
  267. onMounted(() => {
  268. venueCategoryOptions.value = [
  269. { label: '各级风险点', value: '各级风险点' },
  270. { label: '关键业务活动', value: '关键业务活动' },
  271. { label: '日常安全', value: '日常安全' },
  272. { label: '各级危险点', value: '各级危险点' },
  273. { label: '试验室及试验过程', value: '试验室及试验过程' },
  274. {
  275. label: '办公区域(含地下车库、图书馆、档案库房、仓库等)',
  276. value: '办公区域(含地下车库、图书馆、档案库房、仓库等)',
  277. },
  278. { label: '老旧厂房', value: '老旧厂房' },
  279. { label: '施工现场', value: '施工现场' },
  280. { label: '职工食堂', value: '职工食堂' },
  281. { label: '职工宿舍', value: '职工宿舍' },
  282. { label: '体育活动场所', value: '体育活动场所' },
  283. { label: '托育园', value: '托育园' },
  284. { label: '租、出借房屋', value: '租、出借房屋' },
  285. { label: '院内经营服务场所', value: '院内经营服务场所' },
  286. { label: '垃圾房', value: '垃圾房' },
  287. { label: '院内交通', value: '院内交通' },
  288. { label: '消防设施设备', value: '消防设施设备' },
  289. { label: '特种设备', value: '特种设备' },
  290. { label: '防雷设施', value: '防雷设施' },
  291. { label: '供、配电设施设备(含弱电)', value: '供、配电设施设备(含弱电)' },
  292. { label: '公务车辆', value: '公务车辆' },
  293. { label: '燃气管道设施(含报警装置)', value: '燃气管道设施(含报警装置)' },
  294. { label: '建筑物外墙标识物、装饰物', value: '建筑物外墙标识物、装饰物' },
  295. { label: 'UPS电源', value: 'UPS电源' },
  296. { label: '危险化学品', value: '危险化学品' },
  297. { label: '设施设备应急操作流程', value: '设施设备应急操作流程' },
  298. { label: '堆场、物资库房', value: '堆场、物资库房' },
  299. { label: '室内外停车场', value: '室内外停车场' },
  300. ];
  301. getTableData();
  302. });
  303. </script>
  304. <style scoped lang="scss">
  305. @use '@/styles/page-details-layout.scss' as *;
  306. @use '@/styles/page-main-layout.scss' as *;
  307. @use '@/styles/basic-table-action.scss' as *;
  308. @use '@/views/traffic/violation/style/act-search-table.scss' as *;
  309. :deep(.preview-img){
  310. img{
  311. max-width: 100%;
  312. max-height: 80vh;
  313. }
  314. }
  315. </style>