glj_view.js 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659
  1. /**
  2. * Created by CSL on 2017-05-12.
  3. */
  4. var gljOprObj = {
  5. sheet: null,
  6. libID: null,
  7. ration: null,
  8. sheetData: [],
  9. coeSheetData: [],
  10. checkb: null,
  11. coeSheet: null,
  12. assSheet: null,
  13. assSheetData: [],
  14. detailSheet: null,
  15. detailData: [],
  16. GLJSelection: [],
  17. selectedGLJClass: null,
  18. parentNodeIds: {},
  19. activeTab: '#linkGLJ',
  20. setting: {
  21. header: [
  22. {headerName: "编码", headerWidth: 100, dataCode: "code", dataType: "String", formatter: "@"},
  23. {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
  24. {headerName: "规格型号", headerWidth: 90, dataCode: "specs", dataType: "String", hAlign: "left"},
  25. {headerName: "单位", headerWidth: 45, dataCode: "unit", dataType: "String", hAlign: "center"},
  26. {headerName: "类型", headerWidth: 45, dataCode: "shortName", dataType: "String", hAlign: "center"},
  27. {
  28. headerName: "定额消耗",
  29. headerWidth: 80,
  30. dataCode: "rationItemQuantity",
  31. dataType: "Number",
  32. hAlign: "right",
  33. decimalField: "glj.quantity"
  34. }, // dataType: "Number", formatter: "0.00"
  35. {
  36. headerName: "自定消耗",
  37. headerWidth: 80,
  38. dataCode: "customQuantity",
  39. dataType: "Number",
  40. hAlign: "right",
  41. decimalField: "glj.quantity"
  42. },
  43. {
  44. headerName: "消耗量",
  45. headerWidth: 80,
  46. dataCode: "quantity",
  47. dataType: "Number",
  48. hAlign: "right",
  49. decimalField: "glj.quantity"
  50. },
  51. {
  52. headerName: "总消耗量",
  53. headerWidth: 80,
  54. dataCode: "totalQuantity",
  55. dataType: "Number",
  56. hAlign: "right",
  57. decimalField: "glj.quantity"
  58. },
  59. {
  60. headerName: "定额价",
  61. headerWidth: 80,
  62. dataCode: "basePrice",
  63. dataType: "Number",
  64. hAlign: "right",
  65. decimalField: "glj.unitPrice"
  66. },
  67. {
  68. headerName: "调整价",
  69. headerWidth: 80,
  70. dataCode: "adjustPrice",
  71. dataType: "Number",
  72. hAlign: "right",
  73. decimalField: "glj.unitPrice"
  74. },
  75. {
  76. headerName: "市场价",
  77. headerWidth: 80,
  78. dataCode: "marketPrice",
  79. dataType: "Number",
  80. hAlign: "right",
  81. decimalField: "glj.unitPrice"
  82. },
  83. {
  84. headerName: "是否暂估",
  85. headerWidth: 65,
  86. dataCode: "isEstimate",
  87. dataType: "String",
  88. hAlign: "center",
  89. vAlign: "center",
  90. cellType: "checkBox"
  91. }
  92. ],
  93. view: {
  94. comboBox: [{row: -1, col: 12, rowCount: -1, colCount: 1}],
  95. lockedCells: [{row: -1, col: 3, rowCount: -1, colCount: 1}],
  96. lockColumns: [0, 4, 5, 7, 8, 10, 12]
  97. },
  98. // 工料机类型是混凝土、砂浆、配合比、机械台班时,价格不可编辑。
  99. editedTyep:[GLJTypeConst.MAIN_MATERIAL,GLJTypeConst.EQUIPMENT]//主材设备
  100. },
  101. coeSetting: {
  102. header: [
  103. {headerName: "调整", headerWidth: 100, dataCode: "isAdjust", dataType: "String", cellType: "checkBox"},
  104. {headerName: "条件", headerWidth: 120, dataCode: "name", dataType: "String", cellType: "button"},
  105. {headerName: "内容", headerWidth: 350, dataCode: "content", dataType: "String", hAlign: "left"}
  106. ],
  107. view: {
  108. lockColumns: [0, 1, 2]
  109. }
  110. },
  111. assSetting: {
  112. header: [
  113. {headerName: "调整名称", headerWidth: 100, dataCode: "name", dataType: "String"},
  114. {headerName: "定额值", headerWidth: 120, dataCode: "stdValue", hAlign: "right", dataType: "String"},
  115. {headerName: "实际值", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"}
  116. ],
  117. view: {
  118. lockColumns: [0, 1]
  119. }
  120. },
  121. detailSetting: {
  122. header: [
  123. {headerName: "名称", headerWidth: 100, dataCode: "name", dataType: "String"},
  124. {headerName: "计算式", headerWidth: 120, dataCode: "regex", dataType: "String"},
  125. {
  126. headerName: "结果(C)",
  127. headerWidth: 120,
  128. dataCode: "result",
  129. dataType: "Number",
  130. decimalField: "quantity_detail"
  131. },
  132. {headerName: "累加", headerWidth: 120, dataCode: "isSummation", dataType: "String", cellType: "checkBox"}
  133. ],
  134. view: {
  135. lockColumns: [2, 3]
  136. }
  137. },
  138. gljTreeSetting: {
  139. view: {
  140. //addHoverDom: gljTypeTreeOprObj.addHoverDom,
  141. //removeHoverDom: gljTypeTreeOprObj.removeHoverDom,
  142. expandSpeed: "",
  143. selectedMulti: false
  144. },
  145. edit: {
  146. enable: false,
  147. editNameSelectAll: true,
  148. showRemoveBtn: true,
  149. showRenameBtn: true,
  150. removeTitle: "删除节点",
  151. renameTitle: "更改名称"
  152. },
  153. data: {
  154. keep: {
  155. parent: true,
  156. leaf: true
  157. },
  158. key: {
  159. children: "items",
  160. name: "Name"
  161. },
  162. simpleData: {
  163. enable: false,
  164. idKey: "ID",
  165. pIdKey: "ParentID",
  166. rootPId: -1
  167. }
  168. },
  169. callback: {
  170. onClick: function (event, treeId, treeNode) {
  171. if (treeId == 'gljTree') {
  172. let me = gljOprObj, gljTypeId = treeNode.ID;
  173. if (me.gljCurTypeId !== treeNode.ID) {
  174. me.gljCurTypeId = treeNode.ID;
  175. me.filterLibGLJSheetData();
  176. me.showLibGLJSheetData();
  177. }
  178. } else {
  179. if (treeNode.isParent) {
  180. $('#class_selected_conf').attr("disabled", "disabled");
  181. $('#selected_class').val("");
  182. } else {
  183. $('#class_selected_conf').removeAttr("disabled");
  184. $('#selected_class').val(treeNode.ID);
  185. }
  186. }
  187. }
  188. }
  189. },
  190. gljLibSheetSetting: {
  191. owner: 'gljTree',
  192. header: [
  193. {
  194. headerName: "选择",
  195. headerWidth: 40,
  196. dataCode: "select",
  197. hAlign: "center",
  198. vAlign: "center",
  199. cellType: "checkBox"
  200. },
  201. {
  202. headerName: "编码",
  203. headerWidth: 80,
  204. dataCode: "code",
  205. dataType: "String",
  206. formatter: "@",
  207. hAlign: "left",
  208. vAlign: "center"
  209. },
  210. {
  211. headerName: "名称",
  212. headerWidth: 120,
  213. dataCode: "name",
  214. dataType: "String",
  215. hAlign: "left",
  216. vAlign: "center"
  217. },
  218. {
  219. headerName: "规格型号",
  220. headerWidth: 80,
  221. dataCode: "specs",
  222. dataType: "String",
  223. hAlign: "center",
  224. vAlign: "center"
  225. },
  226. {
  227. headerName: "单位",
  228. headerWidth: 40,
  229. dataCode: "unit",
  230. dataType: "String",
  231. hAlign: "center",
  232. vAlign: "center"
  233. },
  234. {
  235. headerName: "单价",
  236. headerWidth: 80,
  237. dataCode: "basePrice",
  238. dataType: "Number",
  239. formatter: "0.00",
  240. hAlign: "right",
  241. vAlign: "center"
  242. },
  243. {
  244. headerName: "类型",
  245. headerWidth: 80,
  246. dataCode: "gljType",
  247. dataType: "String",
  248. hAlign: "center",
  249. vAlign: "center"
  250. }
  251. ],
  252. view: {
  253. lockColumns: [0, 1, 2, 3, 4, 5, 6]
  254. }
  255. },
  256. gljLibSheet: null,
  257. initSheet: function (sheet) {
  258. var me = this;
  259. me.sheet = sheet;
  260. sheetCommonObj.initSheet(me.sheet, me.setting, 30);
  261. sheet.name('ration_glj');
  262. me.bindSheetEvent(sheet);
  263. sheet.bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
  264. sheet.bind(GC.Spread.Sheets.Events.CellDoubleClick, me.onCellDoubleClick);
  265. gljContextMenu.loadGLJSpreadContextMenu();
  266. },
  267. initCoeSheet: function (sheet) {
  268. var me = this;
  269. me.coeSheet = sheet;
  270. sheetCommonObj.initSheet(me.coeSheet, me.coeSetting, 30);
  271. sheet.name('ration_coe');
  272. me.bindSheetEvent(sheet);
  273. sheet.bind(GC.Spread.Sheets.Events.CellClick, me.onCoeCellClick);
  274. subSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClick);
  275. },
  276. initAssSheet: function (sheet) {
  277. var me = this;
  278. me.assSheet = sheet;
  279. sheetCommonObj.initSheet(me.assSheet, me.assSetting, 30);
  280. sheet.name('ration_ass');
  281. me.bindSheetEvent(sheet);
  282. },
  283. initDetailSheet: function (sheet) {
  284. var me = this;
  285. me.detailSheet = sheet;
  286. sheetCommonObj.initSheet(me.detailSheet, me.detailSetting, 30);
  287. // me.detailSheet.selectionUnit(0);//0 cell,1 row,2 col;
  288. sheet.name('quantity_detail');
  289. me.bindSheetEvent(sheet);
  290. },
  291. showCoeData: function (sheet, setting, datas) {
  292. sheet.floatingObjects.remove("customerCoe");
  293. sheetCommonObj.showData(sheet, setting, datas);
  294. if (datas.length > 0) {
  295. var cus_index = _.findIndex(datas, function (item) {
  296. return item.coeID == -1;
  297. })
  298. if (cus_index != -1) {
  299. this.addDropDownList();
  300. this.addCusButton(cus_index, 1, datas[cus_index].name);
  301. }
  302. }
  303. },
  304. bindSheetEvent: function (sheet) {
  305. var me = this;
  306. sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
  307. sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
  308. sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
  309. sheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
  310. // sheet.bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
  311. },
  312. onClipboardPasting: function (sender, args) {
  313. var me = gljOprObj;
  314. if (!me.ration) {
  315. args.cancel = true;
  316. }
  317. },
  318. onClipboardPasted: function (e, info) {
  319. var me = gljOprObj;
  320. console.log('past');
  321. // if (!me.ration) {return;};
  322. // your code...
  323. },
  324. onEditEnded: function (sender, args) {
  325. var me = gljOprObj;
  326. if (args.sheetName == 'ration_glj') {
  327. me.onEditGLJSheet(args)
  328. }
  329. if (args.sheetName == 'ration_ass') {
  330. me.onEditAssSheet(args);
  331. }
  332. if (args.sheetName == 'quantity_detail') {
  333. me.onEditDetailSheet(args);
  334. }
  335. },
  336. onEditDetailSheet: function (args) {
  337. var me = gljOprObj;
  338. if (args.row > me.detailData.length) {
  339. return;
  340. }
  341. if (args.row == me.detailData.length && args.editingText == null) {
  342. return;
  343. }
  344. var selected = projectObj.project.mainTree.selected;//因为使用了延时方法,所以要先取得选中行;
  345. var detailList = me.detailData;
  346. args.editingText = args.editingText.replace(/(/g, "(");//替换中文左右括号;
  347. args.editingText = args.editingText.replace(/)/g, ")");
  348. setTimeout(function () {//这里须用延时执行的办法,不然的弹窗确认窗口会和spreadjs 的事件有冲突,造成定额工料机数据不会根据树结点更新的问题
  349. if (args.row == detailList.length) {
  350. projectObj.project.quantity_detail.saveQuantityDetail(args, me.detailSetting.header[args.col].dataCode, selected);
  351. }
  352. if (args.row < detailList.length) {
  353. projectObj.project.quantity_detail.updateQuantityDetail(args, me.detailSetting.header[args.col].dataCode, detailList[args.row], selected);
  354. }
  355. }, 100);
  356. },
  357. onEditGLJSheet: function (args) {
  358. var me = gljOprObj;
  359. if (args.row >= me.sheetData.length) {
  360. me.sheet.getCell(args.row, args.col).value(null);
  361. return;
  362. }
  363. me.updateRationGLJ(args);
  364. },
  365. onEditAssSheet: function (args) {
  366. var me = gljOprObj;
  367. if (args.row >= me.assSheetData.length) {
  368. me.assSheet.getCell(args.row, args.col).value(null);
  369. return;
  370. }
  371. if (me.assSetting.header[args.col].dataCode == 'actualValue') {//自定义消耗量
  372. me.updateRationAss(args);
  373. }
  374. },
  375. onButtonClick: function (sender, args) {
  376. var me = gljOprObj;
  377. var sheet = args.sheet, row = args.row, col = args.col;
  378. var cellType = sheet.getCellType(row, col);
  379. if (cellType instanceof GC.Spread.Sheets.CellTypes.Button) {
  380. me.onCusButtonClick(sender, args);
  381. } else {
  382. me.onCheckBoxClick(sender, args)
  383. }
  384. },
  385. onCheckBoxClick: function (sender, args) {
  386. var checkboxValue = args.sheet.getCell(args.row, args.col).value();
  387. var newval = 0;
  388. if (checkboxValue) {
  389. newval = 0;
  390. args.sheet.getCell(args.row, args.col).value(newval);
  391. } else {
  392. newval = 1;
  393. args.sheet.getCell(args.row, args.col).value(newval);
  394. }
  395. if (args.sheetName == 'ration_glj') {
  396. gljOprObj.updateIsEstimate(args,newval);
  397. } else if (args.sheetName == 'ration_coe') {
  398. gljOprObj.updateRationCoe(args, newval)
  399. } else if (args.sheetName == 'quantity_detail') {
  400. projectObj.project.quantity_detail.isSummationUpdate(args, gljOprObj.detailData, newval);
  401. } else if (args.sheetName == 'glj_lib') {
  402. gljOprObj.setGLJSelection(args, newval);
  403. }
  404. },
  405. onCusButtonClick: function (sender, args) {
  406. var me = gljOprObj;
  407. var floatingObject = me.coeSheet.floatingObjects.get('customerCoe');
  408. var isVisable = floatingObject.isVisible();
  409. if (!isVisable) {
  410. me.coeSheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).locked(false);
  411. me.showFloationObject(floatingObject, me.coeSheetData[args.row]);
  412. } else {
  413. var result = me.checkIfNeedUpdate();
  414. if (result.isNeed) {
  415. projectObj.project.ration_coe.updateCustomerCoe(result);
  416. }
  417. floatingObject.isVisible(false);
  418. }
  419. },
  420. onCellClick: function (sender, args) {
  421. var me = gljOprObj;
  422. if (args.row >= me.sheetData.length) {
  423. return;
  424. }
  425. me.editChecking(args);
  426. },
  427. onCellDoubleClick:function (sender, args) {
  428. var me = gljOprObj;
  429. var header = me.setting.header;
  430. if (args.row >= me.sheetData.length) {
  431. return;
  432. }
  433. if (header[args.col] && header[args.col].dataCode == 'marketPrice') {
  434. if(me.hasComposition(me.sheetData[args.row])){
  435. alert("当前工料机的市场价由组成物计算得出,不可直接修改。");
  436. }
  437. }
  438. if (header[args.col] && header[args.col].dataCode == 'basePrice') {
  439. var isAdd = me.sheetData[args.row].isAdd;
  440. if(isAdd==1){//是新增但没有组成物时允许修改定额价
  441. if(me.hasComposition(me.sheetData[args.row])){//如果有组成物,不可修改
  442. alert("当前工料机的定额价由组成物计算得出,不可直接修改。");
  443. }
  444. }
  445. }
  446. },
  447. onCoeCellClick: function (sender, args) {
  448. var me = gljOprObj;
  449. var floatingObject = me.coeSheet.floatingObjects.get('customerCoe');
  450. var isVisable = floatingObject.isVisible();
  451. /* if($('#dropdown').css("display") == 'none'){
  452. if(args.col==1&&me.coeSheetData.length>args.row&&me.coeSheetData[args.row].coeID==-1){
  453. me.showFloationObject(floatingObject,me.coeSheetData[args.row]);
  454. }
  455. }*/
  456. if (isVisable) {
  457. var result = me.checkIfNeedUpdate();
  458. if (result.isNeed) {
  459. projectObj.project.ration_coe.updateCustomerCoe(result);
  460. }
  461. floatingObject.isVisible(false);
  462. // $('#dropdown').hide();
  463. }
  464. },
  465. showFloationObject(floatingObject, data){
  466. floatingObject.isVisible(true);
  467. var sheet = this.coeSheet;
  468. var startRow = this.coeSheetData.length;
  469. var endRow = startRow + 7;
  470. floatingObject.startRow(startRow);
  471. floatingObject.startColumn(1);
  472. floatingObject.endColumn(2);
  473. floatingObject.endRow(endRow);
  474. this.bindFloadingObjectValue(data);
  475. sheet.repaint();
  476. // var editPosition = $("#edit").offset();
  477. //$('#dropdown').show();
  478. //var top =editPosition.top>=825?825:editPosition.top
  479. //$('#dropdown').offset({left:editPosition.left,top:top});//top: 791px; left:70px;
  480. },
  481. bindFloadingObjectValue(data){
  482. $('#coe_ration').val(data.coes[0].amount);
  483. $('#manual').val(data.coes[1].amount);
  484. $('#material').val(data.coes[2].amount);
  485. $('#manchine').val(data.coes[3].amount);
  486. $('#mainM').val(data.coes[4].amount);
  487. $('#equipment').val(data.coes[5].amount);
  488. },
  489. onInputChange(id, name){
  490. var coe = _.find(gljOprObj.coeSheetData, function (c) {
  491. return c.coeID == -1;
  492. });
  493. var newValue = gljOprObj.numberValueChecking($('#' + id).val());
  494. if (newValue) {
  495. newValue = _.round(newValue, 2);
  496. if (newValue == coe.coes[name].amount) return;
  497. if (id == 'coe_ration') {
  498. $('#coe_ration').val(newValue);
  499. $('#manual').val(newValue);
  500. $('#material').val(newValue);
  501. $('#manchine').val(newValue);
  502. $('#mainM').val(newValue);
  503. $('#equipment').val(newValue);
  504. } else {
  505. $('#' + id).val(newValue);
  506. }
  507. } else {
  508. $('#' + id).val(coe.coes[name].amount);
  509. }
  510. },
  511. checkIfNeedUpdate(){
  512. var data = _.find(gljOprObj.coeSheetData, function (c) {
  513. return c.coeID == -1;
  514. });
  515. var result = {
  516. isNeed: false
  517. }
  518. var coe_ration = $('#coe_ration').val();
  519. var manual = $('#manual').val();
  520. var material = $('#material').val();
  521. var manchine = $('#manchine').val();
  522. var mainM = $('#mainM').val();
  523. var equipment = $('#equipment').val();
  524. if (coe_ration != data.coes[0].amount) {
  525. result.isNeed = true;
  526. data.coes[0].amount = coe_ration;
  527. }
  528. if (manual != data.coes[1].amount) {
  529. result.isNeed = true;
  530. data.coes[1].amount = manual;
  531. }
  532. if (material != data.coes[2].amount) {
  533. result.isNeed = true;
  534. data.coes[2].amount = material;
  535. }
  536. if (manchine != data.coes[3].amount) {
  537. result.isNeed = true;
  538. data.coes[3].amount = manchine;
  539. }
  540. if (mainM != data.coes[4].amount) {
  541. result.isNeed = true;
  542. data.coes[4].amount = mainM;
  543. }
  544. if (equipment != data.coes[5].amount) {
  545. result.isNeed = true;
  546. data.coes[5].amount = equipment;
  547. }
  548. if (result.isNeed) {
  549. result.doc = {
  550. coes: data.coes
  551. };
  552. result.query = {
  553. projectID: data.projectID,
  554. ID: data.ID,
  555. rationID: data.rationID
  556. };
  557. }
  558. return result;
  559. },
  560. editChecking: function (args) {
  561. var me = gljOprObj;
  562. var header = me.setting.header;
  563. var disable = null;
  564. if (me.sheetData[args.row] != undefined) {
  565. if (me.sheetData[args.row].isMixRatio) {
  566. disable = true;
  567. }else {
  568. if (header[args.col] && header[args.col].dataCode == 'marketPrice') {
  569. if(me.hasComposition(me.sheetData[args.row])){
  570. disable = true;
  571. }else {
  572. disable = false;
  573. }
  574. }
  575. if (header[args.col] && header[args.col].dataCode == 'basePrice') {
  576. var isAdd = me.sheetData[args.row].isAdd;
  577. if(isAdd==1){//是新增但没有组成物时允许修改定额价
  578. if(me.hasComposition(me.sheetData[args.row])){//如果有组成物,不可修改
  579. disable = true;
  580. }else {
  581. disable = false;
  582. }
  583. } else {
  584. disable = true;
  585. }
  586. }
  587. }
  588. }
  589. if (disable != null) {
  590. me.sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).locked(disable);
  591. }
  592. },
  593. hasComposition:function (ration_glj) {//判断是否有组成物,有则返回true
  594. if(notEditType.indexOf(ration_glj.type)!=-1){
  595. let con_key = this.getIndex(ration_glj,gljKeyArray);
  596. var mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
  597. if(mixRatioMap[con_key]&&mixRatioMap[con_key].length>0){
  598. return true;
  599. }
  600. }
  601. return false;
  602. },
  603. addDropDownList: function () {
  604. var sheet = this.coeSheet;
  605. sheet.suspendPaint();
  606. var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("customerCoe");
  607. var div = document.createElement('div');
  608. div.innerHTML = this.generateHtmlString();
  609. customFloatingObject.startRow(1);
  610. customFloatingObject.startColumn(1);
  611. customFloatingObject.endColumn(2);
  612. customFloatingObject.endRow(2);
  613. $(div).css('background', 'white');
  614. customFloatingObject.content(div);
  615. sheet.floatingObjects.add(customFloatingObject);
  616. customFloatingObject.isVisible(false);
  617. sheet.resumePaint();
  618. },
  619. addCusButton: function (row, col, text) {
  620. var cus_button = new GC.Spread.Sheets.CellTypes.Button();
  621. gljOprObj.coeSheet.setCellType(row, col, cus_button, GC.Spread.Sheets.SheetArea.viewport);
  622. cus_button.marginLeft(0);
  623. cus_button.marginTop(0);
  624. cus_button.marginRight(0);
  625. cus_button.marginBottom(0);
  626. cus_button.text(text);
  627. cus_button.buttonBackColor('white');
  628. gljOprObj.coeSheet.repaint();
  629. },
  630. onRangeChanged: function (sender, args) {
  631. var me = gljOprObj;
  632. if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
  633. args.editingText = null;
  634. if (args.sheetName == 'ration_glj') {
  635. me.onEditGLJSheet(args);
  636. }
  637. if (args.sheetName == 'ration_ass') {
  638. me.updateRationAss(args);
  639. }
  640. }
  641. ;
  642. },
  643. generateHtmlString: function () {
  644. // return "<div id='edit'><div>";
  645. var newString = "<form ><table border='1px' bordercolor='#CCCCCC' cellspacing='0px' style='border-collapse:collapse;font-size: 10px;>";
  646. //newString +="<tr><td style='height:15px' colspan='2'>自定义系数</td></tr>"
  647. newString += this.getOneRow('定额', 0, 'coe_ration');
  648. newString += this.getOneRow('人工', 1, 'manual');
  649. newString += this.getOneRow('材料', 2, 'material');
  650. newString += this.getOneRow('机械', 3, 'manchine');
  651. newString += this.getOneRow('主材', 4, 'mainM');
  652. newString += this.getOneRow('设备', 5, 'equipment');
  653. newString += "</table></form>";
  654. return newString;
  655. //"<form id='edit'><table border='1px' bordercolor='#CCCCCC' cellspacing='0px' style='border-collapse:collapse;font-size: 10px;><tr style='height:10px'><td style='width: 50px'>定额:</td><td style='width: 70px' align='right'><input type='text'value='1' name='ration' style='width:30px;border:0;height:14px' align='right'></td></tr><tr><td>定额:</td><td><input type='text' style='width:50px;border:0;height:10px'></td></tr><tr><td>定额:</td><td><input type='text' style='width:50px;border:0;height:10px'></td></tr><tr ><td>定额:</td><td><input type='text' style='width:50px;border:0;height:10px'></td></tr><tr><td>定额:</td><td><input type='text' style='width:50px;border:0;height:10px'></td></tr></table></form>";
  656. },
  657. getOneRow: function (text, name, id) {
  658. var rowstr = "<tr style='height:10px'><td style='width: 50px'>" + text
  659. + ":</td><td style='width: 70px' align='right'><input type='text'value='1' name=" + name
  660. + " style='width:30px;border:0;height:14px' align='right' id=" + id + " onchange='gljOprObj.onInputChange(this.id,this.name)'></td></tr>";
  661. return rowstr;
  662. },
  663. showDataIfRationSelect: function (node) {
  664. var isShow = false;
  665. if (node) {
  666. if (this.selectedNodeId && this.selectedNodeId == node.getID()) {
  667. return;
  668. } else {
  669. this.selectedNodeId = node.getID();
  670. }
  671. if (node.sourceType == "ration") {
  672. this.showRationGLJData(node);
  673. this.showRationCoeData(node);
  674. this.showRationAssData(node);
  675. isShow = true;
  676. }
  677. this.showQuantityDetailData(node);
  678. } else {
  679. this.selectedNodeId = null;
  680. }
  681. if (!isShow) {
  682. this.clearSheetData();
  683. }
  684. //hide floatingObject
  685. var floatingObject = this.coeSheet.floatingObjects.get('customerCoe');
  686. if (floatingObject) {
  687. floatingObject.isVisible(false);
  688. }
  689. // $('#dropdown').hide();
  690. },
  691. showRationGLJData: function (node) {
  692. var gljList = [];
  693. var ration_glj = projectObj.project.ration_glj;
  694. node = node ? node : projectObj.project.mainTree.selected;
  695. if (node.sourceType == ModuleNames.ration) {
  696. let ration = node.data;
  697. gljList = this.filterGljByRation(ration, ration_glj.datas);
  698. this.showInSheet(gljList);
  699. }
  700. },
  701. showRationGLJSheetData: function (init) {
  702. this.combineWithProjectGlj(this.sheetData);
  703. this.sheet.setRowCount(0);
  704. //console.log(+new Date())
  705. //this.sheet.getRange(0,-1,this.sheet.getRowCount(),-1).visible(true); //这个方法导致加载缓慢
  706. this.sheetData = sortRationGLJ(this.sheetData);
  707. this.sumQuantity();//计算总消耗量
  708. this.addMixRatioToShow();//显示组成物信息
  709. this.initRationTree(init);
  710. sheetCommonObj.showData(this.sheet, this.setting, this.sheetData);
  711. },
  712. initRationTree: function (init) {
  713. this.sheet.getRange(-1, 0, -1, 1).cellType(this.getTreeNodeCellType(this.sheetData));
  714. for (var i = 0; i < this.sheetData.length; i++) {
  715. if (this.sheetData[i].hasOwnProperty('subList')) {
  716. var collapsed = false;
  717. if (init) {
  718. this.sheetData[i].collapsed = true;
  719. collapsed = true;
  720. } else {
  721. collapsed = this.sheetData[i].collapsed == undefined ? true : this.sheetData[i].collapsed;
  722. }
  723. if (collapsed == true) {
  724. this.sheet.getRange(i + 1, -1, this.sheetData[i].subList.length, -1).visible(false);
  725. }
  726. //this.sheet.getRange(i+1, -1, this.sheetData[i].subList.length, -1).visible(!collapsed);// this.sheet.getRange(i+1, -1, this.sheetData[i].subList.length, -1).locked(true);
  727. //这个方法导致加载缓慢
  728. }
  729. }
  730. },
  731. filterGljByRation: function (ration, datas) {
  732. var gljList = [];
  733. if (datas && datas.length > 0) {
  734. gljList = _.filter(datas, {'rationID': ration.ID})
  735. }
  736. return gljList;
  737. },
  738. showInSheet: function (gljList) {
  739. this.sheetData = gljList;
  740. this.showRationGLJSheetData(true);
  741. },
  742. sumQuantity: function (node) {
  743. if (this.sheetData.length > 0) {
  744. node = node ? node : projectObj.project.mainTree.selected;
  745. let ration = node.data;
  746. let quantity = ration.quantity;
  747. quantity = (quantity == 0 || quantity == undefined || quantity == null || quantity == "") ? 1 : quantity;
  748. for (let glj of this.sheetData) {
  749. glj.totalQuantity= this.getTotalQuantity(glj,ration);
  750. }
  751. }
  752. },
  753. getTotalQuantity:function(glj,ration){
  754. ration=ration?ration: _.find(projectObj.project.Ration.datas,{"ID":glj.rationID});
  755. if(ration){
  756. let quantity = ration.quantity;
  757. quantity = (quantity == 0 || quantity == undefined || quantity == null || quantity == "") ? 1 : quantity;
  758. if (glj.isMixRatio == true) {//如果是用于显示的组成物,则不用计算,跳过
  759. return;
  760. }
  761. quantity = scMathUtil.roundForObj(quantity, getDecimal("ration.quantity"));//计算前进行4舍5入
  762. glj.quantity = scMathUtil.roundForObj(glj.quantity, getDecimal("glj.quantity"));
  763. glj.totalQuantity = scMathUtil.roundToString(quantity * glj.quantity, getDecimal("glj.quantity"));
  764. if (glj.hasOwnProperty('subList')) {//需要计算glj下挂的组成物的总消耗量
  765. for (let subG of glj.subList) {
  766. subG.rationItemQuantity = scMathUtil.roundForObj(subG.rationItemQuantity, getDecimal("glj.quantity"));
  767. subG.totalQuantity = scMathUtil.roundToString(subG.rationItemQuantity * glj.totalQuantity, getDecimal("glj.quantity"));
  768. }
  769. }
  770. return glj.totalQuantity;
  771. }
  772. },
  773. addMixRatioToShow: function () {
  774. var newList = [];
  775. _.remove(this.sheetData, {'isMixRatio': true});
  776. for (var i = 0; i < this.sheetData.length; i++) {
  777. newList.push(this.sheetData[i]);
  778. if (this.sheetData[i].hasOwnProperty('subList')) {
  779. newList = newList.concat(this.sheetData[i].subList);
  780. }
  781. }
  782. this.sheetData = newList;
  783. },
  784. combineWithProjectGlj: function (ration_gljs) {
  785. var projectGLJData = projectObj.project.projectGLJ.datas;
  786. var projectGljs = projectGLJData.gljList;
  787. var mixRatioMap = projectGLJData.mixRatioMap;
  788. if (ration_gljs && ration_gljs.length > 0 && projectGljs && projectGljs.length > 0) {
  789. for (var i = 0; i < ration_gljs.length; i++) {
  790. var glj = _.find(projectGljs, {'id': ration_gljs[i].projectGLJID});
  791. if (glj) {
  792. let typeString = ration_gljs[i].type + "";
  793. if (typeString.indexOf("2") != -1||typeString=='4'||typeString=='5') {//只有材料类型才显示是否暂估
  794. ration_gljs[i].isEstimate = glj.is_evaluate;
  795. }
  796. ration_gljs[i].isAdd = glj.unit_price.is_add;
  797. ration_gljs[i]=this.setGLJPrice(ration_gljs[i],glj);//设置工料机价格
  798. var connect_index = this.getIndex(glj, gljKeyArray)
  799. if (mixRatioMap.hasOwnProperty(connect_index)) {
  800. var mixRatios = this.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
  801. ration_gljs[i].subList = mixRatios;
  802. }
  803. }
  804. }
  805. }
  806. return ration_gljs;
  807. },
  808. setGLJPrice:function (data,glj) {
  809. glj = glj?glj:_.find(projectObj.project.projectGLJ.datas.projectGljs, {'id': ration_gljs[i].projectGLJID});
  810. if(this.calcPriceDiff(glj)==true) {//计取价差
  811. data.basePrice = glj.unit_price.base_price;
  812. data.marketPrice = glj.unit_price.market_price;
  813. data.adjustPrice = projectObj.project.projectGLJ.getAdjustPrice(glj);
  814. }else {//不计价差
  815. data.basePrice = glj.unit_price.market_price;
  816. data.marketPrice = glj.unit_price.market_price;
  817. data.adjustPrice = glj.unit_price.market_price;
  818. }
  819. return data;
  820. },
  821. calcPriceDiff:function (glj) {
  822. let calcOptions=projectInfoObj.projectInfo.property.calcOptions;
  823. if(glj.is_evaluate==1){//先按是否暂估判断
  824. return calcOptions.calc_est;
  825. }
  826. if(glj.type==gljType.MAIN_MATERIAL||glj.type==gljType.EQUIPMENT){//再判断是否是主材和设备
  827. return calcOptions.calc_main;
  828. }
  829. if(glj.unit_price.is_add==1){//再判断是否新增
  830. return calcOptions.calc_add;
  831. }
  832. return true;
  833. },
  834. getIndex(obj, pops){
  835. let t_index = '';
  836. let k_arr = [];
  837. for (let p of pops) {
  838. let tmpK = (obj[p] == undefined || obj[p] == null || obj[p] == '') ? 'null' : obj[p];
  839. k_arr.push(tmpK);
  840. }
  841. t_index = k_arr.join("|-|");
  842. return t_index;
  843. },
  844. getConditionByKey(conKey){//将连接字符串转换成对象
  845. let valueArray = conKey.split("|-|");
  846. let obj ={};
  847. for(let i = 0;i<valueArray.length;i++){
  848. if(valueArray[i]!='null'){
  849. obj[gljKeyArray[i]]=valueArray[i];
  850. }
  851. }
  852. return obj;
  853. },
  854. getMixRationShowDatas: function (mixRatioList, projectGljs) {
  855. var temRationGLJs = [];
  856. for (var i = 0; i < mixRatioList.length; i++) {
  857. var pg = _.find(projectGljs, {
  858. 'code': mixRatioList[i].code,
  859. 'name': mixRatioList[i].name,
  860. 'specs': mixRatioList[i].specs,
  861. 'type': mixRatioList[i].type,
  862. 'unit': mixRatioList[i].unit
  863. });//改关联关系
  864. var tem = {
  865. projectGLJID: pg.id,
  866. code: pg.code,
  867. name: pg.name,
  868. specs: pg.specs,
  869. unit: pg.unit,
  870. shortName: pg.unit_price.short_name,
  871. rationItemQuantity: mixRatioList[i].consumption,
  872. // quantity:mixRatioList[i].consumption,
  873. basePrice: pg.unit_price.base_price,
  874. marketPrice: pg.unit_price.market_price,
  875. adjustPrice: pg.adjust_price,
  876. isEstimate: pg.is_evaluate,
  877. isMixRatio: true,
  878. isAdd: pg.unit_price.is_add,
  879. GLJID: pg.glj_id
  880. }
  881. temRationGLJs.push(tem);
  882. }
  883. temRationGLJs = _.sortBy(temRationGLJs, 'code');
  884. return temRationGLJs;
  885. },
  886. showRationCoeData: function (node) {
  887. var coeList = [];
  888. var ration_coe = projectObj.project.ration_coe;
  889. var ration = node.data;
  890. if (ration_coe.datas && ration_coe.datas.length > 0) {
  891. coeList = _.filter(ration_coe.datas, {'projectID': ration.projectID, 'rationID': ration.ID})
  892. }
  893. this.showCoeData(this.coeSheet, this.coeSetting, coeList);
  894. this.coeSheetData = coeList;
  895. },
  896. showRationAssData: function (node) {
  897. var assList = node.data.rationAssList ? node.data.rationAssList : [];
  898. sheetCommonObj.showData(this.assSheet, this.assSetting, assList);
  899. this.assSheetData = assList;
  900. },
  901. showQuantityDetailData: function (node) {
  902. var details = [];
  903. node = node ? node : projectObj.project.mainTree.selected;
  904. var quantity_detail = projectObj.project.quantity_detail;
  905. if (node.sourceType == ModuleNames.ration) {
  906. details = _.filter(quantity_detail.datas, {'rationID': node.data.ID});
  907. } else if (node.sourceType == ModuleNames.bills) {
  908. details = _.filter(quantity_detail.datas, {'billID': node.data.ID});
  909. }
  910. details = _.sortBy(details, 'seq');
  911. sheetCommonObj.showData(this.detailSheet, this.detailSetting, details);
  912. this.detailData = details;
  913. if (MainTreeCol.readOnly.forQuantifyDetail(node)) {
  914. this.detailSheet.getRange(-1, 0, -1, this.detailSetting.header.length).locked(true);
  915. }
  916. },
  917. clearSheetData: function () {
  918. sheetCommonObj.showData(this.sheet, this.setting, []);
  919. sheetCommonObj.showData(this.coeSheet, this.coeSetting, []);
  920. sheetCommonObj.showData(this.assSheet, this.assSetting, []);
  921. // sheetCommonObj.showData(this.detailSheet,this.detailSetting,[]);
  922. this.sheetData = [];
  923. this.coeSheetData = [];
  924. this.assSheetData = [];
  925. //this.detailData=[];
  926. },
  927. /* lockRationGLJCell:function(){
  928. sheetCommonObj.lockCells(this.sheet,this.setting);
  929. },
  930. lockRationCoeCell:function () {
  931. sheetCommonObj.lockCells(this.coeSheet,this.coeSetting);
  932. /!* if(this.coeSheetData){
  933. for(var i =0;i<this.coeSheetData.length;i++){
  934. if(this.coeSheetData[i].coeID==-1){
  935. this.coeSheet.getCell(i, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
  936. }
  937. }
  938. }*!/
  939. },
  940. lockRationGLJCell:function(){
  941. sheetCommonObj.lockCells(this.sheet,this.setting);
  942. },*/
  943. updateRationGLJ: function (args) {
  944. var me = this;
  945. var updateField = me.setting.header[args.col].dataCode;
  946. var recode = me.sheetData[args.row];
  947. var newval;
  948. if (updateField == 'marketPrice' || updateField == 'customQuantity' || updateField == 'basePrice') {
  949. if (args.editingText == null) {
  950. updateField == 'marketPrice' ? newval = 0 : newval = "";
  951. } else {
  952. var decimal = updateField == 'customQuantity' ? getDecimal("glj.quantity") : getDecimal("glj.unitPrice");
  953. newval = number_util.checkNumberValue(args.editingText, decimal);
  954. if (newval == null) {
  955. me.sheet.getCell(args.row, args.col).value(recode[updateField]);
  956. return;
  957. }
  958. }
  959. } else {
  960. if (updateField == 'name' || updateField == 'unit') {
  961. if (args.editingText === null) {
  962. alert(me.setting.header[args.col].headerName + '不能为空!');
  963. me.sheet.getCell(args.row, args.col).value(recode[updateField]);
  964. return;
  965. }
  966. }
  967. newval = args.editingText == null ? "" : args.editingText;
  968. }
  969. if (newval === recode[updateField]) {//如果值完全相等,则不需要更新
  970. return
  971. }
  972. if (updateField == 'marketPrice' || updateField == 'basePrice') {
  973. projectObj.project.projectGLJ.updatePriceFromRG(recode, updateField, newval);
  974. } else {
  975. projectObj.project.ration_glj.updateRationGLJByEdit(recode, updateField, newval);
  976. }
  977. },
  978. updateRationTypeGLJ: function (value, node, fieldName) {
  979. let newval;
  980. let updatePrice = false;
  981. if (fieldName == "marketUnitFee") {
  982. updatePrice = true;
  983. if (value == null) {
  984. newval = 0;
  985. } else {
  986. var decimal = getDecimal("glj.unitPrice");
  987. newval = number_util.checkNumberValue(value, decimal);
  988. }
  989. } else {
  990. if (value != null) {
  991. projectObj.project.projectGLJ.updatePropertyFromMainSpread(node, fieldName, value)
  992. return;
  993. //update
  994. }
  995. }
  996. if (newval && updatePrice == true) {
  997. projectObj.project.projectGLJ.updatePriceFromRG(node.data, "marketPrice", newval);
  998. return
  999. }
  1000. projectObj.mainController.refreshTreeNode([node]);
  1001. },
  1002. updateRationAss: function (args) {
  1003. var me = gljOprObj;
  1004. var newval;
  1005. newval = me.numberValueChecking(args.editingText);
  1006. var recode = me.assSheetData[args.row];
  1007. if (args.editingText === null) {
  1008. newval = parseFloat(recode.stdValue);
  1009. }
  1010. var isValidate = false;
  1011. if (newval) {
  1012. isValidate = me.checkingActualValue(recode, newval)
  1013. }
  1014. if (isValidate) {
  1015. newval = scMathUtil.roundTo(newval, -2);
  1016. projectObj.project.ration_ass.updateActualValue(me.assSheetData, args.row, newval)
  1017. } else {
  1018. newval = recode.actualValue;
  1019. me.assSheet.getCell(args.row, args.col).value(newval);
  1020. }
  1021. },
  1022. updateRationCoe: function (args, newval) {
  1023. var me = gljOprObj;
  1024. var recode = me.coeSheetData[args.row];
  1025. projectObj.project.ration_coe.adjustCoeClick(recode, newval);
  1026. },
  1027. updateIsEstimate:function (args, newval) {
  1028. var me = gljOprObj;
  1029. if(me.setting.header[args.col].dataCode=="isEstimate"){
  1030. var pspread= new ProjectGLJSpread();
  1031. var recode = me.sheetData[args.row];
  1032. let projectGljs = projectObj.project.projectGLJ.datas.gljList;
  1033. let glj = _.find(projectGljs, {'id': recode.projectGLJID});
  1034. if(glj){
  1035. glj["is_evaluate"]=newval;
  1036. args.fromRG=true;
  1037. pspread.postUpdate(recode.projectGLJID,"is_evaluate",newval,args,null,successTrigger);
  1038. }
  1039. }
  1040. },
  1041. numberValueChecking: function (val) {
  1042. var newval = Number(val);
  1043. if (number_util.isNumber(newval)) {
  1044. return newval;
  1045. } else {
  1046. if (val) {
  1047. alert('您输入的数据类型不正确,请重新输入。');
  1048. }
  1049. newval = null;
  1050. }
  1051. return newval;
  1052. },
  1053. checkingActualValue(record, newval){
  1054. var minExist = record.minValue && record.minValue != '0' ? true : false;
  1055. var maxExist = record.maxValue && record.maxValue != '0' ? true : false;
  1056. var minValue = parseFloat(record.minValue);
  1057. var maxValue = parseFloat(record.maxValue);
  1058. var stdVale = parseFloat(record.stdValue);
  1059. if (!maxExist && minExist) {
  1060. if (newval < minValue) {
  1061. alert('实际值应≥' + minValue);
  1062. return false;
  1063. }
  1064. }
  1065. if (maxExist && !minExist) {
  1066. if (newval > maxValue) {
  1067. alert('实际值应≤' + maxValue);
  1068. return false;
  1069. }
  1070. }
  1071. if (maxExist && minExist) {
  1072. if (newval < minValue || newval > maxValue) {
  1073. alert('实际值应介于' + minValue + '~' + maxValue + '之间');
  1074. return false;
  1075. }
  1076. }
  1077. return true;
  1078. },
  1079. showLibGLJSheetData: function () {
  1080. this.gljLibSheetData = _.sortBy(this.gljLibSheetData, 'code');
  1081. this.gljLibSheet.setRowCount(this.gljLibSheetData.length);
  1082. sheetCommonObj.showData(this.gljLibSheet, this.gljLibSheetSetting, this.gljLibSheetData, gljOprObj.distTypeTree);
  1083. },
  1084. filterLibGLJSheetData: function () {
  1085. let me = this;
  1086. let val = $("input[name='glj']:checked").val();
  1087. if (val == 'allGljs') {
  1088. me.gljLibSheetData = me.stdGLJ.concat(me.complementaryGLJs);
  1089. } else {
  1090. me.gljLibSheetData = me[val];
  1091. }
  1092. if ($('#actionType').val() == 'replace' || $('#actionType').val() == 'm_replace') {
  1093. me.filterLibGLJByType();
  1094. }
  1095. if (me.gljCurTypeId == undefined) {
  1096. return;
  1097. }
  1098. if (me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]) {
  1099. me.gljLibSheetData = _.filter(me.gljLibSheetData, function (n) {
  1100. return _.includes(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId], n.gljClass);
  1101. });
  1102. } else {
  1103. me.gljLibSheetData = _.filter(me.gljLibSheetData, {'gljClass': me.gljCurTypeId});
  1104. }
  1105. },
  1106. setGLJSelection: function (args, newVal) {
  1107. if ($('#actionType').val() == 'add' || $('#actionType').val() == 'insert') {
  1108. this.addGLJsSelection(args, newVal);
  1109. } else {
  1110. this.replaceGLJSelection(args, newVal);
  1111. }
  1112. },
  1113. addGLJsSelection: function (args, newVal) {
  1114. var con_key = this.getIndex(this.gljLibSheetData[args.row], gljLibKeyArray);
  1115. if (newVal == 1) {
  1116. this.GLJSelection.push(con_key);
  1117. this.gljLibSheetData[args.row].select = 1;
  1118. } else if (newVal == 0) {
  1119. _.pull(this.GLJSelection, con_key);
  1120. this.gljLibSheetData[args.row].select = 0;
  1121. }
  1122. },
  1123. replaceGLJSelection: function (args, newVal) {
  1124. var me = this;
  1125. var oldSelection = this.GLJSelection[0];
  1126. if (newVal == 0) {
  1127. args.sheet.getCell(args.row, args.col).value(1);
  1128. return;
  1129. }
  1130. this.GLJSelection = [me.getIndex(this.gljLibSheetData[args.row], gljLibKeyArray)];
  1131. this.gljLibSheetData[args.row].select = 1;
  1132. var oindex = _.findIndex(this.gljLibSheetData, function (item) {
  1133. var i_key = me.getIndex(item, gljLibKeyArray);
  1134. return oldSelection == i_key;
  1135. });
  1136. if (oindex != -1) {
  1137. args.sheet.getCell(oindex, args.col).value(0);
  1138. this.gljLibSheetData[oindex].select = 0;
  1139. } else {
  1140. var oldData = _.find(gljOprObj.AllRecode, function (item) {
  1141. var i_key = me.getIndex(item, gljLibKeyArray);
  1142. return oldSelection == i_key;
  1143. });
  1144. oldData ? oldData.select = 0 : "";
  1145. }
  1146. },
  1147. filterLibGLJByType: function () {
  1148. var me = this;
  1149. var selected = me.sheetData[gljContextMenu.selectedRow];
  1150. me.gljLibSheetData = _.filter(me.gljLibSheetData, {'gljType': selected.type});
  1151. },
  1152. getComboData: function (gljDistType) {
  1153. let me = this;
  1154. let distType;
  1155. let distTypeTree = {
  1156. prefix: 'gljType',
  1157. distTypes: {},
  1158. comboDatas: [],
  1159. distTypesArr: []
  1160. };
  1161. gljDistType.forEach(function (typeData) {
  1162. let typeObj = {
  1163. data: typeData,
  1164. children: [],
  1165. parent: null
  1166. }
  1167. distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
  1168. distTypeTree.distTypesArr.push(typeObj);
  1169. });
  1170. gljDistType.forEach(function (typeData) {
  1171. distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
  1172. let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
  1173. if (parent) {
  1174. distType.parent = parent;
  1175. parent.children.push(distType);
  1176. }
  1177. });
  1178. distTypeTree.distTypesArr.forEach(function (distTypeObj) {
  1179. if (distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械') {
  1180. distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
  1181. }
  1182. });
  1183. return distTypeTree;
  1184. },
  1185. doInsertGLJ: function () {
  1186. var selected = projectObj.project.mainTree.selected;
  1187. var project = projectObj.project;
  1188. if (gljOprObj.GLJSelection.length <= 0) {
  1189. return;
  1190. }
  1191. $("#glj_tree_div").modal('hide');
  1192. project.ration_glj.insertGLJAsRation(gljOprObj.GLJSelection, selected, function (result) {
  1193. project.projectGLJ.loadData();
  1194. gljOprObj.showRationGLJSheetData();
  1195. })
  1196. },
  1197. doAddGLJ: function () {
  1198. var selected = projectObj.project.mainTree.selected;
  1199. var project = projectObj.project;
  1200. gljOprObj.GLJSelection = _.filter(gljOprObj.GLJSelection, function (n) {
  1201. var rg = _.find(gljOprObj.sheetData, function (item) {
  1202. var i_key = gljOprObj.getIndex(item, gljKeyArray);
  1203. return n == i_key
  1204. })
  1205. return rg ? false : true;
  1206. })
  1207. if (gljOprObj.GLJSelection.length > 0 && selected && selected.sourceType == ModuleNames.ration) {
  1208. $("#glj_tree_div").modal('hide');
  1209. project.ration_glj.addGLJByLib(gljOprObj.GLJSelection, selected.data, function (result) {
  1210. if (result) {
  1211. selected.data.adjustState = result.adjustState;
  1212. //project.ration_glj.datas = project.ration_glj.datas.concat(result.newRecodes);//显示和缓存统一,这样的话就不用更新两个位置了
  1213. project.ration_glj.datas = project.ration_glj.datas.concat(result.showData);
  1214. gljOprObj.sheetData = gljOprObj.sheetData.concat(result.showData);
  1215. gljOprObj.showRationGLJSheetData();
  1216. project.ration_glj.addToMainTree(result.showData);
  1217. project.projectGLJ.loadData();
  1218. project.calcProgram.calculate(selected);
  1219. project.calcProgram.saveNode(selected);
  1220. projectObj.mainController.refreshTreeNode([selected]);
  1221. $.bootstrapLoading.end();
  1222. }
  1223. });//doc.rationID=selected.data.ID;
  1224. } else {
  1225. $("#glj_tree_div").modal('hide');
  1226. }
  1227. },
  1228. doReplaceGLJ: function () {
  1229. var me = this;
  1230. var oldData = me.sheetData[gljContextMenu.selectedRow];
  1231. var project = projectObj.project;
  1232. var selectCode = gljOprObj.GLJSelection[0];
  1233. var selected = projectObj.project.mainTree.selected;
  1234. $("#glj_tree_div").modal('hide');
  1235. project.ration_glj.replaceGLJ(selectCode, oldData, function (result) {
  1236. if (result) {
  1237. //result.adjustState;
  1238. var glj_list = projectObj.project.ration_glj.datas;
  1239. var data = result.data;
  1240. var index = _.findIndex(gljOprObj.sheetData, {'ID': data.ID});
  1241. var list_index = _.findIndex(glj_list, {'ID': data.ID});
  1242. var nodes = [selected];
  1243. gljOprObj.sheetData[index] = data;
  1244. glj_list[list_index] = data;
  1245. gljOprObj.showRationGLJSheetData();
  1246. if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
  1247. var node = project.ration_glj.findGLJNodeByID(data.ID);
  1248. if (node) {
  1249. project.ration_glj.transferToNodeData(data);
  1250. node.source = data;
  1251. node.data = data;
  1252. }
  1253. node ? nodes.push(node) : "";
  1254. }
  1255. //project.ration_glj.addToMainTree(data);
  1256. project.projectGLJ.loadData();
  1257. selected.data.adjustState = result.adjustState;
  1258. projectObj.mainController.refreshTreeNode(nodes);
  1259. project.calcProgram.calculate(selected);
  1260. project.calcProgram.saveNode(selected);
  1261. }
  1262. $.bootstrapLoading.end();
  1263. })
  1264. },
  1265. doMReplaceGLJ: function () {
  1266. var me = this;
  1267. var oldData = me.sheetData[gljContextMenu.selectedRow];
  1268. var project = projectObj.project;
  1269. var selectCode = me.GLJSelection[0];
  1270. $("#glj_tree_div").modal('hide');
  1271. project.ration_glj.mReplaceGLJ(selectCode, oldData, function (result) {
  1272. var data = result.data;
  1273. var stateList = result.stateList;
  1274. var n_index = me.getIndex(data.query, gljKeyArray);
  1275. var nodes = [];
  1276. _.forEach(project.ration_glj.datas, function (t) {
  1277. var t_index = me.getIndex(t, gljKeyArray);
  1278. if (n_index == t_index) {
  1279. me.updateProperty(t, data.doc);
  1280. if (project.ration_glj.needShowToTree(t)) {//如果是造价书中的树节点,则也须刷新
  1281. project.ration_glj.transferToNodeData(t);
  1282. var node = project.ration_glj.findGLJNodeByID(t.ID);
  1283. nodes.push(node);
  1284. }
  1285. }
  1286. })
  1287. me.showRationGLJSheetData();
  1288. project.projectGLJ.loadData();
  1289. var rationNodes = me.refreshStateAfterMreplace(stateList, nodes);
  1290. project.calcProgram.calcRationsAndSave(rationNodes);
  1291. $.bootstrapLoading.end();
  1292. })
  1293. },
  1294. updateProperty: function (obj, doc) {
  1295. _.forEach(doc, function (n, key) {
  1296. obj[key] = n;
  1297. });
  1298. },
  1299. refreshStateAfterMreplace: function (stateList, gljNodes) {
  1300. var nodes = [];
  1301. var rationNodes = [];
  1302. _.forEach(stateList, function (s) {
  1303. var node = _.find(projectObj.project.mainTree.items, function (n) {
  1304. return n.sourceType == ModuleNames.ration && n.data.ID == s.rationID;
  1305. })
  1306. if (node) {
  1307. node.data.adjustState = s.adjustState;
  1308. nodes.push(node);
  1309. rationNodes.push(node);
  1310. }
  1311. });
  1312. gljNodes.length > 0 ? nodes = nodes.concat(gljNodes) : "";
  1313. projectObj.mainController.refreshTreeNode(nodes);
  1314. return rationNodes;
  1315. },
  1316. refreshView: function () {
  1317. this.showRationGLJData();
  1318. },
  1319. //
  1320. refreshTreeNode: function (obj) {
  1321. if (!obj) {
  1322. return;
  1323. }
  1324. var objectArray = [];
  1325. var nodes = [];
  1326. if (obj instanceof Array) {
  1327. objectArray.concat(obj);
  1328. } else {
  1329. objectArray.push(obj);
  1330. }
  1331. for (let o of objectArray) {
  1332. var node = _.find(projectObj.project.mainTree.items, function (n) {
  1333. return n.sourceType == o.type && n.data.ID == o.ID;
  1334. })
  1335. if (node) {
  1336. for (var k in o.data) {
  1337. node.data[k] = o.data[k];
  1338. }
  1339. nodes.push(node);
  1340. }
  1341. }
  1342. projectObj.mainController.refreshTreeNode(nodes);
  1343. return nodes;
  1344. },
  1345. getTreeNodeCellType: function (data) {
  1346. var ns = GC.Spread.Sheets;
  1347. var rectW = 10;
  1348. var rectH = 10;
  1349. var margin = 3;
  1350. function TreeNodeCellType() {
  1351. }
  1352. function drowRect(ctx, x, y, w, h) {
  1353. ctx.save();
  1354. ctx.strokeStyle = "gray";
  1355. ctx.translate(0.5, 0.5);
  1356. ctx.beginPath();
  1357. var rectX = x + margin;
  1358. var rectY = y + Math.round(h / 2) - rectH / 2;
  1359. ctx.moveTo(rectX, rectY);
  1360. ctx.lineTo(rectX, rectY + rectH);
  1361. ctx.lineTo(rectX + rectW, rectY + rectH);
  1362. ctx.lineTo(rectX + rectW, rectY);
  1363. ctx.lineTo(rectX, rectY);
  1364. ctx.moveTo(rectX + rectW, y + Math.round(h / 2));
  1365. ctx.lineTo(rectX + rectW + 5, y + Math.round(h / 2));
  1366. ctx.stroke();
  1367. ctx.restore();
  1368. }
  1369. function drowSymbol(ctx, x, y, w, h, collapsed) {
  1370. ctx.save();
  1371. ctx.strokeStyle = "#000000";
  1372. ctx.translate(0.5, 0.5);
  1373. ctx.beginPath();
  1374. ctx.moveTo(x + margin + 2, y + Math.round(h / 2));
  1375. ctx.lineTo(x + margin + 8, y + Math.round(h / 2));
  1376. var rectY = y + Math.round(h / 2) - rectH / 2;
  1377. if (collapsed) {
  1378. ctx.moveTo(x + margin + rectW / 2, rectY + 2);
  1379. ctx.lineTo(x + margin + rectW / 2, rectY + 2 + 6);
  1380. }
  1381. ctx.stroke();
  1382. ctx.restore();
  1383. }
  1384. function drowSubItem(ctx, x, y, w, h, offset, nextItem) {
  1385. offset += 6;
  1386. ctx.save();
  1387. ctx.strokeStyle = "gray";
  1388. ctx.translate(0.5, 0.5);
  1389. ctx.beginPath();
  1390. ctx.moveTo(x + offset, y);
  1391. ctx.lineTo(x + offset, y + Math.round(h / 2));
  1392. offset += 9;
  1393. ctx.lineTo(x + offset, y + Math.round(h / 2));
  1394. if (nextItem && nextItem.isMixRatio) {
  1395. ctx.moveTo(x + offset - 9, y + Math.round(h / 2));
  1396. ctx.lineTo(x + offset - 9, y + h);
  1397. }
  1398. ctx.stroke();
  1399. ctx.restore();
  1400. return offset;
  1401. }
  1402. TreeNodeCellType.prototype = new ns.CellTypes.Text();
  1403. TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
  1404. if (value != null) {
  1405. var offset = margin + rectW + 6;
  1406. var recode = data[options.row];
  1407. if (recode && recode.hasOwnProperty('subList')) {
  1408. drowRect(ctx, x, y, w, h);
  1409. var collapsed = recode.collapsed == undefined ? true : recode.collapsed;//options.sheet.getTag(options.row,options.col);
  1410. drowSymbol(ctx, x, y, w, h, collapsed);
  1411. } else if (recode && recode.isMixRatio) {
  1412. offset = drowSubItem(ctx, x, y, w, h, offset, data[options.row + 1]);
  1413. offset += 1;
  1414. }
  1415. ctx.fillText(value, x + offset + ctx.measureText(value).width, y + h - 5);
  1416. }
  1417. };
  1418. // override getHitInfo to allow cell type get mouse messages
  1419. TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
  1420. return {
  1421. x: x,
  1422. y: y,
  1423. row: context.row,
  1424. col: context.col,
  1425. cellStyle: cellStyle,
  1426. cellRect: cellRect,
  1427. sheetArea: context.sheetArea
  1428. };
  1429. }
  1430. TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
  1431. var recode = data[hitinfo.row];
  1432. if (recode && recode.hasOwnProperty('subList')) {
  1433. var hoffset = hitinfo.cellRect.x + 3;
  1434. if (hitinfo.x > hoffset && hitinfo.x < hoffset + 10) {
  1435. var collapsed = recode.collapsed == undefined ? true : recode.collapsed;
  1436. collapsed = !collapsed
  1437. recode.collapsed = collapsed;
  1438. //hitinfo.sheet.setTag(hitinfo.row,hitinfo.col,collapsed);
  1439. hitinfo.sheet.getRange(hitinfo.row + 1, -1, recode.subList.length, -1).visible(!collapsed);
  1440. hitinfo.sheet.invalidateLayout();
  1441. hitinfo.sheet.repaint();
  1442. }
  1443. }
  1444. };
  1445. return new TreeNodeCellType()
  1446. },
  1447. marketPriceReadOnly: function (node) {
  1448. return node.data.type == gljType.CONCRETE || node.data.type == gljType.MORTAR || node.data.type == gljType.MIX_RATIO || node.data.type == gljType.GENERAL_MACHINE || node.data.isEstimate == 1
  1449. }
  1450. }
  1451. $(function () {
  1452. $('#glj_tree_div').on('shown.bs.modal', function (e) {
  1453. if (gljOprObj.gljLibSpresd == undefined) {
  1454. gljOprObj.gljLibSpresd = sheetCommonObj.buildSheet($('#gljLibSheet')[0], gljOprObj.gljLibSheetSetting, gljOprObj.stdGLJ.length + gljOprObj.complementaryGLJs.length);
  1455. gljOprObj.gljLibSpresd.bind(GC.Spread.Sheets.Events.ButtonClicked, gljOprObj.onButtonClick);
  1456. gljOprObj.gljLibSheet = gljOprObj.gljLibSpresd.getSheet(0);
  1457. gljOprObj.gljLibSheet.options.isProtected = true;
  1458. gljOprObj.gljLibSheet.name('glj_lib');
  1459. }
  1460. gljOprObj.gljLibSheetData = gljOprObj.AllRecode;
  1461. var selected = null;
  1462. if ($('#actionType').val() == 'add' || $('#actionType').val() == 'insert') {
  1463. gljOprObj.GLJSelection = [];
  1464. } else {
  1465. selected = gljOprObj.sheetData[gljContextMenu.selectedRow];
  1466. var connect_key = gljOprObj.getIndex(selected, gljKeyArray);
  1467. gljOprObj.GLJSelection = [connect_key];
  1468. gljOprObj.filterLibGLJByType();
  1469. }
  1470. if (selected != null) {
  1471. var s_key = gljOprObj.getIndex(selected, gljLibKeyArray);
  1472. var r = _.find(gljOprObj.gljLibSheetData, function (item) {
  1473. var item_key = gljOprObj.getIndex(item, gljKeyArray);
  1474. return s_key == item_key;
  1475. });
  1476. r ? r.select = 1 : "";
  1477. }
  1478. gljOprObj.showLibGLJSheetData();
  1479. });
  1480. $('.glj-radio').change(function () {
  1481. let val = $("input[name='glj']:checked").val();
  1482. if (val == 'allGljs') {
  1483. gljOprObj.gljLibSheetData = gljOprObj.AllRecode;
  1484. gljOprObj.filterLibGLJSheetData();
  1485. gljOprObj.showLibGLJSheetData();
  1486. } else {
  1487. gljOprObj.gljLibSheetData = gljOprObj[val];
  1488. gljOprObj.filterLibGLJSheetData();
  1489. gljOprObj.showLibGLJSheetData();
  1490. }
  1491. })
  1492. $('#glj_selected_conf').click(function () {
  1493. if (gljOprObj.GLJSelection.length < 1) {
  1494. return;
  1495. }
  1496. if ($('#actionType').val() == 'insert') { //造价书页面中插入定额类型的工料机
  1497. gljOprObj.doInsertGLJ();
  1498. } else if ($('#actionType').val() == 'add') { //添加工料机
  1499. gljOprObj.doAddGLJ();
  1500. } else if ($('#actionType').val() == 'replace') {//替换工料机
  1501. gljOprObj.doReplaceGLJ();
  1502. } else if ($('#actionType').val() == 'm_replace') {//批量替换工料机
  1503. gljOprObj.doMReplaceGLJ();
  1504. }
  1505. })
  1506. $('#class_selected_conf').click(function () {
  1507. var gljClass = $('#selected_class').val();
  1508. var glj = gljOprObj.selectedGLJClass;
  1509. if (glj && gljClass && gljClass != "") {
  1510. //保存到我的工料机库
  1511. /*1 检查是否有组成物
  1512. * 2 如果有,则检查组成物中是否有新增的记录,如果有,查看是否已经保存了,没有的话,要先添加组成物到补充工料机库
  1513. * 3 保存
  1514. * */
  1515. var newItem = {
  1516. code: glj.code,
  1517. name: glj.name,
  1518. specs: glj.specs,
  1519. unit: glj.unit,
  1520. basePrice: glj.basePrice,
  1521. gljType: glj.type,
  1522. shortName: glj.shortName,
  1523. component: [],
  1524. gljClass: gljClass
  1525. };
  1526. if (glj.hasOwnProperty("subList") && glj.subList.length > 0) {//有组成物,检查组成物信息,目前组成物不允许修改,所以暂时不用考虑组成物是新增的情况
  1527. for (var i = 0; i < glj.subList.length; i++) {
  1528. let tem = {
  1529. ID: glj.subList[i].GLJID,
  1530. consumeAmt: glj.rationItemQuantity,
  1531. isStd: true
  1532. }
  1533. newItem.component.push(tem);
  1534. }
  1535. }
  1536. var data = getcmpUpdateData([newItem]);
  1537. $.bootstrapLoading.start();
  1538. var callback = function (data) {
  1539. $("#glj_class_div").modal('hide');
  1540. $.bootstrapLoading.end();
  1541. }
  1542. CommonAjax.post("complementartGlj/api/mixUpdateGljItems", data, callback, function () {
  1543. $.bootstrapLoading.end();
  1544. });
  1545. }
  1546. })
  1547. $('#glj_class_div').on('hidden.bs.modal', function (e) {
  1548. gljOprObj.selectedGLJClass = null;
  1549. $('#class_selected_conf').attr("disabled", "disabled");
  1550. $('#selected_class').val("");
  1551. })
  1552. function getcmpUpdateData(items) {
  1553. var data = {
  1554. "updateItems": [],
  1555. "removeIds": []
  1556. }
  1557. data.addItems = items;
  1558. return data;
  1559. }
  1560. })
  1561. function operationWithRound(value1,value2,field,symble) {
  1562. let decimal = getDecimal(field);
  1563. value1 = scMathUtil.roundForObj(value1,decimal);
  1564. value2 = scMathUtil.roundForObj(value2,decimal);
  1565. let result;
  1566. switch (symble){
  1567. case "+" :
  1568. result=scMathUtil.roundForObj(value1 + value2,decimal);
  1569. break;
  1570. case "-":
  1571. result=scMathUtil.roundForObj(value1 - value2,decimal);
  1572. break;
  1573. case "*":
  1574. result=scMathUtil.roundForObj(value1 * value2,decimal);
  1575. break;
  1576. case "/":
  1577. result=scMathUtil.roundForObj(value1 / value2,decimal);
  1578. break
  1579. }
  1580. return result;
  1581. }
  1582. function getDecimal(fieldID, node) {
  1583. if (node) {
  1584. return decimalObj.decimal(fieldID, node);
  1585. } else if (fieldID.indexOf(".") != -1) {
  1586. var keyArray = fieldID.split(".");
  1587. return decimalObj[keyArray[0]][keyArray[1]];
  1588. } else {
  1589. return decimalObj.decimal(fieldID);
  1590. }
  1591. }
  1592. function getFormatter(decimal) {
  1593. var pre = "0.";
  1594. if (decimal <= 0) {
  1595. return "0";
  1596. }
  1597. for (i = 0; i < decimal; i++) {
  1598. pre += "0"
  1599. }
  1600. return pre;
  1601. }
  1602. function sortRationGLJ(list) {
  1603. list = _.sortByAll(list, [function (item) {
  1604. return item.type + "";
  1605. }, "code"])
  1606. return list;
  1607. }
  1608. function compareRationGLJ(a, b) {
  1609. if ((a.type + "") < (b.type + "")) {
  1610. return true
  1611. }
  1612. if ((a.type + "") == (b.type + "")) {
  1613. if (a.code < b.code) {
  1614. return true
  1615. }
  1616. }
  1617. return false;
  1618. }