change_plan_information.js 48 KB

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