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

复制代码
 
相关推荐
杨进军6 分钟前
React 创建根节点 createRoot
前端·react.js·前端框架
vim怎么退出1 小时前
万字长文带你了解微前端架构
前端·微服务·前端框架
Codebee21 小时前
OneCode自主UI设计体系:架构解析与核心实现
前端·javascript·前端框架
百锦再1 天前
Vue中对象赋值问题:对象引用被保留,仅部分属性被覆盖
前端·javascript·vue.js·vue·web·reactive·ref
jingling5551 天前
面试版-前端开发核心知识
开发语言·前端·javascript·vue.js·面试·前端框架
伍哥的传说1 天前
鸿蒙系统(HarmonyOS)应用开发之手势锁屏密码锁(PatternLock)
前端·华为·前端框架·harmonyos·鸿蒙
青松学前端1 天前
vue-2.7源码解读之初始化流程和响应式实现
前端·vue.js·前端框架
杨进军1 天前
前端线上问题的那些事儿
前端·javascript·前端框架
一笑code1 天前
vue/微信小程序/h5 实现react的boundary
微信小程序·vue·react
eric*16881 天前
尚硅谷张天禹老师课程配套笔记
前端·vue.js·笔记·vue·尚硅谷·张天禹·尚硅谷张天禹