import{_ as L}from"./CNIrc0EA.js";import{_ as S,c as d,o as i,b as t,t as o,E as v,F as B,g as H,D as N,G as y,I as w,j as g,l as R,e as p,f as k,d as C,m as r,a as M}from"./Bgmy51Qv.js";import{A as U}from"./AmaTRG5a.js";import{u as I}from"./7pZkuj9N.js";const O={name:"HeaderLink",data(){return{result:{left:[],right:[]}}},props:{resultData:{type:Object,default(){return{left:[],right:[]}}},type:{type:String,default:"left"},title:{type:String}},computed:{},watch:{resultData(){this.assignResult()}},methods:{addNew(e="left"){this.result[e].push({title:"",url:""}),this.$emit("changed",this.result)},deleteItem(e,s="left"){this.result[s][e]={...this.result[s][e],deleted:!0},this.result={...this.result,[s]:this.result[s]},this.$emit("changed",this.result)},undoDelete(e,s="left"){this.result[s][e]={...this.result[s][e],deleted:!1},this.result={...this.result,[s]:this.result[s]},this.$emit("changed",this.result)},assignResult(){this.result=this.resultData}},mounted(){this.assignResult()}},q={class:"dply-felx"},A={class:"table-wrapper mb-20 mb-sm-15"},E={class:"mn-w-600x"},F={class:"lite-bold"},P=["disabled","placeholder","onUpdate:modelValue"],x=["disabled","placeholder","onUpdate:modelValue"],z={class:"undo-container"},G=["onClick"],T=["onClick"];function W(e,s,u,_,n,c){return i(),d("div",null,[t("div",q,[t("h4",null,o(u.title),1),t("button",{onClick:s[0]||(s[0]=v(l=>c.addNew(u.type),["prevent"])),class:"lite-btn"},o(e.$t("setting.addLink")),1)]),t("div",A,[t("table",E,[t("thead",null,[t("tr",F,[t("th",null,o(e.$t("index.title")),1),t("th",null,o(e.$t("admin.url")),1),s[1]||(s[1]=t("th",null,null,-1))])]),t("tbody",null,[(i(!0),d(B,null,H(n.result[u.type],(l,m)=>(i(),d("tr",{key:m,class:N(["deletable",{deleted:l.deleted}])},[t("td",null,[y(t("input",{disabled:l.deleted,type:"text",placeholder:e.$t("index.title"),name:"title","onUpdate:modelValue":h=>l.title=h},null,8,P),[[w,l.title]])]),t("td",null,[y(t("input",{disabled:l.deleted,type:"text",placeholder:e.$t("admin.url"),name:"title","onUpdate:modelValue":h=>l.url=h},null,8,x),[[w,l.url]])]),t("td",z,[l.deleted?(i(),d("button",{key:0,onClick:v(h=>c.undoDelete(m,u.type),["prevent"]),class:"lite-btn"},o(e.$t("fSale.undo")),9,G)):(i(),d("button",{key:1,onClick:v(h=>c.deleteItem(m,u.type),["prevent"]),class:"lite-btn delete-btn"},o(e.$t("category.delete")),9,T))])],2))),128))])])])])}const J=S(O,[["render",W]]),K={key:0,class:"tab-sidebar"},Q={class:"title"},X={ref:"formWrapper",class:""},Y={class:"form-wrapper"},Z={class:"info-msg mb-15 mb-sm-15"},tt={key:0,class:"spinner-wrapper"},et={key:3,class:"dply-felx j-right single-btn"},it={__name:"index",setup(e){const{getRequest:s,setRequest:u}=I(),_=g("header_link"),n=g(null),c=g(!1),l=g(!1),m=async()=>{c.value=!0;const a=await u({params:n.value,api:"setHeaderLink"});n.value=Object.assign({},a),c.value=!1},h=async()=>{l.value=!0;const a=await s({params:{},api:"getHeaderLinks"});n.value=Object.assign({},a),l.value=!1};return R(async()=>{await h()}),(a,f)=>{const D=L,j=M,$=J,V=U;return a.$can("header_link","view")?(i(),d("div",K,[t("h4",Q,o(a.$t("dataPage.head")),1),t("div",X,[t("div",Y,[k(D),t("p",Z,o(a.$t("setting.linkMsg")),1),r(l)?(i(),d("div",tt,[k(j,{radius:60,color:"primary",class:"mr-15"})])):p("",!0),r(n)?(i(),C($,{key:1,title:a.$t("util.left"),"result-data":r(n),onChanged:f[0]||(f[0]=b=>n.value=b)},null,8,["title","result-data"])):p("",!0),r(n)?(i(),C($,{key:2,title:a.$t("util.right"),type:"right","result-data":r(n),onChanged:f[1]||(f[1]=b=>n.value=b)},null,8,["title","result-data"])):p("",!0),!r(_)||a.$can(r(_),"edit")||a.$can(r(_),"create")?(i(),d("div",et,[k(V,{type:"button",class:"primary-btn","fetching-data":r(c),text:a.$t("setting.sv"),onClicked:m},null,8,["fetching-data","text"])])):p("",!0)])],512)])):p("",!0)}}};export{it as default};
