414 lines
15 KiB
Vue
414 lines
15 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="[FamilyGroupEntity.FAMILY_NAME, FamilyGroupEntity.FAMILY_LOCAL_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, index }">
|
|
<template v-if="column.dataIndex === FamilyGroupEntity.VALID_INDC">
|
|
<template v-if="record.ValidIndc == '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 v-if="isEdit" :gutter="[16, 8]">
|
|
<a-space>
|
|
<a-button type="primary" @click.prevent="onCancel">取消</a-button>
|
|
<a-button type="primary" @click.prevent="onSave">确定</a-button>
|
|
</a-space>
|
|
</a-row>
|
|
<a-row v-if="!isEdit" :gutter="[16, 8]">
|
|
<a-space>
|
|
<a-button type="primary" v-if="canView" :icon="h(FileTextOutlined)"
|
|
:disabled="!(keys && keys.length > 0)" @click.prevent="onView">查看</a-button>
|
|
<a-button type="primary" v-if="canAmend" :icon="h(EditOutlined)"
|
|
:disabled="!(keys && keys.length > 0)" @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-button type="primary" v-if="canView" :icon="h(FileTextOutlined)"
|
|
:disabled="!(keys && keys.length > 0)" @click.prevent="onRequest">申请加入</a-button>
|
|
</a-space>
|
|
</a-row>
|
|
</a-col>
|
|
</a-row>
|
|
</div>
|
|
</template>
|
|
</search-card>
|
|
<dragModal v-model:open="showModalRequest" title="请输入申请原因" :fullscreen="width < 640" :mask-closable="false"
|
|
@ok="handleSelectRequest">
|
|
<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-textarea :maxlength="256" required v-model:value="notice" />
|
|
</a-col>
|
|
</a-row>
|
|
</dragModal>
|
|
</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 { FamilyGroupResultData } from "@/data/auto/familyGroupResultData";
|
|
import { FamilyGroupEntity } from "@/data/auto/familyGroupEntity";
|
|
import { SearchFilter } from "@/data/auto/searchFilter"
|
|
import familyGroupService from "@/service/master/familyGroupService";
|
|
import { FamilyGroupSearchCriteria } from "@/data/auto/familyGroupSearchCriteria";
|
|
import { FamilyGroupManagerEntity } from "@/data/auto/familyGroupManagerEntity";
|
|
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 { useYesNoPolicy } from "@/hooks/useYesNoPolicy"
|
|
import dragModal from "@/components/basic/DragModal.vue"
|
|
import { enquiryMethodKey, searchCriteriaManagerKey, masterOperationToEnquiryMethodKey, MasterOperationToEnquiryModelOption, layoutProviderMethodKey } from "@/injections";
|
|
import { useOrderedChildren } from "@/hooks/use-ordered-children";
|
|
import { SearchCriteriaContext } from "@/injections";
|
|
import { useWindowSize } from '@vueuse/core'
|
|
|
|
//page from-----------------------------------------------------------------------------------------------------------------------------------
|
|
//================inject================
|
|
//报表名称
|
|
const layoutProviderMethod = inject(layoutProviderMethodKey);
|
|
|
|
//当前是弹出的Modal,还是Page
|
|
const isModal = ref(inject("isModalFamilyGroup", false) as boolean);
|
|
//初始化查询条件的值
|
|
const initBindOptions = ref(inject("initBindOptionsFamilyGroup", []) as BindOption[]);
|
|
//记录单选还是多选
|
|
const selectionType = ref(inject("selectionTypeFamilyGroup", 'radio') as string);
|
|
//================inject================
|
|
|
|
const emit = defineEmits(['onRowDblclick']);
|
|
const { width, height } = useWindowSize()
|
|
const showModalRequest = ref<boolean>(false);
|
|
const loading = ref<boolean>(false);
|
|
const isEdit = ref<boolean>(false);
|
|
const canView = ref<boolean>(false);
|
|
const canAmend = ref<boolean>(false);
|
|
const canDelete = ref<boolean>(false);
|
|
const canCreate = ref<boolean>(false);
|
|
const notice = ref<string>('');
|
|
|
|
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: FamilyGroupEntity.FAMILY_NAME,
|
|
sorter: true,
|
|
fixed: 'left',
|
|
width: '10%',
|
|
sequence: 1,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "群组名称",
|
|
dataIndex: FamilyGroupEntity.FAMILY_LOCAL_NAME,
|
|
sorter: true,
|
|
width: '20%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "群组描述",
|
|
dataIndex: FamilyGroupEntity.NOTICE,
|
|
sorter: true,
|
|
width: '35%',
|
|
sequence: 2,
|
|
hidden: 'N'
|
|
},
|
|
{
|
|
title: "创建日期",
|
|
dataIndex: FamilyGroupEntity.CREATED_DATETIME,
|
|
sorter: true,
|
|
width: '20%',
|
|
sequence: 3,
|
|
hidden: 'N'
|
|
},
|
|
]);
|
|
|
|
const viewOption = {
|
|
Value: 'default',
|
|
SelectOptions: [{ BindValue: 'default', DisplayName: "默认" }],
|
|
Columns: [{ BindValue: 'default', BindColumn: columns }]
|
|
};
|
|
|
|
|
|
|
|
const bindOptions = ref<BindOption[]>([]);
|
|
const datas = ref<FamilyGroupEntity[]>([]);
|
|
const pagingParams = ref<PagingParams>({ pageSize: 20, page: 1 });
|
|
const result = ref<SearchCriteriaResultData>(new SearchCriteriaResultData());
|
|
|
|
const data = ref<FamilyGroupResultData>(new FamilyGroupResultData());
|
|
const currentFilter = ref<SearchFilter[]>([]);
|
|
const isSearched = ref<boolean>(false);
|
|
const currentSearchCriteria = ref<FamilyGroupSearchCriteria>(new FamilyGroupSearchCriteria());
|
|
|
|
const keys = ref<FamilyGroupEntity[]>([]);
|
|
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();
|
|
onSubmit(items.value[0].getFilter());
|
|
})
|
|
|
|
const onRowDblclick = ((e: any, record: FamilyGroupEntity) => {
|
|
if (isModal.value) {
|
|
emit('onRowDblclick', record);
|
|
}
|
|
else {
|
|
router.push({ name: "FamilyGroupOperation", params: { id: record.FamilyName, mode: 'view' } });
|
|
}
|
|
})
|
|
|
|
const onSelectChange = ((selected: FamilyGroupEntity[]) => {
|
|
keys.value = selected;
|
|
})
|
|
|
|
const onReset = (() => {
|
|
keys.value = [];
|
|
result.value.Total = 0;
|
|
})
|
|
|
|
const onView = (() => {
|
|
if (keys.value.length == 0) return;
|
|
router.push({ name: "FamilyGroupOperation", params: { id: keys.value[0].FamilyName, mode: 'view' } });
|
|
})
|
|
|
|
const onCreate = (() => {
|
|
router.push({ name: "FamilyGroupOperation", params: { id: '', mode: 'create' } });
|
|
})
|
|
|
|
const onRequest = (() => {
|
|
if (keys.value.length == 0) return;
|
|
notice.value = '';
|
|
showModalRequest.value = true;
|
|
})
|
|
|
|
const handleSelectRequest = (() => {
|
|
let m: FamilyGroupManagerEntity = new FamilyGroupManagerEntity();
|
|
m.FamilyName = keys.value[0].FamilyName;
|
|
m.Notice = notice.value;
|
|
if (!m.Notice || m.Notice.length == 0) {
|
|
notification.info({
|
|
message: '系统提示:',
|
|
description: '请输入申请原因方便审核',
|
|
placement: "topRight",
|
|
});
|
|
return;
|
|
}
|
|
submitRequest(m);
|
|
})
|
|
|
|
const submitRequest = ((m: FamilyGroupManagerEntity) => {
|
|
familyGroupService.InsertFamilyGroupManager(m).then(() => {
|
|
showModalRequest.value = false;
|
|
notification.info({
|
|
message: '系统提示:',
|
|
description: '申请加入成功,请等待审核。',
|
|
placement: "topRight",
|
|
});
|
|
}
|
|
);
|
|
})
|
|
|
|
const onAmend = (() => {
|
|
if (keys.value.length == 0) return;
|
|
router.push({ name: "FamilyGroupOperation", params: { id: keys.value[0].FamilyName, mode: 'amend' } });
|
|
})
|
|
|
|
const onDelete = (async () => {
|
|
await familyGroupService.Delete(keys.value[0].FamilyName);
|
|
|
|
notification.info({
|
|
message: '系统提示:',
|
|
description: '记录删除成功',
|
|
placement: "topRight",
|
|
});
|
|
|
|
onReload();
|
|
})
|
|
|
|
const onSave = (() => {
|
|
isEdit.value = false;
|
|
})
|
|
|
|
const onCancel = (() => {
|
|
isEdit.value = false;
|
|
})
|
|
|
|
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(FamilyGroupEntity.DB_FAMILY_NAME, '群组代码', SearchFilterTypePolicy.TEXT, SearchFilterOperatorPolicy.CONTAIN);
|
|
bindOptions.value.push(bindOption);
|
|
|
|
bindOption = ubo.getBindOption(FamilyGroupEntity.DB_FAMILY_LOCAL_NAME, '群组名称', SearchFilterTypePolicy.TEXT, SearchFilterOperatorPolicy.CONTAIN);
|
|
bindOption.lg = 10;
|
|
bindOptions.value.push(bindOption);
|
|
|
|
bindOption = ubo.getBindOption(FamilyGroupEntity.DB_CREATED_DATETIME, '创建日期', SearchFilterTypePolicy.DATE, SearchFilterOperatorPolicy.DATE_BETWEEN);
|
|
bindOptions.value.push(bindOption);
|
|
|
|
// let rps: SelectOption[] = await useYesNoPolicy().getSelectOption(true);
|
|
// bindOption = ubo.getBindSelectOption(FamilyGroupEntity.DB_VALID_INDC, '有效?', SearchFilterTypePolicy.SINGLE_SELECTION, SearchFilterOperatorPolicy.SINGLE, rps);
|
|
// bindOption.lg = 6;
|
|
// bindOption.Value = 'Y';
|
|
// 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: FamilyGroupSearchCriteria = new FamilyGroupSearchCriteria();
|
|
currentFilter.value = filters;
|
|
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 onPrint = (async () => {
|
|
let c: FamilyGroupSearchCriteria = new FamilyGroupSearchCriteria();
|
|
if (currentFilter.value.length > 0)
|
|
c.Filter = currentFilter.value;
|
|
else c.Filter = [];
|
|
|
|
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 familyGroupService.PrintBySearchCriteria(c);
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
})
|
|
|
|
const findBySearchCriteria = (async (c: FamilyGroupSearchCriteria) => {
|
|
try {
|
|
data.value = await familyGroupService.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: FamilyGroupSearchCriteria = new FamilyGroupSearchCriteria();
|
|
|
|
if (currentFilter.value.length > 0)
|
|
c.Filter = currentFilter.value;
|
|
else c.Filter = [];
|
|
|
|
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>
|