change_information_set.js 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406
  1. 'use strict';
  2. /**
  3. * 变更令详细页js
  4. *
  5. * @author EllisRan.
  6. * @date 2018/11/22
  7. * @version
  8. */
  9. // 编号排序,多重判断
  10. function sortByCode(a, b) {
  11. let code1 = a.code.split('-');
  12. let code2 = b.code.split('-');
  13. let code1length = code1.length;
  14. let code2length = code2.length;
  15. for (let i = 0; i < code1length; i ++) {
  16. if (i+1 <= code2length) {
  17. if (code1[i] != code2[i]) {
  18. if (/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
  19. return parseInt(code1[i]) - parseInt(code2[i]);
  20. } else if (!/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
  21. return 1;
  22. } else if (/^\d+$/.test(code1[i]) && !/^\d+$/.test(code2[i])) {
  23. return -1;
  24. } else {
  25. const str1length = code1[i].length;
  26. const str2length = code2[i].length;
  27. for (let j = 0; j < str1length; j++) {
  28. if (j+1 <= str2length) {
  29. if (code1[i].charAt(j) != code2[i].charAt(j)) {
  30. return code1[i].charAt(j).charCodeAt() - code2[i].charAt(j).charCodeAt();
  31. } else if (j+1 == str1length && code1[i].charAt(j) == code2[i].charAt(j)) {
  32. if (str1length == str2length) {
  33. return 0;
  34. } else {
  35. return str1length - str2length;
  36. }
  37. }
  38. } else {
  39. if (j+1 >= str1length) {
  40. return 1;
  41. } else {
  42. return -1;
  43. }
  44. }
  45. }
  46. }
  47. } else if (i+1 == code1length && code1[i] == code2[i]) {
  48. if (code1length == code2length) {
  49. return 0;
  50. } else {
  51. return code1length - code2length;
  52. }
  53. }
  54. } else {
  55. if (i+1 >= code1length) {
  56. return 1;
  57. } else {
  58. return -1;
  59. }
  60. }
  61. }
  62. }
  63. $.event.special.valuechange = {
  64. teardown: function (namespaces) {
  65. $(this).unbind('.valuechange');
  66. },
  67. handler: function (e) {
  68. $.event.special.valuechange.triggerChanged($(this));
  69. },
  70. add: function (obj) {
  71. $(this).on('keyup.valuechange cut.valuechange paste.valuechange input.valuechange', obj.selector, $.event.special.valuechange.handler)
  72. },
  73. triggerChanged: function (element) {
  74. var current = element[0].contentEditable === 'true' ? element.html() : element.val()
  75. , previous = typeof element.data('previous') === 'undefined' ? element[0].defaultValue : element.data('previous');
  76. if (current !== previous) {
  77. element.trigger('valuechange', [element.data('previous')]);
  78. element.data('previous', current);
  79. }
  80. }
  81. };
  82. function getPasteHint (str, row = '') {
  83. let returnObj = str;
  84. if (row) {
  85. returnObj.msg = '清单第' + (row+1) + '行' + str.msg;
  86. }
  87. return returnObj;
  88. }
  89. let searchCodeList = [];
  90. $(document).ready(() => {
  91. const changeSpreadSetting = {
  92. cols: [
  93. {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit2'},
  94. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit2'},
  95. {title: '变更部位', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
  96. {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: false},
  97. {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit2', cellType: 'unit', comboItems: changeUnits, comboEdit: true},
  98. {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit2', getValue: 'getValue.unit_price'},
  99. {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', getValue: 'getValue.oamount'},
  100. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.oa_tp'},
  101. {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', readOnly: false, getValue: 'getValue.camount'},
  102. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.ca_tp'},
  103. {title: '操作', colSpan: '1', rowSpan: '2', field: 'del_list', hAlign: 1, width: 40, readOnly: true, cellType: 'mouseTouch', getValue: 'getValue.del_list'},
  104. ],
  105. emptyRows: 0,
  106. headRows: 2,
  107. headRowHeight: [25, 25],
  108. defaultRowHeight: 21,
  109. headerFont: '12px 微软雅黑',
  110. font: '12px 微软雅黑',
  111. readOnly: readOnly,
  112. rowHeader:[
  113. {
  114. rowHeaderType: 'circle',
  115. setting: {
  116. size: 5,
  117. indent: 16,
  118. getColor: function (index, data) {
  119. if (!data) return;
  120. if (_.findIndex(changeLedgerList, { id: data.gcl_id }) !== -1 || _.findIndex(changePosList, { id: data.mx_id }) !== -1) {
  121. return '#dc3545';
  122. }
  123. if(data.lid != 0) return;
  124. return '#007bff';
  125. }
  126. },
  127. },
  128. ],
  129. localCache: {
  130. key: 'changes-spread',
  131. colWidth: true,
  132. }
  133. };
  134. const changeCol = {
  135. getValue: {
  136. unit_price: function(data) {
  137. return ZhCalc.round(data.unit_price, unitPriceUnit);
  138. },
  139. oa_tp: function (data) {
  140. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount, findDecimal(data.unit))), totalPriceUnit);
  141. },
  142. ca_tp: function (data) {
  143. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
  144. },
  145. oamount: function (data) {
  146. return ZhCalc.round(data.oamount, findDecimal(data.unit));
  147. },
  148. camount: function (data) {
  149. return ZhCalc.round(data.camount, findDecimal(data.unit));
  150. },
  151. del_list: function (data) {
  152. return !_.find(changeUsedData, { id: data.id }) ? '移除' : '';
  153. }
  154. },
  155. readOnly: {
  156. isEdit: function (data) {
  157. return !readOnly && data.lid != 0;
  158. },
  159. isEdit2: function (data) {
  160. return !readOnly && (data.lid != 0 || (data.lid == 0 && _.findIndex(changeUsedData, { id: data.id }) !== -1));
  161. },
  162. },
  163. };
  164. const changeSpreadObj = {
  165. makeSjsFooter: function () {
  166. // 增加汇总行并设为锁定禁止编辑状态
  167. changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
  168. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
  169. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  170. changeSpreadObj.countSum();
  171. },
  172. countSum: function() {
  173. const rowCount = changeSpreadSheet.getRowCount();
  174. let oSum = 0,
  175. cSum = 0;
  176. for(var i = 0; i < rowCount - 1; i++){
  177. oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 7));
  178. cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 9));
  179. }
  180. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, oSum !== 0 ? oSum : null);
  181. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, cSum !== 0 ? cSum : null);
  182. },
  183. add: function () {
  184. postData(window.location.pathname + '/save', {type: 'add'}, function (result) {
  185. if (result) {
  186. changeList.push(result);
  187. changeSpreadSheet.addRows(changeList.length - 1, 1);
  188. SpreadJsObj.reLoadRowData(changeSpreadSheet, changeList.length - 1);
  189. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  190. changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
  191. changeSpreadObj.resetXmjSpread();
  192. }
  193. });
  194. },
  195. batchAdd: function(num) {
  196. postData(window.location.pathname + '/save', {type: 'batchadd', num}, function (result) {
  197. if (result) {
  198. changeList = _.concat(changeList, result);
  199. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  200. changeSpreadObj.makeSjsFooter();
  201. changeSpreadObj.resetXmjSpread();
  202. }
  203. });
  204. },
  205. del: function () {
  206. const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
  207. const index = changeList.indexOf(select);
  208. if (index > -1 && !_.find(changeUsedData, { id: select.id })) {
  209. postData(window.location.pathname + '/save', {type: 'del', id: select.id}, function (result) {
  210. changeList.splice(index, 1);
  211. changeSpreadSheet.deleteRows(index, 1);
  212. const sel = changeSpreadSheet.getSelections();
  213. changeSpreadSheet.setSelection(0, 0, 1, 1);
  214. changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
  215. if (select.lid != 0) {
  216. tableDataRemake(changeListData);
  217. }
  218. changeSpreadObj.countSum();
  219. });
  220. }
  221. },
  222. resetXmjSpread: function(data = null) {
  223. const xmj = [];
  224. if (data && data.lid != 0 && data.xmj_code !== '' && data.xmj_code !== null) {
  225. const newData = JSON.parse(JSON.stringify(data));
  226. if (newData.bwmx === newData.xmj_jldy) {
  227. newData.bwmx = '';
  228. }
  229. xmj.push(newData);
  230. }
  231. SpreadJsObj.loadSheetData(xmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, xmj);
  232. },
  233. selectionChanged: function (e, info) {
  234. const sel = info.sheet.getSelections()[0];
  235. const col = info.sheet.zh_setting.cols[sel.col];
  236. const data = SpreadJsObj.getSelectObject(info.sheet);
  237. if (col && col.field === 'del_list' && !_.find(changeUsedData, { id: data.id })) {
  238. changeSpreadObj.del();
  239. }
  240. changeSpreadObj.resetXmjSpread(data);
  241. },
  242. deletePress: function (sheet) {
  243. return;
  244. },
  245. editEnded: function (e, info) {
  246. if (info.sheet.zh_setting) {
  247. const select = SpreadJsObj.getSelectObject(info.sheet);
  248. const col = info.sheet.zh_setting.cols[info.col];
  249. if (col.field === 'del_list') {
  250. return;
  251. }
  252. // 未改变值则不提交
  253. let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
  254. const orgValue = select[col.field];
  255. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  256. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  257. return;
  258. }
  259. // 判断部分值是否输入的是数字判断和数据计算
  260. if (col.type === 'Number') {
  261. if (isNaN(validText)) {
  262. toastr.error('不能输入其它非数字类型字符');
  263. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  264. return;
  265. }
  266. if (col.field === 'unit_price') {
  267. validText = ZhCalc.round(validText, unitPriceUnit);
  268. } else {
  269. validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  270. }
  271. }
  272. if (col.field === 'unit') {
  273. select.camount = ZhCalc.round(select.camount, findDecimal(validText)) || 0;
  274. select.oamount = ZhCalc.round(select.oamount, findDecimal(validText)) || 0;
  275. }
  276. if(col.field === 'camount') {
  277. // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
  278. const usedInfo = _.find(changeUsedData, { id: select.id });
  279. if (usedInfo && usedInfo.used_qty >= 0 && validText < usedInfo.used_qty) {
  280. toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
  281. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  282. return;
  283. } else if (usedInfo && usedInfo.used_qty < 0 && validText > usedInfo.used_qty) {
  284. toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.used_qty);
  285. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  286. return;
  287. }
  288. select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  289. }
  290. select[col.field] = validText;
  291. console.log(select);
  292. delete select.waitingLoading;
  293. // 更新至服务器
  294. postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
  295. changeList.splice(info.row, 1, select);
  296. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  297. changeSpreadObj.countSum();
  298. }, function () {
  299. select[col.field] = orgValue;
  300. if(col.field === 'camount') {
  301. select.spamount = orgValue;
  302. }
  303. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  304. });
  305. }
  306. },
  307. clipboardPasted(e, info) {
  308. const hint = {
  309. cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
  310. numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
  311. };
  312. const range = info.cellRange;
  313. const sortData = info.sheet.zh_data || [];
  314. if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
  315. toastMessageUniq(hint.cellError);
  316. // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
  317. SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
  318. SpreadJsObj.reLoadSheetData(changeSpreadSheet);
  319. changeSpreadObj.makeSjsFooter();
  320. return;
  321. }
  322. if (sortData.length > 0 && range.col + range.colCount > 10) {
  323. toastMessageUniq(hint.cellError);
  324. SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
  325. SpreadJsObj.reLoadSheetData(changeSpreadSheet);
  326. changeSpreadObj.makeSjsFooter();
  327. return;
  328. }
  329. const data = [];
  330. // const rowData = [];
  331. for (let iRow = 0; iRow < range.rowCount; iRow++) {
  332. let bPaste = true;
  333. const curRow = range.row + iRow;
  334. // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
  335. const cLData = { id: sortData[curRow].id };
  336. const hintRow = range.rowCount > 1 ? curRow : '';
  337. let sameCol = 0;
  338. for (let iCol = 0; iCol < range.colCount; iCol++) {
  339. const curCol = range.col + iCol;
  340. const colSetting = info.sheet.zh_setting.cols[curCol];
  341. if (!colSetting) continue;
  342. let validText = info.sheet.getText(curRow, curCol);
  343. validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
  344. const orgValue = sortData[curRow][colSetting.field];
  345. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  346. sameCol++;
  347. if (range.colCount === sameCol) {
  348. bPaste = false;
  349. }
  350. continue;
  351. }
  352. if (colSetting.type === 'Number') {
  353. if (isNaN(validText)) {
  354. toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
  355. bPaste = false;
  356. continue;
  357. }
  358. if (colSetting.field === 'unit_price') {
  359. validText = ZhCalc.round(validText, unitPriceUnit);
  360. } else {
  361. validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
  362. }
  363. if(colSetting.field === 'camount') {
  364. // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
  365. const usedInfo = _.find(changeUsedData, { id: sortData[curRow].id });
  366. if (usedInfo && usedInfo.used_qty >= 0 && validText < usedInfo.used_qty) {
  367. toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.used_qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
  368. bPaste = false;
  369. continue;
  370. } else if (usedInfo && usedInfo.used_qty < 0 && validText > usedInfo.used_qty) {
  371. toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.used_qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.used_qty);
  372. bPaste = false;
  373. continue;
  374. }
  375. }
  376. }
  377. let unitdecimal = validText;
  378. if (colSetting.field === 'unit') {
  379. //粘贴内容要为下拉列表里所有的单位,不然为空
  380. if (changeUnits.indexOf(validText) === -1) {
  381. unitdecimal = '';
  382. }
  383. cLData.camount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
  384. cLData.oamount = ZhCalc.round(sortData[curRow].oamount, findDecimal(unitdecimal)) || 0;
  385. }
  386. cLData[colSetting.field] = validText;
  387. sortData[curRow][colSetting.field] = validText;
  388. cLData.spamount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
  389. }
  390. if (bPaste) {
  391. data.push(cLData);
  392. // rowData.push(curRow);
  393. } else {
  394. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  395. }
  396. }
  397. if (data.length === 0) {
  398. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  399. return;
  400. }
  401. console.log(data);
  402. // 更新至服务器
  403. postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
  404. changeList = result;
  405. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  406. changeSpreadObj.makeSjsFooter();
  407. changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
  408. }, function () {
  409. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  410. return;
  411. });
  412. },
  413. valueChanged(e, info) {
  414. // 防止ctrl+z撤销数据
  415. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  416. }
  417. };
  418. const preUrl = window.location.pathname.split('/').slice(0, 4).join('/');
  419. let changeListData;
  420. let gclGatherData;
  421. postData(preUrl + '/defaultBills', {}, function (result) {
  422. gclGatherModel.loadLedgerData(result.bills);
  423. gclGatherModel.loadPosData(result.pos);
  424. gclGatherData = gclGatherModel.gatherGclData();
  425. gclGatherData = _.filter(gclGatherData, function (item) {
  426. return item.leafXmjs && item.leafXmjs.length !== 0;
  427. });
  428. for (const ggd in gclGatherData) {
  429. if (gclGatherData[ggd].leafXmjs && gclGatherData[ggd].leafXmjs.length === 0) {
  430. gclGatherData.splice(ggd, 1);
  431. }
  432. gclGatherData[ggd].code = gclGatherData[ggd].b_code;
  433. let hadcid = 0;
  434. for (const xmj of gclGatherData[ggd].leafXmjs) {
  435. if (_.findIndex(changeLedgerList, { id: xmj.gcl_id }) !== -1 || _.findIndex(changePosList, { id: xmj.mx_id, lid: xmj.gcl_id }) !== -1) {
  436. xmj.cid = 1;
  437. hadcid = 1;
  438. }
  439. }
  440. if (hadcid !== 0) gclGatherData[ggd].cid = 1;
  441. }
  442. // 数组去重
  443. const dealBillList = result.dealBills;
  444. for (const db of gclGatherData) {
  445. const exist_index = dealBillList.findIndex(function (item) {
  446. return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
  447. });
  448. if (exist_index !== -1) {
  449. dealBillList.splice(exist_index, 1);
  450. }
  451. }
  452. changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
  453. console.log(changeListData);
  454. // 先加载台账数据
  455. let listHtml = '';
  456. let list_index = 1;
  457. let gcl_index = 0;
  458. for (const gcl of changeListData) {
  459. const unit = gcl.unit !== undefined && gcl.unit !== null ? gcl.unit : '';
  460. const quantity = gcl.quantity !== 0 && gcl.quantity !== null && gcl.quantity !== undefined ? (unit !== '' ? ZhCalc.round(gcl.quantity, findDecimal(gcl.unit)) : gcl.quantity) : 0;
  461. const unit_price = gcl.unit_price !== null && gcl.unit_price !== undefined ? gcl.unit_price : 0;
  462. let gclhtml = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? ' data-gcl="' + gcl_index + '"' : '';
  463. gcl_index = gclhtml !== '' ? ++gcl_index : gcl_index;
  464. const lid = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? (gcl.leafXmjs.length !== 0 ? gcl.leafXmjs[0].gcl_id : false) : gcl.id;
  465. if (lid) {
  466. listHtml += '<tr data-lid="' + lid + '"' + gclhtml + ' data-index="' + list_index + '" data-bwmx="">' +
  467. '<td class="text-center">' + list_index + (gcl.cid ? '<i class="text-danger" style="font-weight: 900">*</i>' : '') + '</td>' +
  468. '<td>' + gcl.code + '</td>' +
  469. '<td class="text-left">' + gcl.name + '</td>' +
  470. '<td class="text-center">' + unit + '</td>' +
  471. '<td class="text-right">' + (ZhCalc.round(unit_price, unitPriceUnit) ? ZhCalc.round(unit_price, unitPriceUnit) : 0) + '</td>' +
  472. '<td class="text-right">' + quantity + '</td>' +
  473. '</tr>';
  474. list_index++;
  475. }
  476. }
  477. $('#table-list-select').html(listHtml);
  478. tableDataRemake(changeListData);
  479. SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
  480. SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
  481. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  482. // changeSpreadSheet.options.protectionOptions = {
  483. // allowSort: true,
  484. // allowFilter: true
  485. // };
  486. // var option = changeSpreadSheet.options.protectionOptions;
  487. // changeSpreadSheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(-1, 0, -1, changeSpreadSetting.cols.length)));
  488. // // changeSpreadSheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(-1, 0, -1, 3)));
  489. // const filter = changeSpreadSheet.rowFilter();
  490. // filter.filterButtonVisible(false);
  491. // filter.filterButtonVisible(0, true);
  492. // filter.filterButtonVisible(2, true);
  493. // filter.filterDialogVisibleInfo({
  494. // sortByValue: true, //SortByValue item is visible.
  495. // sortByColor: false, //SortByColor item is visible.
  496. // filterByColor: false, //FilterByColor item is visible.
  497. // filterByValue: false, //FilterByValue item is visible.
  498. // listFilterArea: false //ListFilterArea item is visible.
  499. // });
  500. // function compareList(obj1, obj2) {
  501. // console.log(obj1, obj2);
  502. // var list = ["", '204-1-b', '合计'];
  503. // var index1 = list.indexOf(obj1), index2 = list.indexOf(obj2);
  504. // if (index1 > index2) {
  505. // return 1;
  506. // } else if (index1 < index2) {
  507. // return -1;
  508. // } else {
  509. // return 0;
  510. // }
  511. // }
  512. // changeSpreadSheet.sortRange(0, 0, changeSpreadSetting.cols.length, 1, true, [{index: 0, ascending: true, compareFunction: compareList}]);
  513. // changeSpreadSheet.bind(GC.Spread.Sheets.Events.RangeSorting, function (e, info) {
  514. // info.compareFunction = compareList;
  515. // });
  516. // filter.sortColumn(0, true);
  517. changeSpreadObj.makeSjsFooter();
  518. changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
  519. });
  520. if (!readOnly) {
  521. $('#add-white-btn').click(changeSpreadObj.add);
  522. changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
  523. changeSpread.bind(spreadNS.Events.SelectionChanged, changeSpreadObj.selectionChanged);
  524. changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
  525. changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
  526. SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
  527. changeSpreadSheet.getCell(-1, 10).foreColor('#dc3545');
  528. let batchInsertObj;
  529. $.contextMenu.types.batchInsert = function (item, opt, root) {
  530. const self = this;
  531. if ($.isFunction(item.icon)) {
  532. item._icon = item.icon.call(this, this, $t, key, item);
  533. } else {
  534. if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {
  535. // to enable font awesome
  536. item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
  537. } else {
  538. item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
  539. }
  540. }
  541. this.addClass(item._icon);
  542. 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>')
  543. .appendTo(this);
  544. const $input = $obj.find('input');
  545. const event = () => {
  546. if (self.hasClass('context-menu-disabled')) return;
  547. item.batchInsert($input[0], root);
  548. };
  549. $obj.on('click', event).keypress(function (e) {if (e.keyCode === 13) { event(); }});
  550. $input.click((e) => {e.stopPropagation();})
  551. .keyup((e) => {if (e.keyCode === 13) item.batchInsert($input[0], root);})
  552. .on('input', function () {this.value = this.value.replace(/[^\d]/g, '');});
  553. };
  554. // 右键菜单
  555. $.contextMenu({
  556. selector: '#change-spread',
  557. build: function ($trigger, e) {
  558. const target = SpreadJsObj.safeRightClickSelection($trigger, e, changeSpread);
  559. return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  560. },
  561. items: {
  562. 'createList': {
  563. name: '添加台账清单',
  564. icon: 'fa-sign-in',
  565. callback: function (key, opt) {
  566. $('#addlist').modal('show');
  567. },
  568. },
  569. 'createAdd': {
  570. name: '添加空白清单',
  571. icon: 'fa-sign-in',
  572. callback: function (key, opt) {
  573. changeSpreadObj.add(changeSpreadSheet);
  574. },
  575. },
  576. 'batchInsert': {
  577. name: '批量添加空白清单',
  578. type: 'batchInsert',
  579. value: '2',
  580. icon: 'fa-sign-in',
  581. batchInsert: function (obj, root) {
  582. if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
  583. obj.value = obj.max;
  584. toastr.warning('批量添加不可多于' + obj.max);
  585. } else if(_.toNumber(obj.value) < _.toNumber(obj.min)) {
  586. obj.value = obj.min;
  587. toastr.warning('批量添加不可少于' + obj.min);
  588. } else {
  589. // treeOperationObj.addNode(ledgerSpread.getActiveSheet(), parseInt(obj.value));
  590. changeSpreadObj.batchAdd(obj.value);
  591. root.$menu.trigger('contextmenu:hide');
  592. }
  593. },
  594. },
  595. 'delete': {
  596. name: '删除',
  597. icon: 'fa-remove',
  598. callback: function (key, opt) {
  599. changeSpreadObj.del(changeSpreadSheet);
  600. },
  601. disabled: function (key, opt) {
  602. const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
  603. const sel = changeSpreadSheet.getSelections()[0];
  604. changeSpreadObj.resetXmjSpread(select);
  605. // console.log(select, sel);
  606. if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1 && !_.find(changeUsedData, { id: select.id })) {
  607. return false;
  608. } else {
  609. return true;
  610. }
  611. }
  612. },
  613. }
  614. });
  615. }
  616. // 清单选中和移除
  617. $('body').on('click', '#table-list-select tr', function () {
  618. searchCodeList = [];
  619. $('#table-list-select tr').removeClass('table-warning');
  620. $(this).addClass('table-warning');
  621. const isCheck = $(this).hasClass('table-success') ? true : false;
  622. const data_bwmx = $(this).attr('data-bwmx').split('$#$');
  623. const isDeal = $(this).data('gcl') !== undefined ? true : false;
  624. let codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id="" mx_id=""><td class="text-center">1</td><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox"></td></tr>';
  625. if (isDeal) {
  626. const lid = $(this).data('lid');
  627. let gcl = _.find(gclGatherData, function (item) {
  628. return item.leafXmjs && item.leafXmjs[0].gcl_id === lid;
  629. });
  630. if (!gcl) {
  631. gcl = gclGatherData[$(this).data('gcl')];
  632. }
  633. codeHtml = '';
  634. for (const [index, leaf] of gcl.leafXmjs.entries()) {
  635. const quantity = leaf.quantity !== undefined && leaf.quantity !== null ? leaf.quantity : 0;
  636. const gcl_id = leaf.gcl_id ? leaf.gcl_id : '';
  637. const mx_id = leaf.mx_id ? leaf.mx_id : '';
  638. const bwmx = leaf.bwmx !== undefined ? leaf.bwmx : (gcl.leafXmjs.length > 1 && gcl.name ? gcl.name : undefined);
  639. const isChecked = data_bwmx.indexOf(
  640. leaf.code + '!_!' + (leaf.jldy ? leaf.jldy : '') + '!_!' +
  641. (leaf.dwgc ? leaf.dwgc : '') + '!_!' + (leaf.fbgc ? leaf.fbgc : '') + '!_!' + (leaf.fxgc ? leaf.fxgc : '')
  642. + '!_!' + (leaf.gcl_id ? leaf.gcl_id : '0') + '!_!' + (leaf.mx_id ? leaf.mx_id : '') + '!_!' +
  643. (bwmx !== undefined ? bwmx : leaf.jldy ? leaf.jldy : '') + '*;*' + quantity) !== -1 && isCheck ?
  644. 'checked' : '';
  645. const isUsed = _.find(changeUsedData, { gcl_id: leaf.gcl_id, bwmx: (bwmx ? bwmx : leaf.jldy ? leaf.jldy : ''), oamount: leaf.quantity });
  646. const isDisabled = isUsed ? 'disabled ' : '';
  647. codeHtml += '<tr quantity="' + quantity + '" gcl_id="' + gcl_id + '" mx_id="' + mx_id + '">' +
  648. '<td class="text-center">' + (index+1) + (leaf.cid ? '<i class="text-danger" style="font-weight: 900">*</i>' : '') + '</td>' +
  649. '<td>' + leaf.code + '</td>' +
  650. '<td>' + (leaf.jldy ? leaf.jldy: '') + '</td>' +
  651. '<td>' + (leaf.dwgc ? leaf.dwgc : '') + '</td>' +
  652. '<td>' + (leaf.fbgc ? leaf.fbgc : '') + '</td>' +
  653. '<td>' + (leaf.fxgc ? leaf.fxgc : '') + '</td>' +
  654. '<td>' + (bwmx !== undefined ? bwmx : '') + '</td>' +
  655. '<td class="text-right">' + (ZhCalc.round(quantity, findDecimal(gcl.unit)) ? ZhCalc.round(quantity, findDecimal(gcl.unit)) : 0) + '</td>' +
  656. '<td class="text-center"><input type="checkbox" ' + isDisabled + isChecked +
  657. '></td></tr>';
  658. searchCodeList.push(leaf.code + '|!|' + (leaf.jldy ? leaf.jldy: '') + '|!|' + (bwmx !== undefined ? bwmx : ''));
  659. }
  660. } else if (!isDeal && isCheck) {
  661. codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id="" mx_id=""><td class="text-center">1</td><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox" checked></td></tr>';
  662. }
  663. $('#code-list').attr('data-index', parseInt($(this).children('td').eq(0).text()));
  664. $('#code-input').val('');
  665. $('#code-input').siblings('a').hide();
  666. $('#code-list').html(codeHtml);
  667. checkSelectAll();
  668. });
  669. // 右边项目节选择
  670. $('body').on('click', '#code-list input', function () {
  671. let index = $('#code-list').attr('data-index');
  672. if ($(this).is(':checked')) {
  673. // 去除其它可能已选的checked
  674. // $('#code-list input').prop('checked', false);
  675. $(this).prop('checked', true);
  676. // 左边表单传值并添加class
  677. $('#table-list-select tr[data-index="' + index + '"]').addClass('table-success');
  678. // 去除部分data-detail值
  679. let data_bwmx = [];
  680. $('#code-list input:checked').each(function () {
  681. const tr = $(this).parents('tr');
  682. const length = tr.children('td').length;
  683. const gcl_id = tr.attr('gcl_id');
  684. const mx_id = tr.attr('mx_id');
  685. const bwmx = length === 9 ?
  686. tr.children('td').eq(1).text() + '!_!' +
  687. tr.children('td').eq(2).text() + '!_!' +
  688. tr.children('td').eq(3).text() + '!_!' +
  689. tr.children('td').eq(4).text() + '!_!' +
  690. tr.children('td').eq(5).text() + '!_!' + gcl_id + '!_!' + mx_id + '!_!' +
  691. (tr.children('td').eq(6).text() !== '' ? tr.children('td').eq(6).text() : tr.children('td').eq(2).text()) : '0';
  692. const quantity = tr.attr('quantity');
  693. const de_qu = bwmx + '*;*' + quantity;
  694. data_bwmx.push(de_qu);
  695. });
  696. data_bwmx = data_bwmx.join('$#$');
  697. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', data_bwmx);
  698. } else {
  699. // 判断还有无选中项目节编号
  700. if ($('#code-list input').is(':checked')) {
  701. // 去除部分data-detail值
  702. let data_bwmx = [];
  703. $('#code-list input:checked').each(function () {
  704. const tr = $(this).parents('tr');
  705. const length = tr.children('td').length;
  706. const gcl_id = tr.attr('gcl_id');
  707. const mx_id = tr.attr('mx_id');
  708. const bwmx = length === 9 ?
  709. tr.children('td').eq(1).text() + '!_!' +
  710. tr.children('td').eq(2).text() + '!_!' +
  711. tr.children('td').eq(3).text() + '!_!' +
  712. tr.children('td').eq(4).text() + '!_!' +
  713. tr.children('td').eq(5).text() + '!_!' + gcl_id + '!_!' + mx_id + '!_!' +
  714. (tr.children('td').eq(6).text() !== '' ? tr.children('td').eq(6).text() : tr.children('td').eq(2).text()) : '0';
  715. const quantity = tr.attr('quantity');
  716. const de_qu = bwmx + '*;*' + quantity;
  717. data_bwmx.push(de_qu);
  718. });
  719. data_bwmx = data_bwmx.join('$#$');
  720. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', data_bwmx);
  721. } else {
  722. $('#table-list-select tr[data-index="' + index + '"]').removeClass('table-success');
  723. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', '');
  724. }
  725. }
  726. checkSelectAll();
  727. });
  728. // 添加空白清单or签约清单
  729. $('.add-list-btn').on('click', function () {
  730. const newLedgerList = remakeChangeSpread();
  731. // 更新至服务器
  732. postData(window.location.pathname + '/save', { type:'ledger_list', updateData: newLedgerList }, function (result) {
  733. changeList = result.changeList;
  734. changeUsedData = result.usedList;
  735. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  736. changeSpreadObj.makeSjsFooter();
  737. const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
  738. changeSpreadObj.resetXmjSpread(select);
  739. $('#addlist').modal('hide');
  740. }, function () {
  741. $('#addlist').modal('hide');
  742. });
  743. });
  744. // 选中input所有值
  745. $('body').on('focus', ".clist input", function() {
  746. $(this).select();
  747. });
  748. // 取消选中清单
  749. $('#cancel-list-btn').click(function () {
  750. // $('#table-list-select tr').removeClass('table-success');
  751. // $('#table-list-select tr').attr('data-bwmx', '');
  752. // $('#code-list').html('');
  753. tableDataRemake(changeListData);
  754. });
  755. // 自动编号
  756. $('.reduction-code').click(function () {
  757. const code = $(this).attr('data-code');
  758. $('input[name="code"]').val(code);
  759. });
  760. $('#select-list').change(function () {
  761. const select = parseInt($(this).val());
  762. let showListData = changeListData;
  763. const value = $('#list-input').val();
  764. if (select === 1) {
  765. if (value !== '') {
  766. $('#list-input').siblings('a').show();
  767. showListData = _.filter(changeListData, function (c) {
  768. return ((c.code && c.code.indexOf(value) !== -1) || (c.name && c.name.indexOf(value) !== -1)) && c.cid;
  769. });
  770. } else {
  771. $('#list-input').siblings('a').hide();
  772. showListData = _.filter(changeListData, function (c) {
  773. return c.cid;
  774. });
  775. }
  776. } else {
  777. if (value !== '') {
  778. $('#list-input').siblings('a').show();
  779. showListData = _.filter(changeListData, function (c) {
  780. return (c.code && c.code.indexOf(value) !== -1) || (c.name && c.name.indexOf(value) !== -1);
  781. });
  782. } else {
  783. $('#list-input').siblings('a').hide();
  784. }
  785. }
  786. makeListTable(changeListData, showListData);
  787. $('#table-list-select tr').removeClass('table-warning');
  788. $('#code-input').val('');
  789. $('#code-input').siblings('a').hide();
  790. $('#code-list').html('');
  791. $('#code-select-all').prop('checked', false);
  792. });
  793. // 回车提交
  794. $('#list-input').on('keypress', function () {
  795. if(window.event.keyCode === 13) {
  796. $(this).blur();
  797. }
  798. });
  799. $('#list-input').on('blur', function () {
  800. const select = parseInt($('#select-list').val());
  801. const value = $(this).val();
  802. let showListData = changeListData;
  803. if (select === 1 && value !== '') {
  804. $(this).siblings('a').show();
  805. showListData = _.filter(changeListData, function (c) {
  806. return ((c.code && c.code.indexOf(value) !== -1) || (c.name && c.name.indexOf(value) !== -1)) && c.cid;
  807. });
  808. } else if (select === 1 && value === '') {
  809. $(this).siblings('a').hide();
  810. showListData = _.filter(changeListData, function (c) {
  811. return c.cid;
  812. });
  813. } else if (value !== '') {
  814. $(this).siblings('a').show();
  815. showListData = _.filter(changeListData, function (c) {
  816. return (c.code && c.code.indexOf(value) !== -1) || (c.name && c.name.indexOf(value) !== -1);
  817. });
  818. } else {
  819. $(this).siblings('a').hide();
  820. }
  821. makeListTable(changeListData, showListData);
  822. $('#table-list-select tr').removeClass('table-warning');
  823. $('#code-input').val('');
  824. $('#code-input').siblings('a').hide();
  825. $('#code-list').html('');
  826. $('#code-select-all').prop('checked', false);
  827. });
  828. // 回车提交
  829. $('#code-input').on('keypress', function () {
  830. if(window.event.keyCode === 13) {
  831. $(this).blur();
  832. }
  833. });
  834. $('#code-input').on('blur', function () {
  835. const value = $(this).val();
  836. if (value !== '') {
  837. $(this).siblings('a').show();
  838. } else {
  839. $(this).siblings('a').hide();
  840. }
  841. makeCodeTable($(this).val());
  842. checkSelectAll();
  843. });
  844. $('.remove-btn').on('click', function () {
  845. $(this).hide();
  846. $(this).siblings('input').val('');
  847. if ($(this).data('btn') === 'list') {
  848. const select = parseInt($('#select-list').val());
  849. let showListData = changeListData;
  850. if (select === 1) {
  851. showListData = _.filter(changeListData, function (c) {
  852. return c.cid;
  853. });
  854. }
  855. makeListTable(changeListData, showListData);
  856. $('#table-list-select tr').removeClass('table-warning');
  857. $('#code-list').html('');
  858. } else {
  859. makeCodeTable();
  860. }
  861. checkSelectAll();
  862. });
  863. // 全选及取消
  864. $('#code-select-all').click(function () {
  865. // 全选checkbox
  866. let index = $('#code-list').attr('data-index');
  867. if (index) {
  868. if ($(this).is(':checked')){
  869. $('#code-list tr').each(function () {
  870. if ($(this).css('display') !== 'none') {
  871. $(this).find('input').prop('checked', true);
  872. }
  873. })
  874. } else {
  875. $('#code-list tr').each(function () {
  876. if ($(this).css('display') !== 'none' && $(this).find('input').prop('disabled') !== true) {
  877. $(this).find('input').prop('checked', false);
  878. }
  879. });
  880. }
  881. // 判断还有无选中项目节编号
  882. if ($('#code-list input').is(':checked')) {
  883. // 去除部分data-detail值
  884. let data_bwmx = [];
  885. $('#code-list input:checked').each(function () {
  886. const tr = $(this).parents('tr');
  887. const length = tr.children('td').length;
  888. const gcl_id = tr.attr('gcl_id');
  889. const mx_id = tr.attr('mx_id');
  890. const bwmx = length === 9 ?
  891. tr.children('td').eq(1).text() + '!_!' +
  892. tr.children('td').eq(2).text() + '!_!' +
  893. tr.children('td').eq(3).text() + '!_!' +
  894. tr.children('td').eq(4).text() + '!_!' +
  895. tr.children('td').eq(5).text() + '!_!' + gcl_id + '!_!' + mx_id + '!_!' +
  896. (tr.children('td').eq(6).text() !== '' ? tr.children('td').eq(6).text() : tr.children('td').eq(2).text()) : '0';
  897. const quantity = tr.attr('quantity');
  898. const de_qu = bwmx + '*;*' + quantity;
  899. data_bwmx.push(de_qu);
  900. });
  901. data_bwmx = data_bwmx.join('$#$');
  902. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', data_bwmx);
  903. $('#table-list-select tr[data-index="' + index + '"]').addClass('table-success');
  904. } else {
  905. $('#table-list-select tr[data-index="' + index + '"]').removeClass('table-success');
  906. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', '');
  907. }
  908. }
  909. });
  910. // 记录变更信息操作
  911. $('body').on('valuechange', '#change_form input[type="text"]', function (e, previous) {
  912. changeInfo[$(this).attr('name')] = $(this).val();
  913. judgeChange();
  914. });
  915. $('body').on('valuechange', '#change_form textarea', function (e, previous) {
  916. changeInfo[$(this).attr('name')] = $(this).val().replace(/[\r\n]/g, '<br><br>');
  917. judgeChange();
  918. });
  919. $('body').on('change', '#change_form select', function (e, previous) {
  920. changeInfo[$(this).attr('name')] = $(this).val();
  921. judgeChange();
  922. });
  923. $('body').on('click', '#change_form input[type="radio"]', function (e, previous) {
  924. changeInfo[$(this).attr('name')] = $(this).val();
  925. judgeChange();
  926. });
  927. $('body').on('click', '#change_form input[type="checkbox"]', function (e, previous) {
  928. const typecheck = [];
  929. $.each($('#change_form input[name="type[]"]:checked'), function () {
  930. typecheck.push($(this).val());
  931. });
  932. changeInfo.type = typecheck.join(',');
  933. judgeChange();
  934. });
  935. // 保存修改ajax提交(不刷新页面)
  936. $('.save_change_btn').on('click', function () {
  937. // 保存修改modal
  938. if ($('input[name="code"]').val() === '') {
  939. toastr.error('申请编号不能为空!');
  940. return;
  941. }
  942. if ($('input[name="name"]').val() === '') {
  943. toastr.error('变更工程名称不能为空!');
  944. return;
  945. }
  946. // 换行更改并提交
  947. changeInfo.content = changeInfo.content.replace(/<br><br>/g, '\r\n');
  948. changeInfo.basis = changeInfo.basis.replace(/<br><br>/g, '\r\n');
  949. changeInfo.expr = changeInfo.expr.replace(/<br><br>/g, '\r\n');
  950. changeInfo.memo = changeInfo.memo.replace(/<br><br>/g, '\r\n');
  951. // 后改为br
  952. // 更新至服务器
  953. postData(window.location.pathname + '/save', { type:'info', updateData: changeInfo }, function (result) {
  954. $('.reduction-code').attr('data-code', $('input[name="code"]').val());
  955. toastr.success(result);
  956. $('#show-save-btn').hide();
  957. $('#sp-btn').show();
  958. $('.title-main').removeClass('bg-warning');
  959. changeInfo.content = changeInfo.content.replace(/[\r\n]/g, '<br>');
  960. changeInfo.basis = changeInfo.basis.replace(/[\r\n]/g, '<br>');
  961. changeInfo.expr = changeInfo.expr.replace(/[\r\n]/g, '<br>');
  962. changeInfo.memo = changeInfo.memo.replace(/[\r\n]/g, '<br>');
  963. back_changeInfo = Object.assign({}, changeInfo);
  964. });
  965. return false;
  966. });
  967. $('#cancel_change').on('click', function () {
  968. $('#show-save-btn').hide();
  969. $('#sp-btn').show();
  970. $('.title-main').removeClass('bg-warning');
  971. if (!isObjEqual(changeInfo, back_changeInfo)) {
  972. changeFormRemake();
  973. }
  974. toastr.success('已还原到上次保存状态');
  975. });
  976. });
  977. function checkSelectAll() {
  978. let check = $('#code-list tr').length > 0 ? true : false;
  979. const codeNum = $('#code-list tr').length;
  980. let i = 0;
  981. $('#code-list tr').each(function () {
  982. if ($(this).css('display') !== 'none' && !$(this).find('input').is(':checked')) {
  983. check = false;
  984. return;
  985. }
  986. else if ($(this).css('display') === 'none') {
  987. i++;
  988. }
  989. });
  990. if (check && i === codeNum) {
  991. check = false;
  992. }
  993. $('#code-select-all').prop('checked', check);
  994. }
  995. function checkChangeFrom() {
  996. let returnFlag = false;
  997. // 表单判断
  998. if ($('input[name="code"]').val() === '') {
  999. toastr.error('申请编号不能为空!');
  1000. returnFlag = true;
  1001. }
  1002. if ($('input[name="name"]').val() === '') {
  1003. toastr.error('变更工程名称不能为空!');
  1004. returnFlag = true;
  1005. }
  1006. if ($('textarea[name="content"]').val() === '') {
  1007. toastr.error('工程变更理由及内容不能为空!');
  1008. returnFlag = true;
  1009. }
  1010. if (changeList.length === 0) {
  1011. toastr.error('请添加变更清单!');
  1012. returnFlag = true;
  1013. } else {
  1014. for (const [i,cl] of changeList.entries()) {
  1015. if (cl.code === '' || cl.name === '' || cl.oamount === '') {
  1016. toastr.error('变更清单第' + (i+1) + '行未完整填写数据(变更部位、变更详情、单位、单价可空)');
  1017. returnFlag = true;
  1018. }
  1019. }
  1020. }
  1021. if(!checkAuditorFrom ()) {
  1022. returnFlag = true;
  1023. }
  1024. if (returnFlag) {
  1025. return false;
  1026. }
  1027. }
  1028. // 检查上报情况
  1029. function checkAuditorFrom () {
  1030. if ($('#auditList li').length === 0) {
  1031. if(shenpi_status === shenpiConst.sp_status.gdspl) {
  1032. toastr.error('请联系管理员添加审批人');
  1033. } else {
  1034. toastr.error('请先选择审批人,再上报数据');
  1035. }
  1036. return false;
  1037. }
  1038. return true;
  1039. }
  1040. function tableDataRemake(changeListData) {
  1041. $('#table-list-select tr').removeClass('table-warning');
  1042. $('#table-list-select tr').removeClass('table-success');
  1043. $('#table-list-select tr').attr('data-bwmx', '');
  1044. $('#code-list').html('');
  1045. $('#code-list').attr('data-index', '');
  1046. $('#code-input').val('');
  1047. $('#code-select-all').prop('checked', false);
  1048. $('#code-input').siblings('a').hide();
  1049. // 根据已添加的清单显示
  1050. if (changeList.length > 0 && changeList[0]) {
  1051. const removeList = [];
  1052. const updateList = [];
  1053. const updateGclIdList = [];
  1054. for (const [index,clinfo] of changeList.entries()) {
  1055. if (clinfo.lid != 0) {
  1056. let listinfo = changeListData.find(function (item) {
  1057. return (item.id !== undefined && item.id == clinfo.lid) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && item.leafXmjs[0].gcl_id == clinfo.lid);
  1058. });
  1059. let info = '';
  1060. if (listinfo === undefined || (clinfo.lid && clinfo.gcl_id && clinfo.lid !== clinfo.gcl_id)) {
  1061. // 有可能这部分台账发生变化,此时要更新清单lid信息,防止数据丢失
  1062. const newlistinfo = changeListData.find(function (item) {
  1063. return (item.id !== undefined && item.id == clinfo.gcl_id) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && _.find(item.leafXmjs, {gcl_id: clinfo.gcl_id }));
  1064. });
  1065. if (listinfo === undefined && newlistinfo || (listinfo && newlistinfo && !isObjEqual(listinfo, newlistinfo))) {
  1066. listinfo = newlistinfo;
  1067. updateList.push({id: clinfo.id, lid: newlistinfo.leafXmjs[0].gcl_id});
  1068. // 更新lid
  1069. changeList[index].lid = newlistinfo.leafXmjs[0].gcl_id;
  1070. }
  1071. }
  1072. if (listinfo === undefined) {
  1073. // 针对旧数据获取清单信息
  1074. listinfo = changeListData[clinfo.lid - 1];
  1075. if (listinfo === undefined) {
  1076. toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
  1077. // changeList.splice(index, 1);
  1078. removeList.push(clinfo);
  1079. continue;
  1080. }
  1081. $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').addClass('table-success');
  1082. let pushbwmx = '0*;*0';
  1083. if (listinfo.leafXmjs !== undefined) {
  1084. const leafInfo = listinfo.leafXmjs.find(function (item) {
  1085. const flag = (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && item.gcl_id === clinfo.gcl_id && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
  1086. if (flag && item.code === clinfo.xmj_code) {
  1087. return flag && item.code === clinfo.xmj_code;
  1088. }
  1089. return flag;
  1090. });
  1091. if (leafInfo) {
  1092. info = leafInfo;
  1093. pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' +
  1094. (leafInfo.dwgc ? leafInfo.dwgc : '') + '!_!' +
  1095. (leafInfo.fbgc ? leafInfo.fbgc : '') + '!_!' +
  1096. (leafInfo.fxgc ? leafInfo.fxgc : '') + '!_!' +
  1097. (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' +
  1098. (leafInfo.mx_id ? leafInfo.mx_id : '') + '!_!' +
  1099. (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (listinfo.leafXmjs.length > 1 && listinfo.name ? listinfo.name : (leafInfo.jldy !== undefined ? leafInfo.jldy : ''))) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
  1100. } else {
  1101. toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
  1102. // changeList.splice(index, 1);
  1103. removeList.push(clinfo);
  1104. continue;
  1105. }
  1106. } else {
  1107. pushbwmx = '0*;*' + (listinfo.quantity !== null ? listinfo.quantity : 0);
  1108. }
  1109. const bwmx = $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx');
  1110. if (bwmx) {
  1111. const bwmxArray = bwmx.split('$#$');
  1112. bwmxArray.push(pushbwmx);
  1113. $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
  1114. } else {
  1115. $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx', pushbwmx);
  1116. }
  1117. } else {
  1118. $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').addClass('table-success');
  1119. let pushbwmx = '0*;*0';
  1120. if (listinfo.leafXmjs !== undefined) {
  1121. const leafInfo = listinfo.leafXmjs.find(function (item) {
  1122. const flag = (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && item.gcl_id === clinfo.gcl_id && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
  1123. if (flag && item.code === clinfo.xmj_code) {
  1124. return flag && item.code === clinfo.xmj_code;
  1125. }
  1126. return flag;
  1127. });
  1128. if (leafInfo) {
  1129. info = leafInfo;
  1130. pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' +
  1131. (leafInfo.dwgc ? leafInfo.dwgc : '') + '!_!' +
  1132. (leafInfo.fbgc ? leafInfo.fbgc : '') + '!_!' +
  1133. (leafInfo.fxgc ? leafInfo.fxgc : '') + '!_!' +
  1134. (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' +
  1135. (leafInfo.mx_id ? leafInfo.mx_id : '') + '!_!' +
  1136. (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (listinfo.leafXmjs.length > 1 && listinfo.name ? listinfo.name : (leafInfo.jldy !== undefined ? leafInfo.jldy : ''))) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
  1137. } else {
  1138. // console.log(clinfo, listinfo.leafXmjs);
  1139. toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
  1140. // changeList.splice(index, 1);
  1141. removeList.push(clinfo);
  1142. continue;
  1143. }
  1144. } else {
  1145. pushbwmx = '0*;*' + (listinfo.quantity !== null ? listinfo.quantity : 0);
  1146. }
  1147. const bwmx = $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx');
  1148. if (bwmx) {
  1149. const bwmxArray = bwmx.split('$#$');
  1150. bwmxArray.push(pushbwmx);
  1151. $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
  1152. } else {
  1153. $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx', pushbwmx);
  1154. }
  1155. }
  1156. if (info && _.findIndex(changeLedgerList, { id: clinfo.gcl_id }) !== -1) {
  1157. // 可能因为升降级关系:细目,分部分项等会发生变化,更新清单
  1158. const updateInfo = {};
  1159. if (info.code !== clinfo.xmj_code) {
  1160. updateInfo.xmj_code = info.code;
  1161. changeList[index].xmj_code = info.code;
  1162. }
  1163. if (info.jldy !== clinfo.xmj_jldy) {
  1164. updateInfo.xmj_jldy = info.jldy;
  1165. changeList[index].xmj_jldy = info.jldy;
  1166. }
  1167. if (info.dwgc !== clinfo.xmj_dwgc) {
  1168. updateInfo.xmj_dwgc = info.dwgc;
  1169. changeList[index].xmj_dwgc = info.dwgc;
  1170. }
  1171. if (info.fbgc !== clinfo.xmj_fbgc) {
  1172. updateInfo.xmj_fbgc = info.fbgc;
  1173. changeList[index].xmj_fbgc = info.fbgc;
  1174. }
  1175. if (info.fxgc !== clinfo.xmj_fxgc) {
  1176. updateInfo.xmj_fxgc = info.fxgc;
  1177. changeList[index].xmj_fxgc = info.fxgc;
  1178. }
  1179. if (!_.isEmpty(updateInfo) && _.indexOf(updateGclIdList, clinfo.gcl_id) === -1) {
  1180. updateGclIdList.push(clinfo.gcl_id);
  1181. // updateInfo.gcl_id = info.id;
  1182. updateList.push({ row: updateInfo, where: { tid: tenderId, gcl_id: clinfo.gcl_id } });
  1183. }
  1184. }
  1185. }
  1186. }
  1187. if(updateList.length > 0) {
  1188. // console.log(updateList);
  1189. postData(window.location.pathname + '/save', { type:'update_list', updateData: updateList }, function (result) {
  1190. }, function () {
  1191. });
  1192. }
  1193. if(removeList.length > 0) {
  1194. _.pullAll(changeList, removeList);
  1195. postData(window.location.pathname + '/save', { type:'remove_list', updateData: removeList }, function (result) {
  1196. }, function () {
  1197. });
  1198. }
  1199. }
  1200. }
  1201. // 清单搜索隐藏清单table部分值
  1202. function makeListTable(changeListData, showListData = changeListData) {
  1203. // 先加载台账数据
  1204. let listHtml = '';
  1205. let list_index = 1;
  1206. let gcl_index = 0;
  1207. for (const [index,gcl] of changeListData.entries()) {
  1208. const isShow = _.find(showListData, gcl);
  1209. $('#table-list-select tr').eq(index).css('display', (isShow ? 'table-row' : 'none'));
  1210. }
  1211. }
  1212. // 项目节搜索隐藏code-table部分值
  1213. function makeCodeTable(search = '') {
  1214. if (search === '') {
  1215. $('#code-list tr').css('display', 'table-row');
  1216. return;
  1217. }
  1218. $('#code-list tr').css('display', 'none');
  1219. if (searchCodeList.length > 0) {
  1220. for (const [index,list] of searchCodeList.entries()) {
  1221. if (list.indexOf(search) !== -1) {
  1222. $('#code-list tr').eq(index).css('display', 'table-row');
  1223. }
  1224. }
  1225. } else {
  1226. for(let i = 0; i < $('#code-list tr').length; i++) {
  1227. const length = $('#code-list tr').eq(i).children('td').length;
  1228. if (length === 9) {
  1229. const code = $('#code-list tr').eq(i).children('td').eq(1).text();
  1230. const name = $('#code-list tr').eq(i).children('td').eq(2).text();
  1231. const jldy = $('#code-list tr').eq(i).children('td').eq(6).text();
  1232. const isShow = code.indexOf(search) !== -1 || name.indexOf(search) !== -1 || jldy.indexOf(search) !== -1;
  1233. if (isShow) {
  1234. $('#code-list tr').eq(i).css('display', 'table-row');
  1235. }
  1236. // $('#code-list tr').eq(i).css('display', (isShow ? 'table-row' : 'none'));
  1237. } else {
  1238. return;
  1239. }
  1240. }
  1241. }
  1242. }
  1243. function remakeChangeSpread() {
  1244. const newTableList = [];
  1245. // 获取选中的签约清单判断并插入到原有清单中
  1246. $('#table-list-select .table-success').each(function(){
  1247. let code = $(this).children('td').eq(1).text();
  1248. let name = $(this).children('td').eq(2).text();
  1249. let unit = $(this).children('td').eq(3).text();
  1250. let price = $(this).children('td').eq(4).text();
  1251. // let oamount = $(this).children('td').eq(5).text();
  1252. // 根据单位获取数量的位数,并得出
  1253. // let numdecimal = findDecimal(unit);
  1254. // let scnum = makedecimalzero(numdecimal);
  1255. let scnum = 0;
  1256. // let detail = $(this).attr('data-detail') != 0 ? $(this).attr('data-detail').split('_')[1] : '';
  1257. let lid = $(this).data('lid');
  1258. let lindex = $(this).data('index');
  1259. // 原清单和数量改变
  1260. let data_bwmx = $(this).attr('data-bwmx').split('$#$');
  1261. for (const b of data_bwmx) {
  1262. const oamount = b.split('*;*')[1] != '' ? b.split('*;*')[1] : 0;
  1263. let bwmx = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[7] : '';
  1264. let xmj_code = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[0] : '';
  1265. let xmj_jldy = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[1] : '';
  1266. let xmj_dwgc = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[2] : '';
  1267. let xmj_fbgc = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[3] : '';
  1268. let xmj_fxgc = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[4] : '';
  1269. let gcl_id = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[5] : '';
  1270. let mx_id = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[6] : '';
  1271. let trlist = {
  1272. code,
  1273. name,
  1274. bwmx,
  1275. unit,
  1276. unit_price: price,
  1277. oamount,
  1278. camount: scnum,
  1279. detail: '',
  1280. lid,
  1281. xmj_code,
  1282. xmj_jldy,
  1283. xmj_dwgc,
  1284. xmj_fbgc,
  1285. xmj_fxgc,
  1286. gcl_id,
  1287. mx_id,
  1288. };
  1289. const radionInfo = changeList.find(function (info) {
  1290. return info.code === code && (info.lid == lid || parseInt(info.lid) === parseInt(lindex)) && gcl_id == info.gcl_id && (info.bwmx === bwmx || info.bwmx === xmj_jldy) && parseInt(info.oamount) === parseInt(oamount);
  1291. });
  1292. if (radionInfo) {
  1293. trlist.camount = radionInfo.camount;
  1294. trlist.detail = radionInfo.detail;
  1295. }
  1296. newTableList.push(trlist);
  1297. }
  1298. });
  1299. // const changeWhiteList = _.filter(changeList, function (item) {
  1300. // return item.lid == 0;
  1301. // });
  1302. // console.log(newTableList);
  1303. // changeList = newTableList.concat(changeWhiteList);
  1304. return newTableList;
  1305. }
  1306. //判断元素是否在数组中,相当于php的in_array();
  1307. function in_array(arr, obj) {
  1308. let i = arr.length;
  1309. while (i--) {
  1310. if (arr[i] == obj) {
  1311. return true;
  1312. }
  1313. }
  1314. return false;
  1315. }
  1316. function isObjEqual(o1,o2){
  1317. var props1 = Object.getOwnPropertyNames(o1);
  1318. var props2 = Object.getOwnPropertyNames(o2);
  1319. if (props1.length != props2.length) {
  1320. return false;
  1321. }
  1322. for (var i = 0,max = props1.length; i < max; i++) {
  1323. var propName = props1[i];
  1324. if (o1[propName] !== o2[propName]) {
  1325. return false;
  1326. }
  1327. }
  1328. return true;
  1329. }
  1330. // 判断是否有更改过
  1331. function judgeChange() {
  1332. let change = false;
  1333. if (!isObjEqual(changeInfo, back_changeInfo)) {
  1334. change = true;
  1335. }
  1336. if (change) {
  1337. $('#show-save-btn').show();
  1338. $('#sp-btn').hide();
  1339. $('.title-main').addClass('bg-warning');
  1340. } else {
  1341. $('#show-save-btn').hide();
  1342. $('#sp-btn').show();
  1343. $('.title-main').removeClass('bg-warning');
  1344. }
  1345. }
  1346. function changeFormRemake() {
  1347. changeInfo = Object.assign({}, back_changeInfo);
  1348. $('#change_form input[name="code"]').val(changeInfo.code);
  1349. $('#change_form input[name="name"]').val(changeInfo.name);
  1350. $('#change_form input[name="peg"]').val(changeInfo.peg);
  1351. $('#change_form input[name="org_name"]').val(changeInfo.org_name);
  1352. $('#change_form input[name="org_code"]').val(changeInfo.org_code);
  1353. $('#change_form input[name="new_name"]').val(changeInfo.new_name);
  1354. $('#change_form input[name="new_code"]').val(changeInfo.new_code);
  1355. $('#change_form textarea[name="content"]').val(changeInfo.content.replace(/<br><br>/g, '\r\n'));
  1356. $('#change_form textarea[name="basis"]').val(changeInfo.basis.replace(/<br><br>/g, '\r\n'));
  1357. $('#change_form textarea[name="expr"]').val(changeInfo.expr.replace(/<br><br>/g, '\r\n'));
  1358. $('#change_form textarea[name="memo"]').val(changeInfo.memo.replace(/<br><br>/g, '\r\n'));
  1359. $('#change_form select[name="type"]').val(changeInfo.type);
  1360. $('#change_form select[name="class"]').val(changeInfo.class);
  1361. $('#change_form select[name="quality"]').val(changeInfo.quality);
  1362. $('#change_form select[name="company"]').val(changeInfo.company);
  1363. $('#change_form input[name="charge"][value="'+ changeInfo.charge +'"]').prop('checked', true);
  1364. $('#change_form input[name="type[]"]').prop('checked', false);
  1365. const typecheck = changeInfo.type.split(',');
  1366. for (const type of typecheck) {
  1367. $('#change_form input[name="type[]"][value="'+ type +'"]').prop('checked', true);
  1368. }
  1369. }