import{W as e}from"./wangEditor.79562b52.js";import{j as l,a as t,N as a,G as o,b as r,O as s,o as d,e as u,f as m,g as n,w as i,I as c,r as f,h as p,p as b,i as h}from"./vendor.08ecc2ea.js";import{b as g,c as _,f as v}from"./document.2bda4967.js";import{_ as V}from"./index.4567af67.js";import"./request.33748d8c.js";const x={name:"document-add",setup(){const d=l(),u=t([]),m=t({}),n=()=>{d.query.id&&_(d.query).then((e=>{200==e.status?(console.log(e.msg),Object.keys(e.data).forEach((l=>{m[l]=e.data[l],h.txt.html(e.data.content)}))):(Object.keys(m).forEach((e=>{m[e]="",h.txt.html("")})),c.error(e.msg))}))};g().then((e=>{200==e.status&&e.data.forEach(((e,l)=>{u[l]=e}))})),n(),a((()=>d.query.id),((e,l)=>{n()}),{deep:!0});const i=o(null),f=()=>{i.value.resetFields(),h.txt.html()},p=o(null),b=t({html:"",text:""});let h;return r((()=>{h=new e(p.value),h.config.zIndex=1,h.create()})),s((()=>{h.destroy(),h=null})),{editor:p,content:b,options:u,rules:{title:[{required:!0,message:"请输入文章标题",trigger:"blur"}],shorttitle:[{required:!0,message:"请输入简要标题",trigger:"blur"}],cid:[{required:!0,message:"请选择栏目",trigger:"blur"}]},formRef:i,form:m,onSubmit:()=>{i.value.validate((e=>{if(!e)return!1;m.content=h.txt.html(),v(m).then((e=>{200==e.status?c.success(e.msg):c.error(e.msg)})),f()}))},onReset:f}}},j={class:"crumbs"},y=(e=>(b("data-v-3d956e90"),e=e(),h(),e))((()=>m("i",{class:"el-icon-lx-sort"},null,-1))),q=p(" 编辑文档 "),k={class:"container"},w={class:"form-box"},C={class:"mgb20",ref:"editor"},E=p("禁用"),R=p("启用"),U=p("提交"),I=p("重置");var O=V(x,[["render",function(e,l,t,a,o,r){const s=f("el-breadcrumb-item"),c=f("el-breadcrumb"),p=f("el-input"),b=f("el-form-item"),h=f("el-cascader"),g=f("el-radio"),_=f("el-radio-group"),v=f("el-button"),V=f("el-form");return d(),u("div",null,[m("div",j,[n(c,{separator:"/"},{default:i((()=>[n(s,null,{default:i((()=>[y,q])),_:1})])),_:1})]),m("div",k,[m("div",w,[n(V,{ref:"formRef",rules:a.rules,model:a.form,"label-width":"auto"},{default:i((()=>[n(b,{label:"文章标题",prop:"title"},{default:i((()=>[n(p,{modelValue:a.form.title,"onUpdate:modelValue":l[0]||(l[0]=e=>a.form.title=e),placeholder:"请输入文章标题"},null,8,["modelValue"])])),_:1}),n(b,{label:"简要标题",prop:"shorttitle"},{default:i((()=>[n(p,{modelValue:a.form.shorttitle,"onUpdate:modelValue":l[1]||(l[1]=e=>a.form.shorttitle=e),placeholder:"请输入简要标题"},null,8,["modelValue"])])),_:1}),n(b,{label:"选择栏目",prop:"cid"},{default:i((()=>[n(h,{options:a.options,modelValue:a.form.cid,"onUpdate:modelValue":l[2]||(l[2]=e=>a.form.cid=e),placeholder:"选择栏目"},null,8,["options","modelValue"])])),_:1}),n(b,{label:"文章内容"},{default:i((()=>[m("div",C,null,512)])),_:1}),n(b,{label:"状态",prop:"status"},{default:i((()=>[n(_,{modelValue:a.form.status,"onUpdate:modelValue":l[3]||(l[3]=e=>a.form.status=e)},{default:i((()=>[n(g,{label:0},{default:i((()=>[E])),_:1}),n(g,{label:1},{default:i((()=>[R])),_:1})])),_:1},8,["modelValue"])])),_:1}),n(b,null,{default:i((()=>[n(v,{type:"primary",onClick:a.onSubmit},{default:i((()=>[U])),_:1},8,["onClick"]),n(v,{onClick:a.onReset},{default:i((()=>[I])),_:1},8,["onClick"])])),_:1})])),_:1},8,["rules","model"])])])])}],["__scopeId","data-v-3d956e90"]]);export{O as default};
