@wooshiao/x-ui2
Version:
包含查询条件、按钮、表格、分页组件
1,334 lines (1,333 loc) • 133 kB
JavaScript
import { defineComponent, ref, onMounted, onUpdated, watch, openBlock, createElementBlock, normalizeStyle, createBlock, unref, withCtx, renderSlot, reactive, createVNode, createElementVNode, toDisplayString, createCommentVNode, createTextVNode, Fragment, renderList, normalizeClass, useAttrs, mergeProps, useCssVars, createSlots, pushScopeId, popScopeId, withDirectives, vShow, normalizeProps, guardReactiveProps, resolveComponent, nextTick, withModifiers } from "vue";
import ace from "ace-builds";
import "ace-builds/src-noconflict/mode-yaml";
import "ace-builds/src-noconflict/mode-sql";
import "ace-builds/src-noconflict/mode-javascript";
import "ace-builds/src-noconflict/mode-markdown";
import "ace-builds/src-noconflict/mode-java";
import "ace-builds/src-noconflict/mode-json";
import "ace-builds/src-noconflict/worker-yaml";
import "ace-builds/src-noconflict/worker-javascript";
import "ace-builds/src-noconflict/theme-chrome";
import { ElConfigProvider, ElTree, ElInput, ElIcon, ElSelect, ElOption, ElDialog, ElButton, ElUpload, ElLink, ElProgress, ElMessage, ElForm, ElFormItem, ElInputNumber, ElSwitch, ElRadioGroup, ElRadio, ElRadioButton, ElCheckboxGroup, ElCheckbox, ElTreeSelect, ElCascader, ElDatePicker, ElTimePicker, ElTimeSelect, ElTooltip, ElMessageBox, ElMenuItem, ElSubMenu, ElMenu, ElContainer, ElHeader, ElAside, ElMain, ElTable, ElTableColumn, ElDropdown, ElDropdownMenu, ElDropdownItem, ElPagination } from "element-plus";
import { Search, Close, Upload, Plus, Download, QuestionFilled, Refresh, DArrowRight, ArrowDown } from "@element-plus/icons-vue";
import TinymceVue from "@tinymce/tinymce-vue";
import { mavonEditor } from "mavon-editor";
import { useRoute } from "vue-router";
const _sfc_main$g = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
modelValue: {
type: String,
default: ""
},
readonly: {
type: Boolean,
default: false
},
theme: {
type: String,
default: "chrome"
},
mode: {
type: String,
default: "javascript"
},
width: {
type: String,
default: "100%"
},
height: {
type: String,
default: "100%"
},
gutter: {
type: Boolean,
default: true
}
},
emits: ["update:modelValue"],
setup(__props, { expose: __expose, emit: __emit }) {
const emit = __emit;
const props = __props;
const editor = ref();
let aceEditor = null;
const initEditor = () => {
if (aceEditor) {
aceEditor.destroy();
}
aceEditor = ace.edit(editor.value, {
fontSize: 12,
fontFamily: "Consolas,Monaco,monospace",
theme: `ace/theme/${props.theme}`,
// dracula
mode: `ace/mode/${props.mode}`,
useWorker: false,
showPrintMargin: false,
// 去掉中间竖线
showGutter: props.gutter,
// 显示行号
tabSize: 2,
useSoftTabs: true,
readOnly: props.readonly
});
aceEditor.setOptions({
autoScrollEditorIntoView: true,
copyWithEmptySelection: true
});
aceEditor.on("blur", () => {
aceEditor.selection.getCursor();
emit("update:modelValue", aceEditor.getValue());
});
aceEditor.alignCursors();
aceEditor.getSession().setUseWrapMode(true);
aceEditor.setOption("wrap", "off");
aceEditor.setValue(props.modelValue, -1);
aceEditor.resize();
};
const getContent = () => {
return aceEditor.getValue();
};
const setContent = (val) => {
aceEditor.setValue(val, -1);
};
__expose({ getContent, setContent, aceEditor });
onMounted(() => {
initEditor();
});
onUpdated(() => {
editor.value.style.fontSize = "12px";
});
watch(
() => props.modelValue,
(newVal) => {
aceEditor.setValue(newVal, -1);
}
);
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
ref_key: "editor",
ref: editor,
style: normalizeStyle({ width: __props.width, height: __props.height })
}, null, 4);
};
}
});
const index_vue_vue_type_style_index_0_scoped_360253c9_lang = "";
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const XEditor = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-360253c9"]]);
/*! Element Plus v2.4.1 */
var zhCn = {
name: "zh-cn",
el: {
colorpicker: {
confirm: "确定",
clear: "清空"
},
datepicker: {
now: "此刻",
today: "今天",
cancel: "取消",
clear: "清空",
confirm: "确定",
selectDate: "选择日期",
selectTime: "选择时间",
startDate: "开始日期",
startTime: "开始时间",
endDate: "结束日期",
endTime: "结束时间",
prevYear: "前一年",
nextYear: "后一年",
prevMonth: "上个月",
nextMonth: "下个月",
year: "年",
month1: "1 月",
month2: "2 月",
month3: "3 月",
month4: "4 月",
month5: "5 月",
month6: "6 月",
month7: "7 月",
month8: "8 月",
month9: "9 月",
month10: "10 月",
month11: "11 月",
month12: "12 月",
weeks: {
sun: "日",
mon: "一",
tue: "二",
wed: "三",
thu: "四",
fri: "五",
sat: "六"
},
months: {
jan: "一月",
feb: "二月",
mar: "三月",
apr: "四月",
may: "五月",
jun: "六月",
jul: "七月",
aug: "八月",
sep: "九月",
oct: "十月",
nov: "十一月",
dec: "十二月"
}
},
select: {
loading: "加载中",
noMatch: "无匹配数据",
noData: "无数据",
placeholder: "请选择"
},
cascader: {
noMatch: "无匹配数据",
loading: "加载中",
placeholder: "请选择",
noData: "暂无数据"
},
pagination: {
goto: "前往",
pagesize: "条/页",
total: "共 {total} 条",
pageClassifier: "页",
page: "页",
prev: "上一页",
next: "下一页",
currentPage: "第 {pager} 页",
prevPages: "向前 {pager} 页",
nextPages: "向后 {pager} 页",
deprecationWarning: "你使用了一些已被废弃的用法,请参考 el-pagination 的官方文档"
},
messagebox: {
title: "提示",
confirm: "确定",
cancel: "取消",
error: "输入的数据不合法!"
},
upload: {
deleteTip: "按 delete 键可删除",
delete: "删除",
preview: "查看图片",
continue: "继续上传"
},
table: {
emptyText: "暂无数据",
confirmFilter: "筛选",
resetFilter: "重置",
clearFilter: "全部",
sumText: "合计"
},
tree: {
emptyText: "暂无数据"
},
transfer: {
noMatch: "无匹配数据",
noData: "无数据",
titles: ["列表 1", "列表 2"],
filterPlaceholder: "请输入搜索内容",
noCheckedFormat: "共 {total} 项",
hasCheckedFormat: "已选 {checked}/{total} 项"
},
image: {
error: "加载失败"
},
pageHeader: {
title: "返回"
},
popconfirm: {
confirmButtonText: "确定",
cancelButtonText: "取消"
}
}
};
const _sfc_main$f = /* @__PURE__ */ defineComponent({
__name: "index",
setup(__props) {
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(ElConfigProvider), { locale: unref(zhCn) }, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 8, ["locale"]);
};
}
});
const index_vue_vue_type_style_index_0_lang = "";
const _sfc_main$e = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
modelValue: {
type: Array,
default() {
return [];
}
},
treeData: {
type: Array,
default() {
return [];
}
},
treeProps: {
type: Object,
default: () => ({})
},
lazy: {
type: Boolean,
default: () => true
},
load: {
type: Function,
default: () => () => {
}
},
showCheckbox: {
type: Boolean,
default: () => false
}
},
emits: ["node-click", "update:modelValue"],
setup(__props, { expose: __expose, emit: __emit }) {
const emit = __emit;
const props = __props;
const defaultTreeProps = {
label: "name",
value: "id",
// 新增
parentId: "parentId",
// 新增
children: "children",
disabled: "disabled",
isLeaf: "isLeaf",
class: "class"
};
const cloneTreeProps = reactive(
Object.assign(defaultTreeProps, props.treeProps)
);
const refTree = ref(null);
const handleMenuCheckChange = (data, check) => {
if (check) {
const parentId = data[cloneTreeProps.parentId];
refTree.value.setChecked(parentId, true, false);
} else {
data[cloneTreeProps.children] != null && data[cloneTreeProps.children].forEach((element) => {
refTree.value.setChecked(element[cloneTreeProps.value], false, false);
});
}
};
const handleMenuChange = (data, check) => {
var _a;
if (((_a = data[cloneTreeProps.children]) == null ? void 0 : _a.length) && check.checkedKeys.includes(data[cloneTreeProps.value])) {
setCheckedOfDeep(data, cloneTreeProps.value, true);
}
emit("update:modelValue", refTree.value.getCheckedKeys());
};
const setCheckedOfDeep = (data, nodeKey = "id", val = true) => {
var _a;
refTree.value.setChecked(data[nodeKey], val, true);
return ((_a = data[cloneTreeProps.children]) == null ? void 0 : _a.length) && data[cloneTreeProps.children].map(
(item) => setCheckedOfDeep(item, nodeKey, val)
);
};
__expose({ refTree });
return (_ctx, _cache) => {
return openBlock(), createBlock(_sfc_main$f, null, {
default: withCtx(() => [
createVNode(unref(ElTree), {
ref_key: "refTree",
ref: refTree,
data: __props.treeData,
"check-strictly": "",
"element-loading-text": "拼命加载中",
"node-key": __props.treeProps.value || "id",
props: cloneTreeProps,
lazy: __props.lazy,
load: __props.load,
"render-after-expand": false,
"expand-on-click-node": false,
"default-expand-all": !__props.lazy,
"show-checkbox": __props.showCheckbox,
"default-checked-keys": __props.modelValue,
"highlight-current": "",
onCheckChange: handleMenuCheckChange,
onCheck: handleMenuChange,
onNodeClick: _cache[0] || (_cache[0] = (node) => {
emit("node-click", node);
})
}, null, 8, ["data", "node-key", "props", "lazy", "load", "default-expand-all", "show-checkbox", "default-checked-keys"])
]),
_: 1
});
};
}
});
const _hoisted_1$a = { class: "x-container" };
const _hoisted_2$7 = {
key: 0,
class: "x-tree-box"
};
const _hoisted_3$5 = { class: "x-title" };
const _hoisted_4$5 = { class: "x-scroll-box" };
const _hoisted_5$5 = { class: "x-user-box" };
const _hoisted_6$4 = { class: "x-title" };
const _hoisted_7$3 = { class: "x-scroll-box" };
const _hoisted_8$2 = ["onClick"];
const _hoisted_9$2 = { class: "x-user-selected-box" };
const _hoisted_10$2 = { class: "x-title" };
const _hoisted_11$1 = { class: "x-scroll-box" };
const _sfc_main$d = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
modelValue: {
type: Array,
default: () => []
},
title: {
type: Array,
default: () => ["组织架构", "用户列表", "已选择项"]
},
hideTree: {
type: Boolean,
default: () => false
},
treeData: {
type: Array,
default: () => []
},
treeProps: {
type: Object,
default: () => ({})
},
lazy: {
type: Boolean,
default: () => true
},
load: {
type: Function,
default: () => () => {
}
},
listData: {
type: Array,
default: () => []
},
listProps: {
type: Object,
default: () => ({ label: "name", value: "id" })
},
multiple: {
type: Boolean,
default: () => false
}
},
emits: ["node-click", "update:modelValue"],
setup(__props, { emit: __emit }) {
const emit = __emit;
const props = __props;
const selectList = ref(props.modelValue);
function selectItem(item) {
if (props.multiple) {
const hasItem = hasItemFunc(item);
!hasItem && selectList.value.push(item);
} else {
selectList.value = [item];
}
emit("update:modelValue", selectList.value);
}
function hasItemFunc(item) {
return selectList.value.find(
(val) => val[props.listProps.value] === item[props.listProps.value]
);
}
function deleteItem(item) {
selectList.value = selectList.value.filter(
(val) => val[props.listProps.value] !== item[props.listProps.value]
);
emit("update:modelValue", selectList.value);
}
const keywords = ref("");
function showItem(item) {
return item[props.listProps.label].includes(keywords.value);
}
watch(
() => props.modelValue,
() => {
selectList.value = props.modelValue;
}
);
return (_ctx, _cache) => {
return openBlock(), createBlock(_sfc_main$f, null, {
default: withCtx(() => [
createElementVNode("div", _hoisted_1$a, [
!__props.hideTree ? (openBlock(), createElementBlock("div", _hoisted_2$7, [
createElementVNode("div", _hoisted_3$5, toDisplayString(__props.title[0] || "组织架构"), 1),
createElementVNode("div", _hoisted_4$5, [
createVNode(unref(_sfc_main$e), {
"tree-data": __props.treeData,
"tree-props": __props.treeProps,
lazy: __props.lazy,
load: __props.load,
onNodeClick: _cache[0] || (_cache[0] = (node) => emit("node-click", node))
}, null, 8, ["tree-data", "tree-props", "lazy", "load"])
])
])) : createCommentVNode("", true),
createElementVNode("div", _hoisted_5$5, [
createElementVNode("div", _hoisted_6$4, [
createTextVNode(toDisplayString(__props.title[1] || "用户列表") + " ", 1),
createVNode(unref(ElInput), {
modelValue: keywords.value,
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => keywords.value = $event),
style: { "width": "calc(100% - 70px)" },
placeholder: "请输入名称查询",
"suffix-icon": unref(Search)
}, null, 8, ["modelValue", "suffix-icon"])
]),
createElementVNode("ul", _hoisted_7$3, [
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.listData, (item, index2) => {
return openBlock(), createElementBlock(Fragment, { key: index2 }, [
showItem(item) ? (openBlock(), createElementBlock("li", {
key: 0,
class: normalizeClass({ active: hasItemFunc(item) }),
onClick: ($event) => selectItem(item)
}, toDisplayString(item[__props.listProps.label]), 11, _hoisted_8$2)) : createCommentVNode("", true)
], 64);
}), 128))
])
]),
createElementVNode("div", _hoisted_9$2, [
createElementVNode("div", _hoisted_10$2, toDisplayString(__props.title[2] || "已选择项"), 1),
createElementVNode("ul", _hoisted_11$1, [
(openBlock(true), createElementBlock(Fragment, null, renderList(selectList.value, (item, index2) => {
return openBlock(), createElementBlock("li", { key: index2 }, [
createTextVNode(toDisplayString(item[__props.listProps.label]) + " ", 1),
createVNode(unref(ElIcon), {
class: "x-close-icon",
size: 16,
onClick: ($event) => deleteItem(item)
}, {
default: withCtx(() => [
createVNode(unref(Close))
]),
_: 2
}, 1032, ["onClick"])
]);
}), 128))
])
])
])
]),
_: 1
});
};
}
});
const index_vue_vue_type_style_index_0_scoped_b49abae6_lang = "";
const XTransfer = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-b49abae6"]]);
const _hoisted_1$9 = { class: "dialog-footer" };
const _sfc_main$c = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
modelValue: {
type: Array,
default() {
return [];
}
}
},
emits: ["update:modelValue"],
setup(__props, { emit: __emit }) {
const emit = __emit;
const props = __props;
const attrs = useAttrs();
const dialogVisible = ref(false);
const dataList = ref([]);
const transferData = ref([]);
function confirm() {
dataList.value = transferData.value;
emit("update:modelValue", dataList.value);
getData();
dialogVisible.value = false;
}
function clickFunc() {
dialogVisible.value = true;
transferData.value = dataList.value;
}
function clearFunc() {
dataList.value = [];
emit("update:modelValue", dataList.value);
}
function removeTagFunc(id) {
dataList.value = dataList.value.filter((val) => {
return attrs.listProps ? val[attrs.listProps.value] !== id : val.id !== id;
});
emit("update:modelValue", dataList.value);
}
const data = ref();
getData();
function getData() {
const ids = props.modelValue.map((val) => {
return attrs.listProps ? val[attrs.listProps.value] : val.id;
});
data.value = attrs.multiple ? ids : ids[0];
dataList.value = props.modelValue;
}
watch(
() => props.modelValue,
() => {
getData();
}
);
return (_ctx, _cache) => {
return openBlock(), createBlock(_sfc_main$f, null, {
default: withCtx(() => [
createVNode(unref(ElSelect), mergeProps({
ref: "refSelect",
modelValue: data.value,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => data.value = $event),
clearable: "",
style: { "width": "100%" }
}, _ctx.$attrs, {
onClick: clickFunc,
onClear: clearFunc,
onRemoveTag: removeTagFunc
}), {
default: withCtx(() => [
(openBlock(true), createElementBlock(Fragment, null, renderList(dataList.value, (val, index2) => {
return openBlock(), createBlock(unref(ElOption), {
key: index2,
style: { "height": "auto" },
label: _ctx.$attrs && _ctx.$attrs.listProps ? val[_ctx.$attrs.listProps.label] : val.name,
value: _ctx.$attrs && _ctx.$attrs.listProps ? val[_ctx.$attrs.listProps.value] : val.id
}, null, 8, ["label", "value"]);
}), 128))
]),
_: 1
}, 16, ["modelValue"]),
createVNode(unref(ElDialog), {
modelValue: dialogVisible.value,
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => dialogVisible.value = $event),
title: "请选择",
width: "60%"
}, {
footer: withCtx(() => [
createElementVNode("span", _hoisted_1$9, [
createVNode(unref(ElButton), {
onClick: _cache[2] || (_cache[2] = ($event) => dialogVisible.value = false)
}, {
default: withCtx(() => [
createTextVNode("取消")
]),
_: 1
}),
createVNode(unref(ElButton), {
type: "primary",
onClick: confirm
}, {
default: withCtx(() => [
createTextVNode("确定")
]),
_: 1
})
])
]),
default: withCtx(() => [
createVNode(XTransfer, mergeProps({
modelValue: transferData.value,
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => transferData.value = $event)
}, _ctx.$attrs), null, 16, ["modelValue"])
]),
_: 1
}, 8, ["modelValue"])
]),
_: 1
});
};
}
});
const index_vue_vue_type_style_index_0_scoped_6a196cdb_lang = "";
const XTransferSelect = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-6a196cdb"]]);
const __vite_glob_0_0 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAQCAYAAADwMZRfAAAAAXNSR0IArs4c6QAAAUdJREFUOE9jZKACYEQ2o/HMDm8uVlZVQuaW6jtPQFYDNyTh4NK7T758UFLiEyFkBsPZN48ZwpUMo8r0nZeDFMMNMV7f8/9MQDFBA0AKKk5vZmBmZNrYZuoTQNCQf///M1x5/5zh6vsXDNc+vGAIkNdlMBaRZZh5/RjDvc9vD3aZ+zngNWT69aMM6x9cYnj38xvYdUq8wgzl+s6kGTLp6iEGBV5hBn0hSQZ5HiGG3sv7GRwkVUg3JE/bDh5Gjed2MPjIaZNmyNRrRxiytWzAhqx7cInh1OuHDKGKBsQbArKVlYmZocrAFWyIyYZeMD3TJox4Q+IOLgVrWmQfDXcJKxMTg6+cDsQwYmLn0Zf3YMVyPIJY0w1RhhBKcTgNSTm04tqDz281iU32YcoGgeV6LhtQEhuI039xf8gfhn8yhFyCMwMS0ohPHgCYYcQRpV73ogAAAABJRU5ErkJggg==";
const __vite_glob_0_1 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAPRJREFUOE+1kzFOw0AQRd8Pp6ClIIVbehDmCkkZ0WCOQSJRcAGKWEj04QIUCYEKUVBCAXfxR7vCkmPLlpHFSqvdlWbe/vmjEQOXBuazA0gzuwtYFBxt7/RejWkANrkaqtILbz3iUeamDmkqEAlmBSTAB2JKwa3Mgj0ObZbVT3opOMu8MkxK6Z0AdhWEnKhis9RneASf/qygalor4DTzRMTa18DB7/4Cvg3hfH3K9dAKiC00zzYvGnFlmAvmQW566XvMeby3lVACEPvAONYOiWBhcYw56QTUnS7rtriWmQne1rmm/2di2aI+s9Haxj7J9ZjB0/gDdjWIEcBBZB0AAAAASUVORK5CYII=";
const __vite_glob_0_2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAASJJREFUOE+l079Kw1AYBfBzbjO4CY3N5CxiR8XZWfyDQzP6HG6tm9An8AVEEiikBXGzk1vXLj6Boe0mLk2P3GIgpo0J5K75zu9+ud+9RM3Fmnn8AdxhrP9AGp7MLlqTbM0GML/y2HyZHy3O3Wla6A7jNwCvAB7yyAYgp9HmchXIMX6KWIBJco+GcyDo0W6S4oUdcJmcSvhaXHvh3igOJHTSUDkQffZIdm1Agm+RzO+oErAOGCOsNK0ENKO4QyJYHxTQkrQPYw4h7QIcS3qykJ3U1g7SERI8EzSG9AFiICKi+G4bssEyYCKiT+FZUo+GdxB2sodXDIziAYSb32J7WY4phDL4hnBLIpxden4hYIP5j9tuZSlQ5W0UjrFKOF9T+zX+ABlMqhGWQfY9AAAAAElFTkSuQmCC";
const __vite_glob_0_3 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAASFJREFUOE+lk71OwzAUhc9JXgGQGFnqDonEwEp+HoGhbExslWBip2zsTEzs9AXYmmREQkIyQz11Y0KCF0gOcqVI5SeNoJ4s33s/X3+6JjZc3LAeXwClibUOGBAHh3P7tJrzA5A6uzybDaMsn78Ufl+ZeCbgAcD1d0gnoDTxInV2rwXU1FUADiDctpf4WCegGsR3DVGJWoTiWMCobb0XUA6jC4oBqUeJl4mzeVvsPa0FNFQeiqeJsye/Ce0EFCYeodGYxFKcQAF8E5qdgMG7oNfM2WknwAcIFKJuKJ7VVBmI5ySOIEwEZL71XkAtlSGZAtgVYAA+E/roBVQmvgew3b67AbYIRB4AaJ/ANHH2uFfiquE/SfTJfaPcOwf/+Vgb/8ZPSB+iESljejMAAAAASUVORK5CYII=";
const __vite_glob_0_4 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAARpJREFUOE+l071KA0EUhuH3DIJ/ha1NphTRVgRLW8tAtrcVVi/B2NnqguItbG5AbExnZSXmAhavQIhRkPlk0CVx87eQafd8z5yZs2MsuGzBPP+AQeY1CwyBvfWz4nm0ZgxYTQv7uvY7y6dFrywcZI1Hmd2buKwiY4ATu8HInUhKJAKgCzO3JXEXNynxqR0EtC+z/lpadD4znwtaZWgu0L/ybec4jwFBEpHhcbxqATHgHBL0agEfmW8Z5GZ2K4UNsE3AAw3Qk7CbCMVJTezgd4TqCntxcIzRlHiAcGi4k3gHMTgXAOsCR1oKTft2bwavAd4NDmYCw5tWBPg7wvbIuDoraZFM7SAWVj9O+ivnAnXextQx1glXaxZ+jT/enqQR+S/wwAAAAABJRU5ErkJggg==";
const __vite_glob_0_5 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAQJJREFUOE+lk78uBWEQxX/nexjxAKLWbKlDKR5As9cLXJ3GXaKhUrv3BbASG5VIRCNeQiFRuuyRXUvW/beb7DRfM+c3Z2a+ER1DHfX8AziOvBAYtKLD68d6zhRASTrlynF0i7jEHDABmQlwLzrH7JSVFDZwvou9j8IS+KxeZDYgjp6BV/A9uY8I4QTY/LXeBnCBbaQPJel2vediTs2AXvRT7cvvOr65agVwITJDzAAxxvqEfPwnDnrRIB3NdVCtMMP5AwqrwB3WE/IbcAosF9ZbAJwhreHyXQf2gKxcSANgWE26TK6iAPWR+sBISbrVaoiLfmMjoM1tzF1jG/FkTudr/AbOxpgRWC6mMAAAAABJRU5ErkJggg==";
const __vite_glob_0_6 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAQxJREFUOE+lkz1Ow0AQRt+Ygh454gaRkGMqDpAaaluyaTgKdJwAiYoqjpSUSIiOFJTQEAfOADGU0PlDBiU4f9iSp9odzbxvdmbHaGjWMJ8FQOrG+g+Yw8F+ljyWY1YAnSxZqSp1oztktxjny5DaAKEzB6ctuCyLrAVMdiLvr0xHcnQKBDNfNaAVhbNgb9oflN9c9KkSMHbjQvHH/CyZn4v7RsCkFQcSA4OFhLm68exNk+FGwO8INTKzC6Ejw0YSV2aEyjnEOClKrwQghtri3n/rP6VufG3wINQF61YBimYFBl85vBv6BGsDH8A2cNPJkrBWE192j/2919543a+sBNTZjY1jrJO8HNN4G78Bd02UEVsJessAAAAASUVORK5CYII=";
const __vite_glob_0_7 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAQlJREFUOE+1kzFOw0AQRd/fpKOGExgo0lJErmgpKJMKiXAA7hA6LkCBhERoHSkUNOmgcgUliMJcAC5AEXvQWlhyYtkysthupZ03b/9oRMejjvWsAYJZbE1Awx18TIYv5TcVQDIJK1bBLH5EWmJ2uQmpGvTdgFUWAQPglb4bs8qusPTC1NsTXJebtDO4iyOMUaHeCGDdwNfkFsnJ8M1ffE5/NiiHVgsIbuMRwv8djAfEMdizbypYmmmRnIXzeoAfoTQltSc5Fhl2I3SE45yMKXDo1ZsBvnmPXaW8s7O9xefXdw418wCaAb9JC+7N2McpygsLgJgnp+H4/0IsRtRmN2rH2KZ4803nbfwBLq2REYhPCWgAAAAASUVORK5CYII=";
const __vite_glob_0_8 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAARFJREFUOE+tk7FKQzEUhv+TCx1cBR/AoS04+AAu7eqm6R1cOqb4AM6tz+AgvW6ubXFz7V06OVUQjIMP4AM4COaXXMwFS1KKbZZA/pPv/OfkRLDlki3vY7eA9uS285pfls3JeBRz9pYPRiEm6H8ctGbFAoIvEJ1oaYISRMNqc5ICLOn4IEqGMQAdr0XJmdXmOA6YFu8k7yuAzwZ5AnkVgiuASN/2zGHKwQcEL1UJgtKem66vmVk2DGcgjqw2BwnA+FOcO6XK5jVgendBcTeA7Iv77lKpR6sHeykHrKx7B6SFqGeAed2PX81qUzd/9RXoxdasYKyJQVsL2GQyk4AwJH6PgfyQrR2kTbKvxuz2L/zHwQ/iQ3sRsybLJQAAAABJRU5ErkJggg==";
const __vite_glob_0_9 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAQFJREFUOE+lkzFuwkAQRf8sd8GImmyfI2DktHCKtJAuJ4iUkhbLFmW6hBJDWmTnEkgobfyjxUZasM1a8jTbzLx9O7Mj6BjSsR5XAC/SvAcUJaN0vP22cyqAbJJUrLz44ROQDxCvt5BaQGHCN3OT5AzZk7n88QWq1yf4bl9SCxjEekpwlvm7RwPxIr0CEFzUnYB+pOcmWQm/zJn6u82l2Ng5AcWbizDqabA/g0qbeoAX6wCEUQ2tLp9AHinyK4JD5idho0E5wh8AawDPBBYCzJhjKQrnJxl1FwC5qKFifigBC3vmLsBVp2s+VJhNkqdWTbz3G52ANrvROMY2xbc5nbfxH5wikRGWOQs4AAAAAElFTkSuQmCC";
const __vite_glob_0_10 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAO9JREFUOE+lk7sNwkAMhv8fmIVI0DJAlggjUBGFxwLQ0fCIQgMNfViADhZAokKEUZCI0ZGHAoFcpFxln+zP/9lnouJhxXx8ADxjKUXAkLWOc3PO2ZgcwA6GOVWesTwSPAhk9g0pDQAxJdAUwSZb5Cdg3Vq0E5nhoyGsPycArORODzAW3SS4H4z87JtVn7QAtzlXFd/HuY9TW/l/AZ6xsgDxIfhISKuTVzsY7AsA0QiFYlJ4ihMvQrgU7JSvpGsBFPSFWKewkCYYqdIBVLMsCLYgerECpcSM7b0dDLulmlj0G7WAMrvxd4xlkr9jKm/jC6pDhRFw1ls+AAAAAElFTkSuQmCC";
const _imports_0$2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB8AAAAfCAYAAAAfrhY5AAAAAXNSR0IArs4c6QAAA55JREFUWEe9V01oVFcU/s57ryQpDaWFJHNvRmoIitVFoZW2i8EGXLuoSohQFxUtNLi0unPRnW2XxUJ/FxW0oSjUrYVUs7ClCl30B0uI4sx9JoFWa8nk5737lTu8SWdeMjNvRsdZzjvnfvec851zvivI+DPGvEhyH4CCiOwAkAPwNIAlAPdI/gFgRkQua61/z3KstDIyxrwpIqcAvEqypb2IEMBPJM9orS81O7/hYYuLi9vX1tY+A7AnOeAvkpd8379irf0lCIK709PT5bGxsb4oiraQfElE9gLYD+D5xOeqtfZYPp+/tdklNgUPw/AggC9J9ovIPQDvLy8vfzUyMrLcKlNzc3O9vb29bwM4TTInIg8BHFFKfZv23QA+Pz//jrX2LEkfwLlyuXx8dHT0QSvQ9PfZ2dln+/r6PgbwlojEnudNDg0NfVprVwfuIib5DQARkZNKqY/aBU3bh2F4guQHImIBTNRmYB3c1TiKop+TVL/XCpjkU2EYXndgSqnXRWSt0UWTC3zoShAEwe6BgYEKB9bBjTE/JOQ6p7U+3CpiY8wLAG4ndlu11nea+RhjvnYlAHBVa/3GOrhrJwAXHbmWlpZ2ZKlxGIZbSc5lBU844GaBmw8HtNYXK5G79JF8TUQmlVKftIo68WkLPPF5l+RZEfmxUio3uUTkV2vt/dXVVZ2lnToFd23Y09NTEpHnSO6SUql0UkTOAPhCa300S9Sdgjs/Y4wbXEdJnnLg34nIPs/zDuVyuQvdBi+VShMicp7kZZd2R/ttAHamF0LSTto1ffpS1tq8iFxz//u+X7DWltI2JKmUMrVt6MoM4DcAfzrwfwD0B0HQPzg4+G/tAcaYGwBezpqNBnY3tdavVL8tLCw8E0WRG7kPHXjkLj8zMxOMj4/H3QafmpryC4WCw4ybRt5O2uM4Lm4WeTrt6cgb1rxZumuHjIiMKKWq065plepqXmU7yUPDw8Mdsb0d8Dq21/T551rrY1nJ9QiR/9/n1QlH8u+VlZXhTiZc1sg3TLjHMduzgodhWD/bk5FX2WpOhZbL5Uxbrd2Vmtpq+5247HiftyMmkgA33+fuY7FY3O77fmYlk5WYSVmdlKoomTiOd1fV7AYNB+ACSa8bGi6O44l8Pr+uYp+YeiU5qbVurF6rqSwWiwd936/odkdCEWlbt5M87SRTkuojtRFXcRq+WBwHPM+re7G4jiD5vYh078WS2mxP/q2WZnM3Xqn/ASCImA761vxRAAAAAElFTkSuQmCC";
const _imports_1$1 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAAAXNSR0IArs4c6QAAAb1JREFUOE99k79L0FEUxT8ng6igoWhoiAxacghpCioi+wGulUNbiJGRSVMNQYOTNFQgBZVRky61RRSIWQ2CCC2B/YTKwT9AiYroxI37lddTe9N7955z33nn3idWWLZ3AyeAPcBWYC0wB7wCRiRNL0dVHbTdDlwDDq50WcbHgD5J70rcPwVtnwWuA2sStADcAV4ABvYBvcCGzH8DTksaaYouFrR9IZU1sVmgQ9LHUoHt7cA40Jrx38AZScNx/ku2fQh4BrQU5COSxmxfBC4l9oakAdsHgIkC+wsI/IRsx/PeADsKwBdJrbY7gSeVl12SHtr+UHE+Azuj4DHgUUV6LqnD9mCqK9M3JfXZjhcdrXjHo+Am4D2wsUjOSGqzfQq4X5HOSbpl+zUQE9Gs+VDceNgD3C2S0dFdwFtgNOcx0o9zvw2YAVYVnOj2cNnle0B3AZgCDkuatx0dbZH0yfb6bODeAjskqX+xy9npuO02EGqbFQoHgJcZ2A9cCfOLkRmUdHnJHDaB9O0qsLnyrj7GfJ6X9LRMLPl6qTZ+Qig9mcavTtIPYBJ4EN5K+lnfsmzBEmR7HbAlh/6rpO//U/4HLPeUdpK6jKoAAAAASUVORK5CYII=";
const _imports_2$1 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAVtJREFUOE+Nkz0vRFEQhp9XLCGhEyoUsr4Sheho/AD7BzRUCh0lBUJJiY6GXiR+AaUoxGe2IAokKptIhOzIbGbXzU0uO9XJvDPPnI/3iESYmYB7oC+ZT6yLQF6SVXPeUAszawS+gOkAJeU8cADkJH3XAGbWAqwAbUADMAeUgdqUKPZhru+GVvI+mVkvcAW0Zmw7K/0BDFeOYGZO3o7p9XB8F/OSyrU7MLN1YCm634BLYDLu5ASYiiN4yYakZV8kAQvAZgB8wirwDFxIGjWzR6A79EVJW2nADLAXBTsBeAHOJY2Z2QPQE/qspP00oAAc1QkoSDpOA8aB0zoBE5LO0oBB4LpOwJCkmzSgE/AzexwCa8BtOHIEeAI6Qu+S9JoG5IDPeBl3oVu6KRp87XrFNkCzJM/9PmMY6j0s/ZeZSpLaqwXpz+Rb7v/HineSBrIA/i+yvnK1pyjJPVGJH+/bhzQn5nLKAAAAAElFTkSuQmCC";
const typeEnum = {
wma: "audio",
mp3: "audio",
wav: "audio",
aac: "audio",
flac: "audio",
ra: "audio",
wmv: "video",
avi: "video",
mpg: "video",
mpeg: "video",
mov: "video",
rm: "video",
ram: "video",
swf: "video",
flv: "video",
mp4: "video",
mkv: "video",
jpg: "jpg",
jpeg: "jpg",
png: "png",
doc: "doc",
docx: "doc",
pdf: "pdf",
ppt: "ppt",
pptx: "ppt",
xls: "xls",
xlsx: "xls",
rar: "rar",
zip: "zip"
};
const _withScopeId$3 = (n) => (pushScopeId("data-v-533b065d"), n = n(), popScopeId(), n);
const _hoisted_1$8 = {
key: 0,
class: "x-avatar"
};
const _hoisted_2$6 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ createElementVNode("img", {
src: _imports_0$2,
alt: ""
}, null, -1));
const _hoisted_3$4 = ["src"];
const _hoisted_4$4 = { class: "el-upload-list__item-actions" };
const _hoisted_5$4 = ["onClick"];
const _hoisted_6$3 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ createElementVNode("img", {
class: "x-look-icon",
src: _imports_1$1,
alt: ""
}, null, -1));
const _hoisted_7$2 = ["onClick"];
const _hoisted_8$1 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ createElementVNode("img", {
class: "x-delete-icon",
src: _imports_2$1,
alt: ""
}, null, -1));
const _hoisted_9$1 = ["innerHTML"];
const _hoisted_10$1 = { key: 0 };
const _hoisted_11 = {
key: 1,
class: "x-view-box"
};
const _hoisted_12 = ["src"];
const _sfc_main$b = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
modelValue: {
type: Array,
default() {
return [];
}
},
// 上传控件是否为按钮
isButton: {
type: Boolean,
default() {
return false;
}
},
// 上传文字
text: {
type: String,
default() {
return "";
}
},
// 上传提示信息
placeholder: {
type: String,
default() {
return "";
}
},
// 图片宽度
width: {
type: String,
default() {
return "";
}
},
// 图片高度
height: {
type: String,
default() {
return "";
}
},
// 文件大小
size: {
type: Number,
default: 5 * 1024 * 1024
},
// 模板下载的func
download: {
type: Function,
default: null
},
refForm: {
type: Object,
default() {
return null;
}
},
// 是否显示进度条
progress: {
type: Boolean,
default() {
return false;
}
}
},
emits: ["update:modelValue", "remove", "check"],
setup(__props, { emit: __emit }) {
useCssVars((_ctx) => ({
"6774bf64": width.value,
"bac120c2": height.value
}));
const emit = __emit;
const props = __props;
const width = ref(props.width || "160px");
const height = ref(props.height || "104px");
const fileArray = ref(props.modelValue);
function beforeUpload(rawFile) {
if (rawFile.size > props.size) {
ElMessage.error(
`${rawFile.name}文件大小不能超过${props.size / 1024 > 1024 ? `${props.size / 1024 / 1024}M` : `${props.size / 1024}kb`}`
);
return false;
}
}
async function httpRequest(func, options) {
if (func) {
time = Math.ceil(options.file.size / (2 * 1024 * 1024) / 100 * 1e3);
try {
props.progress && startTimer();
const result = await func(options, props.refForm);
setTimeout(() => {
getFileArray();
}, 500);
percentage.value = 100;
setTimeout(() => {
percentage.value = 0;
}, 1e3);
return result;
} catch {
percentage.value = 0;
} finally {
clearTimeout(timer);
}
}
}
const dialogVisible = ref(false);
const dialogImageUrl = ref("");
const handlePictureCardPreview = (file) => {
dialogImageUrl.value = file.url;
dialogVisible.value = true;
};
function showIcon(name) {
var _a;
const fileType = (_a = name.split(".").pop()) == null ? void 0 : _a.toLocaleLowerCase();
return new URL((/* @__PURE__ */ Object.assign({ "./images/audio.png": __vite_glob_0_0, "./images/doc.png": __vite_glob_0_1, "./images/jpg.png": __vite_glob_0_2, "./images/pdf.png": __vite_glob_0_3, "./images/png.png": __vite_glob_0_4, "./images/ppt.png": __vite_glob_0_5, "./images/rar.png": __vite_glob_0_6, "./images/txt.png": __vite_glob_0_7, "./images/video.png": __vite_glob_0_8, "./images/xls.png": __vite_glob_0_9, "./images/zip.png": __vite_glob_0_10 }))[`./images/${typeEnum[fileType] || "txt"}.png`], self.location).href;
}
async function handleDownLoad(file) {
if (!file.id) {
return ElMessage.error("文件正在上传中,无法下载");
}
if (file.url) {
const a = document.createElement("a");
a.href = file.url;
a.click();
a.remove();
} else {
emit("check", file);
}
}
async function handleRemove(file) {
try {
await emit("remove", file);
} finally {
fileArray.value = fileArray.value.filter((val) => {
if (val.response) {
val.id = val.response.id;
}
return val.id !== file.id;
});
emit("update:modelValue", fileArray.value);
}
}
function getFileArray() {
fileArray.value = fileArray.value.map((val) => {
var _a, _b, _c, _d;
return {
name: ((_a = val.response) == null ? void 0 : _a.name) || val.name,
id: ((_b = val.response) == null ? void 0 : _b.id) || val.id,
url: ((_c = val.response) == null ? void 0 : _c.imageUrl) || ((_d = val.response) == null ? void 0 : _d.url) || val.url
};
});
emit("update:modelValue", fileArray.value);
}
const percentage = ref(0);
let time = 0;
let timer = null;
function startTimer() {
timer = setTimeout(() => {
if (percentage.value < 99) {
percentage.value++;
startTimer();
}
}, time);
}
watch(
() => props.modelValue,
() => {
fileArray.value = props.modelValue;
}
);
return (_ctx, _cache) => {
return openBlock(), createBlock(_sfc_main$f, null, {
default: withCtx(() => [
createVNode(unref(ElUpload), mergeProps({
"file-list": fileArray.value,
"onUpdate:fileList": _cache[1] || (_cache[1] = ($event) => fileArray.value = $event),
style: { "width": "100%" }
}, _ctx.$attrs, {
"before-upload": beforeUpload,
class: fileArray.value.length >= _ctx.$attrs["limit"] ? "x-hiddeUpload" : "",
"http-request": (file) => httpRequest(_ctx.$attrs["http-request"], file)
}), createSlots({
trigger: withCtx(() => [
_ctx.$attrs && _ctx.$attrs["list-type"] === "picture-card" ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
_hoisted_2$6,
createTextVNode(" " + toDisplayString(_ctx.$attrs.disabled ? "正在上传中" : __props.text || "上传图片"), 1)
])) : _ctx.$attrs.isButton ? (openBlock(), createBlock(unref(ElButton), {
key: 1,
type: "primary",
plain: "",
disabled: _ctx.$attrs.disabled,
loading: _ctx.$attrs.disabled
}, {
default: withCtx(() => [
createVNode(unref(ElIcon), null, {
default: withCtx(() => [
createVNode(unref(Upload))
]),
_: 1
}),
createTextVNode(" " + toDisplayString(_ctx.$attrs.disabled ? "正在上传中" : __props.text || "上传文件"), 1)
]),
_: 1
}, 8, ["disabled", "loading"])) : (openBlock(), createBlock(unref(ElLink), {
key: 2,
style: { "height": "32px" },
type: "primary",
underline: false,
disabled: _ctx.$attrs.disabled,
loading: _ctx.$attrs.disabled
}, {
default: withCtx(() => [
createVNode(unref(ElIcon), null, {
default: withCtx(() => [
createVNode(unref(Plus))
]),
_: 1
}),
createTextVNode(" " + toDisplayString(_ctx.$attrs.disabled ? "正在上传中" : __props.text || "上传文件"), 1)
]),
_: 1
}, 8, ["disabled", "loading"]))
]),
tip: withCtx(() => [
createElementVNode("div", {
style: { "color": "#e6a23c", "font-size": "12px" },
innerHTML: __props.placeholder
}, null, 8, _hoisted_9$1),
__props.download ? (openBlock(), createElementBlock("div", _hoisted_10$1, [
createVNode(unref(ElLink), {
style: { "height": "32px" },
type: "primary",
onClick: _cache[0] || (_cache[0] = ($event) => __props.download())
}, {
default: withCtx(() => [
createVNode(unref(ElIcon), null, {
default: withCtx(() => [
createVNode(unref(Download))
]),
_: 1
}),
createTextVNode(" 模板下载 ")
]),
_: 1
})
])) : createCommentVNode("", true)
]),
_: 2
}, [
_ctx.$attrs && _ctx.$attrs["list-type"] === "picture-card" ? {
name: "file",
fn: withCtx(({ file }) => [
createElementVNode("div", null, [
createElementVNode("img", {
class: "el-upload-list__item-thumbnail",
src: file.url,
alt: ""
}, null, 8, _hoisted_3$4),
createElementVNode("span", _hoisted_4$4, [
createElementVNode("span", {
class: "x-item-icon",
onClick: ($event) => handlePictureCardPreview(file)
}, [
_hoisted_6$3,
createTextVNode(" 查看 ")
], 8, _hoisted_5$4),
createElementVNode("span", {
class: "x-item-icon",
onClick: ($event) => handleRemove(file)
}, [
_hoisted_8$1,
createTextVNode(" 删除 ")
], 8, _hoisted_7$2)
])
])
]),
key: "0"
} : {
name: "file",
fn: withCtx(({ file }) => [
createElementVNode("div", { class: "flex-between" }, [
createElementVNode("div", { style: { "display": "flex", "align-items": "center" } }, [
createElementVNode("img", {
style: { "width": "16px", "height": "16px" },
src: showIcon(file.name),
alt: ""
}, null, 8, ["src"]),
createElementVNode("span", null, toDisplayString(file.name), 1)
]),
createElementVNode("div", null, [
createVNode(unref(ElLink), {
type: "primary",
onClick: ($event) => handleDownLoad(file)
}, {
default: withCtx(() => [
createTextVNode("下载")
]),
_: 2
}, 1032, ["onClick"]),
createVNode(unref(ElLink), {
type: "danger",
style: { "margin-left": "16px" },
onClick: ($event) => handleRemove(file)
}, {
default: withCtx(() => [
createTextVNode(" 删除 ")
]),
_: 2
}, 1032, ["onClick"])
])
])
]),
key: "1"
}
]), 1040, ["file-list", "class", "http-request"]),
__props.progress && percentage.value > 0 ? (openBlock(), createBlock(unref(ElProgress), {
key: 0,
style: { "width": "100%" },
percentage: percentage.value
}, null, 8, ["percentage"])) : createCommentVNode("", true),
dialogVisible.value ? (openBlock(), createElementBlock("div", _hoisted_11, [
createElementVNode("img", {
src: dialogImageUrl.value,
alt: "Preview Image"
}, null, 8, _hoisted_12),
createVNode(unref(ElIcon), {
class: "x-close-icon",
onClick: _cache[2] || (_cache[2] = ($event) => dialogVisible.value = false)
}, {
default: withCtx(() => [
createVNode(unref(Close))
]),
_: 1
})
])) : createCommentVNode("", true)
]),
_: 1
});
};
}
});
const index_vue_vue_type_style_index_0_scoped_533b065d_lang = "";
const XUpload = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-533b065d"]]);
const _hoisted_1$7 = { style: { "width": "100%", "height": "100%" } };
const _sfc_main$a = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
modelValue: {
// 绑定的值
type: String,
default: ""
},
readonly: {
// 是否禁止编辑
type: Boolean,
default: false
},
plugins: {
type: [String, Array],
default: "table lists wordcount fullscreen advlist anchor autolink charmap directionality insertdatetime link image nonbreaking pagebreak preview save searchreplace table visualblocks visualchars"
// [表格 列表 全屏]
},
toolbar: {
type: [String, Array],
default: "undo redo | fullscreen | formatselect alignleft aligncenter alignright alignjustify | link unlink | numlist bullist | link image | fontselect fontsizeselect forecolor backcolor | bold italic underline strikethrough | indent outdent | superscript subscript | removeformat |"
},
height: {
type: [Number, String],
default: 400
},
width: {
type: [Number, String],
default: 800
}
},
emits: ["update:modelValue"],
setup(__props, { emit: __emit }) {
const attrs = useAttrs();
const emit = __emit;
const props = __props;
onMounted(() => {
window.tinymce.init({});
});
const data = reactive({
loading: false,
content: props.modelValue,
init: {
language: "zh_CN",
// 语言
height: props.height,
// 编辑器高度
width: props.width,
// 编辑器高度
branding: false,
// 是否禁用“Powered by TinyMCE”
menubar: attrs.menubar === void 0 ? true : attrs.menubar,
// 顶部菜单栏显示
image_dimensions: false,
// 去除宽高属性
plugins: props.plugins,
// 插件
toolbar: props.toolbar,
// 工具栏
toolbar_mode: "sliding",
promotion: false,
// 隐藏右上角Upgrade 按钮
font_formats: "Arial=arial,helvetica,sans-serif; 宋体=SimSun; 微软雅黑=Microsoft Yahei; Impact=impact,chicago;",
// 字体
fontsize_formats: "11px 12px 14px 16px 18px 24px 36px 48px 64px 72px",
// 文字大小
// paste_convert_word_fake_lists: false, // 插入word文档需要该属性
paste_data_images: false,
// 图片是否可粘贴
paste_webkit_styles: "all",
// 此选项允许您指定在WebKit中粘贴时要保留的样式
paste_merge_formats: true,
// 此选项启用粘贴插件的合并格式功能
nonbreaking_force_tab: false,
// 此选项允许您在用户按下键盘tab键时强制TinyMCE插入三个实体
paste_auto_cleanup_on_paste: false,
file_picker_types: "file image",
// 此选项允许您通过空格或逗号分隔的类型名称列表指定所需的文件选取器类型。目前有三种有效类型:文件、图像和媒体
content_css: "/tinymce/skins/content/default/content.css",
imagetools_toolbar: "editimage",
// 图片控制的工具栏
content_style: "img {max-width:100%;height:auto}",
// 图片最大宽度
// eslint-disable-next-line camelcase
images_upload_handler: (blobInfo) => {
return new Promise((resolve, reject) => {
const bolb = blobInfo.blob();
if (bolb.size > 2 * 1024 * 1024) {
reject(new Error("图片大于2M,请重新上传"));
} else {
resolve(`data:${bolb.type};base64,${blobInfo.base64()}`);
}
});
},
setup: (editor) => {
editor.on("blur", function() {
emit("update:modelValue", editor.getContent());
});
}
}
});
watch(
() => props.modelValue,
(newVal) => {
data.content = newVal;
}
);
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", _hoisted_1$7, [
createVNode(unref(TinymceVue), {
modelValue: data.content,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => data.content = $event),
disabled: __props.readonly,
class: "myTinymceVue",
init: data.init
}, null, 8, ["modelValue", "disabled", "init"])
]);
};
}
});
const index_vue_vue_type_style_index_0_scoped_eed126e2_lang = "";
const XTinymce = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-eed126e2"]]);
const index$1 = "";
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
modelValue: {
// 绑定的值
type: String,
default: ""
},
saveBy: {
type: String,
default: "save"
}
},
emits: ["update:modelValue"],
setup(__props, { emit: __emit }) {
const emit = __emit;
const props = __props;
const content = ref(props.modelValue);
function save(html) {
props.saveBy === "save" && emit("update:modelValue", html);
}
function change(html) {
props.saveBy === "change" && emit("update:modelValue", html);
}
watch(
() => props.modelValue,
(newVal) => {
content.value = newVal;
}
);
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(mavonEditor), {
modelValue: content.value,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => content.value = $event),
onSave: save,
onChange: change
}, null, 8, ["modelValue"]);
};
}
});
const _hoisted_1$6 = {
key: 0,
class: "title"
};
const _hoisted_2$5 = ["innerHTML"];
const _hoisted_3$3 = ["innerHTML"];
const _hoisted_4$3 = ["innerHTML"];
const _hoisted_5$3 = ["innerHTML"];
const _hoisted_6$2 = ["innerHTML"];
const _hoisted_7$1 = {
key: 0,
class: "x-btns"
};
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
// 生成Form的布局结构数组
schema: {
type: Array,
default: () => []
},
// 表单数据对象
model: {
type: Object,
default: () => ({})
},
hideBtn: {
type: Boolean,
default: false
}
},
emits: ["confirm", "cancel"],
setup(__props, { expose: __expose, emit: __emit }) {
const props = __props;
const emit = __emit;
const refForm = ref();
const aceEditor = ref();
const formData = ref(props.model);
function validateForm() {
return new Promise((resolve) => {
var _a;
(_a = refForm.value) == null ? void 0 : _a.validate((volid) => {
if (volid) {
resolve(formData.value);
}
resolve(false);
});
});
}
__expose({ validateForm, refForm });
function resetForm() {
var _a;
(_a = refForm.value) == null ? void 0 : _a.resetFields();
}
async function cancelForm() {
await resetForm();
emit("cancel");
}
const loading = ref(false);
async function confirmForm() {
const data = await validateForm();
if (data) {
loading.value = true;
emit("confirm", data, () => {
loading.value = false;
});
}
}
function disabledFun(item) {
if (item.inputProps && item.inputProps.disabled) {
if (typeof item.inputProps.disabled === "function") {
return item.inputProps.disabled(formData.value);
}
return item.inputProps.disabled;
}
return false;
}
watch(
() => props.model,
() => {
formData.value = props.model;
resetForm();
}
);
return (_ctx, _cache) => {
return openBlock(), createBlock(_sfc_main$f, null, {
default: withCtx(() => [
createVNode(unref(ElForm), mergeProps({
ref_key: "refForm",