let weekDateArr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']; let personTypeArr = ['省公司带班领导', '建设分公司值班主任', '值长', '副值长', '值班员1', '值班员2', '值班员3', '值班员4', '值班员5', '值班员6', '值班员7', '早班值班员', '晚班值班员', '晚班(日报)']; let personTypeArr2 = ['省公司带班领导', '建设分公司值班主任', '值长', '值班员']; let trData = [7, 7, 1, 1, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]; // 省公司带班领导、建设分公司值班主任、值长、副值长 let personList = [], dateRangeParam; let objsArr = []; // 表格赋值 function setTableData(dateRange) { let html = ''; let dateArr = dateRange.split('~'); let weekArr = getAllDate(dateArr[0], dateArr[1]); $.each(weekArr, function (index, item) { html += '

' + setDate(item) + '

' + weekDateArr[index] + '

' }) html += '' html += '' $.each(personTypeArr, function (index, item) { html += '' + '' + item + '' + setTd(index, trData[index], weekArr) + '' }) html += '' $('.classTable').empty().append(html) setSelData(); } // 省公司带班领导、建设分公司值班主任、值长、副值长赋值 function setPersonListData(data) { $.each(personTypeArr2, function (index, item) { let list = []; list.push(data.filter(item2 => { if (item2.post && item2.post.indexOf(item) != -1) { return item2 } })) personList.push(list) }) } function setTd(index, value, date) { let html = ''; if (value === 7) { for (let i = 0; i < 7; i++) { if (index === 0 || index === 1 || index === 2 || index === 3) { html += '
' } else { html += '
' } } } else { html += '
' } return html; } // 下拉选赋值 function setSelData() { let list = personList[0][0]; let list2 = personList[1][0]; let list3 = personList[2][0]; let list4 = personList[3][0]; setPerson(list, 1, 7); // 省公司带班领导 setPerson(list2, 2, 7); // 建设分公司值班主任 setPerson(list3, 3, 1); // 值长 setPerson(list3, 4, 1); // 副值长 for (let i = 5; i <= 14; i++) { setPerson(list4, i, 7); // 值班员 } } function setPerson(data, idx, num) { let parseData = []; $.each(data, function (index, item) { parseData.push({ value: parseInt(item.id), name: item.userName }) }) let color = '#BFBFBF'; /* let html = '' */ let objArr = []; for (let index = 1; index <= num; index++) { let html = '
'; $('#value' + idx + '' + index).empty().append(html); let ins = selectInput.render({ elem: '#select' + (idx + '' + index) + '', data: parseData, placeholder: '请输入/请选择', name: 'select' + (idx) + '', initValue: null, hasCut: true, // 是否允许剪贴 hasSelectIcon: true, layVerType: 'tips', layFilter: 'select' + (idx) + '', //同layui form参数lay-filter layVerify: 'required', //同layui form参数lay-verify remoteSearch: false, // 是否启用远程搜索 默认是false,和远程搜索回调保存同步 maxlength: '20', //最大输入 }); objArr.push(ins); } objsArr.push(objArr); // layui.form.render(); } // 下拉选选中 function changeColor(that) { let value = $(that).val(); if (value) { $(that).css('color', '#262626'); } else { $(that).css('color', '#BFBFBF'); } } function getTableData() { // 省公司领导、建设分公司值班主任、值长、副值长、值班员1-7、早班值班员、晚班值班员、晚班(日报) let list = []; for (let i = 1; i <= 14; i++) { let dataList = getSelectData(i); list.push(dataList) } return list; } function getSelectData(index) { let list = []; let objArr = objsArr[index - 1]; $.each(objArr, function (idx, object) { let userId = object.getValue(); let userName = object.getNameByValue(userId); if (!userId) { userId = -1; userName = $('input[name="select' + index + '"]').eq(idx).val(); } let date = $('input[name="select' + index + '"]').eq(idx).parents('.td-div').attr('date'); let type = index; if (index === 12) { type = 14; } else if (index === 13) { type = 12 } else if (index === 14) { type = 13 } let obj = { 'userId': setValueData(userId), 'userName': setValueData(userName), 'date': setValueData(date), 'type': type + '' }; if (index !== 1 || index !== 2 || index !== 3 || index !== 4) { let remark = $('input[name="select' + index + '"]').eq(idx).parents('.select-div-' + index + '').next().val(); obj.remark = setValueData(remark, 1); } list.push(obj) }) /* $('input[name="select' + index + '"]').each(function (index2) { let userId = $(this).val(); let userName = $(this).find('option:selected').text(); // console.log('userId:'+userId); // console.log('userName:'+userName); let date = $(this).parents('.td-div').attr('date'); let obj = { 'userId': setValueData(userId), 'userName': setValueData(userName), 'date': setValueData(date), 'type': index + '' }; if (index !== 1 || index !== 2 || index !== 3 || index !== 4) { let remark = $(this).parents('.select-div-' + index + '').next().val(); obj.remark = setValueData(remark, 1); } list.push(obj) }) */ return list; } function setValueData(value, type) { if (!value || value === '请选择') { return ''; } return value; } function setFormData(list) { // console.log(list); // console.log(objsArr); $.each(list, function (index, item) { let objArr = objsArr[index]; index = index + 1 $.each(objArr, function (idx, object) { if (item[idx] && item[idx].userId) { object.setValue(parseInt(item[idx].userId)); } else { object.setValue(null); } // console.log(parseInt(item[idx].userId)); if (index !== 1 || index !== 2 || index !== 3 || index !== 4) { let remark = ''; if(item[index] && item[index].remark){ remark = item[index].remark; } $('input[name="select' + index + '"]').eq(idx).parents('.select-div-' + index + '').next().val(remark); } }) /* $('select[name="select' + index + '"]').each(function (index2) { if (item[index2].userId) { $(this).css('color', '#262626') } else { $(this).css('color', '#BFBFBF') } let userId = $(this).val(item[index2].userId); if (index !== 1 || index !== 2 || index !== 3 || index !== 4) { $(this).parents('.select-div-' + index + '').next().val(item[index2].remark); } }) */ }) layui.form.render(); } // 关闭页面 function closePage(type) { let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引 parent.layer.close(index); //再执行关闭 if (type === 1) { parent.reloadData() } }