damon227 3 éve
szülő
commit
37c795a30c

+ 12 - 2
src/api/crafts.js

@@ -1,9 +1,10 @@
 import request from '@/utils/httpRequest'
 
-export function getTechnology () {
+export function getTechnology (params) {
   return request({
     url: request.adornUrl('/biz-service/technology/list'),
-    method: 'get'
+    method: 'get',
+    params
   })
 }
 
@@ -44,3 +45,12 @@ export function getStepId () {
     async: false
   })
 }
+
+// 撤销
+export function revoke (data) {
+  return request({
+    url: request.adornUrl(`/biz-service/technology/revoke`),
+    method: 'POST',
+    data
+  })
+}

+ 9 - 0
src/api/task.js

@@ -44,3 +44,12 @@ export function checkTask (data) {
     data
   })
 }
+
+// 操作损坏
+export function damageTask (data) {
+  return request({
+    url: request.adornUrl(`/biz-service/WorkController/damage`),
+    method: 'post',
+    data
+  })
+}

+ 1 - 1
src/components/work-flow/config/commonConfig.js

@@ -28,7 +28,7 @@ export const jsplumbSetting = {
     fill: 'rgba(255,255,255,0)',
     outlineWidth: 1
   },
-  LogEnabled: false, // 是否打开jsPlumb的内部日志记录
+  LogEnabled: true, // 是否打开jsPlumb的内部日志记录
   // 绘制线
   PaintStyle: {
     stroke: '#409eff',

+ 9 - 1
src/components/work-flow/config/methods.js

@@ -21,7 +21,7 @@ const methods = {
       })
       // 断开连线后,维护本地数据
       this.jsPlumb.bind('connectionDetached', evt => {
-        this.deleLine(evt)
+        //this.deleLine(evt)
       })
       this.loadEasyFlow()
       // 会使整个jsPlumb立即重绘。
@@ -46,6 +46,7 @@ const methods = {
     this.jsPlumb.unbind('connection') // 取消连接事件
     for (let i = 0; i < this.data.lineList.length; i++) {
       let line = this.data.lineList[i]
+      debugger
       this.jsPlumb.connect(
         {
           source: line.from,
@@ -276,6 +277,13 @@ const methods = {
     })
   },
 
+  // 删除所有节点
+  deleteAllNode () {
+    this.data.nodeList.map(item => {
+      this.jsPlumb.remove(item.id)
+    })
+  },
+
   // 更改连线状态
   changeLineState (nodeId, val) {
     console.log(val)

+ 13 - 7
src/components/work-flow/home.vue

@@ -40,9 +40,9 @@
           </div>
         </div>
       </el-scrollbar>
-      <div class="flow_operation">
+      <!-- <div class="flow_operation">
         <el-button type="primary" @click="saveFlow" :disabled="disabled">保存</el-button>
-      </div>
+      </div> -->
     </div>
     <div
       id="flowWrap"
@@ -162,6 +162,13 @@ export default {
   watch: {
     nodeData (val) {
       this.initNode()
+      this.fixNodesPosition()
+      this.$nextTick(() => {
+        this.jsPlumb.deleteEveryConnection();
+        // this.jsPlumb.deleteEveryEndpoint();
+        // this.deleteAllNode();
+        this.init()
+      })
     },
     disabled (val) {
     }
@@ -200,9 +207,9 @@ export default {
         this.data.nodeList.push(v)
       })
 
-      this.$nextTick(() => {
-        this.init()
-      })
+      // this.$nextTick(() => {
+      //   this.init()
+      // })
     },
     nodeDisabled (node) {
       return (
@@ -224,11 +231,10 @@ export default {
       //   delete item.log_bg_color
       //   return item
       // })
-      // debugger
       // this.$emit('saveWorkFlow', data)
     },
     getFlowData(){
-       let data = JSON.parse(JSON.stringify(this.data))
+      let data = JSON.parse(JSON.stringify(this.data))
       data.nodeList = data.nodeList.map(item => {
         delete item.logImg
         delete item.log_bg_color

+ 39 - 15
src/components/work-flow/node-edit.vue

@@ -71,9 +71,17 @@
           ></el-option>
         </el-select>
       </el-form-item>
-      <el-form-item v-if="node.type !== 'end'">
+      <el-form-item v-if="node.type !== 'end' && !disabled && !selectOperator">
          <upload-component
-            :display="disabled || selectOperator"
+            :title="'附件'"
+            :accept="'*'"
+            :file-obj-list="fileList"
+            @uploadSuccess="uploadSuccess"
+          />
+      </el-form-item>
+      <el-form-item v-else>
+         <upload-component
+          :display="true"
             :title="'附件'"
             :accept="'*'"
             :file-obj-list="fileList"
@@ -139,6 +147,23 @@ export default {
         ...this.form,
         ...this.node
       }
+      if (this.node.operatorId) {
+      this.form.operatorId = this.node.operatorId.split(',')
+    }
+
+    // 附件
+    if (this.node.attachList) {
+      this.$nextTick(() =>{
+      this.fileList = []
+      this.node.attachList.forEach(item => {
+        this.fileList.push({
+          name: item.fileName,
+          url: item.url,
+          id: item.url
+        })
+      })
+      })
+    }
     },
     disabled (val) {
       this.disabled = val
@@ -159,8 +184,9 @@ export default {
       this.form.operatorId = this.node.operatorId.split(',')
     }
 
-     // 附件
+    // 附件
     if (this.node.attachList) {
+      this.fileList = []
       this.node.attachList.forEach(item => {
         this.fileList.push({
           name: item.fileName,
@@ -169,7 +195,6 @@ export default {
         })
       })
     }
-
     this.getOperatorList()
   },
   methods: {
@@ -224,17 +249,16 @@ export default {
       }
 
        // 填充附件
-          let fList = this.fileList
-          if (fList.length > 0) {
-            form.attachList = []
-            for (let i = 0; i < fList.length; i++) {
-              form.attachList.push({
-                fileName: fList[i].name,
-                url: fList[i].url
-              })
-            }
-          }
-
+      let fList = this.fileList
+      if (fList.length > 0) {
+        form.attachList = []
+        for (let i = 0; i < fList.length; i++) {
+          form.attachList.push({
+            fileName: fList[i].name,
+            url: fList[i].url
+          })
+        }
+      }
       return form
     }
   }

+ 10 - 10
src/views/modules/production/scheduling-details.vue

@@ -90,15 +90,15 @@ export default {
       })
     },
     dataFormSubmit () {
-      if (!this.clickFlowSave) {
-        this.$message.error('请先点击流程图保存按钮!')
-        return
-      }
-
+      // if (!this.clickFlowSave) {
+      //   this.$message.error('请先点击流程图保存按钮!')
+      //   return
+      // }
+      let workFlowData = this.$refs.workFlow.getFlowData()
       if (
-        !this.workFlowData ||
-        this.workFlowData.nodeList.length === 0 ||
-        this.workFlowData.lineList.length === 0
+        !workFlowData ||
+        workFlowData.nodeList.length === 0 ||
+        workFlowData.lineList.length === 0
       ) {
         this.$message.error('请先完成流程图!')
         this.clickFlowSave = false
@@ -111,10 +111,10 @@ export default {
           let productionPlanNodes = []
           for (
             let index = 0;
-            index < this.workFlowData.nodeList.length;
+            index < workFlowData.nodeList.length;
             index++
           ) {
-            const node = this.workFlowData.nodeList[index]
+            const node = workFlowData.nodeList[index]
             if (node.type !== 'end' && node.operatorId === '') {
               this.$message.error(`请选择 ${node.nodeName} 的操作人员!`)
               this.clickFlowSave = false

+ 44 - 6
src/views/modules/tech/crafts-management.vue

@@ -97,6 +97,23 @@
         min-width="160"
         label="创建人">
       </el-table-column>
+      <el-table-column
+        prop="state"
+        header-align="center"
+        align="center"
+        min-width="160"
+        label="审批状态">
+         <template slot-scope="scope">
+          <span>{{ convertState(scope.row.state)}}</span>
+        </template>
+      </el-table-column>
+      <el-table-column
+        prop="currentApproverName"
+        header-align="center"
+        align="center"
+        min-width="160"
+        label="当前审批人">
+      </el-table-column>
       <el-table-column
         prop="notes"
         header-align="center"
@@ -105,7 +122,7 @@
         label="备注">
       </el-table-column>
       <el-table-column
-        prop="state"
+        prop="techState"
         header-align="center"
         align="center"
         min-width="100"
@@ -121,9 +138,10 @@
         width="140"
         label="操作">
         <template slot-scope="scope">
-          <el-button v-if="isAuth('pro:technology:update') && scope.row.techState == -1" type="text" size="small" @click="addOrUpdateHandle(scope.row.techId)">编辑</el-button>
-          <el-button v-if="isAuth('pro:technology:update') && scope.row.techState == -1" type="text" size="small" @click="changeStateHandle(scope.row.techId, 0)">启用</el-button>
-          <el-button v-if="isAuth('pro:technology:update') && scope.row.techState == 0" type="text" size="small" @click="changeStateHandle(scope.row.techId, -1)">停用</el-button>
+          <el-button v-if="isAuth('pro:technology:update') && scope.row.state === '1'" type="text" size="small" @click="revokeHandle(scope.row.techId)">撤销</el-button>
+          <el-button v-if="isAuth('pro:technology:update') && scope.row.state === '0'" type="text" size="small" @click="addOrUpdateHandle(scope.row.techId)">编辑</el-button>
+          <el-button v-if="isAuth('pro:technology:update') && scope.row.techState === '-1' && scope.row.state === '3'" type="text" size="small" @click="changeStateHandle(scope.row.techId, 0)">启用</el-button>
+          <el-button v-if="isAuth('pro:technology:update') && scope.row.techState === '0'" type="text" size="small" @click="changeStateHandle(scope.row.techId, -1)">停用</el-button>
           <el-button v-if="isAuth('pro:technology:info')" type="text" size="small" @click="detailHandle(scope.row.techId, scope.row.productName)">查看</el-button>
         </template>
       </el-table-column>
@@ -144,7 +162,7 @@
 </template>
 
 <script>
-  import { getTechnology, update } from '@/api/crafts'
+  import { getTechnology, update, revoke } from '@/api/crafts'
   import ctaftsAddOrDetail from './ctafts-add-or-detail'
   import Detail from './crafts-detail'
   export default {
@@ -182,6 +200,15 @@
       }
     },
     methods: {
+      convertState(state){
+        switch(state){
+          case '0': return "待提交";
+          case '1': return "待审批";
+          case '2': return "审批中";
+          case '3': return "审批完成";
+          default: return "审批不通过";
+        }
+      },
       // 查询
       queryData () {
         this.pageIndex = 1
@@ -231,10 +258,21 @@
           this.$refs.addOrUpdate.init(id, false)
         })
       },
+      // 撤销
+      revokeHandle(id){
+        revoke({techId:id}).then(({data}) => {
+          if (data && data.code === '200') {
+            this.getTechnology()
+          }
+        })
+      },
       changeStateHandle (id, type) {
         update({ techId: id, techState: type }).then(({data}) => {
           if (data && data.code === '200') {
-            this.getTechnology()
+            this.$message({
+              type: 'info',
+              message: '撤销成功'
+            })
           }
         })
       },

+ 0 - 1
src/views/modules/tech/ctafts-add-or-detail.vue

@@ -268,7 +268,6 @@ export default {
     },
     // 保存流程图
     saveWorkFlow (workFlowData) {
-      debugger
       this.workFlowData = workFlowData
     }
   }

+ 164 - 16
src/views/modules/works/work.vue

@@ -39,13 +39,14 @@
         label="任务名称">
       </el-table-column>
       <el-table-column
+        v-if="showProgress"
         prop="completeNum"
         header-align="center"
         align="center"
         min-width="160"
         label="任务进度">
         <template slot-scope="scope">
-          <el-progress :percentage="scope.row.completeNum?Number(scope.row.completeNum):0"></el-progress>
+          <el-progress :percentage="getPercentage(scope.row.completeNum, scope.row.totalNum)"></el-progress>
         </template>
       </el-table-column>
       <el-table-column
@@ -56,24 +57,52 @@
         label="规定完成时间">
       </el-table-column>
       <el-table-column
-        prop="stepName"
+        prop="nodeName"
         header-align="center"
         align="center"
         min-width="160"
         :show-tooltip-when-overflow="true"
         label="工序内容">
       </el-table-column>
+      <el-table-column
+        prop="require"
+        header-align="center"
+        align="center"
+        min-width="160"
+        :show-tooltip-when-overflow="true"
+        label="工序要求">
+      </el-table-column>
+      <el-table-column
+        prop="explain"
+        header-align="center"
+        align="center"
+        min-width="160"
+        :show-tooltip-when-overflow="true"
+        label="工序说明">
+      </el-table-column>
+      <el-table-column
+        header-align="center"
+        align="center"
+        min-width="160"
+        :show-tooltip-when-overflow="true"
+        label="工序附件">
+        <template slot-scope="scope">
+          <li v-for="(item, index) in scope.row.attachList" :key="index"><a @click="previewFile(item.url)">{{item.fileName}}</a></li>
+        </template>
+      </el-table-column>
       <el-table-column
         fixed="right"
         header-align="center"
         align="center"
-        width="150"
+        width="180"
         label="操作">
         <template slot-scope="scope">
           <el-button v-if="isAuth('work:clt:start') && (scope.row.state == 0 || scope.row.state == 1)" :disabled="scope.row.state == 0" type="text" size="small" @click="startTask(scope.row.taskId)">开始</el-button>
           <el-button v-if="isAuth('work:clt:complete') && scope.row.state != 3" type="text" size="small" @click="transferTask(scope.row.taskId, scope.row.workTypeId)">移交</el-button>
-          <el-button v-if="isAuth('work:clt:complete') && scope.row.state == 2 && (scope.row.type == null || scope.row.type == 1)" type="text" size="small" @click="completeTask(scope.row.taskId)">完成</el-button>
-          <el-button v-if="isAuth('work:clt:complete') && scope.row.state == 2 && (scope.row.type == 2 || scope.row.type == 3)" type="text" size="small" @click="checkTask(scope.row.taskId)">检验</el-button>
+          <el-button v-if="isAuth('work:clt:complete') && scope.row.state == 2 && (scope.row.nodeType == null || scope.row.nodeType == 'start' || scope.row.nodeType == 'produce')" type="text" size="small" @click="completeTask(scope.row.taskId)">完成</el-button>
+          <el-button v-if="isAuth('work:clt:complete') && scope.row.state == 2 && (scope.row.nodeType == 'check' || scope.row.nodeType == 't-check')" type="text" size="small" @click="checkTask(scope.row.taskId, 1)">通过</el-button>
+          <el-button v-if="isAuth('work:clt:complete') && scope.row.state == 2 && (scope.row.nodeType == 'check' || scope.row.nodeType == 't-check')" type="text" size="small" @click="checkTask(scope.row.taskId, 2)">不通过</el-button>
+          <el-button v-if="isAuth('work:clt:complete') && scope.row.state == 2 && (scope.row.nodeType == null || scope.row.nodeType == 'produce')" type="text" size="small" @click="damageTask(scope.row.taskId)">操作损坏</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -89,11 +118,16 @@
 
     <el-dialog title="移交任务" width="30%" :visible.sync="transferDialogFormVisible">
       <el-form :model="transferDialogForm" :rules="transferDialogFormRules" ref="transferDialogForm">
-        <el-form-item label="检验类型" prop="checkType" label-width="120px">
+        <!-- <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="transferType" label-width="120px">
+           <el-select v-model="transferDialogForm.transferType" placeholder="请选择移交类型">
+            <el-option label="工作移交" value="1"></el-option>
+          </el-select>
         </el-form-item>
         <el-form-item label="移交用户" prop="transferUserId" label-width="120px">
           <el-select v-model="transferDialogForm.transferUserId" placeholder="请选择移交用户">
@@ -105,6 +139,9 @@
           </el-option>
           </el-select>
         </el-form-item>
+        <el-form-item label="移交说明" prop="transferExplain" label-width="120px">
+          <el-input v-model="transferDialogForm.transferExplain" placeholder="请输入"></el-input>
+        </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button @click="transferDialogFormVisible = false">取 消</el-button>
@@ -116,8 +153,8 @@
       <el-form :model="checkDialogForm" :rules="checkDialogFormRules" ref="checkDialogForm">
         <el-form-item label="检验类型" prop="checkType" label-width="80px">
            <el-select v-model="checkDialogForm.checkType" placeholder="请选择检验类型" style="width:100%">
-            <el-option label="通过" value="1"></el-option>
-            <el-option label="不通过" value="2"></el-option>
+            <el-option label="返回上一级" value="2"></el-option>
+            <el-option label="报损" value="3"></el-option>
           </el-select>
         </el-form-item>
         <el-form-item label="备注" prop="notes" label-width="80px">
@@ -129,13 +166,28 @@
         <el-button type="primary" @click="checkSubmit">确 定</el-button>
       </div>
     </el-dialog>
+
+    <el-dialog title="操作损坏" width="30%" :visible.sync="damageDialogFormVisible">
+      <el-form :model="damageDialogForm" :rules="damageDialogFormRules" ref="checkDialogForm">
+        <el-form-item label="损坏原因" prop="damageReason" label-width="80px">
+          <el-input v-model="damageDialogForm.damageReason" type="textarea" :rows="2" placeholder="请输入"></el-input>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="damageDialogFormVisible = false">取 消</el-button>
+        <el-button type="primary" @click="damageSubmit">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-  import { getTaskList, startTask, transferTask, completeTask, checkTask } from '@/api/task'
-  import { workTypeMasterList } from '@/api/worktype'
+import { getTaskList, startTask, transferTask, completeTask, checkTask, damageTask } from '@/api/task'
+import { workTypeMasterList } from '@/api/worktype'
+import template from '../warehouse/template.vue'
+import { downloadUrl } from '@/api/file'
   export default {
+  components: { template },
     name: 'work',
     data () {
       return {
@@ -164,14 +216,21 @@
         transferDialogForm: {},
         transferUserList: [],
         transferDialogFormRules: {
-          checkType: [{required: true, message: '请选择检验类型', trigger: 'blur'}],
+          transferType: [{required: true, message: '请选择移交类型', trigger: 'blur'}],
           transferUserId: [{required: true, message: '请选择移交用户', trigger: 'blur'}]
         },
         checkDialogFormVisible: false,
         checkDialogForm: {},
         checkDialogFormRules: {
-          checkType: [{required: true, message: '请选择检验类型', trigger: 'blur'}]
-        }
+          checkType: [{required: true, message: '请选择', trigger: 'blur'}]
+        },
+        damageDialogFormVisible: false,
+        damageDialogForm: {},
+        damageDialogFormRules: {
+          damageReason: [{required: true, message: '请输入', trigger: 'blur'}]
+        },
+        // 是否显示进度条列
+        showProgress: true
       }
     },
     created () {
@@ -181,6 +240,11 @@
       // 查询
       queryData () {
         this.pageIndex = 1
+        if(this.dataForm.state === '2'){
+          this.showProgress = false
+        } else {
+          this.showProgress = true
+        }
         this.getDataList()
       },
       // 获取数据列表
@@ -307,10 +371,50 @@
         })
       },
       // 检验
-      checkTask (taskId) {
-        this.checkDialogFormVisible = true
+      checkTask (taskId, checkType) {
         this.checkDialogForm.taskId = taskId
+        if(checkType === 1){
+          this.checkDialogForm.checkType = checkType
+          this.passTask()
+        } else {
+          this.checkDialogForm.checkType = null
+          this.refuseTask()
+        }
+      },
+      // 通过
+      passTask(){
+        this.$confirm('是否完成任务?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          let submitData = this.checkDialogForm
+          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
+                })
+              }
+            })
+        }).catch(() => {
+          this.$message({
+            type: 'info',
+            message: '已取消'
+          })
+        })
+      },
+      refuseTask(){
+        this.checkDialogFormVisible = true
       },
+      // 不通过
       // 确认检验
       checkSubmit () {
         this.$refs['checkDialogForm'].validate((valid) => {
@@ -333,11 +437,55 @@
             })
           }
         })
+      },
+      // 操作损坏
+      damageTask(taskId, productionId){
+        this.damageDialogFormVisible = true
+        this.damageDialogForm.taskId = taskId
+        this.damageDialogForm.productionId = productionId
+      },
+      // 确认操作损坏
+      damageSubmit(){
+        this.$refs['damageDialogForm'].validate((valid) => {
+          if (valid) {
+            let submitData = this.checkDialogForm
+            damageTask(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
+                })
+              }
+            })
+          }
+        })
+      },
+      // 预览
+      previewFile (url) {
+        // 弹出新页面显示下载文件
+        window.open(downloadUrl + url, '_blank')
+      },
+      // 计算进度百分比,返回0到100的整数
+      getPercentage(completeNum, totalNum){
+        completeNum = completeNum == null ? 0 : parseInt(completeNum)
+        totalNum = totalNum == null ? 100 : parseInt(totalNum)
+        if(totalNum === 0){
+          return 100
+        }
+
+        return (completeNum/totalNum).toFixed(2) * 100
       }
     }
   }
 </script>
 
 <style scoped>
-
+li {list-style-type:none;}
 </style>