48 lines
2.2 KiB
JavaScript
48 lines
2.2 KiB
JavaScript
|
const detailTable = "detail_1";
|
||
|
// 多选字段
|
||
|
const detailMultiFieldId = ModeForm.convertFieldNameToId("model_field", detailTable);
|
||
|
// 单选字段
|
||
|
const detailRadioFieldId = ModeForm.convertFieldNameToId("model_field_ass", detailTable);
|
||
|
// 表单字段名字段
|
||
|
const detailFieldNameId = ModeForm.convertFieldNameToId("model_field_name", detailTable);
|
||
|
// 所属表
|
||
|
const detailFieldTableNameId = ModeForm.convertFieldNameToId("table_name", detailTable);
|
||
|
// 主表还是明细
|
||
|
const detailMainOrDetailId = ModeForm.convertFieldNameToId("main_or_detail", detailTable);
|
||
|
$(()=>{
|
||
|
let chose = {};
|
||
|
ModeForm.bindDetailFieldChangeEvent(detailMultiFieldId, (id, index, val)=>{
|
||
|
console.log('id : ', id);
|
||
|
console.log('index : ', index);
|
||
|
console.log('val : ', val);
|
||
|
if(!val){
|
||
|
return;
|
||
|
}
|
||
|
let fieldMameArr = [];
|
||
|
let tableNameArr = [];
|
||
|
let mainOrDetailArr = [];
|
||
|
val.split(',').forEach(id=>{
|
||
|
ModeForm.changeFieldValue(`${detailRadioFieldId}_${index}`, {
|
||
|
value: id,
|
||
|
specialobj:[
|
||
|
{id:id, name:"field"}
|
||
|
]
|
||
|
})
|
||
|
setTimeout(()=>{
|
||
|
let detailFieldNameIdValue = ModeForm.getFieldValue(`${detailFieldNameId}_${index}`)
|
||
|
let detailFieldTableNameValue = ModeForm.getFieldValue(`${detailFieldTableNameId}_${index}`)
|
||
|
let detailMainOrDetailValue = ModeForm.getFieldValue(`${detailMainOrDetailId}_${index}`);
|
||
|
fieldMameArr.push(detailFieldNameIdValue);
|
||
|
tableNameArr.push(detailFieldTableNameValue);
|
||
|
mainOrDetailArr.push(detailMainOrDetailValue);
|
||
|
},0);
|
||
|
})
|
||
|
console.log('fieldMameArr : ', fieldMameArr)
|
||
|
console.log('tableNameArr : ', tableNameArr)
|
||
|
console.log('mainOrDetailArr : ', mainOrDetailArr)
|
||
|
|
||
|
ModeForm.changeFieldValue(`${detailFieldNameId}_${index}`,{value:fieldMameArr.join(',')})
|
||
|
ModeForm.changeFieldValue(`${detailFieldTableNameId}_${index}`,{value:tableNameArr.join(',')})
|
||
|
ModeForm.changeFieldValue(`${detailMainOrDetailId}_${index}`,{value:mainOrDetailArr.join(',')})
|
||
|
})
|
||
|
})
|