oneByOneManagementDept.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 style="position: relative">
  10. <el-button plain class="search-table-container--button" @click="handleDownload">
  11. 导出
  12. </el-button>
  13. </div>
  14. <div class="act-search">
  15. <section class="select-box">
  16. <div class="select-box--item">
  17. <span>隐患问题:</span>
  18. <el-input
  19. v-model="tableQuery.queryParam.problem"
  20. placeholder="请输入隐患问题"
  21. class="act-search-input"
  22. />
  23. </div>
  24. <div class="select-box--item">
  25. <span>状态:</span>
  26. <el-select
  27. v-model="tableQuery.queryParam.statusId"
  28. placeholder="请选择状态"
  29. clearable
  30. >
  31. <el-option label="待反馈" :value="3" />
  32. <el-option label="待审核" :value="4" />
  33. <el-option label="已完成" :value="5" />
  34. <el-option label="已作废" :value="6" />
  35. </el-select>
  36. </div>
  37. <div class="select-box--item">
  38. <span>计划日期范围:</span>
  39. <el-date-picker
  40. v-model="planDateRange"
  41. type="daterange"
  42. range-separator="至"
  43. start-placeholder="开始日期"
  44. end-placeholder="结束日期"
  45. value-format="YYYY-MM-DD"
  46. clearable
  47. class="act-search-input"
  48. />
  49. </div>
  50. </section>
  51. <section class="search-btn">
  52. <el-button type="primary" @click="handleSearch">查询</el-button>
  53. <el-button @click="handleReset">重置</el-button>
  54. </section>
  55. </div>
  56. </header>
  57. <div class="batch-table">
  58. <BasicTable
  59. ref="basicTableRef"
  60. :tableData="tableData"
  61. :tableConfig="tableConfig"
  62. @update:pageSize="handleSizeChange"
  63. @update:pageNumber="handleCurrentChange"
  64. >
  65. <template #status="scope">
  66. <span>{{ scope.row.statusName || '-' }}</span>
  67. </template>
  68. <template #action="scope">
  69. <div class="action-container--div" style="justify-content: left">
  70. <ActionButton
  71. v-if="scope.row.statusId === 3"
  72. text="反馈"
  73. @click="handleFeedback(scope.row.associationOtId)"
  74. />
  75. <ActionButton
  76. text="查看"
  77. @click="handleView(scope.row.associationOtId)"
  78. />
  79. </div>
  80. </template>
  81. </BasicTable>
  82. </div>
  83. </div>
  84. </main>
  85. <!-- <BatchImport
  86. v-if="batchImportVisible"
  87. :visible="batchImportVisible"
  88. :import-api-url="importApiUrl"
  89. :template-url="templateUrl"
  90. template-name="下载模板"
  91. :show-template="false"
  92. @close="batchImportVisible = false"
  93. @update="handleUpdate"
  94. /> -->
  95. </div>
  96. </template>
  97. <script setup lang="ts">
  98. import { onMounted, reactive, ref } from 'vue';
  99. import { ElMessage } from 'element-plus';
  100. import BasicTable from '@/components/BasicTable.vue';
  101. import useTableConfig from '@/hooks/useTableConfigHook';
  102. import ActionButton from '@/components/ActionButton.vue';
  103. import { TABLE_OPTIONS, DRAW_LESSONS_DEPT_TABLE_COLUMNS } from './configs/tables';
  104. import { useRouter } from 'vue-router';
  105. import type { QueryPageRequest } from '@/types/basic-query';
  106. import {
  107. queryDrawLessonsAdminDeptPage,
  108. type DrawLessonsQueryParam,
  109. } from '@/api/drawLessons';
  110. import { downloadByData } from '@/utils/file/download';
  111. import { useGlobSetting } from '@/hooks/setting';
  112. import urlJoin from 'url-join';
  113. const router = useRouter();
  114. // 表格
  115. const basicTableRef = ref<InstanceType<typeof BasicTable>>();
  116. const { tableConfig, pagination } = useTableConfig(DRAW_LESSONS_DEPT_TABLE_COLUMNS, TABLE_OPTIONS);
  117. const tableData = ref<any[]>([]);
  118. const planDateRange = ref<[string, string] | null>(null);
  119. const tableQuery = reactive<QueryPageRequest<DrawLessonsQueryParam>>({
  120. pageNumber: pagination.pageNumber,
  121. pageSize: pagination.pageSize,
  122. queryParam: {
  123. problem: '',
  124. statusId: undefined,
  125. startTime: undefined,
  126. endTime: undefined,
  127. },
  128. });
  129. const handleSizeChange = (value: number) => {
  130. pagination.pageSize = value;
  131. tableQuery.pageSize = value;
  132. getTableData();
  133. };
  134. const handleCurrentChange = (value: number) => {
  135. pagination.pageNumber = value;
  136. tableQuery.pageNumber = value;
  137. getTableData();
  138. };
  139. function applyPlanDateRange() {
  140. if (planDateRange.value && planDateRange.value.length === 2) {
  141. tableQuery.queryParam.startTime = planDateRange.value[0];
  142. tableQuery.queryParam.endTime = planDateRange.value[1];
  143. } else {
  144. tableQuery.queryParam.startTime = undefined;
  145. tableQuery.queryParam.endTime = undefined;
  146. }
  147. }
  148. async function getTableData() {
  149. applyPlanDateRange();
  150. tableConfig.loading = true;
  151. try {
  152. const res = await queryDrawLessonsAdminDeptPage(tableQuery);
  153. if (res) {
  154. // 这里暂时共用管理员侧分页接口,后端如有部门侧接口再调整
  155. tableData.value = res.records.map((item: any) => ({
  156. id: item.id,
  157. statusId: item.statusId,
  158. problem: item.problem,
  159. statusName: item.statusName,
  160. associationOtObligationDeptName: item.associationOtObligationDeptName,
  161. associationOneThree: item.associationOneThree,
  162. associationOtTimeLimit: item.associationOtTimeLimit,
  163. associationOtId: item.associationOtId,
  164. planCompleteTime: item.planCompleteTime ?? item.associationOtTimeLimit,
  165. }));
  166. pagination.total = (res as any).totalRow ?? (res as any).total ?? 0;
  167. }
  168. } catch (e) {
  169. console.error('获取举一反三部门侧列表失败:', e);
  170. tableData.value = [];
  171. pagination.total = 0;
  172. } finally {
  173. tableConfig.loading = false;
  174. }
  175. }
  176. const handleSearch = () => {
  177. pagination.pageNumber = 1;
  178. tableQuery.pageNumber = 1;
  179. getTableData();
  180. };
  181. const handleReset = () => {
  182. tableQuery.queryParam.problem = '';
  183. tableQuery.queryParam.statusId = undefined;
  184. tableQuery.queryParam.startTime = undefined;
  185. tableQuery.queryParam.endTime = undefined;
  186. planDateRange.value = null;
  187. handleSearch();
  188. };
  189. const { urlPrefix } = useGlobSetting();
  190. const exportApiUrl = ref(urlJoin(urlPrefix, '/api/production/drawLessons/admin/queryPage'));
  191. const handleDownload = async () => {
  192. try {
  193. // 后端如有专门导出接口,可在此替换
  194. await queryDrawLessonsAdminDeptPage(tableQuery);
  195. ElMessage.success('导出逻辑待实现');
  196. } catch (e) {
  197. console.error('导出举一反三失败:', e);
  198. ElMessage.error(e?.message || e?.data || '导出失败,请重试');
  199. }
  200. };
  201. const handleCreate = () => {
  202. router.push({
  203. name: 'oneByOneManagementDeptItem',
  204. query: {
  205. operate: 'one-by-one-dept-create',
  206. },
  207. });
  208. };
  209. /** 反馈:跳转反馈编辑页,操作仅反馈不根据状态显示 */
  210. const handleFeedback = (id: number) => {
  211. router.push({
  212. name: 'oneByOneManagementDeptItem',
  213. query: {
  214. id: String(id),
  215. operate: 'one-by-one-dept-edit',
  216. },
  217. });
  218. };
  219. /** 查看:跳转详情页,操作仅根据状态显示 */
  220. const handleView = (id: number) => {
  221. router.push({
  222. name: 'oneByOneManagementDeptItem',
  223. query: {
  224. id: String(id),
  225. operate: 'one-by-one-dept-view',
  226. },
  227. });
  228. };
  229. onMounted(() => {
  230. getTableData();
  231. });
  232. </script>
  233. <style scoped lang="scss">
  234. @use '@/styles/page-details-layout.scss' as *;
  235. @use '@/styles/page-main-layout.scss' as *;
  236. @use '@/styles/basic-table-action.scss' as *;
  237. @use '@/views/traffic/violation/style/act-search-table.scss' as *;
  238. </style>