import{D as y,g as v}from"./DataFormDialog.329d7748.js";import{_ as D}from"./index.9e59753f.js";import{ah as a,o as k,c as C,V as e,P as n,a as p,U as u,ar as V,a9 as R,Q as z,T as E}from"./vendor-vue.cefe3aef.js";import"./element-plus.af689926.js";import"./element-icon.1fe9d2a8.js";import"./vendor-lib.a8c0b8df.js";const O={name:"",components:{DataFormDialog:y},props:{list:{type:Array}},computed:{},data(){return{currentRow:null,dialogVisible:!1}},methods:{handleEditRow(s){this.currentRow=s,this.dialogVisible=!0},async handleDeleteClick(s){let t={host_id:s.id};const i=await this.$http.deleteHostById(t);i.code==0?(this.$msg.success("\u64CD\u4F5C\u6210\u529F"),this.$emit("on-success")):this.$msg.error(i.msg)},async handleStatusChange(s){let t={id:s.id};const i=await this.$http.function(t);i.code==0?(this.$msg.success("\u64CD\u4F5C\u6210\u529F"),this.$emit("on-success")):this.$msg.error(i.msg)},handleUpdateSuccess(){this.$emit("on-success")}},created(){}};function U(s,t,i,S,o,r){const c=a("el-table-column"),h=a("Edit"),_=a("el-icon"),m=a("el-link"),g=a("Delete"),f=a("el-popconfirm"),b=a("el-table"),w=a("DataFormDialog");return k(),C("div",null,[e(b,{data:i.list,stripe:"",border:""},{default:n(()=>[e(c,{label:"\u4E3B\u673A\u5730\u5740","header-align":"center",align:"center",prop:"host"},{default:n(l=>[p("span",null,u(l.row.host||"-"),1)]),_:1}),e(c,{label:"\u7AEF\u53E3\u53F7","header-align":"center",align:"center",width:"90",prop:"port"},{default:n(l=>[p("span",null,u(l.row.port||"-"),1)]),_:1}),e(c,{label:"\u767B\u5F55\u7528\u6237","header-align":"center",align:"center",prop:"user"},{default:n(l=>[p("span",null,u(l.row.user||"-"),1)]),_:1}),e(c,{label:"\u9A8C\u8BC1\u65B9\u5F0F","header-align":"center",align:"center",width:"80",prop:"auth_type"},{default:n(l=>[p("span",null,u(l.row.auth_type_label||"-"),1)]),_:1}),e(c,{label:"\u521B\u5EFA\u65F6\u95F4","header-align":"center",align:"center",width:"180",prop:"create_time"},{default:n(l=>[p("span",null,u(l.row.create_time||"-"),1)]),_:1}),e(c,{label:"\u7F16\u8F91",width:"60","header-align":"center",align:"center"},{default:n(l=>[e(m,{underline:!1,type:"primary",onClick:d=>r.handleEditRow(l.row)},{default:n(()=>[e(_,null,{default:n(()=>[e(h)]),_:1})]),_:2},1032,["onClick"])]),_:1}),e(c,{label:"\u5220\u9664",width:"60",align:"center",prop:"tag"},{default:n(l=>[e(f,{title:`${s.$t("\u786E\u5B9A\u5220\u9664")}\uFF1F`,onConfirm:d=>r.handleDeleteClick(l.row)},{reference:n(()=>[e(m,{underline:!1,type:"danger"},{default:n(()=>[e(_,null,{default:n(()=>[e(g)]),_:1})]),_:1})]),_:2},1032,["title","onConfirm"])]),_:1})]),_:1},8,["data"]),e(w,{visible:o.dialogVisible,"onUpdate:visible":t[0]||(t[0]=l=>o.dialogVisible=l),row:o.currentRow,onOnSuccess:r.handleUpdateSuccess},null,8,["visible","row","onOnSuccess"])])}const x=D(O,[["render",U]]),A={name:"host-list",props:{},components:{DataFormDialog:y,DataTable:x},data(){return{list:[],total:0,page:1,size:20,keyword:"",loading:!0,dialogVisible:!1}},computed:{},methods:{resetData(){this.page=1,this.getData()},async getData(){this.loading=!0;let s={page:this.page,size:this.size,keyword:this.keyword};const t=await this.$http.getHostList(s);t.ok&&(this.total=t.data.total,this.list=t.data.list.map(i=>(i.auth_type_label=v(i.auth_type),i))),this.loading=!1},handleAddRow(){this.dialogVisible=!0},handleAddSuccess(){this.resetData()},handleSearch(){this.resetData()}},created(){this.getData()}},T={class:"app-container"},F={class:"flex justify-between margin-bottom--20"};function B(s,t,i,S,o,r){const c=a("Plus"),h=a("el-icon"),_=a("el-button"),m=a("Search"),g=a("el-input"),f=a("DataTable"),b=a("el-pagination"),w=a("DataFormDialog"),l=V("loading");return k(),C("div",T,[p("div",F,[e(_,{type:"primary",onClick:r.handleAddRow},{default:n(()=>[e(h,null,{default:n(()=>[e(c)]),_:1}),E(u(s.$t("\u6DFB\u52A0")),1)]),_:1},8,["onClick"]),e(g,{class:"ml-sm",style:{width:"260px"},modelValue:o.keyword,"onUpdate:modelValue":t[0]||(t[0]=d=>o.keyword=d),placeholder:"\u8F93\u5165\u4E3B\u673A\u5730\u5740",clearable:"",onKeypress:R(r.handleSearch,["enter"]),onClear:r.handleSearch},{append:n(()=>[e(_,{onClick:r.handleSearch},{default:n(()=>[e(h,null,{default:n(()=>[e(m)]),_:1})]),_:1},8,["onClick"])]),_:1},8,["modelValue","onKeypress","onClear"])]),z(e(f,{class:"mt-md",list:o.list,onOnSuccess:r.resetData,onOnEditRow:s.handleEditRow},null,8,["list","onOnSuccess","onOnEditRow"]),[[l,o.loading]]),e(b,{class:"mt-md justify-center",background:"",layout:"total, prev, pager, next",total:o.total,"page-size":o.size,"onUpdate:pageSize":t[1]||(t[1]=d=>o.size=d),"current-page":o.page,"onUpdate:currentPage":t[2]||(t[2]=d=>o.page=d),onCurrentChange:r.getData},null,8,["total","page-size","current-page","onCurrentChange"]),e(w,{visible:o.dialogVisible,"onUpdate:visible":t[3]||(t[3]=d=>o.dialogVisible=d),onOnSuccess:r.handleAddSuccess},null,8,["visible","onOnSuccess"])])}const I=D(A,[["render",B]]);export{I as default};
