yuang-framework-ui-pc
Version:
yuang-framework-ui-pc Library
225 lines (224 loc) • 9.35 kB
JavaScript
import { defineComponent, mergeModels, useModel, ref, resolveComponent, createBlock, openBlock, withCtx, createVNode, createElementVNode, withKeys, unref, createCommentVNode, toDisplayString, createTextVNode, nextTick } from "vue";
import { Monitor, Close, Check } from "@element-plus/icons-vue";
import RoleList from "./role-list";
import { toTree } from "../../utils/core";
import { http } from "yuang-framework-ui-common/lib/config/httpConfig";
import { application } from "yuang-framework-ui-common/lib/config/applicationConfig";
import { SearchOutlined, ApplicationOutlined } from "../../icons";
const _hoisted_1 = { style: { "padding": "0 16px 12px 0" } };
const _sfc_main = /* @__PURE__ */ defineComponent({
...{ name: "UimsRoleV2" },
__name: "role-dialog",
props: /* @__PURE__ */ mergeModels({
param: {}
}, {
"modelValue": { type: Boolean },
"modelModifiers": {}
}),
emits: /* @__PURE__ */ mergeModels(["change"], ["update:modelValue"]),
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const isOpenDialog = useModel(__props, "modelValue");
const splitRef = ref(null);
const treeRef = ref(null);
const treeData = ref([]);
const roleListRef = ref(null);
const isLoading = ref(true);
const isShowTree = ref(true);
const selectedApplication = ref(null);
const applicationName = ref("");
const queryPage = async () => {
let data = { parentIdForEqual: "0", nameForLike: applicationName.value };
isLoading.value = true;
const res = await http.post(`${application.gatewayServerBaseUrl}/uims-api/admin/uims-application/selectPage`, data);
isLoading.value = false;
const listData = [
{
id: "0",
name: "全部应用",
isHasChildren: true,
isLeaf: false,
levelNum: 0,
parentId: ""
},
...res.data.data.records
];
treeData.value = toTree({
data: listData,
idField: "id",
parentIdField: "parentId"
});
nextTick(() => {
handleNodeClick(listData[0] || { id: "0" });
});
};
const handleNodeClick = (row) => {
var _a, _b;
if (row && row.id) {
selectedApplication.value = row;
(_b = (_a = treeRef.value) == null ? void 0 : _a.setCurrentKey) == null ? void 0 : _b.call(_a, row.id);
} else {
selectedApplication.value = null;
}
};
const initQueryPage = async () => {
applicationName.value ? { queryForMode: "treePart", parentIdForEqual: "0", nameForLike: applicationName.value } : null;
reloadTree();
};
const reloadTree = () => {
isShowTree.value = false;
nextTick(() => {
isShowTree.value = true;
});
};
const handleCancel = () => {
isOpenDialog.value = false;
};
const handleSure = () => {
handleCancel();
emit("change", roleListRef.value.selections);
};
queryPage();
return (_ctx, _cache) => {
const _component_el_input = resolveComponent("el-input");
const _component_el_icon = resolveComponent("el-icon");
const _component_el_tree = resolveComponent("el-tree");
const _component_ele_loading = resolveComponent("ele-loading");
const _component_ele_split_panel = resolveComponent("ele-split-panel");
const _component_ele_card = resolveComponent("ele-card");
const _component_ele_page = resolveComponent("ele-page");
const _component_el_button = resolveComponent("el-button");
const _component_ele_dialog = resolveComponent("ele-dialog");
return openBlock(), createBlock(_component_ele_dialog, {
form: "",
width: "85%",
modelValue: isOpenDialog.value,
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isOpenDialog.value = $event),
title: "选择角色",
class: "yu-big-dialog"
}, {
footer: withCtx(() => [
createVNode(_component_el_button, {
icon: unref(Close),
onClick: handleCancel
}, {
default: withCtx(() => _cache[2] || (_cache[2] = [
createTextVNode("取消")
])),
_: 1,
__: [2]
}, 8, ["icon"]),
createVNode(_component_el_button, {
type: "primary",
icon: unref(Check),
loading: isLoading.value,
onClick: handleSure
}, {
default: withCtx(() => _cache[3] || (_cache[3] = [
createTextVNode(" 确认 ")
])),
_: 1,
__: [3]
}, 8, ["icon", "loading"])
]),
default: withCtx(() => [
createVNode(_component_ele_page, {
"flex-table": "",
"multi-card": false,
"hide-footer": "",
style: { "min-height": "720px" }
}, {
default: withCtx(() => [
createVNode(_component_ele_card, {
"flex-table": "",
"body-style": { padding: "0 0 0 16px", overflow: "hidden" }
}, {
default: withCtx(() => [
createVNode(_component_ele_split_panel, {
ref_key: "splitRef",
ref: splitRef,
"flex-table": "",
size: "256px",
"allow-collapse": "",
"custom-style": { borderWidth: "0 1px 0 0", padding: "16px 0" },
"body-style": { padding: "16px 16px 0 0", overflow: "hidden" },
style: { height: "100%", overflow: "visible" }
}, {
body: withCtx(() => [
selectedApplication.value && selectedApplication.value.id ? (openBlock(), createBlock(RoleList, {
key: 0,
ref_key: "roleListRef",
ref: roleListRef,
application: selectedApplication.value,
param: props.param
}, null, 8, ["application", "param"])) : createCommentVNode("", true)
]),
default: withCtx(() => [
createElementVNode("div", _hoisted_1, [
createVNode(_component_el_input, {
modelValue: applicationName.value,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => applicationName.value = $event),
placeholder: "输入应用名称后按回车搜索",
"prefix-icon": unref(SearchOutlined),
clearable: "",
maxlength: 20,
onKeyup: withKeys(initQueryPage, ["enter"]),
onClear: initQueryPage
}, null, 8, ["modelValue", "prefix-icon"])
]),
createVNode(_component_ele_loading, {
loading: isLoading.value,
style: { flex: 1, paddingRight: "16px", overflow: "auto" }
}, {
default: withCtx(() => [
isShowTree.value ? (openBlock(), createBlock(_component_el_tree, {
key: 0,
ref_key: "treeRef",
ref: treeRef,
"node-key": "id",
data: treeData.value,
"highlight-current": "",
props: { label: "name", children: "children", isLeaf: "isLeaf" },
"expand-on-click-node": false,
style: { "--ele-tree-item-height": "34px" },
"default-expand-all": true,
onNodeClick: handleNodeClick
}, {
default: withCtx(({ data }) => [
createElementVNode("span", null, [
createVNode(_component_el_icon, {
size: 15,
style: { "margin-right": "8px", "vertical-align": "-2px" }
}, {
default: withCtx(() => [
data.id == "0" ? (openBlock(), createBlock(unref(ApplicationOutlined), { key: 0 })) : (openBlock(), createBlock(unref(Monitor), { key: 1 }))
]),
_: 2
}, 1024),
createElementVNode("span", null, toDisplayString(data.name), 1)
])
]),
_: 1
}, 8, ["data"])) : createCommentVNode("", true)
]),
_: 1
}, 8, ["loading"])
]),
_: 1
}, 512)
]),
_: 1
})
]),
_: 1
})
]),
_: 1
}, 8, ["modelValue"]);
};
}
});
export {
_sfc_main as default
};