3 lines
18 KiB
JavaScript
3 lines
18 KiB
JavaScript
import{ay as de,b7 as me,b8 as F,aB as s,bd as he,aC as W,be as se,aD as o,aE as f,aF as w,aG as t,aH as l,aI as b,bb as ee,aK as S,aJ as _,bc as q,bo as Z,bs as ye,b$ as Se,bt as ke,bm as Y,bf as pe,bg as we,bh as $e,cf as Ve,ce as Ie,b9 as Pe,bn as L,c7 as Re,br as Te,cY as Me,c3 as Ce}from"./chat-u6cKkSMp.js";import{_ as xe}from"./ParagraphDialog.vue_vue_type_script_setup_true_lang-wzZm2z-c.js";import"./ParagraphForm.vue_vue_type_script_setup_true_lang-UeBom0mT.js";const ze={class:"dialog-footer"},qe=de({__name:"CreateProblemDialog",emits:["refresh"],setup(Q,{expose:E,emit:$}){const I=me(),{params:{id:h}}=I,y=F(()=>I.path.includes("shared")?"systemShare":I.path.includes("resource-management")?"systemManage":"workspace"),N=$,P=s(),k=s(!1),R=s({data:""}),C=he({data:[{required:!0,message:W("views.problem.tip.requiredMessage"),trigger:"blur"}]}),c=s(!1);se(c,n=>{n||(R.value={data:""})});const d=()=>{c.value=!0},V=async n=>{n&&await n.validate((u,v)=>{if(u){const x=R.value.data.split(`
|
||
`).filter(function(B){return B!==""});q({type:"problem",systemType:y.value}).postProblems(h,x,k).then(B=>{Z(W("common.createSuccess")),N("refresh"),c.value=!1})}})};return E({open:d}),(n,u)=>{const v=o("el-input"),x=o("el-form-item"),B=o("el-form"),D=o("el-button"),T=o("el-dialog");return f(),w(T,{title:n.$t("views.problem.createProblem"),modelValue:c.value,"onUpdate:modelValue":u[3]||(u[3]=H=>c.value=H),"close-on-click-modal":!1,"close-on-press-escape":!1,"destroy-on-close":!0},{footer:t(()=>[b("span",ze,[l(D,{onClick:u[1]||(u[1]=ee(H=>c.value=!1,["prevent"]))},{default:t(()=>[S(_(n.$t("common.cancel")),1)]),_:1}),l(D,{type:"primary",onClick:u[2]||(u[2]=H=>V(P.value)),loading:k.value},{default:t(()=>[S(_(n.$t("common.confirm")),1)]),_:1},8,["loading"])])]),default:t(()=>[l(B,{"label-position":"top",ref_key:"problemFormRef",ref:P,rules:C,model:R.value,"require-asterisk-position":"right"},{default:t(()=>[l(x,{label:n.$t("views.problem.title"),prop:"data"},{default:t(()=>[l(v,{modelValue:R.value.data,"onUpdate:modelValue":u[0]||(u[0]=H=>R.value.data=H),placeholder:n.$t("views.problem.tip.placeholder"),rows:10,type:"textarea"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["rules","model"])]),_:1},8,["title","modelValue"])}}}),Be={class:"bold title align-center p-24 pb-0"},Le={class:"p-8",style:{"padding-bottom":"8px"}},Ne={class:"flex lighter align-center"},Ue={class:"p-24",style:{"padding-bottom":"8px","padding-top":"16px"}},Ae={class:"flex-between mb-16"},Ee={class:"bold title align-center"},He={class:"dialog-footer"},je=de({__name:"RelateProblemDialog",emits:["refresh"],setup(Q,{expose:E,emit:$}){const I=me(),{params:{id:h}}=I,y=F(()=>I.path.includes("shared")?"systemShare":I.path.includes("resource-management")?"systemManage":"workspace"),N=$,P=s(!1),k=s(!1),R=s([]),C=s([]),c=s([]),d=s(""),V=s([]),n=s([]),u=s(""),v=s(""),x=s("title"),B=s(""),D=s(!1),T=he({current_page:1,page_size:50,total:0});function H(){const a={problem_id_list:V.value,paragraph_list:n.value.map(r=>({paragraph_id:r.id,document_id:r.document_id}))};q({type:"problem",systemType:y.value}).putMulAssociationProblem(h,a,k).then(()=>{Z(W("views.problem.tip.relatedSuccess")),P.value=!1})}function p(a){if(D.value)K(a.id)?n.value.splice(n.value.indexOf(a.id),1):n.value.push(a);else{const r={paragraph_id:a.id,problem_id:d.value};K(a.id)?q({type:"paragraph",systemType:y.value}).putDisassociationProblem(h,a.document_id,r,k).then(()=>{j(d.value)}):q({type:"paragraph",systemType:y.value}).putAssociationProblem(h,a.document_id,r,k).then(()=>{j(d.value)})}}function U(){T.current_page=1,c.value=[],u.value&&J(u.value)}function le(a){T.current_page=1,c.value=[],u.value=a.id,J(a.id)}function te(){q({type:"document",systemType:y.value}).getDocumentList(h,k).then(a=>{var r;C.value=a.data,R.value=a.data,u.value=((r=C.value)==null?void 0:r.length)>0?C.value[0].id:"",u.value&&J(u.value)})}function J(a){q({type:"paragraph",systemType:y.value}).getParagraphPage(h,a||u.value,T,v.value&&{[x.value]:v.value},k).then(r=>{c.value=[...c.value,...r.data.records],T.total=r.data.total})}function j(a){q({type:"problem",systemType:y.value}).getDetailProblems(h,a,k).then(r=>{n.value=r.data})}function X(a){return n.value.filter(r=>r.document_id===a).length}function K(a){return n.value.some(r=>r.id===a)}return se(P,a=>{a||(R.value=[],C.value=[],c.value=[],n.value=[],D.value=!1,u.value="",v.value="",x.value="title",N("refresh"))}),se(B,a=>{var r;c.value=[],R.value=a?C.value.filter(G=>G.name.includes(a)):C.value,u.value=((r=R.value)==null?void 0:r.length)>0?R.value[0].id:""}),E({open:a=>{te(),a.length==1?(d.value=a[0],j(a)):a.length>1&&(V.value=a,D.value=!0),P.value=!0}}),(a,r)=>{const G=o("el-input"),oe=o("auto-tooltip"),ne=o("el-badge"),M=o("common-list"),z=o("el-scrollbar"),ae=o("el-col"),e=o("el-text"),i=o("el-option"),A=o("el-select"),ve=o("el-empty"),O=o("CardBox"),_e=o("InfiniteScroll"),fe=o("el-row"),re=o("el-button"),ue=o("el-dialog"),ge=ye("loading");return f(),w(ue,{title:a.$t("views.problem.relateParagraph.title"),modelValue:P.value,"onUpdate:modelValue":r[5]||(r[5]=g=>P.value=g),width:"80%",class:"paragraph-dialog","destroy-on-close":"","close-on-click-modal":!1,"close-on-press-escape":!1},Se({default:t(()=>[ke((f(),w(fe,null,{default:t(()=>[l(ae,{span:6},{default:t(()=>[l(z,{height:"500","wrap-class":"paragraph-scrollbar"},{default:t(()=>[b("div",Be,_(a.$t("views.problem.relateParagraph.selectDocument")),1),b("div",Le,[l(G,{modelValue:B.value,"onUpdate:modelValue":r[0]||(r[0]=g=>B.value=g),placeholder:a.$t("views.problem.relateParagraph.placeholder"),"prefix-icon":"Search",clearable:""},null,8,["modelValue","placeholder"]),l(M,{data:R.value,class:"mt-8",onClick:le,"default-active":u.value},{default:t(({row:g})=>[b("span",Ne,[l(oe,{content:g.name},{default:t(()=>[S(_(g.name),1)]),_:2},1032,["content"]),X(g.id)?(f(),w(ne,{key:0,value:X(g.id),type:"primary",class:"paragraph-badge ml-4"},null,8,["value"])):Y("",!0)])]),_:1},8,["data","default-active"])])]),_:1})]),_:1}),l(ae,{span:18,class:"border-l"},{default:t(()=>[l(z,{height:"500","wrap-class":"paragraph-scrollbar"},{default:t(()=>[b("div",Ue,[b("div",Ae,[b("div",Ee,[S(_(a.$t("components.selectParagraph.title"))+" ",1),l(e,null,{default:t(()=>[S(" ("+_(a.$t("views.problem.relateParagraph.selectedParagraph"))+":"+_(X(u.value))+" "+_(a.$t("views.problem.relateParagraph.count"))+") ",1)]),_:1})]),l(G,{modelValue:v.value,"onUpdate:modelValue":r[2]||(r[2]=g=>v.value=g),placeholder:a.$t("common.search"),class:"input-with-select",style:{width:"260px"},onChange:U},{prepend:t(()=>[l(A,{modelValue:x.value,"onUpdate:modelValue":r[1]||(r[1]=g=>x.value=g),placeholder:"Select",style:{width:"80px"}},{default:t(()=>[l(i,{label:a.$t("common.title"),value:"title"},null,8,["label"]),l(i,{label:a.$t("common.content"),value:"content"},null,8,["label"])]),_:1},8,["modelValue"])]),_:1},8,["modelValue","placeholder"])]),c.value.length==0?(f(),w(ve,{key:0,description:a.$t("common.noData")},null,8,["description"])):(f(),w(_e,{key:1,size:c.value.length,total:T.total,page_size:T.page_size,current_page:T.current_page,"onUpdate:current_page":r[3]||(r[3]=g=>T.current_page=g),onLoad:J,loading:k.value},{default:t(()=>[(f(!0),pe(we,null,$e(c.value,(g,be)=>(f(),w(O,{key:be,shadow:"hover",title:g.title||"-",description:g.content,class:Ve(["paragraph-card cursor mb-16",K(g.id)?"selected":""]),showIcon:!1,onClick:m=>p(g)},null,8,["title","description","class","onClick"]))),128))]),_:1},8,["size","total","page_size","current_page","loading"]))])]),_:1})]),_:1})]),_:1})),[[ge,k.value]])]),_:2},[D.value?{name:"footer",fn:t(()=>[b("div",He,[l(re,{onClick:r[4]||(r[4]=g=>P.value=!1)},{default:t(()=>[S(_(a.$t("common.cancel")),1)]),_:1}),l(re,{type:"primary",onClick:H},{default:t(()=>[S(_(a.$t("common.confirm")),1)]),_:1})])]),key:"0"}:void 0]),1032,["title","modelValue"])}}}),De=Ie(je,[["__scopeId","data-v-a862ea99"]]),Fe={class:"p-8"},We={class:"footer-content flex-between"},Qe=de({__name:"DetailProblemDrawer",props:{currentId:{},currentContent:{},next:{},pre:{},pre_disable:{type:Boolean},next_disable:{type:Boolean}},emits:["update:currentId","update:currentContent","refresh"],setup(Q,{expose:E,emit:$}){const I=Q,h=$,y=me(),{params:{id:N}}=y,P=F(()=>y.path.includes("shared")?"systemShare":y.path.includes("resource-management")?"systemManage":"workspace"),k=F(()=>Pe.knowledge[P.value]),R=s(),C=s(),c=s(!1),d=s(!1),V=s([]);function n(p){const U={paragraph_id:p.id,problem_id:I.currentId};q({type:"paragraph",systemType:P.value}).putDisassociationProblem(p.knowledge_id,p.document_id,U,c).then(()=>{D()})}function u(){R.value.open([I.currentId])}function v(p){C.value.open(p,"edit")}function x(p){if(p){const U={content:p};q({type:"problem",systemType:P.value}).putProblems(N,I.currentId,U,c).then(()=>{h("update:currentContent",p),Z(W("common.modifySuccess"))})}else Re(W("views.problem.tip.errorMessage"))}function B(){V.value=[]}function D(){I.currentId&&d.value&&q({type:"problem",systemType:P.value}).getDetailProblems(N,I.currentId,c).then(p=>{V.value=p.data})}function T(){D()}return se(()=>I.currentId,()=>{V.value=[],D()}),se(d,p=>{p||(h("update:currentId",""),h("update:currentContent",""),h("refresh"))}),E({open:()=>{D(),d.value=!0}}),(p,U)=>{const le=o("ReadWrite"),te=o("el-form-item"),J=o("AppIcon"),j=o("el-button"),X=o("el-tooltip"),K=o("el-scrollbar"),ie=o("Document"),a=o("el-icon"),r=o("el-text"),G=o("CardBox"),oe=o("el-form"),ne=o("el-drawer"),M=ye("loading");return f(),w(ne,{modelValue:d.value,"onUpdate:modelValue":U[1]||(U[1]=z=>d.value=z),size:"60%",onClose:B},{header:t(()=>[b("h4",null,_(p.$t("views.problem.detailProblem")),1)]),footer:t(()=>[b("div",null,[k.value.doc_edit(L(N))?(f(),w(j,{key:0,onClick:u},{default:t(()=>[S(_(p.$t("views.problem.relateParagraph.title")),1)]),_:1})):Y("",!0),l(j,{onClick:Q.pre,disabled:Q.pre_disable||c.value},{default:t(()=>[S(_(p.$t("views.chatLog.buttons.prev")),1)]),_:1},8,["onClick","disabled"]),l(j,{onClick:Q.next,disabled:Q.next_disable||c.value},{default:t(()=>[S(_(p.$t("views.chatLog.buttons.next")),1)]),_:1},8,["onClick","disabled"])])]),default:t(()=>[b("div",null,[l(K,null,{default:t(()=>[b("div",Fe,[ke((f(),w(oe,{"label-position":"top",onSubmit:U[0]||(U[0]=ee(()=>{},["prevent"]))},{default:t(()=>[l(te,{label:p.$t("views.problem.title")},{default:t(()=>[l(le,{onChange:x,data:Q.currentContent,showEditIcon:k.value.problem_edit(L(N)),maxlength:256},null,8,["data","showEditIcon"])]),_:1},8,["label"]),l(te,{label:p.$t("views.problem.relateParagraph.title")},{default:t(()=>[(f(!0),pe(we,null,$e(V.value,(z,ae)=>(f(),w(G,{key:ae,title:z.title||"-",class:"cursor mb-8 w-full",showIcon:!1,onClick:ee(e=>k.value.doc_edit(L(N))&&v(z),["stop"]),style:{height:"210px"}},{tag:t(()=>[l(X,{effect:"dark",content:p.$t("views.problem.setting.cancelRelated"),placement:"top"},{default:t(()=>[k.value.problem_relate(L(N))?(f(),w(j,{key:0,type:"primary",text:"",onClick:ee(e=>n(z),["stop"])},{default:t(()=>[l(J,{iconName:"app-quxiaoguanlian"})]),_:1},8,["onClick"])):Y("",!0)]),_:2},1032,["content"])]),footer:t(()=>[b("div",We,[l(r,null,{default:t(()=>[l(a,null,{default:t(()=>[l(ie)]),_:1}),S(" "+_(z==null?void 0:z.document_name),1)]),_:2},1024)])]),default:t(()=>[l(K,{height:"110"},{default:t(()=>[S(_(z.content),1)]),_:2},1024)]),_:2},1032,["title","onClick"]))),128))]),_:1},8,["label"])]),_:1})),[[M,c.value]])])]),_:1}),l(xe,{ref_key:"ParagraphDialogRef",ref:C,title:p.$t("views.paragraph.editParagraph"),apiType:P.value,onRefresh:T},null,8,["title","apiType"]),l(De,{ref_key:"RelateProblemDialogRef",ref:R,onRefresh:T},null,512)])]),_:1},8,["modelValue"])}}}),Ge={class:"document p-16-24"},Je={class:"mb-16"},Ke={class:"main-calc-height"},Oe={class:"p-24"},Ye={class:"flex-between"},Xe={key:1},Ze={class:"mr-4"},lt=de({__name:"index",setup(Q){const E=me(),{params:{id:$,folderId:I}}=E,h=F(()=>E.path.includes("shared")?"systemShare":E.path.includes("resource-management")?"systemManage":E.path.includes("share/")?"workspaceShare":"workspace"),y=F(()=>Pe.knowledge[h.value]),N=F(()=>I==="share"),P=s(),k=s(),R=s(),C=s(!1),c=s(""),d=s(""),V=s(""),n=he({current_page:1,page_size:10,total:0,page_sizes:[10,20,50,100,1e3]}),u=s(""),v=s([]),x=F(()=>v.value.map((e,i)=>({[e.id]:i})).reduce((e,i)=>({...e,...i}),{})),B=s(),D=s([]);function T(e){const i=[];e?i.push(e.id):D.value.map(A=>{A&&i.push(A.id)}),P.value.open(i)}function H(){R.value.open()}const p=e=>{D.value=e};function U(e){C.value=!0;const i=[e];q({type:"problem",systemType:h.value}).postProblems($,i).then(()=>{M(),Z(W("common.createSuccess"))}).catch(()=>{C.value=!1})}function le(){const e=[];D.value.map(i=>{i&&e.push(i.id)}),q({type:"problem",systemType:h.value}).putMulProblem($,e,C).then(()=>{var i;Z(W("views.document.delete.successMessage")),(i=B.value)==null||i.clearSelection(),M()})}function te(e){q({type:"problem",systemType:h.value}).delProblems($,e.id,C).then(()=>{Z(W("common.deleteSuccess")),M()})}function J(e,i){if(e){const A={content:e};q({type:"problem",systemType:h.value}).putProblems($,i,A,C).then(()=>{M(),Z(W("common.modifySuccess"))})}else Re(W("views.problem.tip.errorMessage"))}function j(e){c.value=e.id}function X(){c.value=""}const K=()=>{let e=x.value[d.value]+1;if(e>=v.value.length){if(e+(n.current_page-1)*n.page_size>=n.total-1)return;n.current_page=n.current_page+1,M().then(()=>{e=0,d.value=v.value[e].id,V.value=v.value[e].content})}else d.value=v.value[e].id,V.value=v.value[e].content},ie=F(()=>x.value[d.value]-1<0&&n.current_page<=1),a=F(()=>{const e=x.value[d.value]+1;return e>=v.value.length&&e+(n.current_page-1)*n.page_size>=n.total-1}),r=()=>{let e=x.value[d.value]-1;if(e<0){if(n.current_page<=1)return;n.current_page=n.current_page-1,M().then(()=>{e=n.page_size-1,d.value=v.value[e].id,V.value=v.value[e].content})}else d.value=v.value[e].id,V.value=v.value[e].content};function G(e,i){i&&i.type==="selection"||E.path.includes("share/")||e.paragraph_count&&(d.value=e.id,V.value=e.content,k.value.open())}const oe=({row:e})=>d.value===(e==null?void 0:e.id)?"highlight":"";function ne(){n.current_page=1,M()}function M(){return q({type:"problem",isShared:N.value,systemType:h.value}).getProblemsPage($,n,u.value&&{content:u.value},C).then(e=>{v.value=e.data.records,n.total=e.data.total})}function z(){var e;M(),(e=B.value)==null||e.clearSelection()}function ae(){n.current_page=1,M()}return Te(()=>{M()}),Me(()=>{}),(e,i)=>{const A=o("el-button"),ve=o("el-input"),O=o("el-table-column"),_e=o("ReadWrite"),fe=o("el-link"),re=o("AppIcon"),ue=o("el-tooltip"),ge=o("app-table"),g=o("el-card"),be=ye("loading");return f(),pe("div",Ge,[b("h2",Je,_(e.$t("views.problem.title")),1),l(g,{style:{"--el-card-padding":"0"}},{default:t(()=>[b("div",Ke,[b("div",Oe,[b("div",Ye,[b("div",null,[y.value.problem_create(L($))?(f(),w(A,{key:0,type:"primary",onClick:H},{default:t(()=>[S(_(e.$t("views.problem.createProblem")),1)]),_:1})):Y("",!0),y.value.problem_relate(L($))?(f(),w(A,{key:1,onClick:i[0]||(i[0]=m=>T()),disabled:D.value.length===0},{default:t(()=>[S(_(e.$t("views.problem.relateParagraph.title")),1)]),_:1},8,["disabled"])):Y("",!0),y.value.problem_delete(L($))?(f(),w(A,{key:2,onClick:le,disabled:D.value.length===0},{default:t(()=>[S(_(e.$t("views.problem.setting.batchDelete")),1)]),_:1},8,["disabled"])):Y("",!0)]),l(ve,{modelValue:u.value,"onUpdate:modelValue":i[1]||(i[1]=m=>u.value=m),placeholder:e.$t("views.problem.searchBar.placeholder"),"prefix-icon":"Search",class:"w-240",onChange:M,clearable:""},null,8,["modelValue","placeholder"])]),ke((f(),w(ge,{ref_key:"multipleTableRef",ref:B,class:"mt-16",data:v.value,"pagination-config":n,"quick-create":y.value.problem_create(L($)),quickCreateName:e.$t("views.problem.quickCreateName"),quickCreatePlaceholder:e.$t("views.problem.quickCreateProblem"),quickCreateMaxlength:256,onSizeChange:ne,onChangePage:M,onCellMouseEnter:j,onCellMouseLeave:X,onCreatQuick:U,onRowClick:G,onSelectionChange:p,"row-class-name":oe,"row-key":m=>m.id},{default:t(()=>[l(O,{type:"selection",width:"55","reserve-selection":!0}),l(O,{prop:"content",label:e.$t("views.problem.title"),"min-width":"280"},{default:t(({row:m})=>[l(_e,{onChange:ce=>J(ce,m.id),data:m.content,showEditIcon:y.value.problem_edit(L($))&&m.id===c.value,maxlength:256},null,8,["onChange","data","showEditIcon"])]),_:1},8,["label"]),l(O,{prop:"paragraph_count",label:e.$t("views.problem.table.paragraph_count"),align:"right","min-width":"100"},{default:t(({row:m})=>[m.paragraph_count?(f(),w(fe,{key:0,type:"primary",onClick:ee(ce=>G(m),["stop"])},{default:t(()=>[S(_(m.paragraph_count),1)]),_:2},1032,["onClick"])):(f(),pe("span",Xe,_(m.paragraph_count),1))]),_:1},8,["label"]),l(O,{prop:"create_time",label:e.$t("common.createTime"),width:"170"},{default:t(({row:m})=>[S(_(L(Ce)(m.create_time)),1)]),_:1},8,["label"]),l(O,{prop:"update_time",label:e.$t("views.problem.table.updateTime"),width:"170"},{default:t(({row:m})=>[S(_(L(Ce)(m.update_time)),1)]),_:1},8,["label"]),l(O,{label:e.$t("common.operation"),align:"left",fixed:"right"},{default:t(({row:m})=>[b("div",null,[b("span",Ze,[l(ue,{effect:"dark",content:e.$t("views.problem.relateParagraph.title"),placement:"top"},{default:t(()=>[y.value.problem_relate(L($))?(f(),w(A,{key:0,type:"primary",text:"",onClick:ee(ce=>T(m),["stop"])},{default:t(()=>[l(re,{iconName:"app-generate-question"})]),_:1},8,["onClick"])):Y("",!0)]),_:2},1032,["content"])]),b("span",null,[l(ue,{effect:"dark",content:e.$t("common.delete"),placement:"top"},{default:t(()=>[y.value.problem_delete(L($))?(f(),w(A,{key:0,type:"primary",text:"",onClick:ee(ce=>te(m),["stop"])},{default:t(()=>[l(re,{iconName:"app-delete"})]),_:1},8,["onClick"])):Y("",!0)]),_:2},1032,["content"])])])]),_:1},8,["label"])]),_:1},8,["data","pagination-config","quick-create","quickCreateName","quickCreatePlaceholder","row-key"])),[[be,C.value]])])])]),_:1}),l(qe,{ref_key:"CreateProblemDialogRef",ref:R,onRefresh:ae},null,512),l(Qe,{next:K,pre:r,ref_key:"DetailProblemRef",ref:k,currentId:d.value,"onUpdate:currentId":i[2]||(i[2]=m=>d.value=m),currentContent:V.value,"onUpdate:currentContent":i[3]||(i[3]=m=>V.value=m),pre_disable:ie.value,next_disable:a.value,onRefresh:z},null,8,["currentId","currentContent","pre_disable","next_disable"]),l(De,{ref_key:"RelateProblemDialogRef",ref:P,onRefresh:z},null,512)])}}});export{lt as default};
|