Commit 6af1848b by 胡鑫

生产模块修改

parent 5d28fcfc
......@@ -118,7 +118,7 @@ export interface MesProductionTaskModel {
mesProductionGongdanList?: MesProductionGongdanModel;
mesWarehouseMaterialList?: MesWarehouseMaterialModel;
mesWarehouseMaterialList?: MesWarehouseMaterialModel[];
}
/**
......
......@@ -585,7 +585,7 @@
} else {
if (schema.componentProps?.['events']) {
for (const eventKey in schema.componentProps['events']) {
if (eventKey !== 'change') return;
if (eventKey !== 'change') continue;
try {
const event = new Function(
'schema',
......@@ -596,65 +596,30 @@
`${schema.componentProps['events'][eventKey]}`,
);
schema.componentProps['on' + upperFirst(eventKey)] = function (e, opt) {
event(schema, formModel, formApi, e, opt);
try {
event(schema, formModel, formApi, e, opt);
} catch (error) {
// Handle curRowData is not defined error gracefully
if (error.message && error.message.includes('curRowData is not defined')) {
console.warn('Event handler references curRowData which is not available in this context');
} else {
console.error('Error executing event:', error);
notification.error({
message: 'Tip',
description: '触发事件填写有误!',
});
}
}
};
} catch (error) {
console.log('error', error);
notification.error({
message: 'Tip',
description: '触发事件填写有误!',
});
console.error('Error creating event function:', error);
}
}
}
}
}
// if (componentProps['events']) {
// for (const eventKey in componentProps['events']) {
// try {
// const event = new Function(
// 'schema',
// 'formModel',
// 'formActionType',
// `${componentProps['events'][eventKey]}`,
// );
// componentProps['on' + upperFirst(eventKey)] = function () {
// event(props.schema, formModel, props.formApi);
// };
// } catch (error) {
// console.log('error', error);
// notification.error({
// message: 'Tip',
// description: '触发事件填写有误!',
// });
// }
// }
// }
};
// if (componentProps['events']) {
// for (const eventKey in componentProps['events']) {
// try {
// const event = new Function(
// 'schema',
// 'formModel',
// 'formActionType',
// `${componentProps['events'][eventKey]}`,
// );
// componentProps['on' + upperFirst(eventKey)] = function () {
// event(props.schema, formModel, props.formApi);
// };
// } catch (error) {
// console.log('error', error);
// notification.error({
// message: 'Tip',
// description: '触发事件填写有误!',
// });
// }
// }
// }
//获取表单值 慎用 建议直接页面直接操作formModel数据
const getFieldsValue = (): Recordable => {
return toRaw(unref(formModel));
......
<template>
<div class="pt-4">
<SimpleForm
......@@ -16,6 +15,7 @@
import { formProps, formEventConfigs } from './config';
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
import { addMesProductionTask, getMesProductionTask, updateMesProductionTask } from '/@/api/scgl/scrw';
import { getRokeRouting } from '/@/api/jcsj/gylx';
import { cloneDeep, isString } from 'lodash-es';
import { FormDataProps } from '/@/components/Designer/src/types';
import { usePermission } from '/@/hooks/web/usePermission';
......@@ -25,7 +25,11 @@
import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm';
import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig';
import { useRouter } from 'vue-router';
import { notification } from 'ant-design-vue';
import axios from 'axios';
import { getEnvConfig } from '/@/build/utils';
import { log } from 'node:console';
const { filterFormSchemaAuth } = usePermission();
const RowKey = 'id';
......@@ -42,7 +46,8 @@
});
const state = reactive({
formModel: {},
formInfo:{formId:'',formName:''}
formInfo:{formId:'',formName:''},
isInitializing: false
});
const { currentRoute } = useRouter();
watch(
......@@ -54,7 +59,59 @@
deep: true,
},
);
// Watch for changes to BOM field and call API
watch(
() => state.formModel.bom,
async (newBomId) => {
if (newBomId && !state.isInitializing) {
try {
const apiUrl = import.meta.env.VITE_GLOB_API_URL || '';
const response = await axios.get(apiUrl + '/magic-api/jcxx/wlxList', { params: { bomId: newBomId } });
state.formModel.mesWarehouseMaterialList = []
// Process API response data and assign to material list
state.formModel.mesWarehouseMaterialList = response.data.data.map(item => ({
wlbh: item.wlbh,
wlmc: item.wlmc,
blsl: item.wlsl,
kcl: item.kcl,
khbz: item.khbz,
nkbz: item.nkbz,
sftl: item.sftl,
wlId: item.id
}
)
);
// state.formModel.mesWarehouseMaterialList = materialList;
} catch (error) {
notification.error({ message: '获取物料清单失败' });
}
}
}
);
// Watch for changes to process route field and call API
watch(
() => state.formModel.gylx,
async (newGylxId) => {
if (newGylxId && !state.isInitializing) {
try {
const response = await getRokeRouting(newGylxId);
// Assign the process list from API response to production order list with field mapping
state.formModel.mesProductionGongdanList = response.rokeRoutingProcessList.map(item => ({
gxbh: item.code, // 工序编号 → 工序编号
gxmc: item.name, // 工序名称 → 工序名称
gxId: item.processId // 工序ID → 工序ID
}));
} catch (error) {
notification.error({ message: '获取工艺路线详情失败' });
}
}
}
);
onMounted(async () => {
try {
if (props.fromPage == FromPageType.MENU) {
......@@ -110,14 +167,17 @@
// 根据行唯一ID查询行数据,并设置表单数据 【编辑】
async function setFormDataFromId(rowId) {
try {
const record = await getMesProductionTask(rowId);
state.isInitializing = true;
const record = await getMesProductionTask(rowId);
setFieldsValue(record);
state.formModel = record;
await getFormDataEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:获取表单数据
formProps.schemas, true, state.formInfo.formName, state.formInfo.formId); //表单事件:获取表单数据
} catch (error) {
} finally {
state.isInitializing = false;
}
}
// 辅助返回表单数据
......@@ -189,14 +249,9 @@
state.formModel = formModels;
setFieldsValue(formModels);
} catch (error) {}
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:初始化表单
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:加载表单
}
function handleChange(val) {
state.formModel = val;
emits('update:value', val);
}
async function sendMessageForAllIframe() {
......@@ -220,6 +275,4 @@
getFieldsValue,
sendMessageForAllIframe
});
</script>
\ No newline at end of file
</script>
\ No newline at end of file
......@@ -131,6 +131,7 @@
function handleClose() {
formRef.value.resetFields();
closeModal();
}
</script>
......
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