project_glj_spread.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. /**
  2. * 项目工料机相关spread
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/7/19
  6. * @version
  7. */
  8. /**
  9. * 构造函数
  10. *
  11. * @return {void}
  12. */
  13. function ProjectGLJSpread() {
  14. this.isChanging = false;
  15. this.sheetObj = null;
  16. this.firstMachineRow = -1;
  17. this.firstMixRatioRow = -1;
  18. this.successCallback = null;
  19. this.supplyType = ['自行采购', '部分甲供', '完全甲供', '甲定乙供'];
  20. this.supplyComboMap = supplyComboMap
  21. // 工料机类型是混凝土、砂浆、配合比、机械(不包括机械组成物)时,供货方式列只读。
  22. this.supplyReadonlyType = notEditType;
  23. }
  24. /**
  25. * 初始化
  26. *
  27. * @return {object}
  28. */
  29. ProjectGLJSpread.prototype.init = function () {
  30. // 供货方式类型
  31. let supplySelect = [];
  32. for(let comM of this.supplyComboMap) {
  33. supplySelect.push({
  34. text: comM.text,
  35. value: comM.value
  36. });
  37. }
  38. let selectBox = new GC.Spread.Sheets.CellTypes.ComboBox();
  39. selectBox.items(supplySelect);
  40. selectBox.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
  41. let header = [
  42. {name: '编码', field: 'code', visible: true,width:80},
  43. {name: '名称', field: 'name', visible: true,width:160},
  44. {name: '规格型号', field: 'specs', visible: true,width:120},
  45. {name: '单位', field: 'unit', visible: true,width:45},
  46. {name: '类型', field: 'short_name', visible: true,width:45},
  47. {name: '类型', field: 'unit_price.type', visible: false},
  48. {name: '总消耗量', field: 'quantity', visible: true,width:100,decimalField:'glj.quantity'},
  49. {name: '定额价', field: "base_price", visible: true,width:70,decimalField:"glj.unitPrice",validator: 'number'},//这里feiedID设置是为了在计不计取价差的时候做显示用
  50. {name: '调整价', field: 'adjust_price', visible: true,width:70,decimalField:"glj.unitPrice"},
  51. {name: '市场价', field: "unit_price.market_price", visible: true, validator: 'number',width:70,decimalField:"glj.unitPrice"},
  52. {
  53. name: '是否暂估',
  54. field: 'is_evaluate',
  55. visible: true,
  56. cellType: new GC.Spread.Sheets.CellTypes.CheckBox(),
  57. validator: 'boolean'
  58. ,width:60
  59. },
  60. {name: '供货方式', field: 'supply', visible: true, cellType: selectBox,width:80},
  61. {name: '甲供数量', field: 'supply_quantity',validator:'number', visible: true,width:100},
  62. {name: '交货方式', field: 'delivery', visible: true,width:90},
  63. {name: '送达地点', field: 'delivery_address', visible: true,width:100},
  64. {
  65. name: '不调价',
  66. field: 'is_adjust_price',
  67. visible: true,
  68. cellType: new GC.Spread.Sheets.CellTypes.CheckBox(),
  69. validator: 'boolean',
  70. width:55
  71. },
  72. {name: 'UID', field: 'unit_price.id', visible: false},
  73. {name: '工料机ID', field: 'glj_id', visible: false},
  74. {name: '组成物消耗量', field: 'consumption', visible: false},
  75. {name: '父级关联编码', field: 'connect_code', visible: false},
  76. {name: '组成物信息', field: 'ratio_data', visible: false},
  77. {name: '分部分项总消耗量', field: 'subdivisionQuantity', visible: false,width:100,decimalField:'glj.quantity'},
  78. {name: '技术措施项目总消耗量', field: 'techQuantity', visible: false,width:100,decimalField:'glj.quantity'},
  79. {name: 'ID', field: 'id', visible: false}
  80. ];
  81. let sourceData = jsonData;
  82. this.sheetObj = new CommonSpreadJs(header);
  83. this.sheetObj.init('project-glj');
  84. // 获取列号
  85. let isEvaluateColumn = this.sheetObj.getFieldColumn('is_evaluate');
  86. let isAdjustPriceColumn = this.sheetObj.getFieldColumn('is_adjust_price');
  87. let unitColumn = this.sheetObj.getFieldColumn('unit');
  88. let quantityColumn = this.sheetObj.getFieldColumn('quantity');
  89. let basePriceColumn = this.sheetObj.getFieldColumn('base_price');
  90. let adjustPriceColumn = this.sheetObj.getFieldColumn('adjust_price');
  91. let marketPriceColumn = this.sheetObj.getFieldColumn('unit_price.market_price');
  92. let supplyColumn = this.sheetObj.getFieldColumn('supply');
  93. let shortNameColumn = this.sheetObj.getFieldColumn('unit_price.short_name');
  94. let supplyQuantity = this.sheetObj.getFieldColumn('supply_quantity');
  95. let nameColumn = this.sheetObj.getFieldColumn('name');
  96. let specsColumn = this.sheetObj.getFieldColumn('specs');
  97. //左对齐样式
  98. let leftStyleSetting = {hAlign: GC.Spread.Sheets.HorizontalAlign.left};
  99. this.sheetObj.setStyle(-1, nameColumn, leftStyleSetting);
  100. this.sheetObj.setStyle(-1, specsColumn, leftStyleSetting);
  101. // 居中样式
  102. let centerStyleSetting = {hAlign: 1};
  103. this.sheetObj.setStyle(-1, isEvaluateColumn, centerStyleSetting);
  104. this.sheetObj.setStyle(-1, isAdjustPriceColumn, centerStyleSetting);
  105. this.sheetObj.setStyle(-1, unitColumn, centerStyleSetting);
  106. this.sheetObj.setStyle(-1, shortNameColumn, centerStyleSetting);
  107. // 向右对齐样式
  108. let rightStyleSetting = {hAlign: GC.Spread.Sheets.HorizontalAlign.right};
  109. this.sheetObj.setStyle(-1, quantityColumn, rightStyleSetting);
  110. this.sheetObj.setStyle(-1, basePriceColumn, rightStyleSetting);
  111. this.sheetObj.setStyle(-1, adjustPriceColumn, rightStyleSetting);
  112. this.sheetObj.setStyle(-1, marketPriceColumn, rightStyleSetting);
  113. this.sheetObj.setStyle(-1, supplyColumn, rightStyleSetting);
  114. this.sheetObj.setStyle(-1, supplyQuantity, rightStyleSetting);
  115. // 设置可编辑列
  116. this.sheetObj.setColumnEditable(basePriceColumn);
  117. this.sheetObj.setColumnEditable(marketPriceColumn);
  118. this.sheetObj.setColumnEditable(isEvaluateColumn);
  119. this.sheetObj.setColumnEditable(isAdjustPriceColumn);
  120. this.sheetObj.setColumnEditable(supplyColumn);
  121. this.sheetObj.setData(sourceData);
  122. // 取消正在加载字符提示
  123. $("#project-glj > p").hide();
  124. this.specialColumn(sourceData);
  125. // 绑定修改事件
  126. let self = this;
  127. this.sheetObj.bind(GC.Spread.Sheets.Events.ValueChanged, function(element, info) {
  128. self.updateProjectGLJField(info, self.successCallback);
  129. });
  130. // 绑定双击事件
  131. this.sheetObj.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (element, info) {
  132. let column = info.col;
  133. let row = info.row;
  134. let field = self.sheetObj.getColumnField(column);
  135. let activeSheet = self.sheetObj.getSheet();
  136. // 获取类型
  137. let typeColumn = self.sheetObj.getFieldColumn('unit_price.type');
  138. let type = activeSheet.getValue(row, typeColumn);
  139. let ratioColumn = self.sheetObj.getFieldColumn('ratio_data');
  140. let ratioData = activeSheet.getValue(row, ratioColumn);
  141. // 如果类型为混凝土、砂浆、配合比、机械,则提示
  142. if (field === 'unit_price.market_price' && canNotChangeTypeId.indexOf(type) >= 0) {
  143. if(ratioData&&ratioData.length>0){
  144. alert('当前工料机的市场单价由组成物计算得出,不可直接修改');
  145. }
  146. }
  147. });
  148. return this.sheetObj;
  149. };
  150. /**
  151. * 更新项目工料机中的数据字段
  152. *
  153. * @param {object} info
  154. * @param {function} callback
  155. * @return {void|boolean}
  156. */
  157. ProjectGLJSpread.prototype.updateProjectGLJField = function(info, callback) {
  158. // 获取修改的数据
  159. let column = info.col;
  160. let row = info.row;
  161. let idString = 'id';
  162. let field = projectGLJSheet.getColumnField(column);
  163. if (field === '') {
  164. return false;
  165. }
  166. let activeSheet = projectGLJSheet.getSheet();
  167. // 切割字段
  168. let fieldArray = field.split('.');
  169. idString = fieldArray.length > 1 ? 'unit_price.id' : idString;
  170. // 防止快速同时提交
  171. if (isChanging) {
  172. return false;
  173. }
  174. // 校验数据
  175. let value = info.newValue;
  176. if (!projectGLJSheet.checkData(column, value)) {
  177. alert('输入的数据类型不对,请重新输入!');
  178. activeSheet.setValue(row, column, info.oldValue);
  179. return false;
  180. }
  181. // 获取id
  182. let idColumn = projectGLJSheet.getFieldColumn(idString);
  183. if (idColumn < 0) {
  184. return false;
  185. }
  186. let id = activeSheet.getValue(row, idColumn);
  187. // 直接在前端计算后传值后台改
  188. let extend = {};
  189. /* let updateRecord = jsonData[row]; 这时修改成在后端计算后直接更新,因为还要重新计算受影响的清单节点
  190. let parentMarketPrice = projectGLJSpread.compositionCalculate(updateRecord);
  191. if (parentMarketPrice !== null && Object.keys(parentMarketPrice).length > 0) {
  192. for (let activeCode in parentMarketPrice) {
  193. let tmpObject = {
  194. market_price: parentMarketPrice[activeCode],
  195. };
  196. extend[activeCode] = tmpObject;
  197. }
  198. }*/
  199. // 如果是供货方式则需要处理数据
  200. if (field === 'supply') {
  201. // value = this.supplyType.indexOf(value);
  202. extend.supply_quantity = this.getSupplyQuantity(value, activeSheet, info);
  203. }
  204. if(field === 'supply_quantity'){//修改数量需做4舍5入
  205. value= value.toDecimal(getDecimal('glj.quantity'));
  206. }
  207. if(field === 'unit_price.market_price'||field === 'base_price'){
  208. value= scMathUtil.roundForObj(value,getDecimal('glj.unitPrice'));//修改市场价和修改定额价时需要重新记算很多受影响的树节点,现在改成与定字额工料机那里调相同的方法。
  209. let editField = field === 'base_price'?field:"market_price";
  210. projectObj.project.projectGLJ.updatePrice(jsonData[row],editField,value);
  211. return;
  212. }
  213. extend = Object.keys(extend).length > 0 ? JSON.stringify(extend) : '';
  214. this.postUpdate(id,field,value,info,extend,callback);
  215. };
  216. ProjectGLJSpread.prototype.postUpdate=function (id,field,value,info,extend,callback) {
  217. $.bootstrapLoading.start();
  218. $.ajax({
  219. url: '/glj/update',
  220. type: 'post',
  221. data: {id: id, field: field, value: value, extend: extend},
  222. dataType: 'json',
  223. error: function() {
  224. alert('数据传输有误!');
  225. isChanging = false;
  226. },
  227. beforeSend: function() {
  228. isChanging = true;
  229. },
  230. success: function(response) {
  231. isChanging = false;
  232. // 修改失败则恢复原值
  233. if (response.err !== 0&&info.fromRG!=true) {
  234. projectGLJSheet.getSheet().setValue(info.row, info.col, info.oldValue);
  235. alert('更改数据失败!');
  236. } else {
  237. // 成功则触发相应事件
  238. /* if (parentMarketPrice !== null) {
  239. info.parentMarketPrice = parentMarketPrice;
  240. }*/
  241. if(field !== 'supply'&&info.fromRG!=true){ //供货方式需做转换才能直接设置值, 这里设置值是为了早点更新数据,等getdata返回数据再刷新的话会有比较大的延时
  242. projectGLJSheet.getSheet().setValue(info.row, info.col, value);
  243. }
  244. callback(field, info,id);
  245. }
  246. }
  247. });
  248. }
  249. /**
  250. * 设置特殊单元格数据
  251. *
  252. * @param {object} sourceData
  253. * @return {void}
  254. */
  255. ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
  256. let rowCounter = 0;
  257. // 获取列号
  258. let isEvaluateColumn = this.sheetObj.getFieldColumn('is_evaluate');
  259. let marketPriceColumn = this.sheetObj.getFieldColumn('unit_price.market_price');
  260. let basePriceColumn = this.sheetObj.getFieldColumn('base_price');
  261. let adjustPriceColumn = this.sheetObj.getFieldColumn("adjust_price");
  262. let connectCodeColumn = this.sheetObj.getFieldColumn('connect_code');
  263. let consumptionColumn = this.sheetObj.getFieldColumn('consumption');
  264. let supplyColumn = this.sheetObj.getFieldColumn('supply');
  265. let shortNameColumn = this.sheetObj.getFieldColumn('short_name');
  266. let supplyQuantity = this.sheetObj.getFieldColumn('supply_quantity');
  267. let activeSheet = this.sheetObj.getSheet();
  268. for (let data of sourceData) {
  269. let rowStyle = null;
  270. //设置类型名称:
  271. activeSheet.setValue(rowCounter, shortNameColumn,projectObj.project.projectGLJ.getShortNameByID(data.unit_price.type));
  272. // 只有材料才显示是否暂估
  273. if (materialIdList.indexOf(data.unit_price.type) < 0) {
  274. let string = new GC.Spread.Sheets.CellTypes.Text();
  275. activeSheet.setCellType(rowCounter, isEvaluateColumn, string, GC.Spread.Sheets.SheetArea.viewport);
  276. // 锁定该单元格
  277. activeSheet.getCell(rowCounter, isEvaluateColumn, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  278. activeSheet.setValue(rowCounter, isEvaluateColumn, '');
  279. }else {
  280. let checkBox = new GC.Spread.Sheets.CellTypes.CheckBox();
  281. activeSheet.setCellType(rowCounter, isEvaluateColumn, checkBox, GC.Spread.Sheets.SheetArea.viewport);
  282. activeSheet.getCell(rowCounter, isEvaluateColumn, GC.Spread.Sheets.SheetArea.viewport).locked(false);
  283. activeSheet.setValue(rowCounter, isEvaluateColumn, data.is_evaluate);
  284. }
  285. /* // 设置供货方式列是否可选
  286. if (this.supplyReadonlyType.indexOf(data.unit_price.type) >= 0) {
  287. // 锁定该单元格
  288. activeSheet.getCell(rowCounter, supplyColumn, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  289. }*/
  290. // 如果为部分甲供则甲供数量需要可编辑
  291. if (data.supply == 1) {
  292. activeSheet.getCell(rowCounter, supplyQuantity, GC.Spread.Sheets.SheetArea.viewport).locked(false);
  293. }
  294. //供货方式为完全甲供时设置甲供数量为总消耗量
  295. if (data.supply == 2) {
  296. activeSheet.setValue(rowCounter, supplyQuantity, data.quantity);
  297. }
  298. // 供货方式数据
  299. let supplyIndex = parseInt(data.supply);
  300. supplyIndex = isNaN(supplyIndex) ? 0 : supplyIndex;
  301. let supplyText = this.supplyType[supplyIndex] !== undefined ? this.supplyType[supplyIndex] : '自行采购';
  302. activeSheet.setValue(rowCounter, supplyColumn, supplyText);
  303. // activeSheet.setValue(rowCounter, supplyColumn, supplyIndex);
  304. // 如果类型为混凝土、砂浆、配合比、机械,则市场单价和供货方式不能修改
  305. if (canNotChangeTypeId.indexOf(data.unit_price.type) >= 0) {
  306. this.firstMixRatioRow = this.firstMixRatioRow === -1 && data.unit_price.type !== GLJTypeConst.GENERAL_MACHINE ?
  307. rowCounter : this.firstMixRatioRow;
  308. this.firstMachineRow = this.firstMachineRow === -1 && data.unit_price.type === GLJTypeConst.GENERAL_MACHINE ?
  309. rowCounter : this.firstMachineRow;
  310. // 锁定该单元格
  311. if (data.ratio_data && data.ratio_data.length > 0){//有组成物时,市场单价、定额价、供货方式不能修改
  312. activeSheet.getCell(rowCounter, marketPriceColumn, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  313. activeSheet.getCell(rowCounter, basePriceColumn, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  314. activeSheet.getCell(rowCounter, supplyColumn, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  315. //设置底色
  316. rowStyle = this.getRowStyle("#E0E0E0");
  317. }
  318. }
  319. if(data.unit_price.is_add!=1){//如果不是新增,定额价不可修改。
  320. activeSheet.getCell(rowCounter, basePriceColumn, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  321. }
  322. // 处理数据
  323. if (data.ratio_data !== undefined && data.ratio_data.length > 0) {
  324. let connectCode = [];
  325. let consumption = [];
  326. for (let tmp of data.ratio_data) {
  327. connectCode.push(tmp.connect_key);
  328. consumption.push(tmp.consumption);
  329. }
  330. let connectCodeString = connectCode.join(',');
  331. let consumptionString = consumption.join(',');
  332. activeSheet.setValue(rowCounter, connectCodeColumn, connectCodeString);
  333. activeSheet.setValue(rowCounter, consumptionColumn, consumptionString);
  334. }
  335. data=this.sheetObj.setProjectGLJDiffPrice(data);
  336. activeSheet.setValue(rowCounter,basePriceColumn,data.base_price);
  337. activeSheet.setValue(rowCounter,adjustPriceColumn,data.adjust_price);
  338. if(rowStyle==null&&data.base_price == data.unit_price.market_price){//如果定额价等于市场价时,改底色。 优先度低于有组成物时的底色
  339. rowStyle = this.getRowStyle("#C4CAFB");
  340. }
  341. activeSheet.setStyle(rowCounter, -1, rowStyle);
  342. rowCounter++;
  343. }
  344. };
  345. ProjectGLJSpread.prototype.getRowStyle = function (bgColour) {
  346. let style = new GC.Spread.Sheets.Style();
  347. style.backColor = bgColour;
  348. style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  349. style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  350. style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  351. style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  352. return style;
  353. };
  354. /**
  355. * 计算当前行对应组成物的市场以及基价单价价格
  356. *
  357. * @param {Number} row
  358. * @return {Object}
  359. */
  360. ProjectGLJSpread.prototype.compositionCalculate = function(updateRecord) {
  361. let gljData = projectObj.project.projectGLJ.datas;
  362. let m_index = gljOprObj.getIndex(updateRecord,gljKeyArray);
  363. let parent_connect_keys = gljData.mixRatioConnectData[m_index];
  364. if(!parent_connect_keys||parent_connect_keys.length<=0){// 不属于组成物则忽略
  365. return null;
  366. }
  367. let q_decimal = getDecimal("glj.quantity");
  368. let p_decimal = getDecimal("glj.unitPrice");
  369. let parentMarketPrice = {};
  370. for(let p of parent_connect_keys) {
  371. let mix_ratios = gljData.mixRatioMap[p];
  372. let sum = 0;
  373. for (let m of mix_ratios) {
  374. let unitPrice = this.sheetObj.getUnitPrice(m);
  375. if (unitPrice) {
  376. let com = scMathUtil.roundForObj(m.consumption, q_decimal);
  377. let marketPrice = scMathUtil.roundForObj(unitPrice.market_price, p_decimal);
  378. sum = scMathUtil.roundForObj(marketPrice * com + sum, p_decimal);
  379. }
  380. }
  381. parentMarketPrice[p]=sum;
  382. }
  383. return parentMarketPrice;
  384. };
  385. /**
  386. * 组成物父类数据更新
  387. *
  388. * @param {Object} parentMarketPrice
  389. * @return {void}
  390. */
  391. ProjectGLJSpread.prototype.compositionParentUpdate = function(parentMarketPrice) {
  392. let marketPriceColumn = this.sheetObj.getFieldColumn('unit_price.market_price');
  393. let activeSheet = this.sheetObj.getSheet();
  394. // 定位到父节点,然后更新
  395. for (let code in parentMarketPrice) {
  396. let changeRow = this.sheetObj.searchKeyword(code);
  397. activeSheet.setValue(changeRow, marketPriceColumn, parentMarketPrice[code]);
  398. }
  399. };
  400. /**
  401. * 价格计算
  402. *
  403. * @param {Object} info
  404. * @return {void}
  405. */
  406. ProjectGLJSpread.prototype.priceCalculate = function(info) {
  407. let row = info.row;
  408. let typeColumn = this.sheetObj.getFieldColumn('unit_price.type');
  409. let basePriceColumn = this.sheetObj.getFieldColumn('base_price');
  410. let adjustPriceColumn = projectGLJSheet.getFieldColumn('adjust_price');
  411. let activeSheet = this.sheetObj.getSheet();
  412. // 获取类型
  413. let type = activeSheet.getValue(row, typeColumn);
  414. /* let data = jsonData[row];
  415. if(gljOprObj.calcPriceDiff(data)==true){//是否记算价差
  416. data.base_price = data.unit_price.base_price;
  417. data.adjust_price = projectObj.project.projectGLJ.getAdjustPrice(data);
  418. }else {
  419. data.base_price = data.unit_price.market_price;
  420. data.adjust_price = data.unit_price.market_price;
  421. }
  422. activeSheet.setValue(info.row,basePriceColumn,data.base_price);
  423. activeSheet.setValue(info.row,adjustPriceColumn,data.adjust_price);*/
  424. /* // 基价单价计算
  425. switch (type) {
  426. // 主材、设备自动赋值基价单价=市场单价
  427. case GLJTypeConst.MAIN_MATERIAL:
  428. case GLJTypeConst.EQUIPMENT:
  429. activeSheet.setValue(info.row, basePriceColumn, info.newValue);
  430. break;
  431. }*/
  432. /* // 调整基价计算
  433. switch (type) {
  434. // 材料、主材、设备 调整基价=基价单价
  435. case GLJTypeConst.MAIN_MATERIAL:
  436. case GLJTypeConst.EQUIPMENT:
  437. let basePrice = activeSheet.getValue(info.row, basePriceColumn);
  438. activeSheet.setValue(info.row, adjustPriceColumn, basePrice);
  439. break;
  440. }*/
  441. // 市场单价计算
  442. switch (type) {
  443. // 人工、材料(普通材料)触发 需计算混凝土、砂浆、配合比、机械的市场单价
  444. case GLJTypeConst.LABOUR:
  445. case GLJTypeConst.GENERAL_MATERIAL:
  446. // 计算
  447. this.compositionParentUpdate(info.parentMarketPrice);
  448. break;
  449. }
  450. };
  451. /**
  452. * 更改供货方式
  453. *
  454. * @param {Object} info
  455. * @return {void}
  456. */
  457. ProjectGLJSpread.prototype.changeSupplyType = function(info) {
  458. // let supply = info.newValue;
  459. // let supplyNumber = this.supplyType.indexOf(supply) > -1 ? this.supplyType.indexOf(supply) : 0;
  460. let supplyNumber = info.newValue;
  461. let supplyQuantityColumn = this.sheetObj.getFieldColumn('supply_quantity');
  462. let activeSheet = this.sheetObj.getSheet();
  463. // 部分甲供时可更改甲供数量数据,其余则只读
  464. let locked = supplyNumber == 1 ? false : true;
  465. activeSheet.getCell(info.row, supplyQuantityColumn, GC.Spread.Sheets.SheetArea.viewport).locked(locked);
  466. let supplyQuantity = this.getSupplyQuantity(supplyNumber, activeSheet, info);
  467. activeSheet.setValue(info.row, supplyQuantityColumn, supplyQuantity);
  468. };
  469. /**
  470. * 根据供货方式获取甲供数量
  471. *
  472. * @param {Number} supplyType
  473. * @param {Object} activeSheet
  474. * @param {Object} info
  475. * @return {Number}
  476. */
  477. ProjectGLJSpread.prototype.getSupplyQuantity = function(supplyType, activeSheet, info) {
  478. let quantityColumn = this.sheetObj.getFieldColumn('quantity');
  479. // 获取总消耗量
  480. let quantity = activeSheet.getValue(info.row, quantityColumn);
  481. // 自行采购和甲定乙供则把甲供数量设置为0,其余情况则设置为当前总消耗量
  482. let supplyQuantity = supplyType == 0 || supplyType == 3 ? 0 : quantity;
  483. supplyQuantity = parseFloat(supplyQuantity);
  484. return supplyQuantity;
  485. };