UNPKG

@cmstops/pro-compo

Version:

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

162 lines (161 loc) 5.27 kB
"use strict"; var vue = require("vue"); var webVue = require("@arco-design/web-vue"); var config = require("../config.js"); var useDocHistory = require("./scripts/useDocHistory.js"); var index$1 = require("./components/DocHistoryList/index.js"); var index = require("./components/DocDiffPanel/index.js"); var index$2 = require("../emptyData/index.js"); const _hoisted_1 = { class: "doc-history-wrap" }; const _hoisted_2 = { class: "doc-diff-panel" }; const _hoisted_3 = { class: "doc-history-list" }; const _sfc_main = vue.defineComponent({ ...{ name: "docHistory" }, __name: "component", props: { BASE_API: {}, wrap: { default: "drawer" }, visible: { type: Boolean }, docInfo: {}, pub: { type: Boolean }, currentIdx: {} }, emits: ["update:visible", "select"], setup(__props, { emit: __emit }) { const props = __props; const emits = __emit; const vis = vue.computed({ get: () => props.visible, set: (val) => { emits("update:visible", val); } }); const wrapProps = vue.computed(() => { if (props.wrap === "drawer") { return { class: "doc-history-drawer-wrap", title: "\u7248\u672C\u8BB0\u5F55", width: 1e3 }; } return { bodyClass: "doc-history-modal-wrap", title: "\u7248\u672C\u8BB0\u5F55", width: 1e3 }; }); const BASE_API = props.BASE_API || config.DEFAULT_BASE_API; const { initParams, loadData, handleSelect, loading, diffContent, list, current } = useDocHistory.useDocHistory(BASE_API); const wrapComponent = { drawer: webVue.Drawer, modal: webVue.Modal }; function handeRevert() { emits("select", list.value[current.value]); } vue.watch( () => vis.value, (val) => { if (!val) return; loadData(); }, { immediate: true } ); vue.watch( () => props.currentIdx, (val) => { if (val) { handleSelect(val); } }, { immediate: true } ); vue.onMounted(async () => { if (!props.docInfo) return; initParams(props.docInfo.id, props.pub); await loadData(); if (props.currentIdx) { handleSelect(props.currentIdx); } }); return (_ctx, _cache) => { return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(wrapComponent[_ctx.wrap]), vue.mergeProps({ visible: vis.value, "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => vis.value = $event) }, wrapProps.value), { footer: vue.withCtx(() => [ vue.createVNode(vue.unref(webVue.Button), { type: "primary", disabled: !vue.unref(current), onClick: handeRevert }, { default: vue.withCtx(() => _cache[1] || (_cache[1] = [ vue.createTextVNode(" \u8FD8\u539F\u6B64\u7248\u672C ") ])), _: 1, __: [1] }, 8, ["disabled"]) ]), default: vue.withCtx(() => [ vue.createElementVNode("div", _hoisted_1, [ vue.unref(list).length ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [ vue.createElementVNode("div", _hoisted_2, [ vue.createVNode(vue.unref(webVue.Spin), { loading: vue.unref(loading), style: { "height": "100%", "width": "100%" } }, { default: vue.withCtx(() => [ vue.createVNode(vue.unref(webVue.Scrollbar), { "outer-style": { height: "100%" }, style: { "height": "100%", "width": "100%", "overflow": "auto" } }, { default: vue.withCtx(() => [ vue.unref(diffContent) ? (vue.openBlock(), vue.createBlock(index, { key: 0, doc: vue.unref(diffContent) }, null, 8, ["doc"])) : vue.createCommentVNode("v-if", true) ]), _: 1 }) ]), _: 1 }, 8, ["loading"]) ]), vue.createElementVNode("div", _hoisted_3, [ vue.createVNode(vue.unref(webVue.Scrollbar), { "outer-style": { height: "100%" }, style: { "height": "100%", "overflow": "auto" } }, { default: vue.withCtx(() => [ vue.createVNode(index$1, { list: vue.unref(list), current: vue.unref(current), onSelect: vue.unref(handleSelect) }, null, 8, ["list", "current", "onSelect"]) ]), _: 1 }) ]) ], 64)) : (vue.openBlock(), vue.createBlock(vue.unref(index$2), { key: 1, type: "empty", "custom-tip": "\u6682\u65E0\u5386\u53F2\u8BB0\u5F55" })) ]) ]), _: 1 }, 16, ["visible"]); }; } }); module.exports = _sfc_main;