quick-admin-vue3-core
Version:
以快(计算机执行效率、开发效率)为核心的后台管理系统开发模板
427 lines (426 loc) • 15.7 kB
JavaScript
import { defineComponent as ee, ref as me, resolveComponent as k, resolveDirective as pe, createBlock as b, openBlock as g, withCtx as h, withDirectives as fe, renderSlot as Q, createElementBlock as U, reactive as H, watch as X, unref as A, isRef as ue, createElementVNode as l, createVNode as _, toDisplayString as I, Fragment as N, renderList as q, createTextVNode as B, createCommentVNode as ge } from "vue";
import { u as he, J as ve, I as Z, C as _e, K as Ie } from "./index-C0qRtkRj.js";
import { a as ye } from "./index-D-KS7NhM.js";
import { o as Ue } from "./_config-BPwT698v.js";
import { _ as te } from "./_plugin-vue_export-helper-CHgC5LLL.js";
import w from "./UserItem-DWqy3Co-.js";
import Ce from "./Index-D0h9eTyw.js";
import { u as Se } from "./index-CCwfAkxj.js";
import { D } from "./platform-DsTwHxm6.js";
import Me from "./SearchMsg-Bcl-qUOI.js";
const Be = {
key: 1,
class: "list-box f-1"
}, De = /* @__PURE__ */ ee({
__name: "Index",
props: {
summaryList: { type: [Boolean, Function] },
handleAuth: {}
},
emits: ["update:modelValue", "extraBtns", Ue, "selectionChange"],
setup(se, { expose: O, emit: P }) {
const L = me(null);
function u(s) {
s.page = s.page + 1, L.value.getList(s);
}
return O({
// ...crudRef.value
}), (s, r) => {
const a = k("BaseScroll"), V = k("BaseCrud"), z = pe("loading");
return g(), b(V, {
class: "custom-crud",
summaryList: s.summaryList,
pagination: !s.summaryList,
ref_key: "crudRef",
ref: L
}, {
content: h(({ loading: x, params: E, rows: C, total: y, hasMore: S }) => [
s.summaryList ? (g(), b(a, {
key: 0,
class: "f-1",
onReachBottom: (F) => u(E),
paddingBottom: S ? 0 : 250,
loading: x
}, {
default: h(() => [
Q(s.$slots, "list", {
list: C,
total: y,
hasMore: S
}, void 0, !0)
]),
_: 2
}, 1032, ["onReachBottom", "paddingBottom", "loading"])) : fe((g(), U("div", Be, [
Q(s.$slots, "list", {
list: C,
total: y,
hasMore: S
}, void 0, !0)
])), [
[z, x]
])
]),
_: 3
}, 8, ["summaryList", "pagination"]);
};
}
}), ke = /* @__PURE__ */ te(De, [["__scopeId", "data-v-482df0c7"]]), be = {
class: "f-sb-s f-1",
style: { height: "100%" }
}, Le = { class: "section f-1 f-fs-s-c" }, xe = { class: "header f-c-c f-0" }, $e = { class: "section f-1 f-fs-s-c" }, Re = { class: "header f-c-c f-0" }, Te = { class: "section f-2 f-fs-s-c" }, He = { class: "header f-sb-fe f-0" }, Ae = { class: "f-fs-c" }, Ne = { class: "f-fs-c" }, Oe = { class: "nickname q-line-1" }, Pe = { class: "f-fs-c" }, Ve = { class: "nickname q-line-1" }, ze = { class: "first-time q-line-1" }, Ee = {
key: 0,
class: "tips time"
}, G = 250, Fe = /* @__PURE__ */ ee({
name: "DemoCenterCrudChatCrud",
__name: "index",
setup(se) {
const { openPopup: O } = he(), { getSearchOpts: P } = Se(), L = [8001, 8003, 8004, 8005, 8006];
let u = H({});
const s = H({
loading: !1,
activeId: "",
list: [],
hasMore: !0,
total: 0,
params: {
page: 1,
pageSize: 10
}
}), r = H({
loading: !1,
activeId: "",
list: [],
hasMore: !0,
total: 0,
params: {
page: 1,
pageSize: 10
}
}), a = H({
loading: !1,
list: [],
prevHasMore: !0,
nextHasMore: !1,
total: 0,
params: {
// page: 1,
pageSize: 20,
prevCreatedAt: 0
},
headInfo: {
fromUser: {},
toUser: {},
firstDate: ""
}
}), V = [
{ prop: "fromUserId", label: "用户ID" },
{ prop: "fromUserCode", label: "号码牌" },
{ prop: "fromUserNickname", label: "昵称" },
{ prop: "toUserId", label: "好友ID" },
{ prop: "msgWord", label: "关键词" },
{ prop: "friendNumScope", label: "好友数量", type: "BaseNumberRange" },
P("school", { prop: "fromUserSchoolId", label: "学校" }),
P("company", { prop: "fromUserCompanyId", label: "公司" }),
{ prop: "fromUserRegisterTimeScope", label: "注册时间", type: "date-picker" },
{ prop: "chatTimeScope", label: "会话时间", type: "date-picker" }
];
X(
() => s.activeId,
(t) => {
r.params.page = 1, r.activeId = "", r.list = [], a.list = [], C(t);
},
{ immediate: !0 }
), X(
() => r.activeId,
async (t) => {
if (t) {
const e = u.msgWord, o = s.activeId, i = await S(o, t, e);
if (i) {
const { fromUser: m, toUser: c } = i;
K(m, c, e);
} else
a.params.prevCreatedAt = 0, y(s.activeId, t);
} else
a.list = [];
},
{ immediate: !1 }
);
function z(t, e, o = 3 * 60 * 1e3) {
return e === 0 || a.list[e - 1].create_time < t.create_time - o;
}
function x(t) {
const e = D().diff(D(t), "hours"), o = D().diff(D(t), "minutes");
return e > 1 ? D(t).format("YYYY-MM-DD HH:mm:ss") : o > 1 ? `${o}分钟前` : "刚刚";
}
async function E(t) {
var m, c;
const { hasMore: e, list: o } = s, { page: i } = s.params;
if (!(!e && i !== 1)) {
s.loading = !0;
try {
const p = await Ie(t), { list: v, total: n, hasMore: d, currentPage: f } = p;
f === 1 && (s.params.page = 1), Object.assign(
s,
{
list: f === 1 ? v : o.concat(v),
total: n,
hasMore: d
},
f === 1 ? { activeId: ((c = (m = v == null ? void 0 : v[0]) == null ? void 0 : m.fromUserData) == null ? void 0 : c.id) ?? "" } : void 0
);
} catch (p) {
console.error(p);
} finally {
s.loading = !1;
}
}
}
function C(t) {
if (!t) return;
const { hasMore: e, list: o, params: i } = r, { page: m } = i;
!e && m !== 1 || (r.loading = !0, ve({
fromUserId: t,
msgWord: u.msgWord,
chatTimeScope: u.chatTimeScope,
...i
}).then((c) => {
const { list: p, total: v, hasMore: n, currentPage: d } = c;
d === 1 && (r.params.page = 1), Object.assign(r, {
list: d === 1 ? p : o.concat(p),
total: v,
hasMore: n
});
}).finally(() => {
r.loading = !1;
}));
}
function y(t, e, o = "prev") {
if (!t || !e) return;
const { prevHasMore: i, nextHasMore: m, list: c, params: p } = a, { page: v, prevCreatedAt: n } = p, d = n === 0;
if (!d) {
if (o === "next" && !m)
return;
if (o === "prev" && !i)
return;
}
a.loading = !0, Z({
fromUserId: t,
toUserId: e,
queryDirection: o,
...p
}).then((f) => {
const { list: M, total: oe, hasMore: ne, firstDate: re, fromUser: $, toUser: R } = f, W = M.map((T) => {
const { msgContent: j = {}, ...le } = T, { Data: ce, Ext: de } = T.msgContent;
return j.Data = JSON.parse(ce || "{}"), j.Ext = JSON.parse(de || "{}"), {
fromUser: $.id === T.fromUserId ? $ : R,
toUser: R.id === T.toUserId ? R : $,
msgContent: j,
...le
};
}), ie = d ? W : o === "next" ? [...c, ...W] : [...W, ...c];
Object.assign(a, {
list: ie,
total: oe,
[`${o}HasMore`]: ne,
headInfo: {
firstDate: re,
fromUser: $,
toUser: R
}
});
}).finally(() => {
a.loading = !1;
});
}
async function S(t, e, o) {
if (o)
return await Z({
fromUserId: t,
toUserId: e,
msgWord: o
}).then((i) => {
var m;
if (((m = i == null ? void 0 : i.list) == null ? void 0 : m.length) >= 2) {
const { fromUser: c, toUser: p } = i;
return { fromUser: c, toUser: p };
} else
return null;
}).catch(() => null);
}
function F(t, e) {
var o;
t === "from" ? (s.activeId = (o = e == null ? void 0 : e.fromUserData) == null ? void 0 : o.id, r.params.page = 1) : t === "to" && (r.activeId = e.toUserData.id, Object.assign(a, {
nextHasMore: !0,
prevHasMore: !0,
prevCreatedAt: 0
}));
}
function Y(t) {
t === "from" ? (s.params.page++, E({ ...u, ...s.params })) : t === "to" && (r.params.page++, C(s.activeId));
}
function J(t) {
const e = t === "prev" ? a.list[0] : a.list.slice(-1)[0];
e && (a.params.prevCreatedAt = e.create_time + (t === "prev" ? -1 : 1), y(s.activeId, r.activeId, t));
}
function K(t, e, o) {
O(`【${t.nickname || "-"}】与【${e.nickname || "-"}】的聊天记录搜索`, [
Me,
{ fromUser: t, toUser: e, keyWord: o, onSelect: ae }
]);
}
function ae(t, e, o) {
a.list = [], a.prevHasMore = !0, a.nextHasMore = !0, a.params.prevCreatedAt = t.create_time + 1, y(s.activeId, r.activeId), o();
}
return (t, e) => {
const o = k("BaseScroll"), i = k("el-tooltip"), m = k("el-button");
return g(), b(ke, {
modelValue: A(u),
"onUpdate:modelValue": e[5] || (e[5] = (c) => ue(u) ? u.value = c : u = c),
fields: V,
fetch: A(_e),
pageAttrs: { pageSizes: [5, 10, 15, 20, 25] },
pagination: { currPage: 1, pageSize: 10 },
showPagination: !1
}, {
list: h(({ list: c, total: p, hasMore: v }) => [
l("div", be, [
l("section", Le, [
l("header", xe, [
l("b", null, "搜索结果 (" + I(s.list.length) + "/" + I(s.total) + ")", 1)
]),
_(o, {
class: "f-1",
onReachBottom: e[0] || (e[0] = (n) => Y("from")),
paddingBottom: s.hasMore ? 0 : G,
loading: s.loading,
emptyTips: "换个姿势搜搜看~"
}, {
default: h(() => [
(g(!0), U(N, null, q(s.list, (n, d) => {
var f;
return g(), b(w, {
userDataKey: "fromUserData",
onClick: (M) => F("from", n),
data: n,
active: s.activeId === ((f = n == null ? void 0 : n.fromUserData) == null ? void 0 : f.id),
isSearchResult: "",
key: d
}, null, 8, ["onClick", "data", "active"]);
}), 128))
]),
_: 2
}, 1032, ["paddingBottom", "loading"])
]),
l("section", $e, [
l("header", Re, [
l("b", null, "TA的好友 (" + I(r.list.length) + "/" + I(r.total) + ")", 1)
]),
_(o, {
class: "f-1",
onReachBottom: e[1] || (e[1] = (n) => Y("to")),
paddingBottom: r.hasMore ? 0 : G,
loading: r.loading,
emptyTips: s.activeId ? "暂无好友哦~" : "请在左侧选择用户"
}, {
default: h(() => [
(g(!0), U(N, null, q(r.list, (n, d) => (g(), b(w, {
userDataKey: "toUserData",
onClick: (f) => F("to", n),
data: n,
active: r.activeId === n.toUserData.id,
key: d
}, null, 8, ["onClick", "data", "active"]))), 128))
]),
_: 2
}, 1032, ["paddingBottom", "loading", "emptyTips"])
]),
l("section", Te, [
l("header", He, [
l("div", Ae, [
l("div", Ne, [
e[6] || (e[6] = B(" 【 ")),
_(i, {
content: a.headInfo.fromUser.nickname
}, {
default: h(() => [
l("span", Oe, I(a.headInfo.fromUser.nickname || "-"), 1)
]),
_: 1
}, 8, ["content"]),
e[7] || (e[7] = B("】 "))
]),
e[10] || (e[10] = l("div", null, "与", -1)),
l("div", Pe, [
e[8] || (e[8] = B(" 【 ")),
_(i, {
content: a.headInfo.toUser.nickname
}, {
default: h(() => [
l("span", Ve, I(a.headInfo.toUser.nickname || "-"), 1)
]),
_: 1
}, 8, ["content"]),
e[9] || (e[9] = B(" 】 "))
]),
e[11] || (e[11] = l("div", { class: "q-line-1" }, "的聊天记录", -1))
]),
_(i, {
content: "首次建立会话时间:" + a.headInfo.firstDate
}, {
default: h(() => [
l("span", ze, I(a.headInfo.firstDate), 1)
]),
_: 1
}, 8, ["content"]),
_(m, {
onClick: e[2] || (e[2] = (n) => K(a.headInfo.fromUser, a.headInfo.toUser, A(u).msgWord)),
icon: A(ye),
size: "small",
disabled: !r.activeId,
type: "primary",
class: "ml-o",
plain: "",
round: ""
}, {
default: h(() => e[12] || (e[12] = [
B("搜索")
])),
_: 1
}, 8, ["icon", "disabled"])
]),
_(o, {
class: "f-1",
"padding-top": "16",
paddingBottom: a.hasMore ? 16 : G,
loading: a.loading,
topHasMore: a.prevHasMore,
onReachTop: e[3] || (e[3] = (n) => J("prev")),
onReachBottom: e[4] || (e[4] = (n) => J("next")),
emptyTips: r.activeId ? "暂无聊天记录哦~" : "请在左侧选择TA的好友"
}, {
default: h(() => [
(g(!0), U(N, null, q(a.list, (n, d) => {
var f, M;
return g(), U(N, { key: d }, [
z(n, d) ? (g(), U("div", Ee, I(x(n.create_time)), 1)) : ge("", !0),
_(Ce, {
data: n,
userInfo: a.headInfo[`${r.activeId === n.fromUser.id ? "to" : "from"}User`],
position: n.msgType === "TIMCustomElem" && !L.includes((M = (f = n.msgContent) == null ? void 0 : f.Data) == null ? void 0 : M.type) ? "center" : r.activeId === n.fromUser.id ? "left" : "right"
}, null, 8, ["data", "userInfo", "position"])
], 64);
}), 128))
]),
_: 2
}, 1032, ["paddingBottom", "loading", "topHasMore", "emptyTips"])
])
])
]),
_: 1
}, 8, ["modelValue", "fetch"]);
};
}
}), we = /* @__PURE__ */ te(Fe, [["__scopeId", "data-v-75b008c5"]]);
export {
we as default
};