384 lines
14 KiB
Vue
384 lines
14 KiB
Vue
<template>
|
|
<search-card @on-submit="onSubmit" @on-print="onPrint" @on-reset="onReset" @use-pagination="onPagination"
|
|
:is-modal="isModal" :loading="loading" :pagination="result" :rowSelectionType="selectionType"
|
|
:card-title-keys="[SecurityMasterEntity.MASTER_CATEGORY, SecurityMasterEntity.MASTER_CODE_ITEM]"
|
|
@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, index }">
|
|
<template v-if="column.dataIndex === SecurityMasterEntity.VALID_INDC">
|
|
<template v-if="record.FunctionIndc == 'Y'">
|
|
<span>是</span>
|
|
</template>
|
|
<template v-else> <span>否</span></template>
|
|
</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, defineComponent, onMounted, ref, unref, provide, h } from "vue";
|
|
import { BindOption } from "@/data/custom/bindOption";
|
|
import { SelectOption } from "@/data/auto/selectOption";
|
|
import searchCard from "@/components/basic/SearchCard.vue";
|
|
import { DeleteOutlined, EditOutlined, FileAddOutlined, FileTextOutlined } from "@ant-design/icons-vue";
|
|
|
|
import { SecurityMasterResultData } from "@/data/auto/securityMasterResultData";
|
|
import { SecurityMasterEntity } from "@/data/auto/securityMasterEntity";
|
|
import { SecurityMasterEntityKey } from "@/data/auto/securityMasterEntityKey";
|
|
import { SearchFilter } from "@/data/auto/searchFilter"
|
|
import securityMasterService from "@/service/security/securityMasterService";
|
|
import { SecurityMasterSearchCriteria } from "@/data/auto/securityMasterSearchCriteria";
|
|
|
|
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 { notification } from "ant-design-vue";
|
|
import { GridColumnInfo } from "@/data/auto/gridColumnInfo"
|
|
import { useGridColumnInfo } from "@/hooks/gridColumnInfo"
|
|
import { title } from "process";
|
|
import { enquiryMethodKey, searchCriteriaManagerKey, operationToEnquiryMethodKey, OperationToEnquiryModelOption, layoutProviderMethodKey } from "@/injections";
|
|
import { useOrderedChildren } from "@/hooks/use-ordered-children";
|
|
import { SearchCriteriaContext } from "@/injections";
|
|
//page from-----------------------------------------------------------------------------------------------------------------------------------
|
|
//================inject================
|
|
const actorOperationMethod = inject(operationToEnquiryMethodKey, undefined);
|
|
const modelOption = actorOperationMethod?.getOperationToEnquiryModelOption() as OperationToEnquiryModelOption;
|
|
|
|
const isModal = ref(modelOption ? modelOption.isModalMaster : false);
|
|
const selectionType = modelOption ? modelOption.selectionTypeMaster : 'checkbox';
|
|
const initBindOptions = ref((modelOption ? modelOption.initBindOptionsMaster : []) as BindOption[]);
|
|
//报表名称(layout)
|
|
const layoutProviderMethod = inject(layoutProviderMethodKey);
|
|
|
|
//================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: SecurityMasterEntity.MASTER_CATEGORY,
|
|
sorter: true,
|
|
width: '15%',
|
|
sequence: 1,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "辅类别",
|
|
dataIndex: SecurityMasterEntity.MASTER_SUBCATEGORY,
|
|
sorter: true,
|
|
width: '15%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "项目名称",
|
|
dataIndex: SecurityMasterEntity.MASTER_CODE_ITEM,
|
|
sorter: true,
|
|
width: '10%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "中文描述",
|
|
dataIndex: SecurityMasterEntity.LOCAL_DESCRIPTION,
|
|
sorter: true,
|
|
width: '10%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "英文描述",
|
|
dataIndex: SecurityMasterEntity.ENG_DESCRIPTION,
|
|
sorter: true,
|
|
width: '10%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "排序",
|
|
dataIndex: SecurityMasterEntity.ORDER_BY,
|
|
sorter: true,
|
|
width: '5%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "有效?",
|
|
dataIndex: SecurityMasterEntity.VALID_INDC,
|
|
sorter: true,
|
|
width: '8%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "备注",
|
|
dataIndex: SecurityMasterEntity.REMARK,
|
|
sorter: true,
|
|
width: '20%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
]);
|
|
|
|
const viewOption = {
|
|
Value: 'default',
|
|
SelectOptions: [{ BindValue: 'default', DisplayName: "默认" }],
|
|
Columns: [{ BindValue: 'default', BindColumn: columns }]
|
|
};
|
|
|
|
const bindOptions = ref<BindOption[]>([]);
|
|
|
|
const datas = ref<SecurityMasterEntity[]>([]);
|
|
const pagingParams = ref<PagingParams>({ pageSize: 20, page: 1 });
|
|
const result = ref<SearchCriteriaResultData>(new SearchCriteriaResultData());
|
|
|
|
const data = ref<SecurityMasterResultData>(new SecurityMasterResultData());
|
|
|
|
const isSearched = ref<boolean>(false);
|
|
const currentSearchCriteria = ref<SecurityMasterSearchCriteria>(new SecurityMasterSearchCriteria());
|
|
|
|
const keys = ref<SecurityMasterEntity[]>([]);
|
|
|
|
const {
|
|
children: items,
|
|
addChild: addItem,
|
|
removeChild: removeItem,
|
|
} = useOrderedChildren<SearchCriteriaContext>();
|
|
|
|
//================provide================
|
|
//初始化查询条件UI(search)
|
|
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: SecurityMasterEntity[]) => {
|
|
keys.value = selected;
|
|
})
|
|
|
|
const onRowDblclick = ((e: any, record: SecurityMasterEntity) => {
|
|
if (isModal.value) {
|
|
emit('onRowDblclick', record);
|
|
}
|
|
else {
|
|
router.push({ name: "MasterOperation", params: { id: record.MasterCategory + "|" + record.MasterSubcategory + "|" + record.MasterCodeItem, mode: 'view' } });
|
|
}
|
|
})
|
|
|
|
const onReset = (() => {
|
|
keys.value = [];
|
|
result.value.Total = 0;
|
|
})
|
|
|
|
const onView = (() => {
|
|
if (keys.value.length == 0) return;
|
|
router.push({ name: "MasterOperation", params: { id: keys.value[0].MasterCategory + "|" + keys.value[0].MasterSubcategory + "|" + keys.value[0].MasterCodeItem, mode: 'view' } });
|
|
})
|
|
|
|
const onCreate = (() => {
|
|
router.push({ name: "MasterOperation", params: { id: '', mode: 'create' } });
|
|
})
|
|
|
|
const onAmend = (() => {
|
|
if (keys.value.length == 0) return;
|
|
router.push({ name: "MasterOperation", params: { id: keys.value[0].MasterCategory + "|" + keys.value[0].MasterSubcategory + "|" + keys.value[0].MasterCodeItem, mode: 'amend' } });
|
|
})
|
|
|
|
const onDelete = (async () => {
|
|
let key: SecurityMasterEntityKey = new SecurityMasterEntityKey();
|
|
|
|
for (let i = 0; i < keys.value.length; i++) {
|
|
key.MasterCategory = keys.value[i].MasterCategory;
|
|
key.MasterSubcategory = keys.value[i].MasterSubcategory;
|
|
key.MasterCodeItem = keys.value[i].MasterCodeItem;
|
|
await securityMasterService.Delete(key);
|
|
}
|
|
|
|
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(SecurityMasterEntity.DB_MASTER_CATEGORY, '主类别', SearchFilterTypePolicy.TEXT, SearchFilterOperatorPolicy.CONTAIN);
|
|
bindOptions.value.push(bindOption);
|
|
|
|
bindOption = ubo.getBindOption(SecurityMasterEntity.DB_MASTER_SUBCATEGORY, '辅类别', SearchFilterTypePolicy.TEXT, SearchFilterOperatorPolicy.CONTAIN);
|
|
bindOption.lg = 10;
|
|
bindOptions.value.push(bindOption);
|
|
|
|
bindOption = ubo.getBindOption(SecurityMasterEntity.DB_MASTER_CODE_ITEM, '项目名称', SearchFilterTypePolicy.DATE, SearchFilterOperatorPolicy.DATE_BETWEEN);
|
|
bindOptions.value.push(bindOption);
|
|
|
|
bindOption = ubo.getBindOption(SecurityMasterEntity.DB_LOCAL_DESCRIPTION, '中文描述', 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: SecurityMasterSearchCriteria = new SecurityMasterSearchCriteria();
|
|
|
|
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 onPrint = (async () => {
|
|
let c: SecurityMasterSearchCriteria = new SecurityMasterSearchCriteria();
|
|
|
|
c.Filter = items.value[0].getFilter();
|
|
|
|
c.limit = pagingParams.value.pageSize;
|
|
c.page = pagingParams.value.page ?? 1;
|
|
c.GridColumns = useGridColumnInfo().getGridColumnInfo(unref(columns));
|
|
c.ReportName = layoutProviderMethod?.getLayoutProvider().layoutTitle!;
|
|
try {
|
|
let sss = await securityMasterService.PrintBySearchCriteria(c);
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
})
|
|
|
|
const findBySearchCriteria = (async (c: SecurityMasterSearchCriteria) => {
|
|
try {
|
|
data.value = await securityMasterService.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: SecurityMasterSearchCriteria = new SecurityMasterSearchCriteria();
|
|
|
|
|
|
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>
|