Commit 12109e56 by sunhaiwei

生产任务页面将从生产计划带过来的字段设置为只读

parent 4d535a31
...@@ -134,6 +134,66 @@ import { log } from 'node:console'; ...@@ -134,6 +134,66 @@ import { log } from 'node:console';
} }
); );
const readonlyFields = [
'ywzz', // 业务组织
'kh', // 客户
'jhjsrq', // 计划结束日期
'sfnbdd', // 是否内部订单
'jsyq', // 技术要求
'cpid' // 生产产品
];
// 2. 递归查找schema的通用方法(支持嵌套Grid/SubForm)
function findSchemaByField(schemas: any[], field: string): any {
for (const schema of schemas) {
// 匹配目标字段
if (schema.field === field) {
return schema;
}
// 递归查找Grid子项
if (schema.children?.length) {
for (const child of schema.children) {
if (child.list?.length) {
const res = findSchemaByField(child.list, field);
if (res) return res;
}
}
}
// 递归查找Tab/SubForm子项
if (schema.component === 'Tab' && schema.children?.length) {
for (const tab of schema.children) {
if (tab.list?.length) {
const res = findSchemaByField(tab.list, field);
if (res) return res;
}
}
}
}
return null;
}
// 3. 批量设置字段禁用状态的方法
function setFieldsDisabled(isDisabled: boolean) {
readonlyFields.forEach(field => {
const schema = findSchemaByField(data.formDataProps.schemas, field);
if (schema && schema.componentProps) {
// 修改disabled属性(兼容不同组件的属性名)
schema.componentProps.disabled = isDisabled;
}
});
}
// 4. 核心监听:计划编号变化时批量控制字段
watch(
() => state.formModel.jhbh,
(jhbhVal) => {
// 计划编号有值 → 禁用(只读);无值 → 启用
const isDisabled = !!jhbhVal;
setFieldsDisabled(isDisabled);
},
{ immediate: true } // 初始化立即执行
);
onMounted(async () => { onMounted(async () => {
try { try {
if (props.fromPage == FromPageType.MENU) { if (props.fromPage == FromPageType.MENU) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment