ow
This commit is contained in:
1 parent
d2c2b3cf59
commit
4359903d9c
33 files changed
+2708
-246
No files matched your search
@@ -0,0 +1,345 @@
|
||||
<template>
|
||||
<search @on-submit="onSubmit" @on-print="onPrint" @on-reset="onReset" @use-pagination="onPagination"
|
||||
:is-modal="isModal" :loading="loading" :pagination="result" :rowSelectionType="selectionType"
|
||||
@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 === FamilyTreeViewEntity.PUBLIC_INDC">
|
||||
<template v-if="record.PublicIndc == '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>
|
||||
</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 search from "@/components/basic/Search.vue";
|
||||
import { DeleteOutlined, EditOutlined, FileAddOutlined, FileTextOutlined } from "@ant-design/icons-vue";
|
||||
|
||||
import { FamilyTreeResultData } from "@/data/auto/familyTreeResultData";
|
||||
import { FamilyTreeViewEntity } from "@/data/auto/familyTreeViewEntity";
|
||||
import { SearchFilter } from "@/data/auto/searchFilter"
|
||||
import familyTreeService from "@/service/master/familyTreeService";
|
||||
import { useYesNoPolicy } from "@/hooks/useYesNoPolicy"
|
||||
import { FamilyTreeSearchCriteria } from "@/data/auto/familyTreeSearchCriteria";
|
||||
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================
|
||||
//报表名称(layout)
|
||||
const layoutProviderMethod = inject(layoutProviderMethodKey);
|
||||
|
||||
const actorOperationMethod = inject(operationToEnquiryMethodKey);
|
||||
const modelOption = actorOperationMethod?.getOperationToEnquiryModelOption() as OperationToEnquiryModelOption;
|
||||
|
||||
const isModal = ref(modelOption ? modelOption.isModalTree : false);
|
||||
const selectionType = modelOption ? modelOption.selectionTypeTree : 'checkbox';
|
||||
const initBindOptions = ref((modelOption ? modelOption.initBindOptionsTree : []) 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: FamilyTreeViewEntity.TREE_NAME,
|
||||
sorter: true,
|
||||
width: '15%',
|
||||
sequence: 1,
|
||||
hidden: 'N'
|
||||
},
|
||||
{
|
||||
title: "简介",
|
||||
dataIndex: FamilyTreeViewEntity.BRIEF,
|
||||
sorter: true,
|
||||
width: '15%',
|
||||
sequence: 2,
|
||||
hidden: 'N'
|
||||
},
|
||||
{
|
||||
title: "公开?",
|
||||
dataIndex: FamilyTreeViewEntity.PUBLIC_INDC,
|
||||
sorter: true,
|
||||
width: '5%',
|
||||
sequence: 4,
|
||||
hidden: 'N'
|
||||
},
|
||||
{
|
||||
title: "祖先姓氏",
|
||||
dataIndex: FamilyTreeViewEntity.SURNAME,
|
||||
sorter: true,
|
||||
width: '20%',
|
||||
sequence: 2,
|
||||
hidden: 'N'
|
||||
},
|
||||
{
|
||||
title: "祖先谱名",
|
||||
dataIndex: FamilyTreeViewEntity.GENEALOGY_NAME,
|
||||
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<FamilyTreeViewEntity[]>([]);
|
||||
const pagingParams = ref<PagingParams>({ pageSize: 20, page: 1 });
|
||||
const result = ref<SearchCriteriaResultData>(new SearchCriteriaResultData());
|
||||
|
||||
const data = ref<FamilyTreeResultData>(new FamilyTreeResultData());
|
||||
|
||||
const isSearched = ref<boolean>(false);
|
||||
const currentSearchCriteria = ref<FamilyTreeSearchCriteria>(new FamilyTreeSearchCriteria());
|
||||
|
||||
const keys = ref<FamilyTreeViewEntity[]>([]);
|
||||
|
||||
const {
|
||||
children: items,
|
||||
addChild: addItem,
|
||||
removeChild: removeItem,
|
||||
} = useOrderedChildren<SearchCriteriaContext>();
|
||||
|
||||
//================provide================
|
||||
//初始化查询条件UI
|
||||
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: FamilyTreeViewEntity[]) => {
|
||||
keys.value = selected;
|
||||
})
|
||||
|
||||
const onRowDblclick = ((e: any, record: FamilyTreeViewEntity) => {
|
||||
if (isModal.value) {
|
||||
emit('onRowDblclick', record);
|
||||
}
|
||||
else {
|
||||
router.push({ name: "FamilyTreeOperation", params: { id: record.TreeId, mode: 'view' } });
|
||||
}
|
||||
})
|
||||
|
||||
const onReset = (() => {
|
||||
keys.value = [];
|
||||
result.value.Total = 0;
|
||||
})
|
||||
|
||||
const onView = (() => {
|
||||
if (keys.value.length == 0) return;
|
||||
router.push({ name: "FamilyTreeOperation", params: { id: keys.value[0].TreeId, mode: 'view' } });
|
||||
})
|
||||
|
||||
const onCreate = (() => {
|
||||
router.push({ name: "FamilyTreeOperation", params: { id: '', mode: 'create' } });
|
||||
})
|
||||
|
||||
const onAmend = (() => {
|
||||
if (keys.value.length == 0) return;
|
||||
router.push({ name: "FamilyTreeOperation", params: { id: keys.value[0].TreeId, mode: 'amend' } });
|
||||
})
|
||||
|
||||
const onDelete = (async () => {
|
||||
|
||||
for (let i = 0; i < keys.value.length; i++) {
|
||||
await familyTreeService.Delete(keys.value[i].TreeId);
|
||||
}
|
||||
|
||||
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(FamilyTreeViewEntity.DB_TREE_NAME, '树名称', SearchFilterTypePolicy.TEXT, SearchFilterOperatorPolicy.CONTAIN);
|
||||
bindOptions.value.push(bindOption);
|
||||
bindOption = ubo.getBindOption(FamilyTreeViewEntity.DB_BRIEF, '简介', SearchFilterTypePolicy.TEXT, SearchFilterOperatorPolicy.CN_CONTAIN);
|
||||
bindOption.lg = 10;
|
||||
bindOptions.value.push(bindOption);
|
||||
let rps: SelectOption[] = await useYesNoPolicy().getSelectOption(true);
|
||||
bindOption = ubo.getBindSelectOption(FamilyTreeViewEntity.DB_PUBLIC_INDC, '公开?', SearchFilterTypePolicy.SINGLE_SELECTION, SearchFilterOperatorPolicy.SINGLE, rps);
|
||||
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: FamilyTreeSearchCriteria = new FamilyTreeSearchCriteria();
|
||||
|
||||
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: FamilyTreeSearchCriteria = new FamilyTreeSearchCriteria();
|
||||
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 {
|
||||
// familyTreeService 暂无打印方法
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
const findBySearchCriteria = (async (c: FamilyTreeSearchCriteria) => {
|
||||
data.value = await familyTreeService.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;
|
||||
})
|
||||
|
||||
const onPagination = (async (params: PagingParams) => {
|
||||
|
||||
if (!isSearched.value) return;
|
||||
let c: FamilyTreeSearchCriteria = new FamilyTreeSearchCriteria();
|
||||
|
||||
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>
|
||||
Reference in new issue
Block a user