change_information.js 7.3 KB

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