incompleted.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <el-dialog v-model="showSearch" title="未完成" width="80%" @close="$emit('close')">
  3. <el-row :gutter="20">
  4. <el-col :lg="4" :xs="24">
  5. <el-tree
  6. ref="deptTreeRef"
  7. class="mt-2"
  8. node-key="id"
  9. :data="deptOptions"
  10. :props="{ label: 'label', children: 'children' }"
  11. :expand-on-click-node="false"
  12. :filter-node-method="filterNode"
  13. highlight-current
  14. default-expand-all
  15. @node-click="handleNodeClick"
  16. />
  17. </el-col>
  18. <el-col :lg="20" :xs="24">
  19. <transition name="fade">
  20. <div v-show="showSearch">
  21. <el-form ref="queryFormRef" :model="queryParams">
  22. <el-button type="primary" @click="handleExport">导出</el-button>
  23. </el-form>
  24. </div>
  25. </transition>
  26. <el-table ref="multipleTable" v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
  27. <el-table-column label="排查范围" align="center" prop="area" />
  28. <el-table-column label="任务进度" align="center" prop="task_status">
  29. <!-- 使用自定义槽来渲染转换后的文本 -->
  30. <template #default="scope">
  31. {{ formatStatus(scope.row.task_status) }}
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="巡查人员" align="center" prop="nick_name" />
  35. <el-table-column label="上报时间" align="center" prop="create_time" />
  36. </el-table>
  37. </el-col>
  38. </el-row>
  39. </el-dialog>
  40. </template>
  41. <script setup lang="ts">
  42. import { onMounted, reactive, ref, watch } from 'vue';
  43. import { useRouter } from 'vue-router';
  44. import { inspectorDivision, patrolNum_1 } from '@/api/inspectionWork/inspector';
  45. import { download2 } from '@/utils/request';
  46. const router = useRouter();
  47. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  48. const loading = ref(true);
  49. const showSearch = ref(true);
  50. const ids = ref<Array<number | string>>([]);
  51. const single = ref(true);
  52. const multiple = ref(true);
  53. const total = ref(0);
  54. const deptOptions = ref([]);
  55. const deptTreeRef = ref(null);
  56. const tableData = ref([]);
  57. const props = defineProps<{ eventId: string, taskId: string, state: string }>();
  58. const initFormData = reactive({
  59. area: '',
  60. task_status: '',
  61. yzy_organization: '',
  62. nick_name: '',
  63. create_time: ''
  64. });
  65. const data = reactive({
  66. form: { ...initFormData },
  67. queryParams: {
  68. area_code: '',
  69. deptId: ''
  70. }
  71. });
  72. const { queryParams, form } = toRefs(data);
  73. const formatStatus = (status) => {
  74. return Number(status) === 1 ? '已完成' : '未完成';
  75. };
  76. const filterNode = (value: string, data: any) => {
  77. if (!value) return true;
  78. return data.label.indexOf(value) !== -1;
  79. };
  80. const getTreeSelect = async () => {
  81. const res = await inspectorDivision();
  82. if (res.code === 200) {
  83. deptOptions.value = res.data; // 将部门树数据赋值给deptOptions
  84. } else {
  85. console.error(res.msg);
  86. }
  87. loading.value = false; // 加载完成后关闭加载提示
  88. };
  89. const fetchUserData = async () => {
  90. loading.value = true; // 开始加载
  91. // 构造请求参数
  92. const params = {
  93. ...queryParams.value,
  94. // 只在area_code有值时添加到请求参数中
  95. ...(queryParams.value.area_code ? { area_code: queryParams.value.area_code } : {})
  96. };
  97. return patrolNum_1(props.eventId, params)
  98. .then((res) => {
  99. if (res.code === 200) {
  100. tableData.value = res.data; // 确保tableData是一个数组
  101. total.value = res.total;
  102. } else {
  103. console.error(res.msg);
  104. }
  105. loading.value = false; // 结束加载
  106. })
  107. .catch((error) => {
  108. console.error('Error fetching sub tasks:', error);
  109. loading.value = false; // 结束加载
  110. });
  111. };
  112. watch(queryParams, () => {
  113. fetchUserData();
  114. });
  115. const handleNodeClick = (data: any) => {
  116. queryParams.value.deptId = data.id;
  117. queryParams.value.area_code = data.code; // 设置 area_code
  118. fetchUserData(); // 调用 fetchUserData 函数更新表格数据
  119. };
  120. const handleSelectionChange = (selection) => {
  121. ids.value = selection.map((item) => item.id);
  122. };
  123. const filename = '未完成情况';
  124. const baseUrl = import.meta.env.VITE_APP_BASE_API;
  125. const handleExport = () => {
  126. download2(baseUrl + '/api/riskManagement/inspection/task/children/task/log/'+props.taskId+'/'+props.state+'/export', filename + '.xlsx');
  127. };
  128. onMounted(async () => {
  129. await getTreeSelect();
  130. fetchUserData();
  131. });
  132. </script>
  133. <style scoped>
  134. .mt-2 {
  135. max-width: 300px; /* 设置最大宽度 */
  136. max-height: 800px; /* 设置最大高度 */
  137. overflow-y: auto; /* 如果内容超出高度则显示滚动条 */
  138. }
  139. </style>