302 lines
11 KiB
Vue
302 lines
11 KiB
Vue
<template>
|
|
<search-card @on-submit="onSubmit" @on-reset="onReset" @use-pagination="onPagination" :is-modal="isModal"
|
|
:loading="loading" :pagination="result" :rowSelectionType="selectionType"
|
|
:card-title-keys="[SecurityHelpFunctionEntity.FUNCTION_NAME]" @on-row-dblclick="onRowDblclick"
|
|
@on-select-change="onSelectChange">
|
|
<template #control>
|
|
<a-button type="primary" v-if="canCreate && !isModal" :icon="h(FileAddOutlined)"
|
|
@click.prevent="onCreate">新增</a-button>
|
|
</template>
|
|
<template #bodyCell="{ column, record }">
|
|
<template v-if="column.dataIndex === SecurityHelpFunctionEntity.ENABLED_INDC">
|
|
<span v-if="record.EnabledIndc == 'Y'">是</span>
|
|
<span v-else>否</span>
|
|
</template>
|
|
</template>
|
|
<template #footer>
|
|
<div v-if="!isModal" class="page-footer">
|
|
<a-row :gutter="24">
|
|
<a-col :lg="24" :sm="24">
|
|
<a-row :gutter="[16, 8]">
|
|
<a-space>
|
|
<a-button type="primary" v-if="canView" :icon="h(FileTextOutlined)"
|
|
:disabled="!(keys && keys.length == 1)" @click.prevent="onView">查看</a-button>
|
|
<a-button type="primary" v-if="canAmend" :icon="h(EditOutlined)"
|
|
:disabled="!(keys && keys.length == 1)" @click.prevent="onAmend">修改</a-button>
|
|
<a-popconfirm title="确定是否删除这条记录?" ok-text="是" cancel-text="否" @confirm="onDelete">
|
|
<a-button type="primary" danger :icon="h(DeleteOutlined)" v-if="canDelete"
|
|
:disabled="!(keys && keys.length > 0)">删除</a-button>
|
|
</a-popconfirm>
|
|
</a-space>
|
|
</a-row>
|
|
</a-col>
|
|
</a-row>
|
|
</div>
|
|
</template>
|
|
</search-card>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { reactive, inject, onMounted, ref, unref, provide, h } from "vue";
|
|
import { notification } from "ant-design-vue";
|
|
import { BindOption } from "@/data/custom/bindOption";
|
|
import searchCard from "@/components/basic/SearchCard.vue";
|
|
import { DeleteOutlined, EditOutlined, FileAddOutlined, FileTextOutlined } from "@ant-design/icons-vue";
|
|
|
|
import { SecurityHelpFunctionResultData } from "@/data/auto/securityHelpFunctionResultData";
|
|
import { SecurityHelpFunctionEntity } from "@/data/auto/securityHelpFunctionEntity";
|
|
import { SearchFilter } from "@/data/auto/searchFilter"
|
|
import securityHelpFunctionService from "@/service/security/securityHelpFunctionService";
|
|
import { SecurityHelpFunctionSearchCriteria } from "@/data/auto/securityHelpFunctionSearchCriteria";
|
|
|
|
import { SearchCriteriaResultData } from "@/data/auto/searchCriteriaResultData";
|
|
import { PermissionContext, usePermissionContext } from "@/hooks/PermissionContext"
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
|
import { useBindOption } from "@/hooks/useBindOption";
|
|
import { SearchFilterOperatorPolicy } from "@/data/custom/searchFilterOperatorPolicy"
|
|
import { SearchFilterTypePolicy } from "@/data/custom/searchFilterTypePolicy"
|
|
import { OperationToEnquiryModelOption, operationToEnquiryMethodKey, enquiryMethodKey, searchCriteriaManagerKey } from "@/injections";
|
|
import { useOrderedChildren } from "@/hooks/use-ordered-children";
|
|
import { SearchCriteriaContext } from "@/injections";
|
|
|
|
//================inject================
|
|
const operationMethod = inject(operationToEnquiryMethodKey, undefined);
|
|
const modelOption = operationMethod?.getOperationToEnquiryModelOption() as OperationToEnquiryModelOption;
|
|
|
|
const isModal = ref(modelOption ? !!modelOption.isModalHelpFunction : false);
|
|
const selectionType = modelOption ? modelOption.selectionTypeHelpFunction ?? 'radio' : 'checkbox';
|
|
const initBindOptions = ref((modelOption ? modelOption.initBindOptionsHelpFunction : []) as BindOption[]);
|
|
//================inject================
|
|
|
|
const emit = defineEmits(['onRowDblclick']);
|
|
|
|
const loading = ref<boolean>(false);
|
|
const canView = ref<boolean>(false);
|
|
const canAmend = ref<boolean>(false);
|
|
const canDelete = ref<boolean>(false);
|
|
const canCreate = ref<boolean>(false);
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
|
|
const columns = ref([
|
|
{
|
|
title: '序号',
|
|
dataIndex: 'index',
|
|
width: '5%',
|
|
align: 'center',
|
|
fixed: 'left',
|
|
sequence: 0,
|
|
hidden: 'N',
|
|
format: ''
|
|
},
|
|
{
|
|
title: "功能名称",
|
|
dataIndex: SecurityHelpFunctionEntity.FUNCTION_NAME,
|
|
sorter: true,
|
|
width: '20%',
|
|
sequence: 1,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "功能说明",
|
|
dataIndex: SecurityHelpFunctionEntity.INTRO,
|
|
sorter: true,
|
|
width: '45%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "启用?",
|
|
dataIndex: SecurityHelpFunctionEntity.ENABLED_INDC,
|
|
sorter: true,
|
|
width: '10%',
|
|
sequence: 3,
|
|
hidden: 'N'
|
|
},
|
|
]);
|
|
|
|
const viewOption = {
|
|
Value: 'default',
|
|
SelectOptions: [{ BindValue: 'default', DisplayName: "默认" }],
|
|
Columns: [{ BindValue: 'default', BindColumn: columns }]
|
|
};
|
|
|
|
const bindOptions = ref<BindOption[]>([]);
|
|
|
|
const datas = ref<SecurityHelpFunctionEntity[]>([]);
|
|
const pagingParams = ref<PagingParams>({ pageSize: 20, page: 1 });
|
|
const result = ref<SearchCriteriaResultData>(new SearchCriteriaResultData());
|
|
|
|
const data = ref<SecurityHelpFunctionResultData>(new SecurityHelpFunctionResultData());
|
|
|
|
const isSearched = ref<boolean>(false);
|
|
const currentSearchCriteria = ref<SecurityHelpFunctionSearchCriteria>(new SecurityHelpFunctionSearchCriteria());
|
|
|
|
const keys = ref<SecurityHelpFunctionEntity[]>([]);
|
|
|
|
const {
|
|
children: items,
|
|
addChild: addItem,
|
|
removeChild: removeItem,
|
|
} = useOrderedChildren<SearchCriteriaContext>();
|
|
|
|
//================provide================
|
|
provide(enquiryMethodKey, {
|
|
getLayoutSetting: () => { return { controlLeft: 16, controlRight: 8, space: true, soltLeft: 24, soltRight: 24 }; },
|
|
getBindOptions: () => { return unref(bindOptions); },
|
|
getViewOption: () => { return unref(viewOption); },
|
|
getDatas: () => { return datas; },
|
|
});
|
|
|
|
provide(
|
|
searchCriteriaManagerKey,
|
|
reactive({
|
|
items,
|
|
addItem,
|
|
removeItem,
|
|
})
|
|
);
|
|
//================provide================
|
|
|
|
defineExpose({
|
|
keys,
|
|
initBindOptions,
|
|
})
|
|
|
|
onMounted(() => {
|
|
let pContext: PermissionContext = usePermissionContext();
|
|
canView.value = pContext.canView(route.meta.permission as string);
|
|
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);
|
|
initBindOption();
|
|
onSearch();
|
|
})
|
|
|
|
const onSelectChange = ((selected: SecurityHelpFunctionEntity[]) => {
|
|
keys.value = selected;
|
|
})
|
|
|
|
const onRowDblclick = ((e: any, record: SecurityHelpFunctionEntity) => {
|
|
if (isModal.value) {
|
|
emit('onRowDblclick', record);
|
|
}
|
|
else {
|
|
router.push({ name: "SecurityHelpFunctionOperation", params: { id: record.FunctionName, mode: 'view' } });
|
|
}
|
|
})
|
|
|
|
const onReset = (() => {
|
|
keys.value = [];
|
|
result.value.Total = 0;
|
|
})
|
|
|
|
const onView = (() => {
|
|
if (keys.value.length == 0) return;
|
|
router.push({ name: "SecurityHelpFunctionOperation", params: { id: keys.value[0].FunctionName, mode: 'view' } });
|
|
})
|
|
|
|
const onCreate = (() => {
|
|
router.push({ name: "SecurityHelpFunctionOperation", params: { id: '', mode: 'create' } });
|
|
})
|
|
|
|
const onAmend = (() => {
|
|
if (keys.value.length == 0) return;
|
|
router.push({ name: "SecurityHelpFunctionOperation", params: { id: keys.value[0].FunctionName, mode: 'amend' } });
|
|
})
|
|
|
|
const onDelete = (async () => {
|
|
for (let i = 0; i < keys.value.length; i++) {
|
|
await securityHelpFunctionService.DeleteByFunctionName(keys.value[i].FunctionName);
|
|
}
|
|
|
|
notification.info({
|
|
message: '系统提示:',
|
|
description: '记录删除成功',
|
|
placement: "topRight",
|
|
});
|
|
onReload();
|
|
})
|
|
|
|
const setBindOptionValue = ((bindValue: string, value: string, value1: string, values: string[], disabled: boolean) => {
|
|
let bindOption: BindOption = bindOptions.value.filter(x => x.BindValue == bindValue)[0];
|
|
if (!bindOption) return;
|
|
bindOption.Value = value;
|
|
bindOption.Value1 = value1;
|
|
bindOption.Values = values;
|
|
bindOption.disabled = disabled;
|
|
})
|
|
|
|
//初始化查询条件
|
|
const initBindOption = (async () => {
|
|
let ubo = useBindOption();
|
|
let bindOption: BindOption = ubo.getBindOption(SecurityHelpFunctionEntity.DB_FUNCTION_NAME, '功能名称', SearchFilterTypePolicy.TEXT, SearchFilterOperatorPolicy.CONTAIN);
|
|
bindOptions.value.push(bindOption);
|
|
|
|
bindOption = ubo.getBindOption(SecurityHelpFunctionEntity.DB_INTRO, '功能说明', SearchFilterTypePolicy.TEXT, SearchFilterOperatorPolicy.CONTAIN);
|
|
bindOption.lg = 10;
|
|
bindOptions.value.push(bindOption);
|
|
|
|
initBindOptions.value.forEach(element => {
|
|
setBindOptionValue(element.BindValue, element.Value, element.Value1, element.Values, element.disabled);
|
|
});
|
|
})
|
|
|
|
//table from-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
result.value.Page = pagingParams.value.page ?? 1;
|
|
result.value.Limit = pagingParams.value.pageSize;
|
|
|
|
const onSubmit = (async (filters: SearchFilter[]) => {
|
|
|
|
let c: SecurityHelpFunctionSearchCriteria = new SecurityHelpFunctionSearchCriteria();
|
|
|
|
isSearched.value = true;
|
|
c.Filter = filters;
|
|
c.limit = pagingParams.value.pageSize;
|
|
c.page = pagingParams.value.page ?? 1;
|
|
c.GridColumns = [];
|
|
currentSearchCriteria.value = c;
|
|
await findBySearchCriteria(c);
|
|
})
|
|
|
|
const onSearch = (async () => {
|
|
onSubmit(items.value[0].getFilter());
|
|
})
|
|
|
|
const findBySearchCriteria = (async (c: SecurityHelpFunctionSearchCriteria) => {
|
|
try {
|
|
data.value = await securityHelpFunctionService.FindBySearchCriteria(c);
|
|
result.value.Total = data.value.Total;
|
|
result.value.Page = data.value.Page;
|
|
result.value.Limit = data.value.Limit;
|
|
datas.value = data.value.Datas;
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
})
|
|
|
|
const onPagination = (async (params: PagingParams) => {
|
|
|
|
if (!isSearched.value) return;
|
|
let c: SecurityHelpFunctionSearchCriteria = new SecurityHelpFunctionSearchCriteria();
|
|
|
|
c.Filter = items.value[0].getFilter();
|
|
|
|
c.limit = params.pageSize;
|
|
c.page = params.page ?? 1;
|
|
if (params.sortField)
|
|
c.orderby = params.sortField!;
|
|
if (params.sortOrder)
|
|
c.orderbytag = params.sortOrder?.toString().substring(0, 4)!;
|
|
c.GridColumns = [];
|
|
currentSearchCriteria.value = c;
|
|
await findBySearchCriteria(c);
|
|
});
|
|
|
|
const onReload = (async () => {
|
|
await findBySearchCriteria(unref(currentSearchCriteria));
|
|
})
|
|
//table end-----------------------------------------------------------------------------------------------------------------------------------
|
|
</script>
|