import { css } from "@linaria/core"; import { Button, Input, Select } from "ant-design-vue"; import { SearchOutlined } from "@ant-design/icons-vue"; import { defineComponent, reactive } from "vue"; import { any } from "vue-types"; import { Image } from "@queenjs/ui"; import { useResource } from "@/modules/resource"; import dayjs from "dayjs"; import { queenApi, useModal } from "queenjs"; import { useEditor } from "@/modules/editor"; export default defineComponent({ props: { record: any().isRequired, }, setup(props, { slots }) { const resource = useResource(); const state = reactive({ currCollection: {} as any, searchVal: "", }); const editor = useEditor(); const modal = useModal(); const EmptyHistory = () => { return (
暂无历史发送信息
); }; const EmptyCollection = () => { return (
请输入正确的接收地址以获取信息
); }; const workPreview = async (currId: string) => { await editor.actions.initDesign(currId, false); previewInModal("当前提交"); }; const historyPreview = async (hisId: string) => { await editor.actions.initWkDesign(hisId); previewInModal("历史提交"); }; const collectionPreview = async (collection: any) => { if (collection.introLink) { window.open(collection.introLink); return; } if (collection.introH5Id) { await editor.actions.initDesign(collection.introH5Id, false); previewInModal("详情介绍"); } }; const previewInModal = (title: string) => { editor.actions.switchMode("preview"); resource.showModal(
, { title: title, destroyOnClose: true, } ); }; const itemRender = (data: any) => { return (
workPreview(data._id)} >
{data.title}
{data.desc}
); }; const itemHistory = () => { if (!state.currCollection.h5) { return null; } const h5 = state.currCollection.h5[0]; const wks = state.currCollection.wks; return (
historyPreview(wks.id)} >
{h5.title}
{h5.desc}
提交日期:{dayjs(wks.endTime).format("YYYY-MM-DD")}
); }; const CollectionRender = () => { const data = state.currCollection; return (
{data.title}
{(data.introLink || data.introH5Id) && (
{ collectionPreview(data); }} >
)}
{data.logo && ( )} {data.endTime && ( 截止日期:{dayjs(data.endTime).format("YYYY-MM-DD")} )}
{data.status && (
{data.status}
)}
); }; const search = async () => { if (!state.searchVal) { return false; } const collection = await resource.actions.searchCollection( state.searchVal, props.record._id ); if (!collection) { return; } state.currCollection = collection[0]; }; const commit = async () => { const res = await resource.actions.commitCollection({ id: state.currCollection._id, h5Id: props.record._id, }); if (!res) { return; } modal.submit(); queenApi.messageSuccess("发送成功"); }; return () => { return (
接收地址
{ state.searchVal = e.target.value || ""; }} >
{state.currCollection._id ? CollectionRender() : EmptyCollection()}
当前发送
{itemRender(props.record)}
历史发送
{state.currCollection.h5 ? itemHistory() : EmptyHistory()}
); }; }, }); const itemPreview = css` &:hover { .icon_preview { opacity: 1; } } .icon_preview { opacity: 0; cursor: pointer; } `; const ModalStyle = css` color: #111; .ant-input { border-radius: 4px; border-color: rgba(51, 51, 51, 0.3); color: #111; &::placeholder { color: #999; } } .ant-select:not(.ant-select-customize-input) { .ant-select-selector { border-radius: 4px; border-color: rgba(51, 51, 51, 0.3); color: #111; .ant-select-selection-search { input { text-align: center; } } } } .ant-select-selection-placeholder { color: #999; } .ant-btn-background-ghost.ant-btn-primary { border-radius: 4px; background-color: rgba(255, 227, 178, 0.3); } .ant-btn-background-ghost.ant-btn-primary[disabled] { color: #fff; border-color: transparent; background: #ccc; text-shadow: none; box-shadow: none; &:hover { color: #fff; border-color: transparent; background: #ccc; text-shadow: none; box-shadow: none; } } `;