view.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. *
  3. *
  4. * @author Zhong
  5. * @date 2019/6/5
  6. * @version
  7. */
  8. // 导出接口相关
  9. const EXPORT_VIEW = (() => {
  10. 'use strict';
  11. const _base = INTERFACE_EXPORT_BASE;
  12. const _util = _base.UTIL;
  13. const _cache = _base.CACHE;
  14. // 导出数据缓存,为了自检完后,再导出的时候不需要重新运行相关提取程序。(暂时取消了自检,但还是留着这个缓存机制)
  15. let _exportCache = [];
  16. // 操作状态
  17. const STATE = {
  18. checking: false, // 自检
  19. exporting: false, // 导出
  20. };
  21. // 回到初始状态,需要清空cache中的数据
  22. function resetState() {
  23. _exportCache = [];
  24. _cache.clear();
  25. }
  26. // 设置提示高度样式
  27. function setHeightByInfo(infos) {
  28. if (infos.length > 20) {
  29. $('#hintBox_caption').addClass('export-check');
  30. }
  31. }
  32. //事件监听
  33. function exportListener() {
  34. // 导出接口
  35. $('#interface-export-confirm').click(async function () {
  36. const pr = new SCComponent.InitProgressBar();
  37. try {
  38. let dom = $('#export-parent-area')[0];
  39. if (dom.options[dom.selectedIndex].text === '山东') {
  40. const message = `尊敬的用户:<br>
  41. 感谢您一直以来对纵横的信任和支持,为了更好地坚守初心,持续为您提供高质量的产品与服务,纵横公路养护云造价已升级为大司空云计价。<br>
  42. 请联系当地客服免费升级账号,使用大司空云计价继续导出导入电子招投标文件。<br>
  43. 当地服务热线:王洪生18660778328<br>
  44. 全国服务热线:0756-3850888,企业QQ:800003850<br>
  45. 请点链接进入大司空云计价:<a href="https://dsk.smartcost.com.cn">https://dsk.smartcost.com.cn</a>`;
  46. window.alert(message);
  47. return;
  48. }
  49. if (dom.options[dom.selectedIndex].text === '广西') {
  50. if ($('#certifyInputForGX')[0].value === null || $('#certifyInputForGX')[0].value.trim() === '') {
  51. throw '请输入验证码。';
  52. }
  53. }
  54. if (dom.options[dom.selectedIndex].text === '新疆') {
  55. if ($('#certifyInputForXJ')[0].value === null || $('#certifyInputForXJ')[0].value.trim() === '') {
  56. throw '请输入验证码。';
  57. }
  58. }
  59. const checkedDatas = $('#interface-export-modal input[type="checkbox"]:checked');
  60. if (!checkedDatas.length) {
  61. throw '请勾选导出文件。';
  62. }
  63. const parentArea = $('#export-parent-area').val();
  64. const subArea = $('#export-sub-area').val();
  65. if (subArea === '池州' && projectObj.project.property.boqType !== 1) {
  66. if ($('#certifyInputForAH_CZ')[0].value === null || $('#certifyInputForAH_CZ')[0].value.trim() === '') {
  67. throw '请输入验证码。';
  68. }
  69. }
  70. if (!parentArea || !subArea) {
  71. throw '请选择有效地区。';
  72. }
  73. // 按照地区动态加载导出脚本
  74. const areaKey = `${parentArea}@${subArea}`;
  75. await STD_INTERFACE.loadScriptByArea(areaKey, STD_INTERFACE.ScriptType.EXPORT);
  76. if (STATE.exporting) {
  77. return;
  78. }
  79. STATE.exporting = true;
  80. if (!_exportCache || !_exportCache.length) {
  81. pr.start('导出数据接口', '正在导出文件,请稍候……');
  82. for (const checkedData of checkedDatas) {
  83. const boqType = parseInt($(checkedData).val());
  84. const requestForSummaryInfo = INTERFACE_EXPORT.requestForSummaryInfo || null;
  85. const projectID = projectObj.project.ID();
  86. const exportData = await _base.extractExportData(INTERFACE_EXPORT.entry, requestForSummaryInfo, boqType, areaKey, projectID, userID);
  87. const failList = _util.transformFailList(_cache.getItem('failList'));
  88. if (failList.length) {
  89. // 自检提示错误,打断导出
  90. setHeightByInfo(failList);
  91. throw failList.join('<br/>');
  92. }
  93. _exportCache.push(...exportData);
  94. }
  95. }
  96. if (_exportCache && _exportCache.length) {
  97. // 导出文件
  98. await _base.exportFile(_exportCache, INTERFACE_EXPORT.saveAsFile || INTERFACE_EXPORT_BASE.defaultSaveAs);
  99. }
  100. $('#interface-export-modal').modal('hide');
  101. } catch (err) {
  102. console.log(err);
  103. alert(err);
  104. } finally {
  105. _cache.setItem('failList', []);
  106. pr.end();
  107. setTimeout(() => {
  108. STATE.exporting = false;
  109. }, 300);
  110. }
  111. });
  112. //导出窗口--------
  113. $('#interface-export-modal').on('hide.bs.modal', function () {
  114. resetState();
  115. STATE.checking = false;
  116. STATE.exporting = false;
  117. $('#interface-export-modal input[type="checkbox"]:eq(0)').prop('checked', true);
  118. });
  119. $('#interface-export-modal input[type="checkbox"]').click(function () {
  120. resetState();
  121. });
  122. }
  123. return { exportListener, resetState }
  124. })();
  125. $(document).ready(() => {
  126. $('#interface-export-modal').on('show.bs.modal', () => STD_INTERFACE.initInterfaceAreas($('#export-parent-area'), $('#export-sub-area')));
  127. EXPORT_VIEW.exportListener();
  128. })
  129. function bidAreaSelectChange(dom) {
  130. const subArea = $('#export-sub-area').val();
  131. if (dom.options[dom.selectedIndex].text === '广西') {
  132. $('#certifyDivForGX')[0].style.display = "";
  133. $('#certifyDivForXJ')[0].style.display = "none";
  134. $('#certifyDivForAH_CZ')[0].style.display = "none";
  135. $('#certifyInputForGX')[0].value = '';
  136. let gxDom1 = $('#lblTtlDiv');
  137. if (gxDom1 && gxDom1.length > 0) {
  138. gxDom1[0].style.display = "none";
  139. }
  140. let gxDom2 = $('#bidCtlDiv');
  141. if (gxDom2 && gxDom2.length > 0) {
  142. gxDom2[0].style.display = "none";
  143. }
  144. } else if (dom.options[dom.selectedIndex].text === '新疆') {
  145. //certifyDivForXJ
  146. $('#certifyDivForXJ')[0].style.display = "";
  147. $('#certifyDivForGX')[0].style.display = "none";
  148. $('#certifyDivForAH_CZ')[0].style.display = "none";
  149. $('#certifyInputForXJ')[0].value = '';
  150. let gxDom1 = $('#lblTtlDiv');
  151. if (gxDom1 && gxDom1.length > 0) {
  152. gxDom1[0].style.display = "none";
  153. }
  154. let gxDom2 = $('#bidCtlDiv');
  155. if (gxDom2 && gxDom2.length > 0) {
  156. gxDom2[0].style.display = "none";
  157. }
  158. } else if (projectObj.project.property.boqType !== 1 && (dom.options[dom.selectedIndex].text === '池州' || (dom.options[dom.selectedIndex].text === '安徽' && subArea === '池州'))) {
  159. $('#certifyDivForXJ')[0].style.display = "none";
  160. $('#certifyDivForGX')[0].style.display = "none";
  161. $('#certifyDivForAH_CZ')[0].style.display = "";
  162. $('#certifyInputForAH_CZ')[0].value = '';
  163. //
  164. let gxDom1 = $('#lblTtlDiv');
  165. if (gxDom1 && gxDom1.length > 0) {
  166. gxDom1[0].style.display = "none";
  167. }
  168. let gxDom2 = $('#bidCtlDiv');
  169. if (gxDom2 && gxDom2.length > 0) {
  170. gxDom2[0].style.display = "none";
  171. }
  172. } else {
  173. $('#certifyDivForXJ')[0].style.display = "none";
  174. $('#certifyDivForGX')[0].style.display = "none";
  175. $('#certifyDivForAH_CZ')[0].style.display = "none";
  176. let gxDom1 = $('#lblTtlDiv');
  177. if (gxDom1 && gxDom1.length > 0) {
  178. gxDom1[0].style.display = "";
  179. }
  180. let gxDom2 = $('#bidCtlDiv');
  181. if (gxDom2 && gxDom2.length > 0) {
  182. gxDom2[0].style.display = "";
  183. }
  184. }
  185. }