var J=Object.defineProperty;var B=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var N=(s,n,l)=>n in s?J(s,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[n]=l,U=(s,n)=>{for(var l in n||(n={}))K.call(n,l)&&N(s,l,n[l]);if(B)for(var l of B(n))Q.call(n,l)&&N(s,l,n[l]);return s};var f=(s,n,l)=>new Promise((h,_)=>{var D=i=>{try{v(l.next(i))}catch(u){_(u)}},x=i=>{try{v(l.throw(i))}catch(u){_(u)}},v=i=>i.done?h(i.value):Promise.resolve(i.value).then(D,x);v((l=l.apply(s,n)).next())});import{u as W,a as X,b as Y,_ as ee}from"./useCrudSchemas-BcUSI-wT.js";import{_ as ae}from"./Search.vue_vue_type_script_setup_true_lang-DVm5NdV8.js";import{_ as te}from"./Dialog.vue_vue_type_style_index_0_lang-DTUY8bxL.js";import{e as g,c as le}from"./index-OziN21LA.js";import{_ as oe}from"./Write.vue_vue_type_script_setup_true_lang-BffDnj95.js";import{s as ne}from"./upload-DsK3mgCJ.js";import{a as se,b as ie,m as re}from"./index-BQ7fd9kg.js";import{n as me}from"./element-plus-C2aeItNs.js";import{l as ce,r as c,Z as ue,U as r,F as j,u as a,m as $,p as de,O as d,q as pe,S,T as w,B as A,M as E,R as M,y as fe}from"./vue-chunks-l-AyUCfi.js";import"./tsxHelper-BLTo71S4.js";import"./tree-Dgaev6Pi.js";import"./useForm-DFfbRY9m.js";import"./wang-editor-D6T5hJzu.js";import"./useIcon-83DHkr7U.js";import"./useValidator-dY8qp_qX.js";const ge={class:"mb-10px"};function O(s){return typeof s=="function"||Object.prototype.toString.call(s)==="[object Object]"&&!fe(s)}const Le=ce({__name:"index",setup(s){const n=c([]),{tableRegister:l,tableState:h,tableMethods:_}=W({fetchDataApi:()=>f(this,null,function*(){const{currentPage:t,pageSize:e}=h,o=yield re(U({current:a(t),pageSize:a(e),type:1},a(I)));return{list:o.list,total:o.count}}),fetchDelApi:()=>f(this,null,function*(){})}),{loading:D,dataList:x,total:v,currentPage:i,pageSize:u}=h,{getList:y,getElTableExpose:F,delList:ve}=_,I=c({}),z=t=>{I.value=t,y()},{t:m}=le(),q=ue([{field:"selection",search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},table:{type:"selection"}},{field:"name",label:"素材名称",width:150,search:{component:"Input",componentProps:{placeholder:""}},form:{colProps:{span:8}},detail:{span:24}},{field:"tag",label:"素材标签",width:150,search:{component:"Input",componentProps:{placeholder:""}},component:"Input",colProps:{span:8},formatter:t=>r(me,{type:"primary"},{default:()=>[t.tag]})},{field:"content",label:"内容",search:{hidden:!0}},{field:"action",width:"260px",label:m("tableDemo.action"),search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},table:{slots:{default:t=>{let e,o;return r(j,null,[r(g,{type:"primary",onClick:()=>G(t.row,"edit")},O(e=m("exampleDemo.edit"))?e:{default:()=>[e]}),r(g,{type:"danger",onClick:()=>L(t.row)},O(o=m("exampleDemo.del"))?o:{default:()=>[o]})])}}}}]),{allSchemas:k}=X(q),p=c(!1),C=c(""),P=c(null),b=c(""),Z=()=>{C.value=m("exampleDemo.add"),P.value=null,p.value=!0,b.value=""},R=c(!1),L=t=>f(this,null,function*(){const e=yield F();n.value=t?[t.materialId]:(e==null?void 0:e.getSelectionRows().map(o=>o.materialId))||[],R.value=!0,yield se(a(n).join(",")).finally(()=>{R.value=!1,y()})}),G=(t,e)=>f(this,null,function*(){C.value=m(e==="edit"?"exampleDemo.edit":"exampleDemo.detail"),e=="edit"&&(yield ie(t.materialId),b.value=e,P.value=t,p.value=!0,y())}),T=c(),V=c(!1),H=()=>f(this,null,function*(){const t=a(T),e=yield t==null?void 0:t.submit();e&&(V.value=!0,(yield ne(e).catch(()=>{}).finally(()=>{V.value=!1}))&&(p.value=!1,i.value=1,y()))});return(t,e)=>($(),de(j,null,[r(a(ee),null,{default:d(()=>[r(a(ae),{schema:a(k).searchSchema,onSearch:z,onReset:z},null,8,["schema"]),pe("div",ge,[r(a(g),{type:"primary",onClick:Z},{default:d(()=>[S(w(a(m)("exampleDemo.add")),1)]),_:1}),r(a(g),{loading:R.value,type:"danger",onClick:e[0]||(e[0]=o=>L(null))},{default:d(()=>[S(w(a(m)("exampleDemo.del")),1)]),_:1},8,["loading"])]),r(a(Y),{pageSize:a(u),"onUpdate:pageSize":e[1]||(e[1]=o=>A(u)?u.value=o:null),currentPage:a(i),"onUpdate:currentPage":e[2]||(e[2]=o=>A(i)?i.value=o:null),columns:a(k).tableColumns,data:a(x),loading:a(D),pagination:{total:a(v)},"image-preview":["thumbUrl"],onRegister:a(l)},null,8,["pageSize","currentPage","columns","data","loading","pagination","onRegister"])]),_:1}),r(a(te),{modelValue:p.value,"onUpdate:modelValue":e[4]||(e[4]=o=>p.value=o),title:C.value},{footer:d(()=>[b.value!=="detail"?($(),E(a(g),{key:0,type:"primary",loading:V.value,onClick:H},{default:d(()=>[S(w(a(m)("exampleDemo.save")),1)]),_:1},8,["loading"])):M("",!0),r(a(g),{onClick:e[3]||(e[3]=o=>p.value=!1)},{default:d(()=>[S(w(a(m)("dialogDemo.close")),1)]),_:1})]),default:d(()=>[b.value!=="detail"?($(),E(oe,{key:0,ref_key:"writeRef",ref:T,"form-schema":a(k).formSchema,"current-row":P.value},null,8,["form-schema","current-row"])):M("",!0)]),_:1},8,["modelValue","title"])],64))}});export{Le as default};
