ebu_ecology_dev1/javascript/xuanran.wang/shyl/MealOrder.js

45 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

const enable = 0;
// 班级浏览按钮表单字段id
const classFieldId = WfForm.convertFieldNameToId("bjmc");
// 明细1学员id
const detail1StuId = WfForm.convertFieldNameToId("studentId","detail_1");;
// 明细1学员编号
const detail1StuNo = WfForm.convertFieldNameToId("studentNo","detail_1");;
// 明细1学员姓名
const detail1StuName = WfForm.convertFieldNameToId("studentName","detail_1");;
// 明细1班级id
const detail1ClassId = WfForm.convertFieldNameToId("classId","detail_1");
// 主表学员汇总字段
const stuAllField = WfForm.convertFieldNameToId("mxxybhhzfz");
WfForm.bindFieldChangeEvent(classFieldId, function(obj,id,value){
let classId = WfForm.getBrowserShowName(classFieldId);
WfForm.delDetailRow("detail_1", "all");
$.get('/api/wxr/students/getStudentsByClassId',{id:classId},(res)=>{
let obj = JSON.parse(res);
if(obj.code != 200){
WfForm.showMessage(obj.msg);
return;
}
console.log('obj ', obj);
let objData = obj.data;
let responseObj = JSON.parse(objData);
if(!responseObj || !responseObj.data){
WfForm.showMessage(responseObj.msg);
return;
}
objData = responseObj.data;
WfForm.changeFieldValue(stuAllField, {value: ''});
let stuArr = [];
objData.forEach((item)=>{
let detailObj = {};
detailObj[detail1StuId] = { value: item.id };
detailObj[detail1StuNo] = { value: item.studentNo };
detailObj[detail1StuName] = { value: item.studentName };
detailObj[detail1ClassId] = { value: item.classId };
// console.log('detailObj ', detailObj)
WfForm.addDetailRow("detail_1",detailObj);
stuArr.push(item.studentNo);
})
WfForm.changeFieldValue(stuAllField, {value: stuArr.join(',')});
})
});