提交
This commit is contained in:
1 parent
cb8d9fa1c0
commit
e4c4cbeedc
22 files changed
+1523
-1367
No files matched your search
@@ -38,15 +38,27 @@ export function formatQcParamOptionText(options?: string | null, defaultValue?:
|
||||
return list.join(',')
|
||||
}
|
||||
|
||||
let paramRowKeySeed = 0
|
||||
|
||||
/** 为参数行分配稳定 key(表格展开态、列表渲染) */
|
||||
export function assignQcItemParamRowKeys(params: QcItemParam[]): QcItemParam[] {
|
||||
return (params || []).map((p) => ({
|
||||
...p,
|
||||
_rowKey: p._rowKey || p.id || `param-${Date.now()}-${++paramRowKeySeed}`
|
||||
}))
|
||||
}
|
||||
|
||||
/** 表单加载:补充单选选项编辑态 */
|
||||
export function hydrateQcItemParamsForForm(params: QcItemParam[]): QcItemParam[] {
|
||||
return (params || []).map((p) => {
|
||||
if (p.paramType !== 'select') return { ...p }
|
||||
return {
|
||||
...p,
|
||||
_optionText: formatQcParamOptionText(p.options, p.defaultValue)
|
||||
}
|
||||
})
|
||||
return assignQcItemParamRowKeys(
|
||||
(params || []).map((p) => {
|
||||
if (p.paramType !== 'select') return { ...p }
|
||||
return {
|
||||
...p,
|
||||
_optionText: formatQcParamOptionText(p.options, p.defaultValue)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/** 类型切换时清理或初始化单选字段 */
|
||||
@@ -65,7 +77,7 @@ export function onQcItemParamTypeChange(param: QcItemParam) {
|
||||
/** 提交前序列化并校验 */
|
||||
export function serializeQcItemParamsForSave(params: QcItemParam[]): QcItemParam[] {
|
||||
return (params || []).map((p, idx) => {
|
||||
const { _optionText, ...rest } = p
|
||||
const { _optionText, _rowKey, ...rest } = p
|
||||
const base: QcItemParam = { ...rest, orderNum: p.orderNum ?? idx }
|
||||
if (p.paramType !== 'select') {
|
||||
base.options = undefined
|
||||
|
||||
Reference in new issue
Block a user