create-plan.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="safety-platform-container">
  3. <header class="safety-platform-container__header">
  4. <div class="breadcrumb-title"> {{ detailData?.hazardName }} </div>
  5. <div class="detail-content">
  6. <span>编号:{{ detailData?.hazardCode }} </span>
  7. <span>创建人:{{ detailData?.createdByName }} </span>
  8. <span>创建时间:{{ detailData?.createdAt }} </span>
  9. </div>
  10. <el-tabs v-model="activeTab">
  11. <el-tab-pane label="全部" name="" />
  12. <el-tab-pane label="待开始" :name="1" />
  13. <el-tab-pane label="进行中" :name="2" />
  14. <el-tab-pane label="已完成" :name="3" />
  15. </el-tabs>
  16. </header>
  17. <main class="safety-platform-container__main">
  18. <div class="search-form">
  19. <el-form :inline="true">
  20. <el-form-item label="状态">
  21. <el-select v-model="queryParams.queryParam.status" clearable placeholder="状态" style="width: 170px">
  22. <el-option value="" label="全部" />
  23. <el-option :value="1" label="待开始" />
  24. <el-option :value="2" label="进行中" />
  25. <el-option :value="3" label="已完成" />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="部门名称">
  29. <el-cascader
  30. v-model="queryParams.queryParam.responsibleDepartmentId"
  31. style="width: 170px"
  32. ref="cascaderRef"
  33. :options="firstLevelDepts"
  34. :props="cascaderProp"
  35. :show-all-levels="false"
  36. placeholder="部门名称"
  37. filterable
  38. @change="handleChangeDept"
  39. />
  40. </el-form-item>
  41. <el-form-item label="计划日期">
  42. <el-date-picker
  43. v-model="queryParams.queryParam.date"
  44. clearable
  45. type="daterange"
  46. start-placeholder="开始时间"
  47. end-placeholder="结束时间"
  48. style="width: 230px"
  49. format="YYYY-MM-DD"
  50. value-format="YYYY-MM-DD"
  51. />
  52. </el-form-item>
  53. </el-form>
  54. <div>
  55. <el-button type="primary" @click="handleAddPlan">添加 </el-button>
  56. <el-button type="primary" @click="queryTableList">查询</el-button>
  57. <el-button @click="handleRestParams">重置</el-button>
  58. </div>
  59. </div>
  60. <div class="table-content">
  61. <el-table :data="tableData.data">
  62. <el-table-column type="index" label="序号" width="80" />
  63. <el-table-column label="计划/方案名称" prop="planName" width="180">
  64. <template #default="scope">
  65. <el-link type="primary" underline @click="handleShowPlan(scope)">
  66. {{ scope.row.planName }}
  67. </el-link>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="状态" prop="statusName" width="100" />
  71. <el-table-column label="执行部门" prop="executorName" width="180" />
  72. <el-table-column label="执行人" prop="executor" width="130" />
  73. <el-table-column label="计划/方案描述" prop="planContent" width="180" />
  74. <el-table-column label="计划开始时间" prop="planStartDate" width="220" />
  75. <el-table-column label="计划结束时间" prop="planEndDate" width="220" />
  76. <el-table-column fixed="right" min-width="240" label="操作">
  77. <template #default="scope">
  78. <el-button type="primary" link @click="handleEditPlan(scope)"> 编辑 </el-button>
  79. <el-button type="primary" link @click="handleConfirmDeleteRow(scope)">删除</el-button>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. </div>
  84. <div class="pagination-container" v-if="tableData.total > 0">
  85. <el-pagination
  86. background
  87. :current-page="queryParams.pageNumber"
  88. :page-size="queryParams.pageSize"
  89. :total="tableData.total"
  90. @size-change="handleSizeChange"
  91. @current-change="handleCurrentChange"
  92. />
  93. </div>
  94. </main>
  95. </div>
  96. <PlansAndProgramsDialog
  97. v-if="planDialogOpen"
  98. v-model.visible="planDialogOpen"
  99. :dialogInfo="dialogInfo"
  100. @submit="handlePlanSubmit"
  101. />
  102. </template>
  103. <script lang="ts" setup>
  104. import { onMounted, reactive, ref } from 'vue';
  105. import { ElMessage } from 'element-plus';
  106. import { useRouter, useRoute } from 'vue-router';
  107. import {
  108. safetyHazardInventoryQueryPlanAndSchemePage,
  109. safetyHazardInventoryDeletePlan,
  110. safetyHazardInventoryQueryPlanDetail,
  111. safetyHazardInventorySavePlan,
  112. safetyHazardInventoryUpdatePlan,
  113. } from '@/api/production-safety/responsibility-implementation';
  114. import { omit } from 'lodash-es';
  115. import { useUserInfoHook } from '@/hooks/useUserInfoHook';
  116. import { unformatAttachment } from '@/components/UploadFiles/utils';
  117. import { downloadFile } from '@/views/disaster/utils';
  118. import { formatDeptTree } from '@/views/disaster/utils/formatDeptTree';
  119. import { getAllDepartments } from '@/api/auth/dept';
  120. import PlansAndProgramsDialog from './components/PlansAndProgramsDialog.vue';
  121. import { exec } from 'child_process';
  122. const router = useRouter();
  123. const route = useRoute();
  124. const { id } = useUserInfoHook();
  125. const firstLevelDepts = ref<any[]>([]);
  126. const cascaderProp = {
  127. expandTrigger: 'click',
  128. checkStrictly: true,
  129. // emitPath: false,
  130. value: 'id',
  131. label: 'deptName',
  132. };
  133. const activeTab = ref('');
  134. const planDialogOpen = ref(false);
  135. const queryParams = reactive<any>({
  136. pageNumber: 1,
  137. pageSize: 10,
  138. queryParam: {
  139. status: '',
  140. date: null,
  141. execDepartment: '',
  142. },
  143. });
  144. const cascaderRef = ref();
  145. const detailData = reactive({
  146. createdAt: '',
  147. createdByName: '',
  148. hazardName: '',
  149. hazardCode: '',
  150. });
  151. const tableData = reactive({
  152. data: [],
  153. total: 0,
  154. });
  155. const dialogInfo = reactive<any>({
  156. title: '新增风险源计划与方案',
  157. currentRow: null,
  158. type: 'add',
  159. });
  160. const handleAddPlan = () => {
  161. planDialogOpen.value = true;
  162. dialogInfo.title = '新增风险源计划与方案';
  163. dialogInfo.type = 'add';
  164. };
  165. const handleEditPlan = async (scope: any) => {
  166. dialogInfo.currentRow = scope.row;
  167. dialogInfo.title = '编辑风险源计划与方案';
  168. dialogInfo.type = 'edit';
  169. planDialogOpen.value = true;
  170. };
  171. const handleShowPlan = async (scope: any) => {
  172. dialogInfo.currentRow = scope.row;
  173. dialogInfo.title = '查看风险源计划与方案';
  174. dialogInfo.type = 'view';
  175. planDialogOpen.value = true;
  176. };
  177. const handleClosePlanDialog = () => {
  178. planDialogOpen.value = false;
  179. dialogInfo.currentRow = null;
  180. dialogInfo.type = '';
  181. dialogInfo.title = '';
  182. };
  183. const handlePlanSubmit = (formData, loading) => {
  184. const req = dialogInfo.type === 'edit' ? safetyHazardInventoryUpdatePlan : safetyHazardInventorySavePlan;
  185. loading.value = true;
  186. req({
  187. ...formData,
  188. id: dialogInfo.type === 'edit' ? dialogInfo.currentRow.id : undefined,
  189. hazardListId: route.query.id,
  190. execDepartmentId: formData.execDepartmentId.join(','),
  191. executor: formData.executor.join(','),
  192. })
  193. .then(() => {
  194. handleClosePlanDialog();
  195. queryTableList();
  196. ElMessage.success('操作成功!');
  197. })
  198. .finally(() => {
  199. loading.value = false;
  200. });
  201. };
  202. const handleSizeChange = (value) => {};
  203. const handleCurrentChange = (value) => {
  204. queryParams.pageNumber = value;
  205. queryTableList();
  206. };
  207. const getDeptData = () => {
  208. getAllDepartments().then((res) => {
  209. firstLevelDepts.value = formatDeptTree(res);
  210. });
  211. };
  212. const handleChangeDept = () => {
  213. const deptInfo = cascaderRef.value?.getCheckedNodes();
  214. if (deptInfo?.[0]) {
  215. queryParams.queryParam.execDepartment = deptInfo[0].label;
  216. }
  217. };
  218. const handleConfirmDeleteRow = (scope) => {
  219. safetyHazardInventoryDeletePlan(scope.row.id).then(() => {
  220. ElMessage.success('删除成功!');
  221. queryTableList();
  222. });
  223. };
  224. const queryTableList = () => {
  225. safetyHazardInventoryQueryPlanAndSchemePage({
  226. ...queryParams,
  227. queryParam: {
  228. ...omit(queryParams.queryParam, ['date', 'responsibleDepartmentId']),
  229. hazardListId: route.query.id,
  230. startTime: queryParams.queryParam.date ? queryParams.queryParam.date[0] : undefined,
  231. endTime: queryParams.queryParam.date ? queryParams.queryParam.date[1] : undefined,
  232. },
  233. }).then((res) => {
  234. tableData.data = res.page.records;
  235. tableData.total = res.totalRow;
  236. Object.assign(detailData, res);
  237. });
  238. };
  239. const handleRestParams = () => {
  240. Object.assign(queryParams, {
  241. pageNumber: 1,
  242. pageSize: 10,
  243. queryParam: {
  244. ...queryParams.queryParam,
  245. status: '',
  246. date: null,
  247. execDepartment: '',
  248. },
  249. });
  250. queryTableList();
  251. };
  252. onMounted(async () => {
  253. await getDeptData();
  254. queryTableList();
  255. });
  256. </script>
  257. <style lang="scss" scoped>
  258. @use '@/styles/page-details-layout.scss' as *;
  259. @use '@/styles/page-main-layout.scss' as *;
  260. @use '@/styles/basic-table-action.scss' as *;
  261. :deep(.el-tabs__header) {
  262. margin: 0;
  263. }
  264. :deep(.el-tabs__item) {
  265. font-size: 14px !important;
  266. }
  267. :deep(.flexContent) {
  268. display: flex;
  269. }
  270. :deep(.breadcrumb .title) {
  271. margin-left: 0;
  272. }
  273. :deep(.el-form) {
  274. flex: 1;
  275. display: flex;
  276. row-gap: 15px;
  277. flex-wrap: wrap;
  278. }
  279. :deep(.el-form-item) {
  280. margin-bottom: 0;
  281. }
  282. :deep(main) {
  283. display: flex;
  284. flex-direction: column;
  285. }
  286. .search-form {
  287. min-width: 800px;
  288. display: flex;
  289. justify-content: space-between;
  290. align-items: center;
  291. margin-bottom: 20px;
  292. }
  293. .button-content {
  294. margin-bottom: 20px;
  295. }
  296. .table-content {
  297. flex: 1;
  298. overflow: hidden;
  299. overflow-y: auto;
  300. }
  301. .page-content {
  302. display: flex;
  303. justify-content: flex-end;
  304. }
  305. </style>