yanzhen-design-vue
Version:
197 lines (196 loc) • 8.52 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const antDesignVue = require("ant-design-vue");
const dayjs = require("dayjs");
require("../../icon/src/icon.vue.cjs");
require("../../image-preview/index.cjs");
const message = require("./message.cjs");
const config = require("./config.cjs");
const viewerApi = require("../../image-preview/src/api/viewerApi.cjs");
const icon_vue_vue_type_script_setup_true_lang = require("../../icon/src/icon.vue2.cjs");
const _hoisted_1 = { class: "message-title" };
const _hoisted_2 = { class: "left" };
const _hoisted_3 = ["src", "onerror", "alt"];
const _hoisted_4 = {
key: 0,
class: "organization-name"
};
const _hoisted_5 = { class: "time" };
const _hoisted_6 = {
key: 0,
class: "message-content"
};
const _hoisted_7 = { key: 0 };
const _hoisted_8 = {
key: 0,
class: "record-file"
};
const _hoisted_9 = ["src"];
const _hoisted_10 = { key: 1 };
const _hoisted_11 = ["href"];
const _hoisted_12 = {
key: 1,
class: "message-content-text"
};
const _hoisted_13 = { key: 2 };
const _hoisted_14 = { class: "message-operates" };
const _hoisted_15 = {
key: 1,
class: "system-info"
};
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...{ name: message.messageName },
__name: "message",
props: message.messageExtraProps,
emits: message.messageExtraEmits,
setup(__props, { expose: __expose, emit: __emit }) {
const { class: wrapClass } = message.messageOptions;
const props = __props;
const emit = __emit;
const image = viewerApi.useViewerApi();
const $this = vue.reactive({
errorImg: config.ERROR_IMG,
systemIcon: config.SYSTEM_ICON
});
const recordType = vue.computed(() => {
return props.itemData.recordType;
});
const isImage = vue.computed(() => {
const recordFileName = props.itemData.recordFileName || "";
const fileType = recordFileName.split(".").reverse()[0];
return config.IMG_TYPES.includes(fileType);
});
const isAbledDelete = vue.computed(() => {
return config.DELETE_RECORD_TYPES.includes(recordType.value) && props.accountID === props.itemData.recordUser;
});
const isSystemType = vue.computed(() => {
const recordType2 = props.itemData.recordType;
return config.SYETEM_FLAG.includes(recordType2);
});
const Attributes = vue.computed(() => {
const recordFileUrl = props.itemData.recordFileUrl;
return {
url: recordFileUrl,
imgStyle: { width: "100px", height: "100px", borderRadius: "5px" },
imgUrls: [recordFileUrl]
};
});
const ismyMsg = vue.computed(() => {
const { recordUser } = props.itemData;
return recordUser === props.accountID;
});
const initData = () => {
const { recordTime, recordType: recordType2 } = props.itemData;
props.itemData.recordTime = dayjs(recordTime).format("YYYY-MM-DD HH:mm:ss");
if (config.SYETEM_FLAG.includes(recordType2)) {
props.itemData.recordUserIcon = $this.systemIcon;
}
};
const downloadItem = () => {
emit("download", props.itemData);
};
const deleteItem = async () => {
emit("delete", props.itemData);
};
const previewImage = (url) => {
if (!url) return;
image.preview([url], {
initialViewIndex: 0
});
};
const handleReply = () => {
antDesignVue.message.warning("回复功能暂未开发,敬请期待");
};
initData();
__expose({
handleReply
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass([vue.unref(wrapClass), "cl-message"])
}, [
vue.createElementVNode("div", _hoisted_1, [
vue.createElementVNode("div", _hoisted_2, [
vue.renderSlot(_ctx.$slots, "icon", {}, () => [
vue.createElementVNode("img", {
draggable: "false",
src: isSystemType.value ? $this.systemIcon : _ctx.itemData.recordUserIcon,
onerror: $this.errorImg,
alt: _ctx.itemData.recordUserName
}, null, 8, _hoisted_3)
]),
vue.createVNode(vue.unref(antDesignVue.Tooltip), null, {
title: vue.withCtx(() => [
vue.createTextVNode(vue.toDisplayString(isSystemType.value ? "系统动态" : _ctx.itemData.recordUserName + (_ctx.showOrganizationName && _ctx.itemData.organizationName ? "@" + _ctx.itemData.organizationName : "")), 1)
]),
default: vue.withCtx(() => [
vue.createElementVNode("span", null, [
vue.createTextVNode(vue.toDisplayString(isSystemType.value ? "系统动态" : _ctx.itemData.recordUserName), 1),
_ctx.showOrganizationName && _ctx.itemData.organizationName ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_4, "@" + vue.toDisplayString(_ctx.itemData.organizationName), 1)) : vue.createCommentVNode("", true)
])
]),
_: 1
})
]),
vue.createElementVNode("div", _hoisted_5, vue.toDisplayString(_ctx.itemData.recordTime), 1)
]),
!isSystemType.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6, [
_ctx.itemData.recordFileType == "1" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
vue.createTextVNode(vue.toDisplayString(_ctx.itemData.recordContent) + " ", 1),
isImage.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8, [
vue.createElementVNode("img", {
src: Attributes.value.url,
style: vue.normalizeStyle(Attributes.value.imgStyle),
alt: "",
onClick: _cache[0] || (_cache[0] = ($event) => previewImage(Attributes.value.url))
}, null, 12, _hoisted_9)
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_10, [
vue.createVNode(vue.unref(antDesignVue.Tooltip), null, {
title: vue.withCtx(() => [
vue.createTextVNode(vue.toDisplayString(_ctx.itemData.recordFileName), 1)
]),
default: vue.withCtx(() => [
vue.createElementVNode("a", {
href: _ctx.itemData.recordFileUrl,
target: "_blank",
onClick: vue.withModifiers(downloadItem, ["prevent"])
}, vue.toDisplayString(_ctx.itemData.recordFileName), 9, _hoisted_11)
]),
_: 1
})
]))
])) : _ctx.itemData.recordFileType == "2" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_12, vue.toDisplayString(_ctx.itemData.recordContent), 1)) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_13, vue.toDisplayString(_ctx.itemData.recordContent), 1)),
vue.createElementVNode("div", _hoisted_14, [
isAbledDelete.value && ismyMsg.value ? (vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.Popconfirm), {
key: 0,
placement: _ctx.messageOperatesPopPosition,
"ok-text": "确认",
"cancel-text": "取消",
"overlay-class-name": "clmessage-popconfirm",
onConfirm: deleteItem
}, {
icon: vue.withCtx(() => [
vue.createVNode(icon_vue_vue_type_script_setup_true_lang.default, { type: "question-circle" })
]),
title: vue.withCtx(() => _cache[1] || (_cache[1] = [
vue.createElementVNode("h3", null, "操作确认", -1),
vue.createElementVNode("p", { class: "clmessage-confim-text" }, "确认删除该条动态?", -1)
])),
default: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "delete-button", {}, () => [
vue.createVNode(icon_vue_vue_type_script_setup_true_lang.default, {
class: "item delete-icon",
type: "delete"
})
])
]),
_: 3
}, 8, ["placement"])) : vue.createCommentVNode("", true)
])
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_15, vue.toDisplayString(_ctx.itemData.recordContent), 1))
], 2);
};
}
});
exports.default = _sfc_main;