index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="任务名称" prop="taskName">
  5. <el-input
  6. v-model="queryParams.taskName"
  7. placeholder="请输入任务名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="任务类型" prop="planId">
  13. <el-select v-model="queryParams.taskType" @change="handleQuery" placeholder="请选择任务类型" clearable
  14. size="small" style="width: 100%">
  15. <el-option
  16. v-for="dict in taskTypeOperation"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="任务起始时间" prop="startTime" label-width="100px">
  24. <el-date-picker clearable @change="handleQuery"
  25. v-model="queryParams.startTime"
  26. type="date"
  27. value-format="yyyy-MM-dd"
  28. placeholder="请选择任务起始时间">
  29. </el-date-picker>
  30. </el-form-item>
  31. <el-form-item label="任务截止时间" prop="endTime" label-width="100px">
  32. <el-date-picker clearable @change="handleQuery"
  33. v-model="queryParams.endTime"
  34. type="date"
  35. value-format="yyyy-MM-dd"
  36. placeholder="请选择任务截止时间">
  37. </el-date-picker>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  41. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  42. </el-form-item>
  43. </el-form>
  44. <el-row :gutter="10" class="mb8">
  45. <el-col :span="1.5">
  46. <el-button
  47. type="primary"
  48. plain
  49. icon="el-icon-plus"
  50. size="mini"
  51. @click="handleAdd"
  52. v-hasPermi="['task:repair:add']"
  53. >新增
  54. </el-button>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button
  58. type="success"
  59. plain
  60. icon="el-icon-edit"
  61. size="mini"
  62. :disabled="single"
  63. @click="handleUpdate"
  64. v-hasPermi="['task:repair:edit']"
  65. >修改
  66. </el-button>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-button
  70. type="danger"
  71. plain
  72. icon="el-icon-delete"
  73. size="mini"
  74. :disabled="multiple"
  75. @click="handleDelete"
  76. v-hasPermi="['task:repair:remove']"
  77. >删除
  78. </el-button>
  79. </el-col>
  80. <el-col :span="1.5">
  81. <el-button
  82. type="warning"
  83. plain
  84. icon="el-icon-check"
  85. size="mini"
  86. :disabled="multiple"
  87. @click="handleDivide"
  88. v-hasPermi="['task:repairs:edit']"
  89. >确认分配
  90. </el-button>
  91. </el-col>
  92. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  93. </el-row>
  94. <el-table v-loading="loading" :data="repairList" @selection-change="handleSelectionChange" :height="clientHeight"
  95. :cell-style="tableCellStyle" border>
  96. <el-table-column type="selection" width="55" align="center"/>
  97. <el-table-column label="状态" align="center" prop="status" fixed="left" width="85" :formatter="divideFormat"/>
  98. <el-table-column label="是否超时" align="center" prop="timeOut" fixed="left" width="85"/>
  99. <el-table-column label="装置名称" align="center" prop="plantName" :show-overflow-tooltip="true" width="130"/>
  100. <el-table-column label="任务名称" align="center" prop="taskName" :show-overflow-tooltip="true" width="130"/>
  101. <el-table-column label="任务编号" align="center" prop="taskCode" :show-overflow-tooltip="true" width="130"/>
  102. <el-table-column label="任务类型" align="center" prop="taskType" :show-overflow-tooltip="true" width="130"
  103. :formatter="taskTypeFormat"/>
  104. <el-table-column label="任务起始时间" align="center" prop="startTime" width="180">
  105. <template slot-scope="scope">
  106. <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="任务截止时间" align="center" prop="endTime" width="180">
  110. <template slot-scope="scope">
  111. <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="接收人" align="center" prop="recipientName" :show-overflow-tooltip="true" width="130"/>
  115. <el-table-column label="维修点数" align="center" prop="taskNum" :show-overflow-tooltip="true" width="130"/>
  116. <el-table-column label="已维修点数" align="center" prop="taskDoneNum" :show-overflow-tooltip="true" width="130"/>
  117. <el-table-column label="未维修点数" align="center" prop="taskUndoneNum" :show-overflow-tooltip="true"
  118. width="130"/>
  119. <el-table-column label="完成率" align="center" width="250" prop="percentage">
  120. <template slot-scope="scope">
  121. <el-progress :text-inside="true" :stroke-width="14" :percentage="scope.row.percentage"
  122. status="success"></el-progress>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true" width="130"/>
  126. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="130">
  127. <template slot-scope="scope">
  128. <el-button
  129. size="mini"
  130. type="text"
  131. icon="el-icon-s-order"
  132. @click="openCheckPoint(scope.row)"
  133. >维修点清单
  134. </el-button>
  135. <el-button
  136. size="mini"
  137. type="text"
  138. icon="el-icon-edit"
  139. @click="handleUpdate(scope.row)"
  140. v-hasPermi="['task:repair:edit']"
  141. >修改
  142. </el-button>
  143. <el-button
  144. size="mini"
  145. type="text"
  146. icon="el-icon-delete"
  147. @click="handleDelete(scope.row)"
  148. v-hasPermi="['task:repair:remove']"
  149. >删除
  150. </el-button>
  151. </template>
  152. </el-table-column>
  153. </el-table>
  154. <pagination
  155. v-show="total>0"
  156. :total="total"
  157. :page.sync="queryParams.pageNum"
  158. :limit.sync="queryParams.pageSize"
  159. @pagination="getList"
  160. />
  161. <!-- 添加或修改维修任务对话框 -->
  162. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  163. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  164. <el-form-item label="任务名称" prop="taskName">
  165. <el-input v-model="form.taskName" placeholder="请输入任务名称"/>
  166. </el-form-item>
  167. <el-form-item label="任务编号" prop="taskCode">
  168. <el-input v-model="form.taskCode" placeholder="请输入任务编号"/>
  169. </el-form-item>
  170. <el-form-item label="装置" prop="plantId">
  171. <el-select v-model="form.plantId" placeholder="请选择装置" clearable size="small" style="width: 100%">
  172. <el-option
  173. v-for="dict in plantOperation"
  174. :key="dict.plantId"
  175. :label="dict.plantName"
  176. :value="dict.plantId"
  177. />
  178. </el-select>
  179. </el-form-item>
  180. <el-form-item label="任务类型" prop="taskType">
  181. <el-select v-model="form.taskType" placeholder="请选择任务类型" clearable size="small" style="width: 100%">
  182. <el-option
  183. v-for="dict in taskTypeOperation"
  184. :key="dict.dictValue"
  185. :label="dict.dictLabel"
  186. :value="dict.dictValue"
  187. />
  188. </el-select>
  189. </el-form-item>
  190. <el-form-item label="任务起始时间" prop="startTime">
  191. <el-date-picker clearable style="width: 100%"
  192. v-model="form.startTime"
  193. type="date"
  194. value-format="yyyy-MM-dd"
  195. placeholder="请选择任务起始时间">
  196. </el-date-picker>
  197. </el-form-item>
  198. <el-form-item label="任务截止时间" prop="endTime">
  199. <el-date-picker clearable style="width: 100%"
  200. v-model="form.endTime"
  201. type="date"
  202. value-format="yyyy-MM-dd"
  203. placeholder="请选择任务截止时间">
  204. </el-date-picker>
  205. </el-form-item>
  206. <el-form-item label="接收人" prop="recipient">
  207. <el-select v-model="form.recipient" placeholder="请选择接收人" clearable size="small" style="width: 100%">
  208. <el-option
  209. v-for="dict in userOperation"
  210. :key="dict.userId"
  211. :label="dict.userName"
  212. :value="dict.userId"
  213. />
  214. </el-select>
  215. </el-form-item>
  216. <el-form-item label="备注" prop="remarks">
  217. <el-input v-model="form.remarks" placeholder="请输入备注"/>
  218. </el-form-item>
  219. </el-form>
  220. <div slot="footer" class="dialog-footer">
  221. <el-button type="primary" @click="submitForm">确 定</el-button>
  222. <el-button @click="cancel">取 消</el-button>
  223. </div>
  224. </el-dialog>
  225. <repair-point v-if="pointVisible" ref="repairPointList"></repair-point>
  226. <repair-enter v-if="enterVisible" ref="repairEnterList"></repair-enter>
  227. </div>
  228. </template>
  229. <script>
  230. import {listRepair, getRepair, delRepair, addRepair, updateRepair, divideRepair} from "@/api/task/repair";
  231. import {divideInspection} from "@/api/task/inspection";
  232. import {getAllPlantName} from "@/api/base/plant";
  233. import RepairPoint from "@/views/task/repair/repairPoint";
  234. import RepairEnter from "@/views/check/repairCheck/repairEnter";
  235. import {MessageBox} from "element-ui";
  236. import {allUser} from "@/api/system/user";
  237. export default {
  238. name: "Repair",
  239. components: {RepairEnter, RepairPoint},
  240. data() {
  241. return {
  242. pointVisible: false,
  243. enterVisible: false,
  244. divideOperation: [],
  245. userOperation: [],
  246. taskTypeOperation: [],
  247. plantOperation: [],
  248. // 页面高度
  249. clientHeight: 300,
  250. // 遮罩层
  251. loading: true,
  252. // 选中数组
  253. ids: [],
  254. divideStatus: [],
  255. // 非单个禁用
  256. single: true,
  257. // 非多个禁用
  258. multiple: true,
  259. // 显示搜索条件
  260. showSearch: false,
  261. // 总条数
  262. total: 0,
  263. // 维修任务表格数据
  264. repairList: [],
  265. // 弹出层标题
  266. title: "",
  267. // 是否显示弹出层
  268. open: false,
  269. // 查询参数
  270. queryParams: {
  271. pageNum: 1,
  272. pageSize: 10,
  273. plantId: null,
  274. taskName: null,
  275. taskCode: null,
  276. taskType: null,
  277. startTime: null,
  278. endTime: null,
  279. recipient: null,
  280. taskNum: null,
  281. taskDoneNum: null,
  282. taskUndoneNum: null,
  283. status: null,
  284. remarks: null,
  285. deptId: null,
  286. createrCode: null,
  287. createdate: null,
  288. updaterCode: null,
  289. updatedate: null
  290. },
  291. // 表单参数
  292. form: {},
  293. // 表单校验
  294. rules: {
  295. plantId: [
  296. {required: true, message: '请选择装置', trigger: "blur"}
  297. ],
  298. taskType: [
  299. {required: true, message: '请选择任务类型', trigger: "blur"}
  300. ],
  301. taskCode: [
  302. {required: true, message: '请输入任务编号', trigger: "blur"}
  303. ],
  304. taskName: [
  305. {required: true, message: '请输入任务名称', trigger: "blur"}
  306. ],
  307. startTime: [
  308. {required: true, message: '请选择任务开始时间', trigger: "blur"}
  309. ],
  310. endTime: [
  311. {required: true, message: '请选择任务结束时间', trigger: "blur"}
  312. ],
  313. recipient: [
  314. {required: true, message: '请选择接收人', trigger: "blur"}
  315. ],
  316. }
  317. };
  318. },
  319. created() {
  320. this.getList();
  321. //设置表格高度对应屏幕高度
  322. this.$nextTick(() => {
  323. this.clientHeight = (document.body.clientHeight - 80) * 0.8
  324. });
  325. this.getDicts("divide_status").then(response => {
  326. this.divideOperation = response.data;
  327. });
  328. this.getDicts("repair_type").then(response => {
  329. this.taskTypeOperation = response.data;
  330. });
  331. getAllPlantName().then(response => {
  332. this.plantOperation = response.data;
  333. });
  334. allUser({}).then(res=>{
  335. this.userOperation=res.data;
  336. })
  337. },
  338. methods: {
  339. openCheckPoint(row) {
  340. if (row.status == 1) {
  341. row.isEnter = false;
  342. this.enterVisible = true;
  343. this.$nextTick(() => {
  344. this.$refs.repairEnterList.openDialog(row)
  345. })
  346. } else {
  347. this.pointVisible = true;
  348. this.$nextTick(() => {
  349. this.$refs.repairPointList.openDialog(row)
  350. })
  351. }
  352. },
  353. taskTypeFormat(row, column) {
  354. return this.selectDictLabel(this.taskTypeOperation, row.taskType);
  355. },
  356. tableCellStyle({row, column, rowIndex, columnIndex}) {
  357. if (columnIndex === 1 && row.status == 0) {
  358. return "color:#ff0000;";
  359. }
  360. if (columnIndex === 1 && row.status == 1) {
  361. return "color:#00cc00;";
  362. }
  363. if (columnIndex === 2 && row.timeOut === '是') {
  364. return "color:#ff0000;";
  365. }
  366. if (columnIndex === 2 && row.timeOut === '否') {
  367. return "color:#00cc00;";
  368. }
  369. if (columnIndex === 6) {
  370. return "color:#00d;";
  371. }
  372. },
  373. handleDivide() {
  374. console.log(this.divideStatus)
  375. for (let statusKey of this.divideStatus) {
  376. if (statusKey === "1") {
  377. this.$alert('已分配的任务不可再次分配!', '注意!', {
  378. confirmButtonText: '确定',
  379. });
  380. return
  381. }
  382. }
  383. this.reset();
  384. const ids = this.ids
  385. this.$modal.confirm('是否确认分配?').then(function () {
  386. return divideRepair(ids);
  387. }).then(() => {
  388. this.getList();
  389. this.$modal.msgSuccess("分配成功");
  390. }).catch(() => {
  391. this.$modal.msg("取消分配");
  392. });
  393. },
  394. divideFormat(row, column) {
  395. return this.selectDictLabel(this.divideOperation, row.status);
  396. },
  397. /** 查询维修任务列表 */
  398. getList() {
  399. this.loading = true;
  400. listRepair(this.queryParams).then(response => {
  401. this.repairList = response.rows;
  402. this.total = response.total;
  403. this.loading = false;
  404. });
  405. },
  406. // 取消按钮
  407. cancel() {
  408. this.open = false;
  409. this.reset();
  410. },
  411. // 表单重置
  412. reset() {
  413. this.form = {
  414. id: null,
  415. plantId: null,
  416. taskName: null,
  417. taskCode: null,
  418. taskType: '1',
  419. startTime: null,
  420. endTime: null,
  421. recipient: null,
  422. taskNum: null,
  423. taskDoneNum: null,
  424. taskUndoneNum: null,
  425. status: "0",
  426. remarks: null,
  427. deptId: null,
  428. delFlag: null,
  429. createrCode: null,
  430. createdate: null,
  431. updaterCode: null,
  432. updatedate: null
  433. };
  434. this.resetForm("form");
  435. },
  436. /** 搜索按钮操作 */
  437. handleQuery() {
  438. this.queryParams.pageNum = 1;
  439. this.getList();
  440. },
  441. /** 重置按钮操作 */
  442. resetQuery() {
  443. this.resetForm("queryForm");
  444. this.handleQuery();
  445. },
  446. // 多选框选中数据
  447. handleSelectionChange(selection) {
  448. this.ids = selection.map(item => item.id)
  449. this.divideStatus = selection.map(item => item.status)
  450. this.single = selection.length !== 1
  451. this.multiple = !selection.length
  452. },
  453. /** 新增按钮操作 */
  454. handleAdd() {
  455. this.reset();
  456. this.open = true;
  457. this.title = "添加维修任务";
  458. },
  459. /** 修改按钮操作 */
  460. handleUpdate(row) {
  461. if (row.status != 0) {
  462. MessageBox.alert('已分配的任务不可修改!', '注意!', {
  463. confirmButtonText: '确定',
  464. })
  465. return
  466. }
  467. this.reset();
  468. const id = row.id || this.ids
  469. getRepair(id).then(response => {
  470. this.form = response.data;
  471. this.open = true;
  472. this.title = "修改维修任务";
  473. });
  474. },
  475. /** 提交按钮 */
  476. submitForm() {
  477. this.$refs["form"].validate(valid => {
  478. if (valid) {
  479. if (this.form.id != null) {
  480. updateRepair(this.form).then(response => {
  481. this.$modal.msgSuccess("修改成功");
  482. this.open = false;
  483. this.getList();
  484. });
  485. } else {
  486. addRepair(this.form).then(response => {
  487. this.$modal.msgSuccess("新增成功");
  488. this.open = false;
  489. this.getList();
  490. });
  491. }
  492. }
  493. });
  494. },
  495. /** 删除按钮操作 */
  496. handleDelete(row) {
  497. if (row.status === undefined) {
  498. for (let i = 0; i < this.divideStatus.length; i++) {
  499. if (this.divideStatus[i] != 0) {
  500. MessageBox.alert('已分配的任务不可删除!', '注意!', {
  501. confirmButtonText: '确定',
  502. })
  503. return
  504. }
  505. }
  506. } else if (row.status != 0) {
  507. MessageBox.alert('已分配的任务不可删除!', '注意!', {
  508. confirmButtonText: '确定',
  509. })
  510. return
  511. }
  512. const ids = row.id || this.ids;
  513. this.$modal.confirm('是否确认删除数据项?').then(function () {
  514. return delRepair(ids);
  515. }).then(() => {
  516. this.getList();
  517. this.$modal.msgSuccess("删除成功");
  518. }).catch(() => {
  519. });
  520. },
  521. /** 导出按钮操作 */
  522. handleExport() {
  523. this.download('task/repair/export', {
  524. ...this.queryParams
  525. }, `repair_${new Date().getTime()}.xlsx`)
  526. }
  527. }
  528. };
  529. </script>