import{G as x}from"./el-button-7b435908.js";import{a as B,b as N,E as F}from"./el-breadcrumb-item-0c010d2b.js";import{E as I,a as q}from"./el-form-item-563dc716.js";import{E as T}from"./el-input-5a355fec.js";import{a1 as z,Z as L,q as i,z as U,v as $,L as M,o as A,f as O,M as u,Q as e,w as a,N as m,a as D,O as G}from"./index-11843334.js";import{C as K}from"./ckeditor-8ca0487d.js";import{g as Q,u as X,a as Z}from"./news-b27a662a.js";import{E as _}from"./el-message-c3316f84.js";import{_ as j}from"./_plugin-vue_export-helper-c27b6911.js";import"./castArray-80791487.js";import"./index-58150f7d.js";import"./_baseClone-07904f92.js";import"./request-79887494.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=z(),c=L(),y=K,b=i({simpleUpload:{uploadUrl:"https://prodio.zltest.com.tw/adminapi/article/uploadImage",headers:{"X-CSRF-TOKEN":"CSFR-Token",Authorization:`${sessionStorage.getItem("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:""});U(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 k=$({title:[{required:!0,message:"產業動態標題必填",trigger:"blur"}]}),w=()=>{c.push("/news/list")},E=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=B,r=N,p=x,C=T,h=I,R=M("ckeditor"),S=q,V=F;return A(),O("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(V,null,{default:a(()=>[e(S,{ref_key:"formRef",ref:v,model:o.value,"status-icon":"",rules:k,"label-width":"120px"},{default:a(()=>[e(h,{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(R,{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:w},{default:a(()=>[m("取消")]),_:1}),e(p,{type:"primary",loading:g.value,onClick:t[3]||(t[3]=n=>E(v.value))},{default:a(()=>[m(G(g.value?"提交中 ...":"確認"),1)]),_:1},8,["loading"])])]),_:1})])}}},fe=j(Y,[["__scopeId","data-v-cd64dbf9"]]);export{fe as default};
