浏览代码

update:我的工单批量操作

damon227 1 年之前
父节点
当前提交
9f02871e0a
共有 2 个文件被更改,包括 190 次插入33 次删除
  1. 27 0
      src/api/task.js
  2. 163 33
      src/views/modules/works/work.vue

+ 27 - 0
src/api/task.js

@@ -104,3 +104,30 @@ export function getTechList (taskId) {
     method: 'get'
   })
 }
+
+// 批量开始
+export function batchStart (data) {
+  return request({
+    url: request.adornUrl(`/biz-service/WorkController/batch/start`),
+    method: 'post',
+    data
+  })
+}
+
+// 批量检验
+export function batchCheckTask (data) {
+  return request({
+    url: request.adornUrl(`/biz-service/WorkController/batch/check/pass`),
+    method: 'post',
+    data
+  })
+}
+
+// 批量完成
+export function batchCompleteTask (data) {
+  return request({
+    url: request.adornUrl(`/biz-service/WorkController/batch/complete`),
+    method: 'post',
+    data
+  })
+}

+ 163 - 33
src/views/modules/works/work.vue

@@ -11,6 +11,8 @@
       </el-form-item>
       <el-form-item>
         <el-button @click="queryData()" v-reClick>查询</el-button>
+        <el-button @click="batchStart()" v-reClick v-if="dataForm.state === '1'">批量开始</el-button>
+        <el-button @click="batchFinishOrCheck()" v-reClick v-if="dataForm.state === '2'">批量报工/通过</el-button>
       </el-form-item>
     </el-form>
     <el-tabs v-model="dataForm.state" @tab-click="queryData">
@@ -23,7 +25,13 @@
       border
       v-loading="dataListLoading"
       style="width: 100%;"
+      @selection-change="handleSelectionChange"
     >
+      <el-table-column
+        type="selection"
+        :selectable="selected"
+        width="55">
+      </el-table-column>
       <el-table-column label="序号" type="index" width="50" align="center">
       </el-table-column>
       <el-table-column
@@ -107,6 +115,15 @@
         label="操作记录"
       >
       </el-table-column>
+      <el-table-column
+        prop="nextOperator"
+        header-align="center"
+        align="center"
+        min-width="140"
+        :show-tooltip-when-overflow="true"
+        label="下道工序"
+      >
+      </el-table-column>
       <el-table-column
         prop="backExplain"
         header-align="center"
@@ -386,7 +403,7 @@
               <template slot-scope="scope">
                 <el-form-item
                   :prop="
-                    'prodProductionRequireList.' + scope.$index + '.remarks'
+                    'prodProductionRecordList.' + scope.$index + '.remarks'
                   "
                   label-width="0px"
                 >
@@ -471,7 +488,10 @@ import {
   checkTask,
   damageTask,
   getTaskDetail,
-  getTechList
+  getTechList,
+  batchStart,
+  batchCheckTask,
+  batchCompleteTask
 } from '@/api/task'
 import { workTypeMasterList } from '@/api/worktype'
 import templateList from '../warehouse/template-list'
@@ -553,6 +573,7 @@ export default {
         notes: '',
         prodProductionRecordList: []
       },
+      checkDialogBatch: false, // 是否是批量操作
       checkDialogFormRules: {
         operationRecords: [
           { required: true, message: '完成记录说明不能为空', trigger: 'blur' }
@@ -594,7 +615,8 @@ export default {
       },
       taskTypeOption: taskTypeOption,
       rankTypeOption: rankTypeOption,
-      techOptions: []
+      techOptions: [],
+      multipleSelection: [] // 多选的数据
     }
   },
   created () {
@@ -723,21 +745,41 @@ export default {
       this.$refs['finishDialogForm'].validate((valid) => {
         if (valid) {
           let submitData = this.finishDialogForm
-          completeTask(submitData).then(({ data }) => {
-            if (data && data.code === '200') {
-              this.$message({
-                type: 'success',
-                message: '操作成功!'
-              })
-              this.finishDialogFormVisible = false
-              this.getDataList()
-            } else {
-              this.$message({
-                type: 'error',
-                message: data.msg
-              })
-            }
-          })
+          if (this.checkDialogBatch) {
+            // 批量
+            batchCompleteTask(submitData).then(({ data }) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  type: 'success',
+                  message: '操作成功!'
+                })
+                this.finishDialogFormVisible = false
+                this.checkDialogBatch = false
+                this.getDataList()
+              } else {
+                this.$message({
+                  type: 'error',
+                  message: data.msg
+                })
+              }
+            })
+          } else {
+            completeTask(submitData).then(({ data }) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  type: 'success',
+                  message: '操作成功!'
+                })
+                this.finishDialogFormVisible = false
+                this.getDataList()
+              } else {
+                this.$message({
+                  type: 'error',
+                  message: data.msg
+                })
+              }
+            })
+          }
         }
       })
     },
@@ -785,21 +827,40 @@ export default {
         if (valid) {
           let submitData = this.checkDialogForm
           // console.log(submitData);
-          checkTask(submitData).then(({ data }) => {
-            if (data && data.code === '200') {
-              this.$message({
-                type: 'success',
-                message: '检验成功!'
-              })
-              this.checkDialogFormVisible = false
-              this.getDataList()
-            } else {
-              this.$message({
-                type: 'error',
-                message: data.msg
-              })
-            }
-          })
+          if (this.checkDialogBatch) {
+            batchCheckTask(submitData).then(({ data }) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  type: 'success',
+                  message: '批量检验成功!'
+                })
+                this.checkDialogFormVisible = false
+                this.checkDialogBatch = false
+                this.getDataList()
+              } else {
+                this.$message({
+                  type: 'error',
+                  message: data.msg
+                })
+              }
+            })
+          } else {
+            checkTask(submitData).then(({ data }) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  type: 'success',
+                  message: '检验成功!'
+                })
+                this.checkDialogFormVisible = false
+                this.getDataList()
+              } else {
+                this.$message({
+                  type: 'error',
+                  message: data.msg
+                })
+              }
+            })
+          }
         }
       })
     },
@@ -858,6 +919,75 @@ export default {
       this.$nextTick(() => {
         this.$refs.attachDetail.init(attachList)
       })
+    },
+    // 多选-选中事件
+    handleSelectionChange (val) {
+      this.multipleSelection = val
+    },
+    selected (row, index) {
+      if (this.multipleSelection.length === 0) {
+        return true
+      }
+      if (this.multipleSelection.length > 0 && this.multipleSelection[0].nodeId === row.nodeId) {
+        return true
+      }
+      return false
+    },
+    // 批量开始
+    batchStart () {
+      this.$confirm('是否批量开始任务?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      })
+      .then(() => {
+        if (this.multipleSelection.length === 0) {
+          this.$message({
+            type: 'error',
+            message: '请先选择数据,再操作批量开始'
+          })
+        } else {
+          let param = {
+            taskIds: this.multipleSelection.map(t => t.taskId)
+          }
+          batchStart(param).then(({ data }) => {
+            if (data && data.code === '200') {
+              this.$message({
+                type: 'success',
+                message: '操作成功!'
+              })
+              this.multipleSelection = []
+              this.queryData()
+            } else {
+              this.$message({
+                type: 'error',
+                message: data.msg
+              })
+            }
+          })
+        }
+      })
+        .catch(() => {
+          this.$message({
+            type: 'info',
+            message: '已取消'
+          })
+        })
+    },
+    // 批量报工 或 批量通过
+    batchFinishOrCheck () {
+      this.checkDialogBatch = true
+      this.checkDialogForm.taskIds = this.multipleSelection.map(t => t.taskId)
+      // 检验、总检 -> 批量通过
+      if (this.multipleSelection[0].taskType === 'check' || this.multipleSelection[0].taskType === 't-check') {
+        this.checkDialogForm.taskIds = this.multipleSelection.map(t => t.taskId)
+        this.checkTask(this.checkDialogForm.taskIds[0], 1)
+      }
+      // 常规 -> 批量报工
+      if (this.multipleSelection[0].taskType === 'routine') {
+        this.finishDialogFormVisible = true
+        this.finishDialogForm.taskIds = this.multipleSelection.map(t => t.taskId)
+      }
     }
   }
 }