2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
|
|
import{t as e}from"./useQuery-dxbdhNvu.js";import{a as t,i as n,n as r,o as i,r as a,t as o}from"./select-stsOu5jD.js";import{t as s}from"./file-COj1kCUn.js";import{t as c}from"./folder-input--tEWrMtP.js";import{t as l}from"./folder-Dl7FxCLT.js";import{t as u}from"./plus-BHIlMeNy.js";import{t as d}from"./upload-Cr-BixPb.js";import{$ as f,Ft as p,G as m,H as h,K as g,M as _,Mt as v,Q as y,Qt as b,Tt as x,U as S,V as C,Vn as w,W as T,Zt as E,bt as ee,ct as D,et as O,fn as te,gt as ne,jt as k,ln as A,lt as re,mt as ie,q as j,qn as M,rn as N,st as P,tn as ae,tt as F,yn as I,yt as oe,zn as se}from"./index-BaTxSAlR.js";import{t as ce}from"./directory-breadcrumb-u3uCxukv.js";import{n as L,r as R,t as z}from"./data-table-CEq6a930.js";import{t as le}from"./pagination-Bragnnjj.js";import{a as ue,n as de,o as B,r as V,s as H,t as U}from"./dialog-CnxDxMp1.js";import{n as W,t as fe}from"./es-6YDPW35u.js";import{t as G}from"./textarea-Dyx6I5ZN.js";import{i as K,n as q,r as pe,t as me}from"./tabs-DopbVsQe.js";var he=te(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),J=M(w(),1);const ge=t=>{var n,r,i;let[a,o]=(0,J.useState)([]),[s,c]=(0,J.useState)(0),[l,u]=(0,J.useState)({pageIndex:0,pageSize:10}),d=e({queryKey:[`riskFileList`,l,s],queryFn:()=>ne({rootType:re.OUTSIDE,fileStatus:P.AUDITING,parentId:s||0,pageSize:l.pageSize,pageNo:l.pageIndex+1}).then(e=>e.data)}),f=e=>{c(e.id),m.setPageIndex(0),o(t=>[...t,e])},p=t(f),m=L({data:(d==null||(n=d.data)==null?void 0:n.entityList)||[],columns:p,getCoreRowModel:R(),manualPagination:!1,rowCount:(d==null||(r=d.data)==null?void 0:r.totalCount)||0,pageCount:(d==null||(i=d.data)==null?void 0:i.pageCount)||0,onPaginationChange:u,autoResetPageIndex:!1,state:{pagination:l}});return{parentId:s,handleChangeParentId:f,openDirectorys:a,changeOpenDirectorys:e=>{c(e==null?void 0:e.id),m.setPageIndex(0),o(t=>{let n=t.findIndex(t=>t.id===(e==null?void 0:e.id));return n>-1?[...t.slice(0,n+1)]:[]})},pagination:l,table:m,query:d}},_e=e=>{let{mutateAsync:t,isPending:n}=I({mutationFn:x,...e||{}});return{changeStatus:e=>{A.promise(t(e),{loading:`操作中`,success:`操作成功`})},changeStatusIsPending:n}};var Y=M(se(),1);function ve({open:e,setOpen:t,data:n,refetch:r}){let{changeStatus:i,changeStatusIsPending:a}=_e({onSuccess(){r==null||r(),t(!1)}});return(0,Y.jsx)(U,{open:e,onOpenChange:t,children:(0,Y.jsxs)(V,{className:`w-[400px]`,children:[(0,Y.jsxs)(B,{children:[(0,Y.jsxs)(H,{children:[`您确定要`,(n==null?void 0:n.newStatus)===P.VALID?`通过`:`驳回`,`?`]}),(0,Y.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-sm p-2 rounded-md bg-gray-50`,children:[(n==null?void 0:n.fileType)===D.FILE?(0,Y.jsx)(s,{size:16,className:`text-primary flex-none`}):(0,Y.jsx)(l,{size:16,className:`text-amber-500 flex-none`}),(0,Y.jsx)(`span`,{className:`break-all`,children:n==null?void 0:n.fileName})]})]}),(0,Y.jsxs)(ue,{children:[(0,Y.jsx)(de,{asChild:!0,children:(0,Y.jsx)(b,{variant:`outline`,children:`取消`})}),(0,Y.jsxs)(b,{type:`submit`,disabled:a,onClick:()=>{i({id:n==null?void 0:n.id,oldStatus:n==null?void 0:n.fileStatus,newStatus:n==null?void 0:n.newStatus})},children:[a&&(0,Y.jsx)(E,{}),`确定`]})]})]})})}let X=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`[n[e]&63];return t};function ye({onSubmit:e,loading:t}){let{mutateAsync:n,isPending:r}=I({mutationFn:e=>p(e).then(e=>{var t;return ie((t=e.data)==null?void 0:t.fileCode)}).then(e=>{var t;return((t=JSON.parse((e==null?void 0:e.data)||`{}`))==null||(t=t.risk_rules)==null?void 0:t.map(e=>({...e,content_examples:e.content_examples.join(),id:X(16)})))||[]}),onSuccess(t){e(t)}}),{getRootProps:i,get
|
|||
|
|
${o?`border-primary bg-primary/5`:`border-muted-foreground/25`}`,children:[(r||t)&&(0,Y.jsx)(`div`,{className:`absolute left-0 right-0 top-0 bottom-0 flex items-center justify-center backdrop-blur-xs bg-white/5 z-50`,children:(0,Y.jsx)(E,{className:`h-12 w-12 text-primary`})}),(0,Y.jsxs)(`div`,{...i(),className:`p-8 rounded-lg outline-none`,children:[(0,Y.jsx)(`input`,{...a({accept:`.docx,.txt,.md,.mdx,.markdown,.pdf,.html,.xlsx,.csv,.pptx,.xml,.epub,.mp3,.m4a,.wav,.amr,.mpga,.mp4,.mov,.mpeg,.webm,.jpg,.jpeg,.png,.gif,.svg`})}),(0,Y.jsx)(`div`,{className:`p-4 rounded-full bg-gray-50 inline-flex justify-center items-center`,children:(0,Y.jsx)(d,{className:`mx-auto h-6 w-6 text-muted-foreground`})}),(0,Y.jsx)(`p`,{className:`mt-2 text-lg`,children:o?`松开鼠标以选择文件`:`拖放文件到这里,或点击选择`}),(0,Y.jsx)(`p`,{className:`mt-2 text-sm text-black/50`,children:`文件最大不能超过5MB`})]})]})}var be=y({risk_category:f().max(32,{message:`风险类别名称最多32个字符`}).nonempty({message:`风险类别名称不能为空`}),content_examples:f().max(256,{message:`内容示例最多256个字符`}).nonempty({message:`内容示例不能为空`}),judgment_criteria:f().max(256,{message:`判断依据最多256个字符`}).nonempty({message:`判断依据不能为空`}),risk_level:f().max(16,{message:`风险等级最多16个字符`}).nonempty({message:`风险等级不能为空`})});function xe({onSubmit:e,loading:s,onClose:c}){let l=F({resolver:O(be),defaultValues:{risk_category:``,content_examples:``,judgment_criteria:``,risk_level:``}}),u=t=>{e([{...t,id:X(16)}])};return(0,Y.jsx)(h,{...l,children:(0,Y.jsxs)(`form`,{onSubmit:l.handleSubmit(u),className:`space-y-4`,children:[(0,Y.jsx)(T,{control:l.control,name:`risk_category`,render:({field:e})=>(0,Y.jsxs)(m,{children:[(0,Y.jsx)(g,{children:`风险类别名称`}),(0,Y.jsx)(S,{children:(0,Y.jsx)(C,{...e})}),(0,Y.jsx)(j,{})]})}),(0,Y.jsx)(T,{control:l.control,name:`risk_level`,render:({field:e})=>(0,Y.jsxs)(m,{children:[(0,Y.jsx)(g,{children:`风险类型`}),(0,Y.jsx)(S,{children:(0,Y.jsxs)(o,{onValueChange:e.onChange,value:e.value,children:[(0,Y.jsx)(t,{className:`w-full`,children:(0,Y.jsx)(i,{placeholder:`请选择`})}),(0,Y.jsx)(r,{children:(0,Y.jsxs)(a,{children:[(0,Y.jsx)(n,{value:`1`,children:`高风险`}),(0,Y.jsx)(n,{value:`2`,children:`中风险`}),(0,Y.jsx)(n,{value:`3`,children:`低风险`})]})})]})}),(0,Y.jsx)(j,{})]})}),(0,Y.jsx)(T,{control:l.control,name:`content_examples`,render:({field:e})=>(0,Y.jsxs)(m,{children:[(0,Y.jsx)(g,{children:`内容示例`}),(0,Y.jsx)(S,{children:(0,Y.jsx)(G,{...e,rows:6})}),(0,Y.jsx)(j,{})]})}),(0,Y.jsx)(T,{control:l.control,name:`judgment_criteria`,render:({field:e})=>(0,Y.jsxs)(m,{children:[(0,Y.jsx)(g,{children:`判断依据`}),(0,Y.jsx)(S,{children:(0,Y.jsx)(G,{...e,rows:6})}),(0,Y.jsx)(j,{})]})}),(0,Y.jsxs)(`div`,{className:`space-x-2 flex justify-end`,children:[(0,Y.jsx)(b,{type:`button`,variant:`outline`,onClick:c,children:`取消`}),(0,Y.jsxs)(b,{type:`submit`,disabled:s,children:[s&&(0,Y.jsx)(E,{}),`确定`]})]})]})})}const Z=e=>{let{mutateAsync:t,isPending:n}=I({mutationFn:v,...e||{}});return{save:e=>{A.promise(t(e),{loading:`提交中...`,success:`操作成功`})},saveIsPending:n}};function Q({open:e,setOpen:t,refetch:n,data:r}){let{save:i,saveIsPending:a}=Z({onSuccess(){n(),t(!1)}}),o=e=>{if(!(e!=null&&e.length)){A.error(`数据为空,不能保存`);return}i([...r||[],...e])};return(0,Y.jsx)(U,{open:e,onOpenChange:t,children:(0,Y.jsxs)(V,{className:`!max-w-[500px] overflow-auto`,children:[(0,Y.jsx)(B,{children:(0,Y.jsx)(H,{children:`风险预警设置`})}),(0,Y.jsxs)(me,{defaultValue:`form`,children:[(0,Y.jsxs)(pe,{className:`w-full mb-2`,children:[(0,Y.jsx)(K,{value:`ai`,disabled:a,children:`AI生成`}),(0,Y.jsx)(K,{value:`form`,disabled:a,children:`表单创建`})]}),(0,Y.jsx)(q,{value:`ai`,children:(0,Y.jsx)(ye,{onSubmit:o,loading:a,onClose:()=>t(!1)})}),(0,Y.jsx)(q,{value:`form`,children:(0,Y.jsx)(xe,{onSubmit:o,loading:a,onClose:()=>t(!1)})})]})]})})}const Se=e=>{let{mutateAsyn
|