import{G as B}from"./el-button-ca4abaee.js";import{a as N,b as S,E as F}from"./el-breadcrumb-item-422ecc35.js";import{E as q,a as I}from"./el-form-item-85aab49a.js";import{E as T}from"./el-input-df8c5b16.js";import{a1 as L,Z as U,q as i,z,v as M,L as $,o as O,f as A,M as u,Q as e,w as a,N as m,a as D,O as G}from"./index-fb87886b.js";import{C as K}from"./ckeditor-b26c301c.js";import{g as Q,u as X,a as Z}from"./news-d0a250e1.js";import{E as _}from"./el-message-5778b677.js";import{_ as j}from"./_plugin-vue_export-helper-c27b6911.js";import"./castArray-59d69fd8.js";import"./index-de3a95d3.js";import"./_baseClone-732ede82.js";import"./request-60ae96d2.js";import"./aria-60e0cdc6.js";const H={class:"main"},J={class:"breadcrumb-section"},P={class:""},W={class:"demo-drawer__footer",style:{"text-align":"right"}},Y={__name:"form",setup(ee){const d=L(),c=U(),y=K,b=i({simpleUpload:{uploadUrl:"https://prodio.zltest.com.tw/adminapi/article/uploadImage",headers:{"X-CSRF-TOKEN":"CSFR-Token"}},image:{resize:!0,toolbar:["imageTextAlternative","|","imageStyle:alignLeft","imageStyle:alignRight","|","imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"],styles:["full","alignLeft","alignRight"]}}),f=i("insert"),g=i(!1),v=i(null),o=i({id:0,title:"",content:""});z(async()=>{if(d.query.id){let l=await Q(d.query.id);l.code===200?(o.value=l.data,f.value="update"):(_({message:"取得資料失敗.",type:"error"}),c.push("/news/list"))}});const w=M({title:[{required:!0,message:"產業動態標題必填",trigger:"blur"}]}),E=()=>{c.push("/news/list")},k=l=>{l&&l.validate(async t=>{if(t){let s,r;f.value==="update"?(o.value.id=d.query.id,s=await X(o.value),r="修改成功."):(s=await Z(o.value),r="新增成功."),s.code===200&&(_({message:r,type:"success"}),c.push("/news/list"))}else return _({message:"請檢查輸入資料是否正確.",type:"error"}),!1})};return(l,t)=>{const s=N,r=S,p=B,C=T,R=q,V=$("ckeditor"),h=I,x=F;return O(),A("div",H,[u("div",J,[u("div",null,[e(r,{separator:"/"},{default:a(()=>[e(s,null,{default:a(()=>[m(" 最新消息 ")]),_:1}),e(s,null,{default:a(()=>[m(" 產業動態 ")]),_:1})]),_:1})]),u("div",null,[e(p,{type:"primary",onClick:t[0]||(t[0]=n=>l.$router.back())},{default:a(()=>[m("回產業動態列表")]),_:1})])]),e(x,null,{default:a(()=>[e(h,{ref_key:"formRef",ref:v,model:o.value,"status-icon":"",rules:w,"label-width":"120px"},{default:a(()=>[e(R,{label:"標題",prop:"title"},{default:a(()=>[e(C,{modelValue:o.value.title,"onUpdate:modelValue":t[1]||(t[1]=n=>o.value.title=n)},null,8,["modelValue"])]),_:1}),u("div",P,[e(V,{editor:D(y),modelValue:o.value.content,"onUpdate:modelValue":t[2]||(t[2]=n=>o.value.content=n),config:b.value},null,8,["editor","modelValue","config"])])]),_:1},8,["model","rules"]),u("div",W,[e(p,{onClick:E},{default:a(()=>[m("取消")]),_:1}),e(p,{type:"primary",loading:g.value,onClick:t[3]||(t[3]=n=>k(v.value))},{default:a(()=>[m(G(g.value?"提交中 ...":"確認"),1)]),_:1},8,["loading"])])]),_:1})])}}},fe=j(Y,[["__scopeId","data-v-b641c762"]]);export{fe as default};
