2 lines
8.7 KiB
JavaScript
Raw Permalink Normal View History

2025-06-02 21:34:56 +08:00
var e=Object.defineProperty,l=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,t=Object.prototype.propertyIsEnumerable,n=(l,a,t)=>a in l?e(l,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[a]=t;import{Z as o,_ as u,C as r,d as p,r as m,O as i,S as d,j as s,H as c,c as f,o as g,F as v,e as b,R as y,k as h,w as C,l as V,m as _,h as k,I as w,J as N,f as x,P as O}from"./index-C-c3zR6K.js";import{s as T}from"./variable-BQq6M8_1.js";const $={class:"app-container"},q={class:"dialog-footer"},P=r({name:"Template"}),S=u(Object.assign(P,{setup(e){const{proxy:u}=p(),{template_type:r}=u.useDict("template_type"),P=m([]),S=m(!1),U=m(!0),j=m(!0),D=m([]),I=m(!0),E=m(!0),R=m(0),M=m(""),z=m([]),B=i({form:{templateContent:""},queryParams:{pageNum:1,pageSize:10,templateName:null,templateType:null},rules:{templateName:[{required:!0,message:"请输入模版名称",trigger:"blur"}],templateCode:[{required:!0,message:"请输入模版CODE",trigger:"blur"}],templateType:[{required:!0,message:"请选择模版类型",trigger:"change"}],templateVariable:[{required:!0,message:"请选择变量",trigger:"change"}],remark:[{required:!0,message:"请输入场景说明",trigger:"blur"}],templateContent:[{required:!0,message:"请输入模版内容",trigger:"blur"}]}}),{queryParams:F,form:H,rules:J}=d(B);function K(){var e;U.value=!0,(e=F.value,o({url:"/modelMessage/template/list",method:"get",params:e})).then((e=>{P.value=e.rows,R.value=e.total,U.value=!1}))}function Z(){S.value=!1,A()}function A(){H.value={templateId:null,templateName:null,templateCode:null,templateType:null,templateContent:"",templateVariable:[],createBy:null,createTime:null,updateBy:null,updateTime:null,remark:null},u.resetForm("templateRef")}function G(){F.value.pageNum=1,K()}function L(){u.resetForm("queryRef"),G()}function Q(e){D.value=e.map((e=>e.templateId)),I.value=1!=e.length,E.value=!e.length}function W(){A(),ae(),S.value=!0,M.value="添加模版"}function X(e){A(),ae();const l=e.templateId||D.value;var a;(a=l,o({url:"/modelMessage/template/"+a,method:"get"})).then((e=>{H.value=e.data,H.value.templateVariable=e.data.templateVariable.split("/"),S.value=!0,M.value="编辑模版"}))}function Y(){u.$refs.templateRef.validate((e=>{e&&(H.value.templateVariable=H.value.templateVariable.join("/"),null!=H.value.templateId?function(e){return o({url:"/modelMessage/template",method:"put",data:e})}(H.value).then((e=>{u.$modal.msgSuccess("编辑模版成功"),S.value=!1,K()})):function(e){return o({url:"/modelMessage/template",method:"post",data:e})}(H.value).then((e=>{u.$modal.msgSuccess("新增模版成功"),S.value=!1,K()})))}))}function ee(e){const l=e.templateId||D.value;u.$modal.confirm('是否确认删除模版管理编号为"'+l+'"的数据项?').then((function(){return o({url:"/modelMessage/template/"+l,method:"delete"})})).then((()=>{K(),u.$modal.msgSuccess("删除成功")})).catch((()=>{}))}function le(){u.download("modelMessage/template/export",((e,o)=>{for(var u in o||(o={}))a.call(o,u)&&n(e,u,o[u]);if(l)for(var u of l(o))t.call(o,u)&&n(e,u,o[u]);return e})({},F.value),`template_${(new Date).getTime()}.xlsx`)}function ae(){return e=this,l=null,a=function*(){try{z.value=(yield T()).data}catch(e){}},new Promise(((t,n)=>{var o=e=>{try{r(a.next(e))}catch(l){n(l)}},u=e=>{try{r(a.throw(e))}catch(l){n(l)}},r=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,u);r((a=a.apply(e,l)).next())}));var e,l,a}function te(e){H.value.templateVariable=e,H.value.templateContent||(H.value.templateContent="");const l=H.value.templateContent.match(/\$\{\w+\}/g)||[],a=z.value.filter((l=>e.includes(l.variableName))).map((e=>`\${${e.variableContent}}`));l.forEach((e=>{a.includes(e)||(H.value.templateContent=H.value.templateContent.replace(e,"").trim())}));const t=z.value.find((l=>l.variableName===e[e.length-1]));if(t){const e=`\${${t.variableContent}}`;H.value.templateContent.includes(e)||(H.value.templateContent+=` ${e}`)}H.value.templateContent=H.value.templateContent.replace(/\s+/g," ").trim()}return ae(),K(),(e,l)=>{const a=s("el-input"),t=s("el-form-item"),n=s("el-button"),o