import{g as C}from"./asset.js";import{u as J,r as b,b as f,d as Y,o as m,k as q,w as i,f as s,g as v,t as d,h as H,e as h,i as p,J as Q,z as W,j as A,A as w,n as y}from"./index.js";import{g as X}from"./common.js";import{U as Z,D as ee}from"./constants.js";import{_ as te}from"./_plugin-vue_export-helper.js";const oe=["element-loading-text","element-loading-background"],le={style:{display:"flex","align-items":"center"}},ne=["src"],re=["src","onerror"],ie={style:{"margin-left":"10px"}},se={key:0},ae={key:1},ue={__name:"ChooseFileModal",props:{checkFileExist:{type:Boolean,default:!0}},emits:["choose"],setup(E,{expose:O,emit:V}){const B=E,{t:I}=J({useScope:"global"}),x=V,u=b("/");let l="/";const k=b([]),_=b(!0),c=b(!1);function g(e){_.value=!0,w.post("service_get_file_list.html",`dir=${encodeURIComponent(e)}`).then(({data:{code:t,data:o,error:n}})=>{t==0&&(k.value=[],o.dirs.forEach(a=>{k.value.push({name:a.name,ext:X(a.name),isdir:a.isdir})}),u.value=o.nowdir,l=o.nowdir),t==-1&&(y({message:n,grouping:!0,type:"error"}),w.logout())}).catch(t=>{y({message:t.message,grouping:!0,type:"error"})}).finally(()=>{_.value=!1})}function L(){return'this.src ="'+C("images/icons/default.gif")+'"'}function U(e,t,o,n){if(e.isdir){let a=l==="/"?e.name:l+"/"+e.name;g(a)}else $()}function R(e){if(e)if(e.isdir){let t=l==="/"?e.name:l+"/"+e.name;g(t)}else u.value=l==="/"?e.name:l+"/"+e.name}function D(e,t){if(e.isdir&&!t.isdir)return-1;if(!e.isdir&&t.isdir)return 1;{let o=e.name.toLowerCase(),n=t.name.toLowerCase();return o<n?-1:o>n?1:0}}function N(e,t){if(e.isdir&&!t.isdir)return-1;if(!e.isdir&&t.isdir)return 1;if(e.isdir&&t.isdir)return D(e,t);{let o=e.ext.toLowerCase(),n=t.ext.toLowerCase();return o<n?-1:o>n?1:0}}function F(){var e=l.substring(0,l.lastIndexOf("/"));e.lastIndexOf("/")===-1&&(e="/"),g(e)}function M(){g(l)}function $(){if(B.checkFileExist===!1){x("choose",u.value),c.value=!1;return}_.value=!0,w.post("service_check_file.html","file="+encodeURIComponent(u.value)).then(({data:{code:e,error:t}})=>{e==0?(x("choose",u.value),c.value=!1):e==-1?(y({message:t,grouping:!0,type:"error"}),w.logout()):y({message:I("error_invalid_file"),grouping:!0,type:"error"})}).catch(e=>{y({message:e.message,grouping:!0,type:"error"})}).finally(()=>{_.value=!1})}function P(){c.value=!1}function S(){g()}function G(){c.value=!0}return O({show:G}),(e,t)=>{const o=f("el-button"),n=f("el-row"),a=f("el-table-column"),K=f("el-table"),T=f("el-input"),j=f("el-dialog"),z=Y("loading");return m(),q(j,{title:e.$t("str_choosefile"),draggable:"","align-center":"","destroy-on-close":"",modelValue:c.value,"onUpdate:modelValue":t[1]||(t[1]=r=>c.value=r),class:"general_dialog","open-delay":p(ee),onOpen:S},{footer:i(()=>[s(o,{type:"primary",class:"w-100px",onClick:$},{default:i(()=>[v(d(e.$t("button_submit")),1)]),_:1}),s(o,{type:"primary",class:"w-100px",onClick:P},{default:i(()=>[v(d(e.$t("button_cancel")),1)]),_:1})]),default:i(()=>[H((m(),h("div",{"element-loading-text":e.$t("title_updating"),"element-loading-background":p(Z)},[s(n,null,{default:i(()=>[s(o,{type:"button",class:"btn btn-primary mb-10",icon:p(Q),onClick:F},{default:i(()=>[v(d(e.$t("title_goup")),1)]),_:1},8,["icon"]),s(o,{type:"button",class:"btn btn-primary",icon:p(W),onClick:M},{default:i(()=>[v(d(e.$t("title_refresh")),1)]),_:1},8,["icon"])]),_:1}),s(K,{data:k.value,border:"","default-sort":{prop:"ext",order:"ascending"},class:"dir_table mb-10","highlight-current-row":"",onRowClick:R,onRowDblclick:U},{default:i(()=>[s(a,{label:e.$t("title_name"),prop:"name",sortable:"","sort-orders":["ascending","descending"],"sort-method":D,"min-width":70},{default:i(r=>[A("div",le,[r.row.isdir?(m(),h("img",{key:0,src:p(C)("images/folder.png")},null,8,ne)):(m(),h("img",{key:1,src:p(C)(`images/icons/${r.row.ext}.gif`),onerror:L()},null,8,re)),A("span",ie,d(r.row.name),1)])]),_:1},8,["label"]),s(a,{label:e.$t("title_type"),prop:"ext",sortable:"","sort-orders":["ascending","descending"],"sort-method":N,"min-width":30},{default:i(r=>[r.row.isdir?(m(),h("span",se,d(e.$t("title_directory")),1)):(m(),h("span",ae,d(r.row.ext+e.$t("title_filetype")),1))]),_:1},8,["label"])]),_:1},8,["data"]),s(T,{modelValue:u.value,"onUpdate:modelValue":t[0]||(t[0]=r=>u.value=r),type:"text",placeholder:""},null,8,["modelValue"])],8,oe)),[[z,_.value]])]),_:1},8,["title","modelValue","open-delay"])}}},_e=te(ue,[["__scopeId","data-v-bbe43611"]]);export{_e as C};
