UnisKB/static/chat/assets/index-eGk5XSHm.js

3 lines
18 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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