var K=Object.defineProperty,G=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var M=(a,s,o)=>s in a?K(a,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[s]=o,v=(a,s)=>{for(var o in s||(s={}))W.call(s,o)&&M(a,o,s[o]);if(N)for(var o of N(s))Y.call(s,o)&&M(a,o,s[o]);return a},w=(a,s)=>G(a,z(s));var x=(a,s,o)=>new Promise((p,_)=>{var y=c=>{try{r(o.next(c))}catch(m){_(m)}},g=c=>{try{r(o.throw(c))}catch(m){_(m)}},r=c=>c.done?p(c.value):Promise.resolve(c.value).then(y,g);r((o=o.apply(a,s)).next())});import{a as H,B as J}from"./index-8cbf1e33.js";import{u as Q,_ as X}from"./useForm-19fca69f.js";import"./FormItem.vue_vue_type_script_lang-35d3ca4d.js";import{ao as Z,_ as ee}from"./index.js";import{j as te,k as oe,l as ae,m as se,p as ne}from"./complication-809f35fa.js";import{R as ie,O as V,aR as le,b4 as re,B as ce}from"./antd-ecb53b14.js";import{d as pe,c as ue,u as n,f as h,a5 as de,Y as me,a6 as fe,a7 as u,l as d,E,$ as ve,aa as _e,a1 as xe,a2 as ye,_ as ge}from"./vue-8fccce23.js";import"./useWindowSizeFn-8ad2dbf2.js";import"./useFormItem-d8cab136.js";import"./uuid-31b8b5a4.js";import"./useSortable-987ef813.js";import"./download-c6c2acd3.js";import"./index-22d6b33a.js";import"./copyTextToClipboard-ab85e052.js";import"./index-3eef3423.js";import"./index-b614de6b.js";import"./TextEditor-284232fa.js";import"./onMountedOrActivated-cb072c10.js";const we=a=>(xe("data-v-6f898c05"),a=a(),ye(),a),he=we(()=>ge("span",{class:"context-tip"},"例:患者今日常规透析,预设超滤{V值}。透前称重测血压{透前血压}。",-1)),Fe=pe({__name:"noteFormModal",emits:["success","register"],setup(a,{emit:s}){const o=ue(()=>n(p)?"编辑说明模板":"新增说明模板"),p=h(!1),_=h(),y=h([]),g=h([]),r=h(!0),c=[{label:"并发症ID",field:"complicationId",component:"Input",show:!1},{label:"模版名称",field:"name",required:!0,component:"Input",componentProps:{placeholder:"请输入模版名称",onFocus:function(){r.value=!0}}},{label:"排序",field:"sort",required:!0,component:"InputNumber",componentProps:{placeholder:"请输入排序",min:0,onFocus:function(){r.value=!0}}},{label:"模版内容",field:"context",required:!0,slot:"contextSlot",component:"Input"},{label:"预览内容",field:"preview",slot:"previewSlot",component:"InputTextArea"}],{createMessage:m}=Z(),[R,{resetFields:P,validate:L,setFieldsValue:F,getFieldsValue:b}]=Q({layout:"vertical",showResetButton:!0,labelWidth:100,schemas:c,showActionButtonGroup:!1,actionColOptions:{span:23}}),[O,{setModalProps:S,closeModal:U}]=H(e=>x(this,null,function*(){if(yield P(),T(),S({confirmLoading:!1}),p.value=!!(e!=null&&e.isUpdate),n(p)){_.value=e.record.id;const t=yield te(e.record.id);yield F(v({},t))}else yield F({complicationId:e.id})}));function T(){return x(this,null,function*(){const e=yield oe();y.value=[],g.value=Object.keys(e),Object.keys(e).forEach((t,f)=>{e[t].forEach((i,l)=>{i.key=f*1e3+l}),y.value.push({fieldName:t,key:f,children:e[t]})})})}function A(){return x(this,null,function*(){try{const e=yield L();S({confirmLoading:!0}),n(p)?yield se(w(v({},e),{id:_.value})):yield ae(v({},e)),n(p)?m.success("编辑成功!"):m.success("新增成功!"),U(),s("success",{isUpdate:n(p),values:w(v({},e),{id:_.value})})}finally{S({confirmLoading:!1,canFullscreen:!1})}})}function D(){return x(this,null,function*(){const e=b();if(e&&e.context){const t=yield ne(e.context);yield F(w(v({},e),{preview:t}))}else m.error("请输入模板内容后进行预览")})}function $(e,{selectedNodes:t}){r.value=!1,j(t[0].fieldName)}function j(e){return x(this,null,function*(){var B;let t="",f="",i="";const l=b(),I=document.getElementById("contexts"),C=q(I),k=l.context?l.context:"";f=k.substring(0,C),i=k.substring(C,(B=l.context)==null?void 0:B.length),t=f+"{"+e+"}"+i,yield F(w(v({},l),{context:t}))})}function q(e){let t=0;return(e.selectionStart||e.selectionStart=="0")&&(t=e.selectionStart),t}return(e,t)=>{const f=de("a-tree");return me(),fe(n(J),_e({width:"800px"},e.$attrs,{destroyOnClose:"",onRegister:n(O),title:o.value,onOk:A}),{default:u(()=>[d(n(ie),null,{default:u(()=>[d(n(V),{span:16},{default:u(()=>[d(n(X),{onRegister:n(R)},{contextSlot:u(({model:i,field:l})=>[d(n(le),{compact:""},{default:u(()=>[d(n(re),{type:"textarea",rows:4,value:i[l],"onUpdate:value":I=>i[l]=I,onFocus:t[0]||(t[0]=I=>r.value=!1),id:"contexts"},null,8,["value","onUpdate:value"]),he,d(n(ce),{size:"mini",type:"primary",shape:"round",class:"per-btn",onClick:D},{default:u(()=>[E("内容预览")]),_:1})]),_:2},1024)]),previewSlot:u(({model:i,field:l})=>[E(ve(i[l]),1)]),_:1},8,["onRegister"])]),_:1}),d(n(V),{span:8},{default:u(()=>[d(f,{disabled:r.value,"tree-data":y.value,"expanded-keys":g.value,"onUpdate:expandedKeys":t[1]||(t[1]=i=>g.value=i),onSelect:$,"field-names":{children:"children",title:"fieldName",key:"fieldName"}},null,8,["disabled","tree-data","expanded-keys"])]),_:1})]),_:1})]),_:1},16,["onRegister","title"])}}});const je=ee(Fe,[["__scopeId","data-v-6f898c05"]]);export{je as default};