Merge remote-tracking branch 'origin/master' into feature/20261019-bfi-all-web

# Conflicts:
#	src/views/settlement/formal-settlement.vue
This commit is contained in:
刘泉佳
2026-10-21 16:15:04 +08:00
30 changed files with 2026 additions and 1420 deletions
+31
View File
@@ -0,0 +1,31 @@
# 2026-10-20
## settlement-import 列表页工具栏对齐 receipt-settlement
- `src/views/settlement/settlement-import.vue`:
- 左侧只保留「新增」(`type="primary"`),删掉原来的 `plain` 文字「刷新」按钮(刷新统一收进右侧图标组,与 receipt-settlement / settlement-adjustment 一致)。
- 右侧接入 `<settlement-table-tools>`(`./components/settlement-table-tools.vue`,即 `table-header-tools` 包装):刷新 / 列设置 / 搜索显隐 / 表格尺寸 4 键,`@refresh="refreshTable"`。
- 表格列改为配置化,新增 `src/option/settlement/settlementImportTable.js`(`settlementImportTableColumns`),页面加 `tableColumns / visibleColumnKeys / tableSize / columnSettingOptions / visibleTableColumns`,`el-table` 加 `:size="tableSize"`。
- 列渲染标志:`link / status / enum / billType / count`(注意**不能用 `type` 作 key**,`type` 是 el-table-column 真实 prop,会把列变成 selection/index 列)。
- 新增 `displayValue()`;`settlementBillTypeLabel('')` 返回 `-`。
- 序号列改 `fixed="left"`;数据列与操作列统一 `align: 'center'`,操作链接 `justify-content: center`。
- 校验方式(无 dev server 时):项目根目录临时 `sfc-check.mjs` 用 `vue/compiler-sfc` 的 `parse + compileTemplate + compileScript`;SCSS 用 `sass.compileString`。用完即删。
## 追加:用户要求「列显隐 + 显示方式」→ 两个页面改 avue-crud
用户反馈上面那版不对:右侧工具按钮必须是 **avue-crud 原生**的 4 键,第 2 键是「列显隐」抽屉(不是「列设置」勾选弹窗),第 4 键是「显示方式」(表格↔卡片),不是表格尺寸循环。确认后范围:`settlement-import` + `formal-settlement`(receipt/payment 共用)都改 avue-crud。
- 关键结论:**「列显隐 + 显示方式」只有 avue-crud 原生才有**,avue 的 `dialog-column` 依赖 `inject: ['crud']`,脱离 avue-crud 拿不出来;`table-header-tools` 只是仿制件,做不到。所以目标页只能整页改 avue-crud。
- avue 右侧按钮源码:`node_modules/@smallwei/avue/lib/packages/element-plus/crud/menu/header-menu3.js`(refreshBtn/columnBtn/searchBtn/gridBtn,`gridBtn` → `handleGridShow()` 切 `gridShow` 表格↔卡片);图标默认配置在同目录 `config.js`。
- 新增 `src/option/settlement/settlementImport.js`(`settlementImportOption`)、`src/option/settlement/formalSettlement.js`(`formalSettlementOption`,表格列复用 `formalSettlementTable.js` 的 `formalSettlementTableColumns` + `COLUMN_EXTRA` 增量配置,避免两处维护)。
- `settlement-import.vue` 整页改 avue-crud(删除手写的搜索区/表格/分页);`formal-settlement-table-panel.vue` 由 el-table 改成包一层 `<avue-crud>`,父页面保留数据加载与全部业务动作。
- ⚠️ **avue 的搜索自定义控件要用 `column.renderSearch`(`h()` 渲染),不能用 `searchslot`** —— avue 3.9.2 根本不读 `searchslot`(全库无此字段),而 `searchslot: true` 还会被 `header-search2.js` 的 `searchXxx → xxx` 映射成 `slot: true`。真正的搜索插槽是 avue-crud 上 `${prop}-search`(`crud.searchSlot`,见 `index2.js` `getSlotList(["-search"])`),但其作用域**没有 `row`**(只有 value/column/label/size/readonly/disabled/dic),`mileage-record.vue` 用 `{ row }` 是错的。已用于批次号下拉(filterable + allowCreate)。
- avue `formatter` 签名确认:`detail.js` → `column.formatter(row, row[column.prop], result, column)`。
- `on-load` 由 `table-page2.js` 在 created / 翻页 / 改页容量时触发,参数是内部 `defaultPage`(已 `Object.assign` 合并外部 page)。
- 分页透传写法(父持 page、子包 avue-crud):子组件用 computed `crudPage{get/set}`,setter 里 `Object.assign(this.page, value)` 原地回写,避免 prop 直接赋值告警。
- ⚠️ `src/option/settlement/formalSettlementTable.js` **不能删** —— `formal-settlement-editor.vue` 还从它导入 `candidateColumns/candidateDetailColumns/detailColumns/sourceColumns/summaryColumns`(我一度删掉,Vite 转换报错后从 HEAD 恢复)。
- 校验方式升级:沙箱里 curl 不通 dev server(502),改用 `vite.createServer({ middlewareMode:true })` + `server.transformRequest(path)` 就地转换,能同时暴露依赖解析失败(如上面误删文件)。脚本用完即删。
## 遗留未改(仍用 table-header-tools 仿制件)
pre-settlement、settlement-adjustment、receivable-payable-detail、transport-reconciliation-table-panel、business/{master-order,loading-manage,voucher-manage}、payment/* 手写页。若用户要全站一致,需逐页改 avue-crud。
+12
View File
@@ -69,6 +69,18 @@
- 自检:`curl "localhost:2888/src/xxx.vue"` 与 `"...?vue&type=style&index=0&scoped=true&lang.scss"`(200 / 500)。`vite build` 在 `facelogin.vue` 被沙箱中断,不能作唯一校验。dev `VITE_APP_API=/api` 代理 `172.16.203.228:8000`。 - 自检:`curl "localhost:2888/src/xxx.vue"` 与 `"...?vue&type=style&index=0&scoped=true&lang.scss"`(200 / 500)。`vite build` 在 `facelogin.vue` 被沙箱中断,不能作唯一校验。dev `VITE_APP_API=/api` 代理 `172.16.203.228:8000`。
- 导出:前端 `exportColumns` 后端未用,以 `XxxExportExcel.java` 为准;BladeX `BeanUtil` 类型不兼容静默跳过(`Date` → `LocalDateTime` 丢值,用 `DateUtil.fromDate`)。 - 导出:前端 `exportColumns` 后端未用,以 `XxxExportExcel.java` 为准;BladeX `BeanUtil` 类型不兼容静默跳过(`Date` → `LocalDateTime` 丢值,用 `DateUtil.fromDate`)。
## avue-crud 才是「右侧 4 键」的唯一来源(2026-10-20 定论)
用户要的右侧工具栏是 **avue-crud 原生**:刷新 / **列显隐**(el-drawer,含 隐藏/冻结/过滤/排序 + 行拖拽)/ 搜索显隐 / **显示方式**(表格↔卡片)。
- 源码:`node_modules/@smallwei/avue/lib/packages/element-plus/crud/menu/header-menu3.js`(refreshBtn/columnBtn/searchBtn/gridBtn),`gridBtn` → `handleGridShow()` 切 `gridShow`;图标默认在同目录 `config.js`。「列显隐」文案来自 avue 语言包 `crud.showTitle`(项目 `src/lang/zh.js` 已覆盖)。
- **列显隐抽屉依赖 `inject: ['crud']`,脱离 avue-crud 拿不出来**;`components/table-header-tools` 的「列设置勾选弹窗 + 表格尺寸循环」是仿制件,**做不到这两点**。所以「要和 avue 一致」= 整页改用 avue-crud,没有中间方案。
- ⚠️ 搜索自定义控件用 `column.renderSearch = scope => h(...)`(`scope.row` 可用,同 `mixins/organization-search.js`)。**不要用 `searchslot`**:avue 3.9.2 全库无此字段,且 `header-search2.js` 的 `searchXxx → xxx` 映射会把 `searchslot` 变成 `slot: true`。
- avue-crud 上的 `${prop}-search` 插槽确实存在(`index2.js` 的 `getSlotList(["-search"])`),但**作用域没有 `row`**(只有 value/column/label/size/readonly/disabled/dic)——`mileage-record.vue` 里 `{ row }` 是错的写法,别照抄。
- `formatter` 签名:`detail.js` → `column.formatter(row, row[column.prop], result, column)`。
- `on-load` 由 `table-page2.js` 在 created / 翻页 / 改页容量时触发,参数是内部 `defaultPage`(已合并外部 page)。分页若由父组件持有、子组件包一层 avue-crud,用 computed `crudPage{get/set}` + setter 里 `Object.assign(this.page, value)` 原地回写。
- 已改:settlement-import.vue、formal-settlement.vue + components/formal-settlement-table-panel.vue(receipt/payment 共用)。未改:pre-settlement、settlement-adjustment、receivable-payable-detail、transport-reconciliation-table-panel、business 与 payment 的手写页。
- ⚠️ `src/option/settlement/formalSettlementTable.js` 别删:`formal-settlement-editor.vue` 还依赖它的 candidate/detail/source/summary 列。
- 沙箱里 curl 打不通本地 dev server(一律 502)。改用 `vite.createServer({middlewareMode:true})` + `server.transformRequest(path)` 就地转换校验,还能暴露依赖解析失败。
## Element Plus 图标两种用法的机制差异(易误判) ## Element Plus 图标两种用法的机制差异(易误判)
`main.js` 里 `for (...ElementPlusIconsVue) app.component(key, component)` 全局注册了全部图标,因此模板里可以写标签形式 `<Location />`(靠全局注册解析)。 `main.js` 里 `for (...ElementPlusIconsVue) app.component(key, component)` 全局注册了全部图标,因此模板里可以写标签形式 `<Location />`(靠全局注册解析)。
但 `:icon="OfficeBuilding"` 是**表达式**,编译成 `_ctx.OfficeBuilding`,只会从 data / props / computed / setup 返回值里取 —— **组件对象必须放进 `data()`**;放进 `components: {}` 注册里模板取不到,会静默渲染不出图标(不报错,只是空白)。 但 `:icon="OfficeBuilding"` 是**表达式**,编译成 `_ctx.OfficeBuilding`,只会从 data / props / computed / setup 返回值里取 —— **组件对象必须放进 `data()`**;放进 `components: {}` 注册里模板取不到,会静默渲染不出图标(不报错,只是空白)。
+4 -4
View File
@@ -6,17 +6,17 @@ export const getList = (current, size, params) =>
request({ url: `${baseUrl}/list`, method: 'get', params: { current, size, ...params } }); request({ url: `${baseUrl}/list`, method: 'get', params: { current, size, ...params } });
export const getDetail = id => request({ url: `${baseUrl}/detail`, method: 'get', params: { id } }); export const getDetail = id => request({ url: `${baseUrl}/detail`, method: 'get', params: { id } });
export const getExpiryCounts = () => request({ url: `${baseUrl}/expiry-counts`, method: 'get' }); export const getExpiryCounts = () => request({ url: `${baseUrl}/expiry-counts`, method: 'get' });
export const getAvailableOptions = (keyword, deptId, selectedId) => export const getAvailableOptions = (keyword, deptId, selectedId, payerName, payeeName) =>
request({ request({
url: `${baseUrl}/available-options`, url: `${baseUrl}/available-options`,
method: 'get', method: 'get',
params: { keyword, deptId, selectedId }, params: { keyword, deptId, selectedId, payerName, payeeName },
}); });
export const getAvailablePage = (current, size, keyword, deptId, selectedId) => export const getAvailablePage = (current, size, keyword, deptId, selectedId, payerName, payeeName) =>
request({ request({
url: `${baseUrl}/available-page`, url: `${baseUrl}/available-page`,
method: 'get', method: 'get',
params: { current, size, keyword, deptId, selectedId }, params: { current, size, keyword, deptId, selectedId, payerName, payeeName },
}); });
export const submit = data => request({ url: `${baseUrl}/submit`, method: 'post', data }); export const submit = data => request({ url: `${baseUrl}/submit`, method: 'post', data });
export const remove = id => request({ url: `${baseUrl}/remove`, method: 'post', params: { id } }); export const remove = id => request({ url: `${baseUrl}/remove`, method: 'post', params: { id } });
+2 -2
View File
@@ -252,8 +252,8 @@ export const option = createCrudOption([
searchOrder: 6, searchOrder: 6,
searchPlaceholder: '请输入', searchPlaceholder: '请输入',
order: 185, order: 185,
disabled: true, maxlength: 100,
placeholder: '不填写,则系统自动生成', placeholder: '不填写则按部门规则自动生成',
minWidth: 200, minWidth: 200,
}, },
{ {
+173
View File
@@ -0,0 +1,173 @@
/**
* 正式结算单列表(avue-crud)配置
* ------------------------------------------------------------------
* 列表页与其它模块统一使用 avue-crud,头部 4 个按钮(刷新 / 列显隐 / 搜索显隐 /
* 显示方式)由 avue-crud 自带,不做二次封装。
*
* 表格列复用 formalSettlementTable.js 的 formalSettlementTableColumns(与弹窗内
* 明细表共用同一份列定义),此处只补充 avue 需要的展示/搜索属性,避免两处维护。
*
* ⚠️ searchOrder 为降序排序,值越大越靠前。
* ⚠️ 仅用于搜索的列必须 hide + showColumn: false,否则会混进「列显隐」抽屉。
* ⚠️ column 数组顺序 = 表格列顺序,搜索专用列统一放在数组最前面。
*/
import {
approvalStatusOptions,
invoiceStatusOptions,
kingdeeSyncStatusOptions,
paymentStatusOptions,
} from './formalSettlementSearch';
import { formalSettlementTableColumns } from './formalSettlementTable';
const textFormatter = (row, value) =>
value === null || value === undefined || value === '' ? '-' : value;
/** 金额统一展示:两位小数 + 币种 */
const moneyFormatter = (row, value) =>
`${Number(value || 0).toFixed(2)} ${row?.currency || 'RMB'}`;
const pickLabel = (options, value) =>
options.find(item => item.value === value)?.label || value || '-';
const searchOnlyColumn = ({ label, prop, searchOrder, type = 'input', dicData }) => {
const column = {
label,
prop,
search: true,
searchOrder,
searchSpan: 5,
hide: true,
showColumn: false,
addDisplay: false,
editDisplay: false,
viewDisplay: false,
};
if (type === 'select') {
column.type = 'select';
column.searchPlaceholder = '请选择';
column.dicData = dicData || [];
} else if (type === 'daterange') {
column.type = 'daterange';
column.searchType = 'daterange';
column.searchPlaceholder = '请选择';
} else {
column.searchPlaceholder = '请输入';
}
return column;
};
/** 表格列的 avue 增量配置:搜索项、插槽、覆盖宽度等 */
const COLUMN_EXTRA = {
formalSettlementNo: {
slot: true,
search: true,
searchSpan: 5,
searchOrder: 12,
searchPlaceholder: '请输入',
},
payerName: { search: true, searchSpan: 5, searchOrder: 7, searchPlaceholder: '请输入' },
payeeName: { search: true, searchSpan: 5, searchOrder: 6, searchPlaceholder: '请输入' },
projectName: { search: true, searchSpan: 5, searchOrder: 11, searchPlaceholder: '请输入' },
deptName: { search: true, searchslot: true, searchSpan: 5, searchOrder: 10 },
contractNo: { search: true, searchSpan: 5, searchOrder: 9, searchPlaceholder: '请输入' },
invoiceStatusName: { slot: true },
paymentStatusName: { slot: true },
approvalStatusName: { slot: true },
adjustFlag: {
formatter: row => row.adjustStatusName || (row.originFormalSettlementNo ? '调整后单' : '-'),
},
kingdeeSyncStatus: {
slot: true,
search: true,
type: 'select',
dicData: kingdeeSyncStatusOptions,
searchSpan: 5,
searchOrder: 2,
searchPlaceholder: '请选择',
},
kingdeeLockStatus: { slot: true },
createTime: { width: 180 },
};
const buildTableColumns = () =>
formalSettlementTableColumns.map(column => {
const extra = { ...(COLUMN_EXTRA[column.prop] || {}) };
if (column.money) {
extra.formatter = moneyFormatter;
extra.align = 'right';
}
// link / status 标记的列统一走单元格插槽
if (column.link || column.status) extra.slot = true;
if (!extra.formatter) extra.formatter = textFormatter;
return { ...column, ...extra };
});
export const formalSettlementOption = () => ({
height: 'auto',
calcHeight: 32,
tip: false,
searchBtnText: '查询',
emptyBtnText: '重置',
searchShow: true,
searchIcon: true,
searchLabelWidth: 88,
// 查询/重置紧跟首行 4 个条件(4×5 + 菜单 4 = 24),不再独占下一整行
searchMenuSpan: 4,
searchIndex: 4,
searchMenuPosition: 'right',
border: true,
index: true,
indexLabel: '序号',
indexWidth: 64,
indexFixed: 'left',
selection: true,
selectionWidth: 52,
selectionFixed: 'left',
addBtn: false,
viewBtn: false,
delBtn: false,
editBtn: false,
menuWidth: 320,
menuFixed: 'right',
column: [
// ---------- 仅搜索列 ----------
searchOnlyColumn({
label: '预付结算单号',
prop: 'preSettlementNo',
searchOrder: 8,
}),
searchOnlyColumn({
label: '发票状态',
prop: 'invoiceStatus',
searchOrder: 5,
type: 'select',
dicData: invoiceStatusOptions,
}),
searchOnlyColumn({
label: '收付款状态',
prop: 'paymentStatus',
searchOrder: 4,
type: 'select',
dicData: paymentStatusOptions,
}),
searchOnlyColumn({
label: '审核状态',
prop: 'approvalStatus',
searchOrder: 3,
type: 'select',
dicData: approvalStatusOptions,
}),
searchOnlyColumn({
label: '生成日期',
prop: 'createDateRange',
searchOrder: 1,
type: 'daterange',
}),
// ---------- 表格列(部分兼搜索项) ----------
...buildTableColumns(),
],
});
export const kingdeeSyncName = value => pickLabel(kingdeeSyncStatusOptions, value);
export const paymentStatusName = value => pickLabel(paymentStatusOptions, value);
@@ -55,7 +55,6 @@ export const detailColumns = [
{ label: '运费', prop: 'freightAmount', minWidth: 120, money: true }, { label: '运费', prop: 'freightAmount', minWidth: 120, money: true },
{ label: '调整金额', prop: 'adjustAmount', minWidth: 120, money: true }, { label: '调整金额', prop: 'adjustAmount', minWidth: 120, money: true },
{ label: '结算金额(含税)', prop: 'settlementAmountTax', minWidth: 155, money: true }, { label: '结算金额(含税)', prop: 'settlementAmountTax', minWidth: 155, money: true },
{ label: '结算金额(不含税)', prop: 'settlementAmountNoTax', minWidth: 170, money: true },
{ label: '备注', prop: 'remark', minWidth: 180 }, { label: '备注', prop: 'remark', minWidth: 180 },
]; ];
+157
View File
@@ -0,0 +1,157 @@
/**
* 导入结算单列表(avue-crud)配置
* ------------------------------------------------------------------
* 列表页与其它模块统一使用 avue-crud,头部 4 个按钮(刷新 / 列显隐 / 搜索显隐 /
* 显示方式)由 avue-crud 自带,不做二次封装。
*
* ⚠️ searchOrder 为降序排序,值越大越靠前。
* ⚠️ 仅用于搜索的列必须 hide + showColumn: false,否则会混进「列显隐」抽屉。
*/
const IMPORT_STATUS_OPTIONS = [
{ label: '草稿', value: 'draft' },
{ label: '已完成', value: 'completed' },
{ label: '已作废', value: 'voided' },
];
const SETTLEMENT_TYPE_OPTIONS = [
{ label: '应收', value: 'receivable' },
{ label: '应付', value: 'payable' },
];
const textFormatter = (row, value) =>
value === null || value === undefined || value === '' ? '-' : value;
const pickLabel = (options, value) =>
options.find(item => item.value === value)?.label || value || '-';
const settlementTypeLabel = value => pickLabel(SETTLEMENT_TYPE_OPTIONS, value);
const billTypeLabel = value => (value === 'pre' ? '预结算单' : value ? '正式结算单' : '-');
export const importStatusLabel = value => pickLabel(IMPORT_STATUS_OPTIONS, value);
export const settlementImportOption = () => ({
height: 'auto',
calcHeight: 32,
tip: false,
searchBtnText: '查询',
emptyBtnText: '重置',
searchShow: true,
searchIcon: true,
searchLabelWidth: 88,
// 查询/重置紧跟首行 4 个条件(4×5 + 菜单 4 = 24),不再独占下一整行
searchMenuSpan: 4,
searchIndex: 4,
searchMenuPosition: 'right',
border: true,
index: true,
indexLabel: '序号',
indexWidth: 64,
indexFixed: 'left',
selection: false,
addBtn: false,
viewBtn: false,
delBtn: false,
editBtn: false,
menuWidth: 220,
menuFixed: 'right',
column: [
// ---------- 搜索项(前 4 项默认展示,其余折叠;searchOrder 越大越靠前) ----------
{
label: '状态',
prop: 'importStatus',
type: 'select',
search: true,
searchSpan: 5,
searchOrder: 6,
searchPlaceholder: '请选择',
dicData: IMPORT_STATUS_OPTIONS,
hide: true,
showColumn: false,
addDisplay: false,
editDisplay: false,
viewDisplay: false,
},
{
label: '导入类型',
prop: 'settlementType',
type: 'select',
search: true,
searchSpan: 5,
searchOrder: 5,
searchPlaceholder: '请选择',
dicData: SETTLEMENT_TYPE_OPTIONS,
hide: true,
showColumn: false,
addDisplay: false,
editDisplay: false,
viewDisplay: false,
},
// ---------- 表格列 ----------
{
label: '导入批次号',
prop: 'batchNo',
slot: true,
search: true,
searchSpan: 5,
searchOrder: 7,
searchPlaceholder: '请选择',
minWidth: 160,
},
{ label: '状态', prop: 'importStatusName', slot: true, width: 100, align: 'center' },
{
label: '导入类型',
prop: 'settlementTypeName',
minWidth: 100,
align: 'center',
formatter: (row, value) => value || settlementTypeLabel(row.settlementType),
},
{
label: '结算单',
prop: 'settlementBillTypeName',
minWidth: 110,
align: 'center',
formatter: (row, value) => value || billTypeLabel(row.settlementBillType),
},
{
label: '项目',
prop: 'projectName',
search: true,
searchSpan: 5,
searchOrder: 4,
searchPlaceholder: '请输入',
minWidth: 140,
formatter: textFormatter,
},
{
label: '客户',
prop: 'customerName',
search: true,
searchSpan: 5,
searchOrder: 3,
searchPlaceholder: '请输入',
minWidth: 140,
formatter: textFormatter,
},
{
label: '承运商',
prop: 'carrierName',
search: true,
searchSpan: 5,
searchOrder: 2,
searchPlaceholder: '请输入',
minWidth: 140,
formatter: textFormatter,
},
{
label: '明细行数',
prop: 'detailCount',
width: 100,
align: 'center',
formatter: row => row.detailCount ?? row.waybillCount ?? 0,
},
{ label: '创建时间', prop: 'createTime', width: 180, align: 'center', formatter: textFormatter },
{ label: '创建人', prop: 'createUserName', minWidth: 110, formatter: textFormatter },
],
});
+1
View File
@@ -72,6 +72,7 @@ export const userOption = safe => {
}, },
{ label: '岗位', prop: 'postName', overHidden: true, display: false }, { label: '岗位', prop: 'postName', overHidden: true, display: false },
{ label: '性别', prop: 'sexName', width: 80, 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: 'OA人员id', prop: 'oaPersonId', minWidth: 120, overHidden: true, display: false },
{ label: '备注', prop: 'remark', minWidth: 160, overHidden: true, display: false }, { label: '备注', prop: 'remark', minWidth: 160, overHidden: true, display: false },
{ {
@@ -3774,7 +3774,7 @@
</el-table-column> </el-table-column>
<el-table-column label="剩余数量" min-width="130" align="center"> <el-table-column label="剩余数量" min-width="130" align="center">
<template #default="{ row }"> <template #default="{ row }">
{{ formatDispatchQuantity(dispatchItemRemainingQuantity(row)) }} {{ formatDispatchQuantity(dispatchItemDisplayRemainingQuantity(row)) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column min-width="130" align="center"> <el-table-column min-width="130" align="center">
@@ -4031,7 +4031,7 @@
</el-input> </el-input>
<div class="business-crud-page__dispatch-quantity-hint"> <div class="business-crud-page__dispatch-quantity-hint">
剩余数量:{{ 剩余数量:{{
formatDispatchQuantity(dispatchItemHintRemainingQuantity(dispatchItemForm)) formatDispatchQuantity(dispatchItemDisplayRemainingQuantity(dispatchItemForm))
}} }}
{{ dispatchItemForm.quantityUnit || '吨' }} {{ dispatchItemForm.quantityUnit || '吨' }}
</div> </div>
@@ -5740,6 +5740,8 @@ export default {
dispatchItemIndex: -1, dispatchItemIndex: -1,
dispatchItemForm: defaultDispatchRow(), dispatchItemForm: defaultDispatchRow(),
dispatchItemCargoRows: [], dispatchItemCargoRows: [],
// 本次数量变更版本号:驱动同表其他行「剩余数量」同步重算
dispatchCargoQuantityVersion: 0,
dispatchItemAttachmentRows: [], dispatchItemAttachmentRows: [],
selectedDispatchItemAttachmentRows: [], selectedDispatchItemAttachmentRows: [],
attachmentRows: [], attachmentRows: [],
@@ -12776,18 +12778,23 @@ export default {
row.cargoName = ''; row.cargoName = '';
row.specification = ''; row.specification = '';
row.model = ''; row.model = '';
this.dispatchCargoQuantityVersion += 1;
}, },
handleDispatchConfiguredCargoNameChange(row, value) { handleDispatchConfiguredCargoNameChange(row, value) {
const option = this.getDispatchConfiguredCargoNameOptions(row).find( const option = this.getDispatchConfiguredCargoNameOptions(row).find(
item => String(item.value) === String(value || '') item => String(item.value) === String(value || '')
); );
row.cargoName = option?.value || ''; row.cargoName = option?.value || '';
if (!option) return; if (!option) {
this.dispatchCargoQuantityVersion += 1;
return;
}
row.cargoType = option.cargoTypeLabel || row.cargoType || ''; row.cargoType = option.cargoTypeLabel || row.cargoType || '';
row.cargoTypeCode = option.cargoTypeCode || row.cargoTypeCode || ''; row.cargoTypeCode = option.cargoTypeCode || row.cargoTypeCode || '';
row.cargoTypePath = option.cargoTypePath || row.cargoTypePath || []; row.cargoTypePath = option.cargoTypePath || row.cargoTypePath || [];
row.specification = option.specification || row.specification || ''; row.specification = option.specification || row.specification || '';
row.model = option.model || row.model || ''; row.model = option.model || row.model || '';
this.dispatchCargoQuantityVersion += 1;
}, },
openDispatchItemDialog(index = -1, row = defaultDispatchRow()) { openDispatchItemDialog(index = -1, row = defaultDispatchRow()) {
const defaultSummaryItem = const defaultSummaryItem =
@@ -13119,6 +13126,7 @@ export default {
const parts = text.split('.'); const parts = text.split('.');
row.quantity = row.quantity =
parts.length > 1 ? `${parts[0]}.${parts.slice(1).join('').slice(0, 3)}` : parts[0]; parts.length > 1 ? `${parts[0]}.${parts.slice(1).join('').slice(0, 3)}` : parts[0];
this.dispatchCargoQuantityVersion += 1;
}, },
handleDispatchCargoNumberInput(row, prop, value) { handleDispatchCargoNumberInput(row, prop, value) {
this.handleTaskFullFreightNumberInput(row, prop, value); this.handleTaskFullFreightNumberInput(row, prop, value);
@@ -13138,12 +13146,14 @@ export default {
const nextRow = this.normalizeTransportCargoRow({ priceUnit: '元/吨' }); const nextRow = this.normalizeTransportCargoRow({ priceUnit: '元/吨' });
if (index > -1) this.dispatchItemCargoRows.splice(index + 1, 0, nextRow); if (index > -1) this.dispatchItemCargoRows.splice(index + 1, 0, nextRow);
else this.dispatchItemCargoRows.push(nextRow); else this.dispatchItemCargoRows.push(nextRow);
this.dispatchCargoQuantityVersion += 1;
}, },
removeDispatchCargoRow(index) { removeDispatchCargoRow(index) {
this.dispatchItemCargoRows.splice(index, 1); this.dispatchItemCargoRows.splice(index, 1);
if (!this.dispatchItemCargoRows.length) { if (!this.dispatchItemCargoRows.length) {
this.dispatchItemCargoRows.push(this.normalizeTransportCargoRow()); this.dispatchItemCargoRows.push(this.normalizeTransportCargoRow());
} }
this.dispatchCargoQuantityVersion += 1;
}, },
dispatchCargoFreightAmount(cargo = {}) { dispatchCargoFreightAmount(cargo = {}) {
const quantity = Number(cargo.quantity || 0); const quantity = Number(cargo.quantity || 0);
@@ -13217,11 +13227,52 @@ export default {
}, 0) }, 0)
); );
}, },
/** 精简录入提示:可调度余量扣减当前本次数量后的剩余 */ /**
dispatchItemHintRemainingQuantity(row = {}) { * 当前编辑表单中,与指定行同货物(有身份)或同单位(无身份)已占用的本次数量合计。
* 用于剩余数量展示联动,不参与提交校验(校验仍按整单合计对比计划余量)。
*/
getDispatchFormOccupiedQuantity(row = {}) {
const goodsRows =
this.dispatchItemForm?.taskEntryMode === 'full'
? this.dispatchItemCargoRows || []
: [this.dispatchItemForm || row];
const hasCargoIdentity = Boolean(
String(row.cargoName || row.goodsName || row.name || '').trim() ||
String(
row.cargoType || row.secondCargoTypeName || row.goodsType || row.type || ''
).trim()
);
const unit = this.getDispatchQuantityUnit(row);
const cargoKey = this.getDispatchCargoIdentity(row);
return goodsRows.reduce((sum, goods) => {
if (!goods) return sum;
if (hasCargoIdentity) {
const goodsHasIdentity = Boolean(
String(goods.cargoName || goods.goodsName || goods.name || '').trim() ||
String(
goods.cargoType || goods.secondCargoTypeName || goods.goodsType || goods.type || ''
).trim()
);
if (!goodsHasIdentity || this.getDispatchCargoIdentity(goods) !== cargoKey) {
return sum;
}
} else if (this.getDispatchQuantityUnit(goods) !== unit) {
return sum;
}
return sum + this.parseDispatchQuantity(goods.quantity);
}, 0);
},
/** 展示用剩余数量:计划可调度余量扣减本单已填本次数量(含当前行) */
dispatchItemDisplayRemainingQuantity(row = {}) {
// 依赖版本号,确保一行本次数量变化后其他行剩余数量一并刷新
void this.dispatchCargoQuantityVersion;
const available = this.dispatchItemRemainingQuantity(row); const available = this.dispatchItemRemainingQuantity(row);
const current = this.parseDispatchQuantity(row.quantity); const occupied = this.getDispatchFormOccupiedQuantity(row);
return Math.max(available - current, 0); return Math.max(available - occupied, 0);
},
/** 精简录入提示:与完整录入剩余数量展示规则一致 */
dispatchItemHintRemainingQuantity(row = {}) {
return this.dispatchItemDisplayRemainingQuantity(row);
}, },
pruneDispatchPendingRows(rows = []) { pruneDispatchPendingRows(rows = []) {
const planQuantities = new Map(); const planQuantities = new Map();
@@ -388,7 +388,7 @@
:disabled="dialogReadonly" :disabled="dialogReadonly"
@visible-change="visible => visible && loadFeeUnitOptions()" @visible-change="visible => visible && loadFeeUnitOptions()"
><el-option ><el-option
v-for="unit in feeUnitOptions" v-for="unit in feeUnitSelectOptions"
:key="unit.value" :key="unit.value"
:label="unit.label" :label="unit.label"
:value="unit.value" /></el-select :value="unit.value" /></el-select
@@ -1124,6 +1124,10 @@ import { getDictionary as getSystemDictionary } from '@/api/system/dict';
import { getDictionary } from '@/api/system/dictbiz'; import { getDictionary } from '@/api/system/dictbiz';
import { packageOptions } from '@/option/business/common'; import { packageOptions } from '@/option/business/common';
import { formatContractOptionLabel } from '@/utils/contract'; import { formatContractOptionLabel } from '@/utils/contract';
import {
mapFeeUnitOptions,
resolvePriceUnitByQuantityUnit,
} from '@/utils/currency';
import { loadMeasurementUnitOptions } from '@/utils/measurement-unit'; import { loadMeasurementUnitOptions } from '@/utils/measurement-unit';
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search'; import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
import { downloadFileByUrl, downloadXls } from '@/utils/util'; 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 { export default {
name: 'ShippingTemplatePage', name: 'ShippingTemplatePage',
components: { PageAvueForm, ElImageViewer, OpenFileViewer }, components: { PageAvueForm, ElImageViewer, OpenFileViewer },
@@ -1280,6 +1288,9 @@ export default {
return { return {
Location, Location,
OfficeBuilding, OfficeBuilding,
// 实例所属路由快照,避免 keep-alive 列表实例被全局 $route 误判成表单页。
routePathLocked: this.$route.path,
isFormPageInstance: this.$route.path === shippingTemplateFormRoute,
form: {}, form: {},
query: {}, query: {},
loading: true, loading: true,
@@ -1401,13 +1412,18 @@ export default {
isStandaloneBusinessPage() { isStandaloneBusinessPage() {
return ( return (
this.standaloneFormPage && this.standaloneFormPage &&
['/business/shipping-template', '/business/shipping-template/form'].includes( (this.isFormPageInstance ||
this.$route.path [shippingTemplateListRoute, shippingTemplateFormRoute].includes(this.routePathLocked) ||
) [shippingTemplateListRoute, shippingTemplateFormRoute].includes(this.$route.path))
); );
}, },
isStandaloneFormPage() { 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() { formPageTitle() {
return this.isStandaloneFormPage return this.isStandaloneFormPage
@@ -1464,6 +1480,12 @@ export default {
); );
return this.currencyUnit(option?.label || this.shippingTemplateFreight.currency); return this.currencyUnit(option?.label || this.shippingTemplateFreight.currency);
}, },
feeUnitSelectOptions() {
return mapFeeUnitOptions(
this.feeUnitOptions,
this.shippingTemplateFreight.currency || 'RMB'
);
},
roadFreightTotal() { roadFreightTotal() {
const total = this.shippingTemplateFreight.freightItems.reduce( const total = this.shippingTemplateFreight.freightItems.reduce(
(sum, item) => sum + Number(this.freightAmount(item) || 0), (sum, item) => sum + Number(this.freightAmount(item) || 0),
@@ -1530,6 +1552,18 @@ export default {
}, },
watch: { watch: {
$route(to, from) { $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 ( if (
this.isStandaloneFormPage && this.isStandaloneFormPage &&
(to.query.mode !== from?.query?.mode || (to.query.mode !== from?.query?.mode ||
@@ -1550,6 +1584,10 @@ export default {
this.handleTransportTypeChange(value); this.handleTransportTypeChange(value);
this.syncFreightItems(); this.syncFreightItems();
}, },
'form.templateType'() {
// 切换到运单模板时立即按货物数量单位生成公路运费明细。
this.$nextTick(() => this.syncFreightItems());
},
}, },
created() { created() {
this.loadProjectOptions(); this.loadProjectOptions();
@@ -1559,8 +1597,16 @@ export default {
this.loadCurrencyOptions(); this.loadCurrencyOptions();
if (this.isStandaloneFormPage) this.$nextTick(() => this.initStandaloneFormPage()); if (this.isStandaloneFormPage) this.$nextTick(() => this.initStandaloneFormPage());
}, },
activated() {
if (this.isFormPageInstance) return;
sessionStorage.removeItem(shippingTemplateListRefreshKey);
this.$nextTick(() => this.onLoad(this.page, this.query));
},
methods: { methods: {
formatContractOptionLabel, formatContractOptionLabel,
markShippingTemplateListNeedRefresh() {
sessionStorage.setItem(shippingTemplateListRefreshKey, '1');
},
loadQuantityUnitOptions() { loadQuantityUnitOptions() {
if (this.quantityUnitLoading) return this.quantityUnitLoadPromise; if (this.quantityUnitLoading) return this.quantityUnitLoadPromise;
this.quantityUnitLoading = true; this.quantityUnitLoading = true;
@@ -1591,12 +1637,8 @@ export default {
}); });
} }
if (this.menuWidth != null) next.menuWidth = this.menuWidth; if (this.menuWidth != null) next.menuWidth = this.menuWidth;
if ( // 仅表单页实例套用全屏表单弹窗样式,避免列表页误用后表格区域异常。
this.standaloneFormPage && if (this.standaloneFormPage && this.$route.path === shippingTemplateFormRoute) {
['/business/shipping-template', '/business/shipping-template/form'].includes(
this.$route.path
)
) {
next.dialogAppendToBody = false; next.dialogAppendToBody = false;
next.dialogModal = false; next.dialogModal = false;
next.dialogCustomClass = 'shipping-template-form-page-dialog'; next.dialogCustomClass = 'shipping-template-form-page-dialog';
@@ -1776,13 +1818,22 @@ export default {
this.onLoad(this.page, this.query); this.onLoad(this.page, this.query);
}, },
onLoad(page, params = {}) { onLoad(page, params = {}) {
if (this.isFormPageInstance) return;
this.loading = true; this.loading = true;
const currentPage = page?.currentPage || this.page.currentPage || 1;
const pageSize = page?.pageSize || this.page.pageSize || 10;
this.api this.api
.getList(page.currentPage, page.pageSize, { ...this.query, ...params }) .getList(currentPage, pageSize, { ...this.query, ...params })
.then(res => { .then(res => {
const data = res?.data?.data || {}; const data = res?.data?.data || res?.data || {};
this.data = extractRecords(res); const records = extractRecords(res);
this.page.total = data.total || this.data.length; 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(() => { .finally(() => {
this.loading = false; this.loading = false;
@@ -1821,9 +1872,10 @@ export default {
.submit(submit) .submit(submit)
.then(() => { .then(() => {
this.$message.success('操作成功'); this.$message.success('操作成功');
this.markShippingTemplateListNeedRefresh();
done?.(); done?.();
this.closeCrudDialog(); this.closeCrudDialog();
this.onLoad(this.page, this.query); if (!this.isFormPageInstance) this.onLoad(this.page, this.query);
}) })
.catch(() => loading?.()); .catch(() => loading?.());
}, },
@@ -1837,9 +1889,10 @@ export default {
.submit(submit) .submit(submit)
.then(() => { .then(() => {
this.$message.success('操作成功'); this.$message.success('操作成功');
this.markShippingTemplateListNeedRefresh();
done?.(); done?.();
this.closeCrudDialog(); this.closeCrudDialog();
this.onLoad(this.page, this.query); if (!this.isFormPageInstance) this.onLoad(this.page, this.query);
}) })
.catch(() => loading?.()); .catch(() => loading?.());
}, },
@@ -1883,6 +1936,8 @@ export default {
this.attachmentRows = []; this.attachmentRows = [];
this.shippingTemplateFreight = defaultFreight(); this.shippingTemplateFreight = defaultFreight();
this.loadCurrencyOptions(); this.loadCurrencyOptions();
this.loadFeeUnitOptions();
this.$nextTick(() => this.syncFreightItems());
if (typeof this.api.nextCode === 'function') if (typeof this.api.nextCode === 'function')
this.api this.api
.nextCode() .nextCode()
@@ -2005,20 +2060,47 @@ export default {
return false; return false;
} }
if (this.transportMode === 'road') { if (this.transportMode === 'road') {
const invalid = this.shippingTemplateFreight.freightItems.findIndex( if (!this.shippingTemplateFreight.freightItems.length) {
item => this.$message.warning('请先完善货物数量单位,以便生成运费明细');
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}条货物的单价、计价单位或运费无效`);
return false; 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) { } else if (Number(this.shippingTemplateFreight.freightAmount || 0) < 0) {
this.$message.warning('运费不能小于0'); this.$message.warning('运费不能小于0');
return false; return false;
@@ -2033,8 +2115,11 @@ export default {
return true; return true;
}, },
closeCrudDialog() { closeCrudDialog() {
if (this.isStandaloneBusinessPage) { if (this.isStandaloneBusinessPage || this.isFormPageInstance) {
this.$router.push({ path: '/business/shipping-template', query: {} }); // 关闭独立表单页时标记列表需刷新(含直接点关闭未保存的场景)
this.markShippingTemplateListNeedRefresh();
this.$router.$avueRouter?.closeTag?.();
this.$router.push({ path: shippingTemplateListRoute, query: {} });
return; return;
} }
this.$refs.crud?.closeDialog?.(); this.$refs.crud?.closeDialog?.();
@@ -2294,7 +2379,16 @@ export default {
}, },
loadFeeUnitOptions() { loadFeeUnitOptions() {
getDictionary({ code: 'unit_fee' }).then(res => { 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() { loadCurrencyOptions() {
@@ -3098,24 +3192,53 @@ export default {
: []; : [];
const quantityUnits = []; const quantityUnits = [];
this.transportCargoRows.forEach(row => { 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); if (!quantityUnits.some(unit => unit === quantityUnit)) quantityUnits.push(quantityUnit);
}); });
const currency = this.shippingTemplateFreight.currency || 'RMB';
this.shippingTemplateFreight.freightItems = quantityUnits.map((quantityUnit, index) => { this.shippingTemplateFreight.freightItems = quantityUnits.map((quantityUnit, index) => {
const matched = const matched =
previousItems.find(item => String(item.quantityUnit || '') === String(quantityUnit)) || previousItems.find(item => String(item.quantityUnit || '') === String(quantityUnit)) ||
previousItems[index] || previousItems[index] ||
{}; {};
const defaultPriceUnit = resolvePriceUnitByQuantityUnit(quantityUnit, currency);
const priceUnit = this.normalizeFreightPriceUnit(
matched.priceUnit || defaultPriceUnit || '',
quantityUnit,
currency
);
return { return {
quantityUnit, quantityUnit,
unitPrice: matched.unitPrice || '', unitPrice: matched.unitPrice || '',
priceUnit: matched.priceUnit || '', priceUnit,
freightAmount: matched.freightAmount ?? '', freightAmount: matched.freightAmount ?? '',
freightAmountManual: freightAmountManual:
matched.freightAmountManual === true || matched.manualFreightAmount === true, 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() { quantityUnits() {
return [ return [
...new Set( ...new Set(
@@ -3131,7 +3254,7 @@ export default {
.replace(/\s+/g, '') .replace(/\s+/g, '')
.replace(/立方米|立方公尺|方/g, '立方'); .replace(/立方米|立方公尺|方/g, '立方');
const unit = normalizeUnit(quantityUnit).replace(/[·*.]/g, ''); const unit = normalizeUnit(quantityUnit).replace(/[·*.]/g, '');
const value = String(priceUnit || '') const value = String(this.resolvePriceUnitText(priceUnit) || '')
.trim() .trim()
.toLowerCase() .toLowerCase()
.replace(/\s+/g, ''); .replace(/\s+/g, '');
@@ -3163,6 +3286,10 @@ export default {
return this.formatFreightNumber(item.freightAmount); return this.formatFreightNumber(item.freightAmount);
} }
if (!this.isFreightAutoCalculable(item)) { if (!this.isFreightAutoCalculable(item)) {
// 无法自动计算且未手工填写时返回空,避免把空值显示成 0 造成“已填写”的错觉。
if (item.freightAmount === '' || item.freightAmount === null || item.freightAmount === undefined) {
return '';
}
return this.formatFreightNumber(item.freightAmount); return this.formatFreightNumber(item.freightAmount);
} }
return this.formatFreightNumber( return this.formatFreightNumber(
@@ -1677,7 +1677,7 @@
{{ {{
isDispatchPlanQuantityUnlimited(row) isDispatchPlanQuantityUnlimited(row)
? '-' ? '-'
: formatDispatchQuantity(dispatchItemRemainingQuantity(row)) : formatDispatchQuantity(dispatchItemDisplayRemainingQuantity(row))
}} }}
</template> </template>
</el-table-column> </el-table-column>
@@ -1861,7 +1861,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="司机" :required="dispatchItemForm.carrierType !== '承运商'"> <el-form-item label="司机" required>
<el-autocomplete <el-autocomplete
v-model="dispatchItemForm.driverName" v-model="dispatchItemForm.driverName"
placeholder="请输入" placeholder="请输入"
@@ -1874,7 +1874,7 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
:label="dispatchItemForm.carrierType === '承运商' ? '手机号' : '司机手机号'" :label="dispatchItemForm.carrierType === '承运商' ? '手机号' : '司机手机号'"
:required="dispatchItemForm.carrierType !== '承运商'" required
> >
<el-input v-model="dispatchItemForm.driverPhone" placeholder="请输入" /> <el-input v-model="dispatchItemForm.driverPhone" placeholder="请输入" />
</el-form-item> </el-form-item>
@@ -1955,7 +1955,7 @@
class="transport-plan-page__dispatch-quantity-hint" class="transport-plan-page__dispatch-quantity-hint"
> >
剩余数量:{{ 剩余数量:{{
formatDispatchQuantity(dispatchItemHintRemainingQuantity(dispatchItemForm)) formatDispatchQuantity(dispatchItemDisplayRemainingQuantity(dispatchItemForm))
}} }}
{{ dispatchItemForm.quantityUnit || '吨' }} {{ dispatchItemForm.quantityUnit || '吨' }}
</div> </div>
@@ -2096,11 +2096,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item v-if="dispatchIsRoadTransport" label="司机" required>
v-if="dispatchIsRoadTransport"
label="司机"
:required="dispatchItemForm.carrierType === '自运'"
>
<el-autocomplete <el-autocomplete
v-model="dispatchItemForm.driverName" v-model="dispatchItemForm.driverName"
placeholder="请输入" placeholder="请输入"
@@ -2111,11 +2107,7 @@
@select="item => handleTaskDriverSelect('dispatch', item)" @select="item => handleTaskDriverSelect('dispatch', item)"
/> />
</el-form-item> </el-form-item>
<el-form-item <el-form-item v-if="dispatchIsRoadTransport" label="手机号" required>
v-if="dispatchIsRoadTransport"
label="手机号"
:required="dispatchItemForm.carrierType === '自运'"
>
<el-input v-model="dispatchItemForm.driverPhone" placeholder="请输入" /> <el-input v-model="dispatchItemForm.driverPhone" placeholder="请输入" />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
@@ -2807,8 +2799,11 @@ import 'nprogress/nprogress.css';
const AMAP_KEY = '653b7cf105ad7fb8ec9b2f5198ade315'; const AMAP_KEY = '653b7cf105ad7fb8ec9b2f5198ade315';
const AMAP_SECURITY_CODE = '5aab65c632e48ebae0d0e28f5b28e21a'; const AMAP_SECURITY_CODE = '5aab65c632e48ebae0d0e28f5b28e21a';
let amapLoader; let amapLoader;
const transportPlanListRoute = '/business/transport-plan';
const transportPlanFormRoute = '/business/transport-plan/form';
const transportPlanListRefreshKey = 'transport-plan-list-refresh';
const standaloneTransportPlanFormRoutes = { const standaloneTransportPlanFormRoutes = {
'/business/transport-plan': '/business/transport-plan/form', [transportPlanListRoute]: transportPlanFormRoute,
}; };
const standaloneTransportPlanFormPaths = [ const standaloneTransportPlanFormPaths = [
...Object.keys(standaloneTransportPlanFormRoutes), ...Object.keys(standaloneTransportPlanFormRoutes),
@@ -3072,6 +3067,10 @@ export default {
// 必须放 data:Options API 的顺序是 data → computed → watch(immediate) → created, // 必须放 data:Options API 的顺序是 data → computed → watch(immediate) → created,
// 放 created 的话首个 immediate watcher 会读到空值,把首次加载也挡掉。 // 放 created 的话首个 immediate watcher 会读到空值,把首次加载也挡掉。
routePathLocked: this.$route.path, routePathLocked: this.$route.path,
// 表单页实例在创建时锁定,避免 keep-alive 列表实例随全局 $route 误切到表单态。
isFormPageInstance: Object.values(standaloneTransportPlanFormRoutes).includes(
this.$route.path
),
form: {}, form: {},
suppressTransportTypeClear: false, suppressTransportTypeClear: false,
query: {}, query: {},
@@ -3112,10 +3111,11 @@ export default {
option: (() => { option: (() => {
const opt = this.cloneOption(this.crudOption, estimateMenuButtonCount(this.config)); const opt = this.cloneOption(this.crudOption, estimateMenuButtonCount(this.config));
if (this.menuWidth != null) opt.menuWidth = this.menuWidth; if (this.menuWidth != null) opt.menuWidth = this.menuWidth;
if ( // 仅表单页实例套用全屏表单弹窗样式,避免列表页误用后表格区域异常。
this.standaloneFormPage && const isFormInstance = Object.values(standaloneTransportPlanFormRoutes).includes(
standaloneTransportPlanFormPaths.includes(this.$route.path) this.$route.path
) { );
if (this.standaloneFormPage && isFormInstance) {
opt.dialogAppendToBody = false; opt.dialogAppendToBody = false;
opt.dialogModal = false; opt.dialogModal = false;
opt.dialogCustomClass = 'transport-plan-form-page-dialog'; opt.dialogCustomClass = 'transport-plan-form-page-dialog';
@@ -3150,6 +3150,8 @@ export default {
dispatchItemIndex: -1, dispatchItemIndex: -1,
dispatchItemForm: defaultDispatchRow(), dispatchItemForm: defaultDispatchRow(),
dispatchItemCargoRows: [], dispatchItemCargoRows: [],
// 本次数量变更版本号:驱动同表其他行「剩余数量」同步重算
dispatchCargoQuantityVersion: 0,
dispatchItemAttachmentRows: [], dispatchItemAttachmentRows: [],
selectedDispatchItemAttachmentRows: [], selectedDispatchItemAttachmentRows: [],
attachmentRows: [], attachmentRows: [],
@@ -3289,6 +3291,12 @@ export default {
} }
this.loadTaskQuantityUnitOptions(); this.loadTaskQuantityUnitOptions();
}, },
// keep-alive 重新激活列表时强制刷新,避免缓存脏数据;标记位用于兼容旧跳转逻辑。
activated() {
if (this.isFormPageInstance) return;
sessionStorage.removeItem(transportPlanListRefreshKey);
this.$nextTick(() => this.onLoad(this.page, this.query));
},
computed: { computed: {
...mapGetters(['permission', 'userInfo']), ...mapGetters(['permission', 'userInfo']),
permissionList() { permissionList() {
@@ -3300,10 +3308,20 @@ export default {
return this.config.detailSections || []; return this.config.detailSections || [];
}, },
isStandaloneBusinessPage() { isStandaloneBusinessPage() {
return this.standaloneFormPage && standaloneTransportPlanFormPaths.includes(this.$route.path); return (
this.standaloneFormPage &&
(this.isFormPageInstance ||
standaloneTransportPlanFormPaths.includes(this.routePathLocked) ||
standaloneTransportPlanFormPaths.includes(this.$route.path))
);
}, },
isStandaloneFormPage() { 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() { formPageTitle() {
if (this.isStandaloneFormPage) { if (this.isStandaloneFormPage) {
@@ -3752,6 +3770,18 @@ export default {
}, },
watch: { watch: {
$route(to, from) { $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 (!this.isStandaloneFormPage) return;
if ( if (
to.query.mode !== from?.query?.mode || to.query.mode !== from?.query?.mode ||
@@ -4484,6 +4514,9 @@ export default {
loading(); loading();
} }
}, },
markTransportPlanListNeedRefresh() {
sessionStorage.setItem(transportPlanListRefreshKey, '1');
},
rowSave(row, done, loading) { rowSave(row, done, loading) {
const submitRow = this.normalizeRow(row); const submitRow = this.normalizeRow(row);
if (!submitRow) { if (!submitRow) {
@@ -4492,6 +4525,7 @@ export default {
} }
this.getSaveRequest()(submitRow).then( this.getSaveRequest()(submitRow).then(
() => { () => {
this.markTransportPlanListNeedRefresh();
this.onLoad(this.page); this.onLoad(this.page);
this.$message({ type: 'success', message: '操作成功!' }); this.$message({ type: 'success', message: '操作成功!' });
done(); done();
@@ -4511,6 +4545,7 @@ export default {
} }
this.getSaveRequest()(submitRow).then( this.getSaveRequest()(submitRow).then(
() => { () => {
this.markTransportPlanListNeedRefresh();
this.onLoad(this.page); this.onLoad(this.page);
this.$message({ type: 'success', message: '操作成功!' }); this.$message({ type: 'success', message: '操作成功!' });
done(); done();
@@ -4540,7 +4575,7 @@ export default {
.submit(submitRow) .submit(submitRow)
.then(() => { .then(() => {
this.$message.success(action === 'draft' ? '暂存成功' : '创建成功'); this.$message.success(action === 'draft' ? '暂存成功' : '创建成功');
this.onLoad(this.page, this.query); this.markTransportPlanListNeedRefresh();
this.closeCrudDialog(); this.closeCrudDialog();
}) })
.finally(() => { .finally(() => {
@@ -4548,12 +4583,14 @@ export default {
}); });
}, },
closeCrudDialog() { closeCrudDialog() {
if (this.isStandaloneBusinessPage) { if (this.isStandaloneBusinessPage || this.isFormPageInstance) {
// 关闭独立表单页时标记列表需刷新(含直接点关闭未保存的场景)
this.markTransportPlanListNeedRefresh();
this.$router.$avueRouter?.closeTag?.(); this.$router.$avueRouter?.closeTag?.();
const listPath = const listPath =
Object.entries(standaloneTransportPlanFormRoutes).find( Object.entries(standaloneTransportPlanFormRoutes).find(
([, formPath]) => formPath === this.$route.path ([, formPath]) => formPath === this.$route.path || formPath === this.routePathLocked
)?.[0] || this.$route.path; )?.[0] || transportPlanListRoute;
this.$router.push({ path: listPath, query: {} }); this.$router.push({ path: listPath, query: {} });
return; return;
} }
@@ -6634,20 +6671,33 @@ export default {
return query; return query;
}, },
onLoad(page, params = {}) { onLoad(page, params = {}) {
if (this.isFormPageInstance) return;
this.loading = true; this.loading = true;
const currentPage = page?.currentPage || this.page.currentPage || 1;
const pageSize = page?.pageSize || this.page.pageSize || 10;
const query = this.normalizeQueryParams({ const query = this.normalizeQueryParams({
...params, ...params,
...this.query, ...this.query,
allDept: 0, allDept: 0,
}); });
this.api this.api
.getList(page.currentPage, page.pageSize, query) .getList(currentPage, pageSize, query)
.then(res => { .then(res => {
const result = res.data.data; const result = res?.data?.data || res?.data || {};
this.page.total = result.total; const records = Array.isArray(result.records)
this.data = result.records; ? result.records
: Array.isArray(result)
? result
: [];
this.page.total = Number(result.total ?? records.length) || 0;
this.data = records;
this.selectionClear(); this.selectionClear();
}) })
.catch(error => {
window.console.error(error);
this.data = [];
this.page.total = 0;
})
.finally(() => { .finally(() => {
this.loading = false; this.loading = false;
}); });
@@ -7652,6 +7702,7 @@ export default {
row.cargoName = ''; row.cargoName = '';
row.specification = ''; row.specification = '';
row.model = ''; row.model = '';
this.dispatchCargoQuantityVersion += 1;
}, },
handleDispatchConfiguredCargoNameChange(row, value) { handleDispatchConfiguredCargoNameChange(row, value) {
const nextValue = String(value ?? row.cargoName ?? '').trim(); const nextValue = String(value ?? row.cargoName ?? '').trim();
@@ -7660,6 +7711,7 @@ export default {
); );
if (!option) { if (!option) {
row.cargoName = nextValue; row.cargoName = nextValue;
this.dispatchCargoQuantityVersion += 1;
return; return;
} }
const previousType = String(row.cargoType || '').trim(); const previousType = String(row.cargoType || '').trim();
@@ -7674,6 +7726,7 @@ export default {
} }
row.specification = option.specification || row.specification || ''; row.specification = option.specification || row.specification || '';
row.model = option.model || row.model || ''; row.model = option.model || row.model || '';
this.dispatchCargoQuantityVersion += 1;
}, },
openDispatchItemDialog(index = -1, row = defaultDispatchRow()) { openDispatchItemDialog(index = -1, row = defaultDispatchRow()) {
const defaultSummaryItem = const defaultSummaryItem =
@@ -8002,6 +8055,7 @@ export default {
const parts = text.split('.'); const parts = text.split('.');
row.quantity = row.quantity =
parts.length > 1 ? `${parts[0]}.${parts.slice(1).join('').slice(0, 3)}` : parts[0]; parts.length > 1 ? `${parts[0]}.${parts.slice(1).join('').slice(0, 3)}` : parts[0];
this.dispatchCargoQuantityVersion += 1;
}, },
handleDispatchCargoNumberInput(row, prop, value) { handleDispatchCargoNumberInput(row, prop, value) {
this.handleFreightNumberInput(row, prop, value); this.handleFreightNumberInput(row, prop, value);
@@ -8021,12 +8075,14 @@ export default {
const nextRow = this.normalizeTransportCargoRow({ priceUnit: this.defaultPriceUnit }); const nextRow = this.normalizeTransportCargoRow({ priceUnit: this.defaultPriceUnit });
if (index > -1) this.dispatchItemCargoRows.splice(index + 1, 0, nextRow); if (index > -1) this.dispatchItemCargoRows.splice(index + 1, 0, nextRow);
else this.dispatchItemCargoRows.push(nextRow); else this.dispatchItemCargoRows.push(nextRow);
this.dispatchCargoQuantityVersion += 1;
}, },
removeDispatchCargoRow(index) { removeDispatchCargoRow(index) {
this.dispatchItemCargoRows.splice(index, 1); this.dispatchItemCargoRows.splice(index, 1);
if (!this.dispatchItemCargoRows.length) { if (!this.dispatchItemCargoRows.length) {
this.dispatchItemCargoRows.push(this.normalizeTransportCargoRow()); this.dispatchItemCargoRows.push(this.normalizeTransportCargoRow());
} }
this.dispatchCargoQuantityVersion += 1;
}, },
dispatchCargoFreightAmount(cargo = {}) { dispatchCargoFreightAmount(cargo = {}) {
if (cargo.freightAmount !== undefined && cargo.freightAmount !== null) { if (cargo.freightAmount !== undefined && cargo.freightAmount !== null) {
@@ -8176,11 +8232,50 @@ export default {
}, 0) }, 0)
); );
}, },
/** 精简录入提示:可调度余量扣减当前本次数量后的剩余 */ /**
dispatchItemHintRemainingQuantity(row = {}) { * 当前编辑表单中,与指定行同货物(有身份)或同单位(无身份)已占用的本次数量合计。
* 用于剩余数量展示联动,不参与提交校验(校验仍按整单合计对比计划余量)。
*/
getDispatchFormOccupiedQuantity(row = {}) {
const goodsRows =
this.dispatchItemForm?.taskEntryMode === 'full'
? this.dispatchItemCargoRows || []
: [this.dispatchItemForm || row];
const hasCargoIdentity = Boolean(
String(row.cargoName || row.goodsName || row.name || '').trim() ||
String(row.cargoType || row.secondCargoTypeName || row.goodsType || row.type || '').trim()
);
const unit = this.getDispatchQuantityUnit(row);
const cargoKey = this.getDispatchCargoIdentity(row);
return goodsRows.reduce((sum, goods) => {
if (!goods) return sum;
if (hasCargoIdentity) {
const goodsHasIdentity = Boolean(
String(goods.cargoName || goods.goodsName || goods.name || '').trim() ||
String(
goods.cargoType || goods.secondCargoTypeName || goods.goodsType || goods.type || ''
).trim()
);
if (!goodsHasIdentity || this.getDispatchCargoIdentity(goods) !== cargoKey) {
return sum;
}
} else if (this.getDispatchQuantityUnit(goods) !== unit) {
return sum;
}
return sum + this.parseDispatchQuantity(goods.quantity);
}, 0);
},
/** 展示用剩余数量:计划可调度余量扣减本单已填本次数量(含当前行) */
dispatchItemDisplayRemainingQuantity(row = {}) {
// 依赖版本号,确保一行本次数量变化后其他行剩余数量一并刷新
void this.dispatchCargoQuantityVersion;
const available = this.dispatchItemRemainingQuantity(row); const available = this.dispatchItemRemainingQuantity(row);
const current = this.parseDispatchQuantity(row.quantity); const occupied = this.getDispatchFormOccupiedQuantity(row);
return Math.max(available - current, 0); return Math.max(available - occupied, 0);
},
/** 精简录入提示:与完整录入剩余数量展示规则一致 */
dispatchItemHintRemainingQuantity(row = {}) {
return this.dispatchItemDisplayRemainingQuantity(row);
}, },
pruneDispatchPendingRows(rows = []) { pruneDispatchPendingRows(rows = []) {
const planQuantities = new Map(); const planQuantities = new Map();
@@ -8278,13 +8373,17 @@ export default {
const fullEntry = row.taskEntryMode === 'full'; const fullEntry = row.taskEntryMode === 'full';
const roadTransport = this.resolveTransportMode(row.transportType) === 'road'; const roadTransport = this.resolveTransportMode(row.transportType) === 'road';
if (fullEntry) { if (fullEntry) {
if (roadTransport && row.carrierType === '自运') { // 公路运输时司机/手机号一律必填(含承运类型为承运商)
if (roadTransport && row.carrierType) {
requiredFields.push(['driverName', '司机']); requiredFields.push(['driverName', '司机']);
requiredFields.push(['driverPhone', '手机号']); requiredFields.push(['driverPhone', '手机号']);
} }
} else if (row.carrierType && row.carrierType !== '承运商') { } else if (row.carrierType) {
requiredFields.push(['driverName', '司机']); requiredFields.push(['driverName', '司机']);
requiredFields.push(['driverPhone', '司机手机号']); requiredFields.push([
'driverPhone',
row.carrierType === '承运商' ? '手机号' : '司机手机号',
]);
} }
const emptyField = requiredFields.find(([prop]) => this.isBillingFieldEmpty(row[prop])); const emptyField = requiredFields.find(([prop]) => this.isBillingFieldEmpty(row[prop]));
if (emptyField) return requiredMessage(emptyField[1]); if (emptyField) return requiredMessage(emptyField[1]);
@@ -96,22 +96,12 @@
prop="carrierName" prop="carrierName"
label="承运商" label="承运商"
min-width="140" min-width="140"
/><el-table-column
v-if="columnVisible.carrierType"
prop="carrierType"
label="承运类型"
min-width="120"
/> />
<el-table-column <el-table-column
v-if="columnVisible.waybillCount" v-if="columnVisible.waybillCount"
prop="waybillCount" prop="waybillCount"
label="运单数" label="运单数"
width="90" width="90"
/> <el-table-column
v-if="columnVisible.importTypeName"
prop="importTypeName"
label="导入方式"
width="100"
/> />
<el-table-column <el-table-column
v-if="columnVisible.statusName" v-if="columnVisible.statusName"
@@ -119,6 +109,12 @@
label="状态" label="状态"
width="100" width="100"
/> />
<el-table-column
v-if="columnVisible.settlementStatusName"
prop="settlementStatusName"
label="结算状态"
width="110"
/>
<el-table-column <el-table-column
v-if="columnVisible.createUserName" v-if="columnVisible.createUserName"
prop="createUserName" prop="createUserName"
@@ -159,7 +155,7 @@
>编辑</el-link >编辑</el-link
> >
<el-link <el-link
v-if="row.importStatus === 'draft'" v-if="canRemoveBatch(row)"
type="danger" type="danger"
@click="removeBatch(row)" @click="removeBatch(row)"
>删除</el-link >删除</el-link
@@ -641,10 +637,9 @@ const columnOptions = [
{ prop: 'batchNo', label: '运单批次号' }, { prop: 'batchNo', label: '运单批次号' },
{ prop: 'projectName', label: '项目名称' }, { prop: 'projectName', label: '项目名称' },
{ prop: 'carrierName', label: '承运商' }, { prop: 'carrierName', label: '承运商' },
{ prop: 'carrierType', label: '承运类型' },
{ prop: 'waybillCount', label: '运单数' }, { prop: 'waybillCount', label: '运单数' },
{ prop: 'importTypeName', label: '导入方式' },
{ prop: 'statusName', label: '状态' }, { prop: 'statusName', label: '状态' },
{ prop: 'settlementStatusName', label: '结算状态' },
{ prop: 'createUserName', label: '创建人' }, { prop: 'createUserName', label: '创建人' },
{ prop: 'createTime', label: '创建时间' }, { prop: 'createTime', label: '创建时间' },
{ prop: 'updateTime', label: '更新时间' }, { prop: 'updateTime', label: '更新时间' },
@@ -1266,26 +1261,46 @@ const fillEditForm = async row => {
if (carrierValue) carrierChange(carrierValue); if (carrierValue) carrierChange(carrierValue);
await loadBatchRows(snapshot.id); await loadBatchRows(snapshot.id);
}; };
/** 与行操作一致:仅草稿可删除 */ /** 与后端一致:仅未结算批次可整批删除 */
const canRemoveBatch = row => String(row?.importStatus || '') === 'draft'; const canRemoveBatch = row => String(row?.settlementStatus || 'unsettled') === 'unsettled';
const removeBatches = () => { const removeBatches = async () => {
if (!selected.value.length) { if (!selected.value.length) {
ElMessage.warning('请选择至少一条数据'); ElMessage.warning('请选择至少一条数据');
return; return;
} }
// 选中含不可删条目时整批拦截(含已完成/进行中),不静默跳过 // 选中含部分结算/已结算时整批拦截,不静默跳过
if (selected.value.some(row => !canRemoveBatch(row))) { if (selected.value.some(row => !canRemoveBatch(row))) {
ElMessage.warning('已完成运单不可删除'); ElMessage.warning('仅未结算的运单批次可以删除');
return; return;
} }
return api.removeImportBatches(selected.value.map(item => item.id).join(',')).then(loadBatches); try {
await ElMessageBox.confirm('确认删除选中的运单批次?删除后不可恢复。', '提示', {
type: 'warning',
});
} catch {
return;
}
await api.removeImportBatches(selected.value.map(item => item.id).join(','));
ElMessage.success('删除成功');
return loadBatches();
}; };
const removeBatch = row => { const removeBatch = async row => {
if (!canRemoveBatch(row)) { if (!canRemoveBatch(row)) {
ElMessage.warning('已完成运单不可删除'); ElMessage.warning('仅未结算的运单批次可以删除');
return; return;
} }
return api.removeImportBatches(row.id).then(loadBatches); try {
await ElMessageBox.confirm(
`确认删除运单批次「${row.batchNo || ''}」?删除后不可恢复。`,
'提示',
{ type: 'warning' }
);
} catch {
return;
}
await api.removeImportBatches(row.id);
ElMessage.success('删除成功');
return loadBatches();
}; };
const projectChange = async id => { const projectChange = async id => {
const requestId = ++projectRequestId; const requestId = ++projectRequestId;
+43 -10
View File
@@ -380,17 +380,15 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="合同编号"> <el-form-item label="合同编号" prop="contractNo">
<el-input <el-input
v-model="form.contractNo" v-model="form.contractNo"
disabled maxlength="100"
clearable
:placeholder=" :placeholder="
formMode === 'add' formMode === 'add' ? '不填写则按部门规则自动生成' : '请输入合同编号'
? form.organizationId
? '系统按部门规则自动生成'
: '请先选择合同负责部门'
: ''
" "
@input="handleContractNoInput"
/> />
</el-form-item> </el-form-item>
<el-form-item label="合同名称" prop="contractName"> <el-form-item label="合同名称" prop="contractName">
@@ -1268,7 +1266,23 @@ export default {
{ label: '已到期', value: 'expired', statKey: 'expired' }, { label: '已到期', value: 'expired', statKey: 'expired' },
], ],
form: defaultForm(), form: defaultForm(),
contractNoManual: false,
formRules: { formRules: {
contractNo: [
{
validator: (rule, value, callback) => {
const contractNo = String(value || '').trim();
if (this.formMode === 'edit' && !contractNo) {
return callback(new Error('请输入合同编号'));
}
if (contractNo.length > 100) {
return callback(new Error('合同编号不能超过100个字符'));
}
callback();
},
trigger: 'blur',
},
],
contractName: [{ required: true, message: '请输入合同名称', trigger: 'blur' }], contractName: [{ required: true, message: '请输入合同名称', trigger: 'blur' }],
contractCategory: [{ required: true, message: '请选择合同类别', trigger: 'change' }], contractCategory: [{ required: true, message: '请选择合同类别', trigger: 'change' }],
signType: [{ required: true, message: '请选择签约类型', trigger: 'change' }], signType: [{ required: true, message: '请选择签约类型', trigger: 'change' }],
@@ -1782,6 +1796,7 @@ export default {
this.api.getDetail(id).then(res => this.applyDetail(res.data?.data || {})); this.api.getDetail(id).then(res => this.applyDetail(res.data?.data || {}));
}, },
resetFormState() { resetFormState() {
this.contractNoManual = false;
this.form = { this.form = {
...defaultForm(), ...defaultForm(),
handlerUserName: handlerUserName:
@@ -1857,7 +1872,20 @@ export default {
this.$router.$avueRouter?.closeTag?.(); this.$router.$avueRouter?.closeTag?.();
this.$router.push(contractManageListRoute); this.$router.push(contractManageListRoute);
}, },
validateContractNo() {
const contractNo = String(this.form.contractNo || '').trim();
if (this.formMode === 'edit' && !contractNo) {
this.$message.warning('请输入合同编号');
return false;
}
if (contractNo.length > 100) {
this.$message.warning('合同编号不能超过100个字符');
return false;
}
return true;
},
validateBase(action) { validateBase(action) {
if (!this.validateContractNo()) return false;
if (action === 'temporary') { if (action === 'temporary') {
const required = [ const required = [
['signType', '签约类型'], ['signType', '签约类型'],
@@ -1943,6 +1971,7 @@ export default {
const projectName = projectId ? normalizeProjectValue(this.form.projectName) : ''; const projectName = projectId ? normalizeProjectValue(this.form.projectName) : '';
return { return {
...this.form, ...this.form,
contractNo: String(this.form.contractNo || '').trim(),
projectId, projectId,
projectName, projectName,
copyCount: normalizeOptionalInteger(this.form.copyCount), copyCount: normalizeOptionalInteger(this.form.copyCount),
@@ -2314,11 +2343,14 @@ export default {
this.refreshPreviewContractNo(); this.refreshPreviewContractNo();
} }
}, },
handleContractNoInput(value) {
this.contractNoManual = String(value || '').trim() !== '';
},
refreshPreviewContractNo() { refreshPreviewContractNo() {
if (this.formMode !== 'add') return; if (this.formMode !== 'add') return;
const organizationId = this.form.organizationId; const organizationId = this.form.organizationId;
if (!organizationId) { if (!organizationId) {
this.form.contractNo = ''; if (!this.contractNoManual) this.form.contractNo = '';
return; return;
} }
const requestId = (this.contractNoPreviewRequestId = const requestId = (this.contractNoPreviewRequestId =
@@ -2326,11 +2358,11 @@ export default {
api api
.nextContractNo(organizationId) .nextContractNo(organizationId)
.then(res => { .then(res => {
if (requestId !== this.contractNoPreviewRequestId) return; if (requestId !== this.contractNoPreviewRequestId || this.contractNoManual) return;
this.form.contractNo = res.data?.data || ''; this.form.contractNo = res.data?.data || '';
}) })
.catch(() => { .catch(() => {
if (requestId !== this.contractNoPreviewRequestId) return; if (requestId !== this.contractNoPreviewRequestId || this.contractNoManual) return;
this.form.contractNo = ''; this.form.contractNo = '';
}); });
}, },
@@ -2763,6 +2795,7 @@ export default {
}, },
getContractChangeFieldLabel(field) { getContractChangeFieldLabel(field) {
const labels = { const labels = {
contractNo: '合同编号',
contractName: '合同名称', contractName: '合同名称',
partyB: '乙方', partyB: '乙方',
startDate: '开始日期', startDate: '开始日期',
@@ -602,6 +602,8 @@ export default {
if (result.code !== 200) throw new Error(result.msg || '导入失败'); if (result.code !== 200) throw new Error(result.msg || '导入失败');
this.$message.success('导入完成'); this.$message.success('导入完成');
} }
// 与运单/配载一致:通知 keep-alive 列表实例重新拉取
sessionStorage.setItem('transport-plan-list-refresh', '1');
this.$router.push('/business/transport-plan'); this.$router.push('/business/transport-plan');
} catch (error) { } catch (error) {
this.$message.error(error.message || '导入失败'); this.$message.error(error.message || '导入失败');
+117 -43
View File
@@ -44,7 +44,8 @@
reserve-keyword reserve-keyword
:remote-method="searchCustomers" :remote-method="searchCustomers"
:loading="customerLoading" :loading="customerLoading"
placeholder="请选择客商基础档案" placeholder="请选择"
@change="syncFeeBearer"
> >
<el-option <el-option
v-for="item in customerOptions" v-for="item in customerOptions"
@@ -63,6 +64,7 @@
allow-create allow-create
default-first-option default-first-option
placeholder="请选择或输入" placeholder="请选择或输入"
@change="syncFeeBearer"
> >
<el-option <el-option
v-for="item in receiverOptions" v-for="item in receiverOptions"
@@ -74,7 +76,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="票面金额" prop="faceAmount"> <el-form-item label="票面金额" prop="faceAmount" required>
<el-input-number <el-input-number
v-model="form.faceAmount" v-model="form.faceAmount"
:min="0" :min="0"
@@ -111,17 +113,15 @@
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="可用部门" prop="availableDeptIds"> <el-form-item label="可用部门" prop="availableDeptIds">
<el-tree-select <el-cascader
v-model="form.availableDeptIds" v-model="availableDeptCascaderValue"
:data="deptTree" :options="businessDeptTreeOptions"
:props="deptProps" :props="deptCascaderProps"
node-key="id" placeholder="请选择"
multiple filterable
show-checkbox clearable
collapse-tags collapse-tags
collapse-tags-tooltip collapse-tags-tooltip
placeholder="请选择,默认全部"
@change="handleDeptChange"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
@@ -140,17 +140,9 @@
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="费用承担方" prop="feeBearerId"> <el-form-item label="费用承担方" prop="feeBearerId">
<el-select <el-select v-model="form.feeBearerId" filterable clearable placeholder="请选择">
v-model="form.feeBearerId"
filterable
remote
reserve-keyword
:remote-method="searchCustomers"
:loading="customerLoading"
placeholder="请选择客商基础档案"
>
<el-option <el-option
v-for="item in customerOptions" v-for="item in feeBearerOptions"
:key="item.id" :key="item.id"
:label="customerName(item)" :label="customerName(item)"
:value="item.id" :value="item.id"
@@ -245,13 +237,13 @@ const emptyForm = () => ({
billNo: '', billNo: '',
issuerId: null, issuerId: null,
receiverName: '', receiverName: '',
billType: 'issued', billType: '',
faceAmount: null, faceAmount: null,
availableBalance: 0, availableBalance: 0,
issueDate: '', issueDate: '',
maturityDate: '', maturityDate: '',
availableDeptIds: ['all'], availableDeptIds: [],
availableDeptNames: '全部', availableDeptNames: '',
feeBearerId: null, feeBearerId: null,
confirmedDiscountRate: null, confirmedDiscountRate: null,
issuingBank: '', issuingBank: '',
@@ -272,9 +264,17 @@ export default {
receiverOptions: [], receiverOptions: [],
customerLoading: false, customerLoading: false,
saving: false, saving: false,
deptTree: [], businessDeptTreeOptions: [],
deptMap: new Map(), deptMap: new Map(),
deptProps: { label: 'title', value: 'id', children: 'children' }, deptCascaderProps: {
label: 'label',
value: 'value',
children: 'children',
multiple: true,
checkStrictly: true,
emitPath: true,
expandTrigger: 'click',
},
bankOptions: [ bankOptions: [
'中国工商银行', '中国工商银行',
'中国农业银行', '中国农业银行',
@@ -309,7 +309,10 @@ export default {
issuerId: [{ required: true, message: '请选择出票单位', trigger: 'change' }], issuerId: [{ required: true, message: '请选择出票单位', trigger: 'change' }],
receiverName: [{ required: true, message: '请选择或输入收票单位', trigger: 'change' }], receiverName: [{ required: true, message: '请选择或输入收票单位', trigger: 'change' }],
billType: [{ required: true, message: '请选择汇票类型', trigger: 'change' }], billType: [{ required: true, message: '请选择汇票类型', trigger: 'change' }],
faceAmount: [{ validator: this.validateFaceAmount, trigger: 'change' }], faceAmount: [
{ required: true, message: '请输入票面金额', trigger: 'change' },
{ validator: this.validateFaceAmount, trigger: 'change' },
],
issueDate: [{ required: true, message: '请选择出票日期', trigger: 'change' }], issueDate: [{ required: true, message: '请选择出票日期', trigger: 'change' }],
maturityDate: [{ required: true, validator: this.validateMaturityDate, trigger: 'change' }], maturityDate: [{ required: true, validator: this.validateMaturityDate, trigger: 'change' }],
availableDeptIds: [{ validator: this.validateDepartments, trigger: 'change' }], availableDeptIds: [{ validator: this.validateDepartments, trigger: 'change' }],
@@ -340,6 +343,42 @@ export default {
(Number(this.form.faceAmount || 0) * Number(this.form.confirmedDiscountRate || 0)) / 100 (Number(this.form.faceAmount || 0) * Number(this.form.confirmedDiscountRate || 0)) / 100
); );
}, },
// 可用部门:表单存部门 id,级联多选回显用根到节点的路径
availableDeptCascaderValue: {
get() {
return (this.form.availableDeptIds || [])
.filter(id => id !== undefined && id !== null && String(id) !== 'all' && String(id) !== '')
.map(id => this.findDeptPath(id, this.businessDeptTreeOptions) || [String(id)]);
},
set(paths) {
const ids = [
...new Set(
(paths || [])
.map(path => {
const nodes = Array.isArray(path) ? path.filter(item => item !== undefined && item !== null && item !== '') : [];
return nodes.length ? String(nodes.at(-1)) : '';
})
.filter(Boolean)
),
];
this.form.availableDeptIds = ids;
this.form.availableDeptNames = ids
.map(id => this.deptMap.get(String(id)))
.filter(Boolean)
.join('、');
},
},
feeBearerOptions() {
const issuer = this.customerOptions.find(item => String(item.id) === String(this.form.issuerId));
const receiverName = String(this.form.receiverName || '').trim();
const receiver = receiverName
? this.customerOptions.find(item => this.customerName(item) === receiverName)
: null;
return [issuer, receiver].filter(
(item, index, rows) =>
item && rows.findIndex(row => row && String(row.id) === String(item.id)) === index
);
},
}, },
created() { created() {
this.initialize(); this.initialize();
@@ -352,7 +391,6 @@ export default {
async initialize() { async initialize() {
await Promise.all([this.loadDepartments(), this.searchCustomers('')]); await Promise.all([this.loadDepartments(), this.searchCustomers('')]);
if (!this.recordId) { if (!this.recordId) {
this.form.issueDate = this.$dayjs().format('YYYY-MM-DD');
return; return;
} }
const data = this.unwrapData(await api.getDetail(this.recordId)); const data = this.unwrapData(await api.getDetail(this.recordId));
@@ -361,14 +399,20 @@ export default {
...data, ...data,
confirmedDiscountRate: this.normalizeDiscountRate(data.confirmedDiscountRate), confirmedDiscountRate: this.normalizeDiscountRate(data.confirmedDiscountRate),
bankDiscountReferenceRate: this.normalizeDiscountRate(data.bankDiscountReferenceRate), bankDiscountReferenceRate: this.normalizeDiscountRate(data.bankDiscountReferenceRate),
availableDeptIds: this.parse(data.availableDeptIdsJson), availableDeptIds: this.parse(data.availableDeptIdsJson)
.filter(id => String(id) !== 'all')
.map(id => String(id)),
attachments: this.parse(data.attachmentsJson), attachments: this.parse(data.attachmentsJson),
}; };
this.usageRecords = data.usageRecords || []; this.usageRecords = data.usageRecords || [];
this.receiverOptions = data.receiverName ? [data.receiverName] : []; this.receiverOptions = data.receiverName ? [data.receiverName] : [];
this.ensureCustomerOption(data.issuerId, data.issuerName); this.ensureCustomerOption(data.issuerId, data.issuerName);
this.ensureCustomerOption(data.feeBearerId, data.feeBearerName); this.ensureCustomerOption(data.feeBearerId, data.feeBearerName);
this.handleDeptChange(this.form.availableDeptIds); this.form.availableDeptNames = (this.form.availableDeptIds || [])
.map(id => this.deptMap.get(String(id)))
.filter(Boolean)
.join('、');
this.syncFeeBearer();
}, },
parse(value) { parse(value) {
if (!value) return []; if (!value) return [];
@@ -381,22 +425,52 @@ export default {
}, },
async loadDepartments() { async loadDepartments() {
const response = await getDeptTree(this.userInfo?.tenantId); const response = await getDeptTree(this.userInfo?.tenantId);
const rows = this.unwrapData(response) || []; const rows = this.excludeExternalOrganization(this.unwrapData(response) || []);
this.deptTree = [{ id: 'all', title: '全部', children: rows }]; this.businessDeptTreeOptions = this.toDeptCascaderOptions(rows);
this.deptMap = new Map([['all', '全部']]); this.deptMap = new Map();
this.flattenDepartments(rows).forEach(item => this.deptMap.set(String(item.id), item.title)); this.flattenDepartments(rows).forEach(item =>
this.deptMap.set(String(item.id), item.title || item.deptName || item.name)
);
},
excludeExternalOrganization(list = []) {
return list.reduce((result, item) => {
const deptName = item.title || item.deptName || item.name;
if (String(deptName || '').trim() === '外部组织') return result;
result.push({
...item,
children: item.children?.length
? this.excludeExternalOrganization(item.children)
: item.children,
});
return result;
}, []);
},
toDeptCascaderOptions(list = []) {
return list.map(item => ({
label: item.title || item.deptName || item.name,
value: item.id == null || item.id === '' ? '' : String(item.id),
children: item.children?.length ? this.toDeptCascaderOptions(item.children) : undefined,
}));
}, },
flattenDepartments(rows) { flattenDepartments(rows) {
return (rows || []).flatMap(item => [item, ...this.flattenDepartments(item.children || [])]); return (rows || []).flatMap(item => [item, ...this.flattenDepartments(item.children || [])]);
}, },
handleDeptChange(values) { findDeptPath(id, tree = [], parents = []) {
const ids = values || []; const target = Array.isArray(id) ? id.at(-1) : id;
this.form.availableDeptNames = ids.some(item => String(item) === 'all') if (target === undefined || target === null || target === '') return null;
? '全部' for (const node of tree || []) {
: ids const path = [...parents, node.value];
.map(item => this.deptMap.get(String(item))) if (String(node.value) === String(target)) return path;
.filter(Boolean) const matched = this.findDeptPath(target, node.children, path);
.join('、'); if (matched) return matched;
}
return null;
},
syncFeeBearer() {
const allowed = this.feeBearerOptions.map(item => String(item.id));
if (this.form.feeBearerId && !allowed.includes(String(this.form.feeBearerId))) {
this.form.feeBearerId = null;
}
}, },
async searchCustomers(keyword) { async searchCustomers(keyword) {
this.customerLoading = true; this.customerLoading = true;
@@ -545,7 +619,7 @@ export default {
.bill-ledger-form-page__form :deep(.el-select), .bill-ledger-form-page__form :deep(.el-select),
.bill-ledger-form-page__form :deep(.el-input-number), .bill-ledger-form-page__form :deep(.el-input-number),
.bill-ledger-form-page__form :deep(.el-date-editor), .bill-ledger-form-page__form :deep(.el-date-editor),
.bill-ledger-form-page__form :deep(.el-tree-select) { .bill-ledger-form-page__form :deep(.el-cascader) {
width: 100%; width: 100%;
} }
.bill-ledger-form-page__form :deep(.el-input-number .el-input__inner) { .bill-ledger-form-page__form :deep(.el-input-number .el-input__inner) {
+129 -31
View File
@@ -16,13 +16,22 @@
<el-row :gutter="32"> <el-row :gutter="32">
<el-col :span="6"> <el-col :span="6">
<el-form-item label="发票号码" prop="invoiceNo"> <el-form-item label="发票号码" prop="invoiceNo">
<el-input v-model="form.invoiceNo" readonly placeholder="请选择金蝶票据池发票"> <el-tooltip
<template v-if="!readonly" #append> :content="form.invoiceNo"
<el-tooltip content="查询金蝶票据池" placement="top"> :disabled="!form.invoiceNo"
<el-button :icon="Search" @click="openInvoiceDialog" /> placement="top"
</el-tooltip> :show-after="200"
</template> >
</el-input> <div class="receipt-form-page__overflow-trigger">
<el-input v-model="form.invoiceNo" readonly placeholder="请选择金蝶票据池发票">
<template v-if="!readonly" #append>
<el-tooltip content="查询金蝶票据池" placement="top">
<el-button :icon="Search" @click="openInvoiceDialog" />
</el-tooltip>
</template>
</el-input>
</div>
</el-tooltip>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
@@ -32,7 +41,16 @@
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="发票类型"> <el-form-item label="发票类型">
<el-input v-model="form.invoiceType" disabled placeholder="从金蝶票据池带出" /> <el-tooltip
:content="form.invoiceType"
:disabled="!form.invoiceType"
placement="top"
:show-after="200"
>
<div class="receipt-form-page__overflow-trigger">
<el-input v-model="form.invoiceType" disabled placeholder="从金蝶票据池带出" />
</div>
</el-tooltip>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
@@ -64,23 +82,54 @@
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="受票单位"> <el-form-item label="受票单位">
<el-input v-model="form.receiverName" disabled placeholder="从金蝶票据池带出" /> <el-tooltip
:content="form.receiverName"
:disabled="!form.receiverName"
placement="top"
:show-after="200"
>
<div class="receipt-form-page__overflow-trigger">
<el-input v-model="form.receiverName" disabled placeholder="从金蝶票据池带出" />
</div>
</el-tooltip>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="开票单位"> <el-form-item label="开票单位">
<el-input v-model="form.issuerName" disabled placeholder="从金蝶票据池带出" /> <el-tooltip
:content="form.issuerName"
:disabled="!form.issuerName"
placement="top"
:show-after="200"
>
<div class="receipt-form-page__overflow-trigger">
<el-input v-model="form.issuerName" disabled placeholder="从金蝶票据池带出" />
</div>
</el-tooltip>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="关联结算单" prop="settlementIds"> <el-form-item label="关联结算单" prop="settlementIds">
<el-input :model-value="settlementLabel" readonly placeholder="请选择应付正式结算单"> <el-tooltip
<template v-if="!readonly" #append> :content="settlementLabel"
<el-tooltip content="选择付款结算单" placement="top"> :disabled="!settlementLabel"
<el-button :icon="Search" @click="openSettlementDialog" /> placement="top"
</el-tooltip> :show-after="200"
</template> >
</el-input> <div class="receipt-form-page__overflow-trigger">
<el-input
:model-value="settlementLabel"
readonly
placeholder="请选择应付正式结算单"
>
<template v-if="!readonly" #append>
<el-tooltip content="选择付款结算单" placement="top">
<el-button :icon="Search" @click="openSettlementDialog" />
</el-tooltip>
</template>
</el-input>
</div>
</el-tooltip>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@@ -89,7 +138,12 @@
<section-card title="结算信息"> <section-card title="结算信息">
<el-table :data="form.settlements" border> <el-table :data="form.settlements" border>
<el-table-column type="index" label="序号" width="64" align="center" /> <el-table-column type="index" label="序号" width="64" align="center" />
<el-table-column label="结算单号" min-width="180" align="center"> <el-table-column
label="结算单号"
min-width="180"
align="center"
show-overflow-tooltip
>
<template #default="{ row }"> <template #default="{ row }">
<el-link type="primary" @click="openSettlementDetail(row)"> <el-link type="primary" @click="openSettlementDetail(row)">
{{ row.formalSettlementNo }} {{ row.formalSettlementNo }}
@@ -173,7 +227,7 @@
<el-input <el-input
v-model="settlementDialog.keyword" v-model="settlementDialog.keyword"
clearable clearable
placeholder="3结算单号、项目或合同" placeholder="结算单号、项目或合同"
@keyup.enter="loadSettlementCandidates" @keyup.enter="loadSettlementCandidates"
/> />
<el-button type="primary" @click="loadSettlementCandidates">查询</el-button> <el-button type="primary" @click="loadSettlementCandidates">查询</el-button>
@@ -182,16 +236,32 @@
ref="settlementTable" ref="settlementTable"
v-loading="settlementDialog.loading" v-loading="settlementDialog.loading"
:data="settlementDialog.rows" :data="settlementDialog.rows"
row-key="id"
border border
@selection-change="settlementDialog.selection = $event" @selection-change="settlementDialog.selection = $event"
> >
<el-table-column type="selection" width="52" align="center" /> <el-table-column type="selection" width="52" align="center" reserve-selection />
<el-table-column prop="formalSettlementNo" label="结算单号" min-width="170" /> <el-table-column
<el-table-column prop="projectName" label="所属项目" min-width="150" /> prop="formalSettlementNo"
<el-table-column prop="deptName" label="所属组织" min-width="150" /> label="结算单号"
<el-table-column prop="contractNo" label="合同编号" min-width="150" /> min-width="170"
<el-table-column prop="payerName" label="付款方" min-width="150" /> show-overflow-tooltip
<el-table-column prop="payeeName" label="收款方" min-width="150" /> />
<el-table-column
prop="projectName"
label="所属项目"
min-width="150"
show-overflow-tooltip
/>
<el-table-column prop="deptName" label="所属组织" min-width="150" show-overflow-tooltip />
<el-table-column
prop="contractNo"
label="合同编号"
min-width="150"
show-overflow-tooltip
/>
<el-table-column prop="payerName" label="付款方" min-width="150" show-overflow-tooltip />
<el-table-column prop="payeeName" label="收款方" min-width="150" show-overflow-tooltip />
<el-table-column label="结算总金额" min-width="140" align="right"> <el-table-column label="结算总金额" min-width="140" align="right">
<template #default="{ row }">{{ formatMoney(row.settlementAmount) }}</template> <template #default="{ row }">{{ formatMoney(row.settlementAmount) }}</template>
</el-table-column> </el-table-column>
@@ -206,7 +276,9 @@
</el-table> </el-table>
<template #footer> <template #footer>
<el-button @click="settlementDialog.visible = false">取消</el-button> <el-button @click="settlementDialog.visible = false">取消</el-button>
<el-button type="primary" @click="confirmSettlements">确定</el-button> <el-button type="primary" @click="confirmSettlements">
确定{{ settlementDialog.selection.length ? `(${settlementDialog.selection.length})` : '' }}
</el-button>
</template> </template>
</el-dialog> </el-dialog>
</basic-container> </basic-container>
@@ -437,7 +509,15 @@ export default {
}, },
async openSettlementDialog() { async openSettlementDialog() {
this.settlementDialog.visible = true; this.settlementDialog.visible = true;
this.settlementDialog.selection = [];
await this.loadSettlementCandidates(); await this.loadSettlementCandidates();
await this.$nextTick();
const selectedIds = new Set(this.settlementIds.map(id => String(id)));
this.settlementDialog.rows.forEach(row => {
if (selectedIds.has(String(row.id))) {
this.$refs.settlementTable?.toggleRowSelection(row, true);
}
});
}, },
async loadSettlementCandidates() { async loadSettlementCandidates() {
this.settlementDialog.loading = true; this.settlementDialog.loading = true;
@@ -468,11 +548,21 @@ export default {
this.$message.warning('关联结算单必须属于同一项目、组织及收付款方'); this.$message.warning('关联结算单必须属于同一项目、组织及收付款方');
return; return;
} }
const previousAmount = new Map(
this.form.settlements.map(item => [
String(item.formalSettlementId || item.settlementId),
item.allocatedInvoiceAmount,
])
);
this.form.settlements = rows.map(item => ({ this.form.settlements = rows.map(item => ({
...item, ...item,
formalSettlementId: item.id, formalSettlementId: item.id,
settlementId: item.id, settlementId: item.id,
allocatedInvoiceAmount: rows.length === 1 ? Number(item.settlementAmount || 0) : 0, allocatedInvoiceAmount: previousAmount.has(String(item.id))
? Number(previousAmount.get(String(item.id)) || 0)
: rows.length === 1
? Number(item.settlementAmount || 0)
: 0,
})); }));
this.form.projectName = first.projectName; this.form.projectName = first.projectName;
this.form.deptName = first.deptName; this.form.deptName = first.deptName;
@@ -482,9 +572,8 @@ export default {
await this.loadReferenceInformation(); await this.loadReferenceInformation();
this.$refs.formRef?.validateField('settlementIds').catch(() => {}); this.$refs.formRef?.validateField('settlementIds').catch(() => {});
}, },
async selectSettlement(row) { selectSettlement(row) {
this.settlementDialog.selection = [row]; this.$refs.settlementTable?.toggleRowSelection(row);
await this.confirmSettlements();
}, },
async loadReferenceInformation() { async loadReferenceInformation() {
const data = this.unwrapData(await api.getReferenceInformation(this.settlementIds.join(','))); const data = this.unwrapData(await api.getReferenceInformation(this.settlementIds.join(',')));
@@ -617,6 +706,15 @@ export default {
.receipt-form-page__form :deep(.el-input-number) { .receipt-form-page__form :deep(.el-input-number) {
width: 100%; width: 100%;
} }
.receipt-form-page__overflow-trigger {
display: block;
width: 100%;
min-width: 0;
}
.receipt-form-page__form :deep(.el-tooltip__trigger:not(.el-select__wrapper)) {
display: block;
width: 100%;
}
.receipt-form-page__remark :deep(.el-form-item__content) { .receipt-form-page__remark :deep(.el-form-item__content) {
margin-left: 0 !important; margin-left: 0 !important;
} }
+193 -64
View File
@@ -121,7 +121,7 @@
><div class="payment-form-page__percentage-input"> ><div class="payment-form-page__percentage-input">
<el-input-number <el-input-number
v-model="form.paymentRatio" v-model="form.paymentRatio"
:disabled="readonly || multipleSettlementRows" :disabled="readonly"
:min="0" :min="0"
:max="100" :max="100"
:precision="2" :precision="2"
@@ -134,7 +134,7 @@
><el-form-item label="申请付款金额" prop="appliedAmount" ><el-form-item label="申请付款金额" prop="appliedAmount"
><el-input-number ><el-input-number
v-model="form.appliedAmount" v-model="form.appliedAmount"
:disabled="readonly || multipleSettlementRows" :disabled="readonly"
:min="0" :min="0"
:precision="2" :precision="2"
:step="0.01" :step="0.01"
@@ -852,6 +852,8 @@ export default {
billOptions: [], billOptions: [],
billLoading: false, billLoading: false,
billDialogVisible: false, billDialogVisible: false,
settlementPayerName: '',
settlementPayeeName: '',
billQuery: { billQuery: {
keyword: '', keyword: '',
}, },
@@ -1022,8 +1024,12 @@ export default {
}, },
settlementRows() { settlementRows() {
if (this.referenceRows.length > 1) { if (this.referenceRows.length > 1) {
// 多结算单:行内比例/金额独立维护,不回落到表头比例(表头与结算信息不关联)
return this.referenceRows.map(item => { return this.referenceRows.map(item => {
const paymentRatio = item.paymentRatio ?? this.form.paymentRatio; const paymentRatio =
item.paymentRatio === undefined || item.paymentRatio === null || item.paymentRatio === ''
? 0
: Number(item.paymentRatio);
const appliedAmount = Number(item.appliedAmount || 0); const appliedAmount = Number(item.appliedAmount || 0);
return { return {
...item, ...item,
@@ -1096,7 +1102,8 @@ export default {
}, },
'form.paymentRatio'(value) { 'form.paymentRatio'(value) {
this.checkContractPaymentRatio(value); this.checkContractPaymentRatio(value);
if (this.amountSyncing || this.multipleSettlementRows || !this.paymentAmountBase) return; // 上方比例仅用于反算申请付款金额,不联动结算信息列表
if (this.amountSyncing || !this.paymentAmountBase) return;
this.amountSyncing = true; this.amountSyncing = true;
this.form.appliedAmount = Number( this.form.appliedAmount = Number(
((this.paymentAmountBase * Number(value || 0)) / 100).toFixed(2) ((this.paymentAmountBase * Number(value || 0)) / 100).toFixed(2)
@@ -1106,7 +1113,8 @@ export default {
}); });
}, },
'form.appliedAmount'(value) { 'form.appliedAmount'(value) {
if (this.amountSyncing || this.multipleSettlementRows || !this.paymentAmountBase) return; // 上方申请付款金额反算比例,不联动结算信息列表
if (this.amountSyncing || !this.paymentAmountBase) return;
this.amountSyncing = true; this.amountSyncing = true;
this.form.paymentRatio = Number( this.form.paymentRatio = Number(
((Number(value || 0) / this.paymentAmountBase) * 100).toFixed(2) ((Number(value || 0) / this.paymentAmountBase) * 100).toFixed(2)
@@ -1119,11 +1127,11 @@ export default {
if ( if (
this.amountSyncing || this.amountSyncing ||
this.form.paymentType === 'project_advance' || this.form.paymentType === 'project_advance' ||
this.multipleSettlementRows ||
!this.paymentAmountBase !this.paymentAmountBase
) { ) {
return; return;
} }
// 结算金额变化时按上方比例重算申请付款金额,仍不联动结算信息明细
this.amountSyncing = true; this.amountSyncing = true;
this.form.appliedAmount = Number( this.form.appliedAmount = Number(
((this.paymentAmountBase * Number(this.form.paymentRatio || 0)) / 100).toFixed(2) ((this.paymentAmountBase * Number(this.form.paymentRatio || 0)) / 100).toFixed(2)
@@ -1221,8 +1229,12 @@ export default {
callback(); callback();
return; return;
} }
if (selected.billType && selected.billType !== 'received') { if (
callback(new Error('汇票付款仅可选择收票类型的汇票')); selected.billType &&
selected.billType !== 'received' &&
!this.billMatchesSettlementParties(selected)
) {
callback(new Error('汇票付款仅可选择收票类型,或出票单位与收票单位均为当前结算收付款方的汇票'));
return; return;
} }
if (selected.maturityDate) { if (selected.maturityDate) {
@@ -1541,13 +1553,27 @@ export default {
(total, item) => total + Number(item.payableAmount || 0), (total, item) => total + Number(item.payableAmount || 0),
0 0
); );
const appliedAmount = referenceRows.reduce( const multiple = referenceRows.length > 1;
// 多结算单:表头比例/申请金额独立;单结算单:沿用行金额或按比例计算
const paymentRatio = Number(this.form.paymentRatio || 0);
const rowsAppliedTotal = referenceRows.reduce(
(total, item) => total + Number(item.appliedAmount || 0), (total, item) => total + Number(item.appliedAmount || 0),
0 0
); );
const paymentRatio = settlementAmount const headerAppliedAmount = multiple
? Number(((appliedAmount / settlementAmount) * 100).toFixed(2)) ? Number(((settlementAmount * paymentRatio) / 100).toFixed(2))
: 0; : Number(
(
rowsAppliedTotal > 0
? rowsAppliedTotal
: (payableAmount * paymentRatio) / 100
).toFixed(2)
);
const headerPaymentRatio = multiple
? paymentRatio
: settlementAmount
? Number(((headerAppliedAmount / settlementAmount) * 100).toFixed(2))
: paymentRatio;
const settlementIds = rows.map(item => item.settlementId || item.id).filter(Boolean); const settlementIds = rows.map(item => item.settlementId || item.id).filter(Boolean);
this.amountSyncing = true; this.amountSyncing = true;
this.referenceRows = referenceRows; this.referenceRows = referenceRows;
@@ -1574,12 +1600,13 @@ export default {
settlementAmount: Number(settlementAmount.toFixed(2)), settlementAmount: Number(settlementAmount.toFixed(2)),
payableAmount: Number(payableAmount.toFixed(2)), payableAmount: Number(payableAmount.toFixed(2)),
billType: '', billType: '',
paymentRatio, paymentRatio: headerPaymentRatio,
appliedAmount: Number(appliedAmount.toFixed(2)), appliedAmount: headerAppliedAmount,
invoices: rows.flatMap(item => invoices: rows.flatMap(item =>
this.createInvoiceRows(item.invoices || [], item.formalSettlementNo || item.settlementNo) this.createInvoiceRows(item.invoices || [], item.formalSettlementNo || item.settlementNo)
), ),
}); });
this.rememberSettlementParties(first.payerName, first.payeeName);
this.paymentRecords = rows.flatMap(item => this.paymentRecords = rows.flatMap(item =>
(item.paymentRecords || item.paymentApplications || []).map(record => ({ (item.paymentRecords || item.paymentApplications || []).map(record => ({
...record, ...record,
@@ -1667,7 +1694,11 @@ export default {
? 0 ? 0
: Number(row.payableAmount || 0); : Number(row.payableAmount || 0);
return { return {
id: row.preSettlementId || (isPre ? row.settlementId : null) || row.settlementId || row.id, id:
row.preSettlementId ||
(isPre ? row.settlementId : null) ||
row.settlementId ||
(row.paymentNo ? null : row.id),
settlementNo: row.preSettlementNo || row.formalSettlementNo || row.settlementNo || '', settlementNo: row.preSettlementNo || row.formalSettlementNo || row.settlementNo || '',
referenceType: isPre ? 'pre' : 'formal', referenceType: isPre ? 'pre' : 'formal',
settlementAmount: Number(Number(settlementAmount || 0).toFixed(2)), settlementAmount: Number(Number(settlementAmount || 0).toFixed(2)),
@@ -1827,19 +1858,21 @@ export default {
(total, item) => total + Number(item.payableAmount || 0), (total, item) => total + Number(item.payableAmount || 0),
0 0
); );
const appliedAmount = this.referenceRows.reduce( const multiple = this.referenceRows.length > 1;
const paymentRatio = Number(this.form.paymentRatio || 0);
const rowsAppliedTotal = this.referenceRows.reduce(
(total, item) => total + Number(item.appliedAmount || 0), (total, item) => total + Number(item.appliedAmount || 0),
0 0
); );
const multiple = this.referenceRows.length > 1; // 多结算单:表头申请金额只由上方比例计算;单结算单仍按可付款金额×比例
const paymentRatio = multiple
? settlementAmount
? Number(((appliedAmount / settlementAmount) * 100).toFixed(2))
: 0
: Number(this.form.paymentRatio || 0);
const headerAppliedAmount = multiple const headerAppliedAmount = multiple
? Number(appliedAmount.toFixed(2)) ? Number(((settlementAmount * paymentRatio) / 100).toFixed(2))
: Number(((payableAmount * paymentRatio) / 100).toFixed(2)); : Number(((payableAmount * paymentRatio) / 100).toFixed(2));
const headerPaymentRatio = multiple
? paymentRatio
: settlementAmount && rowsAppliedTotal > 0
? Number(((rowsAppliedTotal / settlementAmount) * 100).toFixed(2))
: paymentRatio;
// 尾款付款场景下选择预付结算单时保留尾款付款类型,不强制改为进度预付 // 尾款付款场景下选择预付结算单时保留尾款付款类型,不强制改为进度预付
this.amountSyncing = true; this.amountSyncing = true;
Object.assign(this.form, { Object.assign(this.form, {
@@ -1865,9 +1898,10 @@ export default {
settlementAmount: Number(settlementAmount.toFixed(2)), settlementAmount: Number(settlementAmount.toFixed(2)),
payableAmount: Number(payableAmount.toFixed(2)), payableAmount: Number(payableAmount.toFixed(2)),
billType: '', billType: '',
paymentRatio, paymentRatio: headerPaymentRatio,
appliedAmount: headerAppliedAmount, appliedAmount: headerAppliedAmount,
}); });
this.rememberSettlementParties(first.payerName, first.payeeName);
this.paymentRecords = []; this.paymentRecords = [];
this.clearReceiptAccount(); this.clearReceiptAccount();
await this.fillBillTypeFromContract(first.contractId, true); await this.fillBillTypeFromContract(first.contractId, true);
@@ -2063,12 +2097,31 @@ export default {
}, },
resolveAttachmentMaterial(file, materials = Object.values(ATTACHMENT_MATERIALS)) { resolveAttachmentMaterial(file, materials = Object.values(ATTACHMENT_MATERIALS)) {
if (!this.attachmentFileUrl(file)) return null; if (!this.attachmentFileUrl(file)) return null;
const typeMatched = (materials || []).find( const typeText = String(file.attachmentType || file.type || '')
material => file.attachmentType === MATERIAL_TYPE_MAP[material.key] .trim()
); .toLocaleLowerCase();
const typeMatched = (materials || []).find(material => {
if (file.attachmentType === MATERIAL_TYPE_MAP[material.key]) return true;
if (!typeText) return false;
const label = String(material.label || '').toLocaleLowerCase();
return (
typeText === label ||
material.keywords.some(keyword => {
const normalizedKeyword = String(keyword).toLocaleLowerCase();
return normalizedKeyword && typeText.includes(normalizedKeyword);
})
);
});
return typeMatched || this.matchAttachmentMaterialByFileName(file, materials); return typeMatched || this.matchAttachmentMaterialByFileName(file, materials);
}, },
mergeAutomaticAttachments(files, materials, sourceName, defaultMaterial = null, sourceKey = '') { mergeAutomaticAttachments(
files,
materials,
sourceName,
defaultMaterial = null,
sourceKey = '',
keepUnmatched = false
) {
const existingUrls = new Set( const existingUrls = new Set(
(this.form.attachments || []).map(file => this.attachmentFileUrl(file)).filter(Boolean) (this.form.attachments || []).map(file => this.attachmentFileUrl(file)).filter(Boolean)
); );
@@ -2077,16 +2130,20 @@ export default {
file, file,
material: this.resolveAttachmentMaterial(file, materials) || defaultMaterial, material: this.resolveAttachmentMaterial(file, materials) || defaultMaterial,
})) }))
.filter(item => item.material && !existingUrls.has(this.attachmentFileUrl(item.file))) .filter(item => {
const url = this.attachmentFileUrl(item.file);
return Boolean(url) && !existingUrls.has(url) && (item.material || keepUnmatched);
})
.map(({ file, material }) => { .map(({ file, material }) => {
existingUrls.add(this.attachmentFileUrl(file)); const url = this.attachmentFileUrl(file);
existingUrls.add(url);
return { return {
...file, ...file,
originalName: this.attachmentFileName(file), originalName: this.attachmentFileName(file),
name: this.attachmentFileName(file), name: this.attachmentFileName(file),
url: this.attachmentFileUrl(file), url,
link: file.link || this.attachmentFileUrl(file), link: file.link || url,
attachmentType: MATERIAL_TYPE_MAP[material.key], attachmentType: material ? MATERIAL_TYPE_MAP[material.key] : 'other',
description: file.description || `自动取自${sourceName}`, description: file.description || `自动取自${sourceName}`,
sourceImported: true, sourceImported: true,
sourceKey: sourceKey || undefined, sourceKey: sourceKey || undefined,
@@ -2119,11 +2176,7 @@ export default {
}, },
/** 按当前结算单附件整批同步:先清旧关联,再写入新结算单上传的附件 */ /** 按当前结算单附件整批同步:先清旧关联,再写入新结算单上传的附件 */
syncSettlementAttachments(settlementRows = []) { syncSettlementAttachments(settlementRows = []) {
const settlementMaterials = [ const settlementMaterials = Object.values(ATTACHMENT_MATERIALS);
ATTACHMENT_MATERIALS.weighingSlip,
ATTACHMENT_MATERIALS.entrustOrder,
ATTACHMENT_MATERIALS.settlement,
];
const settlementFiles = (settlementRows || []).flatMap(row => this.parse(row.attachmentsJson)); const settlementFiles = (settlementRows || []).flatMap(row => this.parse(row.attachmentsJson));
const nextUrlSet = new Set( const nextUrlSet = new Set(
settlementFiles.map(file => this.attachmentFileUrl(file)).filter(Boolean) settlementFiles.map(file => this.attachmentFileUrl(file)).filter(Boolean)
@@ -2140,7 +2193,8 @@ export default {
settlementMaterials, settlementMaterials,
'结算单', '结算单',
null, null,
'settlement' 'settlement',
true
); );
this.linkedSettlementAttachmentUrls = imported this.linkedSettlementAttachmentUrls = imported
.map(file => this.attachmentFileUrl(file)) .map(file => this.attachmentFileUrl(file))
@@ -2547,7 +2601,13 @@ export default {
try { try {
this.billOptions = this.billOptions =
this.unwrapData( this.unwrapData(
await billLedgerApi.getAvailableOptions(keyword, this.form.deptId, selectedId) await billLedgerApi.getAvailableOptions(
keyword,
this.form.deptId,
selectedId,
this.settlementPayerName,
this.settlementPayeeName
)
) || []; ) || [];
} finally { } finally {
this.billLoading = false; this.billLoading = false;
@@ -2569,7 +2629,9 @@ export default {
this.billPage.size, this.billPage.size,
String(this.billQuery.keyword || '').trim() || undefined, String(this.billQuery.keyword || '').trim() || undefined,
this.form.deptId, this.form.deptId,
this.form.billLedgerId this.form.billLedgerId,
this.settlementPayerName,
this.settlementPayeeName
); );
const data = this.unwrapData(response) || {}; const data = this.unwrapData(response) || {};
this.billRows = data.records || []; this.billRows = data.records || [];
@@ -2590,9 +2652,27 @@ export default {
this.billPage.current = 1; this.billPage.current = 1;
this.loadBillPage(); this.loadBillPage();
}, },
rememberSettlementParties(payerName, payeeName) {
this.settlementPayerName = String(payerName || '').trim();
this.settlementPayeeName = String(payeeName || '').trim();
},
billMatchesSettlementParties(row) {
const issuer = String(row?.issuerName || '').trim();
const receiver = String(row?.receiverName || '').trim();
const payer = this.settlementPayerName;
const payee = this.settlementPayeeName;
if (!issuer || !receiver || !payer || !payee) return false;
return (
(issuer === payer && receiver === payee) || (issuer === payee && receiver === payer)
);
},
selectBill(row) { selectBill(row) {
if (row?.billType && row.billType !== 'received') { if (
ElMessage.warning('汇票付款仅可选择收票类型的汇票'); row?.billType &&
row.billType !== 'received' &&
!this.billMatchesSettlementParties(row)
) {
ElMessage.warning('汇票付款仅可选择收票类型,或出票单位与收票单位均为当前结算收付款方的汇票');
return; return;
} }
if (row?.maturityDate) { if (row?.maturityDate) {
@@ -2848,6 +2928,7 @@ export default {
payerName: row.payerName, payerName: row.payerName,
payeeName: '', payeeName: '',
}); });
this.rememberSettlementParties(row.payerName, row.payeeName);
this.referenceVisible = false; this.referenceVisible = false;
this.refreshReferenceValidation(); this.refreshReferenceValidation();
const detail = this.unwrapData(detailResponse); const detail = this.unwrapData(detailResponse);
@@ -2930,6 +3011,7 @@ export default {
payerName: row.payerName, payerName: row.payerName,
payeeName: '', payeeName: '',
}); });
this.rememberSettlementParties(row.payerName, row.payeeName);
this.referenceVisible = false; this.referenceVisible = false;
this.refreshReferenceValidation(); this.refreshReferenceValidation();
const detail = this.unwrapData(detailResponse); const detail = this.unwrapData(detailResponse);
@@ -3014,19 +3096,16 @@ export default {
if (settlementAmount <= 0) return 100; if (settlementAmount <= 0) return 100;
return Number(Math.min(100, (payableAmount / settlementAmount) * 100).toFixed(2)); return Number(Math.min(100, (payableAmount / settlementAmount) * 100).toFixed(2));
}, },
/**
* 多结算单行金额规范化:仅在行内反算比例,不使用表头比例灌入(表头与结算信息不关联)。
*/
seedMultipleRowPayments(rows = []) { seedMultipleRowPayments(rows = []) {
if (rows.length <= 1) return; if (rows.length <= 1) return;
const ratio = Number(this.form.paymentRatio || 0);
rows.forEach(item => { rows.forEach(item => {
const settlementAmount = Number(item.settlementAmount || 0); const settlementAmount = Number(item.settlementAmount || 0);
const payableAmount = Number(item.payableAmount || 0); const payableAmount = Number(item.payableAmount || 0);
const hasRatio =
item.paymentRatio !== null && item.paymentRatio !== undefined && item.paymentRatio !== '';
if (hasRatio) return;
let applied = Number(item.appliedAmount || 0); let applied = Number(item.appliedAmount || 0);
if (applied <= 0 && ratio > 0) { if (!Number.isFinite(applied) || applied < 0) applied = 0;
applied = Number(((settlementAmount * ratio) / 100).toFixed(2));
}
if (applied > payableAmount) applied = Number(payableAmount.toFixed(2)); if (applied > payableAmount) applied = Number(payableAmount.toFixed(2));
item.appliedAmount = Number(applied.toFixed(2)); item.appliedAmount = Number(applied.toFixed(2));
item.paymentRatio = settlementAmount item.paymentRatio = settlementAmount
@@ -3042,6 +3121,25 @@ export default {
item.settlementNo === row.settlementNo item.settlementNo === row.settlementNo
); );
}, },
/** 结算信息付款金额合计 */
settlementRowsAppliedTotal(rows = this.referenceRows) {
return (rows || []).reduce((total, item) => total + Number(item.appliedAmount || 0), 0);
},
/** 结算信息合计不得超过上方申请付款金额 */
ensureSettlementAppliedWithinHeader(showWarning = true) {
if (!this.multipleSettlementRows) return true;
const headerApplied = Number(this.form.appliedAmount || 0);
const rowsTotal = Number(this.settlementRowsAppliedTotal().toFixed(2));
if (rowsTotal - headerApplied > 1e-8) {
if (showWarning) {
this.$message.warning(
`结算信息付款金额合计(${rowsTotal.toFixed(2)})不能大于申请付款金额(${headerApplied.toFixed(2)})`
);
}
return false;
}
return true;
},
handleRowPaymentRatioChange(row, value) { handleRowPaymentRatioChange(row, value) {
const target = this.findReferenceRow(row); const target = this.findReferenceRow(row);
if (!target) return; if (!target) return;
@@ -3054,7 +3152,9 @@ export default {
target.paymentRatio = settlementAmount target.paymentRatio = settlementAmount
? Number(((applied / settlementAmount) * 100).toFixed(2)) ? Number(((applied / settlementAmount) * 100).toFixed(2))
: Number(ratio.toFixed(2)); : Number(ratio.toFixed(2));
this.syncHeaderPaymentFromRows(); // 仅刷新结算金额/可付款金额合计,不回写表头申请金额与比例
this.syncHeaderSettlementTotalsFromRows();
this.ensureSettlementAppliedWithinHeader(true);
}, },
handleRowAppliedAmountChange(row, value) { handleRowAppliedAmountChange(row, value) {
const target = this.findReferenceRow(row); const target = this.findReferenceRow(row);
@@ -3068,9 +3168,11 @@ export default {
target.paymentRatio = settlementAmount target.paymentRatio = settlementAmount
? Number(((target.appliedAmount / settlementAmount) * 100).toFixed(2)) ? Number(((target.appliedAmount / settlementAmount) * 100).toFixed(2))
: 0; : 0;
this.syncHeaderPaymentFromRows(); this.syncHeaderSettlementTotalsFromRows();
this.ensureSettlementAppliedWithinHeader(true);
}, },
syncHeaderPaymentFromRows() { /** 多结算单时仅同步结算金额/可付款金额合计,申请付款金额与比例由上方独立维护 */
syncHeaderSettlementTotalsFromRows() {
if (this.referenceRows.length <= 1) return; if (this.referenceRows.length <= 1) return;
const settlementAmount = this.referenceRows.reduce( const settlementAmount = this.referenceRows.reduce(
(total, item) => total + Number(item.settlementAmount || 0), (total, item) => total + Number(item.settlementAmount || 0),
@@ -3080,23 +3182,21 @@ export default {
(total, item) => total + Number(item.payableAmount || 0), (total, item) => total + Number(item.payableAmount || 0),
0 0
); );
const appliedAmount = this.referenceRows.reduce(
(total, item) => total + Number(item.appliedAmount || 0),
0
);
this.amountSyncing = true; this.amountSyncing = true;
this.form.settlementAmount = Number(settlementAmount.toFixed(2)); this.form.settlementAmount = Number(settlementAmount.toFixed(2));
this.form.payableAmount = Number(payableAmount.toFixed(2)); this.form.payableAmount = Number(payableAmount.toFixed(2));
this.form.appliedAmount = Number(appliedAmount.toFixed(2));
this.form.paymentRatio = settlementAmount
? Number(((appliedAmount / settlementAmount) * 100).toFixed(2))
: 0;
this.$nextTick(() => { this.$nextTick(() => {
this.amountSyncing = false; this.amountSyncing = false;
this.$refs.formRef?.validateField?.(['settlementAmount', 'paymentRatio', 'appliedAmount']); this.$refs.formRef?.validateField?.(['settlementAmount', 'appliedAmount']);
}); });
}, },
/** @deprecated 兼容旧调用名,行为见 syncHeaderSettlementTotalsFromRows */
syncHeaderPaymentFromRows() {
this.syncHeaderSettlementTotalsFromRows();
},
payload() { payload() {
// 驳回重提前再清一次:避免历史误存的正式结算单 ID 盖过预结算引用
this.clearFormalReferenceWhenPreOnly();
const { const {
id, id,
paymentType, paymentType,
@@ -3133,13 +3233,34 @@ export default {
paymentType === 'progress_advance' || paymentType === 'progress_advance' ||
(this.referenceRows.length > 0 && (this.referenceRows.length > 0 &&
this.referenceRows.every(item => item.referenceType === 'pre')); this.referenceRows.every(item => item.referenceType === 'pre'));
// 进度预付 / 仅预结算引用:强制不传正式结算单 ID,并兜底恢复预结算单 ID
const resolvedPreSettlementId =
preSettlementId ||
preSettlementIds?.[0] ||
(usePreSettlementOnly ? settlementId : null) ||
null;
const resolvedPreSettlementIds =
preSettlementIds?.length > 0
? preSettlementIds
: resolvedPreSettlementId
? [resolvedPreSettlementId]
: [];
const preSettlementNo = usePreSettlementOnly
? this.form.preSettlementNo ||
(this.referenceRows || [])
.filter(item => item.referenceType === 'pre')
.map(item => item.settlementNo)
.filter(Boolean)
.join('、')
: this.form.preSettlementNo;
return { return {
id, id,
paymentType, paymentType,
settlementId: usePreSettlementOnly ? null : settlementId, settlementId: usePreSettlementOnly ? null : settlementId,
settlementIds: usePreSettlementOnly ? [] : settlementIds, settlementIds: usePreSettlementOnly ? [] : settlementIds,
preSettlementId, preSettlementId: usePreSettlementOnly ? resolvedPreSettlementId : preSettlementId,
preSettlementIds, preSettlementIds: usePreSettlementOnly ? resolvedPreSettlementIds : preSettlementIds,
preSettlementNo,
projectId, projectId,
projectName, projectName,
deptId, deptId,
@@ -3228,6 +3349,14 @@ export default {
ElMessage.warning(`${invalidRow.settlementNo || '结算单'}付款金额不能超过可付款金额`); ElMessage.warning(`${invalidRow.settlementNo || '结算单'}付款金额不能超过可付款金额`);
return false; return false;
} }
const rowsTotal = Number(this.settlementRowsAppliedTotal().toFixed(2));
if (rowsTotal - appliedAmount > 1e-8) {
this.clearMessages();
ElMessage.warning(
`结算信息付款金额合计(${rowsTotal.toFixed(2)})不能大于申请付款金额(${appliedAmount.toFixed(2)})`
);
return false;
}
} }
if (this.form.paymentType === 'project_advance' && !this.form.projectId) { if (this.form.paymentType === 'project_advance' && !this.form.projectId) {
this.clearMessages(); this.clearMessages();
@@ -302,7 +302,10 @@ export default {
); );
}, },
flowRemaining(flow) { 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) { maxAllocation(row) {
const current = Number(row.settlement.allocations?.[row.flow.id] || 0); const current = Number(row.settlement.allocations?.[row.flow.id] || 0);
+15 -7
View File
@@ -252,10 +252,11 @@ export default {
); );
}, },
claimableAmount() { claimableAmount() {
return Math.max( const unclaimed = Number(this.form.unclaimedAmount || 0);
Number(this.form.unclaimedAmount || 0) - Number(this.form.claimedAmount || 0), const receipt = Number(this.form.receiptAmount || 0);
0 const ceiling =
); unclaimed > 0 && receipt > 0 ? Math.min(unclaimed, receipt) : unclaimed || receipt;
return Math.max(ceiling - Number(this.form.claimedAmount || 0), 0);
}, },
}, },
created() { created() {
@@ -274,14 +275,21 @@ export default {
} }
const data = this.unwrapData(await api.getDetail(this.flowId)); const data = this.unwrapData(await api.getDetail(this.flowId));
const userInfo = this.$store.getters.userInfo || {}; const userInfo = this.$store.getters.userInfo || {};
// 部分认领继续认领:预填本流水历史关联且仍有剩余可认领金额的结算单
const relatedSettlements = (data?.relatedSettlements || []).map(item => ({
...item,
formalSettlementId: item.id,
settlementId: item.id,
allocatedReceiptAmount: 0,
}));
this.form = { this.form = {
...emptyForm(), ...emptyForm(),
...data, ...data,
claimerName: userInfo.realName || userInfo.userName || data.claimerName || '', claimerName: userInfo.realName || userInfo.userName || data.claimerName || '',
claimerDeptName: userInfo.deptName || userInfo.dept_name || data.claimerDeptName || '', claimerDeptName: userInfo.deptName || userInfo.dept_name || data.claimerDeptName || '',
claimDate: this.$dayjs().format('YYYY-MM-DD'), claimDate: this.$dayjs().format('YYYY-MM-DD'),
settlementIds: [], settlementIds: relatedSettlements.map(item => item.formalSettlementId),
settlements: [], settlements: relatedSettlements,
attachments: [], attachments: [],
}; };
}, },
@@ -347,7 +355,7 @@ export default {
return; return;
} }
if (this.allocatedTotal > this.claimableAmount + 0.001) { if (this.allocatedTotal > this.claimableAmount + 0.001) {
this.$message.warning('累计认领金额不能超过公告未认领金额(剩余可认领金额)'); this.$message.warning('累计认领金额不能超过剩余可认领金额');
return; return;
} }
for (const row of this.form.settlements) for (const row of this.form.settlements)
@@ -53,7 +53,7 @@
<el-option <el-option
v-for="item in contracts" v-for="item in contracts"
:key="item.id" :key="item.id"
:label="formatContractOptionLabel(item)" :label="item.contractName || ''"
:value="item.id" :value="item.id"
/> />
</el-select> </el-select>
@@ -1070,7 +1070,6 @@ import {
import { getDictionary } from '@/api/system/dictbiz'; import { getDictionary } from '@/api/system/dictbiz';
import { h } from 'vue'; import { h } from 'vue';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { formatContractOptionLabel } from '@/utils/contract';
import { isTierUnitPrice, isUnitPriceAdjustable } from '@/utils/settlement-adjust-rule'; import { isTierUnitPrice, isUnitPriceAdjustable } from '@/utils/settlement-adjust-rule';
import { normalizeCurrencyCode } from '@/utils/currency'; import { normalizeCurrencyCode } from '@/utils/currency';
import { import {
@@ -1389,7 +1388,6 @@ export default {
methods: { methods: {
isTierUnitPrice, isTierUnitPrice,
isUnitPriceAdjustable, isUnitPriceAdjustable,
formatContractOptionLabel,
hasPermission(code) { hasPermission(code) {
if (this.isAdmin) return true; if (this.isAdmin) return true;
const action = String(code || '').replace( const action = String(code || '').replace(
@@ -1,155 +1,100 @@
<template> <template>
<div class="fs-table-panel"> <avue-crud
<div class="fs-table-panel__toolbar"> ref="crud"
<div> :option="option"
<el-button :table-loading="loading"
v-if="hasPermission('add')" :data="rows"
type="primary" v-model:page="crudPage"
@click="$emit('create')" @search-change="(params, done) => $emit('search-change', params, done)"
>新增</el-button @search-reset="$emit('search-reset')"
> @selection-change="handleSelectionChange"
<el-button @refresh-change="$emit('refresh')"
v-if="showPaymentAction && hasPermission('payment')" @on-load="page => $emit('load', page)"
type="primary" >
plain <template #menu-left>
:disabled="!selection.length" <el-button v-if="hasPermission('add')" type="primary" @click="$emit('create')"
@click="$emit('payment')" >新增</el-button
>付款申请</el-button
>
<el-button
v-if="hasPermission('sync')"
type="primary"
plain
:disabled="!selection.length"
:loading="syncLoading"
@click="$emit('sync')"
>同步金蝶</el-button
>
<el-button
v-if="hasPermission('print')"
type="primary"
plain
@click="emitSingle('print')"
>打印结算单</el-button
>
<el-button
v-if="hasPermission('export')"
type="primary"
plain
@click="$emit('export')"
>导出</el-button
>
</div>
<settlement-table-tools
:columns="columnSettingOptions"
v-model:visible-column-keys="visibleColumnKeys"
v-model:table-size="tableSize"
:search-visible="searchVisible"
@update:search-visible="$emit('update:searchVisible', $event)"
@refresh="$emit('refresh')"
/>
</div>
<el-table
ref="tableRef"
v-loading="loading"
:data="rows"
:size="tableSize"
border
highlight-current-row
@current-change="handleCurrentChange"
@selection-change="handleSelectionChange"
>
<el-table-column type="index" label="序号" width="64" fixed="left" align="center" />
<el-table-column type="selection" width="52" fixed="left" align="center" />
<el-table-column
v-for="column in visibleColumns"
:key="column.prop"
v-bind="column"
align="center"
show-overflow-tooltip
> >
<template #default="{ row }"> <el-button
<el-link v-if="showPaymentAction && hasPermission('payment')"
v-if="column.link && row[column.prop]" type="primary"
type="primary" plain
@click="emitAction('view', row)" :disabled="!selection.length"
>{{ row[column.prop] }}</el-link @click="$emit('payment')"
> >付款申请</el-button
<el-tag >
v-else-if="column.status" <el-button
:type="statusType(row.approvalStatus)" v-if="hasPermission('sync')"
class="status-text" type="primary"
>{{ displayValue(row[column.prop]) }}</el-tag plain
> :disabled="!selection.length"
<span v-else-if="column.money">{{ formatMoney(row[column.prop], row.currency) }}</span> :loading="syncLoading"
<span @click="$emit('sync')"
v-else-if="column.prop === 'invoiceStatusName'" >同步金蝶</el-button
:class="['fs-table-panel__invoice-status', `is-${row.invoiceStatus || 'unreceived'}`]" >
>{{ invoiceName(row.invoiceStatus, row.settlementType) }}</span> <el-button v-if="hasPermission('print')" type="primary" plain @click="emitSingle('print')"
<span v-else-if="column.prop === 'paymentStatusName'">{{ >打印结算单</el-button
paymentName(row.paymentStatus) >
}}</span> <el-button v-if="hasPermission('export')" type="primary" plain @click="$emit('export')"
<span v-else-if="column.prop === 'kingdeeSyncStatus'">{{ >导出</el-button
kingdeeSyncName(row.kingdeeSyncStatus) >
}}</span> </template>
<span v-else-if="column.prop === 'adjustFlag'">{{ adjustFlag(row) }}</span>
<template v-else-if="column.prop === 'kingdeeLockStatus'"> <template #formalSettlementNo="{ row }">
<el-tooltip v-if="lockTag(row).show" :content="lockTag(row).tip" placement="top"> <el-link type="primary" @click="emitAction('view', row)">{{
<el-tag :type="lockTag(row).type" class="status-text">{{ lockTag(row).label }}</el-tag> row.formalSettlementNo || '-'
</el-tooltip> }}</el-link>
<span v-else>-</span> </template>
</template>
<span v-else>{{ displayValue(row[column.prop]) }}</span> <template #invoiceStatusName="{ row }">
</template> <span :class="['fs-invoice-status', `is-${row.invoiceStatus || 'unreceived'}`]">{{
</el-table-column> invoiceName(row.invoiceStatus, row.settlementType)
<el-table-column label="操作" width="320" fixed="right" align="center"> }}</span>
<template #default="{ row }" </template>
><div class="fs-table-panel__links">
<el-link <template #paymentStatusName="{ row }">{{ paymentName(row.paymentStatus) }}</template>
v-for="action in rowActions(row)"
:key="action.type" <template #approvalStatusName="{ row }">
:type="action.danger ? 'danger' : 'primary'" <el-tag :type="statusType(row.approvalStatus)" class="status-text">{{
@click="emitAction(action.type, row)" row.approvalStatusName || '-'
>{{ action.label }}</el-link }}</el-tag>
> </template>
</div></template
> <template #kingdeeSyncStatus="{ row }">{{ kingdeeSyncName(row.kingdeeSyncStatus) }}</template>
</el-table-column>
</el-table> <template #kingdeeLockStatus="{ row }">
<div class="fs-table-panel__pagination"> <el-tooltip v-if="lockTag(row).show" :content="lockTag(row).tip" placement="top">
<el-pagination <el-tag :type="lockTag(row).type" class="status-text">{{ lockTag(row).label }}</el-tag>
:current-page="page.current" </el-tooltip>
:page-size="page.size" <span v-else>-</span>
:total="page.total" </template>
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper" <template #menu="{ row }">
@current-change="current => $emit('page-change', { current, size: page.size })" <el-link
@size-change="size => $emit('page-change', { current: 1, size })" v-for="action in rowActions(row)"
/> :key="action.type"
</div> :type="action.danger ? 'danger' : 'primary'"
</div> @click="emitAction(action.type, row)"
>{{ action.label }}</el-link
>
</template>
</avue-crud>
</template> </template>
<script> <script>
import { import { invoiceStatusName } from '@/option/settlement/formalSettlementSearch';
invoiceStatusName, import { kingdeeSyncName, paymentStatusName } from '@/option/settlement/formalSettlement';
kingdeeSyncStatusOptions,
paymentStatusOptions,
} from '@/option/settlement/formalSettlementSearch';
import SettlementTableTools from './settlement-table-tools.vue';
export default { export default {
name: 'FormalSettlementTablePanel', name: 'FormalSettlementTablePanel',
components: { SettlementTableTools },
props: { props: {
option: { type: Object, required: true },
rows: { type: Array, default: () => [] }, rows: { type: Array, default: () => [] },
columns: { type: Array, default: () => [] },
loading: { type: Boolean, default: false }, loading: { type: Boolean, default: false },
syncLoading: { type: Boolean, default: false }, syncLoading: { type: Boolean, default: false },
page: { type: Object, required: true }, page: { type: Object, required: true },
hasPermission: { type: Function, required: true }, hasPermission: { type: Function, required: true },
mkEnabled: { type: Boolean, default: false }, mkEnabled: { type: Boolean, default: false },
searchVisible: { type: Boolean, default: true },
/** 是否展示付款申请按钮(仅付款结算单) */ /** 是否展示付款申请按钮(仅付款结算单) */
showPaymentAction: { type: Boolean, default: true }, showPaymentAction: { type: Boolean, default: true },
billLabel: { type: String, default: '结算单' }, billLabel: { type: String, default: '结算单' },
@@ -158,66 +103,38 @@ export default {
'create', 'create',
'payment', 'payment',
'sync', 'sync',
'print',
'export', 'export',
'refresh', 'refresh',
'page-change', 'load',
'action', 'action',
'update:selection', 'update:selection',
'update:searchVisible', 'search-change',
'search-reset',
], ],
data() { data() {
return { return {
selection: [], selection: [],
tableSize: 'default',
visibleColumnKeys: [],
knownColumnProps: [],
}; };
}, },
computed: { computed: {
columnSettingOptions() { // 分页对象由父级持有,avue 内部翻页时同步回写同一个对象
return this.columns.map(column => ({ crudPage: {
prop: column.prop, get() {
label: column.label, return this.page;
})); },
}, set(value) {
visibleColumns() { Object.assign(this.page, value || {});
if (!this.visibleColumnKeys.length) return this.columns; },
return this.columns.filter(column => this.visibleColumnKeys.includes(column.prop));
}, },
}, },
watch: { watch: {
columns: {
immediate: true,
handler(columns) {
const props = columns.map(column => column.prop);
if (!this.visibleColumnKeys.length) {
this.visibleColumnKeys = props;
this.knownColumnProps = props;
return;
}
const visible = new Set(this.visibleColumnKeys);
const known = new Set(this.knownColumnProps || []);
props.forEach(prop => {
if (!known.has(prop)) visible.add(prop);
});
this.knownColumnProps = props;
this.visibleColumnKeys = props.filter(prop => visible.has(prop));
},
},
rows() { rows() {
this.selection = []; this.selection = [];
this.$refs.tableRef?.clearSelection(); this.$refs.crud?.toggleSelection?.();
this.$emit('update:selection', this.selection); this.$emit('update:selection', this.selection);
}, },
}, },
methods: { methods: {
handleCurrentChange(row) {
if (!row && this.selection.length === 1) {
this.selection = [];
this.$emit('update:selection', this.selection);
}
},
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.selection = selection; this.selection = selection;
this.$emit('update:selection', selection); this.$emit('update:selection', selection);
@@ -273,20 +190,19 @@ export default {
return invoiceStatusName(value, settlementType); return invoiceStatusName(value, settlementType);
}, },
paymentName(value) { paymentName(value) {
return paymentStatusOptions.find(item => item.value === value)?.label || value || '-'; return paymentStatusName(value);
}, },
kingdeeSyncName(value) { kingdeeSyncName(value) {
return kingdeeSyncStatusOptions.find(item => item.value === value)?.label || value || '-'; return kingdeeSyncName(value);
},
adjustFlag(row) {
// 原单已调整 / 重推生成的新单(显示来源原单号)
if (row.adjustStatusName) return row.adjustStatusName;
if (row.originFormalSettlementNo) return '调整后单';
return '-';
}, },
lockTag(row) { lockTag(row) {
if (row.kingdeeLockStatus === 'locked') { if (row.kingdeeLockStatus === 'locked') {
return { show: true, type: 'danger', label: '金蝶锁定中', tip: '该单据已被金蝶锁定,不可编辑/作废' }; return {
show: true,
type: 'danger',
label: '金蝶锁定中',
tip: '该单据已被金蝶锁定,不可编辑/作废',
};
} }
if (row.kingdeeLockStatus === 'failed') { if (row.kingdeeLockStatus === 'failed') {
if ((row.kingdeeTryCount || 0) >= 5) { if ((row.kingdeeTryCount || 0) >= 5) {
@@ -316,30 +232,12 @@ export default {
} }
return { show: false }; return { show: false };
}, },
displayValue(value) {
return value === null || value === undefined || value === '' ? '-' : value;
},
formatMoney(value, currency = 'RMB') {
return `${Number(value || 0).toFixed(2)} ${currency || 'RMB'}`;
},
}, },
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.fs-table-panel__toolbar { .fs-invoice-status {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 0;
}
.fs-table-panel__links {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 8px;
}
.fs-table-panel__invoice-status {
&.is-unreceived { &.is-unreceived {
color: #f56c6c; color: #f56c6c;
} }
@@ -347,12 +245,7 @@ export default {
color: #e6a23c; color: #e6a23c;
} }
&.is-completed { &.is-completed {
color: #67c23a; color: #67c23c;
} }
} }
.fs-table-panel__pagination {
display: flex;
justify-content: flex-end;
margin-top: 12px;
}
</style> </style>
@@ -251,29 +251,32 @@
:key="item.key" :key="item.key"
:label="item.kind === 'fee' ? item.name : item.column.label" :label="item.kind === 'fee' ? item.name : item.column.label"
:prop="item.kind === 'fee' ? undefined : item.column.prop" :prop="item.kind === 'fee' ? undefined : item.column.prop"
:min-width="item.kind === 'fee' ? 130 : item.column.minWidth" :min-width="item.kind === 'fee' ? 150 : item.column.minWidth"
align="center" align="center"
show-overflow-tooltip show-overflow-tooltip
> >
<template #default="{ row }"> <template #header>
<span v-if="item.kind === 'fee'" class="pre-settlement-editor__billing-rule-cell"> <span class="pre-settlement-editor__billing-rule-cell">
<span> <span>{{ item.kind === 'fee' ? item.name : item.column.label }}</span>
{{
formatMoney(
parseFeeItems(row.feeItemsJson)[item.name],
row.currency || form.currency
)
}}
</span>
<el-icon <el-icon
v-if="hasDetailBillingRule(row)" v-if="showDetailColumnRuleIcon(item)"
class="pre-settlement-editor__billing-rule-icon" class="pre-settlement-editor__billing-rule-icon"
title="查看计费规则详情" title="查看计费规则详情"
@click.stop="openDetailBillingRule(row, item.name)" @click.stop="openDetailColumnRule(item)"
> >
<InfoFilled /> <InfoFilled />
</el-icon> </el-icon>
</span> </span>
</template>
<template #default="{ row }">
<span v-if="item.kind === 'fee'">
{{
formatMoney(
parseFeeItems(row.feeItemsJson)[item.name],
row.currency || form.currency
)
}}
</span>
<el-link <el-link
v-else-if="item.column.link && row[item.column.prop] && !publicMode" v-else-if="item.column.link && row[item.column.prop] && !publicMode"
type="primary" type="primary"
@@ -284,19 +287,8 @@
<span v-else-if="item.column.money && item.column.prop === 'unitPrice'"> <span v-else-if="item.column.money && item.column.prop === 'unitPrice'">
{{ formatUnitPrice(row) }} {{ formatUnitPrice(row) }}
</span> </span>
<span <span v-else-if="item.column.prop === 'freightAmount'">
v-else-if="item.column.prop === 'freightAmount'" {{ formatMoney(row[item.column.prop], row.currency || form.currency) }}
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>
<span v-else-if="item.column.money"> <span v-else-if="item.column.money">
{{ formatMoney(row[item.column.prop], row.currency || form.currency) }} {{ formatMoney(row[item.column.prop], row.currency || form.currency) }}
@@ -499,6 +491,11 @@
<span v-else>{{ displayValue(row[column.prop]) }}</span> <span v-else>{{ displayValue(row[column.prop]) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="100" align="center" fixed="right">
<template #default="{ row }">
<el-link type="primary" @click="openAdjustChangeRecord(row)">查看</el-link>
</template>
</el-table-column>
</el-table> </el-table>
</section-card> </section-card>
</div> </div>
@@ -824,25 +821,28 @@
min-width="160" min-width="160"
align="center" align="center"
> >
<template #default="{ row }"> <template #header>
<div class="pre-settlement-editor__billing-rule-cell"> <span class="pre-settlement-editor__billing-rule-cell">
<el-input-number <span>{{ feeItem }}</span>
v-model="row.feeItems[feeItem]"
:min="0"
:precision="2"
:controls="false"
:disabled="adjustDialog.readonly"
@change="recalculateAdjustRow(row, feeItem)"
/>
<el-icon <el-icon
v-if="hasBillingRule(row)" v-if="showAdjustFeeRuleIcon(feeItem)"
class="pre-settlement-editor__billing-rule-icon" class="pre-settlement-editor__billing-rule-icon"
title="查看计费规则详情" title="查看计费规则详情"
@click="openBillingRuleInfo(row, feeItem)" @click.stop="openAdjustFeeRule(feeItem)"
> >
<InfoFilled /> <InfoFilled />
</el-icon> </el-icon>
</div> </span>
</template>
<template #default="{ row }">
<el-input-number
v-model="row.feeItems[feeItem]"
:min="0"
:precision="2"
:controls="false"
:disabled="adjustDialog.readonly"
@change="recalculateAdjustRow(row, feeItem)"
/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="结算金额(含税)" min-width="170" align="center"> <el-table-column label="结算金额(含税)" min-width="170" align="center">
@@ -1522,7 +1522,9 @@ export default {
availableWriteOffAmount: Number(row.availableWriteOffAmount || 0), availableWriteOffAmount: Number(row.availableWriteOffAmount || 0),
createTime: row.paymentCreateTime || row.createTime, createTime: row.paymentCreateTime || row.createTime,
})); }));
this.changeRecords = detail.changeRecords || []; this.changeRecords = (detail.changeRecords || []).filter(
row => row.changeContent !== '预结算审批通过'
);
this.attachments = this.parseAttachments(detail.attachmentsJson); this.attachments = this.parseAttachments(detail.attachmentsJson);
this.sortAttachments(); this.sortAttachments();
this.selectedAttachmentRows = []; this.selectedAttachmentRows = [];
@@ -2307,6 +2309,17 @@ export default {
}, },
formatAdjustChangeValue(value) { formatAdjustChangeValue(value) {
if (value === undefined || value === null || value === '') return '空'; if (value === undefined || value === null || value === '') return '空';
if (Array.isArray(value)) {
if (!value.length) return '空';
return value
.map(item => {
if (!item || typeof item !== 'object') return String(item);
return Object.entries(item)
.map(([key, itemValue]) => `${key}:${this.formatAdjustChangeValue(itemValue)}`)
.join(',');
})
.join('\n');
}
if (typeof value === 'object') return JSON.stringify(value); if (typeof value === 'object') return JSON.stringify(value);
return String(value); return String(value);
}, },
@@ -2369,12 +2382,60 @@ export default {
ruleFeeName(rule = {}) { ruleFeeName(rule = {}) {
return String(rule.feeItem || rule.feeItemName || rule.name || '').trim(); return String(rule.feeItem || rule.feeItemName || rule.name || '').trim();
}, },
isHandlingFeeItem(name) {
return String(name || '').includes('装卸');
},
feeNamesMatch(left, right) { feeNamesMatch(left, right) {
const source = String(left || '').trim(); const source = String(left || '').trim();
const target = String(right || '').trim(); const target = String(right || '').trim();
if (!source || !target) return false; if (!source || !target) return false;
if (source === target) return true; if (source === target) return true;
return this.isFreightFeeItem(source) && this.isFreightFeeItem(target); if (this.isFreightFeeItem(source) && this.isFreightFeeItem(target)) return true;
return this.isHandlingFeeItem(source) && this.isHandlingFeeItem(target);
},
detailColumnFeeName(item = {}) {
if (item.kind === 'fee') return item.name || '';
if (item.column?.prop === 'freightAmount') return '运输费';
return '';
},
showDetailColumnRuleIcon(item) {
const feeName = this.detailColumnFeeName(item);
if (!feeName) return false;
return this.details.some(row => this.rowHasNamedBillingRule(row, feeName));
},
openDetailColumnRule(item) {
const feeName = this.detailColumnFeeName(item);
const row =
this.details.find(detail => this.rowHasNamedBillingRule(detail, feeName)) ||
this.details[0];
if (row) this.openDetailBillingRule(row, feeName);
},
showAdjustFeeRuleIcon(feeName) {
return (this.adjustRows || []).some(row => this.sourceHasNamedBillingRule(row, feeName));
},
openAdjustFeeRule(feeName) {
const row =
(this.adjustRows || []).find(item => this.sourceHasNamedBillingRule(item, feeName)) ||
this.adjustRows[0];
if (row) this.openBillingRuleInfo(row, feeName);
},
rowHasNamedBillingRule(row, feeName) {
return [row, ...this.detailFeeRows(row)].some(source =>
this.sourceHasNamedBillingRule(source, feeName)
);
},
sourceHasNamedBillingRule(source = {}, feeName) {
const rules = [
...this.collectBillingRules(source),
...(Array.isArray(source.billingRule?.rules) ? source.billingRule.rules : []),
];
if (rules.some(rule => this.feeNamesMatch(this.ruleFeeName(rule), feeName))) return true;
if (!this.hasBillingRule(source)) return false;
const named = String(
source.billingFeeItem || source.feeItem || this.ruleFeeName(source.billingRule) || ''
).trim();
if (!named) return true;
return this.feeNamesMatch(named, feeName);
}, },
collectBillingRules(row = {}) { collectBillingRules(row = {}) {
const source = row || {}; const source = row || {};
@@ -135,7 +135,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <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"> <div class="settlement-import-create__upload">
<el-upload <el-upload
ref="uploadRef" ref="uploadRef"
@@ -143,13 +143,13 @@
accept=".xls,.xlsx" accept=".xls,.xlsx"
:auto-upload="false" :auto-upload="false"
:limit="1" :limit="1"
:disabled="readonly || !formReady" :disabled="!formReady"
:file-list="files" :file-list="files"
:on-change="onFileChange" :on-change="onFileChange"
:on-exceed="onFileExceed" :on-exceed="onFileExceed"
:on-remove="onFileRemove" :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-upload>
<el-link type="primary" :underline="false" @click="downloadTemplate"> <el-link type="primary" :underline="false" @click="downloadTemplate">
下载模板 下载模板
@@ -298,15 +298,10 @@
</el-table> </el-table>
</section> </section>
<div class="settlement-import-create__footer"> <div v-if="!readonly" class="settlement-import-create__footer">
<el-button @click="goBack">取消</el-button> <el-button @click="goBack">取消</el-button>
<el-button v-if="!readonly" :loading="draftLoading" @click="saveDraft">保存草稿</el-button> <el-button :loading="draftLoading" @click="saveDraft">保存草稿</el-button>
<el-button <el-button type="primary" :loading="confirmLoading" @click="confirmImport">
v-if="!readonly"
type="primary"
:loading="confirmLoading"
@click="confirmImport"
>
确认导入 确认导入
</el-button> </el-button>
</div> </div>
@@ -577,6 +572,8 @@ const syncEditedText = (row, column, value) => {
if (column.prop !== 'vehicleNo') return; if (column.prop !== 'vehicleNo') return;
applyVehicleNo(row, value); applyVehicleNo(row, value);
}; };
const feeColumn = name => ({
prop: name, prop: name,
label: name, label: name,
editor: 'number', editor: 'number',
@@ -607,6 +604,38 @@ const dedupeColumns = columns => {
}); });
}; };
const settlementAmountColumn = {
prop: 'settlementAmount',
label: '结算金额',
editor: 'number',
minWidth: 120,
};
/** 模板已去掉结算金额;明细仍展示,并插在费用项之后、日期列之前 */
const ensureSettlementAmountColumn = columns => {
if (columns.some(column => column.prop === 'settlementAmount')) {
return columns;
}
const result = [...columns];
let insertAt = result.findIndex(column =>
['actualStartDate', 'actualEndDate', 'planStartDate', 'planEndDate', 'remark', 'waybillIdentifier'].includes(
column.prop
)
);
if (insertAt < 0) {
const lastFeeIndex = [...result].map((column, index) => (column.isFeeItem ? index : -1)).filter(index => index >= 0).pop();
const transportFeeIndex = result.findIndex(column => column.prop === 'transportFee');
insertAt =
lastFeeIndex !== undefined
? lastFeeIndex + 1
: transportFeeIndex >= 0
? transportFeeIndex + 1
: result.length;
}
result.splice(insertAt, 0, { ...settlementAmountColumn });
return result;
};
const detailColumns = computed(() => { const detailColumns = computed(() => {
const historyColumns = const historyColumns =
form.waybillMode === 'history' form.waybillMode === 'history'
@@ -622,16 +651,13 @@ const detailColumns = computed(() => {
const fallback = [ const fallback = [
...columnsBeforeFee, ...columnsBeforeFee,
...feeItemNames.value.map(name => feeColumn(name)), ...feeItemNames.value.map(name => feeColumn(name)),
{ { ...settlementAmountColumn },
prop: 'settlementAmount',
label: '结算金额',
editor: 'number',
minWidth: 120,
},
...columnsAfterFee, ...columnsAfterFee,
]; ];
const uploaded = parsedHeaders.value.map(columnFromHeader).filter(Boolean); const uploaded = parsedHeaders.value.map(columnFromHeader).filter(Boolean);
const columns = dedupeColumns(uploaded.length ? uploaded : fallback); const columns = ensureSettlementAmountColumn(
dedupeColumns(uploaded.length ? uploaded : fallback)
);
return [...historyColumns, ...columns]; return [...historyColumns, ...columns];
}); });
@@ -720,6 +746,7 @@ const formatCell = (row, column) => {
return value ?? ''; return value ?? '';
}; };
/** 导入解析后自动合计结算金额;编辑运输费/费用项时不再回算 */
const recalcSettlementAmount = row => { const recalcSettlementAmount = row => {
const transportFee = toNumber(row.transportFee ?? row.freight); const transportFee = toNumber(row.transportFee ?? row.freight);
row.transportFee = transportFee; row.transportFee = transportFee;
@@ -738,6 +765,18 @@ const recalcSettlementAmount = row => {
row.settlementAmount = settlementAmount; row.settlementAmount = settlementAmount;
row.otherFeeTotal = Number(feeSum.toFixed(2)); row.otherFeeTotal = Number(feeSum.toFixed(2));
row.freightTotal = settlementAmount; row.freightTotal = settlementAmount;
row['运费合计'] = settlementAmount;
};
const syncOtherFeeTotal = row => {
if (!row.feeItems || typeof row.feeItems !== 'object') {
row.feeItems = {};
}
let feeSum = 0;
feeItemNames.value.forEach(name => {
feeSum += toNumber(row.feeItems[name] ?? row[name]);
});
row.otherFeeTotal = Number(feeSum.toFixed(2));
}; };
const updateNumberCell = (row, column, value) => { const updateNumberCell = (row, column, value) => {
@@ -747,17 +786,16 @@ const updateNumberCell = (row, column, value) => {
if (!row.feeItems) row.feeItems = {}; if (!row.feeItems) row.feeItems = {};
row.feeItems[column.prop] = ''; row.feeItems[column.prop] = '';
row[column.prop] = ''; row[column.prop] = '';
} else { syncOtherFeeTotal(row);
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; return;
} }
recalcSettlementAmount(row); row[column.prop] = '';
if (column.prop === 'transportFee') row.freight = '';
if (column.prop === 'unitPrice') row.transportUnitPrice = '';
if (column.prop === 'settlementAmount') {
row.freightTotal = '';
row['运费合计'] = '';
}
return; return;
} }
const [integer = '', decimal = ''] = raw.replace(/[^\d.]/g, '').split('.'); const [integer = '', decimal = ''] = raw.replace(/[^\d.]/g, '').split('.');
@@ -767,21 +805,20 @@ const updateNumberCell = (row, column, value) => {
if (!row.feeItems) row.feeItems = {}; if (!row.feeItems) row.feeItems = {};
row.feeItems[column.prop] = normalized; row.feeItems[column.prop] = normalized;
row[column.prop] = normalized; row[column.prop] = normalized;
} else { syncOtherFeeTotal(row);
row[column.prop] = normalized; return;
if (column.prop === 'transportFee') { }
row.freight = normalized; row[column.prop] = normalized;
} if (column.prop === 'transportFee') {
if (column.prop === 'unitPrice') { row.freight = normalized;
row.transportUnitPrice = normalized; }
} if (column.prop === 'unitPrice') {
if (column.prop === 'settlementAmount') { row.transportUnitPrice = normalized;
row.freightTotal = normalized; }
row['运费合计'] = normalized; if (column.prop === 'settlementAmount') {
return; row.freightTotal = normalized;
} row['运费合计'] = normalized;
} }
recalcSettlementAmount(row);
}; };
const importFieldText = value => String(value ?? '').trim(); const importFieldText = value => String(value ?? '').trim();
@@ -857,11 +894,8 @@ const normalizeParsedRow = (item, index) => {
applyVehicleNo(row, vehicleNo); applyVehicleNo(row, vehicleNo);
row.transportUnitPrice = row.unitPrice; row.transportUnitPrice = row.unitPrice;
row.freight = row.transportFee; row.freight = row.transportFee;
if (row.settlementAmount === '' || row.settlementAmount === null || row.settlementAmount === undefined) { // 模板无结算金额列:导入后按运输费+费用项自动合计
recalcSettlementAmount(row); recalcSettlementAmount(row);
} else {
row.freightTotal = row.settlementAmount;
}
return row; return row;
}; };
@@ -1344,22 +1378,18 @@ const confirmImport = async () => {
const loadTransportTypeOptions = async () => { const loadTransportTypeOptions = async () => {
try { try {
// 运输方式取业务字典 transport_type 的字典名称(dictValue),不写死枚举
const response = await getDictionary({ code: 'transport_type' }); const response = await getDictionary({ code: 'transport_type' });
const list = unwrapData(response) || []; const list = unwrapData(response) || [];
transportTypeOptions.value = (Array.isArray(list) ? list : []) transportTypeOptions.value = (Array.isArray(list) ? list : [])
.map(item => { .map(item => {
const label = item.dictValue || item.label || item.name || ''; const label = String(item.dictValue || item.label || item.name || '').trim();
const value = item.dictValue || item.dictKey || item.value || label; if (!label || String(item.dictKey) === '-1') return null;
return label ? { label, value } : null; return { label, value: label };
}) })
.filter(Boolean); .filter(Boolean);
} catch (error) { } catch (error) {
transportTypeOptions.value = [ transportTypeOptions.value = [];
{ label: '公路运输', value: '公路运输' },
{ label: '铁路运输', value: '铁路运输' },
{ label: '水路运输', value: '水路运输' },
{ label: '航空运输', value: '航空运输' },
];
} }
}; };
@@ -1411,12 +1441,18 @@ const loadDetail = async id => {
const detailRows = Array.isArray(detail.rows) ? detail.rows : []; const detailRows = Array.isArray(detail.rows) ? detail.rows : [];
rows.value = detailRows.map((item, index) => normalizeParsedRow(item, index)); rows.value = detailRows.map((item, index) => normalizeParsedRow(item, index));
refreshDuplicateFlags(); refreshDuplicateFlags();
readonly.value = detail.importStatus && detail.importStatus !== 'draft'; // 查看模式始终只读;编辑时仅草稿可改,已完成/已作废强制只读
readonly.value =
route.query.mode === 'view' ||
Boolean(detail.importStatus && detail.importStatus !== 'draft');
}; };
const initPage = async () => { const initPage = async () => {
await loadOptions(); await loadOptions();
const id = route.query.id; const id = route.query.id;
if (route.query.mode === 'view') {
readonly.value = true;
}
if (id) { if (id) {
await loadDetail(id); await loadDetail(id);
return; return;
+83 -230
View File
@@ -1,89 +1,39 @@
<template> <template>
<basic-container class="formal-page"> <basic-container class="formal-page">
<section v-show="searchVisible" class="formal-page__search"> <el-tabs
<el-form :model="query" label-position="right" label-width="88px" @submit.prevent> v-if="!lockedSettlementType"
<div class="formal-page__search-grid"> type="border-card"
<el-form-item v-for="field in visibleSearchFields" :key="field.prop" :label="field.label"> v-model="activeSettlementType"
<el-date-picker @tab-change="handleSettlementTypeChange"
v-if="field.type === 'daterange'" >
v-model="query[field.prop]" <el-tab-pane label="应付" name="payable">
type="daterange" <formal-settlement-table-panel
value-format="YYYY-MM-DD" v-if="activeSettlementType === 'payable'"
format="YYYY-MM-DD" key="payable"
range-separator="~" v-bind="tablePanelProps"
start-placeholder="开始日期" v-on="tablePanelListeners"
end-placeholder="结束日期" />
/> </el-tab-pane>
<el-select <el-tab-pane label="应收" name="receivable">
v-else-if="field.type === 'select'" <formal-settlement-table-panel
v-model="query[field.prop]" v-if="activeSettlementType === 'receivable'"
clearable key="receivable"
placeholder="请选择" v-bind="tablePanelProps"
> v-on="tablePanelListeners"
<el-option />
v-for="item in field.options" </el-tab-pane>
:key="item.value" </el-tabs>
:label="item.label" <formal-settlement-table-panel
:value="item.value" v-else
/> key="locked"
</el-select> v-bind="tablePanelProps"
<el-cascader v-on="tablePanelListeners"
v-else-if="field.type === 'cascader'" />
v-model="query[field.prop]"
:options="organizationTreeOptions"
:props="organizationCascaderProps"
clearable
filterable
style="width: 100%"
placeholder="请选择"
/>
<el-input v-else v-model="query[field.prop]" clearable placeholder="请输入" />
</el-form-item>
<div class="formal-page__search-actions">
<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>
</div>
</div>
</el-form>
</section>
<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="'payable'"
v-bind="tablePanelProps"
v-on="tablePanelListeners"
/>
</el-tab-pane>
<el-tab-pane label="应收" name="receivable">
<formal-settlement-table-panel
: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 <formal-settlement-editor
v-model="editor.visible" v-model="editor.visible"
:record-id="editor.id" :record-id="editor.id"
:readonly="editor.readonly" :readonly="editor.readonly"
@success="loadTable" @success="onLoad(page)"
/> />
<el-dialog <el-dialog
v-model="paymentDialog.visible" v-model="paymentDialog.visible"
@@ -152,7 +102,6 @@
</template> </template>
<script> <script>
import { ArrowDown, ArrowUp } from '@element-plus/icons-vue';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { createSettlementTransfer } from '@/utils/settlement-transfer'; import { createSettlementTransfer } from '@/utils/settlement-transfer';
import { import {
@@ -164,33 +113,13 @@ import { isAdministrator } from '@/utils/auth';
import { downloadFile } from '@/utils/util'; import { downloadFile } from '@/utils/util';
import * as api from '@/api/settlement/formalSettlement'; import * as api from '@/api/settlement/formalSettlement';
import * as paymentApi from '@/api/payment/paymentApplication'; import * as paymentApi from '@/api/payment/paymentApplication';
import { import { formalSettlementOption } from '@/option/settlement/formalSettlement';
invoiceStatusName,
formalSettlementSearchFields,
paymentStatusOptions,
} from '@/option/settlement/formalSettlementSearch';
import organizationSearch from '@/mixins/organization-search'; import organizationSearch from '@/mixins/organization-search';
import { formalSettlementTableColumns } from '@/option/settlement/formalSettlementTable';
import FormalSettlementEditor from './components/formal-settlement-editor.vue'; import FormalSettlementEditor from './components/formal-settlement-editor.vue';
import FormalSettlementTablePanel from './components/formal-settlement-table-panel.vue'; import FormalSettlementTablePanel from './components/formal-settlement-table-panel.vue';
import { submitMkApprovalFlow, loadMkEnabled } from '@/utils/mk-approval'; import { submitMkApprovalFlow, loadMkEnabled } from '@/utils/mk-approval';
import { getMKApprovalUrl } from '@/api/system/business-process'; import { getMKApprovalUrl } from '@/api/system/business-process';
const emptyQuery = () => ({
formalSettlementNo: '',
preSettlementNo: '',
projectName: '',
deptName: [],
contractNo: '',
payerName: '',
payeeName: '',
invoiceStatus: '',
paymentStatus: '',
approvalStatus: '',
kingdeeSyncStatus: '',
createDateRange: [],
});
export default { export default {
name: 'FormalSettlement', name: 'FormalSettlement',
components: { FormalSettlementEditor, FormalSettlementTablePanel }, components: { FormalSettlementEditor, FormalSettlementTablePanel },
@@ -205,19 +134,14 @@ export default {
}, },
data() { data() {
return { return {
ArrowDown, option: formalSettlementOption(),
ArrowUp, query: {},
query: emptyQuery(),
searchExpanded: false,
searchVisible: true,
activeSettlementType: 'payable', activeSettlementType: 'payable',
searchFields: formalSettlementSearchFields,
columns: formalSettlementTableColumns,
rows: [], rows: [],
selection: [], selection: [],
loading: false, loading: false,
syncLoading: false, syncLoading: false,
page: { current: 1, size: 10, total: 0 }, page: { currentPage: 1, pageSize: 10, pageSizes: [10, 20, 50, 100], total: 0 },
editor: { visible: false, id: null, readonly: false }, editor: { visible: false, id: null, readonly: false },
paymentDialog: { paymentDialog: {
visible: false, visible: false,
@@ -248,14 +172,13 @@ export default {
}, },
tablePanelProps() { tablePanelProps() {
return { return {
option: this.option,
rows: this.rows, rows: this.rows,
columns: this.columns,
loading: this.loading, loading: this.loading,
page: this.page, page: this.page,
hasPermission: this.hasPermissionFn, hasPermission: this.hasPermissionFn,
syncLoading: this.syncLoading, syncLoading: this.syncLoading,
mkEnabled: this.mkEnabled, mkEnabled: this.mkEnabled,
searchVisible: this.searchVisible,
showPaymentAction: this.activeSettlementType === 'payable', showPaymentAction: this.activeSettlementType === 'payable',
billLabel: this.billLabel, billLabel: this.billLabel,
}; };
@@ -266,20 +189,16 @@ export default {
payment: this.openPaymentDialog, payment: this.openPaymentDialog,
sync: this.handleSync, sync: this.handleSync,
export: this.handleExport, export: this.handleExport,
refresh: this.loadTable, refresh: () => this.onLoad(this.page),
'page-change': this.onPageChange, load: this.onLoad,
action: this.onAction, action: this.onAction,
'search-change': this.searchChange,
'search-reset': this.searchReset,
'update:selection': selection => { 'update:selection': selection => {
this.selection = selection; this.selection = selection;
}, },
'update:searchVisible': visible => {
this.searchVisible = visible;
},
}; };
}, },
visibleSearchFields() {
return this.searchExpanded ? this.searchFields : this.searchFields.slice(0, 4);
},
paymentAvailable() { paymentAvailable() {
return this.paymentRemaining(this.paymentDialog.row); return this.paymentRemaining(this.paymentDialog.row);
}, },
@@ -293,6 +212,10 @@ export default {
} }
}, },
}, },
activeSettlementType() {
// 切换结算类型后由新挂载的 avue-crud 触发 on-load,此处只重置分页,避免重复请求
this.page.currentPage = 1;
},
'$route.query.detailNo'(detailNo) { '$route.query.detailNo'(detailNo) {
if (detailNo) this.openRouteDetail(detailNo); if (detailNo) this.openRouteDetail(detailNo);
}, },
@@ -300,13 +223,9 @@ export default {
created() { created() {
// 标签机制按 fullPath 缓存同页多实例:仅当前路由实例应响应 detailNo 跳转,防止缓存旧实例也弹窗 // 标签机制按 fullPath 缓存同页多实例:仅当前路由实例应响应 detailNo 跳转,防止缓存旧实例也弹窗
this.ownFullPath = this.$route.fullPath; this.ownFullPath = this.$route.fullPath;
this.loadOrganizationOptions();
}, },
mounted() { mounted() {
if (this.lockedSettlementType === 'payable' || this.lockedSettlementType === 'receivable') {
this.activeSettlementType = this.lockedSettlementType;
}
this.loadOrganizationOptions();
this.loadTable();
this.openRouteDetail(); this.openRouteDetail();
loadMkEnabled() loadMkEnabled()
.then(enabled => { .then(enabled => {
@@ -319,18 +238,18 @@ export default {
activated() { activated() {
if (sessionStorage.getItem('formal-settlement-list-refresh') === '1') { if (sessionStorage.getItem('formal-settlement-list-refresh') === '1') {
sessionStorage.removeItem('formal-settlement-list-refresh'); sessionStorage.removeItem('formal-settlement-list-refresh');
this.loadTable(); this.onLoad(this.page);
} }
}, },
methods: { methods: {
hasPermission(actionOrCode) { hasPermission(actionOrCode) {
return this.hasPermissionFn(actionOrCode); return this.hasPermissionFn(actionOrCode);
}, },
async loadTable() { async onLoad(page) {
this.loading = true; this.loading = true;
try { try {
const params = this.buildQueryParams(); const params = this.buildQueryParams();
const response = await api.getList(this.page.current, this.page.size, params); const response = await api.getList(page.currentPage, page.pageSize, params);
const data = this.unwrapData(response); const data = this.unwrapData(response);
this.rows = data.records || []; this.rows = data.records || [];
this.page.total = data.total || 0; this.page.total = data.total || 0;
@@ -338,25 +257,24 @@ export default {
this.loading = false; this.loading = false;
} }
}, },
handleSearch() { searchChange(params, done) {
this.page.current = 1; // 所属组织级联返回 id 路径,转成组织名称传给后端
this.loadTable(); this.normalizeOrganizationSearch(params, 'deptName');
const range = params.createDateRange || [];
delete params.createDateRange;
this.query = {
...params,
createStartDate: range[0] || '',
createEndDate: range[1] || '',
};
this.page.currentPage = 1;
this.onLoad(this.page);
done();
}, },
resetSearch() { searchReset() {
this.query = emptyQuery(); this.query = {};
this.handleSearch(); this.page.currentPage = 1;
}, this.onLoad(this.page);
toggleSearch() {
this.searchExpanded = !this.searchExpanded;
},
handleSizeChange() {
this.page.current = 1;
this.loadTable();
},
onPageChange({ current, size }) {
this.page.current = current;
this.page.size = size;
this.loadTable();
}, },
onAction({ type, row }) { onAction({ type, row }) {
const handlers = { const handlers = {
@@ -418,7 +336,7 @@ export default {
await this.$confirm(`确认删除该${this.billLabel}草稿?`, '提示', { type: 'warning' }); await this.$confirm(`确认删除该${this.billLabel}草稿?`, '提示', { type: 'warning' });
await api.remove(row.id); await api.remove(row.id);
this.$message.success('删除成功'); this.$message.success('删除成功');
this.loadTable(); this.onLoad(this.page);
}, },
async handleSubmit(row) { async handleSubmit(row) {
await this.$confirm('提交后来源预付结算单将保持锁定,确认提交?', '提示', { type: 'warning' }); await this.$confirm('提交后来源预付结算单将保持锁定,确认提交?', '提示', { type: 'warning' });
@@ -432,7 +350,7 @@ export default {
mkEnabled: this.mkEnabled, mkEnabled: this.mkEnabled,
}); });
this.$message.success('提交成功'); this.$message.success('提交成功');
this.loadTable(); this.onLoad(this.page);
}, },
handleMkAudit(row) { handleMkAudit(row) {
if (!row?.id) { if (!row?.id) {
@@ -473,6 +391,7 @@ export default {
} finally { } finally {
this.loading = false; this.loading = false;
} }
this.onLoad(this.page);
}, },
async handleReturn(row) { async handleReturn(row) {
const { value } = await this.$prompt('请输入驳回原因', '审批驳回', { const { value } = await this.$prompt('请输入驳回原因', '审批驳回', {
@@ -480,7 +399,7 @@ export default {
}); });
await api.returnBill({ id: row.id, reason: value }); await api.returnBill({ id: row.id, reason: value });
this.$message.success('已驳回'); this.$message.success('已驳回');
this.loadTable(); this.onLoad(this.page);
}, },
async handleVoid(row) { async handleVoid(row) {
const { value } = await this.$prompt('请输入作废原因', `作废${this.billLabel}`, { const { value } = await this.$prompt('请输入作废原因', `作废${this.billLabel}`, {
@@ -488,7 +407,7 @@ export default {
}); });
await api.voidBill({ id: row.id, reason: value }); await api.voidBill({ id: row.id, reason: value });
this.$message.success('已作废'); this.$message.success('已作废');
this.loadTable(); this.onLoad(this.page);
}, },
selectedOne(action) { selectedOne(action) {
if (this.selection.length !== 1) { if (this.selection.length !== 1) {
@@ -518,7 +437,7 @@ export default {
lastFailReason = String(error?.message || error || '未知错误').trim() || '未知错误'; lastFailReason = String(error?.message || error || '未知错误').trim() || '未知错误';
} }
} }
await this.loadTable(); await this.onLoad(this.page);
if (rows.length === 1) { if (rows.length === 1) {
if (failCount) { if (failCount) {
await this.$alert(`同步失败,${lastFailReason}`, '同步结果', { await this.$alert(`同步失败,${lastFailReason}`, '同步结果', {
@@ -642,7 +561,7 @@ export default {
); );
this.paymentDialog.visible = false; this.paymentDialog.visible = false;
this.selection = []; this.selection = [];
this.loadTable(); this.onLoad(this.page);
} finally { } finally {
this.paymentDialog.loading = false; this.paymentDialog.loading = false;
} }
@@ -692,15 +611,8 @@ export default {
); );
}, },
buildQueryParams() { buildQueryParams() {
// 所属组织级联返回 id 路径,转成组织名称传给后端(用副本,避免污染搜索框回显) const params = { ...this.query };
const params = this.normalizeOrganizationSearch({ ...this.query }, 'deptName');
params.settlementType = this.lockedSettlementType || this.activeSettlementType; params.settlementType = this.lockedSettlementType || this.activeSettlementType;
const range = params.createDateRange || [];
delete params.createDateRange;
if (range.length === 2) {
params.createStartDate = range[0];
params.createEndDate = range[1];
}
return params; return params;
}, },
unwrapData(response) { unwrapData(response) {
@@ -708,8 +620,8 @@ export default {
return body?.data || body; return body?.data || body;
}, },
handleSettlementTypeChange() { handleSettlementTypeChange() {
this.page.current = 1; // 分页重置与数据加载由 activeSettlementType watcher + 新挂载 crud 的 on-load 完成
this.loadTable(); this.selection = [];
}, },
escapeHtml(value) { escapeHtml(value) {
return String(value || '-').replace( return String(value || '-').replace(
@@ -717,24 +629,6 @@ export default {
char => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[char]) char => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[char])
); );
}, },
isEditable(row) {
return ['draft', 'returned'].includes(row.approvalStatus);
},
statusType(status) {
return (
{ approved: 'success', reviewing: 'warning', returned: 'danger', voided: 'info' }[status] ||
''
);
},
invoiceName(value, settlementType) {
return invoiceStatusName(value, settlementType);
},
paymentName(value) {
return paymentStatusOptions.find(item => item.value === value)?.label || value || '-';
},
displayValue(value) {
return value === null || value === undefined || value === '' ? '-' : value;
},
formatMoney(value, currency = 'RMB') { formatMoney(value, currency = 'RMB') {
return `${Number(value || 0).toFixed(2)} ${currency || 'RMB'}`; return `${Number(value || 0).toFixed(2)} ${currency || 'RMB'}`;
}, },
@@ -747,62 +641,21 @@ export default {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.formal-page__search { .formal-page {
padding: 12px 12px 4px; :deep(.el-table) {
background: #fff; --el-table-border-color: #eff1f7;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); }
} :deep(.el-table__body tr:nth-child(even) > td.el-table__cell),
.formal-page__search-grid { :deep(.el-table__body tr:nth-child(even) > td.el-table-fixed-column--left),
display: grid; :deep(.el-table__body tr:nth-child(even) > td.el-table-fixed-column--right) {
grid-template-columns: repeat(4, minmax(0, 1fr)); background: #fafafa;
gap: 8px 24px; }
align-items: start;
}
.formal-page__search :deep(.el-form-item) {
margin-bottom: 8px;
}
.formal-page__search :deep(.el-form-item__label) {
white-space: nowrap;
}
.formal-page__search :deep(.el-input),
.formal-page__search :deep(.el-select),
.formal-page__search :deep(.el-date-editor) {
width: 100%;
}
.formal-page__search-actions {
grid-column: 1 / -1;
display: flex;
justify-content: flex-end;
align-items: center;
gap: 8px;
margin-bottom: 8px;
}
.formal-page__table-panel {
margin-top: 8px;
} }
.formal-payment-dialog__batch-tip { .formal-payment-dialog__batch-tip {
margin-bottom: 12px; margin-bottom: 12px;
color: #606266; color: #606266;
} }
.formal-page :deep(.el-table) {
--el-table-border-color: #eff1f7;
}
.formal-page :deep(.el-table__body tr:nth-child(even) > td.el-table__cell),
.formal-page :deep(.el-table__body tr:nth-child(even) > td.el-table-fixed-column--left),
.formal-page :deep(.el-table__body tr:nth-child(even) > td.el-table-fixed-column--right) {
background: #fafafa;
}
:deep(.formal-page.basic-container .basic-container__card > .el-card__body) { :deep(.formal-page.basic-container .basic-container__card > .el-card__body) {
padding: 0; padding: 0;
} }
@media (max-width: 1200px) {
.formal-page__search-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 760px) {
.formal-page__search-grid {
grid-template-columns: 1fr;
}
}
</style> </style>
@@ -241,7 +241,12 @@
<div <div
class="settlement-detail-page__detail-panel-body settlement-detail-page__adjust-panel-body" class="settlement-detail-page__detail-panel-body settlement-detail-page__adjust-panel-body"
> >
<el-table v-loading="adjustDialog.loading" :data="adjustRows" border> <el-table
v-loading="adjustDialog.loading"
:data="adjustRows"
:max-height="adjustTableMaxHeight"
border
>
<el-table-column type="index" label="序号" width="64" align="center" /> <el-table-column type="index" label="序号" width="64" align="center" />
<el-table-column label="来源" width="110" align="center"> <el-table-column label="来源" width="110" align="center">
<template #default="{ row }">{{ feeSourceLabel(row.dataSource) }}</template> <template #default="{ row }">{{ feeSourceLabel(row.dataSource) }}</template>
@@ -446,36 +451,52 @@
:model="updateFeeForm" :model="updateFeeForm"
:rules="updateFeeRules" :rules="updateFeeRules"
label-position="right" label-position="right"
label-width="auto" label-width="120px"
class="settlement-detail-page__dialog-form" class="settlement-detail-page__dialog-form"
> >
<el-form-item label="更新范围" prop="contractId"> <el-form-item label="更新范围" prop="contractId">
<el-input <div class="settlement-detail-page__update-fee-field">
:model-value="updateContractName" <el-tooltip
class="settlement-detail-page__generate-select" :content="updateContractName"
readonly :disabled="!updateContractName"
placeholder="请选择合同" placement="top"
> :show-after="200"
<template #append> >
<el-button @click="openUpdateContractDialog">选择</el-button> <div class="settlement-detail-page__update-fee-trigger">
</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>
</div>
</el-tooltip>
</div>
</el-form-item> </el-form-item>
<el-form-item label="合同计费方案" prop="billingPlanId"> <el-form-item label="合同计费方案" prop="billingPlanId">
<el-select <div class="settlement-detail-page__update-fee-field">
v-model="updateFeeForm.billingPlanId" <el-select
clearable v-model="updateFeeForm.billingPlanId"
filterable class="settlement-detail-page__update-fee-control"
:disabled="!updateFeeForm.contractId" clearable
placeholder="请选择" filterable
> :disabled="!updateFeeForm.contractId"
<el-option :placeholder="updateFeeForm.contractId ? '请选择' : '请先选择合同'"
v-for="item in billingPlanOptions" :title="updateBillingPlanName || undefined"
:key="item.id" >
:label="item.name" <el-option
:value="item.id" v-for="item in billingPlanOptions"
/> :key="item.id"
</el-select> :label="item.name"
:value="item.id"
:title="item.name"
/>
</el-select>
</div>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
@@ -1099,6 +1120,8 @@ export default {
page: { current: 1, size: 10, total: 0 }, page: { current: 1, size: 10, total: 0 },
// 底部详情/调整面板打开时压缩主表高度,露出表格滚动条 // 底部详情/调整面板打开时压缩主表高度,露出表格滚动条
listTableHeight: undefined, listTableHeight: undefined,
savedListTableHeight: null,
listTableLayoutToken: 0,
detailDialog: { detailDialog: {
visible: false, visible: false,
title: '费用明细', title: '费用明细',
@@ -1113,6 +1136,8 @@ export default {
rule: null, rule: null,
}, },
adjustDialog: { visible: false, loading: false, submitting: false, row: null }, adjustDialog: { visible: false, loading: false, submitting: false, row: null },
// 表头 + 最多 3 行费用 + 横向滚动条,超出后表体上下滚动
adjustTableMaxHeight: 40 + 49 * 3 + 16,
adjustRows: [], adjustRows: [],
adjustDynamicFeeColumns: [], adjustDynamicFeeColumns: [],
adjustTextProps: ['specification', 'model', 'billingFactor', 'billingType'], adjustTextProps: ['specification', 'model', 'billingFactor', 'billingType'],
@@ -1203,6 +1228,14 @@ export default {
); );
return formatContractOptionLabel(contract); 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() { generateContractCategory() {
return this.settlementType === 'payable' ? '承运商合同' : '客户合同'; return this.settlementType === 'payable' ? '承运商合同' : '客户合同';
}, },
@@ -1306,8 +1339,11 @@ export default {
'$route.fullPath'() { '$route.fullPath'() {
this.openRouteDetail(); this.openRouteDetail();
}, },
isBottomPanelOpen() { isBottomPanelOpen: {
this.updateListTableHeight(); flush: 'post',
handler() {
this.updateListTableHeight();
},
}, },
searchVisible() { searchVisible() {
this.updateListTableHeight(); this.updateListTableHeight();
@@ -1372,36 +1408,62 @@ export default {
}, },
/** 表格和分页撑满剩余可视区域;单据详情展开时贴住详情面板,关闭后恢复 */ /** 表格和分页撑满剩余可视区域;单据详情展开时贴住详情面板,关闭后恢复 */
updateListTableHeight() { updateListTableHeight() {
this.listTableLayoutToken = (this.listTableLayoutToken || 0) + 1;
const token = this.listTableLayoutToken;
this.$nextTick(() => { this.$nextTick(() => {
window.requestAnimationFrame(() => this.applyListTableHeight()); window.requestAnimationFrame(() => {
if (token !== this.listTableLayoutToken) return;
this.applyListTableHeight(token);
window.requestAnimationFrame(() => {
if (token !== this.listTableLayoutToken) return;
this.applyListTableHeight(token);
});
});
}); });
}, },
applyListTableHeight() { applyListTableHeight(token = this.listTableLayoutToken) {
if (token !== this.listTableLayoutToken) return;
const tableElement = this.$refs.mainTableRef?.$el; const tableElement = this.$refs.mainTableRef?.$el;
if (!tableElement) return; if (!tableElement) return;
const pagination = this.$el?.querySelector?.('.settlement-detail-page__pagination'); const pagination = this.$el?.querySelector?.(
'.settlement-detail-page__table-panel .settlement-detail-page__pagination'
);
const paginationHeight = pagination?.offsetHeight || 0; const paginationHeight = pagination?.offsetHeight || 0;
const tableTop = tableElement.getBoundingClientRect().top; const tableTop = tableElement.getBoundingClientRect().top;
const view = this.$el?.closest?.('#avue-view'); const view = this.$el?.closest?.('#avue-view');
const viewRect = view?.getBoundingClientRect?.(); const viewRect = view?.getBoundingClientRect?.();
let bottomEdge = viewRect ? viewRect.bottom - 12 : window.innerHeight; // 用滚动容器的可视高度,避免表格被压矮后按内容底部把高度锁死
if (this.isBottomPanelOpen) { let bottomEdge = view
? viewRect.top + view.clientHeight - 12
: window.innerHeight;
const panelOpen = this.isBottomPanelOpen;
if (panelOpen) {
if (!this.savedListTableHeight) {
this.savedListTableHeight = this.listTableHeight || null;
}
const panelRect = document const panelRect = document
.querySelector('.settlement-detail-page__detail-panel') .querySelector('.settlement-detail-page__detail-panel')
?.getBoundingClientRect?.(); ?.getBoundingClientRect?.();
if (panelRect && panelRect.height > 0) { if (panelRect && panelRect.height > 0) {
bottomEdge = panelRect.top; bottomEdge = Math.min(bottomEdge, panelRect.top);
this.listTableHeightRetry = 0; this.listTableHeightRetry = 0;
} else if ((this.listTableHeightRetry || 0) < 5) { } else if ((this.listTableHeightRetry || 0) < 5) {
this.listTableHeightRetry = (this.listTableHeightRetry || 0) + 1; this.listTableHeightRetry = (this.listTableHeightRetry || 0) + 1;
window.requestAnimationFrame(() => this.applyListTableHeight()); window.requestAnimationFrame(() => this.applyListTableHeight(token));
return; return;
} }
} else { } else {
this.listTableHeightRetry = 0; this.listTableHeightRetry = 0;
} }
const gap = this.isBottomPanelOpen ? 8 : 0; const gap = panelOpen ? 8 : 0;
this.listTableHeight = Math.max(180, Math.floor(bottomEdge - tableTop - paginationHeight - gap)); let nextHeight = Math.max(180, Math.floor(bottomEdge - tableTop - paginationHeight - gap));
if (!panelOpen && this.savedListTableHeight) {
if (nextHeight + 24 < this.savedListTableHeight) {
nextHeight = this.savedListTableHeight;
}
this.savedListTableHeight = null;
}
this.listTableHeight = nextHeight;
this.$nextTick(() => this.$refs.mainTableRef?.doLayout?.()); this.$nextTick(() => this.$refs.mainTableRef?.doLayout?.());
}, },
contractCategoryName(value) { contractCategoryName(value) {
@@ -1834,11 +1896,13 @@ export default {
this.changeRecordsDialog.visible = false; this.changeRecordsDialog.visible = false;
this.billingRuleDialog.visible = false; this.billingRuleDialog.visible = false;
this.billingRuleDialog.rule = null; this.billingRuleDialog.rule = null;
this.updateListTableHeight();
}, },
closeAdjustPanel() { closeAdjustPanel() {
this.clearAdjustCalculations(); this.clearAdjustCalculations();
this.adjustDialog.visible = false; this.adjustDialog.visible = false;
this.adjustDialog.row = null; this.adjustDialog.row = null;
this.updateListTableHeight();
}, },
handleTableLink(row, column) { handleTableLink(row, column) {
if (column.prop === 'waybillNo') { if (column.prop === 'waybillNo') {
@@ -2422,7 +2486,8 @@ export default {
return; return;
} }
const options = this.syncBillingPlanOptions(contractId); const options = this.syncBillingPlanOptions(contractId);
const selected = options.find(item => item.defaultPlan) || options[0]; const defaultOptions = options.filter(item => item.defaultPlan);
const selected = defaultOptions[defaultOptions.length - 1] || options[options.length - 1];
this.updateFeeForm.billingPlanId = selected?.id || ''; this.updateFeeForm.billingPlanId = selected?.id || '';
}, },
async confirmUpdateFee() { async confirmUpdateFee() {
@@ -3144,11 +3209,37 @@ export default {
} }
} }
:deep(.el-form-item__content) {
min-width: 0;
}
// 仅作用于外层 tooltip 触发器,排除 el-select 内部下拉用的 .el-select__wrapper
// (后者也带 el-tooltip__trigger;若设为 block 会打断 flex,导致「请选择」与箭头叠在左上角)
:deep(.el-tooltip__trigger:not(.el-select__wrapper)) {
display: block;
width: 100%;
}
:deep(.el-select) { :deep(.el-select) {
width: 100%; width: 100%;
} }
} }
.settlement-detail-page__update-fee-field,
.settlement-detail-page__update-fee-trigger {
display: block;
width: 100%;
min-width: 0;
}
.settlement-detail-page__update-fee-control {
width: 100%;
:deep(.el-input-group) {
width: 100%;
}
}
.settlement-detail-page__adjust-input { .settlement-detail-page__adjust-input {
width: 100%; width: 100%;
min-width: 0; min-width: 0;
@@ -3296,6 +3387,7 @@ export default {
.settlement-detail-page__adjust-panel-body { .settlement-detail-page__adjust-panel-body {
padding-top: 16px; padding-top: 16px;
overflow: hidden;
} }
.settlement-detail-page__billing-rule-cell { .settlement-detail-page__billing-rule-cell {
@@ -11,7 +11,10 @@ import { useRoute } from 'vue-router';
import SettlementImportPage from './components/settlement-import-page.vue'; import SettlementImportPage from './components/settlement-import-page.vue';
const route = useRoute(); const route = useRoute();
const pageTitle = computed(() => (route.query.id ? '编辑导入结算单' : '新增导入结算单')); const pageTitle = computed(() => {
if (route.query.mode === 'view') return '查看导入结算单';
return route.query.id ? '编辑导入结算单' : '新增导入结算单';
});
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
+139 -554
View File
@@ -1,224 +1,56 @@
<template> <template>
<basic-container class="settlement-import-page"> <basic-container class="settlement-import-page">
<section v-show="searchVisible" class="settlement-import-page__search"> <avue-crud
<el-form :model="query" label-position="right" label-width="160px" @submit.prevent> ref="crud"
<div class="settlement-import-page__search-grid"> :option="option"
<el-form-item v-for="field in visibleSearchFields" :key="field.prop" :label="field.label"> :table-loading="loading"
<el-select :data="rows"
v-if="field.type === 'select'" v-model:page="page"
v-model="query[field.prop]" @search-change="searchChange"
clearable @search-reset="searchReset"
filterable @current-change="currentChange"
allow-create @size-change="sizeChange"
default-first-option @refresh-change="refreshChange"
placeholder="请选择" @on-load="onLoad"
>
<el-option
v-for="item in field.options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<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 text :icon="searchExpanded ? ArrowUp : ArrowDown" @click="toggleSearch">
{{ searchExpanded ? '收起' : '展开' }}
</el-button>
</div>
</div>
</el-form>
</section>
<section class="settlement-import-page__table-panel">
<div class="settlement-import-page__toolbar">
<div class="settlement-import-page__toolbar-left">
<el-button
v-if="hasPermission('settlement_import_add')"
type="primary"
@click="openCreate"
>
新增
</el-button>
<el-button plain @click="refreshTable">刷新</el-button>
</div>
</div>
<el-table v-loading="loading" :data="rows" border class="settlement-import-page__table">
<el-table-column type="index" label="序号" width="64" align="center" />
<el-table-column prop="batchNo" label="导入批次号" min-width="160">
<template #default="{ row }">
<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) }}
</template>
</el-table-column>
<el-table-column prop="settlementBillTypeName" label="结算单" min-width="110">
<template #default="{ row }">
{{ row.settlementBillTypeName || settlementBillTypeLabel(row.settlementBillType) }}
</template>
</el-table-column>
<el-table-column prop="projectName" label="项目" min-width="140" show-overflow-tooltip />
<el-table-column prop="customerName" label="客户" min-width="140" show-overflow-tooltip />
<el-table-column prop="carrierName" label="承运商" min-width="140" show-overflow-tooltip />
<el-table-column label="明细行数" width="100" align="center">
<template #default="{ row }">
{{ 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="220" fixed="right">
<template #default="{ row }">
<div class="settlement-import-page__row-actions">
<el-link type="primary" @click="openDetail(row)">查看</el-link>
<el-link
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)"
>
作废
</el-link>
</div>
</template>
</el-table-column>
</el-table>
<div class="settlement-import-page__pagination">
<el-pagination
background
v-model:current-page="page.current"
v-model:page-size="page.size"
layout="total, sizes, prev, pager, next, jumper"
:page-sizes="[10, 20, 50, 100]"
:total="page.total"
@current-change="loadTable"
@size-change="handleSizeChange"
/>
</div>
</section>
<el-dialog
v-model="detailVisible"
title="导入结算单详情"
width="1100px"
append-to-body
destroy-on-close
class="settlement-import-detail-dialog"
> >
<el-descriptions :column="3" border> <template #menu-left>
<el-descriptions-item label="导入批次号">{{ detail.batchNo || '-' }}</el-descriptions-item>
<el-descriptions-item label="状态">
{{ detail.importStatusName || importStatusLabel(detail.importStatus) }}
</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.detailCount ?? detail.waybillCount ?? detailRows.length }}
</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.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="3">
<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>
<div class="dialog-section-title settlement-import-page__detail-title">导入明细</div>
<el-table
v-loading="detailLoading"
:data="detailRows"
border
max-height="420"
class="settlement-import-page__table"
>
<el-table-column type="index" label="序号" width="64" align="center" />
<el-table-column
v-for="column in detailDisplayColumns"
:key="column.prop"
:prop="column.fee ? undefined : column.prop"
:label="column.label"
:min-width="column.minWidth || 120"
show-overflow-tooltip
>
<template #default="{ row }">
{{ column.fee ? formatFeeAmount(row, column.prop) : formatDetailCell(row, column) }}
</template>
</el-table-column>
</el-table>
<template #footer>
<el-button @click="detailVisible = false">关闭</el-button>
<el-button <el-button
v-if="detail.importStatus === 'draft'" v-if="hasPermission('settlement_import_add')"
type="primary" type="primary"
@click="editDraft(detail)" @click="openCreate"
>新增</el-button
> >
编辑草稿
</el-button>
</template> </template>
</el-dialog>
<template #batchNo="{ row }">
<el-link type="primary" @click="openDetail(row)">{{ row.batchNo || '-' }}</el-link>
</template>
<template #importStatusName="{ row }">
<el-tag :type="statusTagType(row.importStatus)" effect="plain">{{
row.importStatusName || importStatusLabel(row.importStatus)
}}</el-tag>
</template>
<template #menu="{ row }">
<el-link type="primary" @click="openDetail(row)">查看</el-link>
<el-link 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)"
>作废</el-link
>
</template>
</avue-crud>
<el-dialog v-model="voidVisible" title="作废导入结算单" width="480px" append-to-body> <el-dialog v-model="voidVisible" title="作废导入结算单" width="480px" append-to-body>
<el-form <el-form
@@ -248,31 +80,11 @@
</template> </template>
<script> <script>
import { ArrowDown, ArrowUp } from '@element-plus/icons-vue'; import { h } from 'vue';
import { ElOption, ElSelect } from 'element-plus';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import * as api from '@/api/settlement/settlementImport'; import * as api from '@/api/settlement/settlementImport';
import { settlementImportOption, importStatusLabel } from '@/option/settlement/settlementImport';
const emptyQuery = () => ({
batchNo: '',
settlementType: '',
importStatus: '',
projectName: '',
customerName: '',
carrierName: '',
});
const SETTLEMENT_TYPE_OPTIONS = [
{ label: '全部', value: '' },
{ 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'; const SETTLEMENT_IMPORT_LIST_REFRESH_KEY = 'settlement-import-list-refresh';
@@ -280,20 +92,17 @@ export default {
name: 'SettlementImport', name: 'SettlementImport',
data() { data() {
return { return {
ArrowDown,
ArrowUp,
searchVisible: true,
searchExpanded: false,
loading: false,
query: emptyQuery(),
rows: [], rows: [],
page: { current: 1, size: 10, total: 0 }, loading: false,
query: {},
option: settlementImportOption(),
page: {
currentPage: 1,
pageSize: 10,
pageSizes: [10, 20, 50, 100],
total: 0,
},
batchNoOptions: [], batchNoOptions: [],
detailVisible: false,
detailLoading: false,
detail: {},
detailRows: [],
detailFeeItemNames: [],
voidVisible: false, voidVisible: false,
voidLoading: false, voidLoading: false,
voidForm: { id: null, reason: '' }, voidForm: { id: null, reason: '' },
@@ -311,84 +120,10 @@ export default {
const authority = this.userInfo?.authority || ''; const authority = this.userInfo?.authority || '';
return String(authority).includes('admin'); return String(authority).includes('admin');
}, },
searchFields() {
return [
{
prop: 'batchNo',
label: '导入批次号',
type: 'select',
options: this.batchNoOptions,
},
{
prop: 'importStatus',
label: '状态',
type: 'select',
options: IMPORT_STATUS_OPTIONS,
},
{
prop: 'settlementType',
label: '导入类型',
type: 'select',
options: SETTLEMENT_TYPE_OPTIONS,
},
{ prop: 'projectName', label: '项目', type: 'input' },
{ prop: 'customerName', label: '客户', type: 'input' },
{ prop: 'carrierName', label: '承运商', type: 'input' },
];
},
visibleSearchFields() {
return this.searchExpanded ? this.searchFields : this.searchFields.slice(0, 4);
},
detailDisplayColumns() {
const before = [
{ prop: 'originalNo', label: '原始单号', minWidth: 130 },
{ prop: 'loadingIdentifier', label: '配载标识号', minWidth: 140 },
{ prop: 'vehicleNo', label: '车牌号/航班号/船号/班列号', minWidth: 190 },
{ prop: 'transportType', label: '运输方式', minWidth: 120 },
{ prop: 'driverName', label: '司机/船长姓名', minWidth: 130 },
{ prop: 'driverPhone', label: '司机/船长手机号', minWidth: 150 },
{ prop: 'departureAddress', label: '发货地址', minWidth: 160 },
{ prop: 'departureContact', label: '发货联系人', minWidth: 120 },
{ prop: 'departurePhone', label: '发货联系人电话', minWidth: 140 },
{ prop: 'arrivalAddress', label: '到货地址', minWidth: 160 },
{ prop: 'arrivalContact', label: '收货联系人', minWidth: 120 },
{ prop: 'arrivalPhone', label: '收货联系人电话', minWidth: 140 },
{ prop: 'cargoName', label: '货物名称', minWidth: 140 },
{ prop: 'cargoType', label: '货物类型', minWidth: 120 },
{ prop: 'packageType', label: '包装', minWidth: 100 },
{ prop: 'quantity', label: '数量', minWidth: 90 },
{ prop: 'quantityUnit', label: '数量单位', minWidth: 100 },
{ prop: 'specification', label: '规格', minWidth: 110 },
{ prop: 'model', label: '型号', minWidth: 110 },
{ prop: 'mileage', label: '里程(km)', minWidth: 110 },
{ prop: 'unitPrice', label: '运输单价', minWidth: 110 },
{ prop: 'transportFee', label: '运输费', minWidth: 110, money: true },
];
const fees = (this.detailFeeItemNames || []).map(name => ({
prop: name,
label: name,
minWidth: 110,
fee: true,
}));
const after = [
{ prop: 'settlementAmount', label: '结算金额', minWidth: 120, money: true },
{ prop: 'actualStartDate', label: '实际发货时间', minWidth: 140 },
{ prop: 'actualEndDate', label: '实际完成时间', minWidth: 140 },
{ prop: 'planStartDate', label: '预计发货时间', minWidth: 140 },
{ prop: 'planEndDate', label: '预计完成时间', minWidth: 140 },
{ prop: 'remark', label: '备注', minWidth: 140 },
{ prop: 'waybillIdentifier', label: '同一运单标识号', minWidth: 150 },
];
const history =
this.detail.waybillMode === 'history'
? [{ prop: 'waybillNo', label: '运单号', minWidth: 140 }]
: [];
return [...history, ...before, ...fees, ...after];
},
}, },
created() { created() {
this.setBatchNoSearchRender();
this.loadOptions(); this.loadOptions();
this.loadTable();
}, },
activated() { activated() {
this.consumeListRefresh(); this.consumeListRefresh();
@@ -409,137 +144,111 @@ export default {
return; return;
} }
sessionStorage.removeItem(SETTLEMENT_IMPORT_LIST_REFRESH_KEY); sessionStorage.removeItem(SETTLEMENT_IMPORT_LIST_REFRESH_KEY);
this.page.current = 1; this.page.currentPage = 1;
this.loadOptions(); this.loadOptions();
this.loadTable(); this.onLoad(this.page);
}, },
hasPermission(code) { hasPermission(code) {
return this.isAdmin || this.validData(this.permission?.[code], false); return this.isAdmin || this.validData(this.permission?.[code], false);
}, },
importStatusLabel(value) { importStatusLabel,
return (
IMPORT_STATUS_OPTIONS.find(item => item.value === value)?.label || value || '-'
);
},
statusTagType(status) { statusTagType(status) {
if (status === 'draft') return 'info'; if (status === 'draft') return 'info';
if (status === 'completed') return 'success'; if (status === 'completed') return 'success';
if (status === 'voided') return 'danger'; if (status === 'voided') return 'danger';
return ''; return '';
}, },
settlementTypeLabel(value) {
return (
SETTLEMENT_TYPE_OPTIONS.find(item => item.value === value)?.label || value || '-'
);
},
settlementBillTypeLabel(value) {
if (value === 'pre') return '预结算单';
return '正式结算单';
},
waybillModeLabel(value) {
if (value === 'history') return '历史运单';
return '新运单';
},
unwrapData(response) { unwrapData(response) {
const body = response?.data || response || {}; const body = response?.data || response || {};
return body?.data !== undefined ? body.data : body; return body?.data !== undefined ? body.data : body;
}, },
formatDetailCell(row, column) { /** 批次号搜索控件:可搜索 + 可手输,选项来自已导入批次 */
const value = row?.[column.prop]; setBatchNoSearchRender() {
if (value === null || value === undefined || value === '') return ''; const column = this.findColumn(this.option.column, 'batchNo');
if (!column.money) return value; if (!column) return;
const number = Number(value); column.renderSearch = scope =>
return Number.isFinite(number) ? number.toFixed(2) : value; h(
}, ElSelect,
formatFeeAmount(row, name) { {
const feeItems = row?.feeItems || {}; modelValue: scope.row?.batchNo ?? '',
const value = feeItems[name] ?? row?.[name]; 'onUpdate:modelValue': value => {
if (value === null || value === undefined || value === '') return ''; if (scope.row) scope.row.batchNo = value ?? '';
const number = Number(value); },
return Number.isFinite(number) ? number.toFixed(2) : value; clearable: true,
filterable: true,
allowCreate: true,
defaultFirstOption: true,
placeholder: '请选择',
style: 'width: 100%',
},
() =>
this.batchNoOptions.map(item =>
h(ElOption, { key: item.value, label: item.label, value: item.value })
)
);
}, },
async loadOptions() { async loadOptions() {
try { try {
const response = await api.getOptions(); const response = await api.getOptions();
const options = this.unwrapData(response) || {}; const options = this.unwrapData(response) || {};
const batchNos = Array.isArray(options.batchNos) ? options.batchNos : []; const batchNos = Array.isArray(options.batchNos) ? options.batchNos : [];
this.batchNoOptions = [ this.batchNoOptions = batchNos.map(item => {
{ label: '全部', value: '' }, if (typeof item === 'string') {
...batchNos.map(item => { return { label: item, value: item };
if (typeof item === 'string') { }
return { label: item, value: item }; const value = item.id ?? item.value ?? item.name ?? item.batchNo ?? '';
} const label = item.name ?? item.label ?? item.batchNo ?? value;
const value = item.id ?? item.value ?? item.name ?? item.batchNo ?? ''; return { label: String(label || ''), value: String(value || '') };
const label = item.name ?? item.label ?? item.batchNo ?? value;
return { label: String(label || ''), value: String(value || '') };
}),
];
} catch (error) {
this.batchNoOptions = [{ label: '全部', value: '' }];
}
},
async loadTable() {
this.loading = true;
try {
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,
}); });
const data = this.unwrapData(response) || {}; } catch (error) {
this.rows = data.records || []; this.batchNoOptions = [];
this.page.total = Number(data.total || 0);
} finally {
this.loading = false;
} }
}, },
refreshTable() { onLoad(page) {
this.loading = true;
api
.getList(page.currentPage, page.pageSize, { ...this.query })
.then(response => {
const data = this.unwrapData(response) || {};
this.rows = data.records || [];
this.page.total = Number(data.total || 0);
})
.finally(() => {
this.loading = false;
});
},
searchChange(params, done) {
this.query = { ...params };
this.page.currentPage = 1;
this.onLoad(this.page);
done();
},
searchReset() {
this.query = {};
this.page.currentPage = 1;
this.onLoad(this.page);
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.loadOptions(); this.loadOptions();
this.loadTable(); this.onLoad(this.page);
},
handleSearch() {
this.page.current = 1;
this.loadTable();
},
resetSearch() {
this.query = emptyQuery();
this.handleSearch();
},
toggleSearch() {
this.searchExpanded = !this.searchExpanded;
},
handleSizeChange() {
this.page.current = 1;
this.loadTable();
}, },
openCreate() { openCreate() {
this.$router.push({ path: '/settlement/settlement-import/form' }); this.$router.push({ path: '/settlement/settlement-import/form' });
}, },
async openDetail(row) { openDetail(row) {
if (!row?.id) return; if (!row?.id) return;
this.detailVisible = true; this.$router.push({
this.detailLoading = true; path: '/settlement/settlement-import/form',
this.detail = { ...row }; query: { id: row.id, mode: 'view' },
this.detailRows = []; });
this.detailFeeItemNames = [];
try {
const response = await api.getDetail(row.id);
const detail = this.unwrapData(response) || { ...row };
this.detail = detail;
this.detailRows = Array.isArray(detail.rows) ? detail.rows : [];
this.detailFeeItemNames = Array.isArray(detail.feeItemNames) ? detail.feeItemNames : [];
} catch (error) {
this.detail = { ...row };
this.$message.error(error?.message || '加载详情失败');
} finally {
this.detailLoading = false;
}
}, },
editDraft(row) { editDraft(row) {
this.detailVisible = false;
this.$router.push({ this.$router.push({
path: '/settlement/settlement-import/form', path: '/settlement/settlement-import/form',
query: { id: row.id }, query: { id: row.id },
@@ -553,37 +262,12 @@ export default {
}); });
await api.removeDraft(row.id); await api.removeDraft(row.id);
this.$message.success('删除成功'); this.$message.success('删除成功');
this.loadTable(); this.refreshChange();
this.loadOptions();
} catch (error) { } catch (error) {
if (error === 'cancel' || error === 'close') return; if (error === 'cancel' || error === 'close') return;
this.$message.error(error?.message || '删除失败'); this.$message.error(error?.message || '删除失败');
} }
}, },
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: '预结算详情',
},
});
},
openVoid(row) { openVoid(row) {
this.voidForm = { id: row.id, reason: '' }; this.voidForm = { id: row.id, reason: '' };
this.voidVisible = true; this.voidVisible = true;
@@ -599,7 +283,7 @@ export default {
}); });
this.$message.success('作废成功'); this.$message.success('作废成功');
this.voidVisible = false; this.voidVisible = false;
this.loadTable(); this.onLoad(this.page);
this.loadOptions(); this.loadOptions();
} finally { } finally {
this.voidLoading = false; this.voidLoading = false;
@@ -610,118 +294,19 @@ export default {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.settlement-import-page__search { .settlement-import-page :deep(.el-table) {
padding: 12px 12px 4px;
background: #fff;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.settlement-import-page__search-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px 24px;
align-items: start;
}
.settlement-import-page__search :deep(.el-form-item) {
margin-bottom: 8px;
}
.settlement-import-page__search :deep(.el-form-item__label) {
white-space: nowrap;
}
.settlement-import-page__search :deep(.el-input),
.settlement-import-page__search :deep(.el-select) {
width: 100%;
}
.settlement-import-page__search-actions {
grid-column: 1 / -1;
display: flex;
justify-content: flex-end;
align-items: center;
gap: 8px;
margin-bottom: 8px;
}
.settlement-import-page__table-panel {
margin-top: 8px;
background: #fff;
}
.settlement-import-page__toolbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 0 0;
}
.settlement-import-page__toolbar-left {
display: flex;
gap: 8px;
}
.settlement-import-page__table {
--el-table-border-color: #eff1f7; --el-table-border-color: #eff1f7;
} }
.settlement-import-page__table :deep(.el-table__body tr:nth-child(even) > td.el-table__cell), .settlement-import-page :deep(.el-table__body tr:nth-child(even) > td.el-table__cell),
.settlement-import-page__table .settlement-import-page
:deep(.el-table__body tr:nth-child(even) > td.el-table-fixed-column--left), :deep(.el-table__body tr:nth-child(even) > td.el-table-fixed-column--left),
.settlement-import-page__table .settlement-import-page
:deep(.el-table__body tr:nth-child(even) > td.el-table-fixed-column--right) { :deep(.el-table__body tr:nth-child(even) > td.el-table-fixed-column--right) {
background: #fafafa; background: #fafafa;
} }
.settlement-import-page__row-actions { :deep(.settlement-import-page.basic-container .basic-container__card > .el-card__body) {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.settlement-import-page__pagination {
display: flex;
justify-content: flex-end;
padding: 12px 0;
}
.settlement-import-page__detail-title {
margin: 16px 0 8px;
}
.dialog-section-title {
position: relative;
padding-left: 12px;
color: #303133;
font-size: 16px;
font-weight: 600;
&::before {
position: absolute;
top: 2px;
left: 0;
width: 4px;
height: 16px;
border-radius: 2px;
background: #409eff;
content: '';
}
}
.settlement-import-page :deep(.basic-container__card > .el-card__body) {
padding: 0; padding: 0;
} }
@media (max-width: 1200px) {
.settlement-import-page__search-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 760px) {
.settlement-import-page__search-grid {
grid-template-columns: 1fr;
}
}
</style> </style>
+44
View File
@@ -418,6 +418,37 @@ export default {
}, },
], ],
}, },
{
label: '合同初始流水号',
prop: 'contractInitialSerial',
type: 'input',
minWidth: 140,
order: 61,
placeholder: '如 1',
tip: '该部门当年首个合同时从此流水号起编,后续递增;范围1-999,不填默认从1开始',
rules: [
{
validator: (rule, value, callback) => {
if (value === undefined || value === null || value === '') {
callback();
return;
}
const text = String(value).trim();
if (!/^\d+$/.test(text)) {
callback(new Error('合同初始流水号只能输入正整数'));
return;
}
const serial = Number(text);
if (serial < 1 || serial > 999) {
callback(new Error('合同初始流水号范围为1到999'));
return;
}
callback();
},
trigger: 'blur',
},
],
},
{ {
label: '组织简称', label: '组织简称',
prop: 'shortName', prop: 'shortName',
@@ -1156,6 +1187,17 @@ export default {
row.parentId = 0; row.parentId = 0;
} }
}, },
normalizeContractInitialSerial(value) {
if (value === undefined || value === null || value === '') {
return null;
}
const text = String(value).trim();
if (!text) {
return null;
}
const serial = Number(text);
return Number.isInteger(serial) ? serial : value;
},
isRootDept(row) { isRootDept(row) {
return row && (row.parentId === 0 || String(row.parentId) === '0'); return row && (row.parentId === 0 || String(row.parentId) === '0');
}, },
@@ -1302,6 +1344,7 @@ export default {
row.deptCode = String(row.deptCode || '').trim(); row.deptCode = String(row.deptCode || '').trim();
row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim(); row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim();
row.contractCodePrefix = String(row.contractCodePrefix || '').trim(); row.contractCodePrefix = String(row.contractCodePrefix || '').trim();
row.contractInitialSerial = this.normalizeContractInitialSerial(row.contractInitialSerial);
row.leaderId = func.join(row.leaderId); row.leaderId = func.join(row.leaderId);
this.normalizeTopParent(row); this.normalizeTopParent(row);
if (!this.prepareDeptSubmitRow(row)) { if (!this.prepareDeptSubmitRow(row)) {
@@ -1349,6 +1392,7 @@ export default {
row.deptCode = String(row.deptCode || '').trim(); row.deptCode = String(row.deptCode || '').trim();
row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim(); row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim();
row.contractCodePrefix = String(row.contractCodePrefix || '').trim(); row.contractCodePrefix = String(row.contractCodePrefix || '').trim();
row.contractInitialSerial = this.normalizeContractInitialSerial(row.contractInitialSerial);
row.leaderId = func.join(row.leaderId); row.leaderId = func.join(row.leaderId);
this.normalizeTopParent(row); this.normalizeTopParent(row);
if (!this.prepareDeptSubmitRow(row)) { if (!this.prepareDeptSubmitRow(row)) {
+37 -8
View File
@@ -4,7 +4,7 @@
<div class="box"> <div class="box">
<el-scrollbar> <el-scrollbar>
<basic-container> <basic-container>
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" /> <avue-tree ref="deptTree" :option="treeOption" :data="treeData" @node-click="nodeClick" />
</basic-container> </basic-container>
</el-scrollbar> </el-scrollbar>
</div> </div>
@@ -172,6 +172,7 @@
</el-form-item> </el-form-item>
</el-col> </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="工号"><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="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.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> <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>
@@ -363,6 +364,10 @@
<span class="oa-sync-stat__label">跳过</span> <span class="oa-sync-stat__label">跳过</span>
<span class="oa-sync-stat__value oa-sync-stat__value--skip">{{ oaSyncProgress.skipped }}</span> <span class="oa-sync-stat__value oa-sync-stat__value--skip">{{ oaSyncProgress.skipped }}</span>
</div> </div>
<div class="oa-sync-stat">
<span class="oa-sync-stat__label">删除</span>
<span class="oa-sync-stat__value oa-sync-stat__value--remove">{{ oaSyncProgress.removed }}</span>
</div>
</div> </div>
<div v-if="oaSyncProgress.dumpFilePath" class="oa-sync-meta"> <div v-if="oaSyncProgress.dumpFilePath" class="oa-sync-meta">
原始数据 JSON:{{ oaSyncProgress.dumpFilePath }} 原始数据 JSON:{{ oaSyncProgress.dumpFilePath }}
@@ -453,6 +458,7 @@ export default {
total: 0, total: 0,
synced: 0, synced: 0,
skipped: 0, skipped: 0,
removed: 0,
dumpFilePath: '', dumpFilePath: '',
}, },
page: { page: {
@@ -646,7 +652,17 @@ export default {
}, },
methods: { methods: {
nodeClick(data) { nodeClick(data) {
this.treeDeptId = data.id; const deptId = data?.id;
if (deptId != null && String(this.treeDeptId) === String(deptId)) {
this.treeDeptId = '';
this.page.currentPage = 1;
this.$nextTick(() => {
this.$refs.deptTree?.setCurrentKey?.(null);
});
this.onLoad(this.page);
return;
}
this.treeDeptId = deptId;
this.page.currentPage = 1; this.page.currentPage = 1;
this.onLoad(this.page); this.onLoad(this.page);
}, },
@@ -681,17 +697,21 @@ export default {
}); });
}, },
handleOaPersonFullSync() { handleOaPersonFullSync() {
this.$confirm('全量同步将拉取 OA 全部人员及组织;已存在且 OA 更新时间一致的记录会跳过。是否继续?', '全量同步', { this.$confirm(
confirmButtonText: '确定', '全量同步将按 OA 对齐人员:有登录名的按登录名更新且不修改密码,没有登录名但有工号的也会入库且不回填登录名,部门按 OA 当前部门重绑,OA 中已不存在或已离职的删除。是否继续?',
cancelButtonText: '取消', '全量同步',
type: 'warning', {
}).then(() => { confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(() => {
this.startOaSync(false); this.startOaSync(false);
}); });
}, },
handleOaPersonIncrementalSync() { handleOaPersonIncrementalSync() {
this.$confirm( this.$confirm(
'增量同步仅拉取本地最大 OA 更新时间之后有变更的人员;不存在的新增,已存在且更新时间不一致的修改,一致的跳过。是否继续?', '增量同步仅拉取本地最大 OA 更新时间之后有变更的人员:已有的更新且不修改密码,没有的新增,部门按 OA 当前部门重绑,离职人员直接删除。是否继续?',
'增量同步', '增量同步',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
@@ -716,6 +736,7 @@ export default {
total: 0, total: 0,
synced: 0, synced: 0,
skipped: 0, skipped: 0,
removed: 0,
dumpFilePath: '', dumpFilePath: '',
}; };
this.runOaSyncPages(); this.runOaSyncPages();
@@ -751,6 +772,7 @@ export default {
this.oaSyncProgress.total = page.total || 0; this.oaSyncProgress.total = page.total || 0;
this.oaSyncProgress.synced += page.syncedCount || 0; this.oaSyncProgress.synced += page.syncedCount || 0;
this.oaSyncProgress.skipped += page.skippedCount || 0; this.oaSyncProgress.skipped += page.skippedCount || 0;
this.oaSyncProgress.removed += page.removedCount || 0;
if (page.dumpFilePath) { if (page.dumpFilePath) {
this.oaSyncProgress.dumpFilePath = page.dumpFilePath; this.oaSyncProgress.dumpFilePath = page.dumpFilePath;
} }
@@ -1074,6 +1096,9 @@ export default {
searchReset() { searchReset() {
this.query = {}; this.query = {};
this.treeDeptId = ''; this.treeDeptId = '';
this.$nextTick(() => {
this.$refs.deptTree?.setCurrentKey?.(null);
});
this.onLoad(this.page); this.onLoad(this.page);
}, },
searchChange(params, done) { searchChange(params, done) {
@@ -1478,6 +1503,10 @@ export default {
color: #909399; color: #909399;
} }
.oa-sync-stat__value--remove {
color: #f56c6c;
}
.user-edit-dialog .el-form-item { .user-edit-dialog .el-form-item {
margin-bottom: 24px; margin-bottom: 24px;
} }
+15 -15
View File
@@ -49,28 +49,28 @@ export default ({ mode, command }) => {
__VUE_I18N_LEGACY_API__: true, __VUE_I18N_LEGACY_API__: true,
__INTLIFY_PROD_DEVTOOLS__: false, __INTLIFY_PROD_DEVTOOLS__: false,
}, },
server: {
port: 2888,
proxy: {
'/api': {
// 本地网关默认 80 端口(blade-gateway bootstrap.yml);开发时需先启动网关及 blade-auth/blade-system 等服务
// 注意:本机 8080 一般是 Nacos,不是业务网关
target: 'http://localhost',
// target: 'http://172.16.203.228:8000', // 仅联调远程网关时启用(且不要 rewrite)
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
},
},
},
// server: { // server: {
// port: 2889, // port: 2888,
// proxy: { // proxy: {
// '/api': { // '/api': {
// target: 'http://172.16.203.228:8000', // // 本地网关默认 80 端口(blade-gateway bootstrap.yml);开发时需先启动网关及 blade-auth/blade-system 等服务
// // 注意:本机 8080 一般是 Nacos,不是业务网关
// target: 'http://localhost',
// // target: 'http://172.16.203.228:8000', // 仅联调远程网关时启用(且不要 rewrite)
// changeOrigin: true, // changeOrigin: true,
// rewrite: path => path.replace(/^\/api/, ''),
// }, // },
// }, // },
// }, // },
server: {
port: 2889,
proxy: {
'/api': {
target: 'http://172.16.203.228:8000',
changeOrigin: true,
},
},
},
resolve: { resolve: {
alias: { alias: {
'~': resolve(__dirname, './'), '~': resolve(__dirname, './'),