yuang-framework-ui-pc
Version:
yuang-framework-ui-pc Library
234 lines (233 loc) • 7.6 kB
JavaScript
"use strict";
const vue = require("vue");
const RoleQuery = require("./role-query");
const httpConfig = require("yuang-framework-ui-common/lib/config/httpConfig");
const frameworkEnum = require("yuang-framework-ui-common/lib/hooks/framework/frameworkEnum");
const objectUtils = require("yuang-framework-ui-common/lib/utils/objectUtils");
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...{ name: "UimsUserList" },
__name: "role-list",
props: {
param: {},
uimsApplication: {},
selectionList: {}
},
emits: ["update:selectionList"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const queryRef = vue.ref(null);
const tableRef = vue.ref(null);
const columns = vue.ref([
{
type: "selection",
columnKey: "selection",
width: 50,
align: "center",
fixed: "left",
selectable: (row) => {
return !row.isRoleExistsUser;
}
},
{
type: "index",
columnKey: "index",
label: "编号",
width: 70,
align: "center",
fixed: "left"
},
{
prop: "name",
label: "角色名称",
sortable: "custom",
minWidth: 200,
align: "left",
slot: "name"
},
{
prop: "code",
label: "角色代码",
sortable: "custom",
minWidth: 180,
align: "left"
},
{
prop: "status",
label: "状态",
width: 90,
align: "center",
sortable: "custom",
slot: "status"
},
{
prop: "remark",
label: "备注",
minWidth: 240,
align: "center"
},
{
prop: "sequence",
label: "排序号",
sortable: "custom",
width: 100,
align: "center"
},
{
prop: "createUserName",
label: "创建人",
sortable: "custom",
width: 100,
align: "center"
},
{
prop: "createTime",
label: "创建时间",
sortable: "custom",
width: 180,
align: "center"
},
{
prop: "lastUpdateUserName",
label: "最后更新人",
sortable: "custom",
width: 120,
align: "center"
},
{
prop: "lastUpdateTime",
label: "最后更新时间",
sortable: "custom",
width: 180,
align: "center"
},
{
columnKey: "action",
label: "操作",
width: 80,
align: "center",
slot: "action",
fixed: "right"
}
]);
const selections = vue.ref([]);
const tableList = vue.ref([]);
const { statusEnumList } = frameworkEnum.useStatusEnumList();
vue.onMounted(() => {
initSelectionList();
});
const initSelectionList = () => {
selections.value = objectUtils.deepClone(props.selectionList ?? []);
console.log("props.param", props.param);
console.log("selections.value", selections.value);
};
const datasource = async ({ queryParam, pageParam, orderParamList }) => {
var _a, _b;
const data = {
...queryParam,
...pageParam,
orderParamList,
uimsApplicationIdForEqual: props.uimsApplication.id,
// 查询角色存在的用户id
selectRoleExistsUserIdForEqual: ((_a = props.param) == null ? void 0 : _a.isDisableSelectRoleOfExistsUser) && ((_b = props.param) == null ? void 0 : _b.selectRoleExistsUserId),
// 是否排除所有人角色
isExcludeEveryOne: true
};
const res = await httpConfig.http.post(`/uims-api/admin/uims-role/selectPage`, data);
tableList.value = res.data.data.records;
return res.data.data;
};
const queryPage = () => {
var _a, _b, _c;
selections.value = [];
(_c = (_a = tableRef.value) == null ? void 0 : _a.reload) == null ? void 0 : _c.call(_a, { currentPage: 1, queryParam: (_b = queryRef.value) == null ? void 0 : _b.queryForm });
};
vue.watch(
() => props.uimsApplication.id,
() => {
var _a, _b;
(_b = (_a = queryRef.value) == null ? void 0 : _a.resetFields) == null ? void 0 : _b.call(_a);
queryPage();
initSelectionList();
}
);
vue.watch(
() => selections.value,
(newSelections) => {
let tempSelections = objectUtils.deepClone(newSelections ?? []);
let updateSelectionList = objectUtils.deepClone(props.selectionList ?? []);
tempSelections.forEach((item) => {
const isRepeat = updateSelectionList.some((old) => old.id === item.id);
if (!isRepeat) {
updateSelectionList.push(item);
}
});
updateSelectionList = updateSelectionList.filter((item) => {
return tempSelections.some((newItem) => newItem.id === item.id) || !tableList.value.some((t) => t.id === item.id);
});
console.log("updateSelectionList", updateSelectionList);
emit("update:selectionList", updateSelectionList);
}
);
return (_ctx, _cache) => {
const _component_el_tag = vue.resolveComponent("el-tag");
const _component_ele_pro_table = vue.resolveComponent("ele-pro-table");
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
vue.createVNode(RoleQuery, {
ref_key: "queryRef",
ref: queryRef,
style: { "margin-bottom": "-14px" },
onQuery: queryPage
}, null, 512),
vue.createVNode(_component_ele_pro_table, {
ref_key: "tableRef",
ref: tableRef,
"row-key": "id",
border: "",
sticky: false,
columns: columns.value,
datasource,
"show-overflow-tooltip": true,
selections: selections.value,
"onUpdate:selections": _cache[0] || (_cache[0] = ($event) => selections.value = $event),
"highlight-current-row": true,
"header-cell-style": { "text-align": "center" },
"footer-style": { paddingBottom: "16px" }
}, {
name: vue.withCtx(({ row }) => [
vue.createTextVNode(vue.toDisplayString(row.name) + " ", 1),
row.isSystemRole ? (vue.openBlock(), vue.createBlock(_component_el_tag, {
key: 0,
type: "warning",
"disable-transitions": true
}, {
default: vue.withCtx(() => _cache[1] || (_cache[1] = [
vue.createTextVNode("系统角色")
])),
_: 1,
__: [1]
})) : vue.createCommentVNode("", true)
]),
status: vue.withCtx(({ row }) => [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(statusEnumList), (item, index) => {
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
row.status == item.value ? (vue.openBlock(), vue.createBlock(_component_el_tag, {
type: item.tagType,
"disable-transitions": true,
key: index
}, {
default: vue.withCtx(() => [
vue.createTextVNode(vue.toDisplayString(item.name), 1)
]),
_: 2
}, 1032, ["type"])) : vue.createCommentVNode("", true)
], 64);
}), 256))
]),
_: 1
}, 8, ["columns", "selections"])
], 64);
};
}
});
module.exports = _sfc_main;