1 |
- var te=Object.defineProperty,oe=Object.defineProperties;var ae=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var $=(o,a,t)=>a in o?te(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t,O=(o,a)=>{for(var t in a||(a={}))ne.call(a,t)&&$(o,t,a[t]);if(V)for(var t of V(a))se.call(a,t)&&$(o,t,a[t]);return o},S=(o,a)=>oe(o,ae(a));var q=(o,a,t)=>new Promise((v,f)=>{var i=s=>{try{c(t.next(s))}catch(h){f(h)}},C=s=>{try{c(t.throw(s))}catch(h){f(h)}},c=s=>s.done?v(s.value):Promise.resolve(s.value).then(i,C);c((t=t.apply(o,a)).next())});import le from"./customIcons-CmLB3bUu.js";import ue from"./productNote-BQLMgFCa.js";import ce from"./productContant-DyH5EJwO.js";import{aa as R,B as re,D as de,r as j,t as G,bF as pe,ay as z,bG as ie,bA as me,bH as ve,j as H}from"./antd-V2f1Ijkg.js";import{d as fe,f as b,r as he,w as W,p as J,a7 as d,_,$ as k,F as _e,aa as ge,a8 as K,a9 as p,a0 as l,k as r,ab as L,a1 as Ce,G as I,B as ye,a3 as we,a4 as Fe}from"./vue-B3Yl1XMW.js";import{_ as be}from"./entry/index-BFpON5wd-1719886843165.js";import"./plugin-DHZ68pLH.js";import"./onMountedOrActivated-Cz7FEpZo.js";const ke=fe({name:"MsgContant",components:{"a-form":R,"a-form-item":R.Item,"a-button":re,"a-dropdown":de,"a-menu":j,"a-menu-item":j.Item,"a-input":G,"a-input-textarea":G.TextArea,"a-sub-menu":pe,"a-upload":z,"a-upload-dragger":z.Dragger,CloudUploadOutlined:ie,PlusCircleOutlined:me,UserOutlined:ve,CustomIcons:le,ProductNote:ue,ProductContant:ce},props:{value:{type:Array,required:!0}},emits:["update:value"],setup(o,{emit:a}){const t=b(f(o.value)),v=he({fileContent:""});W(()=>o.value,e=>{t.value=f(e)}),W(t,e=>{a("update:value",e)},{deep:!0});function f(e){return e.map((n,u,x)=>S(O({},n),{canMoveUp:u>0,canMoveDown:u<x.length-1}))}function i(){t.value.forEach((e,n,u)=>{e.canMoveUp=n>0,e.canMoveDown=n<u.length-1})}const C=(e,n)=>{const u=n.target;t.value[e]=u.value,a("update:value",t.value)},c=b(!1),s=b("/upload"),h=b("image/*,video/*,application/pdf,application/msword,application/vnd.ms-excel"),y=b([]),U=e=>{const n=/image|video|pdf|msword|vnd.ms-excel/.test(e.type);return n||H.error("只能上传图片、视频、PDF、Word、Excel文件"),n},M=({file:e,fileList:n})=>{y.value=n.slice(-1),e.status==="done"?v.fileContent=e.response:e.status==="error"&&H.error(`${e.name} 文件上传失败.`)},A=()=>{y.value=[],v.fileContent=""},E=x=>q(this,[x],function*({file:e,onSuccess:n,onError:u}){const T=new FormData;T.append("file",e);try{const D=yield fetch(s.value,{method:"POST",body:T});if(D.ok){const ee=yield D.json();n(ee)}else u(new Error("上传失败"))}catch(D){u(D)}}),m=()=>{c.value=!0},w=()=>{c.value=!1},F=({key:e})=>{const u={wechatNickname:"微信昵称",name:"姓名",title:"称呼",surname:"姓氏","Mr/Ms":"先生/女士","youngMan/youngLady":"小哥哥/小姐姐"}[e]||e;v.content+=`${u}`},N=()=>{const e=Date.now();t.value.push({id:e,type:1,content:"",canMoveUp:t.value.length>0,canMoveDown:!1}),i()},Q=()=>{const e=Date.now();t.value.push({id:e,type:2,file:"",canMoveUp:t.value.length>0,canMoveDown:!1}),i()},X=e=>{e.key==="1"?N():Q()},P=e=>{t.value.splice(e,1),i()};J("removeItem",P);const B=(e,n)=>{n==="up"&&e>0?[t.value[e],t.value[e-1]]=[t.value[e-1],t.value[e]]:n==="down"&&e<t.value.length-1&&([t.value[e],t.value[e+1]]=[t.value[e+1],t.value[e]]),i()},Y=e=>{B(e,"up")},Z=e=>{B(e,"down")};return J("moveItem",B),{taskForm:v,handleCreateClick:X,addTextArea:N,removeItem:P,moveItem:B,moveItemUp:Y,moveItemDown:Z,updateCanMoveProperties:i,isFocused:c,handleFocus:m,handleBlur:w,handleMenuClick:F,uploadUrl:s,acceptTypes:h,fileList:y,beforeUpload:U,handleChange:M,handleRemove:A,customRequest:E,internalValue:t,updateValue:C,addCanMoveProperties:f}}}),g=o=>(we("data-v-94e2357e"),o=o(),Fe(),o),Me={class:"custom-placeholder-wrapper"},Be={key:0,class:"custom-placeholder"},De=g(()=>l("span",null,"示例:",-1)),Ie=g(()=>l("span",{class:"highlight"},"xx客户",-1)),Ue=g(()=>l("span",{class:"highlight"},"性别",-1)),Ae=g(()=>l("span",null,"您好!",-1)),Ee=[De,Ie,Ue,Ae],Le={class:"textarea-bottom"},Ne={class:"character-count"},Pe={class:"upload-contant"},Te={key:0},Ve=g(()=>l("div",null,[I(" 将文件拖到此处,或 "),l("span",{style:{color:"#1890ff"}},"点击上传")],-1)),$e=g(()=>l("div",null,"支持上传文件为图片、视频、pdf、word、excel",-1)),Oe={class:"message-content-btn"};function Se(o,a,t,v,f,i){const C=d("a-textarea"),c=d("CustomIcons"),s=d("a-form-item"),h=d("CloudUploadOutlined"),y=d("a-upload-dragger"),U=d("a-button"),M=d("a-menu-item"),A=d("a-menu"),E=d("a-dropdown");return _(),k("div",null,[(_(!0),k(_e,null,ge(o.internalValue,(m,w)=>(_(),k("div",{key:w},[m.type===1?(_(),K(s,{key:0,label:"",name:"content",class:"message-content"},{default:p(()=>[l("div",Me,[r(C,{class:"custom-textarea",value:m.content,"onUpdate:value":F=>m.content=F,rows:8,maxlength:1e3,onFocus:o.handleFocus,onBlur:o.handleBlur},null,8,["value","onUpdate:value","onFocus","onBlur"]),!m.content&&!o.isFocused?(_(),k("div",Be,Ee)):L("",!0),l("div",Le,[l("div",Ne,Ce(m.content.length)+"/ 1000",1)]),r(c,{index:w},null,8,["index"])])]),_:2},1024)):m.type===2?(_(),K(s,{key:1,label:"",name:"fileContent",class:"message-content"},{default:p(()=>[l("div",Pe,[r(y,{class:"upload","custom-request":o.customRequest,"before-upload":o.beforeUpload,"file-list":o.fileList,"on-change":o.handleChange,"on-remove":o.handleRemove,multiple:!1,accept:o.acceptTypes,"onUpdate:fileList":a[0]||(a[0]=F=>o.fileList=F),"list-type":"picture-card"},{default:p(()=>[o.fileList.length===0?(_(),k("div",Te,[r(h,{style:{"font-size":"25px"}}),Ve,$e])):L("",!0)]),_:1},8,["custom-request","before-upload","file-list","on-change","on-remove","accept"]),r(c,{index:w,length:o.length},null,8,["index","length"])])]),_:2},1024)):L("",!0),l("div",Oe,[r(E,{trigger:["click"],onClick:a[1]||(a[1]=ye(()=>{},["stop"])),arrow:"",placement:"bottomRight"},{overlay:p(()=>[r(A,{onClick:o.handleCreateClick},{default:p(()=>[r(M,{key:"1"},{default:p(()=>[I("文本")]),_:1}),r(M,{key:"2"},{default:p(()=>[I("文件")]),_:1})]),_:1},8,["onClick"])]),default:p(()=>[r(U,{value:"large",type:"primary",class:"create-btn"},{default:p(()=>[I("添加")]),_:1})]),_:1})])]))),128))])}const Qe=be(ke,[["render",Se],["__scopeId","data-v-94e2357e"]]);export{Qe as default};
|