/**
*
*
* @author Zhong
* @date 2019/6/5
* @version
*/
// 导出接口相关
const EXPORT_VIEW = (() => {
'use strict';
const _base = INTERFACE_EXPORT_BASE;
const _util = _base.UTIL;
const _cache = _base.CACHE;
// 导出数据缓存,为了自检完后,再导出的时候不需要重新运行相关提取程序。(暂时取消了自检,但还是留着这个缓存机制)
let _exportCache = [];
// 操作状态
const STATE = {
checking: false, // 自检
exporting: false, // 导出
};
// 回到初始状态,需要清空cache中的数据
function resetState() {
_exportCache = [];
_cache.clear();
}
// 设置提示高度样式
function setHeightByInfo(infos) {
if (infos.length > 20) {
$('#hintBox_caption').addClass('export-check');
}
}
//事件监听
function exportListener() {
// 导出接口
const excludeAreas = ['山东', '广西'];
const contactMap = {
'山东': '王洪生18660778328',
'广西': '陈叶婷15607807379',
};
$('#interface-export-confirm').click(async function () {
const pr = new SCComponent.InitProgressBar();
try {
let dom = $('#export-parent-area')[0];
if (excludeAreas.includes(dom.options[dom.selectedIndex].text) && userMobile !== '15919278500') {
const message = `尊敬的用户:
感谢您一直以来对纵横的信任和支持,为了更好地坚守初心,持续为您提供高质量的产品与服务,纵横公路养护云造价已升级为大司空云计价。
请联系当地客服免费升级账号,使用大司空云计价继续导出导入电子招投标文件。
当地服务热线:${contactMap[dom.options[dom.selectedIndex].text] || '王洪生18660778328'}
全国服务热线:0756-3850888,企业QQ:800003850
请点链接进入大司空云计价:https://dsk.smartcost.com.cn`;
window.alert(message);
return;
}
if (dom.options[dom.selectedIndex].text === '广西') {
if ($('#certifyInputForGX')[0].value === null || $('#certifyInputForGX')[0].value.trim() === '') {
throw '请输入验证码。';
}
}
if (dom.options[dom.selectedIndex].text === '新疆') {
if ($('#certifyInputForXJ')[0].value === null || $('#certifyInputForXJ')[0].value.trim() === '') {
throw '请输入验证码。';
}
}
const checkedDatas = $('#interface-export-modal input[type="checkbox"]:checked');
if (!checkedDatas.length) {
throw '请勾选导出文件。';
}
const parentArea = $('#export-parent-area').val();
const subArea = $('#export-sub-area').val();
if (subArea === '池州' && projectObj.project.property.boqType !== 1) {
if ($('#certifyInputForAH_CZ')[0].value === null || $('#certifyInputForAH_CZ')[0].value.trim() === '') {
throw '请输入验证码。';
}
}
if (!parentArea || !subArea) {
throw '请选择有效地区。';
}
// 按照地区动态加载导出脚本
const areaKey = `${parentArea}@${subArea}`;
await STD_INTERFACE.loadScriptByArea(areaKey, STD_INTERFACE.ScriptType.EXPORT);
if (STATE.exporting) {
return;
}
STATE.exporting = true;
if (!_exportCache || !_exportCache.length) {
pr.start('导出数据接口', '正在导出文件,请稍候……');
for (const checkedData of checkedDatas) {
const boqType = parseInt($(checkedData).val());
const requestForSummaryInfo = INTERFACE_EXPORT.requestForSummaryInfo || null;
const projectID = projectObj.project.ID();
const exportData = await _base.extractExportData(INTERFACE_EXPORT.entry, requestForSummaryInfo, boqType, areaKey, projectID, userID);
const failList = _util.transformFailList(_cache.getItem('failList'));
if (failList.length) {
// 自检提示错误,打断导出
setHeightByInfo(failList);
throw failList.join('
');
}
_exportCache.push(...exportData);
}
}
if (_exportCache && _exportCache.length) {
// 导出文件
await _base.exportFile(_exportCache, INTERFACE_EXPORT.saveAsFile || INTERFACE_EXPORT_BASE.defaultSaveAs);
}
$('#interface-export-modal').modal('hide');
} catch (err) {
console.log(err);
alert(err);
} finally {
_cache.setItem('failList', []);
pr.end();
setTimeout(() => {
STATE.exporting = false;
}, 300);
}
});
//导出窗口--------
$('#interface-export-modal').on('hide.bs.modal', function () {
resetState();
STATE.checking = false;
STATE.exporting = false;
$('#interface-export-modal input[type="checkbox"]:eq(0)').prop('checked', true);
});
$('#interface-export-modal input[type="checkbox"]').click(function () {
resetState();
});
}
return { exportListener, resetState }
})();
$(document).ready(() => {
$('#interface-export-modal').on('show.bs.modal', () => STD_INTERFACE.initInterfaceAreas($('#export-parent-area'), $('#export-sub-area')));
EXPORT_VIEW.exportListener();
})
function bidAreaSelectChange(dom) {
const subArea = $('#export-sub-area').val();
if (dom.options[dom.selectedIndex].text === '广西') {
$('#certifyDivForGX')[0].style.display = "";
$('#certifyDivForXJ')[0].style.display = "none";
$('#certifyDivForAH_CZ')[0].style.display = "none";
$('#certifyInputForGX')[0].value = '';
let gxDom1 = $('#lblTtlDiv');
if (gxDom1 && gxDom1.length > 0) {
gxDom1[0].style.display = "none";
}
let gxDom2 = $('#bidCtlDiv');
if (gxDom2 && gxDom2.length > 0) {
gxDom2[0].style.display = "none";
}
} else if (dom.options[dom.selectedIndex].text === '新疆') {
//certifyDivForXJ
$('#certifyDivForXJ')[0].style.display = "";
$('#certifyDivForGX')[0].style.display = "none";
$('#certifyDivForAH_CZ')[0].style.display = "none";
$('#certifyInputForXJ')[0].value = '';
let gxDom1 = $('#lblTtlDiv');
if (gxDom1 && gxDom1.length > 0) {
gxDom1[0].style.display = "none";
}
let gxDom2 = $('#bidCtlDiv');
if (gxDom2 && gxDom2.length > 0) {
gxDom2[0].style.display = "none";
}
} else if (projectObj.project.property.boqType !== 1 && (dom.options[dom.selectedIndex].text === '池州' || (dom.options[dom.selectedIndex].text === '安徽' && subArea === '池州'))) {
$('#certifyDivForXJ')[0].style.display = "none";
$('#certifyDivForGX')[0].style.display = "none";
$('#certifyDivForAH_CZ')[0].style.display = "";
$('#certifyInputForAH_CZ')[0].value = '';
//
let gxDom1 = $('#lblTtlDiv');
if (gxDom1 && gxDom1.length > 0) {
gxDom1[0].style.display = "none";
}
let gxDom2 = $('#bidCtlDiv');
if (gxDom2 && gxDom2.length > 0) {
gxDom2[0].style.display = "none";
}
} else {
$('#certifyDivForXJ')[0].style.display = "none";
$('#certifyDivForGX')[0].style.display = "none";
$('#certifyDivForAH_CZ')[0].style.display = "none";
let gxDom1 = $('#lblTtlDiv');
if (gxDom1 && gxDom1.length > 0) {
gxDom1[0].style.display = "";
}
let gxDom2 = $('#bidCtlDiv');
if (gxDom2 && gxDom2.length > 0) {
gxDom2[0].style.display = "";
}
}
}