'use strict';
/**
* 期计量 - 期列表页面 js
*
* @author Mai
* @date 2018/12/7
* @version
*/
$(function () {
// 获取审批流程
$('a[data-target="#sp-list" ]').on('click', function () {
const data = {
order: $(this).attr('m-order'),
};
postData('/tender/' + tenderId + '/measure/material/auditors', data, function (result) {
const materialAuditor = result.materialAuditor;
const auditors = result.auditors;
const auditHistory = result.auditHistory;
// 生成左边列表流程
const lefthtml = [];
lefthtml.push('
'+ materialAuditor.name +' '+ materialAuditor.role +'');
for (const [index,a] of auditors.entries()) {
if (index+1 === auditors.length) {
lefthtml.push(' '+ a.name +' '+ a.role +'');
} else {
lefthtml.push(' '+ a.name +' '+ a.role +'');
}
}
$('#auditor-list').html(lefthtml.join(''));
// 生成右边列表流程
const righthtml = [];
for(const ah of auditHistory) {
righthtml.push('');
for (let iA = 0; iA < ah.length; iA++) {
if (iA === 0) {
righthtml.push('- ');
righthtml.push(''+ (auditHistory.indexOf(ah) > 0 ? '重新' : '') +'上报');
righthtml.push('
');
righthtml.push(' '+ materialAuditor.name +' '+ materialAuditor.role +'
');
righthtml.push('' + (ah[iA].begin_time ? moment(ah[iA].begin_time).format('YYYY-MM-DD') : '') + '
');
righthtml.push('- ');
if (ah[iA].status !== auditConst.status.uncheck) {
righthtml.push('' + auditConst.statusString[ah[iA].status] + (ah[iA].status === auditConst.status.checkNo ? ' ' + materialAuditor.name : '') + '');
}
righthtml.push('
'+ ah[iA].name +' '+ ah[iA].role +'
');
if (ah[iA].status === auditConst.status.checked || ah[iA].status === auditConst.status.checkNo) {
righthtml.push(''+ ah[iA].opinion +'
');
righthtml.push(''+ (ah[iA].end_time ? moment(ah[iA].end_time).format('YYYY-MM-DD') : '') +'
');
}
righthtml.push(' ');
} else if (iA === ah.length - 1) {
righthtml.push('- ');
if (ah[iA].status !== auditConst.status.uncheck) {
righthtml.push('' + auditConst.statusString[ah[iA].status] + (ah[iA].status === auditConst.status.checkNo ? ' ' + materialAuditor.name : '') + '');
}
righthtml.push('
'+ ah[iA].name +' '+ ah[iA].role +'
');
if (ah[iA].status === auditConst.status.checked || ah[iA].status === auditConst.status.checkNo) {
righthtml.push(''+ ah[iA].opinion +'
');
righthtml.push(''+ (ah[iA].end_time ? moment(ah[iA].end_time).format('YYYY-MM-DD') : '') +'
');
}
righthtml.push(' ');
} else {
righthtml.push('- ');
if (ah[iA].status !== auditConst.status.uncheck) {
righthtml.push('' + auditConst.statusString[ah[iA].status] + (ah[iA].status === auditConst.status.checkNo ? ' ' + materialAuditor.name : '') + '');
}
righthtml.push('
'+ ah[iA].name +' '+ ah[iA].role +'
');
if (ah[iA].status === auditConst.status.checked || ah[iA].status === auditConst.status.checkNo) {
righthtml.push(''+ ah[iA].opinion +'
');
righthtml.push(''+ (ah[iA].end_time ? moment(ah[iA].end_time).format('YYYY-MM-DD') : '') +'
');
}
righthtml.push(' ');
}
}
righthtml.push('
');
}
$('#auditor-list2').html(righthtml.join(''));
});
});
// 计量期选中
$('.select-stage-order').on('click', function () {
const stageList = $('.select-stage-order:checked');
if (stageList.length === 0) {
$('#show_order').hide();
$('#s_order').val('');
} else {
const order_array = [];
for (let s = 0; s < stageList.length; s++) {
order_array.push(stageList.eq(s).data('order'));
// console.log(stageList.eq(s));
}
$('#show_order').html('第' + order_array.join(',') + '期');
$('#show_order').show();
$('#s_order').val(order_array.join(','));
}
});
// 提交表单判断
$('#addMaterial').click(function () {
if ($('#s_order').val() == '') {
toastr.error('请选择计量期');
return false;
}
})
});