PageDisposalRectification.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class="disaster-precaution-container">
  3. <header class="disaster-precaution-container__header">
  4. <span class="disaster-precaution-container__title">灾害损失处置整改</span>
  5. </header>
  6. <main class="disaster-precaution-container__main">
  7. <div class="disaster-precaution">
  8. <header class="disaster-precaution__header">
  9. <Search
  10. :searchConfig="DISPOSAL_RECTIFICATION_SEARCH_CONFIG"
  11. :searchData="searchData"
  12. @update:searchData="handleSearch"
  13. >
  14. <template #priority>
  15. <el-select v-model="searchData.priority" placeholder="请选择优先级" class="custom-select">
  16. <el-option
  17. v-for="item in priorityDice"
  18. :key="item.itemCode"
  19. :label="item.itemValue"
  20. :value="item.itemCode"
  21. />
  22. </el-select>
  23. </template>
  24. </Search>
  25. </header>
  26. <section class="disaster-precaution__section">
  27. <div class="collapse-container" v-loading="collapseLoading">
  28. <div class="empty-container" v-if="collapseList.length === 0">
  29. <img :src="Empty" />
  30. <span>暂无数据</span>
  31. </div>
  32. <template v-else>
  33. <CollapseItem
  34. ref="collapseItemRef"
  35. v-for="item in collapseList"
  36. :key="item.id"
  37. :name="item.taskName"
  38. :defaultOpen="item.id === collapseList[0].id"
  39. >
  40. <template #viewOperation> <img :src="ViewDocument" class="collapse-item__icon" /> </template>
  41. <template #main-table>
  42. <BasicTable :tableData="item.tableData[0].disasterReportRecordDetailList" :tableConfig="tableConfig">
  43. <template #affectedArea="scope">
  44. <div class="affected-area-container">
  45. <span>{{ scope.row.buildingNo }}-{{ scope.row.floorNo }}-{{ scope.row.roomNo }}</span>
  46. </div>
  47. </template>
  48. <template #affectedItems="scope">
  49. <el-tooltip
  50. :content="scope.row.affectedItems"
  51. placement="top-start"
  52. effect="light"
  53. v-if="scope.row.affectedItems"
  54. >
  55. <div class="affected-items-container">
  56. <span>{{ scope.row.affectedItems }}</span>
  57. </div>
  58. </el-tooltip>
  59. <span v-else>--</span>
  60. </template>
  61. <template #responsibleDeptName="scope">
  62. <span v-if="scope.row.responsibleDeptName">{{ scope.row.responsibleDeptName }}</span>
  63. <span v-else>--</span>
  64. </template>
  65. <template #priority="scope">
  66. <span v-if="scope.row.priority">{{ getPriority(scope.row.priority) }}</span>
  67. <span v-else>--</span>
  68. </template>
  69. <template #fixStatus="scope">
  70. <span v-if="scope.row.fixStatus">{{ getfixStatus(scope.row.fixStatus) }}</span>
  71. <span v-else>--</span>
  72. </template>
  73. <template #action="scope">
  74. <div class="action-container" v-if="scope.row.fixStatus === FIX_STATUS.TO_BE_RECTIFIED">
  75. <ActionButton text="查看" />
  76. <ActionButton
  77. text="去整改"
  78. @click="
  79. handleRectification(
  80. scope.row.id,
  81. item.id,
  82. scope.row.fixTaskId,
  83. item.tableData[0].disasterReportRecordDetailList,
  84. )
  85. "
  86. />
  87. <ActionButton
  88. text="添加整改人"
  89. v-if="scope.row.isFixPrincipal"
  90. @click="handleAddFixer(scope.row.id, scope.row.fixerList)"
  91. />
  92. </div>
  93. <div class="action-container" v-else>
  94. <ActionButton text="查看" />
  95. <ActionButton
  96. text="去整改"
  97. @click="
  98. handleRectification(
  99. scope.row.id,
  100. item.id,
  101. scope.row.fixTaskId,
  102. item.tableData[0].disasterReportRecordDetailList,
  103. )
  104. "
  105. />
  106. </div>
  107. </template>
  108. </BasicTable>
  109. </template>
  110. </CollapseItem>
  111. </template>
  112. </div>
  113. <div class="pagination-container" v-if="collapseList.length > 0">
  114. <el-pagination
  115. :current-page="currentPage"
  116. :page-size="pageSize"
  117. :page-sizes="DISASTER_CONTROL_PAGE_SIZE_CONFIG"
  118. layout="prev, pager, next, jumper, sizes, total"
  119. background
  120. :total="total"
  121. @size-change="handleSizeChange"
  122. @current-change="handleCurrentChange"
  123. />
  124. </div>
  125. </section>
  126. </div>
  127. </main>
  128. <el-dialog v-model="userInfo" title="添加整改人" destroy-on-close>
  129. <InspectorSelect
  130. :customUserList="currentTaskInspectorList"
  131. @cancel="userInfo = false"
  132. @submit="handleAddFixerSubmit"
  133. />
  134. </el-dialog>
  135. </div>
  136. </template>
  137. <script setup lang="ts">
  138. import Search from '@/views/disaster/components/Search.vue';
  139. import CollapseItem from './src/components/CollapseItem.vue';
  140. import BasicTable from '@/components/BasicTable.vue';
  141. import InspectorSelect from '@/views/disaster/components/InspectorSelect.vue';
  142. import { nextTick, onMounted, reactive, ref } from 'vue';
  143. import { getDisasterControlCollapseData, getLossRecordTableData, addFixer } from '@/api/disaster-control';
  144. import type { disasterReportTaskInfoListResponse } from '@/types/disaster-control';
  145. import { DEFAULT_PAGE_SIZE, DISASTER_CONTROL_PAGE_SIZE_CONFIG, FIX_STATUS } from './src/constant';
  146. import type {
  147. DisposalManagementCollapseListResponse,
  148. LossRecordTableResponse,
  149. disasterReportRecordDetailListResponse,
  150. } from '@/types/disaster-control';
  151. import useTableConfig from '@/hooks/useTableConfigHook';
  152. import {
  153. DISPOSAL_RECTIFICATION_SEARCH_CONFIG,
  154. LOSS_RECORD_TABLE_COLUMNS,
  155. DISPOSAL_MANAGEMENT_TABLE_OPTIONS,
  156. } from './src/config';
  157. import { getfixStatus } from './src/util';
  158. import { ACTIVE_STATUS } from '@/views/disaster/constant';
  159. import ActionButton from '@/components/ActionButton.vue';
  160. import { useRouter } from 'vue-router';
  161. import Empty from 'assets/images/empty@1X.png';
  162. import ViewDocument from './src/svg/view-document.svg';
  163. import { useDisasterControlHook } from './src/hook';
  164. import type { PersonGroupItem } from '@/types/person-group/type';
  165. import { queryUserInfoByIds } from '@/api/system/person-group';
  166. import { ElMessage } from 'element-plus';
  167. const { getPriority, getPriorityDict, priorityDice } = useDisasterControlHook();
  168. const collapseItemRef = ref<InstanceType<typeof CollapseItem>[]>([]);
  169. const searchData = reactive({
  170. priority: null,
  171. fixStatus: '',
  172. isLoss: 1,
  173. });
  174. const userInfo = ref(false);
  175. const currentTaskInspectorList = ref<PersonGroupItem[]>([]);
  176. const currentPage = ref(1);
  177. const pageSize = ref(DEFAULT_PAGE_SIZE);
  178. const total = ref(0);
  179. const collapseLoading = ref(false);
  180. const collapseList = ref<DisposalManagementCollapseListResponse<LossRecordTableResponse>[]>([]);
  181. const { tableConfig } = useTableConfig(LOSS_RECORD_TABLE_COLUMNS, DISPOSAL_MANAGEMENT_TABLE_OPTIONS, false);
  182. const handleSizeChange = async (size: number) => {
  183. pageSize.value = size;
  184. await getDisposalData();
  185. await getDisposalTableData();
  186. };
  187. const handleCurrentChange = async (page: number) => {
  188. currentPage.value = page;
  189. await getDisposalData();
  190. await getDisposalTableData();
  191. };
  192. const handleSearch = () => {
  193. searchData.isLoss = 1;
  194. getDisposalTableData();
  195. };
  196. const taskIds = ref<number[]>([]);
  197. const router = useRouter();
  198. const Table_RouterName = 'disaster-control-disposal-management-item';
  199. const handleEditDisposalManagement = (id: number) => {
  200. router.push({
  201. name: Table_RouterName,
  202. query: {
  203. id,
  204. operate: 'edit',
  205. },
  206. });
  207. };
  208. const getDisposalData = async () => {
  209. collapseLoading.value = true;
  210. const res = await getDisasterControlCollapseData({
  211. pageNumber: currentPage.value,
  212. pageSize: pageSize.value,
  213. queryParam: {},
  214. });
  215. collapseList.value = res.records.map((item) => ({
  216. ...item,
  217. tableData: [
  218. {
  219. handleTaskId: item.id,
  220. disasterReportRecordDetailList: [],
  221. },
  222. ],
  223. }));
  224. taskIds.value = collapseList.value.map((item) => item.id);
  225. total.value = res.totalRow;
  226. collapseLoading.value = false;
  227. nextTick(() => {
  228. collapseItemRef.value[0]?.openFirstCollapseItem();
  229. });
  230. };
  231. const getDisposalTableData = async () => {
  232. tableConfig.loading = true;
  233. const res = await getLossRecordTableData({
  234. handleTaskIds: taskIds.value,
  235. ...searchData,
  236. });
  237. collapseList.value.forEach((item) => {
  238. item.tableData = res.filter((tableItem) => tableItem.handleTaskId === item.id);
  239. });
  240. tableConfig.loading = false;
  241. };
  242. const currentTaskId = ref<number>();
  243. const handleAddFixer = async (id: number, fixerList: string) => {
  244. currentTaskId.value = id;
  245. const userIds = JSON.parse(fixerList) || [];
  246. if (!userIds.length) return;
  247. const res = await queryUserInfoByIds(userIds);
  248. currentTaskInspectorList.value = res.map((user) => {
  249. return {
  250. ...user,
  251. checked: true,
  252. };
  253. });
  254. userInfo.value = true;
  255. };
  256. const handleAddFixerSubmit = async (ids: number[]) => {
  257. if (!currentTaskId.value) return;
  258. await addFixer(currentTaskId.value, ids);
  259. ElMessage.success('添加整改人成功');
  260. userInfo.value = false;
  261. getDisposalTableData();
  262. };
  263. const defaultRouterName = 'disaster-control-disposal-rectification-item';
  264. const handleRectification = (
  265. id: number,
  266. handleTaskId: number,
  267. fixTaskId: number,
  268. detailList: disasterReportRecordDetailListResponse[],
  269. ) => {
  270. const rectificationIds = detailList
  271. .filter((item) => item.fixStatus === FIX_STATUS.TO_BE_RECTIFIED)
  272. .map((item) => item.id);
  273. sessionStorage.setItem('rectificationIds', JSON.stringify(rectificationIds));
  274. router.push({
  275. name: defaultRouterName,
  276. params: {
  277. id,
  278. },
  279. query: {
  280. handleTaskId,
  281. fixTaskId,
  282. },
  283. });
  284. };
  285. const isViewTask = (disasterReportTaskInfoList: disasterReportTaskInfoListResponse[]) => {
  286. return disasterReportTaskInfoList.some((item) => item.status === ACTIVE_STATUS.ACTIVE);
  287. };
  288. const handleViewTask = (id: number) => {
  289. console.log('查看任务ID' + id);
  290. };
  291. onMounted(async () => {
  292. getPriorityDict();
  293. await getDisposalData();
  294. await getDisposalTableData();
  295. });
  296. </script>
  297. <style scoped lang="scss">
  298. @use '../style/disaster.scss' as *;
  299. @use './src/style/collapse.scss' as *;
  300. @use './src/style/common.scss' as *;
  301. $collapse-container-height-default: calc(68vh - 43px);
  302. .collapse-container {
  303. height: $collapse-container-height-default;
  304. max-height: $collapse-container-height-default;
  305. }
  306. .collapse-item__icon {
  307. width: 20px;
  308. &--disabled {
  309. cursor: not-allowed;
  310. opacity: 0.5;
  311. }
  312. }
  313. </style>