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

复制代码
 
相关推荐
Java后端的Ai之路1 天前
15_ReactJS_Flux_简介
前端·react.js·前端框架
weixin_446260851 天前
ReAct‑Evolve:基于轨迹反馈的ReAct智能体自主提示演化系统
前端·react.js·前端框架
阿Q的AI笔记1 天前
从ReAct到GRPO、从OpenHands到SWE-agent:Agent完整知识体系全拆解
前端·react.js·前端框架
Highcharts.js1 天前
Highcharts React v5 正式发布:支持 ESM、更简洁的组件、更出色的开发体验
前端·react.js·前端框架·数据可视化·highcharts·前端可视化·esm
Amos_Web2 天前
Rspack 源码解析(二十五):CssParserAndGenerator 如何把 CSS 变成可 Tree Shaking 的模块
前端·rust·前端框架
看浪的路人3 天前
第2讲:ReAct 模式从零实现——不用框架,手写一个 Agent 内核
前端·react.js·前端框架
冒险的豆子3 天前
Vue2 、Vue3 响应式对比及优劣
vue
Amos_Web3 天前
Rspack 源码解析(二十四):AssetPlugin 如何让图片同时是「URL 字符串」和「真实文件」
前端·rust·前端框架
Java后端的Ai之路4 天前
08_React组件API
前端·react.js·前端框架
NetX行者4 天前
用 Vite + Vue3 + UnoCSS 搭建企业级项目模板(一):基础骨架
vue·vite·unocss