Commit 6af1848b by 胡鑫

生产模块修改

parent 5d28fcfc
...@@ -118,7 +118,7 @@ export interface MesProductionTaskModel { ...@@ -118,7 +118,7 @@ export interface MesProductionTaskModel {
mesProductionGongdanList?: MesProductionGongdanModel; mesProductionGongdanList?: MesProductionGongdanModel;
mesWarehouseMaterialList?: MesWarehouseMaterialModel; mesWarehouseMaterialList?: MesWarehouseMaterialModel[];
} }
/** /**
......
...@@ -585,7 +585,7 @@ ...@@ -585,7 +585,7 @@
} else { } else {
if (schema.componentProps?.['events']) { if (schema.componentProps?.['events']) {
for (const eventKey in schema.componentProps['events']) { for (const eventKey in schema.componentProps['events']) {
if (eventKey !== 'change') return; if (eventKey !== 'change') continue;
try { try {
const event = new Function( const event = new Function(
'schema', 'schema',
...@@ -596,65 +596,30 @@ ...@@ -596,65 +596,30 @@
`${schema.componentProps['events'][eventKey]}`, `${schema.componentProps['events'][eventKey]}`,
); );
schema.componentProps['on' + upperFirst(eventKey)] = function (e, opt) { schema.componentProps['on' + upperFirst(eventKey)] = function (e, opt) {
try {
event(schema, formModel, formApi, e, opt); event(schema, formModel, formApi, e, opt);
};
} catch (error) { } catch (error) {
console.log('error', 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({ notification.error({
message: 'Tip', message: 'Tip',
description: '触发事件填写有误!', description: '触发事件填写有误!',
}); });
} }
} }
};
} catch (error) {
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数据 //获取表单值 慎用 建议直接页面直接操作formModel数据
const getFieldsValue = (): Recordable => { const getFieldsValue = (): Recordable => {
return toRaw(unref(formModel)); return toRaw(unref(formModel));
......
<template> <template>
<div class="pt-4"> <div class="pt-4">
<SimpleForm <SimpleForm
...@@ -16,6 +15,7 @@ ...@@ -16,6 +15,7 @@
import { formProps, formEventConfigs } from './config'; import { formProps, formEventConfigs } from './config';
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue'; import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
import { addMesProductionTask, getMesProductionTask, updateMesProductionTask } from '/@/api/scgl/scrw'; import { addMesProductionTask, getMesProductionTask, updateMesProductionTask } from '/@/api/scgl/scrw';
import { getRokeRouting } from '/@/api/jcsj/gylx';
import { cloneDeep, isString } from 'lodash-es'; import { cloneDeep, isString } from 'lodash-es';
import { FormDataProps } from '/@/components/Designer/src/types'; import { FormDataProps } from '/@/components/Designer/src/types';
import { usePermission } from '/@/hooks/web/usePermission'; import { usePermission } from '/@/hooks/web/usePermission';
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm'; import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm';
import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig'; import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig';
import { useRouter } from 'vue-router'; 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 { filterFormSchemaAuth } = usePermission();
...@@ -42,7 +46,8 @@ ...@@ -42,7 +46,8 @@
}); });
const state = reactive({ const state = reactive({
formModel: {}, formModel: {},
formInfo:{formId:'',formName:''} formInfo:{formId:'',formName:''},
isInitializing: false
}); });
const { currentRoute } = useRouter(); const { currentRoute } = useRouter();
watch( watch(
...@@ -55,6 +60,58 @@ ...@@ -55,6 +60,58 @@
}, },
); );
// 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 () => { onMounted(async () => {
try { try {
if (props.fromPage == FromPageType.MENU) { if (props.fromPage == FromPageType.MENU) {
...@@ -110,14 +167,17 @@ ...@@ -110,14 +167,17 @@
// 根据行唯一ID查询行数据,并设置表单数据 【编辑】 // 根据行唯一ID查询行数据,并设置表单数据 【编辑】
async function setFormDataFromId(rowId) { async function setFormDataFromId(rowId) {
try { try {
state.isInitializing = true;
const record = await getMesProductionTask(rowId); const record = await getMesProductionTask(rowId);
setFieldsValue(record); setFieldsValue(record);
state.formModel = record; state.formModel = record;
await getFormDataEvent(formEventConfigs, state.formModel, await getFormDataEvent(formEventConfigs, state.formModel,
systemFormRef.value, systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:获取表单数据 formProps.schemas, true, state.formInfo.formName, state.formInfo.formId); //表单事件:获取表单数据
} catch (error) { } catch (error) {
} finally {
state.isInitializing = false;
} }
} }
// 辅助返回表单数据 // 辅助返回表单数据
...@@ -189,14 +249,9 @@ ...@@ -189,14 +249,9 @@
state.formModel = formModels; state.formModel = formModels;
setFieldsValue(formModels); setFieldsValue(formModels);
} catch (error) {} } 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) { function handleChange(val) {
state.formModel = val;
emits('update:value', val); emits('update:value', val);
} }
async function sendMessageForAllIframe() { async function sendMessageForAllIframe() {
...@@ -221,5 +276,3 @@ ...@@ -221,5 +276,3 @@
sendMessageForAllIframe sendMessageForAllIframe
}); });
</script> </script>
\ No newline at end of file
\ No newline at end of file
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
function handleClose() { function handleClose() {
formRef.value.resetFields(); formRef.value.resetFields();
closeModal();
} }
</script> </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