1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /**
- * 配合比相关
- *
- * @author CaiAoLin
- * @date 2017/7/10
- * @version
- */
- let mixRatioSpread = null;
- let machineSpread = null;
- let isDeleting = false;
- $(document).ready(function() {
- // 切换tab触发refresh
- $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
- currentTag = $(e.target).data('name');
- // 获取工料机当前选中的行号
- let projectGLJId = 0;
- if (currentTag === "mix-ratio") {
- if (mixRatioSpread === null) {
- mixRatioSpread = new CompositionSpread();
- mixRatioSpread.init(currentTag);
- mixRatioSpread.initRightClick(currentTag);
- mixRatioSpread.successCallback = compositionSuccess;
- }
- // 筛选数据显示(显示混凝土、砂浆、配合比)
- projectGLJSheet.filterData('unit_price.type', [GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR, GLJTypeConst.MIX_RATIO]);
- projectGLJSheet.selectRow(projectGLJSpread.firstMixRatioRow);
- projectGLJId = projectGLJSheet.getActiveDataByField('id');
- // 获取数据
- mixRatioSpread.getRatioData(projectGLJId);
- }
- if (currentTag === "machine") {
- if (machineSpread === null) {
- machineSpread = new CompositionSpread();
- machineSpread.init(currentTag);
- machineSpread.initRightClick(currentTag);
- machineSpread.successCallback = compositionSuccess;
- }
- // 筛选数据显示(显示普通机械)
- projectGLJSheet.filterData('unit_price.type', [GLJTypeConst.GENERAL_MACHINE]);
- projectGLJSheet.selectRow(projectGLJSpread.firstMachineRow);
- projectGLJId = projectGLJSheet.getActiveDataByField('id');
- // 获取数据
- machineSpread.getRatioData(projectGLJId);
- }
- });
- });
- /**
- * 成功事件
- *
- * @param {object} info
- * @return {void}
- */
- function compositionSuccess(info) {
- // 成功则对相应的总消耗量进行设置
- let row= projectGLJSheet.sheet.getActiveRowIndex();//取父机械或组成物的下标
- let parentData = jsonData[row];
- let ratioData = _.find(parentData.ratio_data,{"id":info.id});
- let con_key = gljOprObj.getIndex(ratioData,gljKeyArray);
- for(let i=0;i< jsonData.length;i++){
- let tem_key = gljOprObj.getIndex(jsonData[i],gljKeyArray);
- if(con_key == tem_key){
- //乘以父工料机的消耗量得到该组成物总消耗量的改变量
- info.change = operationWithRound(parentData.quantity,info.change,"glj.quantity","*");
- projectGLJSheet.setCellByField('quantity', info.change, true,i);
- }
- }
- // 设置父级3个价格
- projectGLJSheet.setCellByField('unit_price.market_price', info.parentMarketPrice, false);
- projectGLJSheet.setCellByField('unit_price.base_price', info.parentBasePrice, false);
- projectGLJSheet.setCellByField('adjust_price', info.parentMarketPrice, false);
- // 更新组成物缓存
- projectObj.project.composition.loadData();
- }
|