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,y)=>{var D=r=>{try{v(l.next(r))}catch(u){y(u)}},x=r=>{try{v(l.throw(r))}catch(u){y(u)}},v=r=>r.done?h(r.value):Promise.resolve(r.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-f5-cIgli.js";import{_ as ae}from"./Search.vue_vue_type_script_setup_true_lang-B4LnkeCr.js";import{_ as te}from"./Dialog.vue_vue_type_style_index_0_lang-Crgw5i7b.js";import{e as g,c as le}from"./index-D4Ne4xf-.js";import{_ as oe}from"./Write.vue_vue_type_script_setup_true_lang-DCV_QK2r.js";import{s as ne}from"./upload-Dh64kBvI.js";import{a as se,b as re,m as ie}from"./index-CfVYloEX.js";import{n as me}from"./element-plus-DNKe9-lk.js";import{l as ce,r as c,Z as ue,U as i,F as j,u as e,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-DyZSmvoe.js";import"./tsxHelper-DOqx_mcA.js";import"./tree-Dgaev6Pi.js";import"./useForm-kq1sxERw.js";import"./wang-editor-C7jwA1hA.js";import"./useIcon-CMCVj6oE.js";import"./useValidator-BN3tPovt.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:y}=W({fetchDataApi:()=>f(this,null,function*(){const{currentPage:t,pageSize:a}=h,o=yield ie(U({current:e(t),pageSize:e(a),type:1},e(I)));return{list:o.list,total:o.count}}),fetchDelApi:()=>f(this,null,function*(){})}),{loading:D,dataList:x,total:v,currentPage:r,pageSize:u}=h,{getList:_,getElTableExpose:F,delList:ve}=y,I=c({}),z=t=>{I.value=t,_()},{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=>i(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 a,o;return i(j,null,[i(g,{type:"primary",onClick:()=>G(t.row,"edit")},O(a=m("exampleDemo.edit"))?a:{default:()=>[a]}),i(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 a=yield F();n.value=t?[t.materialId]:(a==null?void 0:a.getSelectionRows().map(o=>o.materialId))||[],R.value=!0,yield se(e(n).join(",")).finally(()=>{R.value=!1,_()})}),G=(t,a)=>f(this,null,function*(){C.value=m("exampleDemo.edit"),yield re(t.materialId),b.value=a,P.value=t,p.value=!0,_()}),T=c(),V=c(!1),H=()=>f(this,null,function*(){const t=e(T),a=yield t==null?void 0:t.submit();a&&(V.value=!0,(yield ne(a).catch(()=>{}).finally(()=>{V.value=!1}))&&(p.value=!1,r.value=1,_()))});return(t,a)=>($(),de(j,null,[i(e(ee),null,{default:d(()=>[i(e(ae),{schema:e(k).searchSchema,onSearch:z,onReset:z},null,8,["schema"]),pe("div",ge,[i(e(g),{type:"primary",onClick:Z},{default:d(()=>[S(w(e(m)("exampleDemo.add")),1)]),_:1}),i(e(g),{loading:R.value,type:"danger",onClick:a[0]||(a[0]=o=>L(null))},{default:d(()=>[S(w(e(m)("exampleDemo.del")),1)]),_:1},8,["loading"])]),i(e(Y),{pageSize:e(u),"onUpdate:pageSize":a[1]||(a[1]=o=>A(u)?u.value=o:null),currentPage:e(r),"onUpdate:currentPage":a[2]||(a[2]=o=>A(r)?r.value=o:null),columns:e(k).tableColumns,data:e(x),loading:e(D),pagination:{total:e(v)},"image-preview":["thumbUrl"],onRegister:e(l)},null,8,["pageSize","currentPage","columns","data","loading","pagination","onRegister"])]),_:1}),i(e(te),{modelValue:p.value,"onUpdate:modelValue":a[4]||(a[4]=o=>p.value=o),title:C.value},{footer:d(()=>[b.value!=="detail"?($(),E(e(g),{key:0,type:"primary",loading:V.value,onClick:H},{default:d(()=>[S(w(e(m)("exampleDemo.save")),1)]),_:1},8,["loading"])):M("",!0),i(e(g),{onClick:a[3]||(a[3]=o=>p.value=!1)},{default:d(()=>[S(w(e(m)("dialogDemo.close")),1)]),_:1})]),default:d(()=>[b.value!=="detail"?($(),E(oe,{key:0,ref_key:"writeRef",ref:T,"form-schema":e(k).formSchema,"current-row":P.value},null,8,["form-schema","current-row"])):M("",!0)]),_:1},8,["modelValue","title"])],64))}});export{Le as default};
