IntelligentRecognition/ah-jjsp-web/.svn/pristine/77/77033c2d48e4e4a17c06afbbd26...

159 lines
5.5 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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];
// 省公司带班领导、建设分公司值班主任、值长、副值长
let personList = [], dateRangeParam;
// 表格赋值
function setTableData(dateRange) {
let html = '<thead><tr><td></td>';
let dateArr = dateRange.split('~');
let weekArr = getAllDate(dateArr[0], dateArr[1]);
$.each(weekArr, function (index, item) {
html += '<td><p>' + setDate(item) + '</p><p>' + weekDateArr[index] + '</p></td>'
})
html += '</tr></thead>'
html += '<tbody>'
$.each(personTypeArr, function (index, item) {
html += '<tr>' +
'<td>' + item + '</td>' +
setTd(index, trData[index], weekArr) +
'</tr>'
})
html += '</tbody>'
$('.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 += '<td><div class="td-div" date="' + date[i] + '"><div class="select-div-' + (index + 1) + '"></div></div></td>'
} else {
html += '<td><div class="td-div" date="' + date[i] + '"><div class="select-div-' + (index + 1) + '"></div><input class="layui-input" maxlength="50" autocomplete="off" type="text" name="remark' + (index + 1) + '" placeholder="备注"></div></td>'
}
}
} else {
html += '<td colspan="7"><div class="td-div td-div2" style="padding: 0;" date="' + date[0] + '"><div class="select-div-' + (index + 1) + '"></div></div></td>'
}
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); // 省公司带班领导
setPerson(list2, 2); // 建设分公司值班主任
setPerson(list3, 3); // 值长
setPerson(list3, 4); // 副值长
for (let i = 5; i <= 13; i++) {
setPerson(list4, i); // 值班员
}
}
function setPerson(data, idx) {
let color = '#BFBFBF';
let html = '<select style="color:' + color + ' " class="layui-select select' + idx + '" onchange="changeColor(this)" name="select' + idx + '">';
html += '<option value="">请选择</option>';
$.each(data, function (index, item) {
html += '<option value="' + item.id + '">' + item.userName + '</option>'
})
html += '</select>'
$('.select-div-' + idx).empty().append(html);
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 = [];
$('select[name="select' + index + '"]').each(function () {
let userId = $(this).val();
let userName = $(this).find('option:selected').text();
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) {
$.each(list, function (index, item) {
index = index + 1
$('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);
}
})
})
}
// 关闭页面
function closePage(type) {
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
if (type === 1) {
parent.reloadData()
}
}