hn-workflow-components 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -36065,7 +36065,10 @@ function tD({
|
|
|
36065
36065
|
)) }) }) })
|
|
36066
36066
|
] });
|
|
36067
36067
|
}
|
|
36068
|
-
const FS = Co({})
|
|
36068
|
+
const FS = Co({});
|
|
36069
|
+
function Dc() {
|
|
36070
|
+
return Wt(FS);
|
|
36071
|
+
}
|
|
36069
36072
|
function nD({ id: e, value: t, onChange: n }) {
|
|
36070
36073
|
const { onSelectRoles: r } = Dc(), [o, a] = Qe([]), [i, l] = Qe();
|
|
36071
36074
|
return at(() => {
|
|
@@ -1249,7 +1249,7 @@ html body {
|
|
|
1249
1249
|
bottom: 0;
|
|
1250
1250
|
background: ${e=>{var t;return(t=e.theme.token)==null?void 0:t.colorPrimary}};
|
|
1251
1251
|
height: 2px;
|
|
1252
|
-
`,az=C.memo(e=>{var s,l;const{value:t,options:n,onChange:r}=e,[o,a]=C.useState(t||((l=(s=e.options)==null?void 0:s[0])==null?void 0:l.key));C.useEffect(()=>{a(t)},[t]);const i=C.useCallback(c=>{a(c),r==null||r(c)},[r]);return w.jsx(nz,{children:n.map(c=>w.jsx(C.Fragment,{children:w.jsxs(rz,{className:o===c.key?"active":void 0,onClick:()=>i(c.key),children:[c.label,o===c.key&&w.jsx(oz,{})]})},c.key))})}),iz={display:"grid",marginTop:"10px"};function sz({form:e}){const t=e.getFieldValue("actions"),n=(t==null?void 0:t.map(p=>p.code))||[],[r,o]=C.useState(n),[a,i]=C.useState($_),s={wrapperCol:{span:24}},l=()=>{a.forEach(p=>{t.length&&t.forEach(h=>{h.code===p.code&&(p.button=h.button)})}),i(a)};C.useEffect(()=>{l()},[t]);const c=p=>{o(p);const h=[];a.forEach(v=>{v.code&&p.includes(v.code)&&h.push(v)}),e.setFieldValue("actions",h)},d=p=>{const h=JSON.parse(JSON.stringify(a));h.forEach(v=>{v.code===p.code&&(v.edit=!v.edit)}),i(h)},f=(p,h)=>{const v=JSON.parse(JSON.stringify(a));v.forEach(m=>{m.code===h.code&&(m.button=p.target.value)}),i(v)},g=p=>{const h=JSON.parse(JSON.stringify(a)),v=[];h.forEach(m=>{m.code===p.code&&(m.edit=!m.edit),r.includes(m.code)&&v.push(m)}),i(h),e.setFieldValue("actions",v)};return w.jsxs(w.Fragment,{children:[w.jsxs(Ao,{children:[w.jsx(Gt,{span:12,style:{fontWeight:"bold"},children:"权限名字"}),w.jsx(Gt,{span:12,style:{fontWeight:"bold"},children:"按钮名字"})]}),w.jsx(Nl.Group,{style:iz,value:r,onChange:c,children:w.jsx(w.Fragment,{children:a.map(p=>w.jsxs(Ao,{children:[w.jsx(Gt,{span:12,children:w.jsx(Nl,{value:p.code,style:{lineHeight:"32px"},children:p.name})}),!p.edit&&w.jsxs(Gt,{span:12,children:[p.button," ",w.jsx(c1,{onClick:()=>d(p)})]}),p.edit&&w.jsx(Gt,{span:12,children:w.jsx(Kt,{placeholder:"按钮名字",value:p.button,onChange:h=>f(h,p),onBlur:()=>g(p)})})]},p.code))})}),w.jsx("div",{style:{display:"none"},children:w.jsx(ze.List,{name:"actions",children:p=>w.jsx(w.Fragment,{children:p.map((h,v)=>C.createElement(ze.Item,{...s,required:!1,key:v},w.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[w.jsx(ze.Item,{name:[h.name,"code"],noStyle:!0,children:w.jsx(Kt,{placeholder:"权限"})}),w.jsx(ze.Item,{name:[h.name,"name"],noStyle:!0,children:w.jsx(Kt,{placeholder:"权限名字"})}),w.jsx(ze.Item,{name:[h.name,"button"],noStyle:!0,children:w.jsx(Kt,{placeholder:"按钮名字"})})]})))})})})]})}const nS=C.createContext({}),wc=()=>C.useContext(nS);function lz({id:e,value:t,onChange:n}){const{onSelectRoles:r}=wc(),[o,a]=C.useState([]),[i,s]=C.useState();C.useEffect(()=>{(async()=>{var f,g;if(r){const p=await r();a(p);return}const d=await KC();a(((g=(f=d.data)==null?void 0:f.data)==null?void 0:g.roleList)||[])})()},[]),C.useEffect(()=>{const c=t!=null&&t.ids?t.ids.split(","):[];s(c==null?void 0:c[0])},[t]);const l=c=>{const d=o.find(f=>f.value===c);d?(n==null||n({ids:d.value,names:d.label}),s(d.value)):(n==null||n(void 0),s(void 0))};return w.jsx("div",{id:e,children:w.jsx(Rn,{value:i,options:o,placeholder:"请选择角色",allowClear:!0,showSearch:!0,filterOption:(c,d)=>((d==null?void 0:d.label)??"").toLowerCase().includes(c.toLowerCase()),onChange:l})})}var Nm,rS;function oS(){if(rS)return Nm;rS=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Nm=e,Nm}var Pm,aS;function cz(){if(aS)return Pm;aS=1;var e=typeof ds=="object"&&ds&&ds.Object===Object&&ds;return Pm=e,Pm}var Tm,iS;function sS(){if(iS)return Tm;iS=1;var e=cz(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Tm=n,Tm}var Mm,lS;function uz(){if(lS)return Mm;lS=1;var e=sS(),t=function(){return e.Date.now()};return Mm=t,Mm}var _m,cS;function dz(){if(cS)return _m;cS=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return _m=t,_m}var Am,uS;function fz(){if(uS)return Am;uS=1;var e=dz(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Am=n,Am}var jm,dS;function fS(){if(dS)return jm;dS=1;var e=sS(),t=e.Symbol;return jm=t,jm}var Lm,mS;function mz(){if(mS)return Lm;mS=1;var e=fS(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,o=e?e.toStringTag:void 0;function a(i){var s=n.call(i,o),l=i[o];try{i[o]=void 0;var c=!0}catch{}var d=r.call(i);return c&&(s?i[o]=l:delete i[o]),d}return Lm=a,Lm}var zm,gS;function gz(){if(gS)return zm;gS=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return zm=n,zm}var Fm,pS;function pz(){if(pS)return Fm;pS=1;var e=fS(),t=mz(),n=gz(),r="[object Null]",o="[object Undefined]",a=e?e.toStringTag:void 0;function i(s){return s==null?s===void 0?o:r:a&&a in Object(s)?t(s):n(s)}return Fm=i,Fm}var Dm,vS;function vz(){if(vS)return Dm;vS=1;function e(t){return t!=null&&typeof t=="object"}return Dm=e,Dm}var Bm,hS;function hz(){if(hS)return Bm;hS=1;var e=pz(),t=vz(),n="[object Symbol]";function r(o){return typeof o=="symbol"||t(o)&&e(o)==n}return Bm=r,Bm}var Rm,bS;function bz(){if(bS)return Rm;bS=1;var e=fz(),t=oS(),n=hz(),r=NaN,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt;function l(c){if(typeof c=="number")return c;if(n(c))return r;if(t(c)){var d=typeof c.valueOf=="function"?c.valueOf():c;c=t(d)?d+"":d}if(typeof c!="string")return c===0?c:+c;c=e(c);var f=a.test(c);return f||i.test(c)?s(c.slice(2),f?2:8):o.test(c)?r:+c}return Rm=l,Rm}var km,yS;function yz(){if(yS)return km;yS=1;var e=oS(),t=uz(),n=bz(),r="Expected a function",o=Math.max,a=Math.min;function i(s,l,c){var d,f,g,p,h,v,m=0,b=!1,y=!1,S=!0;if(typeof s!="function")throw new TypeError(r);l=n(l)||0,e(c)&&(b=!!c.leading,y="maxWait"in c,g=y?o(n(c.maxWait)||0,l):g,S="trailing"in c?!!c.trailing:S);function x(_){var T=d,j=f;return d=f=void 0,m=_,p=s.apply(j,T),p}function $(_){return m=_,h=setTimeout(O,l),b?x(_):p}function E(_){var T=_-v,j=_-m,z=l-T;return y?a(z,g-j):z}function I(_){var T=_-v,j=_-m;return v===void 0||T>=l||T<0||y&&j>=g}function O(){var _=t();if(I(_))return N(_);h=setTimeout(O,E(_))}function N(_){return h=void 0,S&&d?x(_):(d=f=void 0,p)}function P(){h!==void 0&&clearTimeout(h),m=0,d=v=f=h=void 0}function M(){return h===void 0?p:N(t())}function A(){var _=t(),T=I(_);if(d=arguments,f=this,v=_,T){if(h===void 0)return $(v);if(y)return clearTimeout(h),h=setTimeout(O,l),x(v)}return h===void 0&&(h=setTimeout(O,l)),p}return A.cancel=P,A.flush=M,A}return km=i,km}var Cz=yz();const Sz=wg(Cz),xz=100;function wz(e,t,n){const r=e.filter(i=>t.includes(i.value)),a=e.filter(i=>!t.includes(i.value)).slice(0,Math.max(0,n-r.length));return[...r,...a]}function Hm({id:e,value:t,onChange:n}){const{onSelectMembers:r}=wc(),[o,a]=C.useState([]),[i,s]=C.useState(""),[l,c]=C.useState([]);C.useEffect(()=>{(async()=>{var y,S;if(r){const x=await r();a(x);return}const b=await KC();a(((S=(y=b.data)==null?void 0:y.data)==null?void 0:S.userList)||[])})()},[]),C.useEffect(()=>{const m=t!=null&&t.ids?t.ids.split(","):[];c(m)},[t]);const d=C.useMemo(()=>{const m=i.trim().toLowerCase();return m?o.filter(b=>b.label.toLowerCase().includes(m)||b.value.toLowerCase().includes(m)):o},[o,i]),f=C.useMemo(()=>wz(d,l,xz),[d,l]),g=m=>{const b=o.filter(y=>m==null?void 0:m.includes(y.value));if(b&&b.length){const y=b.map(x=>x.value),S=b.map(x=>x.label);n==null||n({ids:y.join(","),names:S.join(",")||""}),c(y)}else n==null||n(void 0),c([])},p=C.useCallback(m=>{s(m)},[]),h=C.useMemo(()=>Sz(m=>p(m),300),[p]),v=m=>{h(m)};return w.jsx("div",{id:e,children:w.jsx(Rn,{mode:"multiple",value:l,options:f,placeholder:"请选择成员",showSearch:!0,filterOption:!1,onSearch:v,onChange:g})})}const Vm="userId",CS="initiator",$z="initiatorDirectManager",Ez="initiatorDepartmentManager",Wm="role",SS=[{value:Vm,label:"指定成员"},{value:CS,label:"发起人自己"},{value:$z,label:"发起⼈的直属主管"},{value:Ez,label:"发起⼈的部⻔主管"},{value:Wm,label:"指定角色"}],Oz={display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8};function qm({form:e,applyType:t="approver"}){const[n,r]=C.useState(e.getFieldValue("groupType")||"userId"),o=C.useMemo(()=>t==="message"?"通知人员":"成员选择",[t]),a=C.useMemo(()=>t==="message"?"通知角色":"角色选择",[t]),i=C.useCallback(()=>{e.setFieldsValue({assignee:void 0,role:void 0})},[e]);return C.useEffect(()=>{e.getFieldValue("groupType")||e.setFieldsValue({groupType:n})},[]),w.jsxs(w.Fragment,{children:[w.jsx(ze.Item,{label:"用户类型",name:"groupType",required:!0,children:w.jsx(zt.Group,{style:Oz,onChange:s=>{const l=s.target.value;r(l),i()},children:SS.map(s=>w.jsx(zt,{value:s.value,children:s.label},s.value))})}),n==="userId"&&w.jsx(w.Fragment,{children:w.jsx(ze.Item,{label:o,name:"assignee",required:!0,rules:[{required:!0,message:`请选择${o}`}],children:w.jsx(Hm,{})})}),n==="role"&&w.jsx(w.Fragment,{children:w.jsx(ze.Item,{label:a,name:"role",required:!0,rules:[{required:!0,message:`请选择${a}`}],children:w.jsx(lz,{})})})]})}const xS=[{label:"会签",description:"默认需要所有审批人同意",value:"countersign",needConfig:!0,text:{configTitle:"会签配置",ratioTitle:"会签审核通过比例(%)",numTitle:"会签审核通过数量"}},{label:"或签",description:"一名审批人同意即可通过",value:"orSign",needConfig:!0,text:{configTitle:"或签配置",ratioTitle:"或签审核拒绝比例(%)",numTitle:"或签审核拒绝数量"}},{label:"并签",description:"同时审批通过",value:"andSign",needConfig:!0,text:{configTitle:"并签配置",ratioTitle:"并签审核通过比例(%)",numTitle:"并签审核通过数量"}},{label:"依次审批",description:"按审批顺序依次审批",value:"serialSign",needConfig:!1}],Iz={display:"flex",flexDirection:"column",gap:8},wS={display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8};function Nz({form:e}){var c,d,f;const[t,n]=C.useState(),[r,o]=C.useState(e.getFieldValue("signConfig.useRatio")||!0),a=ze.useWatch("groupType",e),i=ze.useWatch(["approver_is_empty","type"],e),s=ze.useWatch(["comment_setting","type"],e),l=g=>{const p=xS.find(h=>h.value===g);n(p)};return C.useEffect(()=>{l(e.getFieldValue("approverType")||"countersign")},[e]),w.jsxs(w.Fragment,{children:[w.jsx(qm,{form:e}),a!==CS&&w.jsxs(w.Fragment,{children:[w.jsx(ze.Item,{label:"多人审批时采用的审批方式",name:"approverType",required:!0,children:w.jsx(zt.Group,{style:Iz,onChange:g=>{l(g.target.value)},children:xS.map(g=>w.jsxs(zt,{value:g.value,children:[g.label,"(",g.description,")"]},g.value))})}),(t==null?void 0:t.needConfig)&&w.jsxs(w.Fragment,{children:[w.jsx("p",{children:(c=t==null?void 0:t.text)==null?void 0:c.configTitle}),w.jsx(ze.Item,{layout:"horizontal",label:"类型",name:["signConfig","useRatio"],rules:[{required:!0}],children:w.jsx(Bl,{checkedChildren:"按比例",unCheckedChildren:"按数量",onChange:o})}),r&&w.jsx(ze.Item,{layout:"horizontal",label:(d=t==null?void 0:t.text)==null?void 0:d.ratioTitle,name:["signConfig","ratio"],rules:[{required:!0,message:"请输入比例"}],children:w.jsx(Al,{min:1,max:100,step:1,precision:2})}),!r&&w.jsx(ze.Item,{layout:"horizontal",label:(f=t==null?void 0:t.text)==null?void 0:f.numTitle,name:["signConfig","num"],rules:[{required:!0,message:"请输入数量"}],children:w.jsx(Al,{min:1,step:1,precision:0})})]})]}),w.jsx(ze.Item,{label:"审批人包含发起人时",name:["initiator_is_included","type"],required:!0,children:w.jsxs(zt.Group,{style:wS,children:[w.jsx(zt,{value:"require_process",children:"发起人继续处理"}),w.jsx(zt,{value:"auto_pass",children:"发起人不用处理"}),w.jsx(zt,{value:"forward_initiatorDirectManager",children:"转交给发起人直属主管处理"}),w.jsx(zt,{value:"forward_initiatorDepartmentManager",children:"转交给发起人部门主管处理"})]})}),w.jsx(ze.Item,{label:"审批人为空时",name:["approver_is_empty","type"],required:!0,children:w.jsxs(zt.Group,{style:wS,children:[w.jsx(zt,{value:"auto_pass",children:"自动通过"}),w.jsx(zt,{value:"auto_refuse",children:"自动拒绝"}),w.jsx(zt,{value:"assign_approver",children:"指定人员"}),w.jsx(zt,{value:"prompt_error",children:"报错提醒"})]})}),i==="assign_approver"&&w.jsx(w.Fragment,{children:w.jsx(ze.Item,{label:"指定人员",name:["approver_is_empty","user"],required:!0,rules:[{required:!0,message:"请选择指定人员"}],children:w.jsx(Hm,{})})}),w.jsx(ze.Item,{label:"审批被拒绝时",name:["approval_is_refused","type"],required:!0,rules:[{required:!0,message:"请选择审批被拒绝时的操作"}],children:w.jsxs(zt.Group,{children:[w.jsx(zt,{value:"end_process",children:"直接结束流程"}),w.jsx(zt,{value:"back_to_initiator",children:"退回到发起人"})]})}),w.jsx(ze.Item,{label:"审批意⻅设置",name:["comment_setting","type"],required:!0,rules:[{required:!0,message:"请选择审批被拒绝时的操作"}],children:w.jsxs(zt.Group,{children:[w.jsx(zt,{value:"everyone",children:"所有人可见"}),w.jsx(zt,{value:"assign_approver",children:"指定人员可见"})]})}),s==="assign_approver"&&w.jsx(w.Fragment,{children:w.jsx(ze.Item,{label:"指定人员",name:["comment_setting","user"],required:!0,rules:[{required:!0,message:"请选择指定人员"}],children:w.jsx(Hm,{})})})]})}function Pz(){const e={labelCol:{xs:{span:24},sm:{span:5}},wrapperCol:{xs:{span:24},sm:{span:24}}};return w.jsx(ze.List,{name:"extended",children:(t,{add:n,remove:r},{errors:o})=>w.jsxs(w.Fragment,{children:[t.map((a,i)=>C.createElement(ze.Item,{...e,required:!1,key:i},w.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[w.jsx(ze.Item,{name:[a.name,"name"],noStyle:!0,children:w.jsx(Kt,{placeholder:"扩展名"})}),w.jsx(ze.Item,{name:[a.name,"code"],noStyle:!0,children:w.jsx(Kt,{placeholder:"扩展值"})}),w.jsx(om,{onClick:()=>{r(a.name)}})]}))),w.jsxs(ze.Item,{children:[w.jsx(Et,{type:"dashed",onClick:()=>n(),style:{width:"100%"},icon:w.jsx(mo,{}),children:"添加扩展"}),w.jsx(ze.ErrorList,{errors:o})]})]})})}function Tz(){const e={labelCol:{xs:{span:24},sm:{span:5}},wrapperCol:{xs:{span:24},sm:{span:24}}};return w.jsxs("div",{children:[w.jsxs(Ao,{gutter:10,style:{marginBottom:"20px",background:"#fafafa",lineHeight:"40px"},children:[w.jsx(Gt,{span:12,style:{paddingLeft:"10px",fontWeight:"bold"},children:"表单字段"}),w.jsx(Gt,{span:12,style:{fontWeight:"bold"},children:"操作"})]}),w.jsx(ze.List,{name:"formConfig",children:(t,{add:n,remove:r},{errors:o})=>w.jsxs(w.Fragment,{children:[t.map((a,i)=>C.createElement(ze.Item,{...e,required:!1,key:i},w.jsxs(Ao,{gutter:10,children:[w.jsx(Gt,{span:12,children:w.jsx(ze.Item,{name:[a.name,"name"],noStyle:!0,children:w.jsx(Kt,{placeholder:"字段名"})})}),w.jsx(Gt,{span:10,children:w.jsx(ze.Item,{name:[a.name,"operate"],noStyle:!0,children:w.jsxs(zt.Group,{defaultValue:"1",children:[w.jsx(zt,{value:"1",children:"只读"}),w.jsx(zt,{value:"2",children:"编辑"}),w.jsx(zt,{value:"3",children:"隐藏"})]})})}),w.jsx(Gt,{span:2,children:w.jsx(om,{onClick:()=>{r(a.name)}})})]}))),w.jsxs(ze.Item,{children:[w.jsx(Et,{type:"dashed",onClick:()=>n(),style:{width:"100%"},icon:w.jsx(mo,{}),children:"添加字段"}),w.jsx(ze.ErrorList,{errors:o})]})]})})]})}function $S({name:e}){return w.jsxs(w.Fragment,{children:[w.jsx(ze.Item,{label:"请求地址",required:!0,name:[...e,"api_request_url"],rules:[{required:!0,message:"请输入请求地址"},{type:"url",message:"请输入正确的URL地址"}],children:w.jsx(Kt,{placeholder:"请输入请求地址"})}),w.jsx(ze.Item,{label:"请求头",tooltip:"请求头格式为JSON字符串",name:[...e,"api_request_headers"],children:w.jsx(Kt.TextArea,{autoSize:{minRows:4,maxRows:6},placeholder:"请输入请求头"})}),w.jsx(ze.Item,{label:"请求体",tooltip:"请求体格式为JSON字符串",name:[...e,"api_request_body"],children:w.jsx(Kt.TextArea,{autoSize:{minRows:4,maxRows:6},placeholder:"请输入请求体"})})]})}function Mz({form:e}){const t=ze.useWatch(["listeners","task_create","open"],e),n=ze.useWatch(["listeners","task_finish","open"],e);return w.jsxs(w.Fragment,{children:[w.jsx(ze.Item,{label:"创建任务",name:["listeners","task_create","open"],children:w.jsx(Bl,{checkedChildren:"开启",unCheckedChildren:"关闭"})}),t&&w.jsx($S,{name:["listeners","task_create"]}),w.jsx(ze.Item,{label:"任务完成",name:["listeners","task_finish","open"],children:w.jsx(Bl,{checkedChildren:"开启",unCheckedChildren:"关闭"})}),n&&w.jsx($S,{name:["listeners","task_finish"]})]})}const _z=C.memo(C.forwardRef((e,t)=>{const[n]=ze.useForm(),[r,o]=C.useState("assignee");return C.useImperativeHandle(t,()=>({getValue:()=>n.getFieldsValue(),validateFields:()=>n.validateFields()}),[n]),w.jsxs(ze,{form:n,layout:"vertical",colon:!1,initialValues:e.value,children:[w.jsx(az,{options:[{key:"assignee",label:"审批人"},{key:"actions",label:"操作权限"},{key:"listeners",label:"监听器"}],value:r,onChange:o}),w.jsx("div",{style:{display:r==="assignee"?"block":"none"},children:w.jsx(Nz,{form:n})}),w.jsx("div",{style:{display:r==="actions"?"block":"none"},children:w.jsx(sz,{form:n})}),w.jsx("div",{style:{display:r==="formConfig"?"block":"none"},children:w.jsx(Tz,{})}),w.jsx("div",{style:{display:r==="extended"?"block":"none"},children:w.jsx(Pz,{})}),w.jsx("div",{style:{display:r==="listeners"?"block":"none"},children:w.jsx(Mz,{form:n})})]})}));function Az(){return w.jsxs(Ao,{gutter:10,style:{marginBottom:20,background:"#fafafa",lineHeight:"40px"},children:[w.jsx(Gt,{span:3,style:{paddingLeft:10,fontWeight:"bold"},children:"关系"}),w.jsx(Gt,{span:9,style:{fontWeight:"bold"},children:"字段"}),w.jsx(Gt,{span:6,style:{fontWeight:"bold"},children:"条件"}),w.jsx(Gt,{span:4,style:{fontWeight:"bold"},children:"条件值"}),w.jsx(Gt,{span:2,style:{fontWeight:"bold"},children:"操作"})]})}const jz=[{label:"且",value:"and"},{label:"或",value:"or"}],Lz={and:"&&",or:"||"},ES={eq:"等于",ne:"不等于",gt:"大于",ge:"大于等于",lt:"小于",le:"小于等于",like:"包含",like_start:"开头包含",like_end:"结尾包含",empty:"为空",not_empty:"不为空"},zz={eq:"=",ne:"!=",gt:">",ge:">=",lt:"<",le:"<=",like:"contains",like_start:"startsWith",like_end:"endsWith",empty:"is empty",not_empty:"is not empty"},Fz=["eq","ne"],Dz=["eq","ne","gt","ge","lt","le"],Bz={text:Fz.map(e=>({label:ES[e],value:e})),number:Dz.map(e=>({label:ES[e],value:e}))},Rz={relation:"and",field:"",fieldType:"text",operator:"eq",value:""};function kz(e){const{item:t,fields:n,operatorOptionsByType:r,valueControls:o,onChange:a,onRemove:i}=e,s=C.useMemo(()=>n.map(v=>({label:v.label,value:v.value})),[n]),l=C.useMemo(()=>r[t.fieldType]||[],[r,t.fieldType]),c=t.operator!=="empty"&&t.operator!=="not_empty",d=o[t.fieldType],f=C.useCallback(v=>a({...t,relation:v}),[t,a]),g=C.useCallback(v=>{const m=n.find($=>$.value===v),b=m?m.type:t.fieldType,y=r[b].map($=>$.value),S=y.includes(t.operator)?t.operator:y[0];a({...t,field:v,fieldType:b,operator:S,value:S==="empty"||S==="not_empty"?void 0:b==="number"?0:""})},[n,t,a,r]),p=C.useCallback(v=>{const m=v==="empty"||v==="not_empty"?void 0:t.fieldType==="number"?typeof t.value=="number"?t.value:0:typeof t.value=="string"?t.value:"";a({...t,operator:v,value:m})},[t,a]),h=C.useCallback(v=>a({...t,value:v}),[t,a]);return w.jsxs(Ao,{gutter:10,style:{marginBottom:8},children:[w.jsx(Gt,{span:3,children:w.jsx(Rn,{placeholder:"关系",options:jz,value:t.relation,onChange:f,style:{width:"100%"}})}),w.jsx(Gt,{span:9,children:w.jsx(Rn,{placeholder:"字段",options:s,value:t.field,onChange:g,style:{width:"100%"}})}),w.jsx(Gt,{span:6,children:w.jsx(Rn,{placeholder:"条件",options:l,value:t.operator,onChange:p,style:{width:"100%"}})}),w.jsx(Gt,{span:4,children:c&&d?w.jsx(d,{value:t.value,onChange:h}):null}),w.jsx(Gt,{span:2,style:{display:"flex",alignItems:"center"},children:w.jsx(om,{onClick:i})})]})}function Hz(e){const{value:t,onChange:n,fields:r,defaultCondition:o,operatorOptionsByType:a,valueControls:i}=e,s=C.useCallback(()=>n([...t||[],o]),[n,t,o]),l=C.useCallback(d=>{const f=[...t];f.splice(d,1),n(f)},[n,t]),c=C.useCallback((d,f)=>{const g=[...t];g[d]=f,n(g)},[n,t]);return w.jsxs(w.Fragment,{children:[(t||[]).map((d,f)=>w.jsx(kz,{item:d,fields:r,operatorOptionsByType:a,valueControls:i,onChange:g=>c(f,g),onRemove:()=>l(f)},f)),w.jsx(Et,{type:"dashed",onClick:s,style:{width:"100%"},icon:w.jsx(mo,{}),children:"添加条件"})]})}const Vz={text:({value:e,onChange:t})=>{const n=typeof e=="string"?e:"";return w.jsx(Kt,{value:n,onChange:r=>t(r.target.value),placeholder:"条件值"})},number:({value:e,onChange:t})=>{const n=typeof e=="number"?e:void 0;return w.jsx(Al,{style:{width:"100%"},value:n,onChange:r=>t(typeof r=="number"?r:void 0)})}};function Wz(e){const t=["empty","not_empty"];function n(i,s){return i===0||!s?"":` ${Lz[s]||""} `}function r(i){let s="";return t.includes(i.operator)||!i.value?"":(i.fieldType==="text"?s=`'${i.value}'`:s=i.value.toString(),` ${s}`)}function o(i){if(!i.field||!i.operator)return"";const s=r(i);if(!t.includes(i.operator)&&!s)return"";const l=zz[i.operator]||"";return`${i.field} ${l}${s}`}if(!e)return"";let a="";return e.forEach((i,s)=>{a+=n(s,i.relation),a+=o(i)}),a?`\${${a}}`:""}function qz(e){const[t,n]=C.useState([]),[r,o]=C.useState([]),a="value"in e,i=C.useMemo(()=>a?e.value||[]:t,[a,e.value,t]),s=C.useCallback(d=>{a||n(d),e.onChange&&e.onChange(d)},[a,e]),l=C.useCallback(d=>s(d),[s]),c=C.useCallback(async d=>{var f,g;try{const p=await SL(d);o(((g=(f=p.data)==null?void 0:f.data)==null?void 0:g.bizFormJson)||[])}catch(p){console.error("[海牛工作流SDK}] 获取条件单字段失败",p)}},[]);return C.useEffect(()=>{const d=bL();c(d.key||"")},[c]),w.jsxs("div",{children:[w.jsx(Az,{}),w.jsx(Hz,{value:i,onChange:l,fields:r,defaultCondition:Rz,operatorOptionsByType:Bz,valueControls:Vz})]})}const Uz=C.memo(C.forwardRef((e,t)=>{const[n]=ze.useForm();return C.useImperativeHandle(t,()=>({getValue:()=>n.getFieldsValue(),validateFields:()=>n.validateFields()}),[n]),w.jsxs(ze,{form:n,layout:"vertical",colon:!1,initialValues:e.value,children:[w.jsx(ze.Item,{name:"conditions",noStyle:!0,children:w.jsx(qz,{onChange:r=>n.setFieldValue("condition",Wz(r))})}),w.jsx(ze.Item,{hidden:!0,name:"condition"})]})})),OS={approverType:"orSign",actions:[{code:"addSigner",name:"加签",button:"加签"}]},Gz=C.forwardRef((e,t)=>{const{value:n}=e,[r]=ze.useForm();return C.useImperativeHandle(t,()=>({getValue:()=>r.getFieldsValue(),validateFields:()=>(console.log("validate dispatcher panel",r.getFieldsValue()),r.validateFields())}),[r]),C.useEffect(()=>{r.setFieldsValue({...OS,...n})},[n,r]),w.jsxs(ze,{form:r,layout:"vertical",colon:!1,initialValues:{...OS,...n},children:[w.jsx(qm,{form:r}),w.jsx(ze.Item,{label:"多人审批时采用的审批方式",name:"approverType",required:!0,hidden:!0,children:w.jsx(Kt,{})}),w.jsx(ze.Item,{label:"默认操作权限",name:"actions",required:!0,hidden:!0,children:w.jsx(Kt,{})})]})}),Kz=C.memo(C.forwardRef((e,t)=>{const[n]=ze.useForm();return C.useImperativeHandle(t,()=>({getValue:()=>n.getFieldsValue(),validateFields:()=>n.validateFields()}),[n]),w.jsx(ze,{form:n,layout:"vertical",colon:!1,initialValues:e.value,children:w.jsx(qm,{form:n})})})),Xz=C.memo(C.forwardRef((e,t)=>{const[n]=ze.useForm();return C.useImperativeHandle(t,()=>({getValue:()=>n.getFieldsValue(),validateFields:()=>n.validateFields()}),[n]),w.jsx(ze,{form:n,layout:"vertical",colon:!1,initialValues:e.value,children:w.jsx(ze.Item,{label:"发起人",name:"initiator",children:w.jsx(Kt,{})})})})),Yz=[{value:"scrap_apply",label:"报废申请"},{value:"dept_approve",label:"部门审批"},{value:"tech_eval",label:"技术评估"},{value:"asset_approve",label:"资产管理审批"},{value:"finance_approve",label:"财务审批"}],Jz=C.memo(C.forwardRef((e,t)=>{const[n]=ze.useForm(),r=(o,a)=>{n.setFieldValue("subProcessName",a.label)};return C.useImperativeHandle(t,()=>({getValue:()=>n.getFieldsValue(),validateFields:()=>n.validateFields()}),[n]),w.jsxs(ze,{form:n,layout:"vertical",colon:!1,initialValues:e.value,children:[w.jsx(zl,{label:"子流程",name:"subProcessId",children:w.jsx(Rn,{placeholder:"请选择子流程",options:Yz,onChange:r})}),w.jsx(zl,{hidden:!0,name:"subProcessName",children:w.jsx(Kt,{})})]})}));function Um(e){var n,r,o,a,i;const t=(n=e.config)==null?void 0:n.groupType;return t?t===Vm?!!(((o=(r=e.config)==null?void 0:r.assignee)==null?void 0:o.ids)||""):t===Wm?!!(((i=(a=e.config)==null?void 0:a.role)==null?void 0:i.ids)||""):!0:!1}function Gm(e){var r,o;if(!e)return"";const t=e==null?void 0:e.groupType;let n;if(t){const a=SS.find(i=>i.value===t);if(a)switch(a.value){case Vm:n=((r=e==null?void 0:e.assignee)==null?void 0:r.names)||"";break;case Wm:n=((o=e==null?void 0:e.role)==null?void 0:o.names)||"";break;default:n=a.label;break}}return n}const IS={[it.approver]:{viewContent:e=>{const t=Gm(e.config);return w.jsx(Fa,{secondary:!t,text:t||"选择审批人"})},settersPanel:_z,validate:e=>Um(e)?!0:"未选择审批人"},[it.condition]:{viewContent:e=>{var n;const t=((n=e.config)==null?void 0:n.conditions)||[];return w.jsx(Fa,{secondary:!t.length,text:t.length?"已配置":"请配置条件"})},settersPanel:Uz,validate:e=>e.config?!0:`${e.name}未设置条件`},[it.notifier]:{viewContent:e=>{const t=Gm(e.config);return w.jsx(Fa,{secondary:!t,text:t||"选择抄送人"})},settersPanel:Kz,validate:e=>Um(e)?!0:"未选择抄送人"},[it.start]:{viewContent:e=>{var t;return w.jsx(Fa,{text:`${(t=e.config)==null?void 0:t.initiator}`})},settersPanel:Xz},[it.subProcess]:{viewContent:e=>{var t;return w.jsx(Fa,{text:`${((t=e.config)==null?void 0:t.subProcessName)||"选择子流程"}`})},validate:e=>{var t;return(t=e.config)!=null&&t.subProcessId?!0:"未选择子流程"},settersPanel:Jz},[it.dispatcher]:{viewContent:e=>{const t=Gm(e.config);return w.jsx(Fa,{secondary:!t,text:t||"选择分发人"})},settersPanel:Gz,validate:e=>(console.log("validate dispatcher",e),Um(e)?!0:"未选择分发人")}},Zz=be.div`
|
|
1252
|
+
`,az=C.memo(e=>{var s,l;const{value:t,options:n,onChange:r}=e,[o,a]=C.useState(t||((l=(s=e.options)==null?void 0:s[0])==null?void 0:l.key));C.useEffect(()=>{a(t)},[t]);const i=C.useCallback(c=>{a(c),r==null||r(c)},[r]);return w.jsx(nz,{children:n.map(c=>w.jsx(C.Fragment,{children:w.jsxs(rz,{className:o===c.key?"active":void 0,onClick:()=>i(c.key),children:[c.label,o===c.key&&w.jsx(oz,{})]})},c.key))})}),iz={display:"grid",marginTop:"10px"};function sz({form:e}){const t=e.getFieldValue("actions"),n=(t==null?void 0:t.map(p=>p.code))||[],[r,o]=C.useState(n),[a,i]=C.useState($_),s={wrapperCol:{span:24}},l=()=>{a.forEach(p=>{t.length&&t.forEach(h=>{h.code===p.code&&(p.button=h.button)})}),i(a)};C.useEffect(()=>{l()},[t]);const c=p=>{o(p);const h=[];a.forEach(v=>{v.code&&p.includes(v.code)&&h.push(v)}),e.setFieldValue("actions",h)},d=p=>{const h=JSON.parse(JSON.stringify(a));h.forEach(v=>{v.code===p.code&&(v.edit=!v.edit)}),i(h)},f=(p,h)=>{const v=JSON.parse(JSON.stringify(a));v.forEach(m=>{m.code===h.code&&(m.button=p.target.value)}),i(v)},g=p=>{const h=JSON.parse(JSON.stringify(a)),v=[];h.forEach(m=>{m.code===p.code&&(m.edit=!m.edit),r.includes(m.code)&&v.push(m)}),i(h),e.setFieldValue("actions",v)};return w.jsxs(w.Fragment,{children:[w.jsxs(Ao,{children:[w.jsx(Gt,{span:12,style:{fontWeight:"bold"},children:"权限名字"}),w.jsx(Gt,{span:12,style:{fontWeight:"bold"},children:"按钮名字"})]}),w.jsx(Nl.Group,{style:iz,value:r,onChange:c,children:w.jsx(w.Fragment,{children:a.map(p=>w.jsxs(Ao,{children:[w.jsx(Gt,{span:12,children:w.jsx(Nl,{value:p.code,style:{lineHeight:"32px"},children:p.name})}),!p.edit&&w.jsxs(Gt,{span:12,children:[p.button," ",w.jsx(c1,{onClick:()=>d(p)})]}),p.edit&&w.jsx(Gt,{span:12,children:w.jsx(Kt,{placeholder:"按钮名字",value:p.button,onChange:h=>f(h,p),onBlur:()=>g(p)})})]},p.code))})}),w.jsx("div",{style:{display:"none"},children:w.jsx(ze.List,{name:"actions",children:p=>w.jsx(w.Fragment,{children:p.map((h,v)=>C.createElement(ze.Item,{...s,required:!1,key:v},w.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[w.jsx(ze.Item,{name:[h.name,"code"],noStyle:!0,children:w.jsx(Kt,{placeholder:"权限"})}),w.jsx(ze.Item,{name:[h.name,"name"],noStyle:!0,children:w.jsx(Kt,{placeholder:"权限名字"})}),w.jsx(ze.Item,{name:[h.name,"button"],noStyle:!0,children:w.jsx(Kt,{placeholder:"按钮名字"})})]})))})})})]})}const nS=C.createContext({});function wc(){return C.useContext(nS)}function lz({id:e,value:t,onChange:n}){const{onSelectRoles:r}=wc(),[o,a]=C.useState([]),[i,s]=C.useState();C.useEffect(()=>{(async()=>{var f,g;if(r){const p=await r();a(p);return}const d=await KC();a(((g=(f=d.data)==null?void 0:f.data)==null?void 0:g.roleList)||[])})()},[]),C.useEffect(()=>{const c=t!=null&&t.ids?t.ids.split(","):[];s(c==null?void 0:c[0])},[t]);const l=c=>{const d=o.find(f=>f.value===c);d?(n==null||n({ids:d.value,names:d.label}),s(d.value)):(n==null||n(void 0),s(void 0))};return w.jsx("div",{id:e,children:w.jsx(Rn,{value:i,options:o,placeholder:"请选择角色",allowClear:!0,showSearch:!0,filterOption:(c,d)=>((d==null?void 0:d.label)??"").toLowerCase().includes(c.toLowerCase()),onChange:l})})}var Nm,rS;function oS(){if(rS)return Nm;rS=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Nm=e,Nm}var Pm,aS;function cz(){if(aS)return Pm;aS=1;var e=typeof ds=="object"&&ds&&ds.Object===Object&&ds;return Pm=e,Pm}var Tm,iS;function sS(){if(iS)return Tm;iS=1;var e=cz(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Tm=n,Tm}var Mm,lS;function uz(){if(lS)return Mm;lS=1;var e=sS(),t=function(){return e.Date.now()};return Mm=t,Mm}var _m,cS;function dz(){if(cS)return _m;cS=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return _m=t,_m}var Am,uS;function fz(){if(uS)return Am;uS=1;var e=dz(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Am=n,Am}var jm,dS;function fS(){if(dS)return jm;dS=1;var e=sS(),t=e.Symbol;return jm=t,jm}var Lm,mS;function mz(){if(mS)return Lm;mS=1;var e=fS(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,o=e?e.toStringTag:void 0;function a(i){var s=n.call(i,o),l=i[o];try{i[o]=void 0;var c=!0}catch{}var d=r.call(i);return c&&(s?i[o]=l:delete i[o]),d}return Lm=a,Lm}var zm,gS;function gz(){if(gS)return zm;gS=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return zm=n,zm}var Fm,pS;function pz(){if(pS)return Fm;pS=1;var e=fS(),t=mz(),n=gz(),r="[object Null]",o="[object Undefined]",a=e?e.toStringTag:void 0;function i(s){return s==null?s===void 0?o:r:a&&a in Object(s)?t(s):n(s)}return Fm=i,Fm}var Dm,vS;function vz(){if(vS)return Dm;vS=1;function e(t){return t!=null&&typeof t=="object"}return Dm=e,Dm}var Bm,hS;function hz(){if(hS)return Bm;hS=1;var e=pz(),t=vz(),n="[object Symbol]";function r(o){return typeof o=="symbol"||t(o)&&e(o)==n}return Bm=r,Bm}var Rm,bS;function bz(){if(bS)return Rm;bS=1;var e=fz(),t=oS(),n=hz(),r=NaN,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt;function l(c){if(typeof c=="number")return c;if(n(c))return r;if(t(c)){var d=typeof c.valueOf=="function"?c.valueOf():c;c=t(d)?d+"":d}if(typeof c!="string")return c===0?c:+c;c=e(c);var f=a.test(c);return f||i.test(c)?s(c.slice(2),f?2:8):o.test(c)?r:+c}return Rm=l,Rm}var km,yS;function yz(){if(yS)return km;yS=1;var e=oS(),t=uz(),n=bz(),r="Expected a function",o=Math.max,a=Math.min;function i(s,l,c){var d,f,g,p,h,v,m=0,b=!1,y=!1,S=!0;if(typeof s!="function")throw new TypeError(r);l=n(l)||0,e(c)&&(b=!!c.leading,y="maxWait"in c,g=y?o(n(c.maxWait)||0,l):g,S="trailing"in c?!!c.trailing:S);function x(_){var T=d,j=f;return d=f=void 0,m=_,p=s.apply(j,T),p}function $(_){return m=_,h=setTimeout(O,l),b?x(_):p}function E(_){var T=_-v,j=_-m,z=l-T;return y?a(z,g-j):z}function I(_){var T=_-v,j=_-m;return v===void 0||T>=l||T<0||y&&j>=g}function O(){var _=t();if(I(_))return N(_);h=setTimeout(O,E(_))}function N(_){return h=void 0,S&&d?x(_):(d=f=void 0,p)}function P(){h!==void 0&&clearTimeout(h),m=0,d=v=f=h=void 0}function M(){return h===void 0?p:N(t())}function A(){var _=t(),T=I(_);if(d=arguments,f=this,v=_,T){if(h===void 0)return $(v);if(y)return clearTimeout(h),h=setTimeout(O,l),x(v)}return h===void 0&&(h=setTimeout(O,l)),p}return A.cancel=P,A.flush=M,A}return km=i,km}var Cz=yz();const Sz=wg(Cz),xz=100;function wz(e,t,n){const r=e.filter(i=>t.includes(i.value)),a=e.filter(i=>!t.includes(i.value)).slice(0,Math.max(0,n-r.length));return[...r,...a]}function Hm({id:e,value:t,onChange:n}){const{onSelectMembers:r}=wc(),[o,a]=C.useState([]),[i,s]=C.useState(""),[l,c]=C.useState([]);C.useEffect(()=>{(async()=>{var y,S;if(r){const x=await r();a(x);return}const b=await KC();a(((S=(y=b.data)==null?void 0:y.data)==null?void 0:S.userList)||[])})()},[]),C.useEffect(()=>{const m=t!=null&&t.ids?t.ids.split(","):[];c(m)},[t]);const d=C.useMemo(()=>{const m=i.trim().toLowerCase();return m?o.filter(b=>b.label.toLowerCase().includes(m)||b.value.toLowerCase().includes(m)):o},[o,i]),f=C.useMemo(()=>wz(d,l,xz),[d,l]),g=m=>{const b=o.filter(y=>m==null?void 0:m.includes(y.value));if(b&&b.length){const y=b.map(x=>x.value),S=b.map(x=>x.label);n==null||n({ids:y.join(","),names:S.join(",")||""}),c(y)}else n==null||n(void 0),c([])},p=C.useCallback(m=>{s(m)},[]),h=C.useMemo(()=>Sz(m=>p(m),300),[p]),v=m=>{h(m)};return w.jsx("div",{id:e,children:w.jsx(Rn,{mode:"multiple",value:l,options:f,placeholder:"请选择成员",showSearch:!0,filterOption:!1,onSearch:v,onChange:g})})}const Vm="userId",CS="initiator",$z="initiatorDirectManager",Ez="initiatorDepartmentManager",Wm="role",SS=[{value:Vm,label:"指定成员"},{value:CS,label:"发起人自己"},{value:$z,label:"发起⼈的直属主管"},{value:Ez,label:"发起⼈的部⻔主管"},{value:Wm,label:"指定角色"}],Oz={display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8};function qm({form:e,applyType:t="approver"}){const[n,r]=C.useState(e.getFieldValue("groupType")||"userId"),o=C.useMemo(()=>t==="message"?"通知人员":"成员选择",[t]),a=C.useMemo(()=>t==="message"?"通知角色":"角色选择",[t]),i=C.useCallback(()=>{e.setFieldsValue({assignee:void 0,role:void 0})},[e]);return C.useEffect(()=>{e.getFieldValue("groupType")||e.setFieldsValue({groupType:n})},[]),w.jsxs(w.Fragment,{children:[w.jsx(ze.Item,{label:"用户类型",name:"groupType",required:!0,children:w.jsx(zt.Group,{style:Oz,onChange:s=>{const l=s.target.value;r(l),i()},children:SS.map(s=>w.jsx(zt,{value:s.value,children:s.label},s.value))})}),n==="userId"&&w.jsx(w.Fragment,{children:w.jsx(ze.Item,{label:o,name:"assignee",required:!0,rules:[{required:!0,message:`请选择${o}`}],children:w.jsx(Hm,{})})}),n==="role"&&w.jsx(w.Fragment,{children:w.jsx(ze.Item,{label:a,name:"role",required:!0,rules:[{required:!0,message:`请选择${a}`}],children:w.jsx(lz,{})})})]})}const xS=[{label:"会签",description:"默认需要所有审批人同意",value:"countersign",needConfig:!0,text:{configTitle:"会签配置",ratioTitle:"会签审核通过比例(%)",numTitle:"会签审核通过数量"}},{label:"或签",description:"一名审批人同意即可通过",value:"orSign",needConfig:!0,text:{configTitle:"或签配置",ratioTitle:"或签审核拒绝比例(%)",numTitle:"或签审核拒绝数量"}},{label:"并签",description:"同时审批通过",value:"andSign",needConfig:!0,text:{configTitle:"并签配置",ratioTitle:"并签审核通过比例(%)",numTitle:"并签审核通过数量"}},{label:"依次审批",description:"按审批顺序依次审批",value:"serialSign",needConfig:!1}],Iz={display:"flex",flexDirection:"column",gap:8},wS={display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8};function Nz({form:e}){var c,d,f;const[t,n]=C.useState(),[r,o]=C.useState(e.getFieldValue("signConfig.useRatio")||!0),a=ze.useWatch("groupType",e),i=ze.useWatch(["approver_is_empty","type"],e),s=ze.useWatch(["comment_setting","type"],e),l=g=>{const p=xS.find(h=>h.value===g);n(p)};return C.useEffect(()=>{l(e.getFieldValue("approverType")||"countersign")},[e]),w.jsxs(w.Fragment,{children:[w.jsx(qm,{form:e}),a!==CS&&w.jsxs(w.Fragment,{children:[w.jsx(ze.Item,{label:"多人审批时采用的审批方式",name:"approverType",required:!0,children:w.jsx(zt.Group,{style:Iz,onChange:g=>{l(g.target.value)},children:xS.map(g=>w.jsxs(zt,{value:g.value,children:[g.label,"(",g.description,")"]},g.value))})}),(t==null?void 0:t.needConfig)&&w.jsxs(w.Fragment,{children:[w.jsx("p",{children:(c=t==null?void 0:t.text)==null?void 0:c.configTitle}),w.jsx(ze.Item,{layout:"horizontal",label:"类型",name:["signConfig","useRatio"],rules:[{required:!0}],children:w.jsx(Bl,{checkedChildren:"按比例",unCheckedChildren:"按数量",onChange:o})}),r&&w.jsx(ze.Item,{layout:"horizontal",label:(d=t==null?void 0:t.text)==null?void 0:d.ratioTitle,name:["signConfig","ratio"],rules:[{required:!0,message:"请输入比例"}],children:w.jsx(Al,{min:1,max:100,step:1,precision:2})}),!r&&w.jsx(ze.Item,{layout:"horizontal",label:(f=t==null?void 0:t.text)==null?void 0:f.numTitle,name:["signConfig","num"],rules:[{required:!0,message:"请输入数量"}],children:w.jsx(Al,{min:1,step:1,precision:0})})]})]}),w.jsx(ze.Item,{label:"审批人包含发起人时",name:["initiator_is_included","type"],required:!0,children:w.jsxs(zt.Group,{style:wS,children:[w.jsx(zt,{value:"require_process",children:"发起人继续处理"}),w.jsx(zt,{value:"auto_pass",children:"发起人不用处理"}),w.jsx(zt,{value:"forward_initiatorDirectManager",children:"转交给发起人直属主管处理"}),w.jsx(zt,{value:"forward_initiatorDepartmentManager",children:"转交给发起人部门主管处理"})]})}),w.jsx(ze.Item,{label:"审批人为空时",name:["approver_is_empty","type"],required:!0,children:w.jsxs(zt.Group,{style:wS,children:[w.jsx(zt,{value:"auto_pass",children:"自动通过"}),w.jsx(zt,{value:"auto_refuse",children:"自动拒绝"}),w.jsx(zt,{value:"assign_approver",children:"指定人员"}),w.jsx(zt,{value:"prompt_error",children:"报错提醒"})]})}),i==="assign_approver"&&w.jsx(w.Fragment,{children:w.jsx(ze.Item,{label:"指定人员",name:["approver_is_empty","user"],required:!0,rules:[{required:!0,message:"请选择指定人员"}],children:w.jsx(Hm,{})})}),w.jsx(ze.Item,{label:"审批被拒绝时",name:["approval_is_refused","type"],required:!0,rules:[{required:!0,message:"请选择审批被拒绝时的操作"}],children:w.jsxs(zt.Group,{children:[w.jsx(zt,{value:"end_process",children:"直接结束流程"}),w.jsx(zt,{value:"back_to_initiator",children:"退回到发起人"})]})}),w.jsx(ze.Item,{label:"审批意⻅设置",name:["comment_setting","type"],required:!0,rules:[{required:!0,message:"请选择审批被拒绝时的操作"}],children:w.jsxs(zt.Group,{children:[w.jsx(zt,{value:"everyone",children:"所有人可见"}),w.jsx(zt,{value:"assign_approver",children:"指定人员可见"})]})}),s==="assign_approver"&&w.jsx(w.Fragment,{children:w.jsx(ze.Item,{label:"指定人员",name:["comment_setting","user"],required:!0,rules:[{required:!0,message:"请选择指定人员"}],children:w.jsx(Hm,{})})})]})}function Pz(){const e={labelCol:{xs:{span:24},sm:{span:5}},wrapperCol:{xs:{span:24},sm:{span:24}}};return w.jsx(ze.List,{name:"extended",children:(t,{add:n,remove:r},{errors:o})=>w.jsxs(w.Fragment,{children:[t.map((a,i)=>C.createElement(ze.Item,{...e,required:!1,key:i},w.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[w.jsx(ze.Item,{name:[a.name,"name"],noStyle:!0,children:w.jsx(Kt,{placeholder:"扩展名"})}),w.jsx(ze.Item,{name:[a.name,"code"],noStyle:!0,children:w.jsx(Kt,{placeholder:"扩展值"})}),w.jsx(om,{onClick:()=>{r(a.name)}})]}))),w.jsxs(ze.Item,{children:[w.jsx(Et,{type:"dashed",onClick:()=>n(),style:{width:"100%"},icon:w.jsx(mo,{}),children:"添加扩展"}),w.jsx(ze.ErrorList,{errors:o})]})]})})}function Tz(){const e={labelCol:{xs:{span:24},sm:{span:5}},wrapperCol:{xs:{span:24},sm:{span:24}}};return w.jsxs("div",{children:[w.jsxs(Ao,{gutter:10,style:{marginBottom:"20px",background:"#fafafa",lineHeight:"40px"},children:[w.jsx(Gt,{span:12,style:{paddingLeft:"10px",fontWeight:"bold"},children:"表单字段"}),w.jsx(Gt,{span:12,style:{fontWeight:"bold"},children:"操作"})]}),w.jsx(ze.List,{name:"formConfig",children:(t,{add:n,remove:r},{errors:o})=>w.jsxs(w.Fragment,{children:[t.map((a,i)=>C.createElement(ze.Item,{...e,required:!1,key:i},w.jsxs(Ao,{gutter:10,children:[w.jsx(Gt,{span:12,children:w.jsx(ze.Item,{name:[a.name,"name"],noStyle:!0,children:w.jsx(Kt,{placeholder:"字段名"})})}),w.jsx(Gt,{span:10,children:w.jsx(ze.Item,{name:[a.name,"operate"],noStyle:!0,children:w.jsxs(zt.Group,{defaultValue:"1",children:[w.jsx(zt,{value:"1",children:"只读"}),w.jsx(zt,{value:"2",children:"编辑"}),w.jsx(zt,{value:"3",children:"隐藏"})]})})}),w.jsx(Gt,{span:2,children:w.jsx(om,{onClick:()=>{r(a.name)}})})]}))),w.jsxs(ze.Item,{children:[w.jsx(Et,{type:"dashed",onClick:()=>n(),style:{width:"100%"},icon:w.jsx(mo,{}),children:"添加字段"}),w.jsx(ze.ErrorList,{errors:o})]})]})})]})}function $S({name:e}){return w.jsxs(w.Fragment,{children:[w.jsx(ze.Item,{label:"请求地址",required:!0,name:[...e,"api_request_url"],rules:[{required:!0,message:"请输入请求地址"},{type:"url",message:"请输入正确的URL地址"}],children:w.jsx(Kt,{placeholder:"请输入请求地址"})}),w.jsx(ze.Item,{label:"请求头",tooltip:"请求头格式为JSON字符串",name:[...e,"api_request_headers"],children:w.jsx(Kt.TextArea,{autoSize:{minRows:4,maxRows:6},placeholder:"请输入请求头"})}),w.jsx(ze.Item,{label:"请求体",tooltip:"请求体格式为JSON字符串",name:[...e,"api_request_body"],children:w.jsx(Kt.TextArea,{autoSize:{minRows:4,maxRows:6},placeholder:"请输入请求体"})})]})}function Mz({form:e}){const t=ze.useWatch(["listeners","task_create","open"],e),n=ze.useWatch(["listeners","task_finish","open"],e);return w.jsxs(w.Fragment,{children:[w.jsx(ze.Item,{label:"创建任务",name:["listeners","task_create","open"],children:w.jsx(Bl,{checkedChildren:"开启",unCheckedChildren:"关闭"})}),t&&w.jsx($S,{name:["listeners","task_create"]}),w.jsx(ze.Item,{label:"任务完成",name:["listeners","task_finish","open"],children:w.jsx(Bl,{checkedChildren:"开启",unCheckedChildren:"关闭"})}),n&&w.jsx($S,{name:["listeners","task_finish"]})]})}const _z=C.memo(C.forwardRef((e,t)=>{const[n]=ze.useForm(),[r,o]=C.useState("assignee");return C.useImperativeHandle(t,()=>({getValue:()=>n.getFieldsValue(),validateFields:()=>n.validateFields()}),[n]),w.jsxs(ze,{form:n,layout:"vertical",colon:!1,initialValues:e.value,children:[w.jsx(az,{options:[{key:"assignee",label:"审批人"},{key:"actions",label:"操作权限"},{key:"listeners",label:"监听器"}],value:r,onChange:o}),w.jsx("div",{style:{display:r==="assignee"?"block":"none"},children:w.jsx(Nz,{form:n})}),w.jsx("div",{style:{display:r==="actions"?"block":"none"},children:w.jsx(sz,{form:n})}),w.jsx("div",{style:{display:r==="formConfig"?"block":"none"},children:w.jsx(Tz,{})}),w.jsx("div",{style:{display:r==="extended"?"block":"none"},children:w.jsx(Pz,{})}),w.jsx("div",{style:{display:r==="listeners"?"block":"none"},children:w.jsx(Mz,{form:n})})]})}));function Az(){return w.jsxs(Ao,{gutter:10,style:{marginBottom:20,background:"#fafafa",lineHeight:"40px"},children:[w.jsx(Gt,{span:3,style:{paddingLeft:10,fontWeight:"bold"},children:"关系"}),w.jsx(Gt,{span:9,style:{fontWeight:"bold"},children:"字段"}),w.jsx(Gt,{span:6,style:{fontWeight:"bold"},children:"条件"}),w.jsx(Gt,{span:4,style:{fontWeight:"bold"},children:"条件值"}),w.jsx(Gt,{span:2,style:{fontWeight:"bold"},children:"操作"})]})}const jz=[{label:"且",value:"and"},{label:"或",value:"or"}],Lz={and:"&&",or:"||"},ES={eq:"等于",ne:"不等于",gt:"大于",ge:"大于等于",lt:"小于",le:"小于等于",like:"包含",like_start:"开头包含",like_end:"结尾包含",empty:"为空",not_empty:"不为空"},zz={eq:"=",ne:"!=",gt:">",ge:">=",lt:"<",le:"<=",like:"contains",like_start:"startsWith",like_end:"endsWith",empty:"is empty",not_empty:"is not empty"},Fz=["eq","ne"],Dz=["eq","ne","gt","ge","lt","le"],Bz={text:Fz.map(e=>({label:ES[e],value:e})),number:Dz.map(e=>({label:ES[e],value:e}))},Rz={relation:"and",field:"",fieldType:"text",operator:"eq",value:""};function kz(e){const{item:t,fields:n,operatorOptionsByType:r,valueControls:o,onChange:a,onRemove:i}=e,s=C.useMemo(()=>n.map(v=>({label:v.label,value:v.value})),[n]),l=C.useMemo(()=>r[t.fieldType]||[],[r,t.fieldType]),c=t.operator!=="empty"&&t.operator!=="not_empty",d=o[t.fieldType],f=C.useCallback(v=>a({...t,relation:v}),[t,a]),g=C.useCallback(v=>{const m=n.find($=>$.value===v),b=m?m.type:t.fieldType,y=r[b].map($=>$.value),S=y.includes(t.operator)?t.operator:y[0];a({...t,field:v,fieldType:b,operator:S,value:S==="empty"||S==="not_empty"?void 0:b==="number"?0:""})},[n,t,a,r]),p=C.useCallback(v=>{const m=v==="empty"||v==="not_empty"?void 0:t.fieldType==="number"?typeof t.value=="number"?t.value:0:typeof t.value=="string"?t.value:"";a({...t,operator:v,value:m})},[t,a]),h=C.useCallback(v=>a({...t,value:v}),[t,a]);return w.jsxs(Ao,{gutter:10,style:{marginBottom:8},children:[w.jsx(Gt,{span:3,children:w.jsx(Rn,{placeholder:"关系",options:jz,value:t.relation,onChange:f,style:{width:"100%"}})}),w.jsx(Gt,{span:9,children:w.jsx(Rn,{placeholder:"字段",options:s,value:t.field,onChange:g,style:{width:"100%"}})}),w.jsx(Gt,{span:6,children:w.jsx(Rn,{placeholder:"条件",options:l,value:t.operator,onChange:p,style:{width:"100%"}})}),w.jsx(Gt,{span:4,children:c&&d?w.jsx(d,{value:t.value,onChange:h}):null}),w.jsx(Gt,{span:2,style:{display:"flex",alignItems:"center"},children:w.jsx(om,{onClick:i})})]})}function Hz(e){const{value:t,onChange:n,fields:r,defaultCondition:o,operatorOptionsByType:a,valueControls:i}=e,s=C.useCallback(()=>n([...t||[],o]),[n,t,o]),l=C.useCallback(d=>{const f=[...t];f.splice(d,1),n(f)},[n,t]),c=C.useCallback((d,f)=>{const g=[...t];g[d]=f,n(g)},[n,t]);return w.jsxs(w.Fragment,{children:[(t||[]).map((d,f)=>w.jsx(kz,{item:d,fields:r,operatorOptionsByType:a,valueControls:i,onChange:g=>c(f,g),onRemove:()=>l(f)},f)),w.jsx(Et,{type:"dashed",onClick:s,style:{width:"100%"},icon:w.jsx(mo,{}),children:"添加条件"})]})}const Vz={text:({value:e,onChange:t})=>{const n=typeof e=="string"?e:"";return w.jsx(Kt,{value:n,onChange:r=>t(r.target.value),placeholder:"条件值"})},number:({value:e,onChange:t})=>{const n=typeof e=="number"?e:void 0;return w.jsx(Al,{style:{width:"100%"},value:n,onChange:r=>t(typeof r=="number"?r:void 0)})}};function Wz(e){const t=["empty","not_empty"];function n(i,s){return i===0||!s?"":` ${Lz[s]||""} `}function r(i){let s="";return t.includes(i.operator)||!i.value?"":(i.fieldType==="text"?s=`'${i.value}'`:s=i.value.toString(),` ${s}`)}function o(i){if(!i.field||!i.operator)return"";const s=r(i);if(!t.includes(i.operator)&&!s)return"";const l=zz[i.operator]||"";return`${i.field} ${l}${s}`}if(!e)return"";let a="";return e.forEach((i,s)=>{a+=n(s,i.relation),a+=o(i)}),a?`\${${a}}`:""}function qz(e){const[t,n]=C.useState([]),[r,o]=C.useState([]),a="value"in e,i=C.useMemo(()=>a?e.value||[]:t,[a,e.value,t]),s=C.useCallback(d=>{a||n(d),e.onChange&&e.onChange(d)},[a,e]),l=C.useCallback(d=>s(d),[s]),c=C.useCallback(async d=>{var f,g;try{const p=await SL(d);o(((g=(f=p.data)==null?void 0:f.data)==null?void 0:g.bizFormJson)||[])}catch(p){console.error("[海牛工作流SDK}] 获取条件单字段失败",p)}},[]);return C.useEffect(()=>{const d=bL();c(d.key||"")},[c]),w.jsxs("div",{children:[w.jsx(Az,{}),w.jsx(Hz,{value:i,onChange:l,fields:r,defaultCondition:Rz,operatorOptionsByType:Bz,valueControls:Vz})]})}const Uz=C.memo(C.forwardRef((e,t)=>{const[n]=ze.useForm();return C.useImperativeHandle(t,()=>({getValue:()=>n.getFieldsValue(),validateFields:()=>n.validateFields()}),[n]),w.jsxs(ze,{form:n,layout:"vertical",colon:!1,initialValues:e.value,children:[w.jsx(ze.Item,{name:"conditions",noStyle:!0,children:w.jsx(qz,{onChange:r=>n.setFieldValue("condition",Wz(r))})}),w.jsx(ze.Item,{hidden:!0,name:"condition"})]})})),OS={approverType:"orSign",actions:[{code:"addSigner",name:"加签",button:"加签"}]},Gz=C.forwardRef((e,t)=>{const{value:n}=e,[r]=ze.useForm();return C.useImperativeHandle(t,()=>({getValue:()=>r.getFieldsValue(),validateFields:()=>(console.log("validate dispatcher panel",r.getFieldsValue()),r.validateFields())}),[r]),C.useEffect(()=>{r.setFieldsValue({...OS,...n})},[n,r]),w.jsxs(ze,{form:r,layout:"vertical",colon:!1,initialValues:{...OS,...n},children:[w.jsx(qm,{form:r}),w.jsx(ze.Item,{label:"多人审批时采用的审批方式",name:"approverType",required:!0,hidden:!0,children:w.jsx(Kt,{})}),w.jsx(ze.Item,{label:"默认操作权限",name:"actions",required:!0,hidden:!0,children:w.jsx(Kt,{})})]})}),Kz=C.memo(C.forwardRef((e,t)=>{const[n]=ze.useForm();return C.useImperativeHandle(t,()=>({getValue:()=>n.getFieldsValue(),validateFields:()=>n.validateFields()}),[n]),w.jsx(ze,{form:n,layout:"vertical",colon:!1,initialValues:e.value,children:w.jsx(qm,{form:n})})})),Xz=C.memo(C.forwardRef((e,t)=>{const[n]=ze.useForm();return C.useImperativeHandle(t,()=>({getValue:()=>n.getFieldsValue(),validateFields:()=>n.validateFields()}),[n]),w.jsx(ze,{form:n,layout:"vertical",colon:!1,initialValues:e.value,children:w.jsx(ze.Item,{label:"发起人",name:"initiator",children:w.jsx(Kt,{})})})})),Yz=[{value:"scrap_apply",label:"报废申请"},{value:"dept_approve",label:"部门审批"},{value:"tech_eval",label:"技术评估"},{value:"asset_approve",label:"资产管理审批"},{value:"finance_approve",label:"财务审批"}],Jz=C.memo(C.forwardRef((e,t)=>{const[n]=ze.useForm(),r=(o,a)=>{n.setFieldValue("subProcessName",a.label)};return C.useImperativeHandle(t,()=>({getValue:()=>n.getFieldsValue(),validateFields:()=>n.validateFields()}),[n]),w.jsxs(ze,{form:n,layout:"vertical",colon:!1,initialValues:e.value,children:[w.jsx(zl,{label:"子流程",name:"subProcessId",children:w.jsx(Rn,{placeholder:"请选择子流程",options:Yz,onChange:r})}),w.jsx(zl,{hidden:!0,name:"subProcessName",children:w.jsx(Kt,{})})]})}));function Um(e){var n,r,o,a,i;const t=(n=e.config)==null?void 0:n.groupType;return t?t===Vm?!!(((o=(r=e.config)==null?void 0:r.assignee)==null?void 0:o.ids)||""):t===Wm?!!(((i=(a=e.config)==null?void 0:a.role)==null?void 0:i.ids)||""):!0:!1}function Gm(e){var r,o;if(!e)return"";const t=e==null?void 0:e.groupType;let n;if(t){const a=SS.find(i=>i.value===t);if(a)switch(a.value){case Vm:n=((r=e==null?void 0:e.assignee)==null?void 0:r.names)||"";break;case Wm:n=((o=e==null?void 0:e.role)==null?void 0:o.names)||"";break;default:n=a.label;break}}return n}const IS={[it.approver]:{viewContent:e=>{const t=Gm(e.config);return w.jsx(Fa,{secondary:!t,text:t||"选择审批人"})},settersPanel:_z,validate:e=>Um(e)?!0:"未选择审批人"},[it.condition]:{viewContent:e=>{var n;const t=((n=e.config)==null?void 0:n.conditions)||[];return w.jsx(Fa,{secondary:!t.length,text:t.length?"已配置":"请配置条件"})},settersPanel:Uz,validate:e=>e.config?!0:`${e.name}未设置条件`},[it.notifier]:{viewContent:e=>{const t=Gm(e.config);return w.jsx(Fa,{secondary:!t,text:t||"选择抄送人"})},settersPanel:Kz,validate:e=>Um(e)?!0:"未选择抄送人"},[it.start]:{viewContent:e=>{var t;return w.jsx(Fa,{text:`${(t=e.config)==null?void 0:t.initiator}`})},settersPanel:Xz},[it.subProcess]:{viewContent:e=>{var t;return w.jsx(Fa,{text:`${((t=e.config)==null?void 0:t.subProcessName)||"选择子流程"}`})},validate:e=>{var t;return(t=e.config)!=null&&t.subProcessId?!0:"未选择子流程"},settersPanel:Jz},[it.dispatcher]:{viewContent:e=>{const t=Gm(e.config);return w.jsx(Fa,{secondary:!t,text:t||"选择分发人"})},settersPanel:Gz,validate:e=>(console.log("validate dispatcher",e),Um(e)?!0:"未选择分发人")}},Zz=be.div`
|
|
1253
1253
|
width: 100%;
|
|
1254
1254
|
height: 100vh;
|
|
1255
1255
|
display: flex;
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hn-workflow-components",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
|
+
"exports": {
|
|
5
|
+
".": {
|
|
6
|
+
"import": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"default": "./dist/workflow-components.es.js"
|
|
9
|
+
},
|
|
10
|
+
"require": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/workflow-components.umd.js"
|
|
13
|
+
},
|
|
14
|
+
"default": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/workflow-components.umd.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
4
20
|
"main": "dist/workflow-components.umd.js",
|
|
5
21
|
"module": "dist/workflow-components.es.js",
|
|
6
22
|
"types": "dist/index.d.ts",
|
|
@@ -16,8 +32,8 @@
|
|
|
16
32
|
"pub": "npm config set registry https://registry.npmjs.org/ && npm publish && npm config set registry https://registry.npmmirror.com/"
|
|
17
33
|
},
|
|
18
34
|
"peerDependencies": {
|
|
19
|
-
"react": "
|
|
20
|
-
"react-dom": "
|
|
35
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
36
|
+
"react-dom": "^17.0.0 || ^18.0.0"
|
|
21
37
|
},
|
|
22
38
|
"dependencies": {
|
|
23
39
|
"@ant-design/icons": "^5.1.4",
|