antdesign vue 步骤条a-step按审核人员节点排序显示逻辑

一、需求内容

目前审核人员角色有:学术、法务、售后,串行执行审核流程。

审核流程:发起/修改审核-》审核节点

审核节点规则:学术-》法务-》售后,每个节点均可以审核或修改。

审核状态:发起、修改、待审核、已审核。

因此前端根据节点规则来展示审核步骤给用户。

二、开发思路

1.根据节点规则,自定义一个字段存储审核节点类型:nodeType:1-8

2.区分审核节点是一组还是多组,

例如:一组审核时['发起审核','学术待审核','法务待审核','售后待审核'] ;

而多组审核则是8个状态都会出现,例如:['发起审核','学术已审核','法务已审核','售后已审核','修改审核','学术已审核','法务待审核','售后待审核',...]等此循环出现;

3.多组审核数据需要按照'审核节点规则'重新排序,用sort()重新生产结果数组。

4. 根据生成结果数组result,设置当前步骤值current。

三、项目运用代码(部分)

复制代码
function auditCheckClick(result){      
          if(result && result.length){
            let len = result.length
            result.map((item,index)=>{
              if(item.auditType==1){ item.nodeType=6}
              else if(item.auditType==2){ item.nodeType=7}
              else if(item.auditType==3){ item.nodeType=8}
              else if(item.auditType==4){ item.nodeType=2}
              else if(item.auditType==5){ item.nodeType=3}
              else if(item.auditType==6){ item.nodeType=4}
              else if(item.auditType==7||item.auditType==8){ item.nodeType=1}
              if(item.auditType==8){item.nodeIndex=index}
              return item
            })
            console.log(1,result)
            if(len<=4){ // 一组审核
              result.sort((r1,r2)=>{
                return r1.nodeType - r2.nodeType
              })
            }else{ // 多组审核
              let lastArr = result.filter(el=>el.nodeIndex)
              let lastIndex= lastArr&&lastArr.length?lastArr[lastArr.length-1].nodeIndex:0
              let hisSort = result.slice(0,lastIndex)
              let sortArr = result.slice(lastIndex)
              sortArr.sort((r1,r2)=>{return r1.nodeType - r2.nodeType})
              result = hisSort.concat(sortArr)
              console.log(2, lastArr,lastIndex)
              console.log(3, hisSort,sortArr)
              console.log(4, result)
            }
          }
 // result 结果数组

let step = result.findIndex(item=>item.auditType==1||item.auditType==2||item.auditType==3) // 学术、法务、售后的待审核状态
  let current = step&&step!=-1?step:result.length-1

复制代码
 
相关推荐
Anlici1 小时前
面试官:想把你问趴下 => 面题整理[3] 😮‍💨初心未变🚀
javascript·面试·前端框架
Hopebearer_3 小时前
vue3中ref和reactive的区别
开发语言·前端·javascript·vue.js·前端框架·ecmascript
winyh53 小时前
JWT要点备忘录
前端·前端框架
sailven10 小时前
【uniapp】图片添加canvas水印
uni-app·vue·canvas·拍照·图片水印
想自律的露西西★15 小时前
生命周期总结(uni-app、vue2、vue3生命周期讲解)
前端·javascript·前端框架
知识分享小能手20 小时前
Html5学习教程,从入门到精通,HTML `<div>` 和 `<span>` 标签:语法知识点与案例代码(12)
java·开发语言·前端·学习·前端框架·html·html5
winyh521 小时前
从零开始封装React UI 组件库并发布到NPM
前端·react.js·前端框架
巴巴博一1 天前
Nginx部署spa单页面的小bug
运维·nginx·vue
weixin_443566981 天前
MVVM 模式和 MVC 模式区别
vue
Kousi1 天前
手把手教你使用AVRecorder完成鸿蒙录音
前端·前端框架·harmonyos