<template>
|
<LoadingLayout :loading="state.loading">
|
<AppContainer>
|
<ProTableV2 v-bind="proTableProps" :columns="column" :operationBtns="operationBtns">
|
</ProTableV2>
|
</AppContainer>
|
</LoadingLayout>
|
</template>
|
|
<script setup lang="ts">
|
import { ProTableV2, LoadingLayout, AppContainer, useTable } from '@bole-core/components';
|
import * as enterpriseInsuranceProductServices from '@/services/api/enterpriseInsuranceProduct';
|
import {
|
EnumEnterpriseCooperationStatusText,
|
EnumEnterpriseCooperationSignStatusText,
|
} from '@/constants';
|
import { Message } from '@bole-core/core';
|
|
defineOptions({
|
name: 'InsureProductConfigure',
|
});
|
|
const operationBtnMap: Record<string, OperationBtnType> = {
|
enableBtn: {
|
emits: {
|
onClick: (role) => setDisabledEnterpriseInsuranceProducts(role),
|
},
|
extraProps: {
|
hide: (role: API.GetEnterpriseInsuranceProductsQueryResultItem) => !role.isDisabled,
|
},
|
},
|
disableBtn: {
|
emits: {
|
onClick: (role) => setDisabledEnterpriseInsuranceProducts(role),
|
},
|
extraProps: {
|
hide: (role: API.GetEnterpriseInsuranceProductsQueryResultItem) => role.isDisabled,
|
},
|
},
|
};
|
|
const { checkSubModuleItemShow, column, operationBtns } = useAccess({
|
operationBtnMap,
|
});
|
|
const route = useRoute();
|
const enterpriseCooperationId = (route.params.id as string) ?? '';
|
|
const BaseState = {
|
loading: true,
|
};
|
|
const state = reactive({ ...BaseState });
|
|
onMounted(async () => {
|
await getList();
|
state.loading = false;
|
});
|
|
const {
|
getDataSource: getList,
|
proTableProps,
|
paginationState,
|
extraParamState,
|
reset,
|
} = useTable(
|
async ({ pageIndex, pageSize }, extraParamState) => {
|
try {
|
let params: API.GetEnterpriseInsuranceProductsQuery = {
|
pageModel: {
|
rows: pageSize,
|
page: pageIndex,
|
orderInput: extraParamState.orderInput,
|
},
|
enterpriseCooperationId: enterpriseCooperationId,
|
};
|
|
let res = await enterpriseInsuranceProductServices.getEnterpriseInsuranceProducts(params, {
|
showLoading: !state.loading,
|
});
|
return res;
|
} catch (error) {}
|
},
|
{
|
defaultExtraParams: {
|
orderInput: [{ property: 'id', order: EnumPagedListOrder.Desc }],
|
},
|
queryKey: ['enterpriseServices/getPartyAEnterprises'],
|
columnsRenderProps: {
|
isDisabled: {
|
formatter: (row: API.GetEnterpriseInsuranceProductsQueryResultItem) =>
|
row.isDisabled ? '禁用' : '启用',
|
},
|
},
|
}
|
);
|
|
async function setDisabledEnterpriseInsuranceProducts(
|
row: API.GetEnterpriseInsuranceProductsQueryResultItem
|
) {
|
try {
|
await Message.tipMessage(`确认要${row.isDisabled ? '启用' : '禁用'}该保险产品吗?`);
|
let params: API.SetDisabledEnterpriseInsuranceProductsCommand = {
|
enterpriseCooperationId: enterpriseCooperationId,
|
ids: [row.id],
|
isDisabled: !row.isDisabled,
|
};
|
let res = await enterpriseInsuranceProductServices.setDisabledEnterpriseInsuranceProducts(
|
params
|
);
|
if (res) {
|
Message.successMessage('操作成功');
|
getList(paginationState.pageIndex);
|
}
|
} catch (error) {}
|
}
|
</script>
|