yanzhen-design-vue
Version:
213 lines (212 loc) • 9.77 kB
JavaScript
import { defineComponent, openBlock, createElementBlock, Fragment, unref, createCommentVNode, createVNode, normalizeClass, withCtx, createElementVNode, createBlock, renderList, isRef, renderSlot, toDisplayString } from "vue";
import { SearchOutlined, DeleteOutlined } from "@ant-design/icons-vue";
import { Row, Col, Input, Tabs } from "ant-design-vue";
import "./list/contacts-list.vue.mjs";
import "./list/contacts-group.vue.mjs";
import "./item/contacts-selected-icon.vue.mjs";
import { useContacts } from "./use-contacts.mjs";
import { contactsName, contactsProps, contactsEmits, contactsOptions } from "./contacts.mjs";
import _sfc_main$1 from "./list/contacts-group.vue2.mjs";
import _sfc_main$2 from "./item/contacts-selected-icon.vue2.mjs";
import _sfc_main$3 from "./list/contacts-list.vue2.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
...{ name: contactsName },
__name: "contacts",
props: contactsProps,
emits: contactsEmits,
setup(__props, { expose: __expose, emit: __emit }) {
const { ns } = contactsOptions;
const props = __props;
const emit = __emit;
const {
ctx: {
_ref,
_dataSource,
_query,
searchQueryList,
_contactsTabs,
_activeTab,
_userTabs,
_userActiveTab,
_noMore,
_placeholder,
_leftElRef,
_rightElRef,
_loading,
_selectedValue,
_selectedIds,
_disabledIds,
_isTreeMode,
multiple,
selectState,
allExpand
},
methods,
handleSearch,
handleLoadMore,
handleTreeExpand,
handleTreeSelect,
handleDelete,
handleItemClick,
handleTabChange,
handleAllSelectTrigger
} = useContacts(props, emit);
__expose({
ref: _ref,
selectState,
refresh: handleTabChange,
allSelectTrigger: handleAllSelectTrigger,
...methods
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock(Fragment, null, [
unref(multiple) && _ctx.$slots["all-select"] && unref(_query).keywords.length === 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [], 64)) : createCommentVNode("", true),
createVNode(unref(Row), {
class: normalizeClass([unref(ns).b()])
}, {
default: withCtx(() => [
createVNode(unref(Col), {
ref_key: "_leftElRef",
ref: _leftElRef,
class: normalizeClass([unref(ns).e("left")]),
span: 12
}, {
default: withCtx(() => [
createElementVNode("div", {
class: normalizeClass([unref(ns).e("list-header")])
}, [
createVNode(unref(Input), {
value: unref(_query).keywords,
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => unref(_query).keywords = $event),
valueModifiers: { trim: true },
placeholder: unref(_placeholder),
"allow-clear": "",
onChange: unref(handleSearch),
onPressEnter: _cache[1] || (_cache[1] = () => unref(handleSearch)(true))
}, {
suffix: withCtx(() => [
createVNode(unref(SearchOutlined))
]),
_: 1
}, 8, ["value", "placeholder", "onChange"]),
unref(_query).keywords.length === 0 ? (openBlock(), createBlock(unref(Tabs), {
key: 0,
"active-key": unref(_activeTab),
"onUpdate:activeKey": unref(handleTabChange)
}, {
default: withCtx(() => [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(_contactsTabs), (item) => {
return openBlock(), createBlock(unref(Tabs).TabPane, {
key: item.value,
tab: item.label
}, null, 8, ["tab"]);
}), 128))
]),
_: 1
}, 8, ["active-key", "onUpdate:activeKey"])) : createCommentVNode("", true)
], 2),
unref(_query).keywords.length !== 0 ? (openBlock(), createElementBlock("div", {
key: 0,
class: normalizeClass([unref(ns).e("list-main"), unref(ns).is("search")])
}, [
createVNode(_sfc_main$1, {
"all-expand": "",
loading: unref(_query).loading,
"empty-text": "没有满足条件的数据!",
"selected-ids": unref(_selectedIds),
"active-tab": unref(_activeTab),
"disable-ids": unref(_disabledIds),
"data-source": unref(searchQueryList),
onItemClick: unref(handleItemClick),
onSuffixClick: unref(handleItemClick)
}, {
suffix: withCtx(({ item }) => {
var _a, _b;
return [
createVNode(_sfc_main$2, {
class: normalizeClass([unref(ns).is("search-selected-icon")]),
multiple: unref(multiple),
disabled: (_a = unref(_disabledIds)) == null ? void 0 : _a.includes(item.value),
checked: (_b = unref(_selectedIds)) == null ? void 0 : _b.includes(item == null ? void 0 : item.value)
}, null, 8, ["class", "multiple", "disabled", "checked"])
];
}),
_: 1
}, 8, ["loading", "selected-ids", "active-tab", "disable-ids", "data-source", "onItemClick", "onSuffixClick"])
], 2)) : (openBlock(), createElementBlock("div", {
key: 1,
class: normalizeClass([unref(ns).e("list-main")])
}, [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(_contactsTabs), (tab) => {
return openBlock(), createElementBlock(Fragment, {
key: tab.value
}, [
tab.value === unref(_activeTab) ? (openBlock(), createBlock(_sfc_main$3, {
key: tab.value,
loading: unref(_loading),
"onUpdate:loading": _cache[2] || (_cache[2] = ($event) => isRef(_loading) ? _loading.value = $event : null),
"child-active-tab": unref(_userActiveTab),
"onUpdate:childActiveTab": _cache[3] || (_cache[3] = ($event) => isRef(_userActiveTab) ? _userActiveTab.value = $event : null),
"active-tab": tab.value,
"data-source": unref(_dataSource),
disabled: unref(_noMore),
"child-tabs": unref(_userTabs),
"is-tree-mode": unref(_isTreeMode),
multiple: unref(multiple),
"selected-value": unref(_selectedValue),
"selected-ids": unref(_selectedIds),
"disable-ids": unref(_disabledIds),
onLoadMore: unref(handleLoadMore),
onTreeExpand: unref(handleTreeExpand),
onTreeSelect: unref(handleTreeSelect),
onItemClick: unref(handleItemClick)
}, null, 8, ["loading", "child-active-tab", "active-tab", "data-source", "disabled", "child-tabs", "is-tree-mode", "multiple", "selected-value", "selected-ids", "disable-ids", "onLoadMore", "onTreeExpand", "onTreeSelect", "onItemClick"])) : createCommentVNode("", true)
], 64);
}), 128))
], 2))
]),
_: 1
}, 8, ["class"]),
createVNode(unref(Col), {
ref_key: "_rightElRef",
ref: _rightElRef,
class: normalizeClass([unref(ns).e("right")]),
span: 12
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "right", {}, () => [
createVNode(_sfc_main$1, {
"all-expand": unref(allExpand),
"active-tab": unref(_activeTab),
"disable-ids": unref(_disabledIds),
"data-source": unref(_selectedValue),
onSuffixClick: unref(handleDelete)
}, {
title: withCtx(() => {
var _a;
return [
createElementVNode("span", null, "已选择的数据(" + toDisplayString((_a = unref(_selectedValue)) == null ? void 0 : _a.length) + ")", 1)
];
}),
suffix: withCtx(({ item }) => [
!unref(_disabledIds).includes(item.value) ? (openBlock(), createBlock(unref(DeleteOutlined), {
key: 0,
class: normalizeClass([unref(ns).e("delete-icon")])
}, null, 8, ["class"])) : createCommentVNode("", true)
]),
_: 1
}, 8, ["all-expand", "active-tab", "disable-ids", "data-source", "onSuffixClick"])
])
]),
_: 3
}, 8, ["class"])
]),
_: 3
}, 8, ["class"])
], 64);
};
}
});
export {
_sfc_main as default
};