Переглянути джерело

工艺节点设置整体逻辑校验

sh4wmoo 3 роки тому
батько
коміт
ef8d26ac57

BIN
src/assets/icons/交坯.png


BIN
src/assets/icons/喷雾.png


BIN
src/assets/icons/回收.png


BIN
src/assets/icons/打包.png


BIN
src/assets/icons/打磨.png


BIN
src/assets/icons/检查.png


BIN
src/assets/icons/火炉.png


BIN
src/assets/icons/烘干.png


BIN
src/assets/icons/登记.png


BIN
src/assets/icons/装卸.png


BIN
src/assets/icons/马桶.png


+ 12 - 10
src/components/business/process/edge-modal/edge-modal.vue

@@ -15,11 +15,11 @@
       {{edgeData}}
       <DkForm ref="formInline" :col-count="2" >
         <!--    默认分级    -->
-        <DkFormItem prop="pdtGradeIds">
+        <DkFormItem prop="pdtGradeIds" :data-type="$config.dataType.array">
           <SelectPop ref="pdtGradeIds" v-model="edgeData.pdtGradeIds" label-key="gradeName" value-key="gradeId" :multiple="true" :options="productGradeList" />
         </DkFormItem>
         <!--    成型标签    -->
-        <DkFormItem prop="moldingSysTags">
+        <DkFormItem prop="moldingSysTags" :data-type="$config.dataType.array">
           <SelectPop ref="moldingSysTags" v-model="edgeData.moldingSysTags" label-key="kindName" value-key="kindCode" :multiple="true"
                      :options="dataKindList.filter(it=>it.kindType==='成线标签')" />
         </DkFormItem>
@@ -68,9 +68,11 @@ export default {
   },
   watch:{
     id(n,o){
-      let graph = Process.graph;
-      let cell = graph.getCellById(this.process.currentEdgeId);
-      this.edgeData=cell.data
+      if(n){
+        let graph = Process.graph;
+        let cell = graph.getCellById(this.process.currentEdgeId);
+        this.edgeData=cell.data
+      }
     }
   },
   data() {
@@ -107,13 +109,13 @@ export default {
      * @date   : 2023/1/5 10:38
      */
     modalOk(){
-      this.edgeData.pdtList=this.$refs.pdtTable.getTableDataFilter().map((it) => {
+      this.edgeData.pdtList=this.$refs.pdtTable?.getTableDataFilter()?.map((it) => {
         return {
           flowId:parseInt(this.$route.params.id),
           routeId:this.process.currentEdgeId,
           pdtModelId:it.pdtModelId,
-          modelCode:it.modelCode,
-          modelName:it.modelName,
+          pdtModelCode:it.modelCode,
+          pdtModelName:it.modelName,
           categoryName:it.categoryName,
           remarks:it.remarks,
           ftyId:this.$store.state.user.ftyId
@@ -124,8 +126,8 @@ export default {
       //设置业务数据
       cell.setData(this.edgeData,{overwrite:true})
       //设置样式
-      if(Object.keys(cell.data).length!=0&&((cell.data.pdtGradeIds&&cell.data.pdtGradeIds.length!=0)||(cell.data.moldingSysTags&&cell.data.moldingSysTags.length!=0))){
-        cell.setAttrs({ line: { stroke: 'red', }, }, );
+      if(Object.keys(cell.data).length!=0&&((cell?.data?.pdtGradeIds&&cell?.data?.pdtGradeIds.length>0)||(cell?.data?.moldingSysTags&&cell?.data?.moldingSysTags.length>0))){
+        cell.setAttrs({ line: { stroke: '#4169E1', }, }, );
       }else{
         cell.setAttrs({ line: { stroke: '#A2B1C3', }, },);
       }

+ 56 - 9
src/components/business/process/node-modal/node-modal.vue

@@ -33,7 +33,7 @@
         </DkFormItem>
         <!--    工号类型    -->
         <DkFormItem prop="userKind" :required="true" v-if="nodeControl?.userKind?.visible">
-          <SelectPop ref="userKind" v-model="nodeData.userKind" label-key="kindName" value-key="kindCode"
+          <SelectPop ref="userKind" v-model="nodeData.userKind" label-key="kindName" value-key="kindCode" @on-select="changeUserKind"
                      :multiple="false" :options="dataKindList.filter(it=>it.kindType==='节点工号').filter(it=>!(nodeControl?.userKind?.invalidCode||[]).includes(it.kindCode))"/>
         </DkFormItem>
         <!--    计件模式    -->
@@ -78,7 +78,7 @@
           </div>
         </DkFormItem>
         <!--    默认分级    -->
-        <DkFormItem prop="defGradeId" v-if="nodeControl?.defGradeId?.visible"
+        <DkFormItem prop="defGradeId" v-if="nodeControl?.defGradeId?.visible" :data-type="$config.dataType.number"
                     :required="['工艺节点-回收','工艺节点-成型'].includes(nodeData.nodeKind)
                     ||(['工艺节点-计件','工艺节点-登窑','工艺节点-入窑'].includes(nodeData.nodeKind)&&nodeData.flowKind=='节点流程-开始')" >
           <SelectPop ref="defGradeId" v-model="nodeData.defGradeId" label-key="gradeName" value-key="gradeId"
@@ -90,7 +90,7 @@
                      :multiple="true" :options="dataKindList.filter(it=>it.kindType==='成线标签')"/>
         </DkFormItem>
         <!--    可判分级    -->
-        <DkFormItem prop="judgeGradeIds" :required="['工艺节点-半检','工艺节点-成检'].includes(nodeData.nodeKind)"  v-if="nodeControl?.judgeGradeIds?.visible">
+        <DkFormItem prop="judgeGradeIds" :required="['工艺节点-半检','工艺节点-成检'].includes(nodeData.nodeKind)"  v-if="nodeControl?.judgeGradeIds?.visible" :data-type="$config.dataType.array">
           <SelectPop ref="judgeGradeIds" v-model="nodeData.judgeGradeIds" label-key="gradeName" value-key="gradeId"
                      :multiple="true" :options="productGradeList.filter(it=>it.gradeKind!='产品等级-损')"/>
         </DkFormItem>
@@ -108,7 +108,7 @@
           </div>
         </DkFormItem>
         <!--    返回分级    -->
-        <DkFormItem prop="backGradeIds" v-if="nodeControl?.backGradeIds?.visible" :required="['工艺节点-半检','工艺节点-成检'].includes(nodeData.nodeKind)&&nodeData.flgAloneJudge">
+        <DkFormItem prop="backGradeIds" v-if="nodeControl?.backGradeIds?.visible" :required="['工艺节点-半检','工艺节点-成检'].includes(nodeData.nodeKind)&&nodeData.flgAloneJudge" :data-type="$config.dataType.array">
           <SelectPop ref="backGradeIds" v-model="nodeData.backGradeIds" label-key="gradeName" value-key="gradeId"
                      :disabled="!(['工艺节点-半检','工艺节点-成检'].includes(nodeData.nodeKind)&&nodeData.flgAloneJudge)" :multiple="true" :options="productGradeList"/>
         </DkFormItem>
@@ -169,7 +169,7 @@
         <EditTable ref="userTable" :data="nodeData.userList"
                    v-if="nodeControl?.userTable?.visible"
                    :columns="userColumns"
-                   enabledRepeatId="userId"
+                   :enabledRepeatId="['userId','userKind']"
                    controlId="userId"
                    :height="200"
                    :showSeqBtnFlag="false"
@@ -275,7 +275,7 @@ export default {
         }
         //刷新业务数据
         let cell = this.graph.getCellById(this.process.currentNodeId)
-        this.nodeData = cell.data
+        this.nodeData = cell?.data
         //刷新节点属性控制
         this.nodeControl=this.dataKindList.find(it=>it.kindCode===this.nodeData.nodeKind).kindTags
       }
@@ -318,7 +318,7 @@ export default {
         {
           field: 'userKind',
           type: 'select',
-          options: () => self.dataKindList.filter(it=>it.kindType==='节点工号'),
+          options: () => self.dataKindList.filter(it=>it.kindType==='节点工号').filter(it=>!(self.nodeData.userKind=='节点工号-生产'&&it.kindCode=='节点工号-操作')),
           labelKey: 'kindName',
           valueKey: 'kindCode',
           fieldUpdate: [
@@ -421,6 +421,21 @@ export default {
   methods: {
     ...mapMutations(['setProcessNodeModalDisplay', 'setCurrentNodeId']),
     /**
+     * @desc   : 修改用户类别
+     * @author : 张潇木
+     * @date   : 2023/3/1 14:11
+     */
+    changeUserKind(e){
+      //当切换到生产工号时,删除userTable中设置的操作工号
+      if(e=='节点工号-生产'){
+        this.$refs?.userTable?.getTableDataFilter().forEach((it)=> {
+          if((it.userKind==='节点工号-操作')){
+            this.$refs?.userTable?.del(this.$refs?.userTable?.getTableDataFilter().findIndex(item=>item._X_ID==it._X_ID))
+          }
+        })
+      }
+    },
+    /**
      * @desc   : 确定
      * @author : 张潇木
      * @date   : 2023/1/5 10:38
@@ -448,7 +463,6 @@ export default {
      * @date   : 2023/2/16 16:21
      */
     setParams(){
-      console.log('setParams')
       // region 设置表单数据
       //工序工号
       this.nodeData.userList=this.$refs?.userTable?.getTableDataFilter().map((it,index) => {
@@ -520,12 +534,15 @@ export default {
       // region 设置图形业务数据
       //根据节点id获取节点数据
       let cell = this.graph.getCellById(this.process.currentNodeId)
+      //移除非法连线
+      this.removeInvalidEdge(cell)
       //设置节点数据
       cell.setData(this.nodeData, { overwrite: true })
       //设置节点样式
       cell.setAttrs({
         label: { text: this.nodeData.nodeName },
         text: { text: this.nodeData.nodeName },
+        body: { stroke: '#5F95FF'}
       })
       // endregion
     },
@@ -535,7 +552,6 @@ export default {
      * @date   : 2023/2/27 11:12
      */
     validData(){
-      console.log("validData")
       if((['工艺节点-登窑','工艺节点-卸窑'].includes(this.nodeData.nodeKind)
         ||(['工艺节点-入窑','工艺节点-出窑'].includes(this.nodeData.nodeKind)&&this.nodeData.opnKind=='节点操作-载具码'))
         &&!(this.$refs?.carTable?.getTableDataFilter()||[]).length>0)
@@ -544,6 +560,37 @@ export default {
         return false
       }
       return true
+    },
+    /**
+     * @desc   : 移除非法连线
+     * @author : 张潇木
+     * @date   : 2023/3/1 13:29
+     */
+    removeInvalidEdge(cell){
+      // 开始节点不能作为连线起点
+      if(this.nodeData?.flowKind=='节点流程-开始') {
+        this.graph.getIncomingEdges(cell)?.forEach(it=>{
+          this.graph.removeEdge(it.id)
+        })
+      }
+      // 结束节点不能作为连线起点
+      if(this.nodeData?.flowKind=='节点流程-结束') {
+        this.graph.getOutgoingEdges(cell)?.forEach(it=>{
+          this.graph.removeEdge(it.id)
+        })
+      }
+      // 回收节点既不能作为开始也不能作为结束
+      if(this.nodeData?.nodeKind==='工艺节点-回收') {
+        this.graph.getConnectedEdges(cell)?.forEach(it=>{
+          this.graph.removeEdge(it.id)
+        })
+      }
+      // 独立检验既不能作为开始也不能作为结束
+      if(this.nodeData?.flgAloneJudge) {
+        this.graph.getConnectedEdges(cell)?.forEach(it=>{
+          this.graph.removeEdge(it.id)
+        })
+      }
     }
   }
 

+ 44 - 6
src/view/process/process-flow/config/ProcessConfig.js

@@ -93,7 +93,9 @@ export default class Process {
         },
         anchor: 'center',
         connectionPoint: 'anchor',
-        allowBlank: false,
+        allowBlank: false,//不允许连接到画布空白位置的点
+        allowLoop: false,//不允许创建循环连线
+        allowMulti:false,//不允许在相同的起始节点和终止之间创建多条边
         snap: {
           radius: 20,
         },
@@ -123,7 +125,37 @@ export default class Process {
             data:{}
           })
         },
-        validateConnection({ targetMagnet }) {
+        validateConnection({ edge,
+                             edgeView,
+                             sourceView,
+                             targetView,
+                             sourcePort,
+                             targetPort,
+                             sourceMagnet,
+                             targetMagnet,
+                             sourceCell,
+                             targetCell,
+                             type }) {
+          let source=sourceCell.getData()
+          let target=targetCell.getData()
+          // console.log('sourceCell',source)
+          // console.log('targetCell',target)
+          // 开始节点不能作为连线起点
+          if(target?.flowKind=='节点流程-开始') {
+            return false
+          }
+          // 结束节点不能作为连线起点
+          if(source?.flowKind=='节点流程-结束') {
+            return false
+          }
+          // 回收节点既不能作为开始也不能作为结束
+          if(source?.nodeKind==='工艺节点-回收'||target?.nodeKind==='工艺节点-回收') {
+            return false
+          }
+          // 独立检验既不能作为开始也不能作为结束
+          if(source?.flgAloneJudge||target?.flgAloneJudge) {
+            return false
+          }
           return !!targetMagnet
         },
       },
@@ -623,11 +655,16 @@ export default class Process {
 
     // region 监听添加节点、线事件
     this.graph.on("cell:added", ({ cell }) => {
-      //添加节点或者线自动设置业务数据id
+      //节点
       if(cell.shape=='custom-image'){
+        //添加节点设置业务数据id
         cell.setData({'nodeId':cell.id,'ftyId': store.state.user.ftyId,'flowId':parseInt(router.app._route.params.id)})
+        //设置初始未校验样式
+        cell.setAttrs({body: {stroke: 'red',}})
       }
+      //连接线
       if(cell.shape=='edge'){
+        //添加线设置业务数据id
         cell.setData({'routeId':cell.id,'ftyId':store.state.user.ftyId,'routeType':1,'flowId':parseInt(router.app._route.params.id)})
       }
     });
@@ -814,8 +851,9 @@ export default class Process {
         ],
         attrs: {
           body: {
-            stroke: '#87CEFA',
-            fill: '#1E90FF',
+            stroke: '#5F95FF',
+            strokeWidth: 1,
+            fill: '#FFFFFF',
           },
           image: {
             width: 32,
@@ -829,7 +867,7 @@ export default class Process {
             textAnchor: 'left',
             textVerticalAnchor: 'top',
             fontSize: 12,
-            fill: '#fff',
+            fill: 'black',
           },
         },
         ports: { ...ports },

+ 17 - 1
src/view/process/process-flow/process-setting.vue

@@ -117,7 +117,8 @@ export default {
       })
       //转json
       this.formData.flowLayout=this.graph.toJSON()
-      //todo 校验
+      //流程整体校验
+      if (!this.validData()) return false
       //发送保存网络请求
       this.excute(this.$service.processService, this.$service.processService.processSetting, this.formData).then(res=>{
         if (res.code === this.$config.SUCCESS_CODE) {
@@ -132,6 +133,21 @@ export default {
       })
     },
     /**
+     * @desc   : 校验数据
+     * @author : 张潇木
+     * @date   : 2023/2/27 11:12
+     */
+    validData(){
+     let nodes= this.graph.getNodes().filter(it => it.shape == 'custom-image').filter((it) => {
+        if(it.getAttrs()?.body?.stroke==='red'){
+          this.$Message.error('[ '+it.getData()?.nodeName+'] 节点设置有误,请检查')
+          return true
+        }
+      })
+      if(nodes.length>0) return false
+      return true
+    },
+    /**
      * @desc   : 查询明细
      * @author : 张潇木
      * @date   : 2023/2/3 16:47