UNPKG

@cmstops/pro-compo

Version:

[物料平台文档中心](https://arco.design/docs/material/guide)

136 lines (135 loc) 4.88 kB
import { defineComponent, ref, reactive, openBlock, createElementBlock, createVNode, unref, withCtx, createElementVNode } from "vue"; import { Modal, Spin, Scrollbar } from "@arco-design/web-vue"; import { getDocDetailsNew } from "./script/api.js"; import useDialogVisible from "../hooks/dialogVisible.js"; import { DEFAULT_BASE_API } from "../config.js"; import _sfc_main$1 from "./components/metaInfoForm.js"; const _hoisted_1 = { class: "edit-meta-info-container" }; const _hoisted_2 = { style: { "padding": "20px" } }; const _sfc_main = defineComponent({ ...{ name: "editMetaInfo" }, __name: "component", props: { BASE_API: {}, visible: { type: Boolean }, hashId: {} }, emits: ["update:visible", "submit", "upload"], setup(__props, { emit: __emit }) { const emit = __emit; const props = __props; const metaInfoFormRef = ref(); const isLoading = ref(false); const editorDataPubInfo = ref(null); const BASE_API = props.BASE_API || DEFAULT_BASE_API; const extra = reactive({ title: "\u5C01\u9762", titleValid: false, topImageTitle: "\u5C01\u9762\u5934\u56FE", topImageTitleValid: false }); function setTopImageTitle(doc) { const { series } = doc; if (series === "local_live") { extra.title = "\u5C01\u9762\u56FE"; extra.titleValid = true; } else { extra.title = "\u5C01\u9762"; extra.titleValid = false; } if (["special", "special_v3"].includes(series)) { extra.topImageTitleValid = false; extra.topImageTitle = "\u4E13\u9898\u5934\u56FE"; } else { if (["video_album", "audio_album"].includes(series)) { extra.topImageTitle = "\u5C01\u9762\u5934\u56FE"; } else { extra.topImageTitle = "\u64AD\u653E\u5668\u80CC\u666F\u56FE"; } extra.topImageTitleValid = true; } } const handleOpen = async () => { if (props.hashId) { isLoading.value = true; const { code, message } = await getDocDetailsNew(BASE_API, { hashid: props.hashId }); setTopImageTitle(message); if (code === 0) { isLoading.value = false; editorDataPubInfo.value = { id: message.id, title: message.title, series: message.series, state: message.state, payload: message.payload, ...message.meta }; } } }; const { visible, setVisible } = useDialogVisible(props, emit); const handleOk = async () => { const meta = await metaInfoFormRef.value.getFormData("valid"); if (meta) { const data = { id: editorDataPubInfo.value.id, meta }; emit("submit", data); } }; const handleCancel = () => { setVisible(false); }; return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ createVNode(unref(Modal), { visible: unref(visible), width: "800px", "mask-closable": false, "title-align": "start", "body-class": "edit-meta-info-dialog-body", "unmount-on-close": "", title: "\u7F16\u8F91\u7A3F\u7B7E", onOpen: handleOpen, onOk: handleOk, onCancel: handleCancel }, { default: withCtx(() => [ createVNode(unref(Spin), { loading: isLoading.value, style: { "width": "100%" } }, { default: withCtx(() => [ createVNode(unref(Scrollbar), { "outer-style": "height: 60vh; overflow: auto", style: { "height": "100%", "overflow": "auto" } }, { default: withCtx(() => [ createElementVNode("div", _hoisted_2, [ createVNode(_sfc_main$1, { ref_key: "metaInfoFormRef", ref: metaInfoFormRef, BASE_API: unref(BASE_API), showTitle: true, title: extra.title, "top-image-title": extra.topImageTitle, "title-valid": extra.titleValid, "top-image-title-valid": extra.topImageTitleValid, "init-data": editorDataPubInfo.value, onUpload: _cache[0] || (_cache[0] = (e) => _ctx.$emit("upload", e)) }, null, 8, ["BASE_API", "title", "top-image-title", "title-valid", "top-image-title-valid", "init-data"]) ]) ]), _: 1 }) ]), _: 1 }, 8, ["loading"]) ]), _: 1 }, 8, ["visible"]) ]); }; } }); export { _sfc_main as default };