1、枚举字段数据筛选
const formUpdate = (formProps, formInstance) => {
generateDynamicSchema(formProps, formInstance.formMethods, {
FFC: [
() => {
return {
SHORT_SVPPS: formProps.model.SVPPS,
};
},
],
CAR_CONF_OPACK: [
() => {
if (initForm.value.PBOM_CODE) {
return { PBOM_CODE: initForm.value.PBOM_CODE };
}
},
],
FROMTO: [
() => {
if (isNullOrUnDef(formProps.model.TPR)) {
return { DELFLAG: '0', IFROM_NAME: null };
}
if (formProps.model.TPR === 'Y') {
return { IFROM_NAME: '试制PR' };
}
if (formProps.model.TPR === 'N') {
return { DELFLAG: '0', IFROM_NAME: '试制领用;COC提供' };
}
},
],
});
function dynamicRules(fieldName) {
const name = fieldName;
const formData = formInstance.formMethods.getData();
return formData.FROMTO === '试制PR' || formData.FROMTO === 'COC提供'
? [
{
required: true,
message: `${t(`antd.views.BU_TVBOM_PBOM_DETAIL_VIEW.${name}`)}${t(
'antd.dic.TMP_MSG.required',
)}`,
},
]
: [];
}
// 是否为装车零件为是 关联字段校验必填
function dynamicRulesAssemale(fieldName) {
const name = fieldName;
return formProps.model.ASSEMBLE !== 'N'
? [
{
required: true,
message: `${t(`antd.views.BU_TVBOM_PBOM_DETAIL_VIEW.${name}`)}${t(
'antd.dic.TMP_MSG.required',
)}`,
},
]
: [];
}
function dynamicRulesSoft(fieldName) {
const name = fieldName;
return formProps.model.INCLUDESOFT === 'Y'
? [
{
required: true,
message: `${t(`antd.views.BU_TVBOM_PBOM_DETAIL_VIEW.${name}`)}${t(
'antd.dic.TMP_MSG.required',
)}`,
},
]
: [];
}
function dynamicRulesSubstitute(fieldName) {
const name = fieldName;
return formProps.model.SUBSTITUTE === 'Y'
? [
{
required: true,
message: `${t(`antd.views.BU_TVBOM_PBOM_DETAIL_VIEW.${name}`)}${t(
'antd.dic.TMP_MSG.required',
)}`,
},
]
: [];
}
async function handleTypsAndLitem(svpps, ffc) {
if (!ffc) {
formInstance.formMethods.setData({ TYPES: undefined, LITEM: undefined });
} else {
const res = await useHttp({
params: {
...commonApi().tmpProject.params,
data: { SHORT_SVPPS: svpps, FFC: ffc },
},
method: 'post',
url: '/api/tmp/bom/baTvbomFfcApp/getOneBySvppsAndFfc',
});
if (res.code === 200) {
if (res.data) {
formInstance.formMethods.setData({
TYPES: res.data.CLASS_CODE,
LITEM: res.data.B_FLAG ? 'Y' : 'N',
});
} else {
formInstance.formMethods.setData({ TYPES: undefined, LITEM: undefined });
}
}
}
}
const schema = [
{
dataIndex: 'FFC',
fieldProps: {
onChange: ffc => {
setFormDynamicField('FFC', formInstance.formMethods, 'FFC_CN', 'FFC_CHN');
setFormDynamicField('FFC', formInstance.formMethods, 'FFC_EN', 'FFC_EN');
// 根据FFC赋值零件分类和是否大件
handleTypsAndLitem(formProps.model.SVPPS, ffc);
},
},
dynamicRules: () => {
return formProps.model.IS_BLANKFFC &&
(formProps.model.IS_BLANKFFC == 'Y' || formProps.model.IS_BLANKFFC == '是')
? [
{
required: false,
},
]
: [
{
required: true,
message: `${t(`antd.views.BU_TVBOM_PBOM_DETAIL_EDIT_VIEW.FFC`)}${t(
'antd.dic.TMP_MSG.required',
)}`,
},
];
},
},
{
dataIndex: 'FFC_CN',
disabled: () => {
if (
formProps.model.IS_BLANKFFC &&
(formProps.model.IS_BLANKFFC === 'Y' || formProps.model.IS_BLANKFFC == '是')
) {
return false;
}
return true;
},
dynamicRules: () => {
return formProps.model.IS_BLANKFFC &&
(formProps.model.IS_BLANKFFC == 'Y' || formProps.model.IS_BLANKFFC == '是')
? [
{
required: true,
message: `${t(`antd.views.BU_TVBOM_PBOM_DETAIL_EDIT_VIEW.FFC_CN`)}${t(
'antd.dic.TMP_MSG.required',
)}`,
},
]
: [
{
required: false,
},
];
},
},
{
dataIndex: 'FFC_EN',
disabled: () => {
if (
formProps.model.IS_BLANKFFC &&
(formProps.model.IS_BLANKFFC === 'Y' || formProps.model.IS_BLANKFFC == '是')
) {
return false;
}
return true;
},
dynamicRules: () => {
return formProps.model.IS_BLANKFFC &&
(formProps.model.IS_BLANKFFC == 'Y' || formProps.model.IS_BLANKFFC == '是')
? [
{
required: true,
message: `${t(`antd.views.BU_TVBOM_PBOM_DETAIL_EDIT_VIEW.FFC_EN`)}${t(
'antd.dic.TMP_MSG.required',
)}`,
},
]
: [
{
required: false,
},
];
},
},
//功能组
{
dataIndex: 'FGROUP',
fieldProps: {
onChange: () => {
setFormDynamicField('FGROUP', formInstance.formMethods, 'IS_BLANKFFC', 'IS_BLANKFFC');
},
},
},
// 使用单位
{
dataIndex: 'QUNIT',
fieldProps: {
onChange: () => {
setFormDynamicField('QUNIT', formInstance.formMethods, 'QUNIT_NAME', 'UNIT_NAME');
},
},
},
// 重量单位
{
dataIndex: 'WUNIT',
fieldProps: {
onChange: () => {
setFormDynamicField('WUNIT', formInstance.formMethods, 'WUNIT_NAME', 'UNIT_NAME');
},
},
},
// 状态(成熟度)
{
dataIndex: 'MATURITY',
fieldProps: {
onChange: () => {
setFormDynamicField(
'MATURITY',
formInstance.formMethods,
'MATURITY_NAME',
'CSTATE_NAME',
);
},
},
},
// 工程采购级别
{
dataIndex: 'PLEVEL',
fieldProps: {
onChange: () => {
setFormDynamicField('PLEVEL', formInstance.formMethods, 'PLEVEL_NAME', 'CGLEV_NAME');
},
},
},
// 零件使用地点
{
dataIndex: 'PLACE',
fieldProps: {
onChange: () => {
setFormDynamicField('PLACE', formInstance.formMethods, 'PLACE_NAME', 'PLACE_NAME');
},
},
// 2023-6-19 零件使用地点修改为必填
// dynamicRules: () => {
// return dynamicRulesAssemale('PLACE');
// },
},
// 零件来源
{
dataIndex: 'FROMTO',
params: {
url: '/api/tmp/bom/baTvbomItemFrom/getIfrom',
},
fieldProps: {
onChange: () => {
setFormDynamicField('FROMTO', formInstance.formMethods, 'FROMREMARK', 'REMARK');
setFormDynamicField('FROMTO', formInstance.formMethods, 'FROMTO_NAME', 'IFROM_NAME');
},
beforeRequest: (params: any) => {
if (formProps.model.TPR === 'N') {
params.filter = [];
params.filter.push({
field: 'IFROM_NAME',
value: '试制领用;COC提供',
operation: 'IN',
andOrFlag: 'AND',
});
params.filter.push({
field: 'DELFLAG',
value: '0',
operation: '=',
andOrFlag: 'AND',
});
}
return params;
},
},
// 2023-6-19 修改为必填
// dynamicRules: () => {
// return dynamicRulesAssemale('FROMTO');
// },
},
// 供货状态
{
dataIndex: 'SSTATE',
fieldProps: {
onChange: () => {
setFormDynamicField('SSTATE', formInstance.formMethods, 'SSTATE_NAME', 'SSTATE_NAME');
},
},
// 2023-6-19 修改为必填
// dynamicRules: () => {
// return dynamicRulesAssemale('SSTATE');
// },
},
// 数据状态
{
dataIndex: 'DSTATE',
fieldProps: {
onChange: () => {
setFormDynamicField('DSTATE', formInstance.formMethods, 'DSTATE_NAME', 'DSTATE_NAME');
},
},
// 2023-6-19 修改为必填 2023-7-8 修改为关联零件来源
dynamicRules: () => {
return dynamicRules('DSTATE');
},
// disabled: () => {
// if (formProps.model.FROMTO_NAME !== '试制PR' && formProps.model.FROMTO_NAME !== 'COC提供') {
// delete formProps.model.DSTATE;
// }
// return formProps.model.FROMTO_NAME !== '试制PR' && formProps.model.FROMTO_NAME !== 'COC提供';
// },
},
{
dataIndex: 'MP',
dynamicRules: () => {
return dynamicRules('MP');
},
},
{
dataIndex: 'TWOD',
dynamicRules: () => {
return dynamicRules('TWOD');
},
},
{
dataIndex: 'THREED',
dynamicRules: () => {
return dynamicRules('THREED');
},
},
// 是否需要试制PR
{
dataIndex: 'TPR',
fieldProps: {
onChange: () => {
formInstance.formMethods.setData({ FROMTO_NAME: undefined, FROMTO: undefined });
},
},
// 2023-6-19修改 是否需要试制PR修改为必填
// dynamicRules: () => {
// return dynamicRulesAssemale('TPR');
// },
},
// 替代件使用期限
{
dataIndex: 'SLIMIT',
dynamicRules: () => {
return dynamicRulesSubstitute('SLIMIT');
},
},
// 新开发零件的件号
{
dataIndex: 'NEWITEMCODE',
dynamicRules: () => {
return dynamicRulesSubstitute('NEWITEMCODE');
},
},
// KCDS
// {
// dataIndex: 'KCDS',
// dynamicRules: () => {
// return dynamicRulesSubstitute('KCDS');
// },
// },
// 零件使用地点备注
{
dataIndex: 'PLACEREMARK',
dynamicRules: () => {
let placeName = formProps.model.PLACE_NAME;
return placeName === '其他-GA' ||
placeName === '其他-Body' ||
placeName === '其他-Paint'
? [
{
required: true,
message: `${t(`antd.views.BU_TVBOM_PBOM_DETAIL_VIEW.PLACEREMARK`)}${t(
'antd.dic.TMP_MSG.required',
)}`,
},
]
: [];
},
},
// 何时达到OTS
{
dataIndex: 'OTS',
dynamicRules: () => {
let sstateName = formProps.model.SSTATE_NAME;
return sstateName === 'Soft-tool' || sstateName === 'Proto'
? [
{
required: true,
message: `${t(`antd.views.BU_TVBOM_PBOM_DETAIL_VIEW.OTS`)}${t(
'antd.dic.TMP_MSG.required',
)}`,
},
]
: [];
},
},
// 软件件号
{
dataIndex: 'SOFTCODE',
dynamicRules: () => {
return dynamicRulesSoft('SOFTCODE');
},
},
// 软件版本
{
dataIndex: 'SOFTVERSION',
dynamicRules: () => {
return dynamicRulesSoft('SOFTVERSION');
},
},
// ECU软硬件类别
{
dataIndex: 'ECUCLASS',
dynamicRules: () => {
return dynamicRulesSoft('ECUCLASS');
},
},
// ECOS类型
{
dataIndex: 'ECOS',
dynamicRules: () => {
return dynamicRulesSoft('ECOS');
},
},
// ECUNAME
{
dataIndex: 'ECUNAME',
dynamicRules: () => {
return dynamicRulesSoft('ECUNAME');
},
},
// ECUMODULEID
{
dataIndex: 'ECUMODULEID',
dynamicRules: () => {
return dynamicRulesSoft('ECUMODULEID');
},
},
// 灌装软件
{
dataIndex: 'SOFT',
dynamicRules: () => {
return dynamicRulesSoft('SOFT');
},
},
{
dataIndex: 'SVPPS',
params: {
url: '/api/tmp/bom/baTvbomSvpps/getShortSvpps',
replaceValue: 'SHORT_SVPPS',
replaceLabel: 'SHORT_SVPPS',
queryFields: 'SHORT_SVPPS,SVPPS_CHNNAME',
},
fieldProps: {
onChange: () => {
formInstance.formMethods.setData({
FFC: null,
FFC_CN: null,
FFC_EN: null,
TYPES: undefined,
LITEM: undefined,
});
},
},
},
{
dataIndex: 'CAR_CONF_OPACK',
valueType: 'BSelect',
fieldProps: {
multiple: true,
},
params: {
viewName: 'BU_TVBOM_CHANGE_CAR_CONF_OPACK_LISTQUERY',
url: '/api/tmp/bom/buTvbomPbomMain/getCarConfOpackUsedToPBOM',
replaceLabel: 'CAR_CONF_OPACK',
replaceValue: 'CAR_CONF_OPACK',
},
},
{
dataIndex: 'WUNIT',
valueType: 'Select',
fieldProps: {
options: [
{ label: 'KG', value: 'KG' },
{ label: 'G', value: 'G' },
],
},
},
];
formInstance.formMethods.updateSchema(schema, formProps);
};
const addTableData = studioParams => {
const modalParams = {
studioParams: studioParams,
onOk: ({ data }) => {
data.DRE = initForm.value.DRE;
data.PBOM_CODE = initForm.value.PBOM_CODE;
data.VSE_TASK = initForm.value.VSETASK_CODE;
data.DRE_TASK = initForm.value.DRETASK_CODE;
if (data.MP === '') {
data.MP = null;
}
if (data.TWOD === '') {
data.TWOD = null;
}
if (data.THREED === '') {
data.THREED = null;
}
if (data.NEWITEMCODE === '') {
data.NEWITEMCODE = null;
}
const addParams = {
...commonApi().tmpProject.params,
data,
newObject: 'true',
objectID: '',
viewName: `${viewName}_LISTVIEW`,
};
return request
.post('/tmp/bom/buTvbomPbomDetailDreExt/addData', addParams)
.then((res: any) => {
if (res.code == 200) {
message.success(res?.msg);
tableMethods.query();
} else {
return Promise.reject();
}
});
},
onFormUpdate: formUpdate,
};
commonModalShow(modalParams);
};
2、弹出表单修改宽度
直接在view上面修改宽度
3、