🔀 合并 origin/master 到 dev

# Conflicts:
#	src/views/business/components/business-crud-page.vue
This commit is contained in:
2026-10-19 19:06:34 +08:00
65 changed files with 3198 additions and 930 deletions
+9 -2
View File
@@ -31,8 +31,15 @@ export const approve = data => request({ url: `${baseUrl}/approve`, method: 'pos
export const returnBill = data => request({ url: `${baseUrl}/return`, method: 'post', data });
export const voidBill = data => request({ url: `${baseUrl}/void`, method: 'post', data });
// 同步金蝶涉及多次金蝶远程接口调用(A102-4 预检 + A102-2 保存),可达 20s+,覆盖全局 10s 超时
export const syncKingdee = id =>
request({ url: `${baseUrl}/sync-kingdee`, method: 'post', timeout: 30000, params: { id } });
// config.meta.suppressErrorMessage=true 时由页面弹框汇总结果,避免拦截器重复 toast
export const syncKingdee = (id, config = {}) =>
request({
url: `${baseUrl}/sync-kingdee`,
method: 'post',
timeout: 30000,
params: { id },
...config,
});
export const getDetailFees = detailId =>
request({ url: `${baseUrl}/detail-fees`, method: 'get', params: { detailId } });
export const getReceiptClaims = formalSettlementId =>
@@ -17,6 +17,10 @@ export const approve = id => request({ url: `${baseUrl}/approve`, method: 'post'
export const returnBill = (id, reason) =>
request({ url: `${baseUrl}/return`, method: 'post', data: { id, reason } });
export const repush = id => request({ url: `${baseUrl}/repush`, method: 'post', params: { id } });
export const syncKingdee = id =>
request({ url: `${baseUrl}/sync-kingdee`, method: 'post', timeout: 30000, params: { id } });
export const kingdeeWriteOffPrecheck = formalSettlementId =>
request({ url: `${baseUrl}/kingdee-writeoff-precheck`, method: 'get', params: { formalSettlementId } });
export const approvalStatusOptions = [
{ label: '草稿', value: 'draft' },
+10
View File
@@ -53,3 +53,13 @@ export const confirm = data =>
request({ url: `${baseUrl}/confirm`, method: 'post', data, timeout: 120000 });
export const voidBatch = data => request({ url: `${baseUrl}/void`, method: 'post', data });
export const removeDraft = id =>
request({ url: `${baseUrl}/remove`, method: 'post', params: { id } });
export const getHistoryWaybills = params =>
request({
url: `${baseUrl}/history-waybills`,
method: 'get',
params,
});
+3 -1
View File
@@ -77,7 +77,8 @@ export const syncOaDepartment = (
size = 20,
signal,
incremental = false,
modifiedSince
modifiedSince,
companyOaId
) => {
return request({
url: '/blade-system/dept/sync-oa-department',
@@ -87,6 +88,7 @@ export const syncOaDepartment = (
size,
incremental: !!incremental,
modifiedSince: modifiedSince || undefined,
companyOaId: companyOaId || undefined,
},
timeout: 60000,
signal,
+15 -8
View File
@@ -74,12 +74,15 @@ const redirectToLogin = () => {
* 统一弹出错误提示并返回带标记的 Error。
* `_notified` 标记用于让业务层(批量导入等)识别「拦截器已经提示过」,
* 避免同一条错误被弹两次。
* meta.suppressErrorMessage=true 时由业务层自行弹框汇总,拦截器不再 toast。
*/
const notifiedError = message => {
ElMessage({
message: message,
type: 'error',
});
const notifiedError = (message, config) => {
if (config?.meta?.suppressErrorMessage !== true) {
ElMessage({
message: message,
type: 'error',
});
}
const error = new Error(message);
error._notified = true;
return error;
@@ -260,12 +263,12 @@ axios.interceptors.response.use(
// OAuth2 业务错误码提示
if (status > 2000 && !validatenull(res.data.error_description)) {
return Promise.reject(notifiedError(message));
return Promise.reject(notifiedError(message, config));
}
// 其余非 200 响应统一提示
if (status !== 200) {
return Promise.reject(notifiedError(message));
return Promise.reject(notifiedError(message, config));
}
return res;
},
@@ -273,7 +276,11 @@ axios.interceptors.response.use(
NProgress.done();
// 网络级失败(HTTP 状态 >500、网关错误、超时、断网等 validateStatus 放行之外的响应)
// 原为静默 reject,接口报错页面无任何感知;统一补错误提示,取消请求与刷新令牌请求除外
if (!axios.isCancel(error) && !isRefreshTokenRequest(error?.config)) {
if (
!axios.isCancel(error) &&
!isRefreshTokenRequest(error?.config) &&
error?.config?.meta?.suppressErrorMessage !== true
) {
ElMessage({
message: error?.response?.data?.msg || '请求失败,请稍后重试',
type: 'error',
+2 -1
View File
@@ -97,7 +97,8 @@ export const config = {
action: 'startChange',
label: '变更',
statusProp: 'approvalStatus',
status: ['approved'],
// 立项通过、变更通过后均可再次发起变更
status: ['approved', 'change_approved'],
permission: 'project_apply_change',
},
],
+22 -13
View File
@@ -52,7 +52,8 @@ export const paymentApplicationOption = ({
searchShow: true,
searchIcon: true,
searchLabelWidth: 88,
searchMenuSpan: 24,
// 查询/重置紧跟首行 4 个条件(4×5 + 菜单 4 = 24),不再独占下一整行
searchMenuSpan: 4,
searchIndex: 4,
searchMenuPosition: 'right',
border: true,
@@ -78,6 +79,7 @@ export const paymentApplicationOption = ({
prop: 'paymentNo',
slot: true,
search: true,
searchSpan: 5,
searchOrder: 9,
searchPlaceholder: '请输入',
minWidth: 150,
@@ -88,6 +90,7 @@ export const paymentApplicationOption = ({
type: 'daterange',
searchType: 'daterange',
search: true,
searchSpan: 5,
searchOrder: 8,
hide: true,
showColumn: false,
@@ -95,18 +98,24 @@ export const paymentApplicationOption = ({
editDisplay: false,
viewDisplay: false,
},
searchOnlyColumn({
label: '客户名称',
prop: 'payeeNameSearch',
searchOrder: 7,
searchProp: 'payeeName',
}),
searchOnlyColumn({
label: '项目名称',
prop: 'projectNameSearch',
searchOrder: 6,
searchProp: 'projectName',
}),
{
...searchOnlyColumn({
label: '客户名称',
prop: 'payeeNameSearch',
searchOrder: 7,
searchProp: 'payeeName',
}),
searchSpan: 5,
},
{
...searchOnlyColumn({
label: '项目名称',
prop: 'projectNameSearch',
searchOrder: 6,
searchProp: 'projectName',
}),
searchSpan: 5,
},
searchOnlyColumn({
label: '关联结算单',
prop: 'settlementNo',
@@ -36,7 +36,7 @@ export const kingdeeSyncStatusOptions = [
export const formalSettlementSearchFields = [
{ label: '结算单号', prop: 'formalSettlementNo', type: 'input' },
{ label: '预结算单号', prop: 'preSettlementNo', type: 'input' },
{ label: '预付结算单号', prop: 'preSettlementNo', type: 'input' },
{ label: '项目', prop: 'projectName', type: 'input' },
{ label: '所属组织', prop: 'deptName', type: 'cascader' },
{ label: '合同编号', prop: 'contractNo', type: 'input' },
@@ -19,6 +19,8 @@ export const formalSettlementTableColumns = [
{ label: '审核状态', prop: 'approvalStatusName', minWidth: 110, status: true },
{ label: '当前节点', prop: 'currentNode', minWidth: 130 },
{ label: '当前处理人', prop: 'currentProcessor', minWidth: 130 },
{ label: '调整标识', prop: 'adjustFlag', minWidth: 110 },
{ label: '来源原单号', prop: 'originFormalSettlementNo', minWidth: 170 },
{ label: '金蝶单据号', prop: 'kingdeeBillNo', minWidth: 150 },
{ label: '金蝶单据状态', prop: 'kingdeeSyncStatus', minWidth: 135 },
{ label: '金蝶锁状态', prop: 'kingdeeLockStatus', minWidth: 150 },
@@ -28,7 +30,7 @@ export const formalSettlementTableColumns = [
];
export const sourceColumns = [
{ label: '预结算单号', prop: 'preSettlementNo', minWidth: 160 },
{ label: '预付结算单号', prop: 'preSettlementNo', minWidth: 160 },
{ label: '结算金额', prop: 'settlementAmount', minWidth: 130, money: true },
{ label: '申请预付金额', prop: 'advanceAppliedAmount', minWidth: 140, money: true },
{ label: '已付款金额', prop: 'advancePaidAmount', minWidth: 130, money: true },
@@ -48,6 +50,7 @@ export const detailColumns = [
{ label: '运输总量', prop: 'transportQuantity', minWidth: 120 },
{ label: '里程(KM)', prop: 'mileage', minWidth: 120 },
{ label: '批次号', prop: 'batchNo', minWidth: 120 },
{ label: '计费方式', prop: 'billingType', minWidth: 130 },
{ label: '运输单价', prop: 'unitPrice', minWidth: 120, money: true },
{ label: '运费', prop: 'freightAmount', minWidth: 120, money: true },
{ label: '调整金额', prop: 'adjustAmount', minWidth: 120, money: true },
@@ -66,7 +69,7 @@ export const summaryColumns = [
];
export const candidateColumns = [
{ label: '预结算单号', prop: 'preSettlementNo', minWidth: 170 },
{ label: '预付结算单号', prop: 'preSettlementNo', minWidth: 170 },
{ label: '项目名称', prop: 'projectName', minWidth: 140 },
{ label: '所属组织', prop: 'deptName', minWidth: 140 },
{ label: '合同编号', prop: 'contractNo', minWidth: 150 },
@@ -86,7 +89,7 @@ export const candidateDetailColumns = [
{ label: '合同编号', prop: 'contractNo', minWidth: 150 },
{ label: '合同名称', prop: 'contractName', minWidth: 170 },
{ label: '来源', prop: 'sourceType', minWidth: 110 },
{ label: '预结算单号', prop: 'preSettlementNo', minWidth: 160 },
{ label: '预付结算单号', prop: 'preSettlementNo', minWidth: 160 },
{ label: '正式结算单号', prop: 'formalSettlementNo', minWidth: 160 },
{ label: '运单号', prop: 'waybillNo', minWidth: 150 },
{ label: '车号', prop: 'vehicleNo', minWidth: 130 },
@@ -94,6 +97,7 @@ export const candidateDetailColumns = [
{ label: '货物名称', prop: 'cargoName', minWidth: 140 },
{ label: '货物类型', prop: 'cargoType', minWidth: 130 },
{ label: '批次号', prop: 'batchNo', minWidth: 120 },
{ label: '计费方式', prop: 'billingType', minWidth: 130 },
{ label: '应收应付合计', prop: 'totalAmount', minWidth: 140, money: true },
{ label: '状态', prop: 'settlementStatusName', minWidth: 110 },
];
+1 -1
View File
@@ -4,7 +4,7 @@ export const settlementTypeOptions = [
];
export const preSettlementFormFields = [
{ label: '预结算单号', prop: 'preSettlementNo', readonly: true },
{ label: '预付结算单号', prop: 'preSettlementNo', readonly: true },
{ label: '合同名称', prop: 'contractId', type: 'contract', required: true },
{ label: '合同编号', prop: 'contractNo', readonly: true },
{ label: '项目名称', prop: 'projectName', readonly: true },
+1 -1
View File
@@ -7,7 +7,7 @@ export const approvalStatusOptions = [
];
export const preSettlementSearchFields = [
{ label: '预结算单号', prop: 'preSettlementNo', type: 'input' },
{ label: '预付结算单号', prop: 'preSettlementNo', type: 'input' },
{ label: '预付单号', prop: 'advanceNo', type: 'input' },
{ label: '项目名称', prop: 'projectName', type: 'input' },
{ label: '所属组织', prop: 'deptName', type: 'cascader' },
+3 -1
View File
@@ -1,5 +1,5 @@
export const preSettlementTableColumns = [
{ label: '预结算单号', prop: 'preSettlementNo', minWidth: 150, link: true, fixed: 'left' },
{ label: '预付结算单号', prop: 'preSettlementNo', minWidth: 150, link: true, fixed: 'left' },
{ label: '来源', prop: 'sourceType', minWidth: 100 },
{ label: '付款方', prop: 'payerName', minWidth: 160 },
{ label: '收款方', prop: 'payeeName', minWidth: 160 },
@@ -52,6 +52,7 @@ export const settlementDetailColumns = [
{ label: '运输总量', prop: 'transportQuantityText', minWidth: 120 },
{ label: '里程(KM)', prop: 'mileage', minWidth: 120 },
{ label: '批次号', prop: 'batchNo', minWidth: 130 },
{ label: '计费方式', prop: 'billingType', minWidth: 130 },
{ label: '运输单价', prop: 'unitPrice', minWidth: 120, money: true },
{ label: '运费', prop: 'freightAmount', minWidth: 120, money: true },
{ label: '原金额', prop: 'originalAmount', minWidth: 120, money: true },
@@ -94,5 +95,6 @@ export const candidateDetailColumns = [
{ label: '货物名称', prop: 'cargoName', minWidth: 140 },
{ label: '货物类型', prop: 'cargoType', minWidth: 130 },
{ label: '批次号', prop: 'batchNo', minWidth: 120 },
{ label: '计费方式', prop: 'billingType', minWidth: 130 },
{ label: '结算金额', prop: 'totalAmount', minWidth: 130, money: true },
];
@@ -20,7 +20,7 @@ export const searchFields = [
{ label: '货物名称', prop: 'cargoName', type: 'input' },
{ label: '合同编号', prop: 'contractNo', type: 'input' },
{ label: '合同名称', prop: 'contractName', type: 'input' },
{ label: '预结算单号', prop: 'preSettlementNo', type: 'input' },
{ label: '预付结算单号', prop: 'preSettlementNo', type: 'input' },
{ label: '正式结算单号', prop: 'formalSettlementNo', type: 'input' },
{ label: '批次号', prop: 'batchNo', type: 'input' },
{ label: '车号', prop: 'vehicleNo', type: 'input' },
@@ -35,7 +35,7 @@ export const tableColumns = [
{ label: '合同编号', prop: 'contractNo', minWidth: 140 },
{ label: '合同名称', prop: 'contractName', minWidth: 140 },
{ label: '来源', prop: 'sourceType', minWidth: 110 },
{ label: '预结算单号', prop: 'preSettlementNo', minWidth: 140, link: true },
{ label: '预付结算单号', prop: 'preSettlementNo', minWidth: 140, link: true },
{ label: '正式结算单号', prop: 'formalSettlementNo', minWidth: 140, link: true },
{ label: '运单号', prop: 'waybillNo', minWidth: 140, link: true },
{ label: '车号', prop: 'vehicleNo', minWidth: 120 },
@@ -1,6 +1,6 @@
export const settlementAdjustmentTableColumns = [
{ label: '单据号', prop: 'adjustmentNo', minWidth: 160, link: true, fixed: 'left' },
{ label: '结算单号', prop: 'formalSettlementNo', minWidth: 160 },
{ label: '结算单号', prop: 'formalSettlementNo', minWidth: 160, link: true },
{ label: '结算单类型', prop: 'settlementTypeName', minWidth: 110 },
{ label: '项目名称', prop: 'projectName', minWidth: 140 },
{ label: '所属组织', prop: 'deptName', minWidth: 140 },
@@ -9,6 +9,8 @@ export const settlementAdjustmentTableColumns = [
{ label: '合同名称', prop: 'contractName', minWidth: 170 },
{ label: '调整金额', prop: 'adjustmentAmount', minWidth: 130, money: true },
{ label: '审核状态', prop: 'approvalStatusName', minWidth: 110, status: true },
{ label: '金蝶单据状态', prop: 'kingdeeSyncStatus', minWidth: 130, kingdee: true },
{ label: '金蝶单据号', prop: 'kingdeeBillNo', minWidth: 150 },
{ label: '当前节点', prop: 'currentNode', minWidth: 120 },
{ label: '当前处理人', prop: 'currentProcessor', minWidth: 130 },
{ label: '创建人', prop: 'createUserName', minWidth: 110 },
@@ -13,7 +13,7 @@ export const reconciliationStatusOptions = [
export const transportReconciliationSearchFields = [
{ prop: 'reconciliationNo', label: '对账单号', type: 'input' },
{ prop: 'preSettlementNos', label: '预结算单号', type: 'input' },
{ prop: 'preSettlementNos', label: '预付结算单号', type: 'input' },
{ prop: 'projectName', label: '项目', type: 'input' },
{ prop: 'deptName', label: '所属组织', type: 'cascader' },
{ prop: 'contractNo', label: '合同编号', type: 'input' },
+1
View File
@@ -72,6 +72,7 @@ export const userOption = safe => {
},
{ label: '岗位', prop: 'postName', overHidden: true, display: false },
{ label: '性别', prop: 'sexName', width: 80, display: false },
{ label: 'OA登录名', prop: 'oaLoginId', minWidth: 140, overHidden: true, display: false },
{ label: 'OA人员id', prop: 'oaPersonId', minWidth: 120, overHidden: true, display: false },
{ label: '备注', prop: 'remark', minWidth: 160, overHidden: true, display: false },
{
+2 -2
View File
@@ -108,7 +108,7 @@ export default [
},
{
path: '/settlement/pre-settlement/public-view',
name: '查看预结算信息',
name: '查看预付结算单信息',
component: () => import('@/views/settlement/pre-settlement-public-view.vue'),
meta: {
keepAlive: false,
@@ -119,7 +119,7 @@ export default [
},
{
path: '/settlement/formal-settlement/public-view',
name: '查看正式结算信息',
name: '查看结算单信息',
component: () => import('@/views/settlement/formal-settlement-public-view.vue'),
meta: {
keepAlive: false,
+4 -3
View File
@@ -95,7 +95,7 @@ export default [
children: [
{
path: '',
name: '新增编辑预结算',
name: '新增编辑预付结算单',
meta: {
keepAlive: false,
activeMenu: '/settlement/pre-settlement',
@@ -110,10 +110,11 @@ export default [
children: [
{
path: '',
name: '新增编辑正式结算',
name: '新增编辑结算单',
meta: {
keepAlive: false,
activeMenu: '/settlement/formal-settlement',
// 付款/收款结算单共用表单页,具体高亮菜单由页面按 settlementType 回写
activeMenu: '/settlement/payment-settlement',
},
component: loadView(() => import('@/views/settlement/formal-settlement-form.vue')),
},
+1 -1
View File
@@ -23,7 +23,7 @@ export const MK_BIZ = {
},
'pre-settlement': {
dictName: '提交预结算审核流',
subjectPrefix: '预结算审批',
subjectPrefix: '预付结算审批',
rejected: ['returned'],
approved: ['approved'],
},
+30
View File
@@ -0,0 +1,30 @@
export function isFreightFeeName(name) {
const text = String(name || '');
return text.includes('运费') || text.includes('运输费');
}
/** 运输单价对应的运费计费类型。 */
export function freightBillingType(row = {}) {
const rule = row.billingRule || {};
const rules = Array.isArray(rule.rules) ? rule.rules : [];
const freightRule = rules.find(
item => isFreightFeeName(item?.feeItem) || isFreightFeeName(item?.feeType)
);
return freightRule?.billingType || row.billingType || rule.billingType || '';
}
export function isTierUnitPrice(row) {
return freightBillingType(row) === '阶梯单价';
}
export function isIntervalBilling(row) {
const type = freightBillingType(row);
return type === '区间单价' || (type.includes('区间') && type.includes('一口价'));
}
/** 阶梯单价、区间单价、区间一口价的运输单价不开放手工调整。 */
export function isUnitPriceAdjustable(row) {
const type = freightBillingType(row);
if (!type) return true;
return !isTierUnitPrice(row) && !isIntervalBilling(row);
}
+39
View File
@@ -0,0 +1,39 @@
/** 结算菜单拆分后的展示名与权限前缀 */
export const SETTLEMENT_TYPE_PAYABLE = 'payable';
export const SETTLEMENT_TYPE_RECEIVABLE = 'receivable';
export function settlementBillLabel(settlementType) {
return settlementType === SETTLEMENT_TYPE_RECEIVABLE ? '收款结算单' : '付款结算单';
}
export function settlementPermissionPrefix(settlementType) {
return settlementType === SETTLEMENT_TYPE_RECEIVABLE
? 'receipt_settlement'
: 'payment_settlement';
}
export function settlementListPath(settlementType) {
return settlementType === SETTLEMENT_TYPE_RECEIVABLE
? '/settlement/receipt-settlement'
: '/settlement/payment-settlement';
}
/**
* 权限判断:优先新菜单码,兼容旧 formal_settlement_*。
* @param {Object} ctx 组件实例(需含 permission、isAdmin、validData)
* @param {string} settlementType payable|receivable
* @param {string} action add|edit|view...
*/
export function hasSettlementPermission(ctx, settlementType, action) {
if (ctx?.isAdmin) return true;
const prefix = settlementPermissionPrefix(settlementType);
const codes = [`${prefix}_${action}`, `formal_settlement_${action}`];
return codes.some(code => {
const value = ctx?.permission?.[code];
if (typeof ctx?.validData === 'function') {
return ctx.validData(value, false);
}
return value === true;
});
}
+23
View File
@@ -0,0 +1,23 @@
/**
* 结算单预付记录单据状态名(预结算编辑器与正式结算编辑器共用,避免两页状态名不一致)
*/
export function settlementStatusName(status, displayValue) {
const labels = {
reviewing: '审批中',
approved: '审批通过',
paid: '已付款',
returned: '已驳回',
voided: '已作废',
draft: '草稿',
};
const name = labels[status];
if (name) return name;
return typeof displayValue === 'function' ? displayValue(status) : status || '-';
}
/**
* 统一预付付款记录类型名
*/
export function settlementRecordTypeName(recordType) {
return { progress_advance: '进度预付', project_advance: '项目预付核销' }[recordType] || '';
}
@@ -388,7 +388,7 @@
:disabled="dialogReadonly"
@visible-change="visible => visible && loadFeeUnitOptions()"
><el-option
v-for="unit in feeUnitOptions"
v-for="unit in feeUnitSelectOptions"
:key="unit.value"
:label="unit.label"
:value="unit.value" /></el-select
@@ -1124,6 +1124,10 @@ import { getDictionary as getSystemDictionary } from '@/api/system/dict';
import { getDictionary } from '@/api/system/dictbiz';
import { packageOptions } from '@/option/business/common';
import { formatContractOptionLabel } from '@/utils/contract';
import {
mapFeeUnitOptions,
resolvePriceUnitByQuantityUnit,
} from '@/utils/currency';
import { loadMeasurementUnitOptions } from '@/utils/measurement-unit';
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
import { downloadFileByUrl, downloadXls } from '@/utils/util';
@@ -1264,6 +1268,10 @@ const PageAvueForm = {
},
};
const shippingTemplateListRoute = '/business/shipping-template';
const shippingTemplateFormRoute = '/business/shipping-template/form';
const shippingTemplateListRefreshKey = 'shipping-template-list-refresh';
export default {
name: 'ShippingTemplatePage',
components: { PageAvueForm, ElImageViewer, OpenFileViewer },
@@ -1280,6 +1288,9 @@ export default {
return {
Location,
OfficeBuilding,
// 实例所属路由快照,避免 keep-alive 列表实例被全局 $route 误判成表单页。
routePathLocked: this.$route.path,
isFormPageInstance: this.$route.path === shippingTemplateFormRoute,
form: {},
query: {},
loading: true,
@@ -1401,13 +1412,18 @@ export default {
isStandaloneBusinessPage() {
return (
this.standaloneFormPage &&
['/business/shipping-template', '/business/shipping-template/form'].includes(
this.$route.path
)
(this.isFormPageInstance ||
[shippingTemplateListRoute, shippingTemplateFormRoute].includes(this.routePathLocked) ||
[shippingTemplateListRoute, shippingTemplateFormRoute].includes(this.$route.path))
);
},
isStandaloneFormPage() {
return this.isStandaloneBusinessPage && ['add', 'edit'].includes(this.$route.query.mode);
// 用实例锁定标志,避免列表 keep-alive 实例被全局路由误判成表单页。
return (
this.standaloneFormPage &&
this.isFormPageInstance &&
['add', 'edit'].includes(this.$route.query.mode)
);
},
formPageTitle() {
return this.isStandaloneFormPage
@@ -1464,6 +1480,12 @@ export default {
);
return this.currencyUnit(option?.label || this.shippingTemplateFreight.currency);
},
feeUnitSelectOptions() {
return mapFeeUnitOptions(
this.feeUnitOptions,
this.shippingTemplateFreight.currency || 'RMB'
);
},
roadFreightTotal() {
const total = this.shippingTemplateFreight.freightItems.reduce(
(sum, item) => sum + Number(this.freightAmount(item) || 0),
@@ -1530,6 +1552,18 @@ export default {
},
watch: {
$route(to, from) {
// 列表实例:从其他页进入列表时刷新(activated 负责标签切回)。
if (!this.isFormPageInstance) {
const enteringList =
(to.path === this.routePathLocked || to.path === shippingTemplateListRoute) &&
from?.path &&
from.path !== to.path;
if (enteringList) {
sessionStorage.removeItem(shippingTemplateListRefreshKey);
this.$nextTick(() => this.onLoad(this.page, this.query));
}
return;
}
if (
this.isStandaloneFormPage &&
(to.query.mode !== from?.query?.mode ||
@@ -1550,6 +1584,10 @@ export default {
this.handleTransportTypeChange(value);
this.syncFreightItems();
},
'form.templateType'() {
// 切换到运单模板时立即按货物数量单位生成公路运费明细。
this.$nextTick(() => this.syncFreightItems());
},
},
created() {
this.loadProjectOptions();
@@ -1559,8 +1597,16 @@ export default {
this.loadCurrencyOptions();
if (this.isStandaloneFormPage) this.$nextTick(() => this.initStandaloneFormPage());
},
activated() {
if (this.isFormPageInstance) return;
sessionStorage.removeItem(shippingTemplateListRefreshKey);
this.$nextTick(() => this.onLoad(this.page, this.query));
},
methods: {
formatContractOptionLabel,
markShippingTemplateListNeedRefresh() {
sessionStorage.setItem(shippingTemplateListRefreshKey, '1');
},
loadQuantityUnitOptions() {
if (this.quantityUnitLoading) return this.quantityUnitLoadPromise;
this.quantityUnitLoading = true;
@@ -1591,12 +1637,8 @@ export default {
});
}
if (this.menuWidth != null) next.menuWidth = this.menuWidth;
if (
this.standaloneFormPage &&
['/business/shipping-template', '/business/shipping-template/form'].includes(
this.$route.path
)
) {
// 仅表单页实例套用全屏表单弹窗样式,避免列表页误用后表格区域异常。
if (this.standaloneFormPage && this.$route.path === shippingTemplateFormRoute) {
next.dialogAppendToBody = false;
next.dialogModal = false;
next.dialogCustomClass = 'shipping-template-form-page-dialog';
@@ -1776,13 +1818,22 @@ export default {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
if (this.isFormPageInstance) return;
this.loading = true;
const currentPage = page?.currentPage || this.page.currentPage || 1;
const pageSize = page?.pageSize || this.page.pageSize || 10;
this.api
.getList(page.currentPage, page.pageSize, { ...this.query, ...params })
.getList(currentPage, pageSize, { ...this.query, ...params })
.then(res => {
const data = res?.data?.data || {};
this.data = extractRecords(res);
this.page.total = data.total || this.data.length;
const data = res?.data?.data || res?.data || {};
const records = extractRecords(res);
this.data = records;
this.page.total = Number(data.total ?? records.length) || 0;
})
.catch(error => {
window.console.error(error);
this.data = [];
this.page.total = 0;
})
.finally(() => {
this.loading = false;
@@ -1821,9 +1872,10 @@ export default {
.submit(submit)
.then(() => {
this.$message.success('操作成功');
this.markShippingTemplateListNeedRefresh();
done?.();
this.closeCrudDialog();
this.onLoad(this.page, this.query);
if (!this.isFormPageInstance) this.onLoad(this.page, this.query);
})
.catch(() => loading?.());
},
@@ -1837,9 +1889,10 @@ export default {
.submit(submit)
.then(() => {
this.$message.success('操作成功');
this.markShippingTemplateListNeedRefresh();
done?.();
this.closeCrudDialog();
this.onLoad(this.page, this.query);
if (!this.isFormPageInstance) this.onLoad(this.page, this.query);
})
.catch(() => loading?.());
},
@@ -1883,6 +1936,8 @@ export default {
this.attachmentRows = [];
this.shippingTemplateFreight = defaultFreight();
this.loadCurrencyOptions();
this.loadFeeUnitOptions();
this.$nextTick(() => this.syncFreightItems());
if (typeof this.api.nextCode === 'function')
this.api
.nextCode()
@@ -2005,20 +2060,47 @@ export default {
return false;
}
if (this.transportMode === 'road') {
const invalid = this.shippingTemplateFreight.freightItems.findIndex(
item =>
Number(item.unitPrice || 0) < 0 ||
!item.priceUnit ||
(!this.isFreightAutoCalculable(item) &&
(item.freightAmount === '' ||
item.freightAmount === null ||
item.freightAmount === undefined)) ||
Number(item.freightAmount || 0) < 0
);
if (invalid > -1) {
this.$message.warning(`第${invalid + 1}条货物的单价、计价单位或运费无效`);
if (!this.shippingTemplateFreight.freightItems.length) {
this.$message.warning('请先完善货物数量单位,以便生成运费明细');
return false;
}
for (const [index, item] of this.shippingTemplateFreight.freightItems.entries()) {
const label = `第${index + 1}条运费明细`;
if (
item.unitPrice === '' ||
item.unitPrice === null ||
item.unitPrice === undefined
) {
this.$message.warning(`请填写${label}的单价`);
return false;
}
if (Number(item.unitPrice) < 0) {
this.$message.warning(`${label}的单价不能小于0`);
return false;
}
if (!String(item.priceUnit || '').trim()) {
this.$message.warning(`请选择${label}的计价单位`);
return false;
}
if (this.isFreightAutoCalculable(item)) {
if (!item.freightAmountManual) {
item.freightAmount = this.freightAmount(item);
}
} else if (
item.freightAmount === '' ||
item.freightAmount === null ||
item.freightAmount === undefined
) {
this.$message.warning(
`${label}的计价单位与货物数量单位不匹配,无法自动计算运费,请手动填写运费`
);
return false;
}
if (Number(item.freightAmount || 0) < 0) {
this.$message.warning(`${label}的运费不能小于0`);
return false;
}
}
} else if (Number(this.shippingTemplateFreight.freightAmount || 0) < 0) {
this.$message.warning('运费不能小于0');
return false;
@@ -2033,8 +2115,11 @@ export default {
return true;
},
closeCrudDialog() {
if (this.isStandaloneBusinessPage) {
this.$router.push({ path: '/business/shipping-template', query: {} });
if (this.isStandaloneBusinessPage || this.isFormPageInstance) {
// 关闭独立表单页时标记列表需刷新(含直接点关闭未保存的场景)
this.markShippingTemplateListNeedRefresh();
this.$router.$avueRouter?.closeTag?.();
this.$router.push({ path: shippingTemplateListRoute, query: {} });
return;
}
this.$refs.crud?.closeDialog?.();
@@ -2294,7 +2379,16 @@ export default {
},
loadFeeUnitOptions() {
getDictionary({ code: 'unit_fee' }).then(res => {
this.feeUnitOptions = this.normalizeDictOptions(res?.data?.data || []);
// 计价单位必须保存可读文案(如 元/吨),才能与货物数量单位匹配并自动计算运费。
this.feeUnitOptions = (res?.data?.data || []).map(item => {
const label = String(item.dictValue || item.label || item.value || '').trim();
const key = String(item.dictKey || item.value || '').trim();
return {
label: label || key,
value: label.includes('/') ? label : key || label,
remark: item.remark || '',
};
});
});
},
loadCurrencyOptions() {
@@ -3098,24 +3192,53 @@ export default {
: [];
const quantityUnits = [];
this.transportCargoRows.forEach(row => {
const quantityUnit = row.quantityUnit || '';
const quantityUnit = String(row.quantityUnit || '').trim();
if (!quantityUnit) return;
if (!quantityUnits.some(unit => unit === quantityUnit)) quantityUnits.push(quantityUnit);
});
const currency = this.shippingTemplateFreight.currency || 'RMB';
this.shippingTemplateFreight.freightItems = quantityUnits.map((quantityUnit, index) => {
const matched =
previousItems.find(item => String(item.quantityUnit || '') === String(quantityUnit)) ||
previousItems[index] ||
{};
const defaultPriceUnit = resolvePriceUnitByQuantityUnit(quantityUnit, currency);
const priceUnit = this.normalizeFreightPriceUnit(
matched.priceUnit || defaultPriceUnit || '',
quantityUnit,
currency
);
return {
quantityUnit,
unitPrice: matched.unitPrice || '',
priceUnit: matched.priceUnit || '',
priceUnit,
freightAmount: matched.freightAmount ?? '',
freightAmountManual:
matched.freightAmountManual === true || matched.manualFreightAmount === true,
};
});
},
normalizeFreightPriceUnit(priceUnit, quantityUnit, currency = 'RMB') {
const text = this.resolvePriceUnitText(priceUnit);
if (text && this.priceUnitMatchesQuantity(text, quantityUnit)) return text;
return (
resolvePriceUnitByQuantityUnit(quantityUnit, currency) ||
text ||
String(priceUnit || '').trim()
);
},
resolvePriceUnitText(priceUnit) {
const raw = String(priceUnit || '').trim();
if (!raw) return '';
if (raw.includes('/')) return raw;
const options = this.feeUnitSelectOptions.length
? this.feeUnitSelectOptions
: this.feeUnitOptions;
const matched = options.find(
item => String(item.value) === raw || String(item.label) === raw
);
return matched?.label || raw;
},
quantityUnits() {
return [
...new Set(
@@ -3131,7 +3254,7 @@ export default {
.replace(/\s+/g, '')
.replace(/立方米|立方公尺|方/g, '立方');
const unit = normalizeUnit(quantityUnit).replace(/[·*.]/g, '');
const value = String(priceUnit || '')
const value = String(this.resolvePriceUnitText(priceUnit) || '')
.trim()
.toLowerCase()
.replace(/\s+/g, '');
@@ -3163,6 +3286,10 @@ export default {
return this.formatFreightNumber(item.freightAmount);
}
if (!this.isFreightAutoCalculable(item)) {
// 无法自动计算且未手工填写时返回空,避免把空值显示成 0 造成“已填写”的错觉。
if (item.freightAmount === '' || item.freightAmount === null || item.freightAmount === undefined) {
return '';
}
return this.formatFreightNumber(item.freightAmount);
}
return this.formatFreightNumber(
@@ -2807,8 +2807,11 @@ import 'nprogress/nprogress.css';
const AMAP_KEY = '653b7cf105ad7fb8ec9b2f5198ade315';
const AMAP_SECURITY_CODE = '5aab65c632e48ebae0d0e28f5b28e21a';
let amapLoader;
const transportPlanListRoute = '/business/transport-plan';
const transportPlanFormRoute = '/business/transport-plan/form';
const transportPlanListRefreshKey = 'transport-plan-list-refresh';
const standaloneTransportPlanFormRoutes = {
'/business/transport-plan': '/business/transport-plan/form',
[transportPlanListRoute]: transportPlanFormRoute,
};
const standaloneTransportPlanFormPaths = [
...Object.keys(standaloneTransportPlanFormRoutes),
@@ -3072,6 +3075,10 @@ export default {
// 必须放 data:Options API 的顺序是 data → computed → watch(immediate) → created,
// 放 created 的话首个 immediate watcher 会读到空值,把首次加载也挡掉。
routePathLocked: this.$route.path,
// 表单页实例在创建时锁定,避免 keep-alive 列表实例随全局 $route 误切到表单态。
isFormPageInstance: Object.values(standaloneTransportPlanFormRoutes).includes(
this.$route.path
),
form: {},
suppressTransportTypeClear: false,
query: {},
@@ -3112,10 +3119,11 @@ export default {
option: (() => {
const opt = this.cloneOption(this.crudOption, estimateMenuButtonCount(this.config));
if (this.menuWidth != null) opt.menuWidth = this.menuWidth;
if (
this.standaloneFormPage &&
standaloneTransportPlanFormPaths.includes(this.$route.path)
) {
// 仅表单页实例套用全屏表单弹窗样式,避免列表页误用后表格区域异常。
const isFormInstance = Object.values(standaloneTransportPlanFormRoutes).includes(
this.$route.path
);
if (this.standaloneFormPage && isFormInstance) {
opt.dialogAppendToBody = false;
opt.dialogModal = false;
opt.dialogCustomClass = 'transport-plan-form-page-dialog';
@@ -3289,6 +3297,12 @@ export default {
}
this.loadTaskQuantityUnitOptions();
},
// keep-alive 重新激活列表时强制刷新,避免缓存脏数据;标记位用于兼容旧跳转逻辑。
activated() {
if (this.isFormPageInstance) return;
sessionStorage.removeItem(transportPlanListRefreshKey);
this.$nextTick(() => this.onLoad(this.page, this.query));
},
computed: {
...mapGetters(['permission', 'userInfo']),
permissionList() {
@@ -3300,10 +3314,20 @@ export default {
return this.config.detailSections || [];
},
isStandaloneBusinessPage() {
return this.standaloneFormPage && standaloneTransportPlanFormPaths.includes(this.$route.path);
return (
this.standaloneFormPage &&
(this.isFormPageInstance ||
standaloneTransportPlanFormPaths.includes(this.routePathLocked) ||
standaloneTransportPlanFormPaths.includes(this.$route.path))
);
},
isStandaloneFormPage() {
return this.isStandaloneBusinessPage && ['add', 'edit'].includes(this.$route.query.mode);
// 用实例锁定标志,避免列表 keep-alive 实例被全局路由误判成表单页。
return (
this.standaloneFormPage &&
this.isFormPageInstance &&
['add', 'edit'].includes(this.$route.query.mode)
);
},
formPageTitle() {
if (this.isStandaloneFormPage) {
@@ -3752,6 +3776,18 @@ export default {
},
watch: {
$route(to, from) {
// 列表实例:从其他页进入列表时刷新(activated 负责标签切回)。
if (!this.isFormPageInstance) {
const enteringList =
(to.path === this.routePathLocked || to.path === transportPlanListRoute) &&
from?.path &&
from.path !== to.path;
if (enteringList) {
sessionStorage.removeItem(transportPlanListRefreshKey);
this.$nextTick(() => this.onLoad(this.page, this.query));
}
return;
}
if (!this.isStandaloneFormPage) return;
if (
to.query.mode !== from?.query?.mode ||
@@ -4484,6 +4520,9 @@ export default {
loading();
}
},
markTransportPlanListNeedRefresh() {
sessionStorage.setItem(transportPlanListRefreshKey, '1');
},
rowSave(row, done, loading) {
const submitRow = this.normalizeRow(row);
if (!submitRow) {
@@ -4492,6 +4531,7 @@ export default {
}
this.getSaveRequest()(submitRow).then(
() => {
this.markTransportPlanListNeedRefresh();
this.onLoad(this.page);
this.$message({ type: 'success', message: '操作成功!' });
done();
@@ -4511,6 +4551,7 @@ export default {
}
this.getSaveRequest()(submitRow).then(
() => {
this.markTransportPlanListNeedRefresh();
this.onLoad(this.page);
this.$message({ type: 'success', message: '操作成功!' });
done();
@@ -4540,7 +4581,7 @@ export default {
.submit(submitRow)
.then(() => {
this.$message.success(action === 'draft' ? '暂存成功' : '创建成功');
this.onLoad(this.page, this.query);
this.markTransportPlanListNeedRefresh();
this.closeCrudDialog();
})
.finally(() => {
@@ -4548,12 +4589,14 @@ export default {
});
},
closeCrudDialog() {
if (this.isStandaloneBusinessPage) {
if (this.isStandaloneBusinessPage || this.isFormPageInstance) {
// 关闭独立表单页时标记列表需刷新(含直接点关闭未保存的场景)
this.markTransportPlanListNeedRefresh();
this.$router.$avueRouter?.closeTag?.();
const listPath =
Object.entries(standaloneTransportPlanFormRoutes).find(
([, formPath]) => formPath === this.$route.path
)?.[0] || this.$route.path;
([, formPath]) => formPath === this.$route.path || formPath === this.routePathLocked
)?.[0] || transportPlanListRoute;
this.$router.push({ path: listPath, query: {} });
return;
}
@@ -6634,20 +6677,33 @@ export default {
return query;
},
onLoad(page, params = {}) {
if (this.isFormPageInstance) return;
this.loading = true;
const currentPage = page?.currentPage || this.page.currentPage || 1;
const pageSize = page?.pageSize || this.page.pageSize || 10;
const query = this.normalizeQueryParams({
...params,
...this.query,
allDept: 0,
});
this.api
.getList(page.currentPage, page.pageSize, query)
.getList(currentPage, pageSize, query)
.then(res => {
const result = res.data.data;
this.page.total = result.total;
this.data = result.records;
const result = res?.data?.data || res?.data || {};
const records = Array.isArray(result.records)
? result.records
: Array.isArray(result)
? result
: [];
this.page.total = Number(result.total ?? records.length) || 0;
this.data = records;
this.selectionClear();
})
.catch(error => {
window.console.error(error);
this.data = [];
this.page.total = 0;
})
.finally(() => {
this.loading = false;
});
@@ -1266,9 +1266,27 @@ const fillEditForm = async row => {
if (carrierValue) carrierChange(carrierValue);
await loadBatchRows(snapshot.id);
};
const removeBatches = () =>
api.removeImportBatches(selected.value.map(item => item.id).join(',')).then(loadBatches);
const removeBatch = row => api.removeImportBatches(row.id).then(loadBatches);
/** 与行操作一致:仅草稿可删除 */
const canRemoveBatch = row => String(row?.importStatus || '') === 'draft';
const removeBatches = () => {
if (!selected.value.length) {
ElMessage.warning('请选择至少一条数据');
return;
}
// 选中含不可删条目时整批拦截(含已完成/进行中),不静默跳过
if (selected.value.some(row => !canRemoveBatch(row))) {
ElMessage.warning('已完成运单不可删除');
return;
}
return api.removeImportBatches(selected.value.map(item => item.id).join(',')).then(loadBatches);
};
const removeBatch = row => {
if (!canRemoveBatch(row)) {
ElMessage.warning('已完成运单不可删除');
return;
}
return api.removeImportBatches(row.id).then(loadBatches);
};
const projectChange = async id => {
const requestId = ++projectRequestId;
const item = projects.value.find(row => String(row.id) === String(id));
@@ -217,7 +217,12 @@
/>
<section class="change-section">
<div class="section-head"><div class="dialog-section-title">计费信息</div><el-button type="primary" plain @click="addPlan">添加</el-button></div>
<div class="section-head">
<div class="dialog-section-title">计费信息</div>
<el-button v-if="feeGenerationMode !== 'manual'" type="primary" plain @click="addPlan"
>添加</el-button
>
</div>
<el-radio-group v-model="feeGenerationMode"><el-radio label="system">系统生成</el-radio><el-radio label="manual">账单导入生成</el-radio></el-radio-group>
<el-table :data="plans" border class="change-table"><el-table-column type="index" label="序号" width="70" /><el-table-column prop="planName" label="方案名称" min-width="220" /><el-table-column label="默认方案" min-width="120"><template #default="{ row }">{{ row.defaultPlan ? '是' : '否' }}</template></el-table-column><el-table-column prop="remark" label="备注" min-width="260" /><el-table-column label="操作" width="180"><template #default="{ row, $index }"><el-link type="primary" @click="editPlan(row, $index)">编辑</el-link><el-link type="danger" @click="plans.splice($index, 1)">删除</el-link></template></el-table-column></el-table>
</section>
@@ -440,7 +445,7 @@ export default {
},
preSettlementConfig: {},
formalSettlementConfig: {},
settlementTypeOptions: ['月结', '日结', '周结', '半月结', '固定天数周期结算'],
settlementTypeOptions: ['月结', '日结', '周结', '固定天数周期结算'],
billCycleTypeOptions: ['固定截单日', '自然月', '自定义多周期'],
billCutoffDayOptions: Array.from({ length: 31 }, (_, index) => ({
label: `${index + 1}日`,
+6 -1
View File
@@ -647,7 +647,12 @@
<el-radio label="manual">账单导入生成</el-radio>
</el-radio-group>
</div>
<el-button type="primary" @click="openBillingPlan()">添加</el-button>
<el-button
v-if="form.feeGenerationMode !== 'manual'"
type="primary"
@click="openBillingPlan()"
>添加</el-button
>
</div>
<el-table :data="billingPlanRows" border>
<el-table-column type="index" label="序号" width="80" align="center" />
+4 -3
View File
@@ -224,7 +224,7 @@
placeholder="请选择"
filterable
clearable
:disabled="isBasicInfoReadonly"
:disabled="dialogReadonly"
/>
</el-form-item>
<el-form-item label="平台公司" prop="undertakeDeptId">
@@ -236,7 +236,7 @@
collapse-tags-tooltip
clearable
filterable
:disabled="isBasicInfoReadonly"
:disabled="dialogReadonly"
@change="handleUndertakeDeptChange"
>
<el-option
@@ -2493,7 +2493,8 @@ export default {
loadDeptOptions() {
getDeptTree().then(res => {
const deptTree = res.data.data || [];
const businessDeptTree = ['add', 'edit', 'majorSupplement'].includes(this.dialogType)
// 新增/编辑/重大补录/项目变更均可选择业务部门,排除外部组织
const businessDeptTree = ['add', 'edit', 'majorSupplement', 'change'].includes(this.dialogType)
? this.excludeExternalOrganization(deptTree)
: deptTree;
this.deptOptions = this.flattenDept(businessDeptTree);
@@ -602,6 +602,8 @@ export default {
if (result.code !== 200) throw new Error(result.msg || '导入失败');
this.$message.success('导入完成');
}
// 与运单/配载一致:通知 keep-alive 列表实例重新拉取
sessionStorage.setItem('transport-plan-list-refresh', '1');
this.$router.push('/business/transport-plan');
} catch (error) {
this.$message.error(error.message || '导入失败');
@@ -774,7 +774,7 @@ export default {
},
validateSettlements(rule, value, callback) {
if (!this.form.settlements.length) {
callback(new Error('请选择正式结算单'));
callback(new Error('请选择付款结算单'));
return;
}
callback();
@@ -1215,7 +1215,7 @@ export default {
},
async syncReferenceData() {
if (!this.settlementIds.length) {
this.$message.warning('请先选择正式结算单');
this.$message.warning('请先选择付款结算单');
return;
}
await Promise.all([this.loadReceiverInformation(), this.loadSettlementDetails(false)]);
+1 -1
View File
@@ -359,7 +359,7 @@ export default {
item => String(item.formalSettlementNo || '').trim() === normalizedNo
);
if (!row?.id) {
this.$message.warning('未找到对应的正式结算单');
this.$message.warning('未找到对应的付款结算单');
return;
}
this.$router.push({
+1 -1
View File
@@ -76,7 +76,7 @@
<el-form-item label="关联结算单" prop="settlementIds">
<el-input :model-value="settlementLabel" readonly placeholder="请选择应付正式结算单">
<template v-if="!readonly" #append>
<el-tooltip content="选择正式结算单" placement="top">
<el-tooltip content="选择付款结算单" placement="top">
<el-button :icon="Search" @click="openSettlementDialog" />
</el-tooltip>
</template>
File diff suppressed because it is too large Load Diff
+16 -7
View File
@@ -163,6 +163,7 @@ export default {
rows: [],
selection: [],
loading: false,
approveLoading: false,
syncLoading: false,
resultSyncing: false,
query: {},
@@ -322,18 +323,26 @@ export default {
approvalStatus: previousApprovalStatus,
mkEnabled: this.mkEnabled,
});
this.$message.closeAll?.();
this.$message.success('提交成功');
this.refreshChange();
},
async handleApprove(row) {
const res = await api.approve({ id: row.id });
// data=false 表示审批已通过但自动同步金蝶失败,msg 带具体原因
if (res.data.data === false) {
this.$message.warning(res.data.msg);
} else {
this.$message.success(res.data.msg || '审批通过');
// 防止重复点击:请求进行中忽略后续点击
if (this.approveLoading) return;
this.approveLoading = true;
try {
const res = await api.approve({ id: row.id });
// data=false 表示审批已通过但自动同步金蝶失败,msg 带具体原因
if (res.data.data === false) {
this.$message.warning(res.data.msg);
} else {
this.$message.success(res.data.msg || '审批通过');
}
this.refreshChange();
} finally {
this.approveLoading = false;
}
this.refreshChange();
},
handleMkAudit(row) {
if (!row?.id) {
@@ -302,7 +302,10 @@ export default {
);
},
flowRemaining(flow) {
return Math.max(Number(flow.unclaimedAmount || 0) - Number(flow.claimedAmount || 0), 0);
const unclaimed = Number(flow.unclaimedAmount || 0);
const receipt = Number(flow.receiptAmount || 0);
const ceiling = unclaimed > 0 && receipt > 0 ? Math.min(unclaimed, receipt) : unclaimed || receipt;
return Math.max(ceiling - Number(flow.claimedAmount || 0), 0);
},
maxAllocation(row) {
const current = Number(row.settlement.allocations?.[row.flow.id] || 0);
+15 -7
View File
@@ -252,10 +252,11 @@ export default {
);
},
claimableAmount() {
return Math.max(
Number(this.form.unclaimedAmount || 0) - Number(this.form.claimedAmount || 0),
0
);
const unclaimed = Number(this.form.unclaimedAmount || 0);
const receipt = Number(this.form.receiptAmount || 0);
const ceiling =
unclaimed > 0 && receipt > 0 ? Math.min(unclaimed, receipt) : unclaimed || receipt;
return Math.max(ceiling - Number(this.form.claimedAmount || 0), 0);
},
},
created() {
@@ -274,14 +275,21 @@ export default {
}
const data = this.unwrapData(await api.getDetail(this.flowId));
const userInfo = this.$store.getters.userInfo || {};
// 部分认领继续认领:预填本流水历史关联且仍有剩余可认领金额的结算单
const relatedSettlements = (data?.relatedSettlements || []).map(item => ({
...item,
formalSettlementId: item.id,
settlementId: item.id,
allocatedReceiptAmount: 0,
}));
this.form = {
...emptyForm(),
...data,
claimerName: userInfo.realName || userInfo.userName || data.claimerName || '',
claimerDeptName: userInfo.deptName || userInfo.dept_name || data.claimerDeptName || '',
claimDate: this.$dayjs().format('YYYY-MM-DD'),
settlementIds: [],
settlements: [],
settlementIds: relatedSettlements.map(item => item.formalSettlementId),
settlements: relatedSettlements,
attachments: [],
};
},
@@ -347,7 +355,7 @@ export default {
return;
}
if (this.allocatedTotal > this.claimableAmount + 0.001) {
this.$message.warning('累计认领金额不能超过公告未认领金额(剩余可认领金额)');
this.$message.warning('累计认领金额不能超过剩余可认领金额');
return;
}
for (const row of this.form.settlements)
@@ -177,6 +177,22 @@
</template>
</el-table-column>
</el-table>
<el-descriptions
v-if="form.settlementType === 'payable'"
:column="3"
border
class="formal-editor__settle-summary"
>
<el-descriptions-item label="结算合计(原金额)">
{{ formatMoney(form.settlementAmount) }}
</el-descriptions-item>
<el-descriptions-item label="已付金额(含预付、核销)">
{{ formatMoney(settlePaidTotal) }}
</el-descriptions-item>
<el-descriptions-item label="剩余未付金额">
{{ formatMoney(settleRemainTotal) }}
</el-descriptions-item>
</el-descriptions>
</section-card>
<section-card title="结算明细">
@@ -577,28 +593,27 @@
<template #default="{ row }">{{ displayValue(row.claimStatusName) }}</template>
</el-table-column>
</el-table>
<el-table v-else :data="paymentApplications" border>
<el-table v-else :data="paymentRecords" border>
<el-table-column type="index" label="序号" width="64" align="center" />
<el-table-column prop="paymentTypeName" label="付款类型" min-width="120" align="center">
<template #default="{ row }">{{ displayValue(row.paymentTypeName) }}</template>
<el-table-column label="付款类型" min-width="120" align="center">
<template #default="{ row }">{{ displayValue(row.typeName) }}</template>
</el-table-column>
<el-table-column label="付款方式" min-width="140" align="center">
<template #default="{ row }">{{ paymentMethodName(row.paymentMethod) }}</template>
<template #default="{ row }">{{ row.recordType ? '-' : paymentMethodName(row.paymentMethod) }}</template>
</el-table-column>
<el-table-column prop="paymentNo" label="单据号" min-width="160" align="center" />
<el-table-column prop="appliedAmount" label="申请付款金额" min-width="145" align="center">
<el-table-column prop="appliedAmount" label="申请/核销金额" min-width="145" align="center">
<template #default="{ row }">{{ formatMoney(row.appliedAmount) }}</template>
</el-table-column>
<el-table-column prop="paidAmount" label="已付款金额" min-width="130" align="center">
<template #default="{ row }">{{ formatMoney(row.paidAmount) }}</template>
</el-table-column>
<el-table-column
prop="approvalStatusName"
label="单据状态"
min-width="120"
align="center"
>
<template #default="{ row }">{{ displayValue(row.approvalStatusName) }}</template>
<el-table-column label="单据状态" min-width="120" align="center">
<template #default="{ row }">
{{ row.recordType
? settlementStatusName(row.billStatus)
: displayValue(row.approvalStatusName) }}
</template>
</el-table-column>
<el-table-column prop="kingdeeBillNo" label="金蝶单据号" min-width="150" align="center">
<template #default="{ row }">{{ displayValue(row.kingdeeBillNo) }}</template>
@@ -639,6 +654,22 @@
<el-table-column prop="createTime" label="创建时间" min-width="170" align="center">
<template #default="{ row }">{{ displayValue(row.createTime) }}</template>
</el-table-column>
<el-table-column
v-if="hasPermission('settlement_adjustment_repush')"
label="操作"
width="120"
align="center"
>
<template #default="{ row }">
<el-link
v-if="row.approvalStatus === 'approved' && row.kingdeeSyncStatus === 'synced'"
type="danger"
@click="handleAdjustmentRepush(row)"
>重新推送</el-link
>
<span v-else>-</span>
</template>
</el-table-column>
</el-table>
</section-card>
@@ -702,7 +733,7 @@
</el-button>
</div>
<el-dialog v-model="candidate.visible" title="选择预结算单" width="88%" append-to-body>
<el-dialog v-model="candidate.visible" title="选择预付结算单" width="88%" append-to-body>
<el-card>
<el-form
:model="candidate.query"
@@ -711,7 +742,7 @@
label-width="88px"
class="formal-editor__candidate-search"
>
<el-form-item label="预结算单号"
<el-form-item label="预付结算单号"
><el-input v-model="candidate.query.preSettlementNo" clearable
/></el-form-item>
<el-form-item label="合同编号"
@@ -836,20 +867,6 @@
<el-table-column type="index" label="序号" width="64" fixed="left" align="center" />
<el-table-column prop="cargoName" label="货物名称" min-width="140" align="center" />
<el-table-column prop="cargoType" label="货物类型" min-width="130" align="center" />
<el-table-column label="计费规则" min-width="190" align="center">
<template #default="{ row }">
<div class="formal-editor__billing-rule-cell">
<span>{{ displayValue(billingRuleName(row)) }}</span>
<el-icon
class="formal-editor__billing-rule-icon"
title="查看计费规则详情"
@click="openBillingRuleInfo(row)"
>
<InfoFilled />
</el-icon>
</div>
</template>
</el-table-column>
<el-table-column label="运输总量" min-width="150" align="center">
<template #default="{ row }">
<el-input-number
@@ -874,11 +891,14 @@
</el-table-column>
<el-table-column label="运输单价" min-width="140" align="center">
<template #default="{ row }">
<span v-if="isTierUnitPrice(row)">-</span>
<el-input-number
v-else
v-model="row.unitPrice"
:min="0"
:precision="2"
:controls="false"
:disabled="!isUnitPriceAdjustable(row)"
@change="recalculateAdjustRow(row, 'unitPrice')"
/>
</template>
@@ -887,11 +907,29 @@
v-for="feeItem in adjustFeeItemNames"
:key="feeItem"
:label="feeItem"
min-width="140"
min-width="160"
align="center"
>
<template #default="{ row }">
<div v-if="isFreightFeeItem(feeItem)" class="formal-editor__billing-rule-cell">
<el-input-number
v-model="row.feeItems[feeItem]"
:min="0"
:precision="2"
:controls="false"
@change="recalculateAdjustRow(row, feeItem)"
/>
<el-icon
v-if="hasBillingRule(row)"
class="formal-editor__billing-rule-icon"
title="查看计费规则详情"
@click="openBillingRuleInfo(row)"
>
<InfoFilled />
</el-icon>
</div>
<el-input-number
v-else
v-model="row.feeItems[feeItem]"
:min="0"
:precision="2"
@@ -905,11 +943,6 @@
<el-input-number v-model="row.settlementAmountTax" :precision="2" :controls="false" />
</template>
</el-table-column>
<el-table-column label="备注" min-width="200" align="center">
<template #default="{ row }">
<el-input v-model="row.remark" maxlength="200" />
</template>
</el-table-column>
</el-table>
<el-form
:model="adjust"
@@ -917,8 +950,15 @@
label-width="auto"
class="formal-editor__adjust-reason"
>
<el-form-item label="调整原因" required>
<el-input v-model="adjust.reason" maxlength="200" show-word-limit />
<el-form-item label="备注">
<el-input
v-model="adjust.reason"
type="textarea"
:rows="2"
maxlength="200"
show-word-limit
placeholder="请输入"
/>
</el-form-item>
</el-form>
<template #footer>
@@ -939,51 +979,45 @@
<template v-if="billingRuleDialog.rule">
<div class="dialog-section-title">计费规则</div>
<el-descriptions :column="2" border class="formal-editor__billing-rule-detail">
<el-descriptions-item label="规则名称">{{
displayValue(billingRuleDialog.rule.name)
}}</el-descriptions-item>
<el-descriptions-item label="费用类型">{{
displayValue(billingRuleDialog.rule.feeType)
}}</el-descriptions-item>
<el-descriptions-item label="费用项">{{
displayValue(billingRuleDialog.rule.feeItem)
}}</el-descriptions-item>
<el-descriptions-item label="计费要素">{{
displayValue(billingRuleDialog.rule.billingElement)
}}</el-descriptions-item>
<el-descriptions-item label="计费类型">{{
displayValue(billingRuleDialog.rule.billingType)
}}</el-descriptions-item>
<el-descriptions-item label="计费单位">{{
displayValue(billingRuleDialog.rule.billingUnit)
}}</el-descriptions-item>
<el-descriptions-item label="单价">{{
displayValue(billingRuleDialog.rule.unitPrice)
}}</el-descriptions-item>
<el-descriptions-item label="最低计费量">{{
displayValue(billingRuleDialog.rule.minimumBillingWeight)
}}</el-descriptions-item>
<el-descriptions-item label="计费区间">{{
billingRuleRanges(billingRuleDialog.rule)
}}</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">{{
displayValue(billingRuleDialog.rule.remark)
}}</el-descriptions-item>
<el-descriptions-item label="费用项">
{{ displayValue(billingRuleDialog.rule.feeItem) }}
</el-descriptions-item>
<el-descriptions-item label="计费要素">
{{ displayValue(billingRuleDialog.rule.billingElement) }}
</el-descriptions-item>
<el-descriptions-item label="计费类型">
{{ displayValue(billingRuleDialog.rule.billingType) }}
</el-descriptions-item>
<el-descriptions-item label="计费单位">
{{ displayValue(billingRuleDialog.rule.billingUnit) }}
</el-descriptions-item>
<el-descriptions-item label="单价">
{{ displayValue(billingRuleDialog.rule.unitPrice) }}
</el-descriptions-item>
<el-descriptions-item label="最低计费量">
{{ displayValue(billingRuleDialog.rule.minimumBillingWeight) }}
</el-descriptions-item>
<el-descriptions-item label="计费区间">
{{ billingRuleRanges(billingRuleDialog.rule) }}
</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">
{{ displayValue(billingRuleDialog.rule.remark) }}
</el-descriptions-item>
</el-descriptions>
<div class="dialog-section-title formal-editor__billing-rule-match-title">匹配条件</div>
<el-descriptions :column="2" border class="formal-editor__billing-rule-detail">
<el-descriptions-item label="起运地">{{
displayValue(billingRuleDialog.rule.matchCondition.origin)
}}</el-descriptions-item>
<el-descriptions-item label="目的地">{{
displayValue(billingRuleDialog.rule.matchCondition.destination)
}}</el-descriptions-item>
<el-descriptions-item label="运输方式">{{
displayValue(billingRuleDialog.rule.matchCondition.transportMode)
}}</el-descriptions-item>
<el-descriptions-item label="货物类型">{{
displayValue(billingRuleDialog.rule.matchCondition.cargoType)
}}</el-descriptions-item>
<el-descriptions-item label="起运地">
{{ displayValue(billingRuleDialog.rule.matchCondition.origin) }}
</el-descriptions-item>
<el-descriptions-item label="目的地">
{{ displayValue(billingRuleDialog.rule.matchCondition.destination) }}
</el-descriptions-item>
<el-descriptions-item label="货物名称">
{{ displayValue(billingRuleDialog.rule.matchCondition.cargoName) }}
</el-descriptions-item>
<el-descriptions-item label="货物类型">
{{ displayValue(billingRuleDialog.rule.matchCondition.cargoType) }}
</el-descriptions-item>
</el-descriptions>
</template>
<el-empty v-else description="暂无计费规则详情" />
@@ -995,6 +1029,7 @@
</template>
<script>
import { InfoFilled } from '@element-plus/icons-vue';
import { getMkPublicDetail } from '@/api/mk-process';
import {
adjustDetail,
@@ -1034,10 +1069,14 @@ import {
} from '@/option/settlement/formalSettlementTable';
import { getDictionary } from '@/api/system/dictbiz';
import { h } from 'vue';
import { InfoFilled } from '@element-plus/icons-vue';
import { mapGetters } from 'vuex';
import { formatContractOptionLabel } from '@/utils/contract';
import { isTierUnitPrice, isUnitPriceAdjustable } from '@/utils/settlement-adjust-rule';
import { normalizeCurrencyCode } from '@/utils/currency';
import {
settlementRecordTypeName,
settlementStatusName,
} from '@/utils/settlementStatus';
import { downloadFileByUrl } from '@/utils/util';
import {
downloadKingdeeInvoiceFile,
@@ -1048,6 +1087,7 @@ import KingdeeInvoicePoolDialog from '@/components/kingdee-invoice-pool-dialog/m
import ProjectAdvanceWriteOff from './project-advance-write-off.vue';
import * as XLSX from 'xlsx';
import { isAdministrator } from '@/utils/auth';
import * as settlementAdjustmentApi from '@/api/settlement/settlementAdjustment';
// 结算币种为本位币(人民币)时汇率恒为1,汇率日期、结算汇率与按汇率换算的本位币合计都不展示
const LOCAL_CURRENCY_HIDDEN_FIELDS = ['exchangeRateDate', 'exchangeRate', 'localSettlementAmount'];
@@ -1080,6 +1120,7 @@ export default {
details: [],
summaryFees: [],
paymentApplications: [],
advancePayments: [],
receiptClaims: [],
adjustments: [],
changeRecords: [],
@@ -1220,7 +1261,13 @@ export default {
return isAdministrator(this.userInfo);
},
title() {
return this.readonly ? '查看正式结算单' : this.recordId ? '编辑正式结算单' : '新增正式结算单';
const billLabel =
this.form.settlementType === 'receivable' ? '收款结算单' : '付款结算单';
return this.readonly
? `查看${billLabel}`
: this.recordId
? `编辑${billLabel}`
: `新增${billLabel}`;
},
detailFeeItemNames() {
const names = new Set();
@@ -1253,6 +1300,34 @@ export default {
summaryTotal() {
return this.summaryFees.reduce((total, row) => total + Number(row.settlementAmount || 0), 0);
},
// 已付金额(含预付、核销):编辑态取来源预结算预付快照 + 当前核销行实时合计(草稿态无尾款申请);只读态用落库值
settlePaidTotal() {
if (!this.editable) return Number(this.form.paidAmount || 0);
const advancePaid = this.sources.reduce(
(sum, item) => sum + Number(item.advancePaidAmount || 0),
0
);
const writeOff = this.projectAdvanceWriteOffs.reduce(
(sum, row) => sum + Number(row.writeOffAmount || 0),
0
);
return advancePaid + writeOff;
},
settleRemainTotal() {
return Math.max(Number(this.form.settlementAmount || 0) - Number(this.settlePaidTotal || 0), 0);
},
// 付款记录合并表:预付付款记录(进度预付/项目预付核销)+ 尾款付款申请
paymentRecords() {
const advances = (this.advancePayments || []).map(row => ({
...row,
typeName: settlementRecordTypeName(row.recordType),
}));
const tails = (this.paymentApplications || []).map(row => ({
...row,
typeName: row.paymentTypeName,
}));
return [...advances, ...tails];
},
filteredDetails() {
return this.details.filter(row =>
Object.entries(this.appliedDetailQuery).every(([field, keyword]) => {
@@ -1312,9 +1387,32 @@ export default {
},
},
methods: {
isTierUnitPrice,
isUnitPriceAdjustable,
formatContractOptionLabel,
hasPermission(code) {
return this.isAdmin || this.validData(this.permission?.[code], false);
if (this.isAdmin) return true;
const action = String(code || '').replace(
/^(payment_settlement_|receipt_settlement_|formal_settlement_)/,
''
);
const prefix =
this.form.settlementType === 'receivable' ? 'receipt_settlement' : 'payment_settlement';
return (
this.validData(this.permission?.[`${prefix}_${action}`], false) ||
this.validData(this.permission?.[`formal_settlement_${action}`], false)
);
},
async handleAdjustmentRepush(row) {
await this.$confirm(
'请确认金蝶旧应付/应收单已由财务手工冲销,继续将生成全新财务应付/应收单。',
'高危操作确认',
{ type: 'warning', confirmButtonText: '确认重新推送' }
);
const res = await settlementAdjustmentApi.repush(row.id);
this.$message.success(`已生成新金蝶单据:${res.data?.data || res.data || '-'}`);
await this.loadFormalDetail(this.recordId);
this.$emit('success');
},
async loadFormalDetail(id) {
const response = this.publicMode
@@ -1337,6 +1435,7 @@ export default {
this.detailFeeSnapshots = {};
this.pendingAdjustments = {};
this.paymentApplications = data.paymentApplications || [];
this.advancePayments = data.advancePayments || [];
if (this.readonly && this.form.settlementType === 'receivable' && !this.publicMode) {
this.receiptClaims = this.unwrapData(await getReceiptClaims(id)) || [];
}
@@ -1380,6 +1479,7 @@ export default {
this.adjustments = [];
this.changeRecords = [];
this.projectAdvanceWriteOffs = [];
this.advancePayments = [];
this.attachments = [];
this.selectedAttachmentRows = [];
this.invoices = [];
@@ -1528,6 +1628,19 @@ export default {
this.sources.map(item => getPreSettlementDetail(item.preSettlementId))
);
const settlements = responses.map(response => this.unwrapData(response) || {});
// 预结算转正式:带出来源预结算已保存的项目预付核销行(后端保存时转移源行)
const writeOffRows = settlements.flatMap(settlement => settlement.projectAdvanceWriteOffs || []);
const existingWriteOffIds = new Set(
this.projectAdvanceWriteOffs.map(row => String(row.paymentApplicationId))
);
writeOffRows.forEach(row => {
if (existingWriteOffIds.has(String(row.paymentApplicationId))) return;
existingWriteOffIds.add(String(row.paymentApplicationId));
this.projectAdvanceWriteOffs.push({
...row,
writeOffAmount: Number(row.writeOffAmount || 0),
});
});
this.details = settlements.flatMap(settlement =>
(settlement.details || []).map(detail => ({
...detail,
@@ -1698,7 +1811,7 @@ export default {
this.candidate.page.current = 1;
this.loadCandidates();
},
confirmCandidates() {
async confirmCandidates() {
const merged = [...this.sources, ...this.candidate.selected];
const map = new Map(
merged.map(item => [
@@ -1706,6 +1819,7 @@ export default {
{ ...item, preSettlementId: item.preSettlementId || item.id },
])
);
const previousIds = new Set(this.sources.map(item => String(item.preSettlementId || item.id)));
this.sources = [...map.values()];
this.form.sourcePreSettlementIds = this.sources.map(item => item.preSettlementId);
if (this.sources.length) {
@@ -1722,6 +1836,26 @@ export default {
this.form.localSettlementAmount =
this.form.settlementAmount * Number(this.form.exchangeRate || 1);
this.candidate.visible = false;
// 预结算转正式:带出来源预结算已保存的项目预付核销行(后端保存时转移源行,额度单份占用)
const newIds = this.sources
.map(item => item.preSettlementId)
.filter(id => !previousIds.has(String(id)));
if (!newIds.length) return;
const responses = await Promise.all(newIds.map(id => getPreSettlementDetail(id)));
const rows = responses.flatMap(response =>
this.unwrapData(response)?.projectAdvanceWriteOffs || []
);
const existing = new Set(
this.projectAdvanceWriteOffs.map(row => String(row.paymentApplicationId))
);
rows.forEach(row => {
if (existing.has(String(row.paymentApplicationId))) return;
existing.add(String(row.paymentApplicationId));
this.projectAdvanceWriteOffs.push({
...row,
writeOffAmount: Number(row.writeOffAmount || 0),
});
});
},
removeSource(index) {
this.sources.splice(index, 1);
@@ -2112,15 +2246,21 @@ export default {
const settlementType = row.settlementType || this.form.settlementType || 'payable';
const detailId = await resolveReceivablePayableDetailId(row, settlementType);
if (!detailId) return this.$message.info('当前记录未找到对应的应收/应付明细');
this.$router.push({ path: settlementDetailPath(settlementType), query: { detailId } });
await this.$router.push({ path: settlementDetailPath(settlementType), query: { detailId } });
this.closeDetailDialog();
return;
}
if (column.prop === 'waybillNo') {
const waybillId = await resolveWaybillId(row);
if (!waybillId) return this.$message.info('当前记录未找到对应的运单详情');
this.$router.push({ path: '/business/waybill-manage/detail', query: { id: waybillId } });
await this.$router.push({ path: '/business/waybill-manage/detail', query: { id: waybillId } });
this.closeDetailDialog();
}
},
closeDetailDialog() {
if (this.pageMode) return;
this.visible = false;
},
resetDetailQuery(apply = true) {
this.detailQuery = { documentNo: '', waybillNo: '', batchNo: '', cargoName: '' };
if (apply) this.handleDetailQuery();
@@ -2152,8 +2292,19 @@ export default {
)}.xlsx`
);
},
billingRuleName(row) {
return this.normalizeBillingRule(row).name;
hasBillingRule(row) {
const rule = this.normalizeBillingRule(row);
return Boolean(
rule.feeItem ||
rule.billingElement ||
rule.billingType ||
rule.unitPrice ||
rule.rules?.length ||
rule.matchCondition?.origin ||
rule.matchCondition?.destination ||
rule.matchCondition?.cargoName ||
rule.matchCondition?.cargoType
);
},
openBillingRuleInfo(row) {
this.billingRuleDialog.rule = this.normalizeBillingRule(row);
@@ -2179,26 +2330,8 @@ export default {
const matchCondition = this.parseObject(
source.matchCondition ?? source.billingMatchCondition ?? rule.matchCondition
);
const ruleNames = matchedRules
.map(item => item.ruleName || item.name || item.billingRuleName || item.feeItem)
.filter(Boolean);
return {
...rule,
name:
source.billingRuleName ||
source.feeRuleName ||
source.ruleName ||
source.billingPlanRuleName ||
source.billingPlanName ||
rule.name ||
rule.ruleName ||
rule.billingRuleName ||
rule.planName ||
rule.billingPlanName ||
ruleNames.join('、') ||
rule.feeItem ||
'',
feeType: source.billingFeeType || source.feeType || rule.feeType,
feeItem: source.billingFeeItem || source.feeItem || rule.feeItem,
billingElement:
source.billingElement ||
@@ -2216,7 +2349,11 @@ export default {
...matchCondition,
origin: matchCondition.origin || matchCondition.originName,
destination: matchCondition.destination || matchCondition.destinationName,
transportMode: matchCondition.transportMode || matchCondition.transportType,
cargoName:
matchCondition.cargoName ||
matchCondition.cargoNameLabel ||
source.cargoName ||
rule.cargoName,
cargoType: matchCondition.cargoType || matchCondition.cargoTypeName,
},
};
@@ -2247,11 +2384,16 @@ export default {
row.settlementAmountTax = Number(
(hasFreightItem ? feeItemTotal : Number(row.freightAmount || 0) + feeItemTotal).toFixed(2)
);
if (changedField && this.adjust.sourceDetailId && (row.sourceFeeId || row.id)) {
this.scheduleSourceAdjustCalculation(row);
if (
['transportQuantity', 'mileage', 'unitPrice'].includes(changedField) &&
this.adjust.sourceDetailId &&
(row.sourceFeeId || row.id) &&
(changedField !== 'unitPrice' || isUnitPriceAdjustable(row))
) {
this.scheduleSourceAdjustCalculation(row, changedField);
}
},
scheduleSourceAdjustCalculation(row) {
scheduleSourceAdjustCalculation(row, changedField) {
if (row.adjustCalculateTimer) clearTimeout(row.adjustCalculateTimer);
row.adjustCalculateVersion = Number(row.adjustCalculateVersion || 0) + 1;
row.calculating = true;
@@ -2264,6 +2406,8 @@ export default {
feeId: row.sourceFeeId || row.id,
transportQuantity: Number(row.transportQuantity || 0),
mileage: Number(row.mileage || 0),
unitPrice: row.unitPrice === null || row.unitPrice === '' ? null : Number(row.unitPrice),
changedField,
freightAmount: Number(row.freightAmount || 0),
feeItems: Object.fromEntries(
Object.entries(row.feeItems || {}).map(([name, amount]) => [name, Number(amount || 0)])
@@ -2275,6 +2419,9 @@ export default {
row.feeItems = Object.fromEntries(
Object.entries(data.feeItems || {}).map(([name, amount]) => [name, Number(amount || 0)])
);
if (!isTierUnitPrice(row) && data.unitPrice !== undefined && data.unitPrice !== null) {
row.unitPrice = Number(data.unitPrice);
}
row.adjustAmount = Number(data.adjustAmount || 0);
row.settlementAmountTax = Number(data.afterAmount || 0);
} catch (error) {
@@ -2294,7 +2441,11 @@ export default {
detailId: row.formalSettlementId ? row.id : null,
sourceDetailId: row.sourceDetailId || null,
feeKey,
reason: pending?.reason || '',
// 底部备注回显结算明细备注;暂存过的调整优先取暂存备注
reason:
pending?.reason !== undefined && pending?.reason !== null
? pending.reason
: row.remark || '',
rows: [],
targetRow: row.formalSettlementId ? null : row,
};
@@ -2317,7 +2468,6 @@ export default {
}
},
async saveAdjustment() {
if (!this.adjust.reason.trim()) return this.$message.warning('请输入调整原因');
if (this.adjust.rows.some(row => row.calculating)) {
return this.$message.warning('费用正在重新计算,请稍候');
}
@@ -2346,6 +2496,14 @@ export default {
.reduce((total, item) => total + Number(item.settlementAmountTax || 0), 0)
.toFixed(2)
);
const settlementAmountNoTax = Number(
this.adjust.rows
.reduce((total, item) => total + Number(item.settlementAmountNoTax || 0), 0)
.toFixed(2)
);
const hasSettlementAmountNoTax = this.adjust.rows.some(
item => item.settlementAmountNoTax !== undefined && item.settlementAmountNoTax !== null
);
const feeItems = this.adjust.rows.reduce((result, item) => {
Object.entries(item.feeItems || {}).forEach(([name, amount]) => {
result[name] = Number((Number(result[name] || 0) + Number(amount || 0)).toFixed(2));
@@ -2359,24 +2517,37 @@ export default {
originalAmount,
adjustAmount: Number((settlementAmount - originalAmount).toFixed(2)),
settlementAmountTax: settlementAmount,
settlementAmountNoTax: hasSettlementAmountNoTax
? settlementAmountNoTax
: target.settlementAmountNoTax,
feeItemsJson: JSON.stringify(feeItems),
freightAmount: this.adjust.rows.reduce(
(total, item) => total + Number(item.freightAmount || 0),
0
freightAmount: Number(
this.adjust.rows
.reduce((total, item) => total + Number(item.freightAmount || 0), 0)
.toFixed(2)
),
transportQuantity: this.adjust.rows.reduce(
(total, item) => total + Number(item.transportQuantity || 0),
0
transportQuantity: Number(
this.adjust.rows
.reduce((total, item) => total + Number(item.transportQuantity || 0), 0)
.toFixed(2)
),
mileage: Number(
this.adjust.rows
.reduce((total, item) => total + Number(item.mileage || 0), 0)
.toFixed(2)
),
mileage: this.adjust.rows.reduce((total, item) => total + Number(item.mileage || 0), 0),
unitPrice: edited.unitPrice,
remark: edited.remark,
// 底部备注写入结算明细备注
remark: this.adjust.reason || '',
pendingDetailAdjustment: true,
});
if (this.adjust.feeKey) {
const clonedRows = this.cloneAdjustRows(this.adjust.rows);
// 暂存后同步费用快照,避免再次打开调整弹窗或汇总时仍用调整前数据。
this.detailFeeSnapshots[this.adjust.feeKey] = clonedRows;
this.pendingAdjustments[this.adjust.feeKey] = {
reason: this.adjust.reason,
rows: this.cloneAdjustRows(this.adjust.rows),
rows: clonedRows,
};
}
await this.refreshSummaryFees();
@@ -2398,7 +2569,6 @@ export default {
feeItems: row.feeItems,
settlementAmountTax: row.settlementAmountTax,
settlementAmountNoTax: row.settlementAmountNoTax,
remark: row.remark,
})),
});
this.$message.success('调整保存成功');
@@ -2422,6 +2592,17 @@ export default {
}));
await this.confirmInvoiceClaims();
},
// 发票认领默认金额以当前结算金额为准:优先表单结算金额,其次结算合计,再次明细含税合计。
resolveInvoiceClaimSettlementAmount() {
const formAmount = Number(this.form.settlementAmount || 0);
if (formAmount > 0) return formAmount;
const summaryAmount = Number(this.summaryTotal || 0);
if (summaryAmount > 0) return summaryAmount;
return this.details.reduce(
(total, row) => total + Number(row.settlementAmountTax || row.settlementAmount || 0),
0
);
},
async confirmInvoiceClaims() {
if (!this.invoiceClaimDialog.selected.length) {
this.$message.warning('请至少选择一条发票');
@@ -2430,26 +2611,33 @@ export default {
this.invoiceClaimDialog.confirming = true;
try {
const existingNumbers = new Set(this.invoices.map(item => String(item.invoiceNo)));
const settlementAmount = this.resolveInvoiceClaimSettlementAmount();
if (settlementAmount > 0 && Number(this.form.settlementAmount || 0) <= 0) {
this.form.settlementAmount = Number(settlementAmount).toFixed(2);
}
let remaining = Math.max(
Number(this.form.settlementAmount || 0) -
settlementAmount -
this.invoices.reduce((total, item) => total + Number(item.matchedAmount || 0), 0),
0
);
const invoices = this.invoiceClaimDialog.selected
.filter(row => !existingNumbers.has(String(row.invoiceNo)))
.map(row => {
const sourceAmount = Number(row.matchedAmount || 0);
// 票池 matchedAmount 默认等于整张发票金额;可匹配口径优先取 availableInvoiceAmount
const sourceAmount = Number(
row.availableInvoiceAmount || row.matchedAmount || row.invoiceAmount || 0
);
// 可匹配金额大于剩余结算金额时,默认匹配金额取剩余结算金额(单张发票常见场景)
const matchedAmount =
Number(this.form.settlementAmount || 0) > 0
? Math.min(sourceAmount, remaining)
: sourceAmount;
if (Number(this.form.settlementAmount || 0) > 0) {
settlementAmount > 0 ? Math.min(sourceAmount, remaining) : sourceAmount;
if (settlementAmount > 0) {
remaining = Math.max(0, remaining - matchedAmount);
}
return {
...row,
invoiceType: row.invoiceTypeName || row.invoiceType || '',
matchedAmount,
availableInvoiceAmount: sourceAmount,
matchedAmount: Number(matchedAmount.toFixed(2)),
};
})
.filter(row => row.matchedAmount > 0);
@@ -2507,7 +2695,7 @@ export default {
}
matchedTotal += matchedAmount;
}
if (matchedTotal > Number(this.form.settlementAmount || 0)) {
if (matchedTotal > this.resolveInvoiceClaimSettlementAmount()) {
this.$message.warning('发票匹配结算单金额合计不能超过结算金额');
return false;
}
@@ -2615,7 +2803,7 @@ export default {
summaryFees: this.summaryFees
.filter(
row =>
row.manualFlag === 1 ||
Number(row.manualFlag) === 1 ||
row.id ||
Number(row.adjustAmount || 0) !== 0 ||
String(row.remark || '').trim()
@@ -2626,7 +2814,7 @@ export default {
feeItem: row.feeItem,
adjustAmount: Number(row.adjustAmount || 0),
remark: row.remark,
manualFlag: row.manualFlag || 0,
manualFlag: Number(row.manualFlag) === 1 ? 1 : 0,
})),
attachmentsJson: this.stringifyAttachments(this.attachments),
invoices: this.invoices.map(row => ({
@@ -2708,6 +2896,9 @@ export default {
};
return this.displayValue(labels[value] || value);
},
settlementStatusName(status) {
return settlementStatusName(status, this.displayValue);
},
unwrapData(response) {
const body = response?.data || response || {};
return body?.data || body;
@@ -3053,20 +3244,6 @@ export default {
.formal-editor__billing-rule-match-title {
margin-top: 20px;
}
.dialog-section-title {
display: flex;
align-items: center;
min-height: 22px;
font-size: 16px;
font-weight: 600;
}
.dialog-section-title::before {
width: 4px;
height: 18px;
margin-right: 8px;
background: #409eff;
content: '';
}
.formal-editor__attachment-missing {
margin-left: 12px;
color: var(--el-color-danger);
@@ -3104,6 +3281,9 @@ export default {
.formal-editor__negative-amount {
color: var(--el-color-danger);
}
.formal-editor__settle-summary {
margin-top: 8px;
}
.formal-editor :deep(.formal-editor__negative-amount .el-input__inner) {
color: var(--el-color-danger);
}
@@ -3,13 +3,13 @@
<div class="fs-table-panel__toolbar">
<div>
<el-button
v-if="hasPermission('formal_settlement_add')"
v-if="hasPermission('add')"
type="primary"
@click="$emit('create')"
>新增</el-button
>
<el-button
v-if="hasPermission('formal_settlement_payment')"
v-if="showPaymentAction && hasPermission('payment')"
type="primary"
plain
:disabled="!selection.length"
@@ -17,23 +17,23 @@
>付款申请</el-button
>
<el-button
v-if="hasPermission('formal_settlement_sync')"
v-if="hasPermission('sync')"
type="primary"
plain
:disabled="selection.length !== 1"
:disabled="!selection.length"
:loading="syncLoading"
@click="$emit('sync')"
>同步金蝶</el-button
>
<el-button
v-if="hasPermission('formal_settlement_print')"
v-if="hasPermission('print')"
type="primary"
plain
@click="emitSingle('print')"
>打印结算单</el-button
>
<el-button
v-if="hasPermission('formal_settlement_export')"
v-if="hasPermission('export')"
type="primary"
plain
@click="$emit('export')"
@@ -92,6 +92,7 @@
<span v-else-if="column.prop === 'kingdeeSyncStatus'">{{
kingdeeSyncName(row.kingdeeSyncStatus)
}}</span>
<span v-else-if="column.prop === 'adjustFlag'">{{ adjustFlag(row) }}</span>
<template v-else-if="column.prop === 'kingdeeLockStatus'">
<el-tooltip v-if="lockTag(row).show" :content="lockTag(row).tip" placement="top">
<el-tag :type="lockTag(row).type" class="status-text">{{ lockTag(row).label }}</el-tag>
@@ -149,6 +150,9 @@ export default {
hasPermission: { type: Function, required: true },
mkEnabled: { type: Boolean, default: false },
searchVisible: { type: Boolean, default: true },
/** 是否展示付款申请按钮(仅付款结算单) */
showPaymentAction: { type: Boolean, default: true },
billLabel: { type: String, default: '结算单' },
},
emits: [
'create',
@@ -223,7 +227,7 @@ export default {
},
emitSingle(type) {
if (this.selection.length !== 1) {
this.$message.warning(`${type === 'print' ? '打印' : '操作'}需选择一条正式结算单`);
this.$message.warning(`${type === 'print' ? '打印' : '操作'}需选择一条${this.billLabel}`);
return;
}
this.$emit('action', { type, row: this.selection[0] });
@@ -233,27 +237,26 @@ export default {
},
rowActions(row) {
const actions = [];
if (this.hasPermission('formal_settlement_view'))
actions.push({ type: 'view', label: '查看' });
if (this.hasPermission('formal_settlement_edit') && this.isEditable(row))
if (this.hasPermission('view')) actions.push({ type: 'view', label: '查看' });
if (this.hasPermission('edit') && this.isEditable(row))
actions.push({ type: 'edit', label: '编辑' });
if (this.hasPermission('formal_settlement_delete') && row.approvalStatus === 'draft')
if (this.hasPermission('delete') && row.approvalStatus === 'draft')
actions.push({ type: 'delete', label: '删除', danger: true });
if (this.hasPermission('formal_settlement_submit') && this.isEditable(row))
if (this.hasPermission('submit') && this.isEditable(row))
actions.push({ type: 'submit', label: '提交' });
if (
this.mkEnabled &&
this.hasPermission('formal_settlement_approve') &&
this.hasPermission('approve') &&
['reviewing', 'approved'].includes(row.approvalStatus)
) {
actions.push({ type: 'mkAudit', label: '流程' });
}
if (!this.mkEnabled && this.hasPermission('formal_settlement_approve') && row.approvalStatus === 'reviewing') {
if (!this.mkEnabled && this.hasPermission('approve') && row.approvalStatus === 'reviewing') {
actions.push({ type: 'approve', label: '通过' });
actions.push({ type: 'return', label: '驳回', danger: true });
}
if (
this.hasPermission('formal_settlement_void') &&
this.hasPermission('void') &&
row.approvalStatus === 'approved' &&
row.kingdeeSyncStatus !== 'synced'
)
@@ -275,6 +278,12 @@ export default {
kingdeeSyncName(value) {
return kingdeeSyncStatusOptions.find(item => item.value === value)?.label || value || '-';
},
adjustFlag(row) {
// 原单已调整 / 重推生成的新单(显示来源原单号)
if (row.adjustStatusName) return row.adjustStatusName;
if (row.originFormalSettlementNo) return '调整后单';
return '-';
},
lockTag(row) {
if (row.kingdeeLockStatus === 'locked') {
return { show: true, type: 'danger', label: '金蝶锁定中', tip: '该单据已被金蝶锁定,不可编辑/作废' };
@@ -256,13 +256,23 @@
show-overflow-tooltip
>
<template #default="{ row }">
<span v-if="item.kind === 'fee'">
{{
formatMoney(
parseFeeItems(row.feeItemsJson)[item.name],
row.currency || form.currency
)
}}
<span v-if="item.kind === 'fee'" class="pre-settlement-editor__billing-rule-cell">
<span>
{{
formatMoney(
parseFeeItems(row.feeItemsJson)[item.name],
row.currency || form.currency
)
}}
</span>
<el-icon
v-if="hasDetailBillingRule(row)"
class="pre-settlement-editor__billing-rule-icon"
title="查看计费规则详情"
@click.stop="openDetailBillingRule(row, item.name)"
>
<InfoFilled />
</el-icon>
</span>
<el-link
v-else-if="item.column.link && row[item.column.prop] && !publicMode"
@@ -274,6 +284,20 @@
<span v-else-if="item.column.money && item.column.prop === 'unitPrice'">
{{ formatUnitPrice(row) }}
</span>
<span
v-else-if="item.column.prop === 'freightAmount'"
class="pre-settlement-editor__billing-rule-cell"
>
<span>{{ formatMoney(row[item.column.prop], row.currency || form.currency) }}</span>
<el-icon
v-if="hasDetailBillingRule(row)"
class="pre-settlement-editor__billing-rule-icon"
title="查看计费规则详情"
@click.stop="openDetailBillingRule(row, '运输费')"
>
<InfoFilled />
</el-icon>
</span>
<span v-else-if="item.column.money">
{{ formatMoney(row[item.column.prop], row.currency || form.currency) }}
</span>
@@ -459,7 +483,7 @@
</section-card>
<section-card v-if="form.id && readonly" title="变更记录">
<el-table :data="adjustChangeRecords" border>
<el-table :data="changeRecords" border>
<el-table-column type="index" label="序号" width="64" align="center" />
<el-table-column
v-for="column in changeTableColumns"
@@ -753,20 +777,6 @@
<el-table-column type="index" label="序号" width="64" fixed="left" align="center" />
<el-table-column prop="cargoName" label="货物名称" min-width="140" align="center" />
<el-table-column prop="cargoType" label="货物类型" min-width="130" align="center" />
<el-table-column label="计费规则" min-width="190" align="center">
<template #default="{ row }">
<div class="pre-settlement-editor__billing-rule-cell">
<span>{{ displayValue(billingRuleName(row)) }}</span>
<el-icon
class="pre-settlement-editor__billing-rule-icon"
title="查看计费规则详情"
@click="openBillingRuleInfo(row)"
>
<InfoFilled />
</el-icon>
</div>
</template>
</el-table-column>
<el-table-column label="运输总量" min-width="150" align="center">
<template #default="{ row }">
<span v-if="adjustDialog.readonly">{{ formatQuantity(row) }}</span>
@@ -795,12 +805,14 @@
</el-table-column>
<el-table-column label="运输单价" min-width="140" align="center">
<template #default="{ row }">
<span v-if="isTierUnitPrice(row)">-</span>
<el-input-number
v-else
v-model="row.unitPrice"
:min="0"
:precision="2"
:controls="false"
:disabled="adjustDialog.readonly"
:disabled="adjustDialog.readonly || !isUnitPriceAdjustable(row)"
@change="recalculateAdjustRow(row, 'unitPrice')"
/>
</template>
@@ -809,18 +821,28 @@
v-for="feeItem in adjustFeeItemNames"
:key="feeItem"
:label="feeItem"
min-width="140"
min-width="160"
align="center"
>
<template #default="{ row }">
<el-input-number
v-model="row.feeItems[feeItem]"
:min="0"
:precision="2"
:controls="false"
:disabled="adjustDialog.readonly"
@change="recalculateAdjustRow(row, feeItem)"
/>
<div class="pre-settlement-editor__billing-rule-cell">
<el-input-number
v-model="row.feeItems[feeItem]"
:min="0"
:precision="2"
:controls="false"
:disabled="adjustDialog.readonly"
@change="recalculateAdjustRow(row, feeItem)"
/>
<el-icon
v-if="hasBillingRule(row)"
class="pre-settlement-editor__billing-rule-icon"
title="查看计费规则详情"
@click="openBillingRuleInfo(row, feeItem)"
>
<InfoFilled />
</el-icon>
</div>
</template>
</el-table-column>
<el-table-column label="结算金额(含税)" min-width="170" align="center">
@@ -833,11 +855,6 @@
/>
</template>
</el-table-column>
<el-table-column label="备注" min-width="200" align="center">
<template #default="{ row }">
<el-input v-model="row.remark" maxlength="200" :disabled="adjustDialog.readonly" />
</template>
</el-table-column>
</el-table>
<el-form
v-if="!adjustDialog.readonly"
@@ -846,7 +863,7 @@
label-width="auto"
class="pre-settlement-editor__adjust-reason"
>
<el-form-item label="调整原因">
<el-form-item label="备注">
<el-input
v-model="adjustDialog.reason"
type="textarea"
@@ -885,12 +902,6 @@
<template v-if="billingRuleDialog.rule">
<div class="dialog-section-title">计费规则</div>
<el-descriptions :column="2" border class="pre-settlement-editor__billing-rule-detail">
<el-descriptions-item label="规则名称">
{{ displayValue(billingRuleDialog.rule.name) }}
</el-descriptions-item>
<el-descriptions-item label="费用类型">
{{ displayValue(billingRuleDialog.rule.feeType) }}
</el-descriptions-item>
<el-descriptions-item label="费用项">
{{ displayValue(billingRuleDialog.rule.feeItem) }}
</el-descriptions-item>
@@ -926,8 +937,8 @@
<el-descriptions-item label="目的地">
{{ displayValue(billingRuleDialog.rule.matchCondition.destination) }}
</el-descriptions-item>
<el-descriptions-item label="运输方式">
{{ displayValue(billingRuleDialog.rule.matchCondition.transportMode) }}
<el-descriptions-item label="货物名称">
{{ displayValue(billingRuleDialog.rule.matchCondition.cargoName) }}
</el-descriptions-item>
<el-descriptions-item label="货物类型">
{{ displayValue(billingRuleDialog.rule.matchCondition.cargoType) }}
@@ -989,7 +1000,9 @@ import {
settlementSummaryColumns,
} from '@/option/settlement/preSettlementTable';
import { formatContractOptionLabel } from '@/utils/contract';
import { isTierUnitPrice, isUnitPriceAdjustable } from '@/utils/settlement-adjust-rule';
import { normalizeCurrencyCode } from '@/utils/currency';
import { settlementStatusName } from '@/utils/settlementStatus';
import { downloadFileByUrl } from '@/utils/util';
import { loadMkEnabled, submitMkApprovalFlow } from '@/utils/mk-approval';
import * as XLSX from 'xlsx';
@@ -1202,8 +1215,8 @@ export default {
return this.editable && this.hasPermission('pre_settlement_adjust');
},
dialogTitle() {
if (this.readonly) return '查看预结算单';
return this.form.id ? '编辑预结算单' : '新增预结算单';
if (this.readonly) return '查看预付结算单';
return this.form.id ? '编辑预付结算单' : '新增预付结算单';
},
settlementTypeName() {
return this.form.settlementType === 'receivable' ? '应收' : '应付';
@@ -1237,8 +1250,14 @@ export default {
});
return Array.from(names);
},
// 费用项里已有运输费/运费时,不再单独展示运费列,避免和应收应付费用项重复。
showStandaloneFreightColumn() {
return !this.detailFeeItemNames.some(name => this.isFreightFeeItem(name));
},
detailDisplayColumns() {
const columns = this.visibleDetailColumns;
const columns = this.visibleDetailColumns.filter(
column => this.showStandaloneFreightColumn || column.prop !== 'freightAmount'
);
const unitPriceIndex = columns.findIndex(column => column.prop === 'unitPrice');
const beforeColumns = unitPriceIndex < 0 ? columns : columns.slice(0, unitPriceIndex + 1);
const afterColumns = unitPriceIndex < 0 ? [] : columns.slice(unitPriceIndex + 1);
@@ -1285,13 +1304,6 @@ export default {
});
return Array.from(names);
},
adjustChangeRecords() {
return this.changeRecords.filter(
row =>
row.changeType === '结算明细项' &&
String(row.lineNo ?? '') === String(this.adjustDialog.detailLineNo ?? '')
);
},
},
watch: {
modelValue: {
@@ -1316,6 +1328,8 @@ export default {
},
},
methods: {
isTierUnitPrice,
isUnitPriceAdjustable,
formatContractOptionLabel,
hasPermission(code) {
return this.isAdmin || this.validData(this.permission?.[code], false);
@@ -1865,7 +1879,25 @@ export default {
});
const manualFees = this.summaryFees.filter(row => Number(row.manualFlag) === 1);
this.summaryFees = [...summaryMap.values(), ...manualFees];
const nextFeeMap = new Map();
summaryMap.forEach((row, key) => nextFeeMap.set(`0\u0000${key}`, row));
manualFees.forEach(row => {
const key = `1\u0000${row.feeType}\u0000${row.feeItem}`;
nextFeeMap.set(key, row);
});
// 按编辑前顺序回填,新增费用项追加到末尾,避免手工费用被统一挤到最后。
const orderedFees = [];
const previousKeys = this.summaryFees.map(
row => `${Number(row.manualFlag) === 1 ? 1 : 0}\u0000${row.feeType}\u0000${row.feeItem}`
);
previousKeys.forEach(key => {
const row = nextFeeMap.get(key);
if (!row) return;
orderedFees.push(row);
nextFeeMap.delete(key);
});
nextFeeMap.forEach(row => orderedFees.push(row));
this.summaryFees = orderedFees;
this.recalculateLocalAmount();
},
// 每条明细对应的费用行:[调整前基准行, 调整后当前行],缺少来源费用快照时退化为明细自身的汇总行。
@@ -2053,7 +2085,7 @@ export default {
}
},
async removeDetailRow(row) {
await this.$confirm('确认将该明细踢出预结算单?', '提示', { type: 'warning' });
await this.$confirm('确认将该明细踢出预付结算单?', '提示', { type: 'warning' });
if (!this.form.id || !row.id || row.id === row.sourceDetailId) {
this.details = this.details.filter(item => item !== row);
this.buildSummaryFeesFromDetails();
@@ -2228,7 +2260,11 @@ export default {
: '';
const sourceDetailId = String(this.adjustDialog.sourceDetailId || '');
const pending = sourceDetailId ? this.pendingAdjustments[sourceDetailId] : null;
this.adjustDialog.reason = pending?.reason || '';
// 底部备注回显结算明细备注;暂存过的调整优先取暂存备注
this.adjustDialog.reason =
pending?.reason !== undefined && pending?.reason !== null
? pending.reason
: detailRow.remark || '';
try {
// 已暂存的调整结果优先回显,避免重新打开时又回到调整前的数据。
if (pending?.rows?.length) {
@@ -2295,14 +2331,52 @@ export default {
this.adjustChangeRecordDetailRows = this.buildAdjustChangeRecordRows(row);
this.adjustChangeRecordVisible = true;
},
billingRuleName(row) {
return this.normalizeBillingRule(row).name;
hasBillingRule(row) {
const rule = this.normalizeBillingRule(row);
return Boolean(
rule.feeItem ||
rule.billingElement ||
rule.billingType ||
rule.unitPrice ||
rule.rules?.length ||
rule.matchCondition?.origin ||
rule.matchCondition?.destination ||
rule.matchCondition?.cargoName ||
rule.matchCondition?.cargoType
);
},
openBillingRuleInfo(row) {
this.billingRuleDialog.rule = this.normalizeBillingRule(row);
detailFeeRows(row = {}) {
return this.detailFeeCache[row.id] || this.detailFeeCache[row.preSettlementDetailId] || [];
},
hasDetailBillingRule(row) {
if (this.hasBillingRule(row)) return true;
return this.detailFeeRows(row).some(fee => this.hasBillingRule(fee));
},
openDetailBillingRule(row, feeName = '') {
const fees = this.detailFeeRows(row);
const matched = fees.find(fee =>
this.collectBillingRules(fee).some(rule =>
this.feeNamesMatch(this.ruleFeeName(rule), feeName)
)
);
const source = matched || fees.find(fee => this.hasBillingRule(fee)) || row;
this.openBillingRuleInfo(source, feeName);
},
openBillingRuleInfo(row, feeName = '') {
this.billingRuleDialog.rule = this.normalizeBillingRule(row, feeName);
this.billingRuleDialog.visible = true;
},
normalizeBillingRule(row) {
ruleFeeName(rule = {}) {
return String(rule.feeItem || rule.feeItemName || rule.name || '').trim();
},
feeNamesMatch(left, right) {
const source = String(left || '').trim();
const target = String(right || '').trim();
if (!source || !target) return false;
if (source === target) return true;
return this.isFreightFeeItem(source) && this.isFreightFeeItem(target);
},
collectBillingRules(row = {}) {
const source = row || {};
const nested = [
source.billingRule,
@@ -2315,53 +2389,73 @@ export default {
source.rule,
].find(value => value !== undefined && value !== null && value !== '');
const parsedNested = this.parseJsonValue(nested);
const matchedRules = Array.isArray(parsedNested)
return Array.isArray(parsedNested)
? parsedNested.filter(item => item && typeof item === 'object')
: [];
let rule = this.parseObject(matchedRules[0] || parsedNested || nested);
if (!Object.keys(rule).length && typeof nested === 'string') rule = { name: nested };
},
normalizeBillingRule(row, feeName = '') {
const source = row || {};
const nested = [
source.billingRule,
source.billingRuleInfo,
source.billingRuleJson,
source.billingRulesJson,
source.billingRules,
source.billingPlanRule,
source.feeRule,
source.rule,
].find(value => value !== undefined && value !== null && value !== '');
const parsedNested = this.parseJsonValue(nested);
const parsedRules = this.collectBillingRules(source);
const requestedFeeName = String(feeName || '').trim();
const matchedRules = requestedFeeName
? parsedRules.filter(item => this.feeNamesMatch(this.ruleFeeName(item), requestedFeeName))
: parsedRules;
const sharedRule =
parsedRules.length === 1 && !this.ruleFeeName(parsedRules[0]) ? parsedRules[0] : null;
const ruleSource =
matchedRules[0] || sharedRule || (!requestedFeeName ? parsedNested || nested : null);
let rule = this.parseObject(ruleSource);
if (!Object.keys(rule).length && typeof nested === 'string' && !requestedFeeName) {
rule = { name: nested };
}
const matchCondition = this.parseObject(
source.matchCondition ?? source.billingMatchCondition ?? rule.matchCondition
requestedFeeName
? (rule.matchCondition ?? source.matchCondition ?? source.billingMatchCondition)
: (source.matchCondition ?? source.billingMatchCondition ?? rule.matchCondition)
);
const ruleNames = matchedRules
.map(item => item.ruleName || item.name || item.billingRuleName || item.feeItem)
.filter(Boolean);
const name =
source.billingRuleName ||
source.feeRuleName ||
source.ruleName ||
source.billingPlanRuleName ||
source.billingPlanName ||
rule.name ||
rule.ruleName ||
rule.billingRuleName ||
rule.planName ||
rule.billingPlanName ||
ruleNames.join('、') ||
rule.feeItem ||
'';
return {
...rule,
name,
feeType: source.billingFeeType || source.feeType || rule.feeType,
feeItem: source.billingFeeItem || source.feeItem || rule.feeItem,
billingElement:
source.billingElement ||
source.billingFactor ||
rule.billingElement ||
rule.billingFactor,
billingType: source.billingType || rule.billingType,
billingUnit: source.billingUnit || source.priceUnit || rule.billingUnit || rule.priceUnit,
unitPrice: source.billingUnitPrice ?? source.unitPrice ?? rule.unitPrice,
minimumBillingWeight:
source.minimumBillingWeight ?? rule.minimumBillingWeight ?? rule.lowerLimit,
remark: source.billingRuleRemark || source.ruleRemark || rule.remark,
feeItem: requestedFeeName || source.billingFeeItem || source.feeItem || rule.feeItem,
billingElement: requestedFeeName
? rule.billingElement || rule.billingFactor || ''
: source.billingElement ||
source.billingFactor ||
rule.billingElement ||
rule.billingFactor,
billingType: requestedFeeName ? rule.billingType || '' : source.billingType || rule.billingType,
billingUnit: requestedFeeName
? rule.billingUnit || rule.priceUnit || ''
: source.billingUnit || source.priceUnit || rule.billingUnit || rule.priceUnit,
unitPrice: requestedFeeName
? (rule.unitPrice ?? '')
: (source.billingUnitPrice ?? source.unitPrice ?? rule.unitPrice),
minimumBillingWeight: requestedFeeName
? (rule.minimumBillingWeight ?? rule.lowerLimit ?? '')
: (source.minimumBillingWeight ?? rule.minimumBillingWeight ?? rule.lowerLimit),
remark: requestedFeeName
? rule.remark || ''
: source.billingRuleRemark || source.ruleRemark || rule.remark,
rules: matchedRules,
matchCondition: {
...matchCondition,
origin: matchCondition.origin || matchCondition.originName,
destination: matchCondition.destination || matchCondition.destinationName,
transportMode: matchCondition.transportMode || matchCondition.transportType,
cargoName:
matchCondition.cargoName ||
matchCondition.cargoNameLabel ||
source.cargoName ||
rule.cargoName,
cargoType: matchCondition.cargoType || matchCondition.cargoTypeName,
},
};
@@ -2396,11 +2490,16 @@ export default {
row.settlementAmountTax = Number(
(hasFreightItem ? feeItemTotal : Number(row.freightAmount || 0) + feeItemTotal).toFixed(2)
);
if (changedField && this.adjustDialog.sourceDetailId && row.id) {
this.scheduleSourceAdjustCalculation(row);
if (
['transportQuantity', 'mileage', 'unitPrice'].includes(changedField) &&
this.adjustDialog.sourceDetailId &&
row.id &&
(changedField !== 'unitPrice' || isUnitPriceAdjustable(row))
) {
this.scheduleSourceAdjustCalculation(row, changedField);
}
},
scheduleSourceAdjustCalculation(row) {
scheduleSourceAdjustCalculation(row, changedField) {
if (row.adjustCalculateTimer) clearTimeout(row.adjustCalculateTimer);
row.adjustCalculateVersion += 1;
row.calculating = true;
@@ -2413,6 +2512,8 @@ export default {
feeId: row.id,
transportQuantity: Number(row.transportQuantity || 0),
mileage: Number(row.mileage || 0),
unitPrice: row.unitPrice === null || row.unitPrice === '' ? null : Number(row.unitPrice),
changedField,
freightAmount: Number(row.freightAmount || 0),
feeItems: Object.fromEntries(
Object.entries(row.feeItems || {}).map(([name, amount]) => [
@@ -2427,6 +2528,9 @@ export default {
row.feeItems = Object.fromEntries(
Object.entries(data.feeItems || {}).map(([name, amount]) => [name, Number(amount || 0)])
);
if (!isTierUnitPrice(row) && data.unitPrice !== undefined && data.unitPrice !== null) {
row.unitPrice = Number(data.unitPrice);
}
row.adjustAmount = Number(data.adjustAmount || 0);
row.settlementAmountTax = Number(data.afterAmount || 0);
} catch (error) {
@@ -2451,9 +2555,13 @@ export default {
reason: this.adjustDialog.reason,
rows: this.adjustRows.map(row => ({ ...row, feeItems: { ...row.feeItems } })),
};
this.applyLocalAdjustment(this.adjustDialog.sourceDetailId, this.adjustRows);
this.applyLocalAdjustment(
this.adjustDialog.sourceDetailId,
this.adjustRows,
this.adjustDialog.reason
);
this.adjustDialog.visible = false;
this.$message.success('结算明细调整已暂存,保存预结算单后生效');
this.$message.success('结算明细调整已暂存,保存预付结算单后生效');
return;
}
await adjustDetail({
@@ -2468,7 +2576,6 @@ export default {
feeItems: row.feeItems,
settlementAmountTax: row.settlementAmountTax,
settlementAmountNoTax: row.settlementAmountNoTax,
remark: row.remark,
})),
});
this.adjustDialog.visible = false;
@@ -2479,12 +2586,12 @@ export default {
this.adjustDialog.saving = false;
}
},
applyLocalAdjustment(sourceDetailId, rows) {
applyLocalAdjustment(sourceDetailId, rows, detailRemark) {
const detail = this.details.find(
item => String(item.sourceDetailId || item.id) === String(sourceDetailId)
);
if (!detail) return;
// 原金额以进入预结算单时的费用快照为基准,调整金额 = 结算金额 - 原金额。
// 原金额以进入预付结算单时的费用快照为基准,调整金额 = 结算金额 - 原金额。
const baseRows = this.sourceFeeSnapshots[String(sourceDetailId)] || [];
const originalAmount = baseRows.length
? baseRows.reduce((sum, row) => sum + Number(row.settlementAmountTax || 0), 0)
@@ -2493,20 +2600,48 @@ export default {
(sum, row) => sum + Number(row.settlementAmountTax || 0),
0
);
const settlementAmountNoTax = rows.reduce(
(sum, row) => sum + Number(row.settlementAmountNoTax || 0),
0
);
const hasSettlementAmountNoTax = rows.some(
row => row.settlementAmountNoTax !== undefined && row.settlementAmountNoTax !== null
);
const freightAmount = rows.reduce((sum, row) => sum + Number(row.freightAmount || 0), 0);
const transportQuantity = rows.reduce(
(sum, row) => sum + Number(row.transportQuantity || 0),
0
);
const mileage = rows.reduce((sum, row) => sum + Number(row.mileage || 0), 0);
const feeItems = {};
rows.forEach(row =>
Object.entries(row.feeItems || {}).forEach(([name, amount]) => {
feeItems[name] = Number((Number(feeItems[name] || 0) + Number(amount || 0)).toFixed(2));
})
);
const firstRow = rows[0] || {};
Object.assign(detail, {
transportQuantity: Number(transportQuantity.toFixed(2)),
mileage: Number(mileage.toFixed(2)),
unitPrice: Number(firstRow.unitPrice || 0),
originalAmount: Number(originalAmount.toFixed(2)),
adjustAmount: Number((settlementAmountTax - originalAmount).toFixed(2)),
settlementAmountTax: Number(settlementAmountTax.toFixed(2)),
settlementAmountNoTax: hasSettlementAmountNoTax
? Number(settlementAmountNoTax.toFixed(2))
: detail.settlementAmountNoTax,
freightAmount: Number(freightAmount.toFixed(2)),
feeItemsJson: JSON.stringify(feeItems),
// 底部备注写入结算明细备注
remark: detailRemark ?? '',
});
// 暂存调整后同步费用缓存,保证货物名称/类型拼接与列表展示一致。
if (detail.id) {
this.detailFeeCache[detail.id] = rows.map(row => ({
...row,
feeItems: { ...row.feeItems },
}));
}
this.buildSummaryFeesFromDetails();
},
async persistPendingAdjustments() {
@@ -2534,11 +2669,14 @@ export default {
feeItems: pendingRow.feeItems,
settlementAmountTax: pendingRow.settlementAmountTax,
settlementAmountNoTax: pendingRow.settlementAmountNoTax,
remark: pendingRow.remark,
};
});
if (rows.length) {
await adjustDetail({ detailId: detail.id, changeReason: pending.reason, rows });
await adjustDetail({
detailId: detail.id,
changeReason: pending.reason,
rows,
});
}
}
this.pendingAdjustments = {};
@@ -2588,9 +2726,12 @@ export default {
运输总量: this.formatQuantity(row),
'里程(KM)': row.mileage,
批次号: row.batchNo,
计费方式: row.billingType,
运输单价: this.formatMoney(row.unitPrice, row.currency || this.form.currency),
运费: this.formatMoney(row.freightAmount, row.currency || this.form.currency),
};
if (this.showStandaloneFreightColumn) {
result['运费'] = this.formatMoney(row.freightAmount, row.currency || this.form.currency);
}
dynamicFeeItems.forEach(name => {
result[name] = this.formatMoney(feeItems[name], row.currency || this.form.currency);
});
@@ -2610,7 +2751,7 @@ export default {
XLSX.utils.book_append_sheet(workbook, sheet, '结算明细');
XLSX.writeFile(
workbook,
`${this.form.preSettlementNo || '预结算单'}结算明细${this.$dayjs().format(
`${this.form.preSettlementNo || '预付结算单'}结算明细${this.$dayjs().format(
'YYYY-MM-DD HH-mm-ss'
)}.xlsx`
);
@@ -2877,15 +3018,7 @@ export default {
return value === undefined || value === null || value === '' ? '-' : value;
},
advanceStatusName(status) {
return (
{
reviewing: '审批中',
approved: '审批通过',
paid: '已付款',
returned: '已驳回',
voided: '已作废',
}[status] || this.displayValue(status)
);
return settlementStatusName(status, this.displayValue);
},
advanceCreateUserName(row) {
return this.displayValue(
@@ -414,6 +414,8 @@ export default {
});
this.details = [];
this.recalculate();
// 金蝶冲销预检:软提示,不阻断建单(金蝶不可用时静默降级)
this.precheckWriteOff(formalSettlementId);
this.loading = true;
try {
const { data } = await api.getFormalDetails(formalSettlementId);
@@ -431,6 +433,19 @@ export default {
this.loading = false;
}
},
async precheckWriteOff(formalSettlementId) {
try {
const { data } = await api.kingdeeWriteOffPrecheck(formalSettlementId);
if (String(this.form.formalSettlementId) !== String(formalSettlementId)) return;
const result = data?.data || data || {};
if (!result.message) return;
if (result.syncStatus === 'synced' && result.writtenOff === false)
this.$message.warning(result.message);
else this.$message.info(result.message);
} catch (error) {
// 预检软提示:金蝶查询失败静默降级,不阻断建单
}
},
addFeeRow() {
this.details.push({
formalSettlementDetailId: null,
@@ -55,7 +55,7 @@
<el-option label="正式结算单" value="formal" />
<el-option
v-if="form.settlementType === 'payable'"
label="预结算单"
label="预付结算单"
value="pre"
/>
</el-select>
@@ -122,7 +122,7 @@
</div>
<div>
历史运单:按 项目+车号+运输完成日期+客户+承运商+起运地+目的地+货物名称
匹配已有运单(命中 1 条自动绑定,多条需手工指定运单号);提交时生成应收/应付明细与预/正式结算单,费用按导入单据,不新建运单
匹配尚未生成应收/应付的运单(命中 1 条自动绑定,多条可点「选择」弹窗挑选);提交时生成应收/应付明细与预/正式结算单,费用按导入单据,不新建运单
</div>
</template>
<el-icon class="settlement-import-create__label-tip"><QuestionFilled /></el-icon>
@@ -135,7 +135,7 @@
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="结算单上传" prop="file">
<el-form-item v-if="!readonly" label="结算单上传" prop="file">
<div class="settlement-import-create__upload">
<el-upload
ref="uploadRef"
@@ -143,13 +143,13 @@
accept=".xls,.xlsx"
:auto-upload="false"
:limit="1"
:disabled="readonly || !formReady"
:disabled="!formReady"
:file-list="files"
:on-change="onFileChange"
:on-exceed="onFileExceed"
:on-remove="onFileRemove"
>
<el-button type="primary" :disabled="readonly || !formReady">上传 Excel</el-button>
<el-button type="primary" :disabled="!formReady">上传 Excel</el-button>
</el-upload>
<el-link type="primary" :underline="false" @click="downloadTemplate">
下载模板
@@ -208,20 +208,59 @@
:prop="column.prop"
:label="column.label"
:min-width="column.minWidth || 120"
show-overflow-tooltip
:show-overflow-tooltip="readonly || !column.editor || column.readonly"
>
<template #default="{ row }">
<template v-if="row._editing && column.editor && !column.readonly">
<template v-if="!readonly && column.editor && !column.readonly">
<el-date-picker
v-if="column.editor === 'date'"
:key="`${row._key}-${column.prop}`"
v-model="row[column.prop]"
type="date"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
placeholder="请选择"
/>
<el-select
v-else-if="column.editor === 'select' && column.prop === 'transportType'"
:key="`${row._key}-${column.prop}`"
v-model="row[column.prop]"
clearable
filterable
placeholder="请选择运输方式"
style="width: 100%"
>
<el-option
v-for="item in transportTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<div
v-else-if="column.editor === 'waybillSelect'"
class="settlement-import-create__waybill-select"
>
<el-input v-model="row.waybillNo" clearable placeholder="运单号" />
<el-link type="primary" :underline="false" @click="openHistoryWaybillDialog(row)">
选择
</el-link>
</div>
<el-cascader
v-else-if="column.editor === 'cargoType'"
:key="`${row._key}-${column.prop}`"
:model-value="resolveCargoTypePath(row)"
:options="cargoTypeSelectOptions(row)"
:props="cargoTypeCascaderProps"
clearable
filterable
placeholder="请选择货物类型"
style="width: 100%"
@change="value => handleCargoTypeChange(row, value)"
/>
<el-input
v-else-if="column.editor === 'number'"
v-else-if="column.editor === 'number' || column.editor === 'optionalNumber'"
:key="`${row._key}-${column.prop}`"
:model-value="resolveCellValue(row, column)"
inputmode="decimal"
:placeholder="`请输入${column.label}`"
@@ -229,45 +268,78 @@
/>
<el-input
v-else
:key="`${row._key}-${column.prop}`"
v-model="row[column.prop]"
:placeholder="`请输入${column.label}`"
@update:model-value="value => syncEditedText(row, column, value)"
/>
</template>
<template v-else-if="column.editor === 'waybillSelect' && !readonly">
<div class="settlement-import-create__waybill-select">
<span>{{ row.waybillNo || '-' }}</span>
<el-link type="primary" :underline="false" @click="openHistoryWaybillDialog(row)">
选择
</el-link>
</div>
</template>
<span v-else>{{ formatCell(row, column) }}</span>
</template>
</el-table-column>
<el-table-column v-if="!readonly" label="操作" width="180" fixed="right">
<el-table-column v-if="!readonly" label="操作" width="120" fixed="right">
<template #default="{ row }">
<div class="settlement-import-create__row-actions">
<template v-if="row._editing">
<el-link type="primary" @click="saveRow(row)">保存</el-link>
<el-link type="primary" @click="cancelRow(row)">取消</el-link>
</template>
<template v-else>
<el-link v-if="row._duplicate" type="primary" @click="confirmDuplicateRow(row)">
确认
</el-link>
<el-link type="primary" @click="editRow(row)">编辑</el-link>
<el-link type="danger" @click="deleteRow(row)">删除</el-link>
</template>
<el-link v-if="row._duplicate" type="primary" @click="confirmDuplicateRow(row)">
确认
</el-link>
<el-link type="danger" @click="deleteRow(row)">删除</el-link>
</div>
</template>
</el-table-column>
</el-table>
</section>
<div class="settlement-import-create__footer">
<div v-if="!readonly" class="settlement-import-create__footer">
<el-button @click="goBack">取消</el-button>
<el-button v-if="!readonly" :loading="draftLoading" @click="saveDraft">保存草稿</el-button>
<el-button
v-if="!readonly"
type="primary"
:loading="confirmLoading"
@click="confirmImport"
>
<el-button :loading="draftLoading" @click="saveDraft">保存草稿</el-button>
<el-button type="primary" :loading="confirmLoading" @click="confirmImport">
确认导入
</el-button>
</div>
<el-dialog
v-model="historyWaybillVisible"
title="选择历史运单"
width="960px"
append-to-body
destroy-on-close
>
<div class="settlement-import-create__history-tip">
仅展示相同项目、客户合同、承运商合同下,尚未生成当前结算类型应收/应付明细的运单
</div>
<el-table
v-loading="historyWaybillLoading"
:data="historyWaybillRows"
border
max-height="420"
highlight-current-row
@row-dblclick="selectHistoryWaybill"
@current-change="row => (historyWaybillCurrent = row)"
>
<el-table-column prop="waybillNo" label="运单号" min-width="140" />
<el-table-column prop="vehicleNo" label="车号" min-width="120" />
<el-table-column prop="departureAddress" label="起运地" min-width="140" show-overflow-tooltip />
<el-table-column prop="arrivalAddress" label="目的地" min-width="140" show-overflow-tooltip />
<el-table-column prop="cargoName" label="货物名称" min-width="120" show-overflow-tooltip />
<el-table-column prop="actualEndDate" label="完成日期" min-width="120" />
<el-table-column prop="quantity" label="数量" width="90" />
<el-table-column prop="quantityUnit" label="数量单位" width="90" />
<el-table-column prop="mileage" label="里程" width="90" />
</el-table>
<template #footer>
<el-button @click="historyWaybillVisible = false">取消</el-button>
<el-button type="primary" @click="confirmHistoryWaybill">确定</el-button>
</template>
</el-dialog>
</div>
</template>
@@ -278,7 +350,9 @@ import { ElMessage, ElMessageBox } from 'element-plus';
import { QuestionFilled } from '@element-plus/icons-vue';
import dayjs from 'dayjs';
import * as api from '@/api/settlement/settlementImport';
import { getList as getCargoTypeList } from '@/api/base/cargo-type';
import { getList as getContractList } from '@/api/business/contract-manage';
import { getDictionary } from '@/api/system/dictbiz';
import { formatContractOptionLabel } from '@/utils/contract';
import { downloadXls } from '@/utils/util';
@@ -295,12 +369,27 @@ const parseLoading = ref(false);
const rowSelection = ref([]);
const previewTab = ref('all');
const feeItemNames = ref([]);
const parsedHeaders = ref([]);
const projects = ref([]);
const customerContracts = ref([]);
const carrierContracts = ref([]);
const draftLoading = ref(false);
const confirmLoading = ref(false);
const readonly = ref(false);
const transportTypeOptions = ref([]);
const cargoTypeOptions = ref([]);
const cargoTypeFlatOptions = ref([]);
const cargoTypeCascaderProps = {
label: 'cargoName',
value: 'id',
children: 'children',
emitPath: true,
};
const historyWaybillVisible = ref(false);
const historyWaybillLoading = ref(false);
const historyWaybillRows = ref([]);
const historyWaybillCurrent = ref(null);
const historyWaybillTargetRow = ref(null);
const createDefaultForm = () => ({
id: undefined,
@@ -404,59 +493,143 @@ const loadContractsByProject = async (projectId, projectName = '') => {
.filter(Boolean);
};
const fixedDetailColumns = [
{ prop: 'loadingIdentifier', label: '配载标识号', editor: 'input', minWidth: 140 },
{ prop: 'batchNo', label: '运单批次号', editor: 'input', minWidth: 140 },
const columnsBeforeFee = [
{ prop: 'originalNo', label: '原始单号', editor: 'input', minWidth: 130 },
{ prop: 'loadingIdentifier', label: '配载标识号', editor: 'input', minWidth: 140 },
{
prop: 'vehicleNo',
label: '车牌号/航班号/船号/班列号',
editor: 'input',
minWidth: 190,
},
{ prop: 'driverName', label: '司机/船长', editor: 'input', minWidth: 120 },
{ prop: 'transportType', label: '运输方式', editor: 'input', minWidth: 110 },
{ prop: 'departureAddress', label: '起运地', editor: 'input', minWidth: 160 },
{ prop: 'arrivalAddress', label: '目的地', editor: 'input', minWidth: 160 },
{ prop: 'transportType', label: '运输方式', editor: 'select', minWidth: 140 },
{ prop: 'driverName', label: '司机/船长姓名', editor: 'input', minWidth: 130 },
{ prop: 'driverPhone', label: '司机/船长手机号', editor: 'input', minWidth: 150 },
{ prop: 'departureAddress', label: '发货地址', editor: 'input', minWidth: 160 },
{ prop: 'departureContact', label: '发货联系人', editor: 'input', minWidth: 120 },
{ prop: 'departurePhone', label: '发货联系人电话', editor: 'input', minWidth: 140 },
{ prop: 'arrivalAddress', label: '到货地址', editor: 'input', minWidth: 160 },
{ prop: 'arrivalContact', label: '收货联系人', editor: 'input', minWidth: 120 },
{ prop: 'arrivalPhone', label: '收货联系人电话', editor: 'input', minWidth: 140 },
{ prop: 'cargoName', label: '货物名称', editor: 'input', minWidth: 140 },
{ prop: 'actualStartDate', label: '开始时间', editor: 'date', minWidth: 140 },
{ prop: 'actualEndDate', label: '运输完成日期', editor: 'date', minWidth: 140 },
{ prop: 'unitPrice', label: '单价', editor: 'number', minWidth: 100, feeField: false },
{ prop: 'transportFee', label: '运费', editor: 'number', minWidth: 100 },
{ prop: 'cargoType', label: '货物类型', editor: 'cargoType', minWidth: 200 },
{ prop: 'packageType', label: '包装', editor: 'input', minWidth: 100 },
{ prop: 'quantity', label: '数量', editor: 'number', minWidth: 100 },
{ prop: 'quantityUnit', label: '数量单位', editor: 'input', minWidth: 110 },
{ prop: 'specification', label: '规格', editor: 'input', minWidth: 110 },
{ prop: 'model', label: '型号', editor: 'input', minWidth: 110 },
{ prop: 'mileage', label: '里程(km)', editor: 'optionalNumber', minWidth: 110 },
{ prop: 'unitPrice', label: '运输单价', editor: 'optionalNumber', minWidth: 110 },
{ prop: 'transportFee', label: '运输费', editor: 'number', minWidth: 110 },
];
const columnsAfterFee = [
{ prop: 'actualStartDate', label: '实际发货时间', editor: 'date', minWidth: 150 },
{ prop: 'actualEndDate', label: '实际完成时间', editor: 'date', minWidth: 150 },
{ prop: 'planStartDate', label: '预计发货时间', editor: 'date', minWidth: 150 },
{ prop: 'planEndDate', label: '预计完成时间', editor: 'date', minWidth: 150 },
{ prop: 'remark', label: '备注', editor: 'input', minWidth: 160 },
{ prop: 'waybillIdentifier', label: '同一运单标识号', editor: 'input', minWidth: 150 },
];
const detailColumns = computed(() => {
const feeColumns = feeItemNames.value.map(name => ({
const headerColumnMap = {};
[...columnsBeforeFee, ...columnsAfterFee].forEach(column => {
headerColumnMap[column.label] = column;
headerColumnMap[`*${column.label}`] = column;
});
headerColumnMap['结算金额'] = {
prop: 'settlementAmount',
label: '结算金额',
editor: 'number',
minWidth: 120,
};
headerColumnMap['里程'] = headerColumnMap['里程(km)'];
headerColumnMap['单价'] = headerColumnMap['运输单价'];
headerColumnMap['运输类型'] = headerColumnMap['运输方式'];
headerColumnMap['*运输类型'] = headerColumnMap['运输方式'];
const VEHICLE_ALIAS_KEYS = [
'*车牌号/航班号/船号/班列号',
'车牌号/航班号/船号/班列号',
'*车牌号/船班号/船次号/班次号',
'车牌号/船班号/船次号/班次号',
'车号',
];
const readFilledText = value => {
const text = String(value ?? '').trim();
return text;
};
const applyVehicleNo = (row, value) => {
const vehicleNo = readFilledText(value);
row.vehicleNo = vehicleNo;
VEHICLE_ALIAS_KEYS.forEach(key => {
row[key] = vehicleNo;
});
};
const syncEditedText = (row, column, value) => {
if (column.prop !== 'vehicleNo') return;
applyVehicleNo(row, value);
};
const feeColumn = name => ({
prop: name,
label: name,
editor: 'number',
minWidth: 110,
isFeeItem: true,
});
const columnFromHeader = header => {
const name = String(header || '').trim();
if (!name || name === '序号') return null;
if (feeItemNames.value.includes(name)) return feeColumn(name);
const mapped = headerColumnMap[name];
if (mapped) return { ...mapped, label: mapped.label || name.replace(/^\*/, '') };
return {
prop: name,
label: name,
editor: 'number',
minWidth: 110,
isFeeItem: true,
}));
label: name.replace(/^\*/, ''),
editor: 'input',
minWidth: 140,
};
};
const dedupeColumns = columns => {
const seen = new Set();
return columns.filter(column => {
if (!column?.prop || seen.has(column.prop)) return false;
seen.add(column.prop);
return true;
});
};
const detailColumns = computed(() => {
const historyColumns =
form.waybillMode === 'history'
? [
{
prop: 'waybillNo',
label: '运单号',
editor: 'input',
minWidth: 150,
editor: 'waybillSelect',
minWidth: 180,
},
]
: [];
return [
...historyColumns,
...fixedDetailColumns,
...feeColumns,
const fallback = [
...columnsBeforeFee,
...feeItemNames.value.map(name => feeColumn(name)),
{
prop: 'settlementAmount',
label: '结算金额',
editor: 'number',
readonly: true,
minWidth: 120,
},
{ prop: 'remark', label: '备注', editor: 'input', minWidth: 140 },
...columnsAfterFee,
];
const uploaded = parsedHeaders.value.map(columnFromHeader).filter(Boolean);
const columns = dedupeColumns(uploaded.length ? uploaded : fallback);
return [...historyColumns, ...columns];
});
const duplicateRows = computed(() => rows.value.filter(row => row._duplicate));
@@ -532,9 +705,14 @@ const resolveCellValue = (row, column) => {
const formatCell = (row, column) => {
const value = resolveCellValue(row, column);
if (column.editor === 'number' || column.prop === 'settlementAmount') {
if (
column.editor === 'number' ||
column.editor === 'optionalNumber' ||
column.prop === 'settlementAmount'
) {
if (value === '' || value === null || value === undefined) return '';
return Number(value).toFixed(2);
const number = Number(value);
return Number.isFinite(number) ? number.toFixed(2) : '';
}
return value ?? '';
};
@@ -560,11 +738,28 @@ const recalcSettlementAmount = row => {
};
const updateNumberCell = (row, column, value) => {
const [integer = '', decimal = ''] = String(value || '')
.replace(/[^\d.]/g, '')
.split('.');
const raw = String(value ?? '').trim();
if (!raw) {
if (column.isFeeItem) {
if (!row.feeItems) row.feeItems = {};
row.feeItems[column.prop] = '';
row[column.prop] = '';
} else {
row[column.prop] = column.editor === 'optionalNumber' ? '' : '';
if (column.prop === 'transportFee') row.freight = '';
if (column.prop === 'unitPrice') row.transportUnitPrice = '';
}
if (column.prop === 'settlementAmount') {
row.settlementAmount = '';
row.freightTotal = '';
return;
}
recalcSettlementAmount(row);
return;
}
const [integer = '', decimal = ''] = raw.replace(/[^\d.]/g, '').split('.');
const normalized =
decimal || String(value || '').includes('.') ? `${integer}.${decimal.slice(0, 2)}` : integer;
decimal || raw.includes('.') ? `${integer}.${decimal.slice(0, 2)}` : integer;
if (column.isFeeItem) {
if (!row.feeItems) row.feeItems = {};
row.feeItems[column.prop] = normalized;
@@ -577,6 +772,11 @@ const updateNumberCell = (row, column, value) => {
if (column.prop === 'unitPrice') {
row.transportUnitPrice = normalized;
}
if (column.prop === 'settlementAmount') {
row.freightTotal = normalized;
row['运费合计'] = normalized;
return;
}
}
recalcSettlementAmount(row);
};
@@ -637,11 +837,28 @@ const normalizeParsedRow = (item, index) => {
loadingIdentifier: item.loadingIdentifier || item.loadingNo || '',
transportFee: item.transportFee ?? item.freight ?? item['*运输费'] ?? item['运输费'] ?? '',
unitPrice: item.unitPrice ?? item.transportUnitPrice ?? item['运输单价'] ?? item['单价'] ?? '',
mileage: item.mileage ?? item['里程(km)'] ?? item['里程'] ?? '',
quantity: item.quantity ?? item['*数量'] ?? item['数量'] ?? '',
quantityUnit: item.quantityUnit ?? item['*数量单位'] ?? item['数量单位'] ?? '',
model: item.model ?? item['型号'] ?? '',
specification: item.specification ?? item['规格'] ?? '',
cargoType: item.cargoType ?? item['*货物类型'] ?? item['货物类型'] ?? '',
settlementAmount:
item.settlementAmount ?? item['结算金额'] ?? '',
feeItems,
};
const vehicleNo =
item.vehicleNo !== undefined && item.vehicleNo !== null
? readFilledText(item.vehicleNo)
: readFilledText(VEHICLE_ALIAS_KEYS.map(key => item[key]).find(value => readFilledText(value)));
applyVehicleNo(row, vehicleNo);
row.transportUnitPrice = row.unitPrice;
row.freight = row.transportFee;
recalcSettlementAmount(row);
if (row.settlementAmount === '' || row.settlementAmount === null || row.settlementAmount === undefined) {
recalcSettlementAmount(row);
} else {
row.freightTotal = row.settlementAmount;
}
return row;
};
@@ -752,6 +969,7 @@ const resetUploadState = () => {
form.file = null;
rows.value = [];
feeItemNames.value = [];
parsedHeaders.value = [];
rowSelection.value = [];
};
@@ -807,6 +1025,7 @@ const parseSelectedFile = async (raw, displayName = '') => {
const response = await api.parseFile(raw);
const data = unwrapData(response) || {};
feeItemNames.value = Array.isArray(data.feeItemNames) ? data.feeItemNames : [];
parsedHeaders.value = Array.isArray(data.headers) ? data.headers : [];
const parsedRows = Array.isArray(data.rows) ? data.rows : [];
rows.value = parsedRows.map((item, index) => normalizeParsedRow(item, index));
refreshDuplicateFlags();
@@ -827,22 +1046,115 @@ const parseSelectedFile = async (raw, displayName = '') => {
}
};
const editRow = row => {
row._editSnapshot = JSON.parse(JSON.stringify(row));
row._editing = true;
const formatCargoTypeLabel = item =>
item?.cargoName || item?.name || item?.typeName || item?.label || '';
const buildCargoTypeTree = cargoTypes => {
const flatCargoTypes = [];
const collectCargoTypes = list => {
(list || []).forEach(item => {
flatCargoTypes.push({ ...item, children: undefined });
if (item.children?.length) collectCargoTypes(item.children);
});
};
collectCargoTypes(cargoTypes);
const nodeMap = new Map();
const codeMap = new Map();
flatCargoTypes.forEach(item => {
const id = item.id ?? item.cargoCode ?? item.code;
if (id === undefined || id === null) return;
const node = {
...item,
id: String(id),
cargoName: formatCargoTypeLabel(item),
cargoCode: item.cargoCode || item.code || '',
parentId: item.parentId === undefined || item.parentId === null ? '' : String(item.parentId),
parentCargoCode: item.parentCargoCode || item.parentCode || '',
children: [],
};
nodeMap.set(node.id, node);
if (node.cargoCode) codeMap.set(String(node.cargoCode), node);
});
const rootNodes = [];
nodeMap.forEach(node => {
const parent =
nodeMap.get(node.parentId) ||
codeMap.get(String(node.parentCargoCode || '')) ||
codeMap.get(String(node.parentId || ''));
if (parent && parent !== node && Number(node.typeLevel) !== 1) parent.children.push(node);
else rootNodes.push(node);
});
const normalize = (cargoType, level = 1, parentPath = []) => {
if (level > 2) return null;
const id = String(cargoType.id);
const path = [...parentPath, id];
const children =
level === 1
? (cargoType.children || []).map(item => normalize(item, level + 1, path)).filter(Boolean)
: [];
return {
...cargoType,
id,
cargoName: formatCargoTypeLabel(cargoType),
path,
leaf: level === 2,
children: children.length ? children : undefined,
};
};
return rootNodes.map(item => normalize(item, 1)).filter(Boolean);
};
const saveRow = row => {
recalcSettlementAmount(row);
row._editing = false;
delete row._editSnapshot;
refreshDuplicateFlags();
const flattenCargoTypeOptions = options => {
const result = [];
const collect = list =>
(list || []).forEach(item => {
result.push(item);
if (item.children?.length) collect(item.children);
});
collect(options);
return result;
};
const cancelRow = row => {
if (row._editSnapshot) Object.assign(row, row._editSnapshot);
row._editing = false;
delete row._editSnapshot;
const resolveCargoTypePath = row => {
if (Array.isArray(row.cargoTypePath) && row.cargoTypePath.length) return row.cargoTypePath;
const current = String(row.cargoType || row.cargoTypeCode || '').trim();
if (!current) return [];
const matched = cargoTypeFlatOptions.value.find(item =>
[item.cargoName, item.name, item.typeName, item.cargoCode, item.code].some(
value => String(value || '').trim() === current
)
);
if (matched?.path?.length) return matched.path;
return [`custom:${current}`];
};
const cargoTypeSelectOptions = row => {
const path = resolveCargoTypePath(row);
const customId = path.find(value => String(value).startsWith('custom:'));
if (!customId) return cargoTypeOptions.value;
const name = String(customId).slice('custom:'.length);
return [{ id: customId, cargoName: name, leaf: true }, ...cargoTypeOptions.value];
};
const handleCargoTypeChange = (row, value) => {
const path = Array.isArray(value) ? value : [];
const leafId = path.length ? String(path[path.length - 1]) : '';
if (!leafId) {
row.cargoTypePath = [];
row.cargoType = '';
row.cargoTypeCode = '';
return;
}
if (leafId.startsWith('custom:')) {
row.cargoTypePath = path;
row.cargoType = leafId.slice('custom:'.length);
row.cargoTypeCode = '';
return;
}
const cargoType = cargoTypeFlatOptions.value.find(item => String(item.id) === leafId);
row.cargoTypePath = cargoType?.path || path;
row.cargoType = cargoType?.cargoName || '';
row.cargoTypeCode = cargoType?.cargoCode || cargoType?.code || '';
};
const deleteRow = row => {
@@ -867,6 +1179,74 @@ const leaveAfterConfirm = () => {
router.push({ path: '/settlement/settlement-import' });
};
const openHistoryWaybillDialog = async row => {
if (!form.projectId || !form.customerContractId || !form.carrierContractId) {
ElMessage.warning('请先选择项目、客户合同和承运商合同');
return;
}
if (!form.settlementType) {
ElMessage.warning('请先选择结算类型');
return;
}
historyWaybillTargetRow.value = row;
historyWaybillCurrent.value = null;
historyWaybillVisible.value = true;
historyWaybillLoading.value = true;
try {
const response = await api.getHistoryWaybills({
projectId: form.projectId,
customerContractId: form.customerContractId,
carrierContractId: form.carrierContractId,
settlementType: form.settlementType,
});
historyWaybillRows.value = unwrapData(response) || [];
} catch (error) {
historyWaybillRows.value = [];
ElMessage.error(error?.message || '加载历史运单失败');
} finally {
historyWaybillLoading.value = false;
}
};
const applyHistoryWaybill = waybill => {
const target = historyWaybillTargetRow.value;
if (!target || !waybill) return;
target.waybillNo = waybill.waybillNo || '';
target.matchedWaybillId = waybill.id;
target.vehicleNo = waybill.vehicleNo || target.vehicleNo;
target.departureAddress = waybill.departureAddress || target.departureAddress;
target.arrivalAddress = waybill.arrivalAddress || target.arrivalAddress;
target.cargoName = waybill.cargoName || target.cargoName;
target.cargoType = waybill.cargoType || target.cargoType;
target.quantity = waybill.quantity ?? target.quantity;
target.quantityUnit = waybill.quantityUnit || target.quantityUnit;
target.model = waybill.model || target.model;
target.mileage =
waybill.mileage === null || waybill.mileage === undefined ? target.mileage : waybill.mileage;
target.actualStartDate = waybill.actualStartDate
? dayjs(waybill.actualStartDate).format('YYYY-MM-DD')
: target.actualStartDate;
target.actualEndDate = waybill.actualEndDate
? dayjs(waybill.actualEndDate).format('YYYY-MM-DD')
: target.actualEndDate;
target.driverName = waybill.driverName || target.driverName;
refreshDuplicateFlags();
};
const selectHistoryWaybill = row => {
applyHistoryWaybill(row);
historyWaybillVisible.value = false;
};
const confirmHistoryWaybill = () => {
if (!historyWaybillCurrent.value) {
ElMessage.warning('请选择一条运单');
return;
}
applyHistoryWaybill(historyWaybillCurrent.value);
historyWaybillVisible.value = false;
};
const downloadFailureExcel = async failureRows => {
const response = await api.exportFailures({
feeItemNames: [...feeItemNames.value],
@@ -910,7 +1290,7 @@ const saveDraft = async () => {
if (batch.id) form.id = batch.id;
if (batch.batchNo) form.batchNo = batch.batchNo;
ElMessage.success('保存草稿成功');
goBack();
leaveAfterConfirm();
} catch (error) {
ElMessage.error(error?.message || '保存草稿失败');
} finally {
@@ -959,10 +1339,45 @@ const confirmImport = async () => {
}
};
const loadTransportTypeOptions = async () => {
try {
const response = await getDictionary({ code: 'transport_type' });
const list = unwrapData(response) || [];
transportTypeOptions.value = (Array.isArray(list) ? list : [])
.map(item => {
const label = item.dictValue || item.label || item.name || '';
const value = item.dictValue || item.dictKey || item.value || label;
return label ? { label, value } : null;
})
.filter(Boolean);
} catch (error) {
transportTypeOptions.value = [
{ label: '公路运输', value: '公路运输' },
{ label: '铁路运输', value: '铁路运输' },
{ label: '水路运输', value: '水路运输' },
{ label: '航空运输', value: '航空运输' },
];
}
};
const loadCargoTypeOptions = async () => {
try {
const response = await getCargoTypeList(1, 9999);
const body = unwrapData(response) || {};
const records = Array.isArray(body) ? body : body.records || body.data || [];
cargoTypeOptions.value = buildCargoTypeTree(records);
cargoTypeFlatOptions.value = flattenCargoTypeOptions(cargoTypeOptions.value);
} catch (error) {
cargoTypeOptions.value = [];
cargoTypeFlatOptions.value = [];
}
};
const loadOptions = async () => {
const response = await api.getOptions();
const options = unwrapData(response) || {};
projects.value = (options.projects || []).map(normalizeProject).filter(Boolean);
await Promise.all([loadTransportTypeOptions(), loadCargoTypeOptions()]);
};
const loadDetail = async id => {
@@ -989,15 +1404,22 @@ const loadDetail = async id => {
await loadContractsByProject(detail.projectId, detail.projectName || '');
}
feeItemNames.value = Array.isArray(detail.feeItemNames) ? detail.feeItemNames : [];
parsedHeaders.value = [];
const detailRows = Array.isArray(detail.rows) ? detail.rows : [];
rows.value = detailRows.map((item, index) => normalizeParsedRow(item, index));
refreshDuplicateFlags();
readonly.value = detail.importStatus && detail.importStatus !== 'draft';
// 查看模式始终只读;编辑时仅草稿可改,已完成/已作废强制只读
readonly.value =
route.query.mode === 'view' ||
Boolean(detail.importStatus && detail.importStatus !== 'draft');
};
const initPage = async () => {
await loadOptions();
const id = route.query.id;
if (route.query.mode === 'view') {
readonly.value = true;
}
if (id) {
await loadDetail(id);
return;
@@ -1115,4 +1537,16 @@ onMounted(() => {
padding-top: 16px;
border-top: 1px solid #eff1f7;
}
.settlement-import-create__waybill-select {
display: flex;
align-items: center;
gap: 8px;
}
.settlement-import-create__history-tip {
margin-bottom: 8px;
color: #909399;
font-size: 13px;
}
</style>
@@ -508,7 +508,7 @@
<span class="completion-dialog__value">{{ displayValue(form.reconciliationNo) }}</span>
</div>
<div class="completion-dialog__field">
<span class="completion-dialog__label">预结算单号</span>
<span class="completion-dialog__label">预付结算单号</span>
<span class="completion-dialog__value">{{
displayValue(form.preSettlementNo || form.formalSettlementNo)
}}</span>
@@ -1278,10 +1278,13 @@ export default {
delete snapshot._externalKey;
delete snapshot.feeItems;
snapshot.feeItemsJson = row.feeItemsJson || JSON.stringify(row.feeItems || {});
snapshot.actualDepartureTime = this.normalizeExternalDateTime(row.actualDepartureTime);
snapshot.actualCompletionTime = this.normalizeExternalDateTime(row.actualCompletionTime);
return snapshot;
});
},
serializeExternalRows() {
const duplicateIds = new Set(this.duplicateRows.map(row => String(row.id)));
return this.externalDetails.map(row => {
const snapshot = { ...row };
delete snapshot._sourceRows;
@@ -1290,6 +1293,7 @@ export default {
snapshot.feeItemsJson = row.feeItemsJson || JSON.stringify(row.feeItems || {});
snapshot.actualDepartureTime = this.normalizeExternalDateTime(row.actualDepartureTime);
snapshot.actualCompletionTime = this.normalizeExternalDateTime(row.actualCompletionTime);
snapshot.suspectedDuplicate = duplicateIds.has(String(row.id));
return snapshot;
});
},
@@ -1336,6 +1340,11 @@ export default {
}
},
async handleComplete() {
const unmatchedInternal = this.internalDetails.filter(item => item.matchResult !== 'matched').length;
const unmatchedExternal = this.externalDetails.filter(item => item.matchStatus !== 'matched').length;
if (this.duplicateRows.length || unmatchedInternal || unmatchedExternal) {
return this.$message.warning('所有内外部账单明细必须一一匹配且不存在疑似重复');
}
if (
Number(this.form.differenceCount || 0) !== 0 ||
Number(this.form.differenceQuantity || 0) !== 0 ||
@@ -1694,8 +1703,11 @@ export default {
},
normalizeExternalDateTime(value) {
if (!value) return null;
const text = String(value);
return text.length === 10 ? `${text}T00:00:00` : text;
const text = String(value).trim();
if (!text) return null;
const date = this.$dayjs(text);
if (date.isValid()) return date.format('YYYY-MM-DD HH:mm:ss');
return text.length === 10 ? `${text} 00:00:00` : text.replace('T', ' ');
},
refreshLocalStats() {
const internalQuantity = this.internalDetails.reduce(
@@ -16,6 +16,7 @@
<script>
import FormalSettlementEditor from './components/formal-settlement-editor.vue';
import { readSettlementTransfer, removeSettlementTransfer } from '@/utils/settlement-transfer';
import { settlementBillLabel, settlementListPath } from '@/utils/settlement-menu';
const LIST_REFRESH_KEY = 'formal-settlement-list-refresh';
@@ -35,12 +36,25 @@ export default {
readonly() {
return this.$route.query.mode === 'view';
},
settlementType() {
return this.$route.query.settlementType || this.transferPayload?.settlementType || 'payable';
},
billLabel() {
return settlementBillLabel(this.settlementType);
},
pageTitle() {
return this.readonly ? '查看正式结算' : this.recordId ? '编辑正式结算' : '新增正式结算';
return this.readonly
? `查看${this.billLabel}`
: this.recordId
? `编辑${this.billLabel}`
: `新增${this.billLabel}`;
},
listPath() {
return this.$route.query.listPath || settlementListPath(this.settlementType);
},
editorInitialData() {
const settlementType = this.$route.query.settlementType;
if (!this.transferPayload && !settlementType) return null;
const settlementType = this.settlementType;
if (!this.transferPayload && !this.$route.query.settlementType) return null;
return {
...(this.transferPayload || {}),
...(settlementType ? { settlementType } : {}),
@@ -63,7 +77,7 @@ export default {
goBack() {
removeSettlementTransfer(this.$route.query.transferToken);
this.$router.$avueRouter.closeTag();
this.$router.push('/settlement/formal-settlement');
this.$router.push(this.listPath);
},
syncTagTitle() {
this.$nextTick(() => {
+175 -75
View File
@@ -52,53 +52,32 @@
<section class="formal-page__table-panel">
<el-tabs
v-if="!lockedSettlementType"
type="border-card"
v-model="activeSettlementType"
@tab-change="handleSettlementTypeChange"
>
<el-tab-pane label="应付" name="payable">
<formal-settlement-table-panel
:key="activeSettlementType"
:rows="rows"
:columns="columns"
:loading="loading"
:page="page"
:has-permission="hasPermissionFn"
:sync-loading="syncLoading"
:mk-enabled="mkEnabled"
v-model:search-visible="searchVisible"
@create="openCreate"
@payment="openPaymentDialog"
@sync="handleSync"
@export="handleExport"
@refresh="loadTable"
@page-change="onPageChange"
@action="onAction"
@update:selection="selection = $event"
:key="'payable'"
v-bind="tablePanelProps"
v-on="tablePanelListeners"
/>
</el-tab-pane>
<el-tab-pane label="应收" name="receivable">
<formal-settlement-table-panel
:key="activeSettlementType"
:rows="rows"
:columns="columns"
:loading="loading"
:page="page"
:has-permission="hasPermissionFn"
:sync-loading="syncLoading"
:mk-enabled="mkEnabled"
v-model:search-visible="searchVisible"
@create="openCreate"
@payment="openPaymentDialog"
@sync="handleSync"
@export="handleExport"
@refresh="loadTable"
@page-change="onPageChange"
@action="onAction"
@update:selection="selection = $event"
:key="'receivable'"
v-bind="tablePanelProps"
v-on="tablePanelListeners"
/>
</el-tab-pane>
</el-tabs>
<formal-settlement-table-panel
v-else
:key="activeSettlementType"
v-bind="tablePanelProps"
v-on="tablePanelListeners"
/>
</section>
<formal-settlement-editor
v-model="editor.visible"
@@ -116,7 +95,7 @@
<section-card title="付款信息">
<template v-if="paymentDialog.rows.length > 1">
<div class="formal-payment-dialog__batch-tip">
已选择 {{ paymentDialog.rows.length }} 条同合同应付正式结算单,请确认各单申请金额。
已选择 {{ paymentDialog.rows.length }} 条同合同付款结算单,请确认各单申请金额。
</div>
<el-table :data="paymentDialog.rows" border>
<el-table-column prop="formalSettlementNo" label="结算单号" min-width="160" />
@@ -176,6 +155,12 @@
import { ArrowDown, ArrowUp } from '@element-plus/icons-vue';
import { mapGetters } from 'vuex';
import { createSettlementTransfer } from '@/utils/settlement-transfer';
import {
hasSettlementPermission,
settlementBillLabel,
settlementListPath,
} from '@/utils/settlement-menu';
import { isAdministrator } from '@/utils/auth';
import { downloadFile } from '@/utils/util';
import * as api from '@/api/settlement/formalSettlement';
import * as paymentApi from '@/api/payment/paymentApplication';
@@ -210,6 +195,14 @@ export default {
name: 'FormalSettlement',
components: { FormalSettlementEditor, FormalSettlementTablePanel },
mixins: [organizationSearch],
props: {
/** 菜单拆分后锁定结算类型:payable=付款结算单,receivable=收款结算单 */
lockedSettlementType: {
type: String,
default: '',
validator: value => ['', 'payable', 'receivable'].includes(value),
},
},
data() {
return {
ArrowDown,
@@ -237,9 +230,52 @@ export default {
};
},
computed: {
...mapGetters(['permission']),
...mapGetters(['permission', 'userInfo']),
isAdmin() {
return isAdministrator(this.userInfo);
},
billLabel() {
return settlementBillLabel(this.activeSettlementType);
},
hasPermissionFn() {
return code => this.permission?.[code] !== false;
return actionOrCode => {
const action = String(actionOrCode || '').replace(
/^(payment_settlement_|receipt_settlement_|formal_settlement_)/,
''
);
return hasSettlementPermission(this, this.activeSettlementType, action);
};
},
tablePanelProps() {
return {
rows: this.rows,
columns: this.columns,
loading: this.loading,
page: this.page,
hasPermission: this.hasPermissionFn,
syncLoading: this.syncLoading,
mkEnabled: this.mkEnabled,
searchVisible: this.searchVisible,
showPaymentAction: this.activeSettlementType === 'payable',
billLabel: this.billLabel,
};
},
tablePanelListeners() {
return {
create: this.openCreate,
payment: this.openPaymentDialog,
sync: this.handleSync,
export: this.handleExport,
refresh: this.loadTable,
'page-change': this.onPageChange,
action: this.onAction,
'update:selection': selection => {
this.selection = selection;
},
'update:searchVisible': visible => {
this.searchVisible = visible;
},
};
},
visibleSearchFields() {
return this.searchExpanded ? this.searchFields : this.searchFields.slice(0, 4);
@@ -249,11 +285,26 @@ export default {
},
},
watch: {
lockedSettlementType: {
immediate: true,
handler(value) {
if (value === 'payable' || value === 'receivable') {
this.activeSettlementType = value;
}
},
},
'$route.query.detailNo'(detailNo) {
if (detailNo) this.openRouteDetail(detailNo);
},
},
created() {
// 标签机制按 fullPath 缓存同页多实例:仅当前路由实例应响应 detailNo 跳转,防止缓存旧实例也弹窗
this.ownFullPath = this.$route.fullPath;
},
mounted() {
if (this.lockedSettlementType === 'payable' || this.lockedSettlementType === 'receivable') {
this.activeSettlementType = this.lockedSettlementType;
}
this.loadOrganizationOptions();
this.loadTable();
this.openRouteDetail();
@@ -272,8 +323,8 @@ export default {
}
},
methods: {
hasPermission(code) {
return this.permission?.[code] !== false;
hasPermission(actionOrCode) {
return this.hasPermissionFn(actionOrCode);
},
async loadTable() {
this.loading = true;
@@ -326,15 +377,23 @@ export default {
path: '/settlement/formal-settlement/form',
query: {
mode: 'add',
name: '新增正式结算',
name: `新增${this.billLabel}`,
settlementType: this.activeSettlementType,
listPath: settlementListPath(this.activeSettlementType),
},
});
},
openEdit(row) {
const settlementType = row.settlementType || this.activeSettlementType;
this.$router.push({
path: '/settlement/formal-settlement/form',
query: { mode: 'edit', id: row.id, name: '编辑正式结算' },
query: {
mode: 'edit',
id: row.id,
name: `编辑${settlementBillLabel(settlementType)}`,
settlementType,
listPath: settlementListPath(settlementType),
},
});
},
openView(row) {
@@ -342,25 +401,27 @@ export default {
},
async openRouteDetail(detailNo = this.$route.query.detailNo) {
const formalSettlementNo = String(detailNo || '').trim();
if (!formalSettlementNo) return;
if (!formalSettlementNo || this.ownFullPath !== this.$route.fullPath) return;
const response = await api.getList(1, 10, { formalSettlementNo });
const data = this.unwrapData(response);
const row = (data.records || []).find(item => item.formalSettlementNo === formalSettlementNo);
if (!row) {
this.$message.warning('未找到对应的正式结算单');
this.$message.warning(`未找到对应的${this.billLabel}`);
return;
}
this.activeSettlementType = row.settlementType || this.activeSettlementType;
if (!this.lockedSettlementType) {
this.activeSettlementType = row.settlementType || this.activeSettlementType;
}
this.openView(row);
},
async handleDelete(row) {
await this.$confirm('确认删除该正式结算草稿?', '提示', { type: 'warning' });
await this.$confirm(`确认删除该${this.billLabel}草稿?`, '提示', { type: 'warning' });
await api.remove(row.id);
this.$message.success('删除成功');
this.loadTable();
},
async handleSubmit(row) {
await this.$confirm('提交后来源预结算将保持锁定,确认提交?', '提示', { type: 'warning' });
await this.$confirm('提交后来源预付结算单将保持锁定,确认提交?', '提示', { type: 'warning' });
const previousApprovalStatus = row.approvalStatus || '';
await api.submit({ id: row.id });
await submitMkApprovalFlow({
@@ -375,7 +436,7 @@ export default {
},
handleMkAudit(row) {
if (!row?.id) {
this.$message.warning('正式结算单ID为空,无法打开审核页');
this.$message.warning(`${this.billLabel}ID为空,无法打开审核页`);
return;
}
getMKApprovalUrl({ bizId: String(row.id) })
@@ -393,7 +454,7 @@ export default {
},
async handleApprove(row) {
await this.$confirm(
'审核通过后正式结算生效,金额只能通过结算调整单处理,确认通过?',
`审核通过后${this.billLabel}生效,金额只能通过结算调整单处理,确认通过?`,
'提示',
{ type: 'warning' }
);
@@ -415,7 +476,7 @@ export default {
this.loadTable();
},
async handleVoid(row) {
const { value } = await this.$prompt('请输入作废原因', '作废正式结算单', {
const { value } = await this.$prompt('请输入作废原因', `作废${this.billLabel}`, {
inputValidator: value => Boolean(value?.trim()) || '请输入作废原因',
});
await api.voidBill({ id: row.id, reason: value });
@@ -424,46 +485,80 @@ export default {
},
selectedOne(action) {
if (this.selection.length !== 1) {
this.$message.warning(`${action}需选择一条正式结算单`);
this.$message.warning(`${action}需选择一条${this.billLabel}`);
return null;
}
return this.selection[0];
},
async handleSync() {
if (this.syncLoading) return;
const row = this.selectedOne('同步金蝶');
if (!row) return;
const rows = (this.selection || []).filter(row => row.approvalStatus === 'approved');
if (!rows.length) {
this.$message.warning(`请选择至少一条审批通过的${this.billLabel}`);
return;
}
this.syncLoading = true;
try {
const response = await api.syncKingdee(row.id);
const data = this.unwrapData(response);
this.$message.success(`同步成功,金蝶单据号:${data}`);
await this.loadTable();
// 附件联带同步提示:同步成功但附件未全部上传时追加 warning,重推即自动补传
const freshRow = (this.rows || []).find(item => String(item.id) === String(row.id));
if (freshRow && ['pending', 'partial'].includes(freshRow.attachmentSyncStatus)) {
this.$message({
type: 'warning',
message: '该单附件未全部上传,可重推补传',
duration: 8000,
});
let successCount = 0;
let failCount = 0;
let lastFailReason = '';
for (const row of rows) {
try {
await api.syncKingdee(row.id, { meta: { suppressErrorMessage: true } });
successCount += 1;
} catch (error) {
failCount += 1;
lastFailReason = String(error?.message || error || '未知错误').trim() || '未知错误';
}
}
await this.loadTable();
if (rows.length === 1) {
if (failCount) {
await this.$alert(`同步失败,${lastFailReason}`, '同步结果', {
type: 'error',
confirmButtonText: '知道了',
});
} else {
let message = '同步成功';
const freshRow = (this.rows || []).find(item => String(item.id) === String(rows[0].id));
if (freshRow && ['pending', 'partial'].includes(freshRow.attachmentSyncStatus)) {
message += '\n该单附件未全部上传,可重推补传';
}
await this.$alert(message, '同步结果', {
type: 'success',
confirmButtonText: '知道了',
});
}
return;
}
let batchMessage = `完成同步${successCount}条,失败${failCount}条`;
const idSet = new Set(rows.map(row => String(row.id)));
const pendingCount = (this.rows || []).filter(
row =>
idSet.has(String(row.id)) && ['pending', 'partial'].includes(row.attachmentSyncStatus)
).length;
if (pendingCount) {
batchMessage += `\n其中${pendingCount}单附件未全部上传,可重推补传`;
}
await this.$alert(batchMessage, '同步结果', {
type: failCount ? 'warning' : 'success',
confirmButtonText: '知道了',
});
} finally {
this.syncLoading = false;
}
},
async openPaymentDialog() {
if (!this.selection.length) return this.$message.warning('请至少选择一条正式结算单');
if (!this.selection.length) return this.$message.warning(`请至少选择一条${this.billLabel}`);
const rows = this.selection;
if (rows.some(row => row.approvalStatus !== 'approved' || row.settlementType !== 'payable'))
return this.$message.warning('仅审批通过的应付正式结算单允许发起付款申请');
return this.$message.warning('仅审批通过的付款结算单允许发起付款申请');
const contractIds = new Set(rows.map(row => String(row.contractId || '')));
if (contractIds.size !== 1 || contractIds.has(''))
return this.$message.warning('付款申请必须选择同一个合同的正式结算单');
return this.$message.warning('付款申请必须选择同一个合同的付款结算单');
const paymentRows = rows.map(row => ({ ...row, appliedAmount: this.paymentRemaining(row) }));
if (paymentRows.some(row => row.appliedAmount <= 0))
return this.$message.warning('所选正式结算单均须存在剩余可申请金额');
return this.$message.warning('所选付款结算单均须存在剩余可申请金额');
try {
const sourceFormalSettlements = await Promise.all(
paymentRows.map(async row => {
@@ -499,7 +594,7 @@ export default {
})
);
if (sourceFormalSettlements.some(row => row.appliedAmount <= 0)) {
this.$message.warning('所选正式结算单均须存在剩余可申请金额');
this.$message.warning('所选付款结算单均须存在剩余可申请金额');
return;
}
const transferToken = createSettlementTransfer({
@@ -519,7 +614,7 @@ export default {
const paymentRows = this.paymentDialog.rows;
if (paymentRows.length > 1) {
if (paymentRows.some(row => Number(row.appliedAmount || 0) <= 0))
return this.$message.warning('请输入各正式结算单的申请付款金额');
return this.$message.warning('请输入各付款结算单的申请付款金额');
if (paymentRows.some(row => Number(row.appliedAmount) > this.paymentRemaining(row)))
return this.$message.warning('申请付款金额不能超过剩余可申请金额');
} else if (Number(this.paymentDialog.form.appliedAmount || 0) <= 0) {
@@ -555,9 +650,11 @@ export default {
win.document.write(
`<!doctype html><html><head><title>${
row.formalSettlementNo
}</title><style>body{font-family:Arial,"Microsoft YaHei",sans-serif;padding:32px;color:#222}h1{text-align:center}.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px 28px;margin-top:30px}.item{border-bottom:1px solid #ddd;padding:8px 0}.actions{text-align:center;margin-top:36px}@media print{.actions{display:none}}</style></head><body><h1>正式结算单</h1><div class="grid"><div class="item">结算单号:${this.escapeHtml(
}</title><style>body{font-family:Arial,"Microsoft YaHei",sans-serif;padding:32px;color:#222}h1{text-align:center}.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px 28px;margin-top:30px}.item{border-bottom:1px solid #ddd;padding:8px 0}.actions{text-align:center;margin-top:36px}@media print{.actions{display:none}}</style></head><body><h1>${this.escapeHtml(
settlementBillLabel(row.settlementType || this.activeSettlementType)
)}</h1><div class="grid"><div class="item">结算单号:${this.escapeHtml(
row.formalSettlementNo
)}</div><div class="item">预结算单号:${this.escapeHtml(
)}</div><div class="item">预付结算单号:${this.escapeHtml(
row.preSettlementNos
)}</div><div class="item">项目:${this.escapeHtml(
row.projectName
@@ -582,12 +679,15 @@ export default {
const params = this.buildQueryParams();
if (this.selection.length) params.ids = this.selection.map(item => item.id).join(',');
const { data } = await api.exportList(params);
downloadFile(data, `正式结算单${this.$dayjs().format('YYYY-MM-DD HH-mm-ss')}.xlsx`);
downloadFile(
data,
`${this.billLabel}${this.$dayjs().format('YYYY-MM-DD HH-mm-ss')}.xlsx`
);
},
buildQueryParams() {
// 所属组织级联返回 id 路径,转成组织名称传给后端(用副本,避免污染搜索框回显)
const params = this.normalizeOrganizationSearch({ ...this.query }, 'deptName');
params.settlementType = this.activeSettlementType;
params.settlementType = this.lockedSettlementType || this.activeSettlementType;
const range = params.createDateRange || [];
delete params.createDateRange;
if (range.length === 2) {
@@ -0,0 +1,12 @@
<template>
<formal-settlement locked-settlement-type="payable" />
</template>
<script>
import FormalSettlement from './formal-settlement.vue';
export default {
name: 'PaymentSettlement',
components: { FormalSettlement },
};
</script>
+2 -2
View File
@@ -1,7 +1,7 @@
<template>
<basic-container class="pre-settlement-form-page">
<div class="pre-settlement-form-page__title">{{ pageTitle }}</div>
<!-- 新增来源明细可直接调整:计费试算走独立接口,调整结果先暂存,保存预结算单时再落库。 -->
<!-- 新增来源明细可直接调整:计费试算走独立接口,调整结果先暂存,保存预付结算单时再落库。 -->
<pre-settlement-editor
v-model="editorVisible"
page-mode
@@ -31,7 +31,7 @@ export default {
return this.$route.query.id || '';
},
pageTitle() {
return this.recordId || this.savedRecordId ? '编辑预结算' : '新增预结算';
return this.recordId || this.savedRecordId ? '编辑预付结算单' : '新增预付结算单';
},
},
watch: {
@@ -1,7 +1,7 @@
<template>
<mk-public-shell biz-type="pre-settlement" :get-form="getForm">
<basic-container>
<div class="mk-public-form-title">查看预结算</div>
<div class="mk-public-form-title">查看预付结算单</div>
<pre-settlement-editor
ref="page"
:model-value="true"
+26 -20
View File
@@ -446,13 +446,13 @@ export default {
openCreate() {
this.$router.push({
path: '/settlement/pre-settlement/form',
query: { mode: 'add', name: '新增预结算' },
query: { mode: 'add', name: '新增预付结算单' },
});
},
openEdit(row) {
this.$router.push({
path: '/settlement/pre-settlement/form',
query: { mode: 'edit', id: row.id, name: '编辑预结算' },
query: { mode: 'edit', id: row.id, name: '编辑预付结算单' },
});
},
openView(row) {
@@ -465,7 +465,7 @@ export default {
const records = data?.data?.records || [];
const row = records.find(item => item.preSettlementNo === preSettlementNo);
if (!row) {
this.$message.warning('未找到对应的预结算单');
this.$message.warning('未找到对应的预付结算单');
return;
}
this.openView(row);
@@ -474,30 +474,30 @@ export default {
return ['draft', 'returned'].includes(row.approvalStatus);
},
async handleDelete(row) {
await this.$confirm('确认删除该预结算草稿?', '提示', { type: 'warning' });
await this.$confirm('确认删除该预付结算单草稿?', '提示', { type: 'warning' });
await remove(row.id);
this.$message.success('删除成功');
this.loadTable();
},
selectedOne(operationName) {
if (this.selection.length !== 1) {
this.$message.warning(`${operationName}需选择一条预结算单`);
this.$message.warning(`${operationName}需选择一条预付结算单`);
return null;
}
return this.selection[0];
},
handleAdvanceApplication() {
if (!this.selection.length) {
this.$message.warning('请选择需要发起预付申请的预结算单');
this.$message.warning('请选择需要发起预付申请的预付结算单');
return;
}
if (this.selection.some(row => !row.contractId)) {
this.$message.warning('所选预结算单缺少合同ID,无法发起预付申请');
this.$message.warning('所选预付结算单缺少合同ID,无法发起预付申请');
return;
}
const contractIds = new Set(this.selection.map(row => String(row.contractId)));
if (contractIds.size > 1) {
this.$message.warning('预付申请只能选择同一合同下的预结算单');
this.$message.warning('预付申请只能选择同一合同下的预付结算单');
return;
}
if (
@@ -508,7 +508,7 @@ export default {
row.formalSettlementNo
)
) {
this.$message.warning('仅审批通过、未转正式结算的应付预结算单可发起预付');
this.$message.warning('仅审批通过、未转付款结算的应付预付结算单可发起预付');
return;
}
const sourcePreSettlements = this.selection.map(row => ({
@@ -533,11 +533,11 @@ export default {
},
handleFormalSettlement() {
if (!this.selection.length) {
this.$message.warning('请选择需要转正式结算的预结算单');
this.$message.warning('请选择需要转付款结算的预付结算单');
return;
}
if (this.selection.some(row => row.approvalStatus !== 'approved')) {
this.$message.warning('仅审核通过的预结算单可转正式结算');
this.$message.warning('仅审核通过的预付结算单可转付款结算');
return;
}
const hasCompleteProjectIds = this.selection.every(
@@ -549,7 +549,7 @@ export default {
)
);
if (projectKeys.size > 1) {
this.$message.warning('尾款结算只能选择同一项目下的预结算单');
this.$message.warning('尾款结算只能选择同一项目下的预付结算单');
return;
}
const transferToken = createSettlementTransfer({
@@ -560,14 +560,20 @@ export default {
});
this.$router.push({
path: '/settlement/formal-settlement/form',
query: { mode: 'add', name: '新增正式结算', transferToken },
query: {
mode: 'add',
name: '新增付款结算单',
settlementType: 'payable',
listPath: '/settlement/payment-settlement',
transferToken,
},
});
},
async openPrintDialog() {
const row = this.selectedOne('打印结算单');
if (!row) return;
if (row.approvalStatus === 'voided') {
this.$message.warning('已作废的预结算单不能打印');
this.$message.warning('已作废的预付结算单不能打印');
return;
}
this.printDialog.row = row;
@@ -622,8 +628,8 @@ export default {
)
.join('');
return `<!doctype html><html><head><meta charset="utf-8"><title>${this.escapeHtml(
detail.preSettlementNo || '预结算单'
)}</title><style>body{font-family:Arial,"Microsoft YaHei",sans-serif;color:#222;padding:28px}h1{text-align:center;font-size:24px}.meta{display:grid;grid-template-columns:repeat(3,1fr);gap:14px 24px;margin:24px 0}.meta div{border-bottom:1px solid #ddd;padding:7px 0}table{width:100%;border-collapse:collapse;margin-top:16px}th,td{border:1px solid #bbb;padding:9px;text-align:center;font-size:13px}th{background:#f5f5f5}.actions{text-align:center;margin-top:24px}@media print{.actions{display:none}}</style></head><body><h1>预结算单</h1><div class="meta"><div>预结算单号:${this.escapeHtml(
detail.preSettlementNo || '预付结算单'
)}</title><style>body{font-family:Arial,"Microsoft YaHei",sans-serif;color:#222;padding:28px}h1{text-align:center;font-size:24px}.meta{display:grid;grid-template-columns:repeat(3,1fr);gap:14px 24px;margin:24px 0}.meta div{border-bottom:1px solid #ddd;padding:7px 0}table{width:100%;border-collapse:collapse;margin-top:16px}th,td{border:1px solid #bbb;padding:9px;text-align:center;font-size:13px}th{background:#f5f5f5}.actions{text-align:center;margin-top:24px}@media print{.actions{display:none}}</style></head><body><h1>预付结算单</h1><div class="meta"><div>预付结算单号:${this.escapeHtml(
detail.preSettlementNo
)}</div><div>项目名称:${this.escapeHtml(
detail.projectName
@@ -651,7 +657,7 @@ export default {
const params = this.buildQuery();
if (this.selection.length) params.ids = this.selection.map(item => item.id).join(',');
const { data } = await exportList(params);
downloadFile(data, `预结算单${this.$dayjs().format('YYYY-MM-DD HH-mm-ss')}.xlsx`);
downloadFile(data, `预付结算单${this.$dayjs().format('YYYY-MM-DD HH-mm-ss')}.xlsx`);
},
async handleSubmit(row) {
const previousApprovalStatus = row.approvalStatus || '';
@@ -668,7 +674,7 @@ export default {
},
handleMkAudit(row) {
if (!row?.id) {
this.$message.warning('预结算单ID为空,无法打开审核页');
this.$message.warning('预付结算单ID为空,无法打开审核页');
return;
}
getMKApprovalUrl({ bizId: String(row.id) })
@@ -685,7 +691,7 @@ export default {
});
},
async handleApprove(row) {
await this.$confirm('确认审批通过该预结算单?', '提示', { type: 'warning' });
await this.$confirm('确认审批通过该预付结算单?', '提示', { type: 'warning' });
await approve({ id: row.id });
this.$message.success('审批通过');
this.loadTable();
@@ -700,7 +706,7 @@ export default {
this.loadTable();
},
async handleVoid(row) {
const { value } = await this.$prompt('请输入作废原因', '作废预结算单', {
const { value } = await this.$prompt('请输入作废原因', '作废预付结算单', {
inputType: 'textarea',
inputValidator: value => Boolean(value?.trim()) || '请输入作废原因',
});
@@ -0,0 +1,12 @@
<template>
<formal-settlement locked-settlement-type="receivable" />
</template>
<script>
import FormalSettlement from './formal-settlement.vue';
export default {
name: 'ReceiptSettlement',
components: { FormalSettlement },
};
</script>
@@ -54,9 +54,11 @@
</div>
<el-table
ref="mainTableRef"
v-loading="loading"
:data="rows"
:size="tableSize"
:height="listTableHeight"
border
class="settlement-detail-page__table"
@selection-change="selectionChange"
@@ -146,7 +148,21 @@
show-overflow-tooltip
>
<template #default="{ row }">
{{ formatFeeDetailCell(row, column.prop) }}
<div
v-if="isChargeFeeColumn(column)"
class="settlement-detail-page__billing-rule-cell"
>
<span>{{ formatFeeDetailCell(row, column.prop) }}</span>
<el-icon
v-if="hasBillingRule(row)"
class="settlement-detail-page__billing-rule-icon"
title="查看计费规则详情"
@click.stop="openBillingRuleInfo(row, chargeFeeName(column))"
>
<InfoFilled />
</el-icon>
</div>
<span v-else>{{ formatFeeDetailCell(row, column.prop) }}</span>
</template>
</el-table-column>
</el-table>
@@ -360,12 +376,14 @@
inputmode="decimal"
@input="value => handleAdjustDecimalInput(row, 'transportQuantity', value)"
/>
<span v-else-if="column.prop === 'unitPrice' && isTierUnitPrice(row)">-</span>
<el-input
v-else-if="column.prop === 'unitPrice'"
class="settlement-detail-page__adjust-input"
:model-value="row.unitPrice"
:disabled="!isUnitPriceAdjustable(row)"
inputmode="decimal"
@input="value => handleAdjustDecimalInput(row, 'unitPrice', value)"
@input="value => handleAdjustDecimalInput(row, 'unitPrice', value, 'unitPrice')"
/>
<el-input
v-else-if="column.prop === 'mileage'"
@@ -432,32 +450,48 @@
class="settlement-detail-page__dialog-form"
>
<el-form-item label="更新范围" prop="contractId">
<el-input
:model-value="updateContractName"
class="settlement-detail-page__generate-select"
readonly
placeholder="请选择合同"
<el-tooltip
:content="updateContractName"
:disabled="!updateContractName"
placement="top"
:show-after="200"
>
<template #append>
<el-button @click="openUpdateContractDialog">选择</el-button>
</template>
</el-input>
<el-input
:model-value="updateContractName"
class="settlement-detail-page__update-fee-control"
readonly
placeholder="请选择合同"
>
<template #append>
<el-button @click="openUpdateContractDialog">选择</el-button>
</template>
</el-input>
</el-tooltip>
</el-form-item>
<el-form-item label="合同计费方案" prop="billingPlanId">
<el-select
v-model="updateFeeForm.billingPlanId"
clearable
filterable
:disabled="!updateFeeForm.contractId"
placeholder="请选择"
<el-tooltip
:content="updateBillingPlanName"
:disabled="!updateBillingPlanName"
placement="top"
:show-after="200"
>
<el-option
v-for="item in billingPlanOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
<el-select
v-model="updateFeeForm.billingPlanId"
class="settlement-detail-page__update-fee-control"
clearable
filterable
:disabled="!updateFeeForm.contractId"
placeholder="请选择"
>
<el-option
v-for="item in billingPlanOptions"
:key="item.id"
:label="item.name"
:value="item.id"
:title="item.name"
/>
</el-select>
</el-tooltip>
</el-form-item>
</el-form>
<template #footer>
@@ -934,11 +968,70 @@
</el-button>
</template>
</el-dialog>
<el-dialog
v-model="billingRuleDialog.visible"
title="计费规则详情"
width="720px"
append-to-body
destroy-on-close
>
<template v-if="billingRuleDialog.rule">
<div class="dialog-section-title">计费规则</div>
<el-descriptions :column="2" border class="settlement-detail-page__billing-rule-detail">
<el-descriptions-item label="费用项">
{{ displayValue(billingRuleDialog.rule.feeItem) }}
</el-descriptions-item>
<el-descriptions-item label="计费要素">
{{ displayValue(billingRuleDialog.rule.billingElement) }}
</el-descriptions-item>
<el-descriptions-item label="计费类型">
{{ displayValue(billingRuleDialog.rule.billingType) }}
</el-descriptions-item>
<el-descriptions-item label="计费单位">
{{ displayValue(billingRuleDialog.rule.billingUnit) }}
</el-descriptions-item>
<el-descriptions-item label="单价">
{{ displayValue(billingRuleDialog.rule.unitPrice) }}
</el-descriptions-item>
<el-descriptions-item label="最低计费量">
{{ displayValue(billingRuleDialog.rule.minimumBillingWeight) }}
</el-descriptions-item>
<el-descriptions-item label="计费区间">
{{ billingRuleRanges(billingRuleDialog.rule) }}
</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">
{{ displayValue(billingRuleDialog.rule.remark) }}
</el-descriptions-item>
</el-descriptions>
<div class="dialog-section-title settlement-detail-page__billing-rule-match-title">
匹配条件
</div>
<el-descriptions :column="2" border class="settlement-detail-page__billing-rule-detail">
<el-descriptions-item label="起运地">
{{ displayValue(billingRuleDialog.rule.matchCondition.origin) }}
</el-descriptions-item>
<el-descriptions-item label="目的地">
{{ displayValue(billingRuleDialog.rule.matchCondition.destination) }}
</el-descriptions-item>
<el-descriptions-item label="货物名称">
{{ displayValue(billingRuleDialog.rule.matchCondition.cargoName) }}
</el-descriptions-item>
<el-descriptions-item label="货物类型">
{{ displayValue(billingRuleDialog.rule.matchCondition.cargoType) }}
</el-descriptions-item>
</el-descriptions>
</template>
<el-empty v-else description="暂无计费规则详情" />
<template #footer>
<el-button type="primary" @click="billingRuleDialog.visible = false">关闭</el-button>
</template>
</el-dialog>
</basic-container>
</template>
<script>
import { ArrowDown, ArrowUp, Close } from '@element-plus/icons-vue';
import { ArrowDown, ArrowUp, Close, InfoFilled } from '@element-plus/icons-vue';
import {
changeRecordColumns,
feeDetailBaseColumns,
@@ -959,6 +1052,7 @@ import { getList as getCargoTypeList } from '@/api/base/cargo-type';
import { exportBlob } from '@/api/common';
import { getDictionary } from '@/api/system/dictbiz';
import { formatContractOptionLabel } from '@/utils/contract';
import { isTierUnitPrice, isUnitPriceAdjustable } from '@/utils/settlement-adjust-rule';
import { downloadXls } from '@/utils/util';
import { createSettlementTransfer } from '@/utils/settlement-transfer';
import {
@@ -990,7 +1084,7 @@ const ADJUST_BILLING_TYPE_MAP = {
};
export default {
components: { SettlementTableTools },
components: { SettlementTableTools, InfoFilled },
props: {
settlementType: {
type: String,
@@ -1002,6 +1096,7 @@ export default {
ArrowDown,
ArrowUp,
Close,
InfoFilled,
searchFields,
tableColumns,
tableFeeItemNames: [],
@@ -1018,6 +1113,8 @@ export default {
rows: [],
selection: [],
page: { current: 1, size: 10, total: 0 },
// 底部详情/调整面板打开时压缩主表高度,露出表格滚动条
listTableHeight: undefined,
detailDialog: {
visible: false,
title: '费用明细',
@@ -1027,6 +1124,10 @@ export default {
},
feeRows: [],
dynamicFeeColumns: [],
billingRuleDialog: {
visible: false,
rule: null,
},
adjustDialog: { visible: false, loading: false, submitting: false, row: null },
adjustRows: [],
adjustDynamicFeeColumns: [],
@@ -1118,6 +1219,14 @@ export default {
);
return formatContractOptionLabel(contract);
},
updateBillingPlanName() {
const billingPlanId = this.updateFeeForm.billingPlanId;
if (!billingPlanId) return '';
const plan = this.billingPlanOptions.find(
item => String(item.id) === String(billingPlanId)
);
return plan?.name || '';
},
generateContractCategory() {
return this.settlementType === 'payable' ? '承运商合同' : '客户合同';
},
@@ -1139,7 +1248,9 @@ export default {
return this.searchExpanded ? this.searchFields : this.searchFields.slice(0, 4);
},
feeDetailColumns() {
const baseColumns = feeDetailBaseColumns.filter(column => column.prop !== 'freightAmount');
const baseColumns = feeDetailBaseColumns.filter(
column => !['freightAmount', 'billingFactor', 'billingType'].includes(column.prop)
);
const hasAdjustment = this.feeRows.some(row => Number(row.adjustAmount || 0) !== 0);
const tailColumns = feeDetailTailColumns.map(col =>
col.prop === 'originalAmountText' && hasAdjustment
@@ -1210,11 +1321,24 @@ export default {
transportCargoTypeOptions() {
return this.cargoTypeOptions.filter(item => item.children?.length);
},
/** 底部单据详情或调整面板是否展开(与 teleport 面板显示条件一致) */
isBottomPanelOpen() {
return Boolean(this.detailDialog.visible || this.adjustDialog.visible);
},
},
watch: {
'$route.fullPath'() {
this.openRouteDetail();
},
isBottomPanelOpen() {
this.updateListTableHeight();
},
searchVisible() {
this.updateListTableHeight();
},
searchExpanded() {
this.updateListTableHeight();
},
displayTableColumns: {
immediate: true,
handler(columns) {
@@ -1238,20 +1362,28 @@ export default {
},
},
async mounted() {
window.addEventListener('resize', this.updateListTableHeight);
this.loadTransportTypeOptions();
this.loadCargoTypeOptions();
this.loadPriceUnitOptions();
await this.loadTable();
await this.openRouteDetail();
this.updateListTableHeight();
},
activated() {
this.updateListTableHeight();
},
// 标签切走(keep-alive 缓存)或销毁时,收起 teleport/append-to-body 弹层,避免残留盖住其它页面
deactivated() {
this.closeInnerDialogs();
},
beforeUnmount() {
window.removeEventListener('resize', this.updateListTableHeight);
this.closeInnerDialogs();
},
methods: {
isTierUnitPrice,
isUnitPriceAdjustable,
closeInnerDialogs() {
this.closeDetailPanel();
this.closeAdjustPanel();
@@ -1262,6 +1394,40 @@ export default {
this.previewDialog.visible = false;
this.generateContractDialog.visible = false;
},
/** 表格和分页撑满剩余可视区域;单据详情展开时贴住详情面板,关闭后恢复 */
updateListTableHeight() {
this.$nextTick(() => {
window.requestAnimationFrame(() => this.applyListTableHeight());
});
},
applyListTableHeight() {
const tableElement = this.$refs.mainTableRef?.$el;
if (!tableElement) return;
const pagination = this.$el?.querySelector?.('.settlement-detail-page__pagination');
const paginationHeight = pagination?.offsetHeight || 0;
const tableTop = tableElement.getBoundingClientRect().top;
const view = this.$el?.closest?.('#avue-view');
const viewRect = view?.getBoundingClientRect?.();
let bottomEdge = viewRect ? viewRect.bottom - 12 : window.innerHeight;
if (this.isBottomPanelOpen) {
const panelRect = document
.querySelector('.settlement-detail-page__detail-panel')
?.getBoundingClientRect?.();
if (panelRect && panelRect.height > 0) {
bottomEdge = panelRect.top;
this.listTableHeightRetry = 0;
} else if ((this.listTableHeightRetry || 0) < 5) {
this.listTableHeightRetry = (this.listTableHeightRetry || 0) + 1;
window.requestAnimationFrame(() => this.applyListTableHeight());
return;
}
} else {
this.listTableHeightRetry = 0;
}
const gap = this.isBottomPanelOpen ? 8 : 0;
this.listTableHeight = Math.max(180, Math.floor(bottomEdge - tableTop - paginationHeight - gap));
this.$nextTick(() => this.$refs.mainTableRef?.doLayout?.());
},
contractCategoryName(value) {
return (
this.contractCategoryOptions.find(item => String(item.value) === String(value))?.label ||
@@ -1690,6 +1856,8 @@ export default {
this.detailDialog.visible = false;
this.detailDialog.row = null;
this.changeRecordsDialog.visible = false;
this.billingRuleDialog.visible = false;
this.billingRuleDialog.rule = null;
},
closeAdjustPanel() {
this.clearAdjustCalculations();
@@ -1859,8 +2027,9 @@ export default {
},
handleAdjustDecimalInput(row, prop, value, changedField) {
row[prop] = this.normalizeAdjustDecimal(value);
if (!row.manualFee && row.id && ['transportQuantity', 'mileage'].includes(prop)) {
this.scheduleAdjustFeeCalculation(row);
if (!row.manualFee && row.id && ['transportQuantity', 'mileage', 'unitPrice'].includes(prop)) {
if (prop === 'unitPrice' && !isUnitPriceAdjustable(row)) return;
this.scheduleAdjustFeeCalculation(row, prop);
return;
}
this.recalculateAdjustRow(row, changedField);
@@ -1887,23 +2056,25 @@ export default {
);
row.adjustAmount = Number((row.afterAmount - Number(row.originalAmount || 0)).toFixed(2));
},
scheduleAdjustFeeCalculation(row) {
scheduleAdjustFeeCalculation(row, changedField) {
if (row.adjustCalculateTimer) clearTimeout(row.adjustCalculateTimer);
row.adjustCalculateVersion += 1;
row.calculating = true;
const version = row.adjustCalculateVersion;
row.adjustCalculateTimer = setTimeout(() => {
row.adjustCalculateTimer = null;
this.calculateAdjustRow(row, version);
this.calculateAdjustRow(row, version, changedField);
}, 300);
},
async calculateAdjustRow(row, version) {
async calculateAdjustRow(row, version, changedField) {
try {
const res = await api.calculateAdjustedFee({
detailId: this.adjustDialog.row?.id,
feeId: row.id,
transportQuantity: Number(row.transportQuantity || 0),
mileage: Number(row.mileage || 0),
unitPrice: row.unitPrice === null || row.unitPrice === '' ? null : Number(row.unitPrice),
changedField,
freightAmount: Number(row.freightAmount || 0),
feeItems: Object.fromEntries(
Object.entries(row.feeItems || {}).map(([name, amount]) => [name, Number(amount || 0)])
@@ -1911,18 +2082,24 @@ export default {
});
if (version !== row.adjustCalculateVersion || !this.adjustDialog.visible) return;
const data = res.data?.data || res.data || res || {};
row.freightAmount = Number(data.freightAmount || 0);
row.feeItems = Object.fromEntries(
Object.entries(data.feeItems || {}).map(([name, amount]) => [name, Number(amount || 0)])
);
row.adjustAmount = Number(data.adjustAmount || 0);
row.afterAmount = Number(data.afterAmount || 0);
this.applyCalculatedAdjustRow(row, data);
} catch (error) {
row.calculateError = error.message;
} finally {
if (version === row.adjustCalculateVersion) row.calculating = false;
}
},
applyCalculatedAdjustRow(row, data) {
row.freightAmount = Number(data.freightAmount || 0);
row.feeItems = Object.fromEntries(
Object.entries(data.feeItems || {}).map(([name, amount]) => [name, Number(amount || 0)])
);
if (!isTierUnitPrice(row) && data.unitPrice !== undefined && data.unitPrice !== null) {
row.unitPrice = Number(data.unitPrice);
}
row.adjustAmount = Number(data.adjustAmount || 0);
row.afterAmount = Number(data.afterAmount || 0);
},
clearAdjustCalculations() {
this.adjustRows.forEach(row => {
if (row.adjustCalculateTimer) clearTimeout(row.adjustCalculateTimer);
@@ -1934,6 +2111,140 @@ export default {
isFreightFeeItem(name) {
return String(name || '').includes('运费') || String(name || '').includes('运输费');
},
isChargeFeeColumn(column = {}) {
if (column.prop === 'priceUnit') return false;
if (column.prop === 'freightAmount') return true;
return String(column.prop || '').startsWith('feeItem');
},
chargeFeeName(column = {}) {
if (column.prop === 'freightAmount') return column.label || '运输费';
return column.label || '';
},
hasBillingRule(row) {
const rule = this.normalizeBillingRule(row);
return Boolean(
rule.feeItem ||
rule.billingElement ||
rule.billingType ||
rule.unitPrice ||
rule.rules?.length ||
rule.matchCondition?.origin ||
rule.matchCondition?.destination ||
rule.matchCondition?.cargoName ||
rule.matchCondition?.cargoType
);
},
openBillingRuleInfo(row, feeName = '') {
this.billingRuleDialog.rule = this.normalizeBillingRule(row, feeName);
this.billingRuleDialog.visible = true;
},
ruleFeeName(rule = {}) {
return String(rule.feeItem || rule.feeItemName || rule.name || '').trim();
},
feeNamesMatch(left, right) {
const source = String(left || '').trim();
const target = String(right || '').trim();
if (!source || !target) return false;
if (source === target) return true;
return this.isFreightFeeItem(source) && this.isFreightFeeItem(target);
},
normalizeBillingRule(row, feeName = '') {
const source = row || {};
const nested = [
source.billingRule,
source.billingRuleInfo,
source.billingRuleJson,
source.billingRulesJson,
source.billingRules,
source.billingPlanRule,
source.feeRule,
source.rule,
].find(value => value !== undefined && value !== null && value !== '');
const parsedNested = this.parseJsonValue(nested);
const parsedRules = Array.isArray(parsedNested)
? parsedNested.filter(item => item && typeof item === 'object')
: [];
const requestedFeeName = String(feeName || '').trim();
const matchedRules = requestedFeeName
? parsedRules.filter(item => this.feeNamesMatch(this.ruleFeeName(item), requestedFeeName))
: parsedRules;
const sharedRule =
parsedRules.length === 1 && !this.ruleFeeName(parsedRules[0]) ? parsedRules[0] : null;
const ruleSource =
matchedRules[0] || sharedRule || (!requestedFeeName ? parsedNested || nested : null);
let rule = this.parseObject(ruleSource);
if (!Object.keys(rule).length && typeof nested === 'string' && !requestedFeeName) {
rule = { name: nested };
}
const matchCondition = this.parseObject(
requestedFeeName
? (rule.matchCondition ?? source.matchCondition ?? source.billingMatchCondition)
: (source.matchCondition ?? source.billingMatchCondition ?? rule.matchCondition)
);
return {
...rule,
feeItem: requestedFeeName || source.billingFeeItem || source.feeItem || rule.feeItem,
billingElement: requestedFeeName
? rule.billingElement || rule.billingFactor || ''
: source.billingElement ||
source.billingFactor ||
rule.billingElement ||
rule.billingFactor,
billingType: requestedFeeName ? rule.billingType || '' : source.billingType || rule.billingType,
billingUnit: requestedFeeName
? rule.billingUnit || rule.priceUnit || ''
: source.billingUnit || source.priceUnit || rule.billingUnit || rule.priceUnit,
unitPrice: requestedFeeName
? (rule.unitPrice ?? '')
: (source.billingUnitPrice ?? source.unitPrice ?? rule.unitPrice),
minimumBillingWeight: requestedFeeName
? (rule.minimumBillingWeight ?? rule.lowerLimit ?? '')
: (source.minimumBillingWeight ?? rule.minimumBillingWeight ?? rule.lowerLimit),
remark: requestedFeeName
? rule.remark || ''
: source.billingRuleRemark || source.ruleRemark || rule.remark,
rules: matchedRules,
matchCondition: {
...matchCondition,
origin: matchCondition.origin || matchCondition.originName,
destination: matchCondition.destination || matchCondition.destinationName,
cargoName:
matchCondition.cargoName ||
matchCondition.cargoNameLabel ||
source.cargoName ||
rule.cargoName,
cargoType: matchCondition.cargoType || matchCondition.cargoTypeName,
},
};
},
billingRuleRanges(rule) {
const ranges = Array.isArray(rule?.limitRanges) ? rule.limitRanges : [];
if (ranges.length) {
return ranges
.map(
item => `${item.lowerLimit ?? '-'}~${item.upperLimit ?? '-'}:${item.unitPrice ?? '-'}`
)
.join(';');
}
if (rule?.lowerLimit !== undefined || rule?.upperLimit !== undefined) {
return `${rule.lowerLimit ?? '-'}~${rule.upperLimit ?? '-'}`;
}
return '-';
},
parseJsonValue(value) {
if (value === undefined || value === null || value === '') return null;
if (typeof value === 'object') return value;
if (typeof value !== 'string') return value;
try {
return JSON.parse(value);
} catch (error) {
return value;
}
},
parseObject(value) {
const parsed = this.parseJsonValue(value);
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
},
async saveAdjustFee() {
if (!this.adjustRows.length || !this.adjustDialog.row) {
this.$message.warning('没有可调整的费用明细');
@@ -2857,11 +3168,24 @@ export default {
}
}
:deep(.el-form-item__content) {
min-width: 0;
}
:deep(.el-tooltip__trigger) {
display: block;
width: 100%;
}
:deep(.el-select) {
width: 100%;
}
}
.settlement-detail-page__update-fee-control {
width: 100%;
}
.settlement-detail-page__adjust-input {
width: 100%;
min-width: 0;
@@ -3011,6 +3335,28 @@ export default {
padding-top: 16px;
}
.settlement-detail-page__billing-rule-cell {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
max-width: 100%;
}
.settlement-detail-page__billing-rule-icon {
flex: 0 0 auto;
color: var(--el-color-primary);
cursor: pointer;
}
.settlement-detail-page__billing-rule-detail {
margin-top: 12px;
}
.settlement-detail-page__billing-rule-match-title {
margin-top: 20px;
}
@media screen and (max-width: 992px) {
.settlement-detail-page__detail-panel {
left: 0;
+49 -18
View File
@@ -88,16 +88,21 @@
><el-link
v-if="column.link && row[column.prop]"
type="primary"
@click="openView(row)"
@click="handleTableLink(row, column)"
>{{ row[column.prop] }}</el-link
><el-tag v-else-if="column.status" :type="statusType(row.approvalStatus)" class="status-text">{{
row[column.prop] || '-'
}}</el-tag
><el-tag
v-else-if="column.kingdee"
:type="kingdeeStatusType(row.kingdeeSyncStatus)"
class="status-text"
>{{ kingdeeSyncName(row.kingdeeSyncStatus) }}</el-tag
><span v-else-if="column.money">{{ formatMoney(row[column.prop]) }}</span
><span v-else>{{ displayValue(row[column.prop]) }}</span></template
></el-table-column
>
<el-table-column label="操作" width="120" fixed="right" align="center"
<el-table-column label="操作" width="320" fixed="right" align="center"
><template #default="{ row }"
><div class="settlement-adjustment-page__links">
<el-link
@@ -139,14 +144,10 @@
@click="handleReturn(row)"
>驳回</el-link
><el-link
v-if="
hasPermission('settlement_adjustment_repush') &&
row.approvalStatus === 'approved' &&
row.kingdeeSyncStatus === 'synced'
"
type="danger"
@click="handleRepush(row)"
>重新推送(高危)</el-link
v-if="hasPermission('settlement_adjustment_repush') && row.approvalStatus === 'approved'"
:type="row.kingdeeSyncStatus === 'synced' ? 'danger' : 'primary'"
@click="handleKingdee(row)"
>{{ row.kingdeeSyncStatus === 'synced' ? '重新推送(高危)' : '推送金蝶' }}</el-link
>
</div></template
></el-table-column
@@ -180,6 +181,7 @@ import * as api from '@/api/settlement/settlementAdjustment';
import { settlementAdjustmentSearchFields } from '@/option/settlement/settlementAdjustmentSearch';
import organizationSearch from '@/mixins/organization-search';
import { settlementAdjustmentTableColumns } from '@/option/settlement/settlementAdjustmentTable';
import { kingdeeSyncStatusOptions } from '@/option/settlement/formalSettlementSearch';
import SettlementAdjustmentEditor from './components/settlement-adjustment-editor.vue';
import SettlementTableTools from './components/settlement-table-tools.vue';
import { isAdministrator } from '@/utils/auth';
@@ -283,6 +285,21 @@ export default {
openView(row) {
this.editor = { visible: true, id: row.id, readonly: true };
},
// 单据号→本单查看弹窗;结算单号→跳正式结算列表页并自动打开该单详情(页面支持 ?detailNo=)
handleTableLink(row, column) {
if (column.prop === 'formalSettlementNo') {
this.openSettlementDetail(row.formalSettlementNo);
return;
}
this.openView(row);
},
openSettlementDetail(detailNo) {
if (!detailNo) {
this.$message.info('当前记录未关联结算单详情');
return;
}
this.$router.push({ path: '/settlement/formal-settlement', query: { detailNo } });
},
isEditable(row) {
return ['draft', 'returned'].includes(row.approvalStatus);
},
@@ -300,12 +317,10 @@ export default {
},
async handleApprove(row) {
await this.$confirm('审批通过后将更新关联正式结算单,确认继续?', '提示');
await api.approve(row.id);
if (row.kingdeeSyncStatus === 'synced')
this.$message.warning(
'调整已生效,本地已更新;原结算单已推送金蝶,请财务先手工冲销旧应付单后再重新推送。'
);
else this.$message.success('审批通过');
const res = await api.approve(row.id);
// data=false:自动同步金蝶失败;data=true 且 msg 带已推送场景的手工冲销提示
if (res.data.data === true || res.data.data === false) this.$message.warning(res.data.msg);
else this.$message.success(res.data.msg || '审批通过');
this.loadTable();
},
async handleReturn(row) {
@@ -317,14 +332,24 @@ export default {
this.$message.success('已驳回');
this.loadTable();
},
// 单一入口按状态分流:未同步/失败→推送原结算单;已同步→冲销后重推新单(高危)
async handleKingdee(row) {
if (row.kingdeeSyncStatus === 'synced') return this.handleRepush(row);
return this.handleSyncKingdee(row);
},
async handleSyncKingdee(row) {
const res = await api.syncKingdee(row.id);
this.$message.success(`已推送金蝶:${res.data.data || '-'}`);
this.loadTable();
},
async handleRepush(row) {
await this.$confirm(
'请确认金蝶旧应付单已由财务手工冲销,继续将生成全新财务应付单。',
'请确认金蝶旧应付/应收单已由财务手工冲销,继续将生成全新财务应付/应收单。',
'高危操作确认',
{ type: 'warning', confirmButtonText: '确认重新推送' }
);
const { data } = await api.repush(row.id);
this.$message.success(`已生成新金蝶应付单:${data?.data || data || '-'}`);
this.$message.success(`已生成新金蝶单据:${data?.data || data || '-'}`);
this.loadTable();
},
statusType(status) {
@@ -333,6 +358,12 @@ export default {
'info'
);
},
kingdeeStatusType(status) {
return { synced: 'success', failed: 'danger' }[status] || 'info';
},
kingdeeSyncName(value) {
return kingdeeSyncStatusOptions.find(item => item.value === value)?.label || value || '-';
},
displayValue(value) {
return value === null || value === undefined || value === '' ? '-' : value;
},
@@ -11,7 +11,10 @@ import { useRoute } from 'vue-router';
import SettlementImportPage from './components/settlement-import-page.vue';
const route = useRoute();
const pageTitle = computed(() => (route.query.id ? '编辑导入结算单' : '新增导入结算单'));
const pageTitle = computed(() => {
if (route.query.mode === 'view') return '查看导入结算单';
return route.query.id ? '编辑导入结算单' : '新增导入结算单';
});
</script>
<style scoped lang="scss">
+81 -106
View File
@@ -23,8 +23,8 @@
<el-input v-else v-model="query[field.prop]" clearable placeholder="请输入" />
</el-form-item>
<div class="settlement-import-page__search-actions">
<el-button type="primary" @click="handleSearch">查询</el-button>
<el-button @click="resetSearch">重置</el-button>
<el-button type="primary" @click="handleSearch">搜索</el-button>
<el-button @click="resetSearch">清空</el-button>
<el-button text :icon="searchExpanded ? ArrowUp : ArrowDown" @click="toggleSearch">
{{ searchExpanded ? '收起' : '展开' }}
</el-button>
@@ -43,6 +43,7 @@
>
新增
</el-button>
<el-button plain @click="refreshTable">刷新</el-button>
</div>
</div>
@@ -53,6 +54,13 @@
<el-link type="primary" @click="openDetail(row)">{{ row.batchNo || '-' }}</el-link>
</template>
</el-table-column>
<el-table-column prop="importStatusName" label="状态" width="100" align="center">
<template #default="{ row }">
<el-tag :type="statusTagType(row.importStatus)" effect="plain">
{{ row.importStatusName || importStatusLabel(row.importStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="settlementTypeName" label="导入类型" min-width="100">
<template #default="{ row }">
{{ row.settlementTypeName || settlementTypeLabel(row.settlementType) }}
@@ -68,19 +76,35 @@
<el-table-column prop="carrierName" label="承运商" min-width="140" show-overflow-tooltip />
<el-table-column label="明细行数" width="100" align="center">
<template #default="{ row }">
{{ row.waybillCount ?? row.detailCount ?? 0 }}
{{ row.detailCount ?? row.waybillCount ?? 0 }}
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" min-width="170" />
<el-table-column prop="createUserName" label="创建人" min-width="120">
<template #default="{ row }">{{ row.createUserName || '-' }}</template>
</el-table-column>
<el-table-column label="操作" width="160" fixed="right">
<el-table-column label="操作" width="220" fixed="right">
<template #default="{ row }">
<div class="settlement-import-page__row-actions">
<el-link type="primary" @click="openDetail(row)">详情</el-link>
<el-link type="primary" @click="openDetail(row)">查看</el-link>
<el-link
v-if="row.importStatus !== 'voided' && hasPermission('settlement_import_void')"
v-if="row.importStatus === 'draft'"
type="primary"
@click="editDraft(row)"
>
编辑
</el-link>
<el-link
v-if="row.importStatus === 'draft' && hasPermission('settlement_import_delete')"
type="danger"
@click="handleDelete(row)"
>
删除
</el-link>
<el-link
v-if="
row.importStatus === 'completed' && hasPermission('settlement_import_void')
"
type="danger"
@click="openVoid(row)"
>
@@ -105,66 +129,6 @@
</div>
</section>
<el-dialog v-model="detailVisible" title="导入结算单详情" width="640px" append-to-body>
<el-descriptions :column="2" border>
<el-descriptions-item label="导入批次号">{{ detail.batchNo || '-' }}</el-descriptions-item>
<el-descriptions-item label="导入类型">
{{ detail.settlementTypeName || settlementTypeLabel(detail.settlementType) }}
</el-descriptions-item>
<el-descriptions-item label="结算单">
{{ detail.settlementBillTypeName || settlementBillTypeLabel(detail.settlementBillType) }}
</el-descriptions-item>
<el-descriptions-item label="运单类型">
{{ detail.waybillModeName || waybillModeLabel(detail.waybillMode) }}
</el-descriptions-item>
<el-descriptions-item label="项目">{{ detail.projectName || '-' }}</el-descriptions-item>
<el-descriptions-item label="客户">{{ detail.customerName || '-' }}</el-descriptions-item>
<el-descriptions-item label="客户合同">
{{ detail.customerContractName || '-' }}
</el-descriptions-item>
<el-descriptions-item label="承运商">{{ detail.carrierName || '-' }}</el-descriptions-item>
<el-descriptions-item label="承运商合同">
{{ detail.carrierContractName || '-' }}
</el-descriptions-item>
<el-descriptions-item label="明细行数">
{{ detail.waybillCount ?? detail.detailCount ?? 0 }}
</el-descriptions-item>
<el-descriptions-item label="导入状态">
{{ detail.importStatusName || detail.importStatus || '-' }}
</el-descriptions-item>
<el-descriptions-item label="创建人">{{ detail.createUserName || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ detail.createTime || '-' }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">{{ detail.remark || '-' }}</el-descriptions-item>
<el-descriptions-item label="关联结算单" :span="2">
<el-link
v-if="detail.formalSettlementId"
type="primary"
@click="goFormalSettlement(detail)"
>
{{ detail.formalSettlementNo || detail.formalSettlementId }}
</el-link>
<el-link
v-else-if="detail.preSettlementId"
type="primary"
@click="goPreSettlement(detail)"
>
{{ detail.preSettlementNo || detail.preSettlementId }}
</el-link>
<span v-else>-</span>
</el-descriptions-item>
</el-descriptions>
<template #footer>
<el-button @click="detailVisible = false">关闭</el-button>
<el-button
v-if="detail.importStatus === 'draft'"
type="primary"
@click="editDraft(detail)"
>
编辑草稿
</el-button>
</template>
</el-dialog>
<el-dialog v-model="voidVisible" title="作废导入结算单" width="480px" append-to-body>
<el-form
ref="voidFormRef"
@@ -200,6 +164,7 @@ import * as api from '@/api/settlement/settlementImport';
const emptyQuery = () => ({
batchNo: '',
settlementType: '',
importStatus: '',
projectName: '',
customerName: '',
carrierName: '',
@@ -207,8 +172,15 @@ const emptyQuery = () => ({
const SETTLEMENT_TYPE_OPTIONS = [
{ label: '全部', value: '' },
{ label: '应收正式结算单', value: 'receivable' },
{ label: '应付正式结算单', value: 'payable' },
{ label: '应收', value: 'receivable' },
{ label: '应付', value: 'payable' },
];
const IMPORT_STATUS_OPTIONS = [
{ label: '全部', value: '' },
{ label: '草稿', value: 'draft' },
{ label: '已完成', value: 'completed' },
{ label: '已作废', value: 'voided' },
];
const SETTLEMENT_IMPORT_LIST_REFRESH_KEY = 'settlement-import-list-refresh';
@@ -226,8 +198,6 @@ export default {
rows: [],
page: { current: 1, size: 10, total: 0 },
batchNoOptions: [],
detailVisible: false,
detail: {},
voidVisible: false,
voidLoading: false,
voidForm: { id: null, reason: '' },
@@ -253,6 +223,12 @@ export default {
type: 'select',
options: this.batchNoOptions,
},
{
prop: 'importStatus',
label: '状态',
type: 'select',
options: IMPORT_STATUS_OPTIONS,
},
{
prop: 'settlementType',
label: '导入类型',
@@ -298,6 +274,17 @@ export default {
hasPermission(code) {
return this.isAdmin || this.validData(this.permission?.[code], false);
},
importStatusLabel(value) {
return (
IMPORT_STATUS_OPTIONS.find(item => item.value === value)?.label || value || '-'
);
},
statusTagType(status) {
if (status === 'draft') return 'info';
if (status === 'completed') return 'success';
if (status === 'voided') return 'danger';
return '';
},
settlementTypeLabel(value) {
return (
SETTLEMENT_TYPE_OPTIONS.find(item => item.value === value)?.label || value || '-'
@@ -307,10 +294,6 @@ export default {
if (value === 'pre') return '预结算单';
return '正式结算单';
},
waybillModeLabel(value) {
if (value === 'history') return '历史运单';
return '新运单';
},
unwrapData(response) {
const body = response?.data || response || {};
return body?.data !== undefined ? body.data : body;
@@ -341,6 +324,7 @@ export default {
const response = await api.getList(this.page.current, this.page.size, {
batchNo: this.query.batchNo || undefined,
settlementType: this.query.settlementType || undefined,
importStatus: this.query.importStatus || undefined,
projectName: this.query.projectName || undefined,
customerName: this.query.customerName || undefined,
carrierName: this.query.carrierName || undefined,
@@ -352,6 +336,10 @@ export default {
this.loading = false;
}
},
refreshTable() {
this.loadOptions();
this.loadTable();
},
handleSearch() {
this.page.current = 1;
this.loadTable();
@@ -370,46 +358,33 @@ export default {
openCreate() {
this.$router.push({ path: '/settlement/settlement-import/form' });
},
async openDetail(row) {
openDetail(row) {
if (!row?.id) return;
try {
const response = await api.getDetail(row.id);
this.detail = this.unwrapData(response) || { ...row };
} catch (error) {
this.detail = { ...row };
}
this.detailVisible = true;
this.$router.push({
path: '/settlement/settlement-import/form',
query: { id: row.id, mode: 'view' },
});
},
editDraft(row) {
this.detailVisible = false;
this.$router.push({
path: '/settlement/settlement-import/form',
query: { id: row.id },
});
},
goFormalSettlement(row) {
if (!row?.formalSettlementId) return;
this.detailVisible = false;
this.$router.push({
path: '/settlement/formal-settlement/form',
query: {
mode: 'view',
id: row.formalSettlementId,
name: '正式结算详情',
},
});
},
goPreSettlement(row) {
if (!row?.preSettlementId) return;
this.detailVisible = false;
this.$router.push({
path: '/settlement/pre-settlement/form',
query: {
mode: 'view',
id: row.preSettlementId,
name: '预结算详情',
},
});
async handleDelete(row) {
if (!row?.id) return;
try {
await this.$confirm('确认删除该草稿批次?删除后不可恢复。', '提示', {
type: 'warning',
});
await api.removeDraft(row.id);
this.$message.success('删除成功');
this.loadTable();
this.loadOptions();
} catch (error) {
if (error === 'cancel' || error === 'close') return;
this.$message.error(error?.message || '删除失败');
}
},
openVoid(row) {
this.voidForm = { id: row.id, reason: '' };
+101 -35
View File
@@ -153,7 +153,12 @@
/>
<div class="oa-sync-meta" v-if="oaSyncStage === 'clear'">当前阶段:{{ oaSyncStageLabel }}</div>
<div class="oa-sync-meta" v-else>
当前阶段:{{ oaSyncStageLabel }},第 {{ oaSyncProgress.current || 0 }} / {{ oaSyncTotalPage }} 页
当前阶段:{{ oaSyncStageLabel }}
<template v-if="oaSyncStage === 'department' && oaSyncProgress.companyTotal">
,公司 {{ oaSyncProgress.companyIndex || 0 }} / {{ oaSyncProgress.companyTotal }}
<template v-if="oaSyncProgress.companyOaId">(oaId={{ oaSyncProgress.companyOaId }})</template>
</template>
,第 {{ oaSyncProgress.current || 0 }} / {{ oaSyncTotalPage }} 页
</div>
<div class="oa-sync-stats">
<div class="oa-sync-stat">
@@ -257,6 +262,9 @@ export default {
synced: 0,
skipped: 0,
dumpFilePath: '',
companyOaId: '',
companyIndex: 0,
companyTotal: 0,
},
parentId: 0,
page: {
@@ -290,7 +298,9 @@ export default {
{
label: '组织名称',
prop: 'deptName',
minWidth: 160,
minWidth: 320,
align: 'left',
headerAlign: 'left',
order: 80,
search: true,
searchOrder: 2,
@@ -642,12 +652,18 @@ export default {
}
const totalPage = this.oaSyncTotalPage;
const current = Number(this.oaSyncProgress.current) || 0;
const stageBase = this.oaSyncStage === 'department' ? 50 : 0;
if (totalPage <= 0) {
return stageBase;
if (this.oaSyncStage === 'department') {
const companyTotal = Math.max(1, Number(this.oaSyncProgress.companyTotal) || 1);
const companyIndex = Math.max(1, Number(this.oaSyncProgress.companyIndex) || 1);
const companyBase = ((companyIndex - 1) / companyTotal) * 50;
const pageRatio = totalPage > 0 ? Math.min(1, current / totalPage) : 0;
const companyPagePercent = (pageRatio * 50) / companyTotal;
return Math.min(99, Math.round(50 + companyBase + companyPagePercent));
}
const stagePercent = Math.min(50, Math.round((current / totalPage) * 50));
return Math.min(99, stageBase + stagePercent);
if (totalPage <= 0) {
return 0;
}
return Math.min(49, Math.round((current / totalPage) * 50));
},
oaSyncProgressStatus() {
if (this.oaSyncStatus === 'done') {
@@ -661,25 +677,7 @@ export default {
},
methods: {
handleOaOrgFullSync() {
this.$confirm(
'全量同步将拉取 OA 公司/部门(仅保留二级公司 oaId=2、135 及其子公司与部门);已存在且 OA 更新时间一致的记录会跳过。是否清除后同步?选择“是”将保留顶级「外部组织」与集团锚点(id=1/GWWL),删除其余组织后再同步;选择“否”则直接全量同步。',
'全量同步',
{
confirmButtonText: '是',
cancelButtonText: '否',
distinguishCancelAndClose: true,
closeOnClickModal: false,
type: 'warning',
}
)
.then(() => {
this.startOaOrgSync({ clearNonTop: true, incremental: false });
})
.catch(action => {
if (action === 'cancel') {
this.startOaOrgSync({ clearNonTop: false, incremental: false });
}
});
this.startOaOrgSync({ clearNonTop: false, incremental: false });
},
handleOaOrgIncrementalSync() {
this.$confirm(
@@ -714,6 +712,9 @@ export default {
synced: 0,
skipped: 0,
dumpFilePath: '',
companyOaId: '',
companyIndex: 0,
companyTotal: 0,
};
this.runOaOrgSyncPages();
},
@@ -725,6 +726,25 @@ export default {
error?.name === 'AbortError'
);
},
applyOaOrgSyncPage(page, current, size) {
this.oaSyncProgress.current = page.current || current;
this.oaSyncProgress.size = page.size || size;
this.oaSyncProgress.total = page.total || 0;
this.oaSyncProgress.synced += page.syncedCount || 0;
this.oaSyncProgress.skipped += page.skippedCount || 0;
if (page.dumpFilePath) {
this.oaSyncProgress.dumpFilePath = page.dumpFilePath;
}
if (page.companyOaId != null) {
this.oaSyncProgress.companyOaId = page.companyOaId || '';
}
if (page.companyIndex != null) {
this.oaSyncProgress.companyIndex = page.companyIndex || 0;
}
if (page.companyTotal != null) {
this.oaSyncProgress.companyTotal = page.companyTotal || 0;
}
},
async runOaOrgSyncStage(syncApi) {
const size = 20;
const incremental = this.oaSyncMode === 'incremental';
@@ -742,20 +762,57 @@ export default {
if (!modifiedSince && page.modifiedSince) {
modifiedSince = page.modifiedSince;
}
this.oaSyncProgress.current = page.current || current;
this.oaSyncProgress.size = page.size || size;
this.oaSyncProgress.total = page.total || 0;
this.oaSyncProgress.synced += page.syncedCount || 0;
this.oaSyncProgress.skipped += page.skippedCount || 0;
if (page.dumpFilePath) {
this.oaSyncProgress.dumpFilePath = page.dumpFilePath;
}
this.applyOaOrgSyncPage(page, current, size);
if (page.finished) {
break;
}
current += 1;
}
},
/**
* 部门阶段:公司同步完成后,按公司 oaId 轮询;当前公司部门拉完后切换下一公司并重置页码
*/
async runOaOrgDepartmentSyncStage() {
const size = 20;
const incremental = this.oaSyncMode === 'incremental';
let current = 1;
let modifiedSince = '';
let companyOaId = '';
while (!this.oaSyncCancelled) {
const res = await syncOaDepartment(
current,
size,
this.oaSyncController?.signal,
incremental,
modifiedSince,
companyOaId
);
const page = res?.data?.data || {};
if (!modifiedSince && page.modifiedSince) {
modifiedSince = page.modifiedSince;
}
if (page.companyOaId) {
companyOaId = page.companyOaId;
}
this.applyOaOrgSyncPage(page, current, size);
if (page.finished) {
break;
}
if (page.companyFinished && page.nextCompanyOaId) {
companyOaId = page.nextCompanyOaId;
current = 1;
this.oaSyncProgress.current = 0;
this.oaSyncProgress.total = 0;
// 单公司部门拉完并重建层级后刷新树,便于中途核对挂载结果
this.parentId = 0;
this.data = [];
this.$refs.crud?.refreshTable?.();
this.onLoad(this.page, this.query);
continue;
}
current += 1;
}
},
async runOaOrgSyncPages() {
try {
if (this.oaSyncClearNonTop) {
@@ -775,7 +832,10 @@ export default {
this.oaSyncStage = 'department';
this.oaSyncProgress.current = 0;
this.oaSyncProgress.total = 0;
await this.runOaOrgSyncStage(syncOaDepartment);
this.oaSyncProgress.companyOaId = '';
this.oaSyncProgress.companyIndex = 0;
this.oaSyncProgress.companyTotal = 0;
await this.runOaOrgDepartmentSyncStage();
if (this.oaSyncCancelled) {
this.oaSyncStatus = 'cancelled';
return;
@@ -1460,6 +1520,12 @@ export default {
</script>
<style scoped>
/* 覆盖全站表格居中:树形组织名称需左对齐,展开后缩进才可读 */
:deep(.el-table th.el-table__cell.is-left .cell),
:deep(.el-table td.el-table__cell.is-left .cell) {
text-align: left;
}
.carrier-search-form {
padding: 12px 12px 4px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
+1
View File
@@ -172,6 +172,7 @@
</el-form-item>
</el-col>
<el-col :span="6"><el-form-item label="工号"><el-input v-model="form.code" :disabled="isUserViewMode" /></el-form-item></el-col>
<el-col :span="6"><el-form-item label="OA登录名"><el-input v-model="form.oaLoginId" :disabled="isUserViewMode" maxlength="128" placeholder="请输入OA登录名" /></el-form-item></el-col>
<el-col :span="6"><el-form-item label="人员类别"><el-select v-model="form.personCategory" :disabled="isUserViewMode"><el-option label="内部员工" :value="1" /><el-option label="承运商" :value="2" /></el-select></el-form-item></el-col>
<el-col :span="18"><el-form-item label="数据权限范围"><el-radio-group v-model="form.dataScopeRange" :disabled="isUserViewMode"><el-radio :value="1">仅所属组织</el-radio><el-radio :value="2">全部组织</el-radio><el-radio :value="3">自定义</el-radio></el-radio-group></el-form-item></el-col>
<el-col :span="18"><el-form-item label="数据层级范围"><el-radio-group v-model="form.dataLevelRange" :disabled="isUserViewMode"><el-radio :value="1">包含下级</el-radio><el-radio :value="2">仅本级</el-radio></el-radio-group></el-form-item></el-col>
+1 -1
View File
@@ -42,5 +42,5 @@ export default {
</script>
<style lang="scss" scoped>
@import '../dashboard.scss';
@use '../dashboard.scss';
</style>
@@ -156,7 +156,7 @@ export default {
</script>
<style lang="scss" scoped>
@import '../dashboard.scss';
@use '../dashboard.scss';
.business-panel {
margin-bottom: 16px;
+1 -1
View File
@@ -60,7 +60,7 @@ export default {
</script>
<style lang="scss" scoped>
@import '../dashboard.scss';
@use '../dashboard.scss';
.finance-panel {
margin-bottom: 16px;
+1 -1
View File
@@ -67,7 +67,7 @@ export default {
</script>
<style lang="scss" scoped>
@import '../dashboard.scss';
@use '../dashboard.scss';
.fleet-panel {
margin-bottom: 16px;
+1 -1
View File
@@ -92,7 +92,7 @@ export default {
</script>
<style lang="scss" scoped>
@import '../dashboard.scss';
@use '../dashboard.scss';
.kpi-card {
background: #ffffff;
+1 -1
View File
@@ -62,7 +62,7 @@ export default {
</script>
<style lang="scss" scoped>
@import '../dashboard.scss';
@use '../dashboard.scss';
.project-panel {
margin-bottom: 16px;
@@ -102,7 +102,7 @@ export default {
</script>
<style lang="scss" scoped>
@import '../dashboard.scss';
@use '../dashboard.scss';
.structure-cards__item {
margin-bottom: 16px;
+1 -1
View File
@@ -59,7 +59,7 @@ export default {
</script>
<style lang="scss" scoped>
@import '../dashboard.scss';
@use '../dashboard.scss';
.summary-panel {
margin-bottom: 16px;
+1 -1
View File
@@ -68,7 +68,7 @@ export default {
</script>
<style lang="scss" scoped>
@import '../dashboard.scss';
@use '../dashboard.scss';
.vehicle-cards__item {
margin-bottom: 16px;
+1 -1
View File
@@ -41,7 +41,7 @@ export default {
</script>
<style lang="scss" scoped>
@import '../dashboard.scss';
@use '../dashboard.scss';
.wel-filter__range {
width: 110px;