基础信息页:类别→规格型号自动提取正则扩展为支持字母+数字(如 Opt9)
This commit is contained in:
@ -1034,18 +1034,19 @@ const onCategoryChange = () => {
|
|||||||
// 1) 收起下拉
|
// 1) 收起下拉
|
||||||
categoryCascaderRef.value.togglePopperVisible(false);
|
categoryCascaderRef.value.togglePopperVisible(false);
|
||||||
|
|
||||||
// 2) 从末级节点 Label 提取英文字母后缀 (例如 "电子半成品HH" -> "HH"),写入规格型号
|
// 2) 从末级节点 Label 末尾提取连续的英文字母/数字 (例如 "电子半成品HH" -> "HH",
|
||||||
|
// "ASD定标实验室Opt9" -> "Opt9"),写入规格型号。
|
||||||
// 仅在 @change 触发时赋一次值,用户可继续手动修改;未匹配到则保持原值
|
// 仅在 @change 触发时赋一次值,用户可继续手动修改;未匹配到则保持原值
|
||||||
try {
|
try {
|
||||||
const nodes = categoryCascaderRef.value.getCheckedNodes?.() || [];
|
const nodes = categoryCascaderRef.value.getCheckedNodes?.() || [];
|
||||||
const node = nodes[0];
|
const node = nodes[0];
|
||||||
const label: string = (node && node.label) || '';
|
const label: string = (node && node.label) || '';
|
||||||
const match = label.match(/[a-zA-Z]+$/);
|
const match = label.match(/[a-zA-Z0-9]+$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
form.value.spec = match[0];
|
form.value.spec = match[0];
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('提取类别英文后缀失败', e);
|
console.error('提取类别编码后缀失败', e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user