change_plan_information.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  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 ) || deleteFilePermission
  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.userGroups);
  197. if (change.status === auditConst.status.checking || change.status === auditConst.status.checked) {
  198. for (const audit of change.userGroups) {
  199. if (audit[0] && audit[0].audit_order !== 0) {
  200. // const userinfo = _.find(auditList2, { 'aid': aid });
  201. const newColcount = {
  202. title: (audit && audit.length > 1 ? (audit[0].audit_order + '审') : audit[0].name) + ' 审批|数量',
  203. colSpan: '2|1', rowSpan: '1|1',
  204. field: 'audit_amount_' + audit[0].audit_order,
  205. hAlign: 2, width: 60, type: 'Number',
  206. readOnly: !(change.shenpiPower && _.findIndex(audit, { aid: parseInt(cur_uid) }) !== -1),
  207. };
  208. const newColTp = {
  209. title: '|金额',
  210. colSpan: '|1', rowSpan: '|1',
  211. field: 'sa_tp_' + audit[0].audit_order,
  212. hAlign: 2, width: 80, type: 'Number',
  213. readOnly: true
  214. };
  215. changeSpreadSetting.cols.push(newColcount);
  216. changeSpreadSetting.cols.push(newColTp);
  217. }
  218. }
  219. }
  220. 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'});
  221. 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'});
  222. const changeCol = {
  223. getValue: {
  224. unit_price: function(data) {
  225. return ZhCalc.round(data.unit_price, unitPriceUnit);
  226. },
  227. oa_tp: function (data) {
  228. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount, findDecimal(data.unit))), totalPriceUnit);
  229. },
  230. ca_tp: function (data) {
  231. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
  232. },
  233. oamount: function (data) {
  234. return ZhCalc.round(data.oamount, findDecimal(data.unit));
  235. },
  236. camount: function (data) {
  237. return ZhCalc.round(data.camount, findDecimal(data.unit));
  238. },
  239. samount: function (data) {
  240. return ZhCalc.round(data.samount, findDecimal(data.unit));
  241. },
  242. sa_tp: function (data) {
  243. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.samount, findDecimal(data.unit))), totalPriceUnit);
  244. },
  245. },
  246. readOnly: {
  247. isEdit: function (data) {
  248. return readOnly;
  249. },
  250. isEdit2: function (data) {
  251. return !(!readOnly || change.shenpiPower);
  252. },
  253. },
  254. };
  255. const changeSpreadObj = {
  256. makeSjsFooter: function() {
  257. // 增加汇总行并设为锁定禁止编辑状态
  258. changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
  259. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 1, '合计');
  260. const cellType1 = new GC.Spread.Sheets.CellTypes.Text();
  261. changeSpreadSheet.getCell(changeSpreadSheet.getRowCount() - 1, 0).cellType(cellType1);
  262. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  263. changeSpreadObj.countSum();
  264. },
  265. setAuditValue: function () {
  266. for (const c of changeList) {
  267. for (const audit of change.userGroups) {
  268. if (audit[0].audit_order !== 0) {
  269. c['audit_amount_' + audit[0].audit_order] = ZhCalc.round(c['audit_amount_' + audit[0].audit_order], findDecimal(c.unit));
  270. c['sa_tp_' + audit[0].audit_order] = ZhCalc.round(ZhCalc.mul(c['audit_amount_' + audit[0].audit_order], ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit);
  271. }
  272. }
  273. }
  274. },
  275. setRowValueAndSum: function (data, row, col) {
  276. for (const j in change.userGroups) {
  277. if (change.userGroups[j][0].audit_order !== 0) {
  278. const sum = ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), parseFloat(changeSpreadSheet.getValue(row, 11 + parseInt(j - 1) * 2))), totalPriceUnit);
  279. changeSpreadSheet.setValue(row, 12 + (j - 1) * 2, sum !== 0 ? sum : null);
  280. }
  281. }
  282. // const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, data.spamount), totalPriceUnit);
  283. // changeSpreadSheet.setValue(row, col+1, sum !== 0 ? sum : null);
  284. const count = changeSpreadSetting.cols.length;
  285. if (col+1 >= count - 2) {
  286. return;
  287. }
  288. const rowCount = changeSpreadSheet.getRowCount();
  289. // 用户的数据合计
  290. let audit_sum = 0;
  291. for(let i = 0; i < rowCount - 1; i++){
  292. audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, col+1));
  293. }
  294. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, col+1, audit_sum !== 0 ? audit_sum : null);
  295. },
  296. countSum: function() {
  297. const rowCount = changeSpreadSheet.getRowCount();
  298. let oSum = 0,
  299. cSum = 0,
  300. sSum = 0;
  301. for (let i = 0; i < rowCount - 1; i++) {
  302. oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 6));
  303. cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 8));
  304. sSum = ZhCalc.add(sSum, changeSpreadSheet.getValue(i, 10));
  305. }
  306. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 6, oSum !== 0 ? oSum : null);
  307. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 8, cSum !== 0 ? cSum : null);
  308. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 10, sSum !== 0 ? sSum : null);
  309. if (readOnly) {
  310. // 用户的数据合计
  311. for (const j in change.userGroups) {
  312. if (change.userGroups[j][0].audit_order !== 0) {
  313. let audit_sum = 0;
  314. for (let i = 0; i < rowCount - 1; i++) {
  315. audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, 12 + (j - 1) * 2));
  316. }
  317. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 12 + (j - 1) * 2, audit_sum !== 0 ? audit_sum : null);
  318. }
  319. }
  320. }
  321. },
  322. deletePress: function (sheet) {
  323. return;
  324. },
  325. showHideAudit: function (show = false) {
  326. const count = changeSpreadSetting.cols.length;
  327. for (let i = 11; i < count; i++) {
  328. changeSpreadSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
  329. }
  330. changeSpreadSheet.setColumnVisible(count - 1, true, GC.Spread.Sheets.SheetArea.viewport);
  331. changeSpreadSheet.setColumnVisible(count - 2, true, GC.Spread.Sheets.SheetArea.viewport);
  332. changeSpreadSheet.setColumnVisible(9, !show, GC.Spread.Sheets.SheetArea.viewport);
  333. changeSpreadSheet.setColumnVisible(10, !show, GC.Spread.Sheets.SheetArea.viewport);
  334. },
  335. valueChanged: function (e, info) {
  336. // 防止ctrl+z撤销数据
  337. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  338. }
  339. };
  340. if (!readOnly) {
  341. changeSpreadObj.add = function () {
  342. changeSpreadSheet.addRows(changeSpreadSheet.getRowCount() - 1, 1);
  343. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  344. // changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
  345. };
  346. changeSpreadObj.batchAdd = function (num) {
  347. changeSpreadSheet.addRows(changeSpreadSheet.getRowCount() - 1, parseInt(num));
  348. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  349. };
  350. changeSpreadObj.del = function (sheet) {
  351. const selection = sheet.getSelections();
  352. const row = selection[0].row, count = selection[0].rowCount;
  353. const sortData = sheet.zh_data;
  354. const ids = [];
  355. let emptyRowNum = 0;
  356. for (let iRow = 0; iRow < count; iRow++) {
  357. if (sortData[iRow + row]) {
  358. ids.push(sortData[iRow + row].id);
  359. } else {
  360. emptyRowNum++;
  361. }
  362. }
  363. if (ids.length > 0) {
  364. postData(preUrl + '/list/save', {type: 'del', ids}, function (result) {
  365. changeList = result;
  366. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  367. changeSpreadObj.makeSjsFooter();
  368. });
  369. } else if (emptyRowNum > 0) {
  370. changeSpreadSheet.deleteRows(changeList.length, emptyRowNum);
  371. changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
  372. }
  373. };
  374. changeSpreadObj.editEnded = function (e, info) {
  375. if (info.sheet.zh_setting) {
  376. const type = SpreadJsObj.getSelectObject(info.sheet) ? 'update' : 'add';
  377. const select = type === 'update' ? SpreadJsObj.getSelectObject(info.sheet) : {unit: ''};
  378. const col = info.sheet.zh_setting.cols[info.col];
  379. if (col.field === 'new_up') {
  380. return;
  381. }
  382. // 未改变值则不提交
  383. let validText = (col.type === 'Number' || col.field === 'new_up') && is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
  384. const orgValue = type === 'update' ? select[col.field] : '';
  385. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  386. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  387. return;
  388. }
  389. if (col.field === 'oa_tp' || col.field === 'ca_tp') {
  390. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  391. return;
  392. }
  393. // 判断部分值是否输入的是数字判断和数据计算
  394. if (col.type === 'Number') {
  395. if (isNaN(validText)) {
  396. toastr.error('不能输入其它非数字类型字符');
  397. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  398. return;
  399. }
  400. if (col.field === 'unit_price') {
  401. validText = ZhCalc.round(validText, unitPriceUnit);
  402. } else {
  403. validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  404. }
  405. }
  406. if (col.field === 'unit') {
  407. select.camount = ZhCalc.round(select.camount, findDecimal(validText)) || 0;
  408. select.oamount = ZhCalc.round(select.oamount, findDecimal(validText)) || 0;
  409. }
  410. if(col.field === 'camount') {
  411. select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  412. }
  413. select[col.field] = validText;
  414. console.log(select, type);
  415. delete select.waitingLoading;
  416. // 更新至服务器
  417. postData(preUrl + '/list/save', { type, updateData: select }, function (result) {
  418. if(type === 'update') {
  419. changeList.splice(info.row, 1, select);
  420. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  421. changeSpreadObj.countSum();
  422. } else {
  423. changeList.push(result);
  424. changeSpreadSheet.addRows(changeList.length - 1, 1);
  425. SpreadJsObj.reLoadRowData(changeSpreadSheet, changeList.length - 1);
  426. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  427. // changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
  428. }
  429. }, function () {
  430. select[col.field] = orgValue;
  431. if(col.field === 'camount') {
  432. select.spamount = orgValue;
  433. }
  434. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  435. });
  436. }
  437. };
  438. changeSpreadObj.clipboardPasted = function(e, info, cellRange) {
  439. if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
  440. info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
  441. }
  442. const hint = {
  443. cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
  444. numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
  445. };
  446. if (info.sheet.zh_setting) {
  447. const sortData = info.sheet.zh_data || [];
  448. const range = info.cellRange;
  449. const data = [];
  450. let haveNew = false;
  451. for (let iRow = 0; iRow < range.rowCount; iRow++) {
  452. let bPaste = true;
  453. const curRow = range.row + iRow;
  454. // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
  455. const cLData = curRow >= sortData.length ? {unit: ''} : {id: sortData[curRow].id};
  456. haveNew = curRow >= sortData.length ? curRow : false;
  457. const hintRow = range.rowCount > 1 ? curRow : '';
  458. let sameCol = 0;
  459. for (let iCol = 0; iCol < range.colCount; iCol++) {
  460. const curCol = range.col + iCol;
  461. const colSetting = info.sheet.zh_setting.cols[curCol];
  462. if (!colSetting) continue;
  463. // cLData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
  464. let validText = info.sheet.getText(curRow, curCol);
  465. validText = (colSetting.type === 'Number' || colSetting.field === 'new_up') && is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
  466. const orgValue = curRow >= sortData.length ? '' : sortData[curRow][colSetting.field];
  467. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  468. sameCol++;
  469. if (range.colCount === sameCol) {
  470. bPaste = false;
  471. }
  472. continue;
  473. }
  474. if (colSetting.type === 'Number') {
  475. if (isNaN(validText)) {
  476. // toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
  477. toastMessageUniq(hint.numberExpr);
  478. bPaste = false;
  479. continue;
  480. }
  481. if (colSetting.field === 'unit_price') {
  482. validText = ZhCalc.round(validText, unitPriceUnit);
  483. } else {
  484. validText = ZhCalc.round(validText, findDecimal(cLData.unit)) || 0;
  485. }
  486. }
  487. let unitdecimal = validText;
  488. if (colSetting.field === 'unit') {
  489. //粘贴内容要为下拉列表里所有的单位,不然为空
  490. if (changeUnits.indexOf(validText) === -1) {
  491. unitdecimal = '';
  492. // validText = null;
  493. }
  494. cLData.camount = curRow >= sortData.length ? 0 : ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
  495. cLData.oamount = curRow >= sortData.length ? 0 : ZhCalc.round(sortData[curRow].oamount, findDecimal(unitdecimal)) || 0;
  496. cLData.spamount = curRow >= sortData.length ? 0 : ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
  497. }
  498. // sortData[curRow][colSetting.field] = validText;
  499. if (colSetting.field === 'camount') {
  500. cLData.spamount = ZhCalc.round(validText, findDecimal(unitdecimal)) || 0;
  501. }
  502. cLData[colSetting.field] = validText;
  503. }
  504. if (bPaste) {
  505. delete cLData.oa_tp;
  506. delete cLData.ca_tp;
  507. data.push(cLData);
  508. // rowData.push(curRow);
  509. } else {
  510. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  511. }
  512. }
  513. if (data.length === 0) {
  514. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  515. return;
  516. }
  517. console.log(data);
  518. // 更新至服务器
  519. postData(preUrl + '/list/save', { type:'paste', updateData: data }, function (result) {
  520. changeList = result;
  521. if (haveNew) {
  522. SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
  523. }
  524. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  525. changeSpreadObj.makeSjsFooter();
  526. if (haveNew) {
  527. changeSpreadSheet.setSelection(haveNew, 1, 1, 1);
  528. changeSpreadSheet.getParent().focus();
  529. changeSpreadSheet.showRow(haveNew, spreadNS.VerticalPosition.center);
  530. }
  531. }, function () {
  532. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  533. return;
  534. });
  535. }
  536. };
  537. changeSpreadObj.updateOamount = function () {
  538. const dataSource = listRule.source === 1 ? gclGatherData : dealBillList;
  539. const updateList = [];
  540. for (const c of changeList) {
  541. const source = _.find(dataSource, function (item) {
  542. if (((item.b_code && item.b_code === c.code) || (item.code && item.code === c.code)) && item.name === c.name) {
  543. if (listRule.rule.length > 0) {
  544. for(const r of listRule.rule) {
  545. if (item[r] !== c[r]) {
  546. return false;
  547. }
  548. }
  549. }
  550. return true;
  551. }
  552. return false;
  553. });
  554. if (source && source.quantity !== c.oamount) {
  555. updateList.push({ id: c.id, oamount: source.quantity });
  556. }
  557. }
  558. console.log(updateList);
  559. if(updateList.length > 0) {
  560. postData(preUrl + '/list/save', { type:'paste', updateData: updateList }, function (result) {
  561. changeList = result;
  562. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  563. changeSpreadObj.makeSjsFooter();
  564. });
  565. }
  566. };
  567. changeSpreadObj.buttonClicked = function (e, info) {
  568. if (info.sheet.zh_setting) {
  569. const select = SpreadJsObj.getSelectObject(info.sheet);
  570. const col = info.sheet.zh_setting.cols[info.col];
  571. if(!select) {
  572. toastr.error('请添加清单编号再勾选');
  573. if (info.sheet.isEditing()) {
  574. info.sheet.endEdit(true);
  575. }
  576. return;
  577. } else if (col.field === 'new_up') {
  578. if (info.sheet.isEditing()) {
  579. info.sheet.endEdit(true);
  580. }
  581. select.new_up = info.sheet.getValue(info.row, info.col) ? 0 : 1;
  582. postData(preUrl + '/list/save', { type: 'update', updateData: { id: select.id, new_up: select.new_up } }, function (result) {
  583. changeList.splice(info.row, 1, select);
  584. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  585. changeSpreadObj.countSum();
  586. }, function () {
  587. select.new_up = info.sheet.getValue(info.row, info.col) ? 1 : 0;
  588. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  589. });
  590. }
  591. // if (materialCol.readOnly.isEdit(select)) {
  592. // return;
  593. // }
  594. // if (col.field === 'new_up') {
  595. // if (info.sheet.isEditing()) {
  596. // info.sheet.endEdit(true);
  597. // }
  598. // select.is_summary = info.sheet.getValue(info.row, info.col) ? 1 : 0;
  599. // delete select.waitingLoading;
  600. // // 更新至服务器
  601. // postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
  602. // m_tp = result.m_tp;
  603. // if (materialTax) {
  604. // m_tax_tp = result.m_tax_tp;
  605. // }
  606. // resetTpTable();
  607. // SpreadJsObj.reLoadRowData(info.sheet, info.row);
  608. // }, function () {
  609. // select.is_summary = info.sheet.getValue(info.row, info.col) ? 0 : 1;
  610. // SpreadJsObj.reLoadRowData(info.sheet, info.row);
  611. // });
  612. // }
  613. }
  614. };
  615. changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
  616. changeSpread.bind(spreadNS.Events.ButtonClicked, changeSpreadObj.buttonClicked);
  617. changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
  618. changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
  619. SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
  620. let batchInsertObj;
  621. $.contextMenu.types.batchInsert = function (item, opt, root) {
  622. const self = this;
  623. if ($.isFunction(item.icon)) {
  624. item._icon = item.icon.call(this, this, $t, key, item);
  625. } else {
  626. if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {
  627. // to enable font awesome
  628. item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
  629. } else {
  630. item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
  631. }
  632. }
  633. this.addClass(item._icon);
  634. 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>')
  635. .appendTo(this);
  636. const $input = $obj.find('input');
  637. const event = () => {
  638. if (self.hasClass('context-menu-disabled')) return;
  639. item.batchInsert($input[0], root);
  640. };
  641. $obj.on('click', event).keypress(function (e) {if (e.keyCode === 13) { event(); }});
  642. $input.click((e) => {e.stopPropagation();})
  643. .keyup((e) => {if (e.keyCode === 13) item.batchInsert($input[0], root);})
  644. .on('input', function () {this.value = this.value.replace(/[^\d]/g, '');});
  645. };
  646. // 右键菜单
  647. $.contextMenu({
  648. selector: '#plan-spread',
  649. build: function ($trigger, e) {
  650. const target = SpreadJsObj.safeRightClickSelection($trigger, e, changeSpread);
  651. return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  652. },
  653. items: {
  654. 'updateOamount': {
  655. name: '原设计数量读取',
  656. icon: '',
  657. callback: function (key, opt) {
  658. changeSpreadObj.updateOamount(changeSpreadSheet);
  659. },
  660. disabled: function (key, opt) {
  661. // const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
  662. // const sel = changeSpreadSheet.getSelections()[0];
  663. // // console.log(select, sel);
  664. // if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1) {
  665. // return false;
  666. // } else {
  667. // return true;
  668. // }
  669. }
  670. },
  671. sprDel: '------------',
  672. 'createAdd': {
  673. name: '添加行',
  674. icon: 'fa-sign-in',
  675. callback: function (key, opt) {
  676. changeSpreadObj.add(changeSpreadSheet);
  677. },
  678. },
  679. 'batchInsert': {
  680. name: '批量添加行',
  681. type: 'batchInsert',
  682. value: '2',
  683. icon: 'fa-sign-in',
  684. batchInsert: function (obj, root) {
  685. if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
  686. obj.value = obj.max;
  687. toastr.warning('批量添加不可多于' + obj.max);
  688. } else if(_.toNumber(obj.value) < _.toNumber(obj.min)) {
  689. obj.value = obj.min;
  690. toastr.warning('批量添加不可少于' + obj.min);
  691. } else {
  692. // treeOperationObj.addNode(ledgerSpread.getActiveSheet(), parseInt(obj.value));
  693. changeSpreadObj.batchAdd(obj.value);
  694. root.$menu.trigger('contextmenu:hide');
  695. }
  696. },
  697. },
  698. 'delete': {
  699. name: '删除',
  700. icon: 'fa-remove',
  701. callback: function (key, opt) {
  702. changeSpreadObj.del(changeSpreadSheet);
  703. },
  704. disabled: function (key, opt) {
  705. // const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
  706. if (changeSpreadSheet.zh_data) {
  707. const selection = changeSpreadSheet.getSelections();
  708. // return changeSpreadSheet.zh_data.length < selection[0].row + selection[0].rowCount;
  709. return changeSpreadSheet.getRowCount() - 1 < selection[0].row + selection[0].rowCount;
  710. } else {
  711. return true;
  712. }
  713. // const sel = changeSpreadSheet.getSelections()[0];
  714. // // console.log(select, sel);
  715. // if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1) {
  716. // return false;
  717. // } else {
  718. // return true;
  719. // }
  720. }
  721. },
  722. }
  723. });
  724. $('#shuliangguize').on('show.bs.modal', function () {
  725. $('#shuliangguize input[name="data_source"][value="'+ listRule.source +'"]').prop('checked', true);
  726. $('#shuliangguize input[name="data_rule"]').prop('checked', false);
  727. for(const r of listRule.rule) {
  728. $('#shuliangguize input[name="data_rule"][value="' + r +'"]').prop('checked', true);
  729. }
  730. });
  731. // 设置原设计数量读取
  732. $('#setListRule').click(function () {
  733. const rule = [];
  734. $('#shuliangguize input[name="data_rule"]:checked').each(function () {
  735. rule.push($(this).val());
  736. });
  737. const newListRule = {
  738. source: parseInt($('#shuliangguize input[name="data_source"]:checked').val()),
  739. rule,
  740. };
  741. postData(preUrl + '/list/save', { type: 'list_rule', postData: JSON.stringify(newListRule) }, function (result) {
  742. listRule = newListRule;
  743. $('#shuliangguize').modal('hide');
  744. });
  745. })
  746. }
  747. if (change.shenpiPower) {
  748. changeSpreadObj.editEnded = function (e, info) {
  749. if (info.sheet.zh_setting) {
  750. const select = SpreadJsObj.getSelectObject(info.sheet);
  751. const col = info.sheet.zh_setting.cols[info.col];
  752. // 未改变值则不提交
  753. let validText = col.type === 'Number' && is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
  754. const orgValue = select[col.field];
  755. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  756. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  757. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  758. return;
  759. }
  760. // 判断部分值是否输入的是数字判断和数据计算
  761. if (col.type === 'Number') {
  762. if (isNaN(validText)) {
  763. toastr.error('不能输入其它非数字类型字符');
  764. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  765. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  766. return;
  767. }
  768. validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  769. // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
  770. select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  771. }
  772. select[col.field] = validText;
  773. const data = {
  774. id: select.id,
  775. // spamount: select.spamount,
  776. };
  777. if (col.field === 'ex_memo1' || col.field === 'ex_memo2') {
  778. data[col.field] = select[col.field];
  779. } else {
  780. data.spamount = select.spamount;
  781. }
  782. console.log(data);
  783. // 更新至服务器
  784. postData(preUrl + '/list/save', { type:'update', updateData: data }, function (result) {
  785. changeList.splice(info.row, 1, select);
  786. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  787. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  788. }, function () {
  789. select[col.field] = orgValue;
  790. if (col.field !== 'ex_memo1' && col.field !== 'ex_memo2') {
  791. select.spamount = orgValue;
  792. }
  793. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  794. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  795. });
  796. }
  797. };
  798. changeSpreadObj.clipboardPasted = function(e, info) {
  799. const hint = {
  800. cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
  801. numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
  802. };
  803. const range = info.cellRange;
  804. const sortData = info.sheet.zh_data || [];
  805. const data = [];
  806. for (let iRow = 0; iRow < range.rowCount; iRow++) {
  807. let bPaste = true;
  808. const curRow = range.row + iRow;
  809. // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
  810. const cLData = { id: sortData[curRow].id };
  811. const hintRow = range.rowCount > 1 ? curRow : '';
  812. let sameCol = 0;
  813. for (let iCol = 0; iCol < range.colCount; iCol++) {
  814. const curCol = range.col + iCol;
  815. const colSetting = info.sheet.zh_setting.cols[curCol];
  816. if (!colSetting) continue;
  817. let validText = info.sheet.getText(curRow, curCol);
  818. validText = colSetting.type === 'Number' && is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
  819. const orgValue = sortData[curRow][colSetting.field];
  820. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  821. sameCol++;
  822. if (range.colCount === sameCol) {
  823. bPaste = false;
  824. }
  825. continue;
  826. }
  827. if (colSetting.type === 'Number') {
  828. if (isNaN(validText)) {
  829. toastMessageUniq(hint.numberExpr);
  830. bPaste = false;
  831. continue;
  832. }
  833. validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
  834. }
  835. // cLData[colSetting.field] = validText;
  836. sortData[curRow][colSetting.field] = validText;
  837. if (colSetting.field === 'ex_memo1' || colSetting.field === 'ex_memo2') {
  838. cLData[colSetting.field] = validText;
  839. } else {
  840. cLData.spamount = validText;
  841. }
  842. }
  843. if (bPaste) {
  844. data.push(cLData);
  845. // rowData.push(curRow);
  846. } else {
  847. changeSpreadObj.setAuditValue();
  848. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  849. // SpreadJsObj.reLoadRowData(info.sheet, curRow);
  850. }
  851. }
  852. if (data.length === 0) {
  853. // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  854. return;
  855. }
  856. console.log(data);
  857. // 更新至服务器
  858. postData(preUrl + '/list/save', { type:'paste_amount_rows', updateData: data }, function (result) {
  859. changeList = result;
  860. changeSpreadObj.setAuditValue();
  861. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  862. changeSpreadObj.makeSjsFooter();
  863. }, function () {
  864. changeSpreadObj.setAuditValue();
  865. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  866. return;
  867. });
  868. };
  869. changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
  870. changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
  871. changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
  872. SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
  873. }
  874. let changeListData;
  875. let gclGatherData;
  876. let dealBillList;
  877. const billUrl = window.location.pathname.split('/').slice(0, 4).join('/');
  878. postData(billUrl + '/defaultBills', {}, function (result) {
  879. gclGatherModel.loadLedgerData(result.bills);
  880. gclGatherModel.loadPosData(result.pos);
  881. gclGatherData = gclGatherModel.gatherGclData();
  882. gclGatherData = _.filter(gclGatherData, function (item) {
  883. return item.leafXmjs && item.leafXmjs.length !== 0;
  884. });
  885. // 数组去重
  886. dealBillList = result.dealBills;
  887. changeListData = gclGatherData;
  888. console.log(changeListData, dealBillList);
  889. SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
  890. SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
  891. if (change.status === auditConst.status.checking || change.status === auditConst.status.checked) changeSpreadObj.setAuditValue();
  892. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  893. changeSpreadObj.makeSjsFooter();
  894. // 计算最新的变更总额和change的total_price是否一致,不一致则更新
  895. if (change.status !== auditConst.status.checked) {
  896. // let new_tp = 0;
  897. const updateArray = [];
  898. for (const c of changeList) {
  899. const oneUpdate = {};
  900. if (ZhCalc.round(c.spamount, findDecimal(c.unit)) !== c.spamount) oneUpdate.spamount = ZhCalc.round(c.spamount, findDecimal(c.unit));
  901. if (ZhCalc.round(c.oamount, findDecimal(c.unit)) !== c.oamount) oneUpdate.oamount = ZhCalc.round(c.oamount, findDecimal(c.unit));
  902. if (ZhCalc.round(c.camount, findDecimal(c.unit)) !== c.camount) oneUpdate.camount = ZhCalc.round(c.camount, findDecimal(c.unit));
  903. if (ZhCalc.round(c.unit_price, unitPriceUnit) !== c.unit_price) oneUpdate.unit_price = ZhCalc.round(c.unit_price, unitPriceUnit);
  904. const audit_amount = c.audit_amount ? c.audit_amount.split(',') : null;
  905. if (audit_amount) {
  906. for (const i in audit_amount) {
  907. 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));
  908. }
  909. if (c.audit_amount !== audit_amount.join(',')) oneUpdate.audit_amount = audit_amount.join(',');
  910. }
  911. if (!_.isEmpty(oneUpdate)) {
  912. oneUpdate.id = c.id;
  913. updateArray.push(oneUpdate);
  914. }
  915. // new_tp = ZhCalc.add(new_tp, ZhCalc.round(ZhCalc.mul(ZhCalc.round(c.spamount, findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit));
  916. }
  917. console.log(updateArray);
  918. if (updateArray.length > 0) {
  919. // 更新至服务器
  920. postData(preUrl + '/list/save', { type:'paste', updateData: updateArray }, function (result) {
  921. changeList = result;
  922. if (change.status === auditConst.status.checking) changeSpreadObj.setAuditValue();
  923. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  924. changeSpreadObj.makeSjsFooter();
  925. });
  926. }
  927. // if (change.total_price && change.total_price !== new_tp) {
  928. // postData(preUrl + '/list/save', {type: 'update_tp', updateData: new_tp}, function (result) {
  929. // });
  930. // }
  931. changeSpreadObj.showHideAudit(true);
  932. }
  933. if (change.status === auditConst.status.checked) {
  934. changeSpreadObj.showHideAudit(false);
  935. }
  936. });
  937. // 审批流程展示与隐藏
  938. $('#show-table-detail').on('click', function (e) {
  939. if($(e.target).is('label')){
  940. return;
  941. }
  942. changeSpreadObj.showHideAudit($(this).is(':checked'));
  943. });
  944. });
  945. /**
  946. * 校验文件大小、格式
  947. * @param {Array} files 文件数组
  948. */
  949. function validateFiles(files) {
  950. if (files.length > 10) {
  951. toastr.error('至多同时上传10个文件');
  952. return false
  953. }
  954. return files.every(file => {
  955. if (file.size > 1024 * 1024 * 30) {
  956. toastr.error('文件大小限制为30MB');
  957. return false
  958. }
  959. if (whiteList.indexOf('.' + file.ext.toLowerCase()) === -1) {
  960. toastr.error('请上传正确的格式文件');
  961. return false
  962. }
  963. return true
  964. })
  965. }
  966. function findDecimal(unit) {
  967. let value = precision.other.value;
  968. const changeUnits = precision;
  969. for (const d in changeUnits) {
  970. if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
  971. value = changeUnits[d].value;
  972. break;
  973. }
  974. }
  975. return value;
  976. }
  977. const is_numeric = (value) => {
  978. if (typeof(value) === 'object') {
  979. return false;
  980. } else {
  981. return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
  982. }
  983. };