create-plan.vue 10 KB

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