mps-platform/cds-fontend-2025.V1/src/views/mps/detail-entry/index.vue

479 lines
12 KiB
Vue
Raw Normal View History

2025-08-21 10:37:18 +08:00
<script setup lang="tsx">
import { NDivider } from 'naive-ui';
import { fetchBatchDeleteDetailEntry, fetchGetDetailEntryList } from '@/service/api/mps/detail-entry';
import { useAppStore } from '@/store/modules/app';
import { useAuth } from '@/hooks/business/auth';
import { useDownload } from '@/hooks/business/download';
import { useTable, useTableOperate } from '@/hooks/common/table';
import { $t } from '@/locales';
import ButtonIcon from '@/components/custom/button-icon.vue';
import DetailEntryOperateDrawer from './modules/detail-entry-operate-drawer.vue';
import DetailEntrySearch from './modules/detail-entry-search.vue';
import {computed, ref, watch} from "vue";
import {useBoolean} from "~/packages/hooks";
import DetailEntryImportModal from './modules/detail-entry-import-modal.vue';
defineOptions({
name: 'DetailEntryList'
});
const appStore = useAppStore();
const { download } = useDownload();
const { hasAuth } = useAuth();
const { bool: importVisible, setTrue: openImportModal } = useBoolean();
const {
columns,
columnChecks,
data,
getData,
getDataByPage,
loading,
mobilePagination,
searchParams,
resetSearchParams
} = useTable({
apiFn: fetchGetDetailEntryList,
apiParams: {
pageNum: 1,
pageSize: 10,
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null
// the value can not be undefined, otherwise the property in Form will not be reactive
subcategoryId: null,
subcategoryName: null,
yxName: null,
jbName: null,
yxId: null,
jbId: null,
date: null,
deptName: null,
deptId: null,
custType: null,
custId: null,
custName: null,
custAcctNo: null,
custPhoneNo: null,
magneticCardId: null,
acquiringName: null,
acquiringId: null,
internetChannel: null,
trafficId: null,
workplace: null,
surplusAccountName: null,
heatingNo: null,
checkFlag: null,
checkTime: null,
checkUser: null,
checkType: null,
checkMsg: null,
params: {}
},
columns: () => [
{
type: 'selection',
align: 'center',
width: 48
},
{
key: 'index',
title: $t('common.index'),
align: 'center',
width: 64,
resizable: true
},
{
key: 'dataId',
title: '主键',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'subcategoryId',
title: '业务类型id',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'subcategoryName',
title: '业务类型名称',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'yxName',
title: '营销人员名称',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'jbName',
title: '经办人员名称',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'yxId',
title: '营销人员营销号',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'jbId',
title: '经办人员营销号',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'date',
title: '数据日期',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'deptName',
title: '部门名称',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'deptId',
title: '部门id',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'custType',
title: '客户类型1-个人2-对公)',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'custId',
title: '客户身份证号',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'custName',
title: '客户姓名',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'custAcctNo',
title: '客户账号/卡号',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'custPhoneNo',
title: '客户联系电话',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'magneticCardId',
title: '磁条卡更换登记id',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'acquiringName',
title: '综合收单商户名',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'acquiringId',
title: '综合收单商户号',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'internetChannel',
title: '网上支付开通渠道',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'trafficId',
title: '交警处罚决定书',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'workplace',
title: '职工所属单位',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'surplusAccountName',
title: '公积金缴纳账户名称',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'heatingNo',
title: '取暖费户号',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'checkFlag',
title: '核对标志0未核对 1核对通过 9核对失败',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'checkTime',
title: '核对时间',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'checkUser',
title: '核对人员(人工核对时)',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'checkType',
title: '核对方式0系统 1人工 2其他1 3其他2 4其他3',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'checkMsg',
title: '核对结果',
align: 'center',
minWidth: 120,
ellipsis: true,
resizable: true
},
{
key: 'operate',
title: $t('common.operate'),
fixed: 'right',
width: 130,
render: row => {
const divider = () => {
if (!hasAuth('mps:detailEntry:edit') || !hasAuth('mps:detailEntry:remove')) {
return null;
}
return <NDivider vertical />;
};
const editBtn = () => {
if (!hasAuth('mps:detailEntry:edit')) {
return null;
}
return (
<ButtonIcon
text
type="primary"
2025-08-21 11:40:09 +08:00
local-icon="drive-file-rename-outline-outline"
2025-08-21 10:37:18 +08:00
tooltipContent={$t('common.edit')}
onClick={() => edit(row.dataId!)}
/>
);
};
const deleteBtn = () => {
if (!hasAuth('mps:detailEntry:remove')) {
return null;
}
return (
<ButtonIcon
text
type="error"
2025-08-21 11:40:09 +08:00
local-icon="delete-outline"
2025-08-21 10:37:18 +08:00
tooltipContent={$t('common.delete')}
popconfirmContent={$t('common.confirmDelete')}
onPositiveClick={() => handleDelete(row.dataId!)}
/>
);
};
return (
<div class="flex-center gap-8px">
{editBtn()}
{divider()}
{deleteBtn()}
</div>
);
}
}
]
});
const scrollX = ref(0);
// 计算总宽度函数
const calculateTotalWidth = () => {
let totalWidth = 0;
const visibleColumns = columns.value;
for (let i = 0; i < visibleColumns.length; i++) {
const column = visibleColumns[i];
// 获取列的实际渲染宽度
// 注意:调整大小时会更新 column.width
let width = column.width;
// 如果没有显式宽度则使用minWidth或默认值
if (!width) {
width = column.minWidth || 120;
}
// 转换为数字类型
width = typeof width === 'string' ? parseInt(width) : width;
totalWidth += width;
}
// 添加额外的50px余量防止边缘裁剪
return totalWidth + 50;
};
// 监听列变化并计算宽度
watch(columns, (newColumns) => {
scrollX.value = calculateTotalWidth();
}, { deep: true });
const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onBatchDeleted, onDeleted } =
useTableOperate(data, getData);
async function handleBatchDelete() {
// request
const { error } = await fetchBatchDeleteDetailEntry(checkedRowKeys.value);
if (error) return;
onBatchDeleted();
}
async function handleDelete(dataId: CommonType.IdType) {
// request
const { error } = await fetchBatchDeleteDetailEntry([dataId]);
if (error) return;
onDeleted();
}
function edit(dataId: CommonType.IdType) {
handleEdit('dataId', dataId);
}
function handleImport() {
openImportModal();
}
function handleExport() {
download('/mps/detailEntry/export', searchParams, `每日录入明细_${new Date().getTime()}.xlsx`);
}
</script>
<template>
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
<DetailEntrySearch v-model:model="searchParams" @reset="resetSearchParams" @search="getDataByPage" />
<NCard title="每日录入明细列表" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
<template #header-extra>
<TableHeaderOperation
v-model:columns="columnChecks"
:disabled-delete="checkedRowKeys.length === 0"
:loading="loading"
:show-add="hasAuth('mps:detailEntry:add')"
:show-delete="hasAuth('mps:detailEntry:remove')"
:show-export="hasAuth('mps:detailEntry:export')"
@add="handleAdd"
@delete="handleBatchDelete"
@export="handleExport"
@refresh="getData"
>
<template #after>
<NButton v-if="hasAuth('mps:privateEbankNew:export')" size="small" ghost @click="handleImport">
<template #icon>
2025-08-21 11:40:09 +08:00
<SvgIcon local-icon="upload-rounded" class="text-icon"/>
2025-08-21 10:37:18 +08:00
</template>
{{ $t('common.import') }}
</NButton>
</template>
</TableHeaderOperation>
</template>
<!--scroll-x : 所有表格列宽度之和(包含操作列)+操作列宽度-->
<NDataTable
v-model:checked-row-keys="checkedRowKeys"
:columns="columns"
:data="data"
size="small"
:flex-height="!appStore.isMobile"
:scroll-x="scrollX"
:loading="loading"
remote
:row-key="row => row.dataId"
:pagination="mobilePagination"
class="sm:h-full"
@update-resize-widths="scrollX = calculateTotalWidth()"
/>
<DetailEntryImportModal v-model:visible="importVisible" @submitted="getDataByPage"/>
<DetailEntryOperateDrawer
v-model:visible="drawerVisible"
:operate-type="operateType"
:row-data="editingData"
@submitted="getDataByPage"
/>
</NCard>
</div>
</template>
<style scoped></style>