500 lines
19 KiB
Vue
500 lines
19 KiB
Vue
<template>
|
|
<a-spin size="large" :spinning="loading">
|
|
<div class="page-container">
|
|
<div class="page-header">
|
|
<a-row :gutter="[16, 8]">
|
|
<a-col :lg="8" :sm="24">
|
|
<a-row :wrap="false">
|
|
<a-col flex="none">
|
|
<div style="padding: 0 "><a-input flex="none" readonly value="用户名称"
|
|
class="site-input-split" style="width: 160px;border-radius:0; border-top-left-radius: 5pt 5pt;
|
|
border-bottom-left-radius: 5pt 5pt;
|
|
pointer-events: none" /></div>
|
|
</a-col>
|
|
<a-col flex="auto">
|
|
<a-input-search :disabled="isEdit" v-model:value="userName" flex="auto"
|
|
@search="onModalSearch" />
|
|
</a-col>
|
|
</a-row>
|
|
</a-col>
|
|
<a-col :lg="12" :sm="24">
|
|
<a-space>
|
|
<a-button type="primary" :disabled="isEdit" :icon="h(FileSearchOutlined)"
|
|
@click.prevent="onSearch">查询</a-button>
|
|
<a-button type="primary" :disabled="isEdit" :icon="h(ClearOutlined)"
|
|
@click.prevent="onReset">重置</a-button>
|
|
<a-button type="primary" :disabled="isEdit" :icon="h(FileAddOutlined)"
|
|
@click.prevent="onCreate">新增</a-button>
|
|
</a-space>
|
|
</a-col>
|
|
</a-row>
|
|
</div>
|
|
<div class="page-main" :style="{ height: resultH }">
|
|
<a-row :gutter="[16, 8]">
|
|
<a-col :lg="8" :sm="24">
|
|
<a-row :wrap="false" align="middle">
|
|
<a-col :lg="6" :sm="6" style="min-width: 80px;">
|
|
<span>用户名称:</span>
|
|
</a-col>
|
|
<a-col :lg="18" :sm="18" style="min-width: 300px;">
|
|
<a-input required :readonly="!isEdit || data.SecurityUser.UserName" v-model:value="data.SecurityUser.UserName" />
|
|
</a-col>
|
|
</a-row>
|
|
</a-col>
|
|
<a-col :lg="{ span: 8, offset: 2 }" :sm="24">
|
|
<a-row :wrap="false" align="middle">
|
|
<a-col :lg="6" :sm="6" style="min-width: 80px;">
|
|
<span>中文名称:</span>
|
|
</a-col>
|
|
<a-col :lg="18" :sm="18" style="min-width: 300px;">
|
|
<a-input required :readonly="!isEdit" v-model:value="data.SecurityUser.UserLocalName" />
|
|
</a-col>
|
|
</a-row>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row :gutter="[16, 8]" style="margin-top: 8px;">
|
|
<a-col :lg="8" :sm="24">
|
|
<a-row :wrap="false" align="middle">
|
|
<a-col :lg="6" :sm="6" style="min-width: 80px;">
|
|
<span>英文名称:</span>
|
|
</a-col>
|
|
<a-col :lg="18" :sm="18" style="min-width: 300px;">
|
|
<a-input :readonly="!isEdit" v-model:value="data.SecurityUser.UserEngName" />
|
|
</a-col>
|
|
</a-row>
|
|
</a-col>
|
|
<a-col :lg="{ span: 8, offset: 2 }" :sm="24">
|
|
<a-row :wrap="false" align="middle">
|
|
<a-col :lg="6" :sm="6" style="min-width: 80px;">
|
|
<span>手机:</span>
|
|
</a-col>
|
|
<a-col :lg="18" :sm="18" style="min-width: 300px;">
|
|
<a-input :readonly="!isEdit" v-model:value="data.SecurityUser.UserMobile" />
|
|
</a-col>
|
|
</a-row>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row :gutter="[16, 8]" style="margin-top: 8px;">
|
|
<a-col :lg="8" :sm="24">
|
|
<a-row :wrap="false" align="middle">
|
|
<a-col :lg="6" :sm="6" style="min-width: 80px;">
|
|
<span>登录密码:</span>
|
|
</a-col>
|
|
<a-col :lg="18" :sm="18" style="min-width: 300px;">
|
|
<a-input :readonly="!isEdit" v-model:value="data.SecurityUser.OrgUserPassword" />
|
|
</a-col>
|
|
</a-row>
|
|
</a-col>
|
|
<a-col :lg="{ span: 8, offset: 2 }" :sm="24">
|
|
</a-col>
|
|
</a-row>
|
|
<a-divider orientation="left" orientation-margin="0px" dashed style="background-color: silver">
|
|
|
|
</a-divider>
|
|
<a-collapse v-model:activeKey="activeKey">
|
|
<a-collapse-panel key="1" header="角色明细">
|
|
<a-table bordered :data-source="data.SecurityUserActors" :columns="columnActors"
|
|
:pagination="false" :scroll="{ x: 520, y: 600 }">
|
|
<template #bodyCell="datas">
|
|
<template v-if="datas.column.dataIndex === 'index'">
|
|
<span>{{ datas.index + 1 }}</span>
|
|
</template>
|
|
<template v-else-if="datas.column.dataIndex === 'operation' && isEdit">
|
|
<DeleteOutlined :style="{ fontSize: '24px', color: 'red' }"
|
|
@click="deleteActor(datas.record.ActorName)" />
|
|
</template>
|
|
<template
|
|
v-else-if="datas.column.dataIndex === SecurityUserActorViewEntity.ACTOR_NAME && !isEdit">
|
|
<span style="color: blue;font-size:18px;cursor: pointer;"
|
|
@click="onViewActorOperation(datas.record.ActorName)"> {{ datas.record.ActorName
|
|
}}</span>
|
|
</template>
|
|
</template>
|
|
</a-table>
|
|
<template #extra v-if="isEdit">
|
|
<PlusSquareTwoTone :style="{ fontSize: '24px', color: '#08c' }" @click="addActor" />
|
|
</template>
|
|
</a-collapse-panel>
|
|
</a-collapse>
|
|
</div>
|
|
<div class="page-footer">
|
|
<div style="">
|
|
<a-row :gutter="24">
|
|
<a-col :lg="24" :sm="24">
|
|
<div>
|
|
<a-row v-if="isEdit" :gutter="[16, 8]">
|
|
<a-space>
|
|
<a-popconfirm v-if="data.SecurityUser.CreatedBy" title="确定是否取消修改?" ok-text="是"
|
|
cancel-text="否" @confirm="onCancel">
|
|
<a-button type="primary" ghost :icon="h(UndoOutlined)">取消</a-button>
|
|
</a-popconfirm>
|
|
<a-button v-if="!data.SecurityUser.CreatedBy" type="primary" ghost
|
|
:icon="h(UndoOutlined)" @click.prevent="onCancel">取消</a-button>
|
|
<a-button type="primary" ghost :icon="h(SaveOutlined)"
|
|
@click.prevent="onSave">保存</a-button>
|
|
</a-space>
|
|
</a-row>
|
|
<a-row v-else :gutter="[16, 8]">
|
|
<a-space>
|
|
<a-button type="primary" v-if="canAmend" :icon="h(EditOutlined)"
|
|
:disabled="!hasData" @click.prevent="onAmend">修改</a-button>
|
|
<a-popconfirm :disabled="!hasData" title="确定是否删除这条记录?" ok-text="是"
|
|
cancel-text="否" @confirm="onDelete">
|
|
<a-button type="primary" danger :icon="h(DeleteOutlined)"
|
|
:disabled="!hasData" v-if="canDelete">无效</a-button>
|
|
</a-popconfirm>
|
|
</a-space>
|
|
</a-row>
|
|
</div>
|
|
</a-col>
|
|
</a-row>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<dragModal v-model:open="modelOption.isModalUser" width="80%" title="用户查询" :mask-closable="false"
|
|
:fullscreen="width < 640" @ok="handleSelect">
|
|
<UserEnquiry ref="enquiry" @on-row-dblclick="handleSelect"></UserEnquiry>
|
|
</dragModal>
|
|
<dragModal v-model:open="modelOption.isModalActor" width="80%" title="角色查询" :mask-closable="false"
|
|
:fullscreen="width < 640" @ok="handleSelectActor">
|
|
<ActorEnquiry ref="actorEnquiry" @on-row-dblclick="handleSelectActor"></ActorEnquiry>
|
|
</dragModal>
|
|
</a-spin>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import { ref, unref, onBeforeMount, inject, provide, h, onMounted } from "vue";
|
|
import { notification } from "ant-design-vue";
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { DeleteOutlined, EditOutlined, ClearOutlined, FileSearchOutlined, FileAddOutlined, UndoOutlined, SaveOutlined, PlusSquareTwoTone, DownSquareTwoTone, UpSquareTwoTone } from "@ant-design/icons-vue";
|
|
import { PermissionContext, usePermissionContext } from "@/hooks/PermissionContext"
|
|
import dragModal from "@/components/basic/DragModal.vue"
|
|
import UserEnquiry from "./UserEnquiry.vue";
|
|
import ActorEnquiry from "./ActorEnquiry.vue";
|
|
import { SecurityUserData } from "@/data/auto/securityUserData";
|
|
import { SecurityUserDisplayData } from "@/data/auto/securityUserDisplayData";
|
|
import securityUserService from "@/service/security/securityUserService";
|
|
import { SelectOption } from "@/data/auto/selectOption";
|
|
import { useWindowSize } from '@vueuse/core'
|
|
import { SecurityUserActorViewEntity } from "@/data/auto/securityUserActorViewEntity";
|
|
import { BindOption } from "@/data/custom/bindOption";
|
|
import { SecurityActorEntity } from "@/data/auto/securityActorEntity";
|
|
import { operationToEnquiryMethodKey, OperationToEnquiryModelOption } from "@/injections"
|
|
//================inject================
|
|
const loading = ref<boolean>(false);
|
|
//================inject================
|
|
|
|
const { width, height } = useWindowSize()
|
|
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
|
|
const userName = ref<string>(route.params.id as string)
|
|
const mode = ref<string>(route.params.mode as string)
|
|
|
|
const isEdit = ref<boolean>(false);
|
|
const canAmend = ref<boolean>(false);
|
|
const canDelete = ref<boolean>(false);
|
|
const canCreate = ref<boolean>(false);
|
|
|
|
const data = ref<SecurityUserData>(new SecurityUserData());
|
|
const hasData = ref<boolean>(false);
|
|
|
|
const resultH = ref('');
|
|
const oldUserName = ref<string>(userName.value);
|
|
|
|
interface UserEnquiry {
|
|
keys: SecurityUserDisplayData[],
|
|
setBindOptionValue(bindValue: string, value: string, value1: string, values: string[]): void,
|
|
}
|
|
|
|
|
|
interface ActorEnquiry {
|
|
keys: SecurityActorEntity[],
|
|
setBindOptionValue(bindValue: string, value: string, value1: string, values: string[]): void,
|
|
}
|
|
|
|
const enquiry = ref<UserEnquiry | null>(null)
|
|
const actorEnquiry = ref<ActorEnquiry | null>(null)
|
|
|
|
const activeKey = ref(['1', '2']);
|
|
|
|
const columnActors = ref([
|
|
{
|
|
title: '序号',
|
|
dataIndex: 'index',
|
|
width: '10%',
|
|
align: 'center',
|
|
fixed: 'left',
|
|
sequence: 0,
|
|
hidden: 'N',
|
|
format: ''
|
|
},
|
|
{
|
|
title: "角色名称",
|
|
dataIndex: SecurityUserActorViewEntity.ACTOR_NAME,
|
|
width: '30%',
|
|
sequence: 1,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "中文名称",
|
|
dataIndex: SecurityUserActorViewEntity.ACTOR_LOCAL_NAME,
|
|
width: '30%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "",
|
|
dataIndex: 'operation',
|
|
width: '5%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
}
|
|
]);
|
|
|
|
//================provide================
|
|
const modelOption = ref<OperationToEnquiryModelOption>(new OperationToEnquiryModelOption());
|
|
modelOption.value.isModalActor = false;
|
|
modelOption.value.isModalUser = false;
|
|
modelOption.value.selectionTypeActor = 'checkbox';
|
|
modelOption.value.selectionTypeUser = 'radio';
|
|
modelOption.value.initBindOptionsActor = [];
|
|
|
|
const getOperationToEnquiryModelOption = () => {
|
|
return modelOption.value
|
|
}
|
|
provide(
|
|
operationToEnquiryMethodKey,
|
|
{
|
|
getOperationToEnquiryModelOption,
|
|
}
|
|
);
|
|
//================provide================
|
|
|
|
onMounted(() => {
|
|
let pContext: PermissionContext = usePermissionContext();
|
|
canAmend.value = pContext.canAmend(route.meta.permission as string);
|
|
canDelete.value = pContext.canDelete(route.meta.permission as string);
|
|
canCreate.value = pContext.canCreate(route.meta.permission as string);
|
|
computResultTableHeight();
|
|
|
|
if (userName.value && userName.value.trim().length > 0) {
|
|
onSearch();
|
|
}
|
|
if (mode.value && mode.value == 'create') {
|
|
onCreate();
|
|
isEdit.value = true;
|
|
}
|
|
else if (mode.value && mode.value == 'amend') {
|
|
isEdit.value = true;
|
|
}
|
|
})
|
|
|
|
const computResultTableHeight = () => {
|
|
if (width.value > 640) {
|
|
resultH.value = 'calc(100vh - 220px )';
|
|
}
|
|
else {
|
|
resultH.value = 'calc(100vh - 250px )';
|
|
}
|
|
}
|
|
|
|
const onModalSearch = (() => {
|
|
modelOption.value.isModalUser = true;
|
|
})
|
|
|
|
|
|
const onSearch = (async () => {
|
|
|
|
if (!userName.value || userName.value.trim().length == 0) {
|
|
notification.info({
|
|
message: '系统提示:',
|
|
description: '请输入功能名称',
|
|
placement: "topRight",
|
|
});
|
|
hasData.value = false;
|
|
return;
|
|
}
|
|
|
|
data.value = await securityUserService.FindByKey(userName.value.trim());
|
|
|
|
if (data.value.SecurityUser == null) {
|
|
notification.info({
|
|
message: '系统提示:',
|
|
description: '记录不存在',
|
|
placement: "topRight",
|
|
});
|
|
data.value = new SecurityUserData();
|
|
hasData.value = false;
|
|
return;
|
|
}
|
|
|
|
|
|
hasData.value = true;
|
|
})
|
|
|
|
const onReset = (() => {
|
|
data.value = new SecurityUserData();
|
|
data.value.SecurityUserActors = [];
|
|
userName.value = '';
|
|
hasData.value = false;
|
|
})
|
|
|
|
const onCreate = (() => {
|
|
onReset();
|
|
isEdit.value = true;
|
|
})
|
|
|
|
const onAmend = (() => {
|
|
isEdit.value = true;
|
|
oldUserName.value = unref(data.value.SecurityUser.UserName);
|
|
})
|
|
|
|
const onSave = (async () => {
|
|
|
|
try {
|
|
loading.value = true;
|
|
|
|
if (!data.value.SecurityUserActors) data.value.SecurityUserActors = [];
|
|
|
|
if (data.value.SecurityUser?.CreatedBy)
|
|
data.value = await securityUserService.Update(data.value);
|
|
else {
|
|
data.value = await securityUserService.Insert(data.value);
|
|
}
|
|
|
|
userName.value = data.value.SecurityUser.UserName;
|
|
|
|
loading.value = false;
|
|
hasData.value = true;
|
|
isEdit.value = false;
|
|
|
|
} catch (error) {
|
|
loading.value = false;
|
|
console.log(error);
|
|
}
|
|
|
|
})
|
|
|
|
const onCancel = (() => {
|
|
onReset();
|
|
if (oldUserName.value && oldUserName.value.length > 0) {
|
|
userName.value = oldUserName.value;
|
|
onSearch();
|
|
}
|
|
isEdit.value = false;
|
|
})
|
|
|
|
const onDelete = (async () => {
|
|
try {
|
|
loading.value = true;
|
|
|
|
await securityUserService.Delete(data.value.SecurityUser.UserName);
|
|
|
|
onReset();
|
|
loading.value = false;
|
|
|
|
} catch (error) {
|
|
loading.value = false;
|
|
console.log(error);
|
|
}
|
|
})
|
|
|
|
|
|
const addActor = (event: MouseEvent) => {
|
|
modelOption.value.isModalActor = true;
|
|
// If you don't want click extra trigger collapse, you can prevent this:
|
|
event.stopPropagation();
|
|
};
|
|
|
|
const deleteActor = (key: string) => {
|
|
data.value.SecurityUserActors = data.value.SecurityUserActors.filter(item => item.ActorName !== key);
|
|
};
|
|
|
|
const handleSelect = (async () => {
|
|
if (enquiry.value) {
|
|
if (enquiry.value.keys.length > 0) {
|
|
//查询弹出
|
|
userName.value = enquiry.value.keys[0].UserName;
|
|
onSearch();
|
|
modelOption.value.isModalUser = false;
|
|
}
|
|
else {
|
|
notification.info({
|
|
message: '系统提示:',
|
|
description: '请选择一条记录',
|
|
placement: "topRight",
|
|
});
|
|
}
|
|
}
|
|
})
|
|
|
|
const handleSelectActor = (async () => {
|
|
if (actorEnquiry.value) {
|
|
if (actorEnquiry.value.keys.length > 0) {
|
|
//查询弹出
|
|
if (!data.value.SecurityUserActors) data.value.SecurityUserActors = [];
|
|
actorEnquiry.value.keys.forEach(element => {
|
|
if (data.value.SecurityUserActors.filter(item => item.ActorName == element.ActorName).length == 0) {
|
|
let ent: SecurityUserActorViewEntity = new SecurityUserActorViewEntity();
|
|
ent.ActorName = element.ActorName;
|
|
ent.ActorLocalName = element.ActorLocalName;
|
|
data.value.SecurityUserActors.push(ent);
|
|
}
|
|
});
|
|
modelOption.value.isModalActor = false;
|
|
}
|
|
else {
|
|
notification.info({
|
|
message: '系统提示:',
|
|
description: '请选择一条记录',
|
|
placement: "topRight",
|
|
});
|
|
}
|
|
}
|
|
})
|
|
|
|
const onViewActorOperation = ((actorName: string) => {
|
|
router.push({ name: "ActorOperation", params: { id: actorName, mode: 'view' } });
|
|
})
|
|
|
|
</script>
|
|
<style lang="less">
|
|
.page-container {
|
|
margin-right: 0px;
|
|
|
|
}
|
|
|
|
.page-header {
|
|
padding-top: 4px;
|
|
padding-bottom: 8px;
|
|
padding-right: 12px;
|
|
border-bottom: 1px solid silver;
|
|
margin-left: 6px;
|
|
}
|
|
|
|
.page-header .ant-input-search .ant-input {
|
|
border-radius: 0;
|
|
border-left: 0;
|
|
text-align: left
|
|
}
|
|
|
|
.page-main {
|
|
overflow-y: auto;
|
|
padding-top: 24px;
|
|
padding-bottom: 4px;
|
|
padding-right: 32px;
|
|
padding-left: 12px;
|
|
}
|
|
|
|
.page-footer {
|
|
z-index: 999;
|
|
padding-left: 8px;
|
|
padding-right: 18px;
|
|
padding-top: 8px;
|
|
width: 100%;
|
|
position: fixed;
|
|
bottom: 8px;
|
|
border-top: 1px solid silver;
|
|
}
|
|
</style> |