PageDisposalRectification.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. </header>
  15. <div class="collapse-container" v-loading="collapseLoading">
  16. <div class="empty-container" v-if="collapseList.length === 0">
  17. <img :src="Empty" />
  18. <span>暂无数据</span>
  19. </div>
  20. <template v-else>
  21. <CollapseItem
  22. v-for="item in collapseList"
  23. :key="item.id"
  24. :name="item.taskName"
  25. :defaultOpen="item.id === 1"
  26. >
  27. <template #viewOperation> <img :src="ViewDocument" class="collapse-item__icon" /> </template>
  28. <template #main-table>
  29. <BasicTable :tableData="item.tableData[0].disasterReportRecordDetailList" :tableConfig="tableConfig">
  30. <template #affectedArea="scope">
  31. <div class="affected-area-container">
  32. <span>{{ scope.row.buildingNo + scope.row.floorNo + scope.row.roomNo }}</span>
  33. </div>
  34. </template>
  35. <template #affectedItems="scope">
  36. <el-tooltip :content="scope.row.affectedItems" placement="top-start" effect="light">
  37. <div class="affected-items-container">
  38. <span>{{ scope.row.affectedItems }}</span>
  39. </div>
  40. </el-tooltip>
  41. </template>
  42. <template #priority="scope">
  43. <div
  44. class="priority-container"
  45. :class="
  46. scope.row.priority === PRIORITY_STATUS.URGENT
  47. ? 'priority-container--urgent'
  48. : 'priority-container--normal'
  49. "
  50. >
  51. <span>{{ getPriorityStatus(scope.row.priority) }}</span>
  52. </div>
  53. </template>
  54. <template #fixStatus="scope">
  55. <div class="fix-status-container">
  56. <span>{{ getfixStatus(scope.row.fixStatus) }}</span>
  57. </div>
  58. </template>
  59. <template #action="scope">
  60. <div class="action-container" v-if="scope.row.fixStatus === FIX_STATUS.TO_BE_RECTIFIED">
  61. <ActionButton text="查看" />
  62. <ActionButton text="去整改" />
  63. <ActionButton text="添加整改人" />
  64. </div>
  65. <div class="action-container" v-else>
  66. <ActionButton text="查看" />
  67. <ActionButton text="去整改" />
  68. </div>
  69. </template>
  70. </BasicTable>
  71. </template>
  72. </CollapseItem>
  73. </template>
  74. </div>
  75. <div class="pagination-container" v-if="collapseList.length > 0">
  76. <el-pagination
  77. :current-page="currentPage"
  78. :page-size="pageSize"
  79. :page-sizes="DISASTER_CONTROL_PAGE_SIZE_CONFIG"
  80. layout="prev, pager, next, jumper, sizes, total"
  81. background
  82. :total="total"
  83. @size-change="handleSizeChange"
  84. @current-change="handleCurrentChange"
  85. />
  86. </div>
  87. </div>
  88. </main>
  89. </div>
  90. </template>
  91. <script setup lang="ts">
  92. import Search from '@/views/disaster/components/Search.vue';
  93. import CollapseItem from './src/components/CollapseItem.vue';
  94. import BasicTable from '@/components/BasicTable.vue';
  95. import { onMounted, reactive, ref } from 'vue';
  96. import { getDisasterControlCollapseData, getLossRecordTableData } from '@/api/disaster-control';
  97. import type { disasterReportTaskInfoListResponse } from '@/types/disaster-control';
  98. import { DEFAULT_PAGE_SIZE, DISASTER_CONTROL_PAGE_SIZE_CONFIG, PRIORITY_STATUS, FIX_STATUS } from './src/constant';
  99. import type { DisposalManagementCollapseListResponse, LossRecordTableResponse } from '@/types/disaster-control';
  100. import useTableConfig from '@/hooks/useTableConfigHook';
  101. import {
  102. DISPOSAL_RECTIFICATION_SEARCH_CONFIG,
  103. LOSS_RECORD_TABLE_COLUMNS,
  104. DISPOSAL_MANAGEMENT_TABLE_OPTIONS,
  105. } from './src/config';
  106. import { getPriorityStatus, getfixStatus } from './src/util';
  107. import { ACTIVE_STATUS } from '@/views/disaster/constant';
  108. import ActionButton from '@/components/ActionButton.vue';
  109. import { useRouter } from 'vue-router';
  110. import Empty from 'assets/images/empty@1X.png';
  111. import ViewDocument from './src/svg/view-document.svg';
  112. const searchData = reactive({
  113. priority: '',
  114. fixStatus: '',
  115. });
  116. const currentPage = ref(1);
  117. const pageSize = ref(DEFAULT_PAGE_SIZE);
  118. const total = ref(0);
  119. const collapseLoading = ref(false);
  120. const collapseList = ref<DisposalManagementCollapseListResponse<LossRecordTableResponse>[]>([]);
  121. const { tableConfig } = useTableConfig(LOSS_RECORD_TABLE_COLUMNS, DISPOSAL_MANAGEMENT_TABLE_OPTIONS, false);
  122. const handleSizeChange = async (size: number) => {
  123. pageSize.value = size;
  124. await getDisposalData();
  125. await getDisposalTableData();
  126. };
  127. const handleCurrentChange = async (page: number) => {
  128. currentPage.value = page;
  129. await getDisposalData();
  130. await getDisposalTableData();
  131. };
  132. const handleSearch = () => {
  133. getDisposalTableData();
  134. };
  135. const taskIds = ref<number[]>([]);
  136. const router = useRouter();
  137. const Table_RouterName = 'disaster-control-disposal-management-item';
  138. const handleEditDisposalManagement = (id: number) => {
  139. router.push({
  140. name: Table_RouterName,
  141. query: {
  142. id,
  143. operate: 'edit',
  144. },
  145. });
  146. };
  147. const getDisposalData = async () => {
  148. collapseLoading.value = true;
  149. const res = await getDisasterControlCollapseData({
  150. pageNumber: currentPage.value,
  151. pageSize: pageSize.value,
  152. queryParam: {},
  153. });
  154. collapseList.value = res.records.map((item) => ({
  155. ...item,
  156. tableData: [
  157. {
  158. handleTaskId: item.id,
  159. disasterReportRecordDetailList: [],
  160. },
  161. ],
  162. }));
  163. taskIds.value = collapseList.value.map((item) => item.id);
  164. total.value = res.totalRow;
  165. collapseLoading.value = false;
  166. };
  167. const getDisposalTableData = async () => {
  168. tableConfig.loading = true;
  169. const res = await getLossRecordTableData({
  170. handleTaskIds: taskIds.value,
  171. ...searchData,
  172. });
  173. collapseList.value.forEach((item) => {
  174. item.tableData = res.filter((tableItem) => tableItem.handleTaskId === item.id);
  175. });
  176. tableConfig.loading = false;
  177. };
  178. const isViewTask = (disasterReportTaskInfoList: disasterReportTaskInfoListResponse[]) => {
  179. return disasterReportTaskInfoList.some((item) => item.status === ACTIVE_STATUS.ACTIVE);
  180. };
  181. const handleViewTask = (id: number) => {
  182. console.log('查看任务ID' + id);
  183. };
  184. onMounted(async () => {
  185. await getDisposalData();
  186. await getDisposalTableData();
  187. });
  188. </script>
  189. <style scoped lang="scss">
  190. @use '../style/disaster.scss' as *;
  191. @use './src/style/collapse.scss' as *;
  192. @use './src/style/common.scss' as *;
  193. @use './src/style/pagination.scss' as *;
  194. $collapse-container-height-default: calc(68vh - 13cpx);
  195. .collapse-container {
  196. height: $collapse-container-height-default;
  197. max-height: $collapse-container-height-default;
  198. }
  199. .collapse-item__icon {
  200. width: 20cpx;
  201. &--disabled {
  202. cursor: not-allowed;
  203. opacity: 0.5;
  204. }
  205. }
  206. </style>