change_plan_information.js 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author EllisRan
  6. * @date 2022/01/21
  7. * @version
  8. */
  9. $(document).ready(() => {
  10. $.subMenu({
  11. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  12. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  13. key: 'menu.1.0.0',
  14. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  15. callback: function (info) {
  16. if (info.mini) {
  17. $('.panel-title').addClass('fluid');
  18. $('#sub-menu').removeClass('panel-sidebar');
  19. } else {
  20. $('.panel-title').removeClass('fluid');
  21. $('#sub-menu').addClass('panel-sidebar');
  22. }
  23. autoFlashHeight();
  24. }
  25. });
  26. handleFileList(fileList);
  27. $('#file-ok').click(function () {
  28. const files = Array.from($('#file-modal')[0].files)
  29. const valiData = files.map(v => {
  30. const ext = v.name.substring(v.name.lastIndexOf('.') + 1)
  31. return {
  32. size: v.size,
  33. ext
  34. }
  35. });
  36. if (validateFiles(valiData)) {
  37. if (files.length) {
  38. const formData = new FormData();
  39. files.forEach(file => {
  40. formData.append('name', file.name);
  41. formData.append('size', file.size);
  42. formData.append('file', file);
  43. })
  44. postDataWithFile(preUrl + '/file/upload', formData, function (result) {
  45. handleFileList(result);
  46. $('#file-cancel').click();
  47. });
  48. }
  49. }
  50. })
  51. function handleFileList(files = []) {
  52. $('#file-content').empty();
  53. // const { uncheck, checkNo } = auditConst.status
  54. const newFiles = files.map(file => {
  55. let showDel = false;
  56. if (file.uid === cur_uid) {
  57. // if (!curAuditor) {
  58. // advance.status === uncheck && cur_uid === advance.uid && (showDel = true)
  59. // advance.status === checkNo && cur_uid === advance.uid && (showDel = true)
  60. // } else {
  61. // curAuditor.audit_id === cur_uid && (showDel = true)
  62. // }
  63. if (change.status === auditConst.status.checked) {
  64. showDel = Boolean(file.extra_upload )
  65. } else {
  66. showDel = true
  67. }
  68. }
  69. return {...file, showDel}
  70. })
  71. let html = change.filePermission ? `<tr><td colspan="5"><a href="#addfujian" data-toggle="modal" class="btn btn-primary btn-sm" data-placement="bottom" title="">上传附件</a></td></tr>` : '';
  72. newFiles.forEach((file, idx) => {
  73. if (file.showDel) {
  74. html += `<tr><td>${idx + 1}</td><td><a href="${file.filepath}" target="_blank">${file.filename}</a></td><td>${file.username}</td><td>${moment(file.upload_time).format('YYYY-MM-DD HH:mm:ss')}</td><td><a href="/tender/${file.tid}/change/plan/${file.cpid}/information/file/${file.id}/download" class="mr-2"><i class="fa fa-download"></i></a><a href="javascript: void(0);" class="text-danger file-del" data-id="${file.id}"><i class="fa fa-remove"></i></a></td></tr>`
  75. } else {
  76. html += `<tr><td width="70">${idx + 1}</td><td><a href="${file.filepath}" target="_blank">${file.filename}</a></td><td>${file.username}</td><td>${moment(file.upload_time).format('YYYY-MM-DD HH:mm:ss')}</td><td><a href="/tender/${file.tid}/change/plan/${file.cpid}/information/file/${file.id}/download" class="mr-2"><i class="fa fa-download"></i></a></td></tr>`
  77. }
  78. })
  79. $('#file-content').append(html);
  80. }
  81. $('#file-content').on('click', 'a', function () {
  82. if ($(this).hasClass('file-del')) {
  83. const id = $(this).data('id');
  84. postData(preUrl + '/file/delete', {id}, (result) => {
  85. handleFileList(result);
  86. })
  87. }
  88. });
  89. // 回车提交
  90. $('#plan-table input').on('keypress', function () {
  91. if(window.event.keyCode === 13) {
  92. $(this).blur();
  93. }
  94. });
  95. $('#plan-table input').blur(function () {
  96. const val_name = $(this).data('name');
  97. let val = _.trim($(this).val()) !== '' ? _.trim($(this).val()) : null;
  98. switch(val_name) {
  99. case 'code':
  100. if(!val) {
  101. toastr.error('方案编号不能为空');
  102. $(this).val(change[val_name]);
  103. return false;
  104. }
  105. break;
  106. case 'name':
  107. if(val && val.length > 100) {
  108. toastr.error('名称超过100个字,请缩减名称');
  109. $(this).val(change[val_name]);
  110. return false;
  111. }
  112. break;
  113. default:
  114. if(val && val.length > 255) {
  115. toastr.error('超出字段范围,请缩减');
  116. $(this).val(change[val_name]);
  117. return false;
  118. }
  119. break;
  120. }
  121. if(change[val_name] !== val) {
  122. const _self = $(this);
  123. postData(preUrl + '/save', { name: val_name, val}, function (result) {
  124. change[val_name] = val;
  125. _self.val(change[val_name]);
  126. if (val_name === 'code') {
  127. $('#change-plan-code').text(change[val_name]);
  128. }
  129. }, function () {
  130. _self.val(change[val_name]);
  131. })
  132. } else {
  133. $(this).val(change[val_name]);
  134. }
  135. });
  136. $('#plan-table textarea').blur(function () {
  137. const val_name = $(this).data('name');
  138. let val = _.trim($(this).val()) !== '' ? _.trim($(this).val()) : null;
  139. if(change[val_name] !== val) {
  140. const _self = $(this);
  141. postData(preUrl + '/save', { name: val_name, val}, function (result) {
  142. change[val_name] = val;
  143. _self.val(change[val_name]);
  144. }, function () {
  145. _self.val(change[val_name]);
  146. })
  147. } else {
  148. $(this).val(change[val_name]);
  149. }
  150. });
  151. $('#plan-table select').change(function () {
  152. const val_name = $(this).attr('data-name');
  153. let val = _.trim($(this).val()) !== '' ? _.trim($(this).val()) : null;
  154. if(change[val_name] !== val) {
  155. const _self = $(this);
  156. postData(preUrl + '/save', { name: val_name, val}, function (result) {
  157. change[val_name] = val;
  158. _self.val(change[val_name]);
  159. }, function () {
  160. _self.val(change[val_name]);
  161. })
  162. } else {
  163. $(this).val(change[val_name]);
  164. }
  165. });
  166. const changeSpread = SpreadJsObj.createNewSpread($('#plan-spread')[0]);
  167. const changeSpreadSheet = changeSpread.getActiveSheet();
  168. const style1 = new GC.Spread.Sheets.Style();
  169. style1.locked = true;
  170. const changeSpreadSetting = {
  171. cols: [
  172. {title: '新增单价', colSpan: '1', rowSpan: '2', field: 'new_up', hAlign: 1, width: 35, cellType: 'checkbox', readOnly: 'readOnly.isEdit'},
  173. {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 110, formatter: '@', readOnly: 'readOnly.isEdit'},
  174. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 130, formatter: '@', readOnly: 'readOnly.isEdit'},
  175. {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit', cellType: 'unit', comboItems: changeUnits, comboEdit: true},
  176. {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', getValue: 'getValue.unit_price'},
  177. {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', getValue: 'getValue.oamount'},
  178. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.oa_tp'},
  179. {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', getValue: 'getValue.camount'},
  180. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.ca_tp'},
  181. {title: '批复变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.samount'},
  182. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.sa_tp'},
  183. ],
  184. emptyRows: !readOnly ? 3 : 0,
  185. headRows: 2,
  186. headRowHeight: [25, 25],
  187. defaultRowHeight: 21,
  188. headerFont: '12px 微软雅黑',
  189. font: '12px 微软雅黑',
  190. readOnly: change.status === auditConst.status.checking ? false : readOnly,
  191. localCache: {
  192. key: 'changes-plan-list-spread',
  193. colWidth: true,
  194. }
  195. };
  196. console.log(changeList, change.listAudits);
  197. if (change.status === auditConst.status.checking || change.status === auditConst.status.checked) {
  198. for (const audit of change.listAudits) {
  199. // const userinfo = _.find(auditList2, { 'aid': aid });
  200. const newColcount = {
  201. title: audit.name + ' 审批|数量',
  202. colSpan: '2|1', rowSpan: '1|1',
  203. field: 'audit_amount_' + audit.aid,
  204. hAlign: 2, width: 60, type: 'Number',
  205. readOnly: !(change.shenpiPower && audit.aid === parseInt(cur_uid))
  206. };
  207. const newColTp = {
  208. title: '|金额',
  209. colSpan: '|1', rowSpan: '|1',
  210. field: 'sa_tp_' + audit.aid,
  211. hAlign: 2, width: 80, type: 'Number',
  212. readOnly: true
  213. };
  214. changeSpreadSetting.cols.push(newColcount);
  215. changeSpreadSetting.cols.push(newColTp);
  216. }
  217. }
  218. changeSpreadSetting.cols.push({title: '备注1', colSpan: '1', rowSpan: '2', field: 'ex_memo1', hAlign: 0, width: 110, formatter: '@', readOnly: 'readOnly.isEdit2', cellType: 'ellipsisAutoTip', scrollHeightClass: '.sjs-height-0'});
  219. changeSpreadSetting.cols.push({title: '备注2', colSpan: '1', rowSpan: '2', field: 'ex_memo2', hAlign: 0, width: 110, formatter: '@', readOnly: 'readOnly.isEdit2', cellType: 'ellipsisAutoTip', scrollHeightClass: '.sjs-height-0'});
  220. const changeCol = {
  221. getValue: {
  222. unit_price: function(data) {
  223. return ZhCalc.round(data.unit_price, unitPriceUnit);
  224. },
  225. oa_tp: function (data) {
  226. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount, findDecimal(data.unit))), totalPriceUnit);
  227. },
  228. ca_tp: function (data) {
  229. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
  230. },
  231. oamount: function (data) {
  232. return ZhCalc.round(data.oamount, findDecimal(data.unit));
  233. },
  234. camount: function (data) {
  235. return ZhCalc.round(data.camount, findDecimal(data.unit));
  236. },
  237. samount: function (data) {
  238. return ZhCalc.round(data.samount, findDecimal(data.unit));
  239. },
  240. sa_tp: function (data) {
  241. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.samount, findDecimal(data.unit))), totalPriceUnit);
  242. },
  243. },
  244. readOnly: {
  245. isEdit: function (data) {
  246. return readOnly;
  247. },
  248. isEdit2: function (data) {
  249. return !(!readOnly || change.shenpiPower);
  250. },
  251. },
  252. };
  253. const changeSpreadObj = {
  254. makeSjsFooter: function() {
  255. // 增加汇总行并设为锁定禁止编辑状态
  256. changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
  257. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 1, '合计');
  258. const cellType1 = new GC.Spread.Sheets.CellTypes.Text();
  259. changeSpreadSheet.getCell(changeSpreadSheet.getRowCount() - 1, 0).cellType(cellType1);
  260. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  261. changeSpreadObj.countSum();
  262. },
  263. setAuditValue: function () {
  264. for (const c of changeList) {
  265. for (const audit of change.listAudits) {
  266. c['audit_amount_' + audit.aid] = ZhCalc.round(c['audit_amount_' + audit.aid], findDecimal(c.unit));
  267. c['sa_tp_' + audit.aid] = ZhCalc.round(ZhCalc.mul(c['audit_amount_' + audit.aid], ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit);
  268. }
  269. }
  270. },
  271. setRowValueAndSum: function (data, row, col) {
  272. for (const j in change.listAudits) {
  273. const sum = ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), parseFloat(changeSpreadSheet.getValue(row, 11 + parseInt(j)*2))), totalPriceUnit);
  274. changeSpreadSheet.setValue(row, 12 + j*2, sum !== 0 ? sum : null);
  275. }
  276. // const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, data.spamount), totalPriceUnit);
  277. // changeSpreadSheet.setValue(row, col+1, sum !== 0 ? sum : null);
  278. const count = changeSpreadSetting.cols.length;
  279. if (col+1 >= count - 2) {
  280. return;
  281. }
  282. const rowCount = changeSpreadSheet.getRowCount();
  283. // 用户的数据合计
  284. let audit_sum = 0;
  285. for(let i = 0; i < rowCount - 1; i++){
  286. audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, col+1));
  287. }
  288. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, col+1, audit_sum !== 0 ? audit_sum : null);
  289. },
  290. countSum: function() {
  291. const rowCount = changeSpreadSheet.getRowCount();
  292. let oSum = 0,
  293. cSum = 0,
  294. sSum = 0;
  295. for (let i = 0; i < rowCount - 1; i++) {
  296. oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 6));
  297. cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 8));
  298. sSum = ZhCalc.add(sSum, changeSpreadSheet.getValue(i, 10));
  299. }
  300. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 6, oSum !== 0 ? oSum : null);
  301. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 8, cSum !== 0 ? cSum : null);
  302. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 10, sSum !== 0 ? sSum : null);
  303. // 用户的数据合计
  304. for (const j in change.listAudits) {
  305. let audit_sum = 0;
  306. for(let i = 0; i < rowCount - 1; i++){
  307. audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, 12 + j*2));
  308. }
  309. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 12 + j*2, audit_sum !== 0 ? audit_sum : null);
  310. }
  311. },
  312. deletePress: function (sheet) {
  313. return;
  314. },
  315. showHideAudit: function (show = false) {
  316. const count = changeSpreadSetting.cols.length;
  317. for (let i = 11; i < count; i++) {
  318. changeSpreadSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
  319. }
  320. changeSpreadSheet.setColumnVisible(count - 1, true, GC.Spread.Sheets.SheetArea.viewport);
  321. changeSpreadSheet.setColumnVisible(count - 2, true, GC.Spread.Sheets.SheetArea.viewport);
  322. changeSpreadSheet.setColumnVisible(9, !show, GC.Spread.Sheets.SheetArea.viewport);
  323. changeSpreadSheet.setColumnVisible(10, !show, GC.Spread.Sheets.SheetArea.viewport);
  324. },
  325. valueChanged: function (e, info) {
  326. // 防止ctrl+z撤销数据
  327. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  328. }
  329. };
  330. if (!readOnly) {
  331. changeSpreadObj.add = function () {
  332. changeSpreadSheet.addRows(changeSpreadSheet.getRowCount() - 1, 1);
  333. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  334. // changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
  335. };
  336. changeSpreadObj.batchAdd = function (num) {
  337. changeSpreadSheet.addRows(changeSpreadSheet.getRowCount() - 1, parseInt(num));
  338. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  339. };
  340. changeSpreadObj.del = function (sheet) {
  341. const selection = sheet.getSelections();
  342. const row = selection[0].row, count = selection[0].rowCount;
  343. const sortData = sheet.zh_data;
  344. const ids = [];
  345. let emptyRowNum = 0;
  346. for (let iRow = 0; iRow < count; iRow++) {
  347. if (sortData[iRow + row]) {
  348. ids.push(sortData[iRow + row].id);
  349. } else {
  350. emptyRowNum++;
  351. }
  352. }
  353. if (ids.length > 0) {
  354. postData(preUrl + '/list/save', {type: 'del', ids}, function (result) {
  355. changeList = result;
  356. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  357. changeSpreadObj.makeSjsFooter();
  358. });
  359. } else if (emptyRowNum > 0) {
  360. changeSpreadSheet.deleteRows(changeList.length, emptyRowNum);
  361. changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
  362. }
  363. };
  364. changeSpreadObj.editEnded = function (e, info) {
  365. if (info.sheet.zh_setting) {
  366. const type = SpreadJsObj.getSelectObject(info.sheet) ? 'update' : 'add';
  367. const select = type === 'update' ? SpreadJsObj.getSelectObject(info.sheet) : {unit: ''};
  368. const col = info.sheet.zh_setting.cols[info.col];
  369. if (col.field === 'new_up') {
  370. return;
  371. }
  372. // 未改变值则不提交
  373. let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
  374. const orgValue = type === 'update' ? select[col.field] : '';
  375. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  376. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  377. return;
  378. }
  379. if (col.field === 'oa_tp' || col.field === 'ca_tp') {
  380. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  381. return;
  382. }
  383. // 判断部分值是否输入的是数字判断和数据计算
  384. if (col.type === 'Number') {
  385. if (isNaN(validText)) {
  386. toastr.error('不能输入其它非数字类型字符');
  387. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  388. return;
  389. }
  390. if (col.field === 'unit_price') {
  391. validText = ZhCalc.round(validText, unitPriceUnit);
  392. } else {
  393. validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  394. }
  395. }
  396. if (col.field === 'unit') {
  397. select.camount = ZhCalc.round(select.camount, findDecimal(validText)) || 0;
  398. select.oamount = ZhCalc.round(select.oamount, findDecimal(validText)) || 0;
  399. }
  400. if(col.field === 'camount') {
  401. select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  402. }
  403. select[col.field] = validText;
  404. console.log(select, type);
  405. delete select.waitingLoading;
  406. // 更新至服务器
  407. postData(preUrl + '/list/save', { type, updateData: select }, function (result) {
  408. if(type === 'update') {
  409. changeList.splice(info.row, 1, select);
  410. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  411. changeSpreadObj.countSum();
  412. } else {
  413. changeList.push(result);
  414. changeSpreadSheet.addRows(changeList.length - 1, 1);
  415. SpreadJsObj.reLoadRowData(changeSpreadSheet, changeList.length - 1);
  416. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  417. // changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
  418. }
  419. }, function () {
  420. select[col.field] = orgValue;
  421. if(col.field === 'camount') {
  422. select.spamount = orgValue;
  423. }
  424. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  425. });
  426. }
  427. };
  428. changeSpreadObj.clipboardPasted = function(e, info, cellRange) {
  429. if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
  430. info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
  431. }
  432. const hint = {
  433. cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
  434. numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
  435. };
  436. if (info.sheet.zh_setting) {
  437. const sortData = info.sheet.zh_data || [];
  438. const range = info.cellRange;
  439. const data = [];
  440. let haveNew = false;
  441. for (let iRow = 0; iRow < range.rowCount; iRow++) {
  442. let bPaste = true;
  443. const curRow = range.row + iRow;
  444. // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
  445. const cLData = curRow >= sortData.length ? {unit: ''} : {id: sortData[curRow].id};
  446. haveNew = curRow >= sortData.length ? curRow : false;
  447. const hintRow = range.rowCount > 1 ? curRow : '';
  448. let sameCol = 0;
  449. for (let iCol = 0; iCol < range.colCount; iCol++) {
  450. const curCol = range.col + iCol;
  451. const colSetting = info.sheet.zh_setting.cols[curCol];
  452. if (!colSetting) continue;
  453. // cLData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
  454. let validText = info.sheet.getText(curRow, curCol);
  455. validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
  456. const orgValue = curRow >= sortData.length ? '' : sortData[curRow][colSetting.field];
  457. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  458. sameCol++;
  459. if (range.colCount === sameCol) {
  460. bPaste = false;
  461. }
  462. continue;
  463. }
  464. if (colSetting.type === 'Number') {
  465. if (isNaN(validText)) {
  466. // toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
  467. toastMessageUniq(hint.numberExpr);
  468. bPaste = false;
  469. continue;
  470. }
  471. if (colSetting.field === 'unit_price') {
  472. validText = ZhCalc.round(validText, unitPriceUnit);
  473. } else {
  474. validText = ZhCalc.round(validText, findDecimal(cLData.unit)) || 0;
  475. }
  476. }
  477. let unitdecimal = validText;
  478. if (colSetting.field === 'unit') {
  479. //粘贴内容要为下拉列表里所有的单位,不然为空
  480. if (changeUnits.indexOf(validText) === -1) {
  481. unitdecimal = '';
  482. // validText = null;
  483. }
  484. cLData.camount = curRow >= sortData.length ? 0 : ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
  485. cLData.oamount = curRow >= sortData.length ? 0 : ZhCalc.round(sortData[curRow].oamount, findDecimal(unitdecimal)) || 0;
  486. cLData.spamount = curRow >= sortData.length ? 0 : ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
  487. }
  488. // sortData[curRow][colSetting.field] = validText;
  489. if (colSetting.field === 'camount') {
  490. cLData.spamount = ZhCalc.round(validText, findDecimal(unitdecimal)) || 0;
  491. }
  492. cLData[colSetting.field] = validText;
  493. }
  494. if (bPaste) {
  495. delete cLData.oa_tp;
  496. delete cLData.ca_tp;
  497. data.push(cLData);
  498. // rowData.push(curRow);
  499. } else {
  500. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  501. }
  502. }
  503. if (data.length === 0) {
  504. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  505. return;
  506. }
  507. console.log(data);
  508. // 更新至服务器
  509. postData(preUrl + '/list/save', { type:'paste', updateData: data }, function (result) {
  510. changeList = result;
  511. if (haveNew) {
  512. SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
  513. }
  514. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  515. changeSpreadObj.makeSjsFooter();
  516. if (haveNew) {
  517. changeSpreadSheet.setSelection(haveNew, 1, 1, 1);
  518. changeSpreadSheet.getParent().focus();
  519. changeSpreadSheet.showRow(haveNew, spreadNS.VerticalPosition.center);
  520. }
  521. }, function () {
  522. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  523. return;
  524. });
  525. }
  526. };
  527. changeSpreadObj.updateOamount = function () {
  528. const dataSource = listRule.source === 1 ? gclGatherData : dealBillList;
  529. const updateList = [];
  530. for (const c of changeList) {
  531. const source = _.find(dataSource, function (item) {
  532. if (((item.b_code && item.b_code === c.code) || (item.code && item.code === c.code)) && item.name === c.name) {
  533. if (listRule.rule.length > 0) {
  534. for(const r of listRule.rule) {
  535. if (item[r] !== c[r]) {
  536. return false;
  537. }
  538. }
  539. }
  540. return true;
  541. }
  542. return false;
  543. });
  544. if (source && source.quantity !== c.oamount) {
  545. updateList.push({ id: c.id, oamount: source.quantity });
  546. }
  547. }
  548. console.log(updateList);
  549. if(updateList.length > 0) {
  550. postData(preUrl + '/list/save', { type:'paste', updateData: updateList }, function (result) {
  551. changeList = result;
  552. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  553. changeSpreadObj.makeSjsFooter();
  554. });
  555. }
  556. };
  557. changeSpreadObj.buttonClicked = function (e, info) {
  558. if (info.sheet.zh_setting) {
  559. const select = SpreadJsObj.getSelectObject(info.sheet);
  560. const col = info.sheet.zh_setting.cols[info.col];
  561. if(!select) {
  562. toastr.error('请添加清单编号再勾选');
  563. if (info.sheet.isEditing()) {
  564. info.sheet.endEdit(true);
  565. }
  566. return;
  567. } else if (col.field === 'new_up') {
  568. if (info.sheet.isEditing()) {
  569. info.sheet.endEdit(true);
  570. }
  571. select.new_up = info.sheet.getValue(info.row, info.col) ? 0 : 1;
  572. postData(preUrl + '/list/save', { type: 'update', updateData: { id: select.id, new_up: select.new_up } }, function (result) {
  573. changeList.splice(info.row, 1, select);
  574. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  575. changeSpreadObj.countSum();
  576. }, function () {
  577. select.new_up = info.sheet.getValue(info.row, info.col) ? 1 : 0;
  578. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  579. });
  580. }
  581. // if (materialCol.readOnly.isEdit(select)) {
  582. // return;
  583. // }
  584. // if (col.field === 'new_up') {
  585. // if (info.sheet.isEditing()) {
  586. // info.sheet.endEdit(true);
  587. // }
  588. // select.is_summary = info.sheet.getValue(info.row, info.col) ? 1 : 0;
  589. // delete select.waitingLoading;
  590. // // 更新至服务器
  591. // postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
  592. // m_tp = result.m_tp;
  593. // if (materialTax) {
  594. // m_tax_tp = result.m_tax_tp;
  595. // }
  596. // resetTpTable();
  597. // SpreadJsObj.reLoadRowData(info.sheet, info.row);
  598. // }, function () {
  599. // select.is_summary = info.sheet.getValue(info.row, info.col) ? 0 : 1;
  600. // SpreadJsObj.reLoadRowData(info.sheet, info.row);
  601. // });
  602. // }
  603. }
  604. };
  605. changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
  606. changeSpread.bind(spreadNS.Events.ButtonClicked, changeSpreadObj.buttonClicked);
  607. changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
  608. changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
  609. SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
  610. let batchInsertObj;
  611. $.contextMenu.types.batchInsert = function (item, opt, root) {
  612. const self = this;
  613. if ($.isFunction(item.icon)) {
  614. item._icon = item.icon.call(this, this, $t, key, item);
  615. } else {
  616. if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {
  617. // to enable font awesome
  618. item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
  619. } else {
  620. item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
  621. }
  622. }
  623. this.addClass(item._icon);
  624. const $obj = $('<div>' + item.name + '<input class="text-right ml-1 mr-1" type="tel" max="100" min="1" value="' + item.value + '" style="width: 30px; height: 18px; padding-right: 4px;">行</div>')
  625. .appendTo(this);
  626. const $input = $obj.find('input');
  627. const event = () => {
  628. if (self.hasClass('context-menu-disabled')) return;
  629. item.batchInsert($input[0], root);
  630. };
  631. $obj.on('click', event).keypress(function (e) {if (e.keyCode === 13) { event(); }});
  632. $input.click((e) => {e.stopPropagation();})
  633. .keyup((e) => {if (e.keyCode === 13) item.batchInsert($input[0], root);})
  634. .on('input', function () {this.value = this.value.replace(/[^\d]/g, '');});
  635. };
  636. // 右键菜单
  637. $.contextMenu({
  638. selector: '#plan-spread',
  639. build: function ($trigger, e) {
  640. const target = SpreadJsObj.safeRightClickSelection($trigger, e, changeSpread);
  641. return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  642. },
  643. items: {
  644. 'updateOamount': {
  645. name: '原设计数量读取',
  646. icon: '',
  647. callback: function (key, opt) {
  648. changeSpreadObj.updateOamount(changeSpreadSheet);
  649. },
  650. disabled: function (key, opt) {
  651. // const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
  652. // const sel = changeSpreadSheet.getSelections()[0];
  653. // // console.log(select, sel);
  654. // if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1) {
  655. // return false;
  656. // } else {
  657. // return true;
  658. // }
  659. }
  660. },
  661. sprDel: '------------',
  662. 'createAdd': {
  663. name: '添加行',
  664. icon: 'fa-sign-in',
  665. callback: function (key, opt) {
  666. changeSpreadObj.add(changeSpreadSheet);
  667. },
  668. },
  669. 'batchInsert': {
  670. name: '批量添加行',
  671. type: 'batchInsert',
  672. value: '2',
  673. icon: 'fa-sign-in',
  674. batchInsert: function (obj, root) {
  675. if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
  676. obj.value = obj.max;
  677. toastr.warning('批量添加不可多于' + obj.max);
  678. } else if(_.toNumber(obj.value) < _.toNumber(obj.min)) {
  679. obj.value = obj.min;
  680. toastr.warning('批量添加不可少于' + obj.min);
  681. } else {
  682. // treeOperationObj.addNode(ledgerSpread.getActiveSheet(), parseInt(obj.value));
  683. changeSpreadObj.batchAdd(obj.value);
  684. root.$menu.trigger('contextmenu:hide');
  685. }
  686. },
  687. },
  688. 'delete': {
  689. name: '删除',
  690. icon: 'fa-remove',
  691. callback: function (key, opt) {
  692. changeSpreadObj.del(changeSpreadSheet);
  693. },
  694. disabled: function (key, opt) {
  695. // const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
  696. if (changeSpreadSheet.zh_data) {
  697. const selection = changeSpreadSheet.getSelections();
  698. // return changeSpreadSheet.zh_data.length < selection[0].row + selection[0].rowCount;
  699. return changeSpreadSheet.getRowCount() - 1 < selection[0].row + selection[0].rowCount;
  700. } else {
  701. return true;
  702. }
  703. // const sel = changeSpreadSheet.getSelections()[0];
  704. // // console.log(select, sel);
  705. // if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1) {
  706. // return false;
  707. // } else {
  708. // return true;
  709. // }
  710. }
  711. },
  712. }
  713. });
  714. $('#shuliangguize').on('show.bs.modal', function () {
  715. $('#shuliangguize input[name="data_source"][value="'+ listRule.source +'"]').prop('checked', true);
  716. $('#shuliangguize input[name="data_rule"]').prop('checked', false);
  717. for(const r of listRule.rule) {
  718. $('#shuliangguize input[name="data_rule"][value="' + r +'"]').prop('checked', true);
  719. }
  720. });
  721. // 设置原设计数量读取
  722. $('#setListRule').click(function () {
  723. const rule = [];
  724. $('#shuliangguize input[name="data_rule"]:checked').each(function () {
  725. rule.push($(this).val());
  726. });
  727. const newListRule = {
  728. source: parseInt($('#shuliangguize input[name="data_source"]:checked').val()),
  729. rule,
  730. };
  731. postData(preUrl + '/list/save', { type: 'list_rule', postData: JSON.stringify(newListRule) }, function (result) {
  732. listRule = newListRule;
  733. $('#shuliangguize').modal('hide');
  734. });
  735. })
  736. }
  737. if (change.shenpiPower) {
  738. changeSpreadObj.editEnded = function (e, info) {
  739. if (info.sheet.zh_setting) {
  740. const select = SpreadJsObj.getSelectObject(info.sheet);
  741. const col = info.sheet.zh_setting.cols[info.col];
  742. // 未改变值则不提交
  743. let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
  744. const orgValue = select[col.field];
  745. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  746. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  747. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  748. return;
  749. }
  750. // 判断部分值是否输入的是数字判断和数据计算
  751. if (col.type === 'Number') {
  752. if (isNaN(validText)) {
  753. toastr.error('不能输入其它非数字类型字符');
  754. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  755. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  756. return;
  757. }
  758. validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  759. // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
  760. select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  761. }
  762. select[col.field] = validText;
  763. const data = {
  764. id: select.id,
  765. // spamount: select.spamount,
  766. };
  767. if (col.field === 'ex_memo1' || col.field === 'ex_memo2') {
  768. data[col.field] = select[col.field];
  769. } else {
  770. data.spamount = select.spamount;
  771. }
  772. console.log(data);
  773. // 更新至服务器
  774. postData(preUrl + '/list/save', { type:'update', updateData: data }, function (result) {
  775. changeList.splice(info.row, 1, select);
  776. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  777. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  778. }, function () {
  779. select[col.field] = orgValue;
  780. if (col.field !== 'ex_memo1' && col.field !== 'ex_memo2') {
  781. select.spamount = orgValue;
  782. }
  783. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  784. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  785. });
  786. }
  787. };
  788. changeSpreadObj.clipboardPasted = function(e, info) {
  789. const hint = {
  790. cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
  791. numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
  792. };
  793. const range = info.cellRange;
  794. const sortData = info.sheet.zh_data || [];
  795. const data = [];
  796. for (let iRow = 0; iRow < range.rowCount; iRow++) {
  797. let bPaste = true;
  798. const curRow = range.row + iRow;
  799. // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
  800. const cLData = { id: sortData[curRow].id };
  801. const hintRow = range.rowCount > 1 ? curRow : '';
  802. let sameCol = 0;
  803. for (let iCol = 0; iCol < range.colCount; iCol++) {
  804. const curCol = range.col + iCol;
  805. const colSetting = info.sheet.zh_setting.cols[curCol];
  806. if (!colSetting) continue;
  807. let validText = info.sheet.getText(curRow, curCol);
  808. validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
  809. const orgValue = sortData[curRow][colSetting.field];
  810. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  811. sameCol++;
  812. if (range.colCount === sameCol) {
  813. bPaste = false;
  814. }
  815. continue;
  816. }
  817. if (colSetting.type === 'Number') {
  818. if (isNaN(validText)) {
  819. toastMessageUniq(hint.numberExpr);
  820. bPaste = false;
  821. continue;
  822. }
  823. validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
  824. }
  825. // cLData[colSetting.field] = validText;
  826. sortData[curRow][colSetting.field] = validText;
  827. if (colSetting.field === 'ex_memo1' || colSetting.field === 'ex_memo2') {
  828. cLData[colSetting.field] = validText;
  829. } else {
  830. cLData.spamount = validText;
  831. }
  832. }
  833. if (bPaste) {
  834. data.push(cLData);
  835. // rowData.push(curRow);
  836. } else {
  837. changeSpreadObj.setAuditValue();
  838. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  839. // SpreadJsObj.reLoadRowData(info.sheet, curRow);
  840. }
  841. }
  842. if (data.length === 0) {
  843. // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  844. return;
  845. }
  846. console.log(data);
  847. // 更新至服务器
  848. postData(preUrl + '/list/save', { type:'paste_amount_rows', updateData: data }, function (result) {
  849. changeList = result;
  850. changeSpreadObj.setAuditValue();
  851. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  852. changeSpreadObj.makeSjsFooter();
  853. }, function () {
  854. changeSpreadObj.setAuditValue();
  855. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  856. return;
  857. });
  858. };
  859. changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
  860. changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
  861. changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
  862. SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
  863. }
  864. let changeListData;
  865. let gclGatherData;
  866. let dealBillList;
  867. const billUrl = window.location.pathname.split('/').slice(0, 4).join('/');
  868. postData(billUrl + '/defaultBills', {}, function (result) {
  869. gclGatherModel.loadLedgerData(result.bills);
  870. gclGatherModel.loadPosData(result.pos);
  871. gclGatherData = gclGatherModel.gatherGclData();
  872. gclGatherData = _.filter(gclGatherData, function (item) {
  873. return item.leafXmjs && item.leafXmjs.length !== 0;
  874. });
  875. // 数组去重
  876. dealBillList = result.dealBills;
  877. changeListData = gclGatherData;
  878. console.log(changeListData, dealBillList);
  879. SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
  880. SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
  881. if (change.status === auditConst.status.checking || change.status === auditConst.status.checked) changeSpreadObj.setAuditValue();
  882. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  883. changeSpreadObj.makeSjsFooter();
  884. // 计算最新的变更总额和change的total_price是否一致,不一致则更新
  885. if (change.status !== auditConst.status.checked) {
  886. // let new_tp = 0;
  887. const updateArray = [];
  888. for (const c of changeList) {
  889. const oneUpdate = {};
  890. if (ZhCalc.round(c.spamount, findDecimal(c.unit)) !== c.spamount) oneUpdate.spamount = ZhCalc.round(c.spamount, findDecimal(c.unit));
  891. if (ZhCalc.round(c.oamount, findDecimal(c.unit)) !== c.oamount) oneUpdate.oamount = ZhCalc.round(c.oamount, findDecimal(c.unit));
  892. if (ZhCalc.round(c.camount, findDecimal(c.unit)) !== c.camount) oneUpdate.camount = ZhCalc.round(c.camount, findDecimal(c.unit));
  893. if (ZhCalc.round(c.unit_price, unitPriceUnit) !== c.unit_price) oneUpdate.unit_price = ZhCalc.round(c.unit_price, unitPriceUnit);
  894. const audit_amount = c.audit_amount ? c.audit_amount.split(',') : null;
  895. if (audit_amount) {
  896. for (const i in audit_amount) {
  897. if (ZhCalc.round(parseFloat(audit_amount[i]), findDecimal(c.unit)) !== parseFloat(audit_amount[i])) audit_amount[i] = ZhCalc.round(parseFloat(audit_amount[i]), findDecimal(c.unit));
  898. }
  899. if (c.audit_amount !== audit_amount.join(',')) oneUpdate.audit_amount = audit_amount.join(',');
  900. }
  901. if (!_.isEmpty(oneUpdate)) {
  902. oneUpdate.id = c.id;
  903. updateArray.push(oneUpdate);
  904. }
  905. // new_tp = ZhCalc.add(new_tp, ZhCalc.round(ZhCalc.mul(ZhCalc.round(c.spamount, findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit));
  906. }
  907. console.log(updateArray);
  908. if (updateArray.length > 0) {
  909. // 更新至服务器
  910. postData(preUrl + '/list/save', { type:'paste', updateData: updateArray }, function (result) {
  911. changeList = result;
  912. if (change.status === auditConst.status.checking) changeSpreadObj.setAuditValue();
  913. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  914. changeSpreadObj.makeSjsFooter();
  915. });
  916. }
  917. // if (change.total_price && change.total_price !== new_tp) {
  918. // postData(preUrl + '/list/save', {type: 'update_tp', updateData: new_tp}, function (result) {
  919. // });
  920. // }
  921. changeSpreadObj.showHideAudit(true);
  922. }
  923. if (change.status === auditConst.status.checked) {
  924. changeSpreadObj.showHideAudit(false);
  925. }
  926. });
  927. // 审批流程展示与隐藏
  928. $('#show-table-detail').on('click', function (e) {
  929. if($(e.target).is('label')){
  930. return;
  931. }
  932. changeSpreadObj.showHideAudit($(this).is(':checked'));
  933. });
  934. });
  935. /**
  936. * 校验文件大小、格式
  937. * @param {Array} files 文件数组
  938. */
  939. function validateFiles(files) {
  940. if (files.length > 10) {
  941. toastr.error('至多同时上传10个文件');
  942. return false
  943. }
  944. return files.every(file => {
  945. if (file.size > 1024 * 1024 * 30) {
  946. toastr.error('文件大小限制为30MB');
  947. return false
  948. }
  949. if (whiteList.indexOf('.' + file.ext) === -1) {
  950. toastr.error('请上传正确的格式文件');
  951. return false
  952. }
  953. return true
  954. })
  955. }
  956. function findDecimal(unit) {
  957. let value = precision.other.value;
  958. const changeUnits = precision;
  959. for (const d in changeUnits) {
  960. if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
  961. value = changeUnits[d].value;
  962. break;
  963. }
  964. }
  965. return value;
  966. }
  967. const is_numeric = (value) => {
  968. if (typeof(value) === 'object') {
  969. return false;
  970. } else {
  971. return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
  972. }
  973. };