协议样本、生产产出和盘点明细按行更新并保留原 id;补齐存储证明质检预填、离职人员显示名,以及样本采集通知模板字段。 Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
/** 与后端 generate_uuid 一致:32 位大写、无连字符。子表行从创建起就带稳定 ID。 */
|
|
export function createStableRowId() {
|
|
const uuid =
|
|
typeof globalThis.crypto?.randomUUID === 'function'
|
|
? globalThis.crypto.randomUUID()
|
|
: `${Date.now().toString(16)}${Math.random().toString(16).slice(2)}`
|
|
return uuid.replace(/-/g, '').toUpperCase()
|
|
}
|
|
|
|
export function createStepOutputId() {
|
|
return createStableRowId()
|
|
}
|
|
|
|
/** 工艺步骤「产出物」新增行:条码默认实验室入库编码。 */
|
|
export function createEmptyStepOutputRow(labStorageCode?: string | null) {
|
|
return {
|
|
id: createStepOutputId(),
|
|
outputTypeId: '',
|
|
outputName: '',
|
|
outputBarcode: String(labStorageCode || '').trim(),
|
|
remark: ''
|
|
}
|
|
}
|
|
|
|
/** 保存步骤产出物:带上原行 ID,避免后端整表换 ID。 */
|
|
export function toStepOutputReplaceItem(row: Record<string, any>) {
|
|
const id = String(row.id || '').trim() || createStepOutputId()
|
|
row.id = id
|
|
return {
|
|
id,
|
|
output_type_id: row.outputTypeId,
|
|
output_name: row.outputName,
|
|
output_barcode: row.outputBarcode,
|
|
remark: row.remark || ''
|
|
}
|
|
}
|