You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
14 KiB

2 weeks ago
import{n as e}from"./axios-CiYFffbI.js";import{I as t,N as n,V as r,Y as i,_ as a,d as o,f as s,i as c,it as l,kt as u,l as d,nt as f,p,u as m,ut as h,v as g,y as _,z as v}from"./runtime-core.esm-bundler-CnFWH3R5.js";import{n as y}from"./http-LCi9aT1G.js";import{c as b}from"./index-DtDFIu4i.js";import{t as x}from"./RichEditorField-DVnrTI6h.js";import{t as S}from"./listTableRowIndex-ConJ8Gia.js";import{t as C}from"./mediaUrl-CPV6u7br.js";var ee=[`src`,`onClick`],te={key:1,style:{color:`#86909c`}},ne={style:{"max-width":`90vw`,"max-height":`80vh`}},re=[`src`],ie=[`src`],ae={class:`admin-modal-form__full`},oe={class:`study-tour-tags-field`},w={class:`study-tour-tags-input-row`},se={class:`study-tour-tags-list`},ce={key:0,style:{color:`#86909c`}},T={style:{width:`100%`,display:`flex`,"flex-direction":`column`,"align-items":`stretch`}},le={style:{width:`100%`,"margin-bottom":`8px`}},ue={style:{width:`100%`,border:`1px solid #e5e6eb`,"border-radius":`6px`,padding:`8px`,"max-height":`220px`,overflow:`auto`}},de={key:0,style:{display:`flex`,"flex-direction":`column`,"align-items":`flex-start`,gap:`8px`}},fe=[`src`],pe=900,E=b(_({__name:`StudyTourList`,setup(_){let b=l(!1),E=l(!1),D=l(!1),O=l(!0),k=l(null),A=l([]),j=l([]),M=l(``),N=l(void 0),P=l(void 0),F=f({current:1,pageSize:10}),me={maxHeight:`70vh`,overflow:`auto`},I=l(0),L=l(!1),R=l(`image`),z=l(``),B=f({name:``,tags:[],venue_ids:[],cover_image:``,intro_html:``,sort:0,is_on_shelf:!0}),V=l(``),H=d(()=>{let e=new Map(j.value.map(e=>[e.id,e]));return B.venue_ids.map(t=>e.get(t)).filter(Boolean)});function U(e,t){let n=String(e||``).trim();if(n)return C(n);let r=String(t||``).trim();return r?C(r):``}async function W(e){let t=new FormData;t.append(`file`,e);let{data:n}=await y.post(`/upload`,t);return U(n?.url,n?.path)}async function G(e){return W(e)}function K(){I.value+=1}function q(e){let t=new Set,n=[e];for(;n.length;){let e=n.shift();if(!(!e||t.has(e))){if(t.add(e),e instanceof File)return e;if(e?.target?.files?.[0]instanceof File)return e.target.files[0];if(Array.isArray(e)){for(let t of e)n.push(t);continue}if(typeof e==`object`){for(let t of[`file`,`raw`,`originFile`,`originFileObj`,`fileItem`,`item`,`data`])e[t]&&n.push(e[t]);for(let t of Object.values(e))t&&(typeof t==`object`||Array.isArray(t))&&n.push(t)}}}return null}function J(){let t=this.quill,n=document.createElement(`input`);n.type=`file`,n.accept=`image/*`,n.onchange=async()=>{let r=n.files?.[0];if(r)try{let n=await G(r),i=t.getSelection(!0)?.index??Math.max(0,t.getLength()-1);t.insertEmbed(i,`image`,n,`user`),t.setSelection(i+1,0),e.success(`图片已上传并插入`)}catch(t){e.error(t?.response?.data?.message??t?.message??`图片上传失败`)}},n.click()}function Y(){let t=this.quill,n=document.createElement(`input`);n.type=`file`,n.accept=`video/*`,n.onchange=async()=>{let r=n.files?.[0];if(r)try{let n=await G(r),i=t.getSelection(!0)?.index??Math.max(0,t.getLength()-1);t.insertEmbed(i,`video`,n,`user`),t.setSelection(i+1,0),e.success(`视频已上传并插入`)}catch(t){e.error(t?.response?.data?.message??t?.message??`视频上传失败`)}},n.click()}let he={modules:{toolbar:{container:[[{header:[1,2,3,!1]}],[`bold`,`italic`,`underline`,`strike`],[{color:[]},{background:[]}],[{list:`ordered`},{list:`bullet`}],[{align:[]}],[`link`,`image`,`video`],[`clean`]],handlers:{image:J,video:Y}}},placeholder:`请输入线路简介`};function ge(e){return(e||[]).length?(e||[]).join(``):`-`}function _e(e,t){t&&(R.value=e,z.value=C(t),L.value=!0)}async function X(t){try{let n=q(t);if(!n)return e.warning(`未识别到上传文件`),!1;B.cover_image=await W(n),e.success(`封面上传成功`)}catch(t){e.error(t?.response?.data?.message??`封面上传失败`)}return!1}function ve(...e){X(e)}function ye(){B.cover_image=``}function Z(t){let n=t?.target,r=(n?.getAttribute?.(`src`)||n?.src||``).trim();!r||r===`about:blank`||e.error(`图片地址无法访问,请检查后端 storage 访问配置`)}function be(){M.value=``,N.value=void 0,P.value=void 0,F.current=1,Q()}async function Q(t=!1){b.value=!0;try{let e={},n=M.value.