import{_ as g,i as f,z as k,A as v,f as d,k as C,d as l,e as i,g as s,l as _,t as a,p as I,q as U,j as u,F as S,h as N,n as w}from"./app-ad835f92.js";import{a as m}from"./swal-23a4a8dd.js";const T={data(){return{baseUrl:"/sets/sm",hotbeeUrl:"/sets/sm/efw",polibeeUrl:"/sets/sm/si",chembeeUrl:"/sets/sm/csm",hotbeeSystemCode:"SM-EFW",polibeeSystemCode:"SM-SI",chembeeSystemCode:"SM-CSM",id:this.$route.params.id??null,subSystemId:this.$route.params.subSystemId??null,subSystem:["","安全智慧巡檢功能","電氣火災預警功能","化學品智慧安全管理功能"],isAdmin:f(),isParent:k(),isSub:v(),users:[],parentName:"",subName:"",dataTable:null,systemToken:[]}},mounted(){const t=this;t.fetchData(),$("input[type='search']").on("keyup input",function(){t.dataTable.search(this.value).draw()})},methods:{fetchData:async function(){const t=this;await d.get(`/api/getUserSubHasSystemRole/${this.subSystemId}/u/${this.id}`).then(e=>{t.users=e.data.data,t.subName=e.data.subName,t.parentName=e.data.parentName}).catch(m),t.dataTable=$("#table").DataTable()},gotoSubSystem:async function(t){const e=this,h={1:e.polibeeSystemCode,2:e.hotbeeSystemCode,3:e.chembeeSystemCode},p={1:e.polibeeUrl,2:e.hotbeeUrl,3:e.chembeeUrl},o={1:n=>`${e.polibeeUrl}/login/${n}`,2:n=>`${e.hotbeeUrl}/thermal-web/login/${n}`,3:n=>`${e.chembeeUrl}/login/${n}`};if(!p[e.subSystemId]){m("找不到對應的子系統 URL");return}try{const n={userId:t,system:h[e.subSystemId]};await d.post("/api/sso/ida/addLoginLog",n);const r=await d.get(`/api/getJwtTokenByUserId/${t}`);e.systemToken=r.data.data;const b=e.systemToken[e.subSystemId];if(!b){m("找不到子系統 Token");return}const y=o[e.subSystemId](b);window.location.href=y}catch(n){console.error("gotoSubSystem error:",n),m("登入子系統失敗，請稍後再試")}}}},A={class:"main-view px-4 pt-2"},M={class:"d-flex align-items-center mb-3"},P={style:{"--bs-breadcrumb-divider":"'>'"},"aria-label":"breadcrumb"},x={class:"breadcrumb m-0"},B={class:"breadcrumb-item"},D={href:"#"},F={key:0,class:"breadcrumb-item"},L={key:1,class:"breadcrumb-item"},V={class:"breadcrumb-item active","aria-current":"page"},j={class:"mb-5"},z={key:0,class:"text-end"},E={class:"table table-hover",id:"table"},R={class:"text-center"},q={class:"text-center"},H={class:"col-1 text-center"},J={class:"col-2"},W={class:"col-3"},G={class:"col-2 text-center"},K=["onClick"];function O(t,e,h,p,o,c){const n=C("router-link");return l(),i(S,null,[s("div",A,[s("div",M,[s("button",{class:"btn-goback me-2",onClick:e[0]||(e[0]=r=>t.$router.back())},[e[3]||(e[3]=s("i",{class:"bi bi-chevron-left me-1"},null,-1)),_(a(t.$t("global.go_back")),1)]),s("nav",P,[s("ol",x,[s("li",B,[s("a",D,a(t.$t("global.homepage")),1)]),o.isAdmin?(l(),i("li",F,[I(n,{to:"/userSubSystem/parentSubSystemIndex/1"},{default:U(()=>[_(a(o.parentName),1)]),_:1})])):u("",!0),(o.isAdmin||o.isParent)&&o.parentName!=o.subName?(l(),i("li",L,[s("a",{href:"javascript:;",onClick:e[1]||(e[1]=r=>t.$router.back())},a(o.subName),1)])):u("",!0),s("li",V,"【"+a(o.subSystem[o.subSystemId])+"】"+a(t.$t("backend.userSubSystem.sub_user_list")),1)])])]),s("h1",j,"【"+a(o.subSystem[o.subSystemId])+"】"+a(t.$t("backend.userSubSystem.sub_user_list")),1),o.isSub||o.isParent?(l(),i("div",z,[s("button",{class:"btn btn-primary mb-2",onClick:e[2]||(e[2]=r=>c.gotoSubSystem(o.id))},a(t.$t("global.navigate_to")),1)])):u("",!0)]),s("div",{class:w(["p-4",{"admin-bg-color":o.isAdmin,"user-bg-color":!o.isAdmin}])},[e[4]||(e[4]=s("div",{class:"input-group w-50 mb-3"},[s("input",{type:"search",class:"form-control border border-2 border-end-0 inside-border-color",placeholder:"Search..."}),s("button",{class:"btn btn-light border border-2 border-start-0 inside-border-color",type:"button"},[s("i",{class:"bi bi-search"})])],-1)),s("table",E,[s("thead",null,[s("tr",null,[s("th",R,a(t.$t("global.serial_number")),1),s("th",null,a(t.$t("global.name")),1),s("th",null,a(t.$t("global.email")),1),s("th",q,a(t.$t("global.operation")),1)])]),s("tbody",null,[(l(!0),i(S,null,N(o.users,(r,b)=>(l(),i("tr",{key:r.id},[s("td",H,a(b+1),1),s("td",J,a(r.name),1),s("td",W,a(r.email),1),s("td",G,[s("button",{class:"btn btn-success mx-1",onClick:y=>c.gotoSubSystem(r.id)},a(t.$t("global.navigate_to")),9,K)])]))),128))])])],2)],64)}const Y=g(T,[["render",O],["__scopeId","data-v-8f7f4b98"]]);export{Y as default};
