index.vue 16 KB

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