view.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. const excludeAreas = ['山东', '广西'];
  36. const contactMap = {
  37. '山东': '王洪生18660778328',
  38. '广西': '陈叶婷15607807379',
  39. };
  40. $('#interface-export-confirm').click(async function () {
  41. const pr = new SCComponent.InitProgressBar();
  42. try {
  43. let dom = $('#export-parent-area')[0];
  44. if (excludeAreas.includes(dom.options[dom.selectedIndex].text) && userMobile !== '15919278500') {
  45. const message = `尊敬的用户:<br>
  46. 感谢您一直以来对纵横的信任和支持,为了更好地坚守初心,持续为您提供高质量的产品与服务,纵横公路养护云造价已升级为大司空云计价。<br>
  47. 请联系当地客服免费升级账号,使用大司空云计价继续导出导入电子招投标文件。<br>
  48. 当地服务热线:${contactMap[dom.options[dom.selectedIndex].text] || '王洪生18660778328'}<br>
  49. 全国服务热线:0756-3850888,企业QQ:800003850<br>
  50. 请点链接进入大司空云计价:<a href="https://dsk.smartcost.com.cn">https://dsk.smartcost.com.cn</a>`;
  51. window.alert(message);
  52. return;
  53. }
  54. if (dom.options[dom.selectedIndex].text === '广西') {
  55. if ($('#certifyInputForGX')[0].value === null || $('#certifyInputForGX')[0].value.trim() === '') {
  56. throw '请输入验证码。';
  57. }
  58. }
  59. if (dom.options[dom.selectedIndex].text === '新疆') {
  60. if ($('#certifyInputForXJ')[0].value === null || $('#certifyInputForXJ')[0].value.trim() === '') {
  61. throw '请输入验证码。';
  62. }
  63. }
  64. const checkedDatas = $('#interface-export-modal input[type="checkbox"]:checked');
  65. if (!checkedDatas.length) {
  66. throw '请勾选导出文件。';
  67. }
  68. const parentArea = $('#export-parent-area').val();
  69. const subArea = $('#export-sub-area').val();
  70. if (subArea === '池州' && projectObj.project.property.boqType !== 1) {
  71. if ($('#certifyInputForAH_CZ')[0].value === null || $('#certifyInputForAH_CZ')[0].value.trim() === '') {
  72. throw '请输入验证码。';
  73. }
  74. }
  75. if (!parentArea || !subArea) {
  76. throw '请选择有效地区。';
  77. }
  78. // 按照地区动态加载导出脚本
  79. const areaKey = `${parentArea}@${subArea}`;
  80. await STD_INTERFACE.loadScriptByArea(areaKey, STD_INTERFACE.ScriptType.EXPORT);
  81. if (STATE.exporting) {
  82. return;
  83. }
  84. STATE.exporting = true;
  85. if (!_exportCache || !_exportCache.length) {
  86. pr.start('导出数据接口', '正在导出文件,请稍候……');
  87. for (const checkedData of checkedDatas) {
  88. const boqType = parseInt($(checkedData).val());
  89. const requestForSummaryInfo = INTERFACE_EXPORT.requestForSummaryInfo || null;
  90. const projectID = projectObj.project.ID();
  91. const exportData = await _base.extractExportData(INTERFACE_EXPORT.entry, requestForSummaryInfo, boqType, areaKey, projectID, userID);
  92. const failList = _util.transformFailList(_cache.getItem('failList'));
  93. if (failList.length) {
  94. // 自检提示错误,打断导出
  95. setHeightByInfo(failList);
  96. throw failList.join('<br/>');
  97. }
  98. _exportCache.push(...exportData);
  99. }
  100. }
  101. if (_exportCache && _exportCache.length) {
  102. // 导出文件
  103. await _base.exportFile(_exportCache, INTERFACE_EXPORT.saveAsFile || INTERFACE_EXPORT_BASE.defaultSaveAs);
  104. }
  105. $('#interface-export-modal').modal('hide');
  106. } catch (err) {
  107. console.log(err);
  108. alert(err);
  109. } finally {
  110. _cache.setItem('failList', []);
  111. pr.end();
  112. setTimeout(() => {
  113. STATE.exporting = false;
  114. }, 300);
  115. }
  116. });
  117. //导出窗口--------
  118. $('#interface-export-modal').on('hide.bs.modal', function () {
  119. resetState();
  120. STATE.checking = false;
  121. STATE.exporting = false;
  122. $('#interface-export-modal input[type="checkbox"]:eq(0)').prop('checked', true);
  123. });
  124. $('#interface-export-modal input[type="checkbox"]').click(function () {
  125. resetState();
  126. });
  127. }
  128. return { exportListener, resetState }
  129. })();
  130. $(document).ready(() => {
  131. $('#interface-export-modal').on('show.bs.modal', () => STD_INTERFACE.initInterfaceAreas($('#export-parent-area'), $('#export-sub-area')));
  132. EXPORT_VIEW.exportListener();
  133. })
  134. function bidAreaSelectChange(dom) {
  135. const subArea = $('#export-sub-area').val();
  136. if (dom.options[dom.selectedIndex].text === '广西') {
  137. $('#certifyDivForGX')[0].style.display = "";
  138. $('#certifyDivForXJ')[0].style.display = "none";
  139. $('#certifyDivForAH_CZ')[0].style.display = "none";
  140. $('#certifyInputForGX')[0].value = '';
  141. let gxDom1 = $('#lblTtlDiv');
  142. if (gxDom1 && gxDom1.length > 0) {
  143. gxDom1[0].style.display = "none";
  144. }
  145. let gxDom2 = $('#bidCtlDiv');
  146. if (gxDom2 && gxDom2.length > 0) {
  147. gxDom2[0].style.display = "none";
  148. }
  149. } else if (dom.options[dom.selectedIndex].text === '新疆') {
  150. //certifyDivForXJ
  151. $('#certifyDivForXJ')[0].style.display = "";
  152. $('#certifyDivForGX')[0].style.display = "none";
  153. $('#certifyDivForAH_CZ')[0].style.display = "none";
  154. $('#certifyInputForXJ')[0].value = '';
  155. let gxDom1 = $('#lblTtlDiv');
  156. if (gxDom1 && gxDom1.length > 0) {
  157. gxDom1[0].style.display = "none";
  158. }
  159. let gxDom2 = $('#bidCtlDiv');
  160. if (gxDom2 && gxDom2.length > 0) {
  161. gxDom2[0].style.display = "none";
  162. }
  163. } else if (projectObj.project.property.boqType !== 1 && (dom.options[dom.selectedIndex].text === '池州' || (dom.options[dom.selectedIndex].text === '安徽' && subArea === '池州'))) {
  164. $('#certifyDivForXJ')[0].style.display = "none";
  165. $('#certifyDivForGX')[0].style.display = "none";
  166. $('#certifyDivForAH_CZ')[0].style.display = "";
  167. $('#certifyInputForAH_CZ')[0].value = '';
  168. //
  169. let gxDom1 = $('#lblTtlDiv');
  170. if (gxDom1 && gxDom1.length > 0) {
  171. gxDom1[0].style.display = "none";
  172. }
  173. let gxDom2 = $('#bidCtlDiv');
  174. if (gxDom2 && gxDom2.length > 0) {
  175. gxDom2[0].style.display = "none";
  176. }
  177. } else {
  178. $('#certifyDivForXJ')[0].style.display = "none";
  179. $('#certifyDivForGX')[0].style.display = "none";
  180. $('#certifyDivForAH_CZ')[0].style.display = "none";
  181. let gxDom1 = $('#lblTtlDiv');
  182. if (gxDom1 && gxDom1.length > 0) {
  183. gxDom1[0].style.display = "";
  184. }
  185. let gxDom2 = $('#bidCtlDiv');
  186. if (gxDom2 && gxDom2.length > 0) {
  187. gxDom2[0].style.display = "";
  188. }
  189. }
  190. }