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

复制代码
 
相关推荐
爱上纯净的蓝天15 小时前
使用 AtomCode 构建微前端架构:从设计到实现实战
架构·vue·实战·react·微前端·atomcode
星栈19 小时前
LiveView 怎么测:从组件测试到端到端,我终于不再只敢手点页面了
前端·前端框架·elixir
光影少年21 小时前
RN 渲染原理:不依赖WebView,原生控件渲染
前端·react native·react.js·前端框架
LaughingZhu2 天前
智能体经典范式构建:ReAct、Plan-and-Solve 与 Reflection
前端·react.js·前端框架
binbin_522 天前
React 井字棋教程:用一个小游戏理解组件和状态
前端·react.js·前端框架
禅思院2 天前
AI对话前端从入门到崩溃:一个长对话引发的五层优化战争【三】
前端·架构·前端框架
山海云端有限公司2 天前
随机诗词API实战:Vue项目接入完整示例与5个常见坑
vue·实战·前端开发·跨域·api调用·随机诗词api
YIAN3 天前
LangChain JS 工具调用实战:基于 DeepSeek-V4-Flash 实现本地文件读取 AI 代码助手(完整可运行源码)
javascript·langchain·前端框架
星栈3 天前
LiveView 的认证系统:从登录到权限,我一开始以为有 `current_user` 就算完事了
前端·前端框架·elixir
GISer_Jing3 天前
从 Demo 到 Production:拆解 Superpower、SDD、Harness 与 Loop 的现代 AI 落地范式
前端·人工智能·ai·前端框架