UnisKB/static/admin/chat/assets/index-CdoSOmL5.js

2 lines
8.8 KiB
JavaScript
Raw Normal View History

import{ay as Ee,b8 as we,aB as v,bW as M,b9 as oe,b7 as A,bd as G,br as ke,be as ne,bf as K,aI as o,aH as s,aJ as h,bn as I,c0 as Ae,aG as u,aD as i,bc as R,bZ as Oe,bY as W,b_ as H,bt as re,bs as Ue,aE as O,bm as F,aK as z,aC as ie,aF as b,bo as Le,ce as Te}from"./chat-GejDyFYU.js";const De={class:"group p-16-24"},Se={class:"mb-16"},Ie={class:"color-secondary"},Re={class:"flex"},Pe={class:"user-left border-r"},Ve={class:"p-24 pb-0"},$e={class:"medium mb-12"},Ne={class:"list-height-left"},Me={class:"p-16"},Ge=["title"],Ke={class:"user-right"},We={class:"flex-between"},He={class:"flex align-center"},Fe=["title"],ze={class:"color-input-placeholder ml-4"},Be={key:0,class:"flex align-center"},je={class:"color-secondary mr-8"},xe={class:"flex-between mb-16",style:{"margin-top":"18px"}},Je={class:"flex complex-search"},Ye=Ee({__name:"index",setup(Ze){const r=we(),{params:{id:B,folderId:ue}}=r,j=v({APPLICATION:oe.application.workspace.application_chat_user_edit(B),KNOWLEDGE:oe.knowledge.workspace.chat_user_edit(B),RESOURCE_APPLICATION:M([W.ADMIN,H.RESOURCE_APPLICATION_CHAT_USER_EDIT],"OR"),RESOURCE_KNOWLEDGE:M([W.ADMIN,H.RESOURCE_KNOWLEDGE_CHAT_USER_EDIT],"OR"),SHAREDKNOWLEDGE:M(new Oe([W.ADMIN],[H.SHARED_KNOWLEDGE_CHAT_USER_EDIT],[],"OR"),"OR")}),x=A(()=>{var e,a,n;if(r.path.includes("resource-management")){if(((e=r.meta)==null?void 0:e.resourceType)==="KNOWLEDGE")return"RESOURCE_KNOWLEDGE";if(((a=r.meta)==null?void 0:a.resourceType)==="APPLICATION")return"RESOURCE_APPLICATION"}else{if(r.path.includes("shared"))return"SHAREDKNOWLEDGE";if(r.path.includes("knowledge/"))return"KNOWLEDGE";if(r.path.includes("application/"))return"APPLICATION"}return(n=r.meta)==null?void 0:n.resourceType}),w=G({resource_id:r.params.id,resource_type:r.meta.resourceType}),U=v(""),L=v(!1),T=v([]),P=v([]),t=v(),D=A(()=>r.path.includes("shared")?"systemShare":r.path.includes("resource-management")?"systemManage":"workspace");async function J(){try{const e=await R({type:"chatUser",isShared:Z.value,systemType:D.value}).getUserGroupList(w,L);T.value=e.data,P.value=Y(T.value,U.value)}catch(e){console.error(e)}}ke(async()=>{await J(),t.value=T.value[0]});function Y(e,a){return a.length?e.filter(n=>n.name.toLowerCase().includes(a.toLowerCase())):e}ne(U,e=>{P.value=Y(T.value,e)});const d=G({});function ce(e){for(const a in d)delete d[a];t.value=e}async function de(){var a,n,_,p,m;const e=[{user_group_id:(a=t.value)==null?void 0:a.id,is_auth:!((n=t.value)!=null&&n.is_auth)}];try{await R({type:"chatUser",systemType:D.value}).editUserGroupList(w,e,L),await J(),t.value={name:(_=t.value)==null?void 0:_.name,id:(p=t.value)==null?void 0:p.id,is_auth:!((m=t.value)!=null&&m.is_auth)},y()}catch($){console.error($)}}const V=v(!1),g=v("username"),f=v({username:"",nick_name:"",source:""}),C=G({current_page:1,page_size:20,total:0}),E=v([]),Z=A(()=>ue==="share");async function y(){var n,_;if(!((n=t.value)!=null&&n.id))return;const e={},a=f.value[g.value];a!=null&&a!==""&&(e[g.value]=a);try{const p=await R({type:"chatUser",isShared:Z.value,systemType:D.value}).getUserGroupUserList(w,(_=t.value)==null?void 0:_.id,C,e,V);p.data.records.forEach(m=>{d[m.id]===void 0&&(d[m.id]=m.is_auth),m.is_auth=d[m.id]}),E.value=p.data.records,C.total=p.data.total}catch(p){console.error(p)}}function pe(){C.current_page=1,y()}ne(()=>{var e;return(e=t.value)==null?void 0:e.id},()=>{C.current_page=1,y()});const q=A(()=>E.value.length>0&&E.value.every(e=>d[e.id])),me=A(()=>!q.value&&E.value.some(e=>d[e.id])),ve=e=>{E.value.forEach(a=>{a.is_auth=e,d[a.id]=e})},he=(e,a)=>{a.is_auth=e,d[a.id]=e};async function _e(){var e;try{const a=Object.entries(d).map(([n,_])=>({chat_user_id:n,is_auth:_}));await R({type:"chatUser",systemType:D.value}).putUserGroupUser(w,(e=t.value)==null?void 0:e.id,a,V),Le(ie("common.saveSuccess"))}catch(a){console.error(a)}}return(e,a)=>{const n=i("el-input"),_=i("common-list"),p=i("el-scrollbar"),m=i("el-divider"),$=i("UserFilled"),be=i("el-icon"),ge=i("el-switch"),c=i("el-option"),Q=i("el-select"),fe=i("el-button"),S=i("el-table-column"),X=i("el-checkbox"),ye=i("app-table"),Ce