ow
This commit is contained in:
1 parent
1404640f16
commit
2bbf016cbf
167 files changed
+18941
-589
No files matched your search
@@ -0,0 +1,475 @@
|
||||
<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="permissionName" 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 :maxlength="50" required :readonly="!isEdit"
|
||||
v-model:value="data.SecurityPermission.PermissionName" />
|
||||
</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 :maxlength="500" required :readonly="!isEdit"
|
||||
v-model:value="data.SecurityPermission.Description" />
|
||||
</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 :maxlength="50" :readonly="!isEdit"
|
||||
v-model:value="data.SecurityPermission.Dependent" />
|
||||
</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-select v-model:value="data.SecurityPermission.DelegateIndc" :disabled="!isEdit"
|
||||
style="width: 100%;min-width:124px;">
|
||||
<a-select-option v-for="o in yesNoPolicy" :value="o.BindValue">{{
|
||||
o.DisplayName }}</a-select-option>
|
||||
</a-select>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</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.SecurityPermissionDependents" :columns="columnDependents"
|
||||
: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 === SecurityPermissionDependentEntity.DEPENDENT_DETAIL_NAME && isEdit">
|
||||
<a-input :maxlength="50" required
|
||||
v-model:value="datas.record.DependentDetailName" />
|
||||
</template>
|
||||
<template
|
||||
v-else-if="datas.column.dataIndex === SecurityPermissionDependentEntity.DEPENDENT_DETAIL_NAME && !isEdit">
|
||||
{{ datas.record.DependentDetailName }}
|
||||
</template>
|
||||
<template
|
||||
v-else-if="datas.column.dataIndex === SecurityPermissionDependentEntity.DEPENDENT_DETAIL_DESCRIPTION && isEdit">
|
||||
<a-input :maxlength="500" required
|
||||
v-model:value="datas.record.DependentDetailDescription" />
|
||||
</template>
|
||||
<template
|
||||
v-else-if="datas.column.dataIndex === SecurityPermissionDependentEntity.DEPENDENT_DETAIL_DESCRIPTION && !isEdit">
|
||||
{{ datas.record.DependentDetailDescription }}
|
||||
</template>
|
||||
<template v-else-if="datas.column.dataIndex === 'operation' && isEdit">
|
||||
<DeleteOutlined :style="{ fontSize: '24px', color: 'red' }"
|
||||
@click="deleteDependent(datas.record.DependentDetailName)" />
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
<template #extra v-if="isEdit">
|
||||
<PlusSquareTwoTone :style="{ fontSize: '24px', color: '#08c' }" @click="addDependent" />
|
||||
</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.SecurityPermission.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.SecurityPermission.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.isModalPermission" width="80%" title="权限查询" :mask-closable="false"
|
||||
:fullscreen="width < 640" @ok="handleSelect">
|
||||
<PermissionEnquiry ref="enquiry" @on-row-dblclick="handleSelect"></PermissionEnquiry>
|
||||
</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 PermissionEnquiry from "./PermissionEnquiry.vue";
|
||||
import { SecurityPermissionData } from "@/data/auto/securityPermissionData";
|
||||
import { SecurityPermissionDependentEntity } from "@/data/auto/securityPermissionDependentEntity";
|
||||
import SecurityPermissionService from "@/service/security/securityPermissionService";
|
||||
import { useYesNoPolicy } from "@/hooks/useYesNoPolicy"
|
||||
import { SelectOption } from "@/data/auto/selectOption";
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { SecurityPermissionEntity } from "@/data/auto/securityPermissionEntity";
|
||||
import { BindOption } from "@/data/custom/bindOption";
|
||||
import { nextTick } from "process";
|
||||
import { operationToEnquiryMethodKey, OperationToEnquiryModelOption } from "@/injections"
|
||||
|
||||
const loading = ref<boolean>(false);
|
||||
const { width, height } = useWindowSize()
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const permissionName = 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 showModalType = ref<number>(0);
|
||||
|
||||
const data = ref<SecurityPermissionData>(new SecurityPermissionData());
|
||||
const hasData = ref<boolean>(false);
|
||||
|
||||
const yesNoPolicy = ref<SelectOption[]>([]);
|
||||
const resultH = ref('');
|
||||
const oldPermissionName = ref<string>(permissionName.value);
|
||||
|
||||
|
||||
interface PermissionEnquiry {
|
||||
keys: SecurityPermissionEntity[],
|
||||
setBindOptionValue(bindValue: string, value: string, value1: string, values: string[]): void,
|
||||
}
|
||||
|
||||
const enquiry = ref<PermissionEnquiry | null>(null)
|
||||
const activeKey = ref(['1']);
|
||||
|
||||
const columnDependents = ref([
|
||||
{
|
||||
title: '序号',
|
||||
dataIndex: 'index',
|
||||
width: '10%',
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
sequence: 0,
|
||||
hidden: 'N',
|
||||
format: ''
|
||||
},
|
||||
{
|
||||
title: "扩展名称",
|
||||
dataIndex: SecurityPermissionDependentEntity.DEPENDENT_DETAIL_NAME,
|
||||
width: '30%',
|
||||
sequence: 1,
|
||||
hidden: 'N'
|
||||
},
|
||||
{
|
||||
title: "中文名称",
|
||||
dataIndex: SecurityPermissionDependentEntity.DEPENDENT_DETAIL_DESCRIPTION,
|
||||
width: '50%',
|
||||
sequence: 2,
|
||||
hidden: 'N'
|
||||
},
|
||||
{
|
||||
title: "",
|
||||
dataIndex: 'operation',
|
||||
width: '5%',
|
||||
sequence: 3,
|
||||
hidden: 'N'
|
||||
}
|
||||
]);
|
||||
|
||||
//================provide================
|
||||
const modelOption = ref<OperationToEnquiryModelOption>(new OperationToEnquiryModelOption());
|
||||
modelOption.value.isModalPermission = false;
|
||||
modelOption.value.selectionTypePermission = 'radio';
|
||||
modelOption.value.initBindOptionsPermission = [];
|
||||
|
||||
const getOperationToEnquiryModelOption = () => {
|
||||
return modelOption.value
|
||||
}
|
||||
provide(
|
||||
operationToEnquiryMethodKey,
|
||||
{
|
||||
getOperationToEnquiryModelOption,
|
||||
}
|
||||
);
|
||||
|
||||
//================provide================
|
||||
|
||||
onBeforeMount(async () => {
|
||||
yesNoPolicy.value = await useYesNoPolicy().getSelectOption(false);
|
||||
})
|
||||
|
||||
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 (permissionName.value && permissionName.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.isModalPermission = true;
|
||||
modelOption.value.selectionTypePermission = 'radio';
|
||||
showModalType.value = 0;
|
||||
})
|
||||
|
||||
const onSearch = (async () => {
|
||||
|
||||
if (!permissionName.value || permissionName.value.trim().length == 0) {
|
||||
notification.info({
|
||||
message: '系统提示:',
|
||||
description: '请输入权限名称',
|
||||
placement: "topRight",
|
||||
});
|
||||
hasData.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
data.value = await SecurityPermissionService.FindByKey(permissionName.value.trim());
|
||||
|
||||
if (data.value.SecurityPermission == null) {
|
||||
notification.info({
|
||||
message: '系统提示:',
|
||||
description: '记录不存在',
|
||||
placement: "topRight",
|
||||
});
|
||||
data.value = new SecurityPermissionData();
|
||||
hasData.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
hasData.value = true;
|
||||
})
|
||||
|
||||
const onReset = (() => {
|
||||
data.value = new SecurityPermissionData();
|
||||
data.value.SecurityPermissionDependents = [];
|
||||
|
||||
permissionName.value = '';
|
||||
hasData.value = false;
|
||||
})
|
||||
|
||||
const onCreate = (() => {
|
||||
onReset();
|
||||
isEdit.value = true;
|
||||
})
|
||||
|
||||
const onAmend = (() => {
|
||||
isEdit.value = true;
|
||||
oldPermissionName.value = unref(data.value.SecurityPermission.PermissionName);
|
||||
})
|
||||
|
||||
const onSave = (async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
|
||||
if (!data.value.SecurityPermissionDependents) data.value.SecurityPermissionDependents = [];
|
||||
|
||||
if (data.value.SecurityPermission?.CreatedBy)
|
||||
data.value = await SecurityPermissionService.Update(data.value);
|
||||
else {
|
||||
data.value = await SecurityPermissionService.Insert(data.value);
|
||||
}
|
||||
|
||||
permissionName.value = data.value.SecurityPermission.PermissionName;
|
||||
|
||||
loading.value = false;
|
||||
hasData.value = true;
|
||||
isEdit.value = false;
|
||||
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
}
|
||||
})
|
||||
|
||||
const onCancel = (() => {
|
||||
onReset();
|
||||
if (oldPermissionName.value && oldPermissionName.value.length > 0) {
|
||||
permissionName.value = oldPermissionName.value;
|
||||
onSearch();
|
||||
}
|
||||
isEdit.value = false;
|
||||
})
|
||||
|
||||
const onDelete = (async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
|
||||
await SecurityPermissionService.Delete(data.value.SecurityPermission.PermissionName);
|
||||
|
||||
onReset();
|
||||
loading.value = false;
|
||||
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
console.log(error);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const addDependent = (event: MouseEvent) => {
|
||||
if (!data.value.SecurityPermissionDependents) data.value.SecurityPermissionDependents = [];
|
||||
|
||||
data.value.SecurityPermissionDependents.push(new SecurityPermissionDependentEntity());
|
||||
// If you don't want click extra trigger collapse, you can prevent this:
|
||||
event.stopPropagation();
|
||||
};
|
||||
|
||||
const deleteDependent = (key: string) => {
|
||||
data.value.SecurityPermissionDependents = data.value.SecurityPermissionDependents.filter(item => item.DependentDetailName !== key);
|
||||
};
|
||||
|
||||
const handleSelect = (async () => {
|
||||
if (enquiry.value) {
|
||||
if (enquiry.value.keys.length > 0) {
|
||||
//查询弹出
|
||||
if (showModalType.value == 0) {
|
||||
permissionName.value = enquiry.value.keys[0].PermissionName;
|
||||
|
||||
onSearch();
|
||||
}
|
||||
modelOption.value.isModalPermission = false;
|
||||
|
||||
}
|
||||
else {
|
||||
notification.info({
|
||||
message: '系统提示:',
|
||||
description: '请选择一条记录',
|
||||
placement: "topRight",
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
</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;
|
||||
}
|
||||
|
||||
.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>
|
||||
Reference in new issue
Block a user