jm-expense-vue-ts/assets/Access.83adb1a9.js

2 lines
2.5 KiB
JavaScript
Raw Normal View History

2022-03-29 01:55:31 +00:00
var P=Object.defineProperty;var A=(i,o,n)=>o in i?P(i,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[o]=n;var a=(i,o,n)=>(A(i,typeof o!="symbol"?o+"":o,n),n);import{u as v}from"./index.e0544e65.js";import{S as D}from"./Spinner.5acc2245.js";import{f as F,u as I,x as d,o as s,c as l,l as E,t as h,h as e,F as p,P as f,k as N,p as w}from"./vendor.495b01ec.js";class R{constructor(){a(this,"id");a(this,"name");a(this,"name_en");a(this,"deletedAt");a(this,"createdAt");a(this,"updatedAt");a(this,"Permissions")}}const S={key:0},T={class:"d-flex my-3"},O={key:0,class:"table table-striped table-danger table-hover"},V={key:0,scope:"col"},L=e("th",{scope:"col"},"ID",-1),M=e("th",{scope:"col"},"ACTION",-1),$=e("th",{scope:"col"},"ITEM",-1),j=e("th",{scope:"col"},"DESCRIPTION",-1),q=["onClick"],z={key:0},G={class:"form-check"},H=["checked"],J=e("label",{class:"form-check-label",for:"flexCheckChecked"},null,-1),K={key:1,class:"img-fluid",src:"https://stickershop.line-scdn.net/stickershop/v1/sticker/208430466/iPhone/sticker_animation@2x.png",alt:"img"},Z=F({setup(i){const o=I(),n=d(!0),r=d(!1),m=d(new R),_=d([]),u=d([]),b=async function(){try{const{data:t}=await v.role.getOne(Number(o.params.id));m.value=t.data,n.value=!1}catch(t){console.error("error",t)}},y=async function(){try{const{data:t}=await v.permission.getAll();_.value=t.data,n.value=!1}catch(t){console.error("error",t)}},C=()=>{r.value=!0,u.value=m.value.Permissions.map(t=>t.id)},g=t=>{if(r.value)if(!u.value.includes(t))u.value.push(t);else{const k=u.value.findIndex(c=>c===t);u.value.splice(k,1)}},x=()=>{r.value=!1};return b(),y(),(t,k)=>n.value?(s(),w(D,{key:1})):(s(),l("div",S,[E(h(u.value)+" ",1),e("div",T,[r.value?(s(),l(p,{key:1},[e("button",{onClick:k[0]||(k[0]=c=>r.value=!1),class:"btn btn-secondary me-3"},"\u53D6\u6D88\u7DE8\u8F2F"),e("button",{onClick:x,class:"btn btn-warning"},"\u78BA\u5B9A\u7DE8\u8F2F")],64)):(s(),l("button",{key:0,onClick:C,class:"btn btn-primary"},"\u958B\u59CB\u7DE8\u8F2F"))]),_.value.length?(s(),l("table",O,[e("thead",null,[e("tr",null,[r.value?(s(),l("th",V,"#")):f("",!0),L,M,$,j])]),e("tbody",null,[(s(!0),l(p,null,N(_.value,(c,B)=>(s(),l("tr",{key:B,onClick:Q=>g(c.id)},[r.value?(s(),l("td",z,[e("div",G,[e("input",{class:"form-check-input",type:"checkbox",value:"",id:"flexCheckChecked",checked:u.value.includes(c.id)},null,8,H),J])])):f("",!0),e("td",null,h(c.id),1),e("td",null,h(c.action),1),e("td",null,h(c.item),1),e("td",null,h(c.description),1)],8,q))),128))])])):(s(),l("img",K))]))}});export{Z as default};