Ver Fonte

工单批量操作

damon227 há 5 meses atrás
pai
commit
af12b0bf3c
2 ficheiros alterados com 110 adições e 56 exclusões
  1. 9 0
      src/api/task.js
  2. 101 56
      src/views/modules/works/work.vue

+ 9 - 0
src/api/task.js

@@ -167,3 +167,12 @@ export function revokeBatch (data) {
     data
   })
 }
+
+// 设备列表
+export function deviceList (params) {
+  return request({
+    url: request.adornUrl(`/biz-service/equipment/listDown`),
+    method: 'get',
+    params: params
+  })
+}

+ 101 - 56
src/views/modules/works/work.vue

@@ -177,10 +177,9 @@
             :disabled="Number(scope.row.state) === 0"
             type="text"
             size="small"
-            @click="startTask(scope.row.taskId)"
+            @click="startTask(scope.row)"
             >开始</el-button
           >
-          <!--          <el-button v-if="isAuth('work:clt:start')" type="text" size="small" @click="startTask(scope.row.taskId)">开始</el-button>-->
           <el-button
             v-if="isAuth('work:clt:transfer') && Number(scope.row.state) !== 3"
             type="text"
@@ -199,7 +198,7 @@
             "
             type="text"
             size="small"
-            @click="completeTask(scope.row.taskId)"
+            @click="completeTask(scope.row)"
             >报工</el-button
           >
           <el-button
@@ -271,6 +270,36 @@
     >
     </el-pagination>
 
+    <el-dialog
+      title="开始任务"
+      width="30%"
+      :visible.sync="startDialogFormVisible"
+    >
+      <el-form
+        :model="startDialogForm"
+        :rules="startDialogFormRules"
+        ref="startDialogForm"
+      >
+        <el-form-item label="数量" prop="count">
+          <el-input-number v-model="startDialogForm.count" :min="1" :max="startDialogForm.maxCount"></el-input-number>
+        </el-form-item>
+        <el-form-item label="设备" >
+          <el-select v-model="startDialogForm.usageRecordId">
+            <el-option
+              v-for="item in devices"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value">
+            </el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer">
+        <el-button @click="startDialogFormVisible = false">取 消</el-button>
+        <el-button type="primary" @click="startSubmit" v-reClick>确 定</el-button>
+      </div>
+    </el-dialog>
+
     <el-dialog
       title="移交任务"
       width="30%"
@@ -281,12 +310,9 @@
         :rules="transferDialogFormRules"
         ref="transferDialogForm"
       >
-        <!-- <el-form-item label="检验类型" prop="checkType" label-width="120px">
-           <el-select v-model="transferDialogForm.checkType" placeholder="请选择检验类型">
-            <el-option label="通过" value="1"></el-option>
-            <el-option label="不通过" value="2"></el-option>
-          </el-select>
-        </el-form-item> -->
+        <el-form-item label="数量" prop="count" label-width="120px">
+          <el-input-number v-model="transferDialogForm.count" :min="1" :max="transferDialogForm.maxCount"></el-input-number>
+        </el-form-item>
         <el-form-item label="移交类型" prop="transferType" label-width="120px">
           <el-select
             v-model="transferDialogForm.transferType"
@@ -465,6 +491,9 @@
         :rules="finishDialogFormRules"
         ref="finishDialogForm"
       >
+        <el-form-item label="数量" prop="count" label-width="120px">
+          <el-input-number v-model="finishDialogForm.count" :min="1" :max="finishDialogForm.maxCount"></el-input-number>
+        </el-form-item>
         <el-form-item
           label="完成记录说明"
           prop="operationRecords"
@@ -546,7 +575,6 @@
 <script>
 import {
   getMyTaskList,
-  startTask,
   transferTask,
   completeTask,
   checkTask,
@@ -557,7 +585,8 @@ import {
   batchCheckTask,
   batchCompleteTask,
   submitTask,
-  revokeBatch
+  revokeBatch,
+  deviceList
 } from '@/api/task'
 import { workTypeMasterList } from '@/api/worktype'
 import templateList from '../warehouse/template-list'
@@ -600,24 +629,19 @@ export default {
       totalPage: 0,
       dataListLoading: false,
       dataListSelections: [],
-      // optionsState: [
-      //   {
-      //     code: '1',
-      //     value: '未开始'
-      //   },
-      //   {
-      //     code: '2',
-      //     value: '待操作'
-      //   },
-      //   {
-      //     code: '3',
-      //     value: '已完成'
-      //   }
-      // ],
+      startDialogFormVisible: false,
+      startDialogForm: {
+        count: 0
+      },
+      startDialogFormRules: {},
       transferDialogFormVisible: false,
-      transferDialogForm: {},
+      transferDialogForm: {
+        count: 0
+      },
       finishDialogFormVisible: false,
-      finishDialogForm: {},
+      finishDialogForm: {
+        count: 0
+      },
       finishDialogFormRules: {
         operationRecords: [
           { required: true, message: '完成记录说明不能为空', trigger: 'blur' }
@@ -701,7 +725,8 @@ export default {
         taskIds: '',
         maxNumber: 0,
         number: 0
-      }
+      },
+      devices: [{}] // 设备列表
     }
   },
   created () {
@@ -754,42 +779,57 @@ export default {
       this.dataListSelections = val
     },
     // 开始
-    startTask (taskId) {
-      this.$confirm('是否开始任务?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
+    startTask (item) {
+      this.startDialogFormVisible = true
+      this.startDialogForm.taskIds = item.taskIds
+      this.startDialogForm.count = item.taskIds == null ? 0 : item.taskIds.length
+      this.startDialogForm.maxCount = this.startDialogForm.count
+
+      let params = {
+        current: 1,
+        size: 50
+      }
+      deviceList(params).then(({data}) => {
+        if (data && data.code === '200') {
+          this.devices = []
+          for (item in data.records) {
+            this.devices.push({
+              label: item.name,
+              value: item.id
+            })
+          }
+        }
       })
-        .then(() => {
-          startTask({ taskId }).then(({ data }) => {
-            if (data && data.code === '200') {
-              this.$message({
-                type: 'success',
-                message: '操作成功!'
-              })
-              this.getDataList()
-            } else {
-              this.$message({
-                type: 'error',
-                message: data.msg
-              })
-            }
+    },
+    startSubmit () {
+      let data = {
+        taskIds: this.startDialogForm.taskIds.slice(0, this.startDialogForm.count)
+      }
+      batchStart(data).then(({ data }) => {
+        this.startDialogFormVisible = false
+        if (data && data.code === '200') {
+          this.$message({
+            type: 'success',
+            message: '操作成功!'
           })
-        })
-        .catch(() => {
+          this.getDataList()
+        } else {
           this.$message({
-            type: 'info',
-            message: '已取消'
+            type: 'error',
+            message: data.msg
           })
-        })
+        }
+      })
     },
     // 移交
     transferTask (item) {
-      let {taskId, workTypeId, taskType} = item
+      let {taskIds, workTypeId, taskType} = item
       this.transferDialogFormVisible = true
-      this.transferDialogForm.taskIdList = taskId
+      this.transferDialogForm.taskIds = taskIds
       this.transferDialogForm.taskType = taskType
       this.transferDialogForm.cnt = 1
+      this.transferDialogForm.count = taskIds == null ? 0 : taskIds.length
+      this.transferDialogForm.maxCount = this.transferDialogForm.count
 
       if (taskType !== 'routine') {
         workTypeMasterList(workTypeId).then(({ data }) => {
@@ -803,6 +843,8 @@ export default {
     transferSubmit () {
       this.$refs['transferDialogForm'].validate((valid) => {
         if (valid) {
+          let taskIds = this.transferDialogForm.taskIds.slice(0, this.transferDialogForm.count)
+          this.transferDialogForm.taskIdList = taskIds.join(',')
           transferTask(this.transferDialogForm).then(({ data }) => {
             if (data && data.code === '200') {
               this.$message({
@@ -822,15 +864,18 @@ export default {
       })
     },
     // 完成
-    completeTask (taskId) {
+    completeTask (item) {
       this.finishDialogFormVisible = true
-      this.finishDialogForm.taskId = taskId
+      this.finishDialogForm.taskIds = item.taskIds
+      this.finishDialogForm.count = item.taskIds == null ? 0 : item.taskIds.length
+      this.finishDialogForm.maxCount = this.finishDialogForm.count
     },
     // 确认完成
     finishSubmit () {
       this.$refs['finishDialogForm'].validate((valid) => {
         if (valid) {
           let submitData = this.finishDialogForm
+          submitData.taskIds = this.finishDialogForm.taskIds.slice(0, this.finishDialogForm.count)
           if (this.checkDialogBatch) {
             // 批量
             batchCompleteTask(submitData).then(({ data }) => {