change_information.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. 'use strict';
  2. /**
  3. * 变更令详细页js
  4. *
  5. * @author EllisRan.
  6. * @date 2018/11/22
  7. * @version
  8. */
  9. const is_numeric = (value) => {
  10. if (typeof(value) === 'object') {
  11. return false;
  12. } else {
  13. return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
  14. }
  15. };
  16. $(document).ready(() => {
  17. const cca = getLocalCache('change-checkbox-account-' + accountId);
  18. if (cca !== null && cca !== undefined) {
  19. $('#customCheck1').prop('checked', cca !== 'false');
  20. }
  21. changeSpreadSheet.setColumnVisible(3,$('#customCheck1').is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
  22. // 变更详情展示和隐藏
  23. $('.change-detail-checkbox').on('click', function (e) {
  24. if($(e.target).is('label')){
  25. return;
  26. }
  27. // // 设置用户项目本地记录展示和隐藏情况
  28. setLocalCache('change-checkbox-account-'+ accountId, $(this).is(':checked'));
  29. changeSpreadSheet.setColumnVisible(3,$(this).is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
  30. });
  31. //tab change
  32. $('a[data-toggle="tab"]').on('shown.bs.tab', function () {
  33. const tab = $(this).data('tab');
  34. if (tab === 'bgfujian') {
  35. $('#fujian_btn').show();
  36. } else {
  37. $('#fujian_btn').hide();
  38. }
  39. });
  40. $('#add-bj').on('click', 'input[type="checkbox"]', function () {
  41. const isCheck = $(this).prop('checked');
  42. if (isCheck) {
  43. $('#add-bj input[type="checkbox"]').each(function () {
  44. $(this).prop('checked', false)
  45. });
  46. $(this).prop('checked', true)
  47. }
  48. });
  49. $('#bg-copy').click(function() {
  50. const cid = $('#add-bj input:checked').data('id');
  51. postData(window.location.pathname + '/copy', cid, function () {
  52. window.location.reload();
  53. })
  54. });
  55. // 上传附件
  56. $('#upload-file-btn').click(function () {
  57. const files = $('#upload-file')[0].files;
  58. const formData = new FormData();
  59. formData.append('cid', $('#changeId').val());
  60. formData.append('tid', $('#tenderId').val());
  61. for (const file of files) {
  62. if (file === undefined) {
  63. toastr.error('未选择上传文件!');
  64. return false;
  65. }
  66. const filesize = file.size;
  67. if (filesize > 30 * 1024 * 1024) {
  68. toastr.error('文件大小过大!');
  69. return false;
  70. }
  71. const fileext = '.' + file.name.toLowerCase().split('.').splice(-1)[0];
  72. if (whiteList.indexOf(fileext) === -1) {
  73. toastr.error('只能上传指定格式的附件!');
  74. return false;
  75. }
  76. formData.append('size', filesize);
  77. formData.append('file[]', file);
  78. }
  79. if (auditList.findIndex(item => item.uid === parseInt(accountId)) === -1) {
  80. return toastr.error('暂无权限上传!')
  81. }
  82. postDataWithFile(window.location.pathname + '/file/upload', formData, function (data) {
  83. $('#addfujian').modal('hide');
  84. let html = '';
  85. let index = $('#attList tr').length + 1;
  86. for (const fileInfo of data) {
  87. html += '<tr> ' +
  88. `<td width="20"><input type="checkbox" class="check-file" file-id=${fileInfo.id}></td>` +
  89. '<td>' + index + '</td> ' +
  90. `<td><a href="javascript: void(0);" class="file-atn" f-id="${fileInfo.id}">${fileInfo.filename}${fileInfo.fileext}</a></td>`+
  91. '<td>' + fileInfo.in_time + '<br>' + fileInfo.filesize + '</td> ' +
  92. `<td><a href="/change/download/file/${fileInfo.id}" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>`+
  93. ( auditStatus === 4 ?
  94. fileInfo.extra_upload ? `<a class="mr-2 delete-file" data-attid="${fileInfo.id}" title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : ''
  95. : ` <a href="javascript:void(0);" class="mr-2 delete-file" data-attid="${fileInfo.id}" title="删除附件"><span class="fa fa-trash text-danger"></span></a>`)+
  96. `</td>`+
  97. // '<td> <a class="btn btn-light btn-sm delete-file" data-attid="' + fileInfo.id + '" title="删除附件"><span class="fa fa-trash text-danger"></span></a> </td> ' +
  98. '</tr>';
  99. ++index;
  100. }
  101. $('#attList').append(html);
  102. }, function () {
  103. });
  104. $('#upload-file').val('');
  105. });
  106. // 删除附件
  107. $('body').on('click', '.delete-file', function () {
  108. let attid = $(this).data('attid');
  109. let self = $(this);
  110. const data = {id: attid};
  111. postData(window.location.pathname + '/file/delete', data, function (result) {
  112. self.parents('tr').remove();
  113. // 重新排序
  114. let newsort = 1;
  115. $('#attList tr').each(function(){
  116. $(this).children('td').eq(1).text(newsort);
  117. newsort++;
  118. });
  119. });
  120. });
  121. // /change/download/file/
  122. $('#attList').on('click', '.file-atn', function() {
  123. const id = $(this).attr('f-id');
  124. postData(`/change/download/file/${id}`, {}, (data) => {
  125. const { filepath } = data;
  126. $('#file-upload').attr('href', filepath);
  127. $('#file-upload')[0].click();
  128. })
  129. });
  130. $('#attList').on('click', '.check-file', function() {
  131. const checkedList = $('#attList').find('input:checked');
  132. const childs = $('#attList').children().length;
  133. const checkBox = $('#check-all-file');
  134. if (checkedList.length === childs) {
  135. checkBox.prop("checked", true);
  136. } else {
  137. checkBox.prop("checked", false);
  138. }
  139. });
  140. $('#check-all-file').click(function() {
  141. const isCheck = $(this).is(':checked');
  142. $('#attList').children().each(function() {
  143. $(this).find('input:checkbox').prop("checked", isCheck);
  144. })
  145. });
  146. $('#bach-download').click(function() {
  147. const fileIds = [];
  148. $( '#attList .check-file:checked').each(function() {
  149. const fileId = $(this).attr('file-id');
  150. fileId && fileIds.push(fileId);
  151. });
  152. if (fileIds.length) {
  153. const tid = $('#tenderId').val();
  154. const cid = $('#changeId').val();
  155. $('#downloadZip').attr('href', `/tender/${tid}/change/${cid}/download/compresse-file?fileIds=${JSON.stringify(fileIds)}`);
  156. $('#downloadZip')[0].click();
  157. }
  158. });
  159. $.subMenu({
  160. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  161. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  162. key: 'menu.1.0.0',
  163. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  164. callback: function (info) {
  165. if (info.mini) {
  166. $('.panel-title').addClass('fluid');
  167. $('#sub-menu').removeClass('panel-sidebar');
  168. } else {
  169. $('.panel-title').removeClass('fluid');
  170. $('#sub-menu').addClass('panel-sidebar');
  171. }
  172. autoFlashHeight();
  173. changeSpread.refresh();
  174. }
  175. });
  176. });
  177. function findDecimal(unit) {
  178. let value = precision.other.value;
  179. const changeUnits = precision;
  180. for (const d in changeUnits) {
  181. if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
  182. value = changeUnits[d].value;
  183. break;
  184. }
  185. }
  186. return value;
  187. }