<template>
|
<LoadingLayout :loading="state.loading">
|
<AppContainer>
|
<ProTableQueryFilterBar @on-reset="reset">
|
<template #query>
|
<QueryFilterItem tip-content="配置状态">
|
<FieldRadio
|
v-model="extraParamState.isConfigured"
|
:value-enum="[
|
{
|
value: true,
|
label: '已配置',
|
},
|
{
|
value: false,
|
label: '未配置',
|
},
|
]"
|
buttonStyle
|
showAllBtn
|
@change="getList()"
|
/>
|
</QueryFilterItem>
|
<QueryFilterItem>
|
<SearchInput
|
v-model="extraParamState.keywords"
|
style="width: 200px"
|
placeholder="企业名称/法人/联系人"
|
@on-click-search="getList"
|
@keyup.enter="getList()"
|
>
|
</SearchInput>
|
</QueryFilterItem>
|
</template>
|
<template #btn>
|
<el-button
|
v-if="checkSubModuleItemShow('pageButton', 'addBtn')"
|
@click="addOrEditEnterprise()"
|
icon="Plus"
|
type="primary"
|
>新增</el-button
|
>
|
</template>
|
</ProTableQueryFilterBar>
|
<ProTableV2 v-bind="proTableProps" :columns="column" :operationBtns="operationBtns">
|
</ProTableV2>
|
</AppContainer>
|
<!-- <ConfigureDialog v-bind="dialogProps" /> -->
|
</LoadingLayout>
|
</template>
|
|
<script setup lang="ts">
|
import {
|
ProTableQueryFilterBar,
|
OperationBtnType,
|
ProTableV2,
|
SearchInput,
|
LoadingLayout,
|
AppContainer,
|
QueryFilterItem,
|
useTable,
|
useFormDialog,
|
FieldRadio,
|
} from '@bole-core/components';
|
import { useAccess, useGlobalEventContext } from '@/hooks';
|
import { EnterpriseConfigureType } from '@/constants';
|
import ConfigureDialog from './components/ConfigureDialog.vue';
|
import { Message } from '@bole-core/core';
|
import * as enterpriseServices from '@/services/api/enterprise';
|
|
defineOptions({
|
name: 'EnterpriseManageList',
|
});
|
|
const operationBtnMap: Record<string, OperationBtnType> = {
|
editBtn: { emits: { onClick: (role) => addOrEditEnterprise(role) } },
|
detailBtn: { emits: { onClick: (role) => handleDetail(role) } },
|
configBtn: { emits: { onClick: (role) => openDialog(role) } },
|
};
|
|
const { checkSubModuleItemShow, column, operationBtns } = useAccess({
|
operationBtnMap,
|
});
|
|
const eventContext = useGlobalEventContext();
|
|
eventContext.addEvent('enterprise:add', () => {
|
getList();
|
});
|
|
eventContext.addEvent('enterprise:edit', () => {
|
getList(paginationState.pageIndex);
|
});
|
|
const router = useRouter();
|
|
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.GetEnterprisesQuery = {
|
pageModel: {
|
rows: pageSize,
|
page: pageIndex,
|
orderInput: extraParamState.orderInput,
|
},
|
isConfigured: extraParamState.isConfigured,
|
keywords: extraParamState.keywords,
|
};
|
|
let res = await enterpriseServices.getEnterprises(params, {
|
showLoading: !state.loading,
|
});
|
return res;
|
} catch (error) {
|
console.log('error: ', error);
|
}
|
},
|
{
|
defaultExtraParams: {
|
keywords: '',
|
orderInput: [{ property: 'id', order: EnumPagedListOrder.Desc }],
|
isConfigured: '' as any as boolean,
|
},
|
queryKey: ['flexEnterpriseServices/getFlexEnterpriseList'],
|
columnsRenderProps: {},
|
}
|
);
|
|
function openDialog(row?: API.GetEnterprisesQueryResultItem) {
|
if (row) {
|
handleEdit({
|
id: row.id,
|
});
|
} else {
|
handleAdd();
|
}
|
}
|
|
const { dialogProps, handleAdd, handleEdit, editForm, dialogState } = useFormDialog({
|
onConfirm: handleAddOrEdit,
|
defaultFormParams: {
|
id: '',
|
},
|
});
|
|
async function handleAddOrEdit(type: EnterpriseConfigureType) {
|
try {
|
let res;
|
// if (type === EnterpriseConfigureType.Bank) {
|
// res = await createOrEditFlexEnterpriseBankSetting();
|
// }
|
if (type === EnterpriseConfigureType.Electronic) {
|
res = await createOrEditFlexEnterpriseSignSetting();
|
}
|
if (type === EnterpriseConfigureType.ShortMessage) {
|
res = await createOrEditFlexEnterpriseMessageSetting();
|
}
|
if (res) {
|
Message.successMessage('操作成功');
|
getList(paginationState.pageIndex);
|
dialogState.dialogVisible = false;
|
}
|
} catch (error) {}
|
}
|
|
// async function createOrEditFlexEnterpriseBankSetting() {
|
// try {
|
// let params: API.CreateOrEditFlexEnterpriseBankInput = {
|
// id: editForm.id,
|
// openBank: editForm.openBank,
|
// openBranchBank: editForm.openBranchBank,
|
// bankAccount: editForm.bankAccount,
|
// verifyStatus: editForm.verifyStatus,
|
// flexEnterpirseId: editForm.flexEnterpirseId,
|
// };
|
// return await flexEnterpriseServices.createOrEditFlexEnterpriseBankSetting(params);
|
// } catch (error) {}
|
// }
|
async function createOrEditFlexEnterpriseSignSetting() {
|
try {
|
let params: API.SetEnterpriseElectronSignSettingCommand = {
|
id: editForm.id,
|
};
|
return await enterpriseServices.setEnterpriseElectronSignSetting(params);
|
} catch (error) {}
|
}
|
async function createOrEditFlexEnterpriseMessageSetting() {
|
try {
|
let params: API.SetEnterpriseSmsSettingCommand = {
|
id: editForm.id,
|
};
|
return await enterpriseServices.setEnterpriseSmsSetting(params);
|
} catch (error) {}
|
}
|
|
function addOrEditEnterprise(row?: API.GetEnterprisesQueryResultItem) {
|
router.push({ name: 'AddOrEditEnterprise', params: { id: row?.id ?? '' } });
|
}
|
function handleDetail(row: API.GetEnterprisesQueryResultItem) {
|
router.push({ name: 'EnterpriseDetail', params: { id: row?.id ?? '' } });
|
}
|
</script>
|