20260903173136
This commit is contained in:
1 parent
0faf44cffc
commit
3d4e2c7413
1 file changed
+23
@@ -4,6 +4,29 @@ export const identifierRe = /^[A-Za-z_][A-Za-z0-9_]*$/
|
|||||||
|
|
||||||
const padDatePart = (number) => String(number).padStart(2, '0')
|
const padDatePart = (number) => String(number).padStart(2, '0')
|
||||||
|
|
||||||
|
// 序号字段按保存表主键的命名域推断:b_id(系统/基础表)→ b_xh,subid(业务子表)→ mx_xh。
|
||||||
|
const seqFieldByKeyField = new Map([
|
||||||
|
['b_id', 'b_xh'],
|
||||||
|
['subid', 'mx_xh'],
|
||||||
|
])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析模块的序号字段(用于行拖拽重排、新增自动取 MAX+10)。
|
||||||
|
* 显式传入 orderField 时直接使用(页面覆盖口);
|
||||||
|
* 否则按主键域推断,且推断结果必须已登记为模块的数值字段,
|
||||||
|
* 否则返回 ''(不启用,避免给无序号列的表塞字段,如日志表)。
|
||||||
|
*/
|
||||||
|
export function resolveSeqField(orderField, module, fields) {
|
||||||
|
const explicit = String(orderField || '').trim()
|
||||||
|
if (identifierRe.test(explicit)) return explicit
|
||||||
|
const inferred = seqFieldByKeyField.get(String(module?.b_keyfield || '').trim())
|
||||||
|
if (!inferred) return ''
|
||||||
|
const field = (fields || []).find((item) => item.b_field === inferred)
|
||||||
|
if (!field) return ''
|
||||||
|
if (field.b_type !== 'number' && field.b_type !== 'money') return ''
|
||||||
|
return inferred
|
||||||
|
}
|
||||||
|
|
||||||
export function escapeSqlText(value) {
|
export function escapeSqlText(value) {
|
||||||
return String(value).replaceAll("'", "''")
|
return String(value).replaceAll("'", "''")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user