material_calc_view.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973
  1. /**
  2. * Created by zhang on 2019/3/11.
  3. */
  4. materialCalcObj = {
  5. moduleName:'materalCal',
  6. materialSpread:null,
  7. materialSheet:null,
  8. materialDatas:[],
  9. materialSetting:{
  10. header:[
  11. {headerName: "编号", headerWidth: 80, dataCode: "code", dataType: "String"},
  12. {headerName: "名称", headerWidth: 100, dataCode: "name", dataType: "String"},
  13. {headerName: "预算价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},
  14. {headerName: "供应地点", headerWidth: 100, dataCode: "supplyLocation", hAlign: "left", dataType: "String"},
  15. {headerName: "原价", headerWidth: 60, dataCode: "originalPrice", hAlign: "right", dataType: "String"},
  16. {headerName: "单位运费", headerWidth: 60, dataCode: "unitFreight", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'glj.unitPrice'
  17. {headerName: "单位毛重(吨)", headerWidth: 60, dataCode: "grossWeightCoe_n", hAlign: "right", dataType: "Number"},//,decimalField:"glj.unitPrice"
  18. {headerName: "装卸总次数", headerWidth: 60, dataCode: "totalLoadingTimes", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
  19. {headerName: "每增加一次装卸损耗率", headerWidth: 80, dataCode: "handlingLossRate_n", hAlign: "right", dataType: "Number",validator:"number"},
  20. {headerName: "场外运输损耗率", headerWidth: 60, dataCode: "offSiteTransportLossRate_n", hAlign: "right", dataType: "Number"},//,decimalField:"glj.unitPrice"
  21. {headerName: "场外运输损耗", headerWidth: 60, dataCode: "offSiteTransportLoss", hAlign: "right", dataType: "Number"},//,decimalField:"glj.unitPrice"
  22. {headerName: "采购及保管费率", headerWidth: 60, dataCode: "purchaseStorageRate_n", hAlign: "right", dataType: "Number"},//,decimalField:"glj.unitPrice"
  23. {headerName: "采购及保管费", headerWidth: 60, dataCode: "purchaseStorage", hAlign: "right", dataType: "Number"},//,decimalField:"glj.unitPrice"
  24. {headerName: "包装品回收价值", headerWidth: 60, dataCode: "packageRecoverValue", hAlign: "right", dataType: "Number"}//,decimalField:"glj.unitPrice"
  25. ],
  26. view: {
  27. lockColumns: ["code","name","marketPrice",'offSiteTransportLoss','purchaseStorage'],
  28. colHeaderHeight:36
  29. }
  30. },
  31. freightSpread:null,
  32. freightSheet:null,
  33. freightDatas:[],
  34. conveyanceOptions:["自办运输","汽车","火车","船舶","马车","手推车","拖拉机"],
  35. userFreightList:[],
  36. freightSetting:{
  37. header:[
  38. {headerName: "起讫地点", headerWidth: 80, dataCode: "start", dataType: "String"},
  39. {headerName: "运输工具", headerWidth: 80, dataCode: "conveyance", dataType: "String"},
  40. {headerName: "单位运价", headerWidth: 60, dataCode: "unitFreight", hAlign: "right", dataType: "Number",validator:"number"},
  41. {headerName: "km运距", headerWidth: 60, dataCode: "kmDistance", hAlign: "right", dataType: "String",validator:"number"},
  42. {headerName: "装卸费\n单价", headerWidth: 60, dataCode: "unitLoadingFee", hAlign: "right", dataType: "String",validator:"number"},
  43. {headerName: "装卸\n次数", headerWidth: 60, dataCode: "loadingTimes", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'glj.unitPrice'
  44. {headerName: "其它\n费用", headerWidth: 60, dataCode: "otherFee", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
  45. {headerName: "运价增\n加率(%)", headerWidth: 60, dataCode: "freightIncreaseRate", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
  46. {headerName: "加权\n系数", headerWidth: 60, dataCode: "weightCoe", hAlign: "right", dataType: "Number",validator:"number"},
  47. {headerName: "计算式", headerWidth: 170, dataCode: "exp", hAlign: "left", dataType: "Number",getText:'forExp'},//,decimalField:"glj.unitPrice"
  48. {headerName: "计算方式", headerWidth: 80, dataCode: "calcType", dataType: "String",cellType:"comboBox",options:["全国","内蒙古"]},
  49. {headerName: "材料类型", headerWidth: 80, dataCode: "materialType", dataType: "String",cellType:"comboBox",options:["地方材料","外购材料","沥青、燃料等"]}
  50. ],
  51. view: {
  52. lockColumns: ["exp"],
  53. colHeaderHeight:36
  54. },
  55. getText:{
  56. forExp:function (item) {
  57. let material = materialCalcObj.getMaterialSelected();
  58. if(item.calcType == "内蒙古"){
  59. let uString = materialCalcObj.getNeiMengUnitFreightString(item.kmDistance,item.materialType);
  60. return `((${uString}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes})/1.09+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
  61. }
  62. //(单位运价×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
  63. if(item.conveyance == "自办运输") return `(${item.unitFreight}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
  64. //(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
  65. return `(${item.unitFreight}x${item.kmDistance}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
  66. }
  67. }
  68. },
  69. priceSpread:null,
  70. priceSheet:null,
  71. priceDatas:[],
  72. priceSetting:{
  73. header:[
  74. {headerName: "供应地点", headerWidth: 80, dataCode: "supplyLocation", dataType: "String"},
  75. {headerName: "供应价", headerWidth: 70, dataCode: "supplyPrice", hAlign: "right", dataType: "Number",validator:"number"},
  76. {headerName: "加权系数", headerWidth: 80, dataCode: "coe", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'glj.unitPrice'
  77. ],
  78. view: {
  79. lockColumns: [],
  80. colHeaderHeight:36
  81. }
  82. },
  83. freightRationSpread:null,
  84. freightRationSheet:null,
  85. freightRations:[],
  86. priceRations:[],
  87. priceRationSpread:null,
  88. priceRationSheet:null,
  89. rationSetting:{
  90. header:[
  91. {headerName: "编号", headerWidth: 80, dataCode: "code", dataType: "String",formatter: "@"},
  92. {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
  93. {headerName: "单位", headerWidth: 100, dataCode: "unit", dataType: "String"},
  94. {headerName: "数量", headerWidth: 100, dataCode: "quantity", dataType: "String",hAlign: "right",validator:"number"},
  95. {headerName: "高原取费类别", headerWidth: 100, dataCode: "feeType", dataType: "String",visible: false,cellType:"comboBox",options:[]}
  96. ],
  97. view: {
  98. lockColumns: ["unit"],
  99. colHeaderHeight:36
  100. }
  101. },
  102. initMaterialSpread:function () {
  103. this.materialSpread = SheetDataHelper.createNewSpread($("#materialCalcSheet")[0]);
  104. sheetCommonObj.spreadDefaultStyle(this.materialSpread);
  105. this.materialSheet = this.materialSpread.getSheet(0);
  106. sheetCommonObj.initSheet(this.materialSheet, this.materialSetting, 30);
  107. this.materialSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onMaterialValueChange);
  108. this.materialSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onMaterialSelectionChange);
  109. this.materialSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onMaterialEditStarting);
  110. this.materialSheet.name('material_calc');
  111. if(projectReadOnly){
  112. disableSpread(this.materialSpread);
  113. }else {
  114. this.initRightClick("materialCalcSheet",this.materialSpread)
  115. }
  116. },
  117. initFreightSpread:async function(){
  118. this.freightSpread = SheetDataHelper.createNewSpread($("#freightSheet")[0]);
  119. sheetCommonObj.spreadDefaultStyle(this.freightSpread);
  120. this.freightSheet = this.freightSpread.getSheet(0);
  121. sheetCommonObj.initSheet(this.freightSheet, this.freightSetting, 30);
  122. this.freightSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onFreightValueChange);
  123. this.freightSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onFreightSelectionChange);
  124. this.freightSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onFreightEditStarting);
  125. this.freightSheet.name('freight_calc');
  126. if(projectReadOnly){
  127. disableSpread(this.freightSpread);
  128. }else {
  129. this.initRightClick("freightSheet",this.freightSpread)
  130. }
  131. this.userFreightList = await projectObj.project.projectGLJ.getUserFreights();
  132. },
  133. initFreightRationSpread:function () {
  134. this.freightRationSpread = SheetDataHelper.createNewSpread($("#freight_ration_sheet")[0]);
  135. sheetCommonObj.spreadDefaultStyle(this.freightRationSpread);
  136. this.freightRationSheet = this.freightRationSpread.getSheet(0);
  137. sheetCommonObj.initSheet(this.freightRationSheet, this.rationSetting, 30);
  138. this.freightRationSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onFreightRationValueChange);
  139. this.freightRationSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onRationSelectionChange);
  140. this.freightRationSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onFreightRationEditStarting);
  141. this.freightRationSheet.name('freight_ration');
  142. if(projectReadOnly){
  143. disableSpread(this.freightRationSpread);
  144. }else {
  145. this.initRightClick("freight_ration_sheet",this.freightRationSpread);
  146. }
  147. },
  148. initPriceRationSpread:function () {
  149. this.priceRationSpread = SheetDataHelper.createNewSpread($("#price_ration_sheet")[0]);
  150. sheetCommonObj.spreadDefaultStyle(this.priceRationSpread);
  151. this.priceRationSheet = this.priceRationSpread.getSheet(0);
  152. sheetCommonObj.initSheet(this.priceRationSheet, this.rationSetting, 30);
  153. this.priceRationSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onPriceRationValueChange);
  154. this.priceRationSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onRationSelectionChange);
  155. this.priceRationSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onPriceRationEditStarting);
  156. this.priceRationSheet.name('price_ration');
  157. if(projectReadOnly){
  158. disableSpread(this.priceRationSpread);
  159. }else {
  160. this.initRightClick("price_ration_sheet",this.priceRationSpread);
  161. }
  162. },
  163. initPriceSpread:async function(){
  164. this.priceSpread = SheetDataHelper.createNewSpread($("#priceSheet")[0]);
  165. sheetCommonObj.spreadDefaultStyle(this.priceSpread);
  166. this.priceSheet = this.priceSpread.getSheet(0);
  167. sheetCommonObj.initSheet(this.priceSheet, this.priceSetting, 30);
  168. this.priceSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onPriceValueChange);
  169. this.priceSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onPriceSelectionChange);
  170. this.priceSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onPriceEditStarting);
  171. this.priceSheet.name('price_calc');
  172. if(projectReadOnly){
  173. disableSpread(this.priceSpread);
  174. }else {
  175. this.initRightClick("priceSheet",this.priceSpread)
  176. }
  177. },
  178. showFreightDatas:function () {
  179. if(!$('#freightSheet').is(':visible')) return;
  180. let sel = this.freightSheet.getSelections()[0];
  181. let oldData = sel.row<this.freightDatas.length?this.freightDatas[sel.row]:"";
  182. this.freightSheet.setRowCount(0);
  183. this.freightDatas = this.getFreightDatas();
  184. sheetCommonObj.showData(this.freightSheet, this.freightSetting,this.freightDatas);
  185. this.freightSheet.setRowCount(this.freightDatas+20);
  186. let convCol = _.findIndex(this.freightSetting.header,{'dataCode':'conveyance'});
  187. sheetCommonObj.setComboBox(-1,convCol,this.freightSheet,this.conveyanceOptions,false);
  188. let startCol = _.findIndex(this.freightSetting.header,{'dataCode':'start'});
  189. let startOptions = this.getUserFreightOptions();
  190. sheetCommonObj.setComboBox(-1,startCol,this.freightSheet,startOptions,false,true);
  191. sel.row = oldData?_.findIndex(this.freightDatas,{'ID':oldData.ID}):sel.row ;
  192. this.freightSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
  193. this.refreshRationView();
  194. },
  195. getUserFreightOptions :function () {
  196. let options = [];
  197. for(let uf of this.userFreightList){
  198. options.push(uf.freight.start);
  199. }
  200. return options;
  201. },
  202. showFreightRationDatas:function (freight) {
  203. let sel = this.freightRationSheet.getSelections()[0];
  204. let oldData = sel.row<this.freightRations.length?this.freightRations[sel.row]:"";
  205. this.freightRationSheet.setRowCount(0);
  206. this.freightRations = freight.rations?freight.rations:[];
  207. sheetCommonObj.showData(this.freightRationSheet, this.rationSetting,this.freightRations);
  208. this.freightRationSheet.setRowCount(this.freightRations+20);
  209. sel.row = oldData?_.findIndex(this.freightRations,{'ID':oldData.ID}):sel.row ;
  210. this.freightRationSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
  211. this.refreshAssView();
  212. },
  213. showPriceRationDatas:function () {
  214. let price = this.getSelectedPrice();
  215. let sel = this.priceRationSheet.getSelections()[0];
  216. let oldData = sel.row<this.priceRations.length?this.priceRations[sel.row]:"";
  217. this.priceRationSheet.setRowCount(0);
  218. this.priceRations = price&&price.rations?price.rations:[];
  219. sheetCommonObj.showData(this.priceRationSheet, this.rationSetting,this.priceRations);
  220. this.priceRationSheet.setRowCount(this.priceRations+20);
  221. sel.row = oldData?_.findIndex(this.priceRations,{'ID':oldData.ID}):sel.row ;
  222. this.priceRationSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
  223. this.refreshAssView();
  224. },
  225. showMaterialCalcDatas:function(){
  226. let sel = this.materialSheet.getSelections()[0];
  227. let oldData = sel.row<this.materialDatas.length?this.materialDatas[sel.row]:"";
  228. this.materialSheet.setRowCount(0);
  229. this.materialDatas = this.getMaterialCalcDatas();
  230. sheetCommonObj.showData(this.materialSheet, this.materialSetting,this.materialDatas);
  231. this.materialSheet.setRowCount(this.materialDatas.length);
  232. sel.row = oldData?_.findIndex(this.materialDatas,{'id':oldData.id}):-1;
  233. this.materialSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
  234. },
  235. showPriceDatas:function () {
  236. if(!$('#priceSheet').is(':visible')) return;
  237. let sel = this.priceSheet.getSelections()[0];
  238. let oldData = sel.row<this.priceDatas.length?this.priceDatas[sel.row]:"";
  239. this.priceSheet.setRowCount(0);
  240. this.priceDatas = this.getPriceDatas();
  241. sheetCommonObj.showData(this.priceSheet, this.priceSetting,this.priceDatas);
  242. this.priceSheet.setRowCount(this.priceDatas.length+20);
  243. sel.row = oldData?_.findIndex(this.priceDatas,{'ID':oldData.ID}):sel.row ;
  244. this.priceSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
  245. this.showPriceRationDatas();
  246. },
  247. showDatas:async function(){
  248. if(!$('#materialCalcSheet').is(':visible')) return;
  249. if(!this.materialSpread) this.initMaterialSpread();
  250. if(!this.freightSpread)await this.initFreightSpread();
  251. if(!this.priceSpread) this.initPriceSpread();
  252. if(!this.freightRationSpread) this.initFreightRationSpread();
  253. if(!this.priceRationSpread) this.initPriceRationSpread();
  254. let h =_.find(this.rationSetting.header,{"dataCode":"feeType"});
  255. if(h) h.options = projectObj.project.calcProgram.compiledTemplateNames;
  256. this.showMaterialCalcDatas();
  257. this.showFreightDatas();
  258. this.showPriceDatas();
  259. // 先试试看注释有没有bug projectGljObject.refreshSubViews();
  260. },
  261. getMaterialSelected:function () {
  262. let sel = this.materialSheet.getSelections()[0];
  263. if(sel.row != -1 && this.materialDatas.length>sel.row){
  264. return this.materialDatas[sel.row]
  265. }
  266. return null;
  267. },
  268. getPriceDatas:function () {
  269. let list = projectObj.project.projectGLJ.datas.originalList;
  270. let material = this.getMaterialSelected();
  271. return material?_.filter(list,{"connect_key":gljUtil.getIndex(material)}):[];
  272. },
  273. getFreightDatas:function () {
  274. let list = projectObj.project.projectGLJ.datas.freightList;
  275. let material = this.getMaterialSelected();
  276. return material?_.filter(list,{"connect_key":gljUtil.getIndex(material)}):[];
  277. },
  278. getMaterialCalcDatas:function () {
  279. let gljList = projectObj.project.projectGLJ.datas.gljList;
  280. let datas = [];
  281. for(let g of gljList){
  282. if(g.quantity !== 0 && g.quantity !== '0' && g.unit_price.calcMaterial == 1){
  283. let data = {
  284. id:g.id,
  285. code:g.code,
  286. name:g.name,
  287. type:g.type,
  288. unit:g.unit,
  289. specs:g.specs,
  290. unit_price:{id:g.unit_price.id,type:g.type,unit_price_file_id:g.unit_price.unit_price_file_id},//type用来排序
  291. supplyLocation:g.unit_price.supplyLocation,
  292. originalPrice:g.unit_price.originalPrice?g.unit_price.originalPrice:0,
  293. unitFreight:g.unit_price.unitFreight?g.unit_price.unitFreight:0,
  294. // unitWeight:g.unit_price.unitWeight?g.unit_price.unitWeight:0,
  295. totalLoadingTimes:g.unit_price.totalLoadingTimes?g.unit_price.totalLoadingTimes:0,
  296. handlingLossRate_n:g.unit_price.handlingLossRate_n?g.unit_price.handlingLossRate_n:0,
  297. offSiteTransportLossRate_n:g.unit_price.offSiteTransportLossRate_n?g.unit_price.offSiteTransportLossRate_n:0,
  298. offSiteTransportLoss:g.unit_price.offSiteTransportLoss?g.unit_price.offSiteTransportLoss:0,
  299. purchaseStorageRate_n:g.unit_price.purchaseStorageRate_n?g.unit_price.purchaseStorageRate_n:0,
  300. purchaseStorage:g.unit_price.purchaseStorage?g.unit_price.purchaseStorage:0,
  301. grossWeightCoe_n:g.unit_price.grossWeightCoe_n?g.unit_price.grossWeightCoe_n:0,
  302. packageRecoverValue:g.unit_price.packageRecoverValue?g.unit_price.packageRecoverValue:0
  303. };
  304. gljOprObj.setGLJPrice(data,g);
  305. datas.push(data);
  306. }
  307. }
  308. return gljUtil.sortProjectGLJ(datas);
  309. },
  310. onMaterialSelectionChange:function(sender,args){
  311. let me = materialCalcObj;
  312. let newSel = args.newSelections[0];
  313. let oldSel = args.oldSelections?args.oldSelections[0]:{};
  314. if(newSel.row != oldSel.row){
  315. me.showPriceDatas();
  316. me.showFreightDatas();
  317. }
  318. },
  319. onFreightSelectionChange:function (sender,args) {
  320. materialCalcObj.refreshRationView();
  321. args.sheet.repaint();
  322. },
  323. onRationSelectionChange:function(sender,args){
  324. materialCalcObj.refreshAssView(args);
  325. args.sheet.repaint();
  326. },
  327. onPriceSelectionChange:function (sender,args) {
  328. materialCalcObj.showPriceRationDatas();
  329. },
  330. onPriceEditStarting:function (sender,args) {
  331. let me = materialCalcObj;
  332. if(!me.getMaterialSelected()){
  333. args.cancel = true;
  334. }
  335. },
  336. onFreightEditStarting:function(sender,args){
  337. let me = materialCalcObj;
  338. if(!me.getMaterialSelected()){
  339. args.cancel = true;
  340. }else {
  341. let freigth = me.freightDatas[args.row];
  342. let dataCode = me.freightSetting.header[args.col].dataCode;
  343. if(dataCode == "calcType" || dataCode=="materialType"){
  344. if(!freigth){
  345. args.cancel = true;
  346. }else if(dataCode == "materialType" && freigth.calcType !="内蒙古"){//不是内蒙古的情况下,下拉框不可编辑
  347. args.cancel = true;
  348. }
  349. }
  350. if(freigth){
  351. if(dataCode == "kmDistance" || dataCode=="unitLoadingFee" || dataCode =="loadingTimes" || dataCode == "freightIncreaseRate"){
  352. if(freigth.conveyance == "自办运输") args.cancel = true;
  353. }
  354. if(dataCode == "unitFreight"){
  355. if(freigth.rations && freigth.rations.length > 0) args.cancel = true;
  356. if(freigth.calcType == "内蒙古") args.cancel = true;
  357. }
  358. }
  359. }
  360. },
  361. onFreightRationEditStarting:function (sender,args) {
  362. materialCalcObj.onRationEditStarting(sender,args,"freight");
  363. },
  364. onPriceRationEditStarting:function (sender,args) {
  365. materialCalcObj.onRationEditStarting(sender,args,"price");
  366. },
  367. onRationEditStarting:function(sender,args,type){
  368. let me = materialCalcObj;
  369. let dataCode = me.rationSetting.header[args.col].dataCode;
  370. let datas = type == "freight"?me.freightRations:me.priceRations;
  371. if(args.row > datas.length){
  372. args.cancel = true;
  373. }else if(args.row == datas.length && dataCode != "code"){
  374. args.cancel = true;
  375. }
  376. },
  377. onMaterialEditStarting:function (sender,args) {
  378. let me = materialCalcObj;
  379. let dataCode = me.materialSetting.header[args.col].dataCode;
  380. if(dataCode == "supplyLocation" ||dataCode == "originalPrice"){//原价计算表有数据时只读,
  381. args.cancel = me.getPriceDatas().length > 0;
  382. }
  383. if(dataCode == "unitFreight"){//当运费计算表有数据时,则只读
  384. args.cancel = me.getFreightDatas().length > 0;
  385. }
  386. },
  387. onMaterialValueChange:function (sender,args) {
  388. let me = materialCalcObj;
  389. let dataCode = me.materialSetting.header[args.col].dataCode;
  390. let value = args.newValue;
  391. if (value&&!sheetCommonObj.checkData(args.col,me.materialSetting,value)) {
  392. alert('输入的数据类型不对,请重新输入!');
  393. me.showDatas();
  394. return;
  395. }
  396. if(dataCode != 'supplyLocation'){
  397. value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
  398. }
  399. let recode = me.materialDatas[args.row];
  400. if(recode[dataCode] == value) return;
  401. let doc = {};
  402. doc[dataCode] = value;
  403. projectObj.project.projectGLJ.updateMaterialCalc([{id:recode.id,doc:doc}]);
  404. },
  405. getDefualtCalcType:function () {
  406. return "全国";
  407. },
  408. getNewFreightData:function (material) {
  409. let newData = {
  410. ID: uuid.v1(),
  411. start:"",//起讫地点
  412. conveyance:"汽车",//运输工具
  413. unitFreight:'0',//单位运价
  414. kmDistance:'0',//km运距
  415. unitLoadingFee:'0',//装卸费单价
  416. loadingTimes:'0',//装卸次数
  417. otherFee:'0',//其它费用
  418. freightIncreaseRate:'0',//运价增加率
  419. weightCoe:'1',//加权系数
  420. connect_key:gljUtil.getIndex(material),
  421. unit_price_file_id:material.unit_price.unit_price_file_id
  422. };
  423. return newData;
  424. },
  425. getSavedFreight:function (start,material) {
  426. let t = null;
  427. for(let f of this.userFreightList){
  428. if(f.freight.start == start){
  429. t = newDatas(f.freight,material);
  430. break;
  431. }
  432. }
  433. return t;
  434. function newDatas(freight,material) {
  435. let doc = {};
  436. for(let key in freight){
  437. doc[key] = freight[key];
  438. if(key == "ID") doc[key] = uuid.v1();
  439. if(key == "connect_key") doc[key] = gljUtil.getIndex(material);
  440. if(key == "unit_price_file_id") doc[key] = material.unit_price.unit_price_file_id;
  441. }
  442. return doc;
  443. }
  444. },
  445. checkSavedFreight:function (start) {
  446. let t = null;
  447. for(let f of this.userFreightList){
  448. if(f.freight.start == start){
  449. t = f;
  450. break;
  451. }
  452. }
  453. return t;
  454. },
  455. onFreightValueChange:function (sender,args) {
  456. let me = materialCalcObj;
  457. let dataCode = me.freightSetting.header[args.col].dataCode;
  458. let value = args.newValue;
  459. let material = me.getMaterialSelected();
  460. if (value&&!sheetCommonObj.checkData(args.col,me.freightSetting,value)) {
  461. alert('输入的数据类型不对,请重新输入!');
  462. me.showDatas();
  463. return;
  464. }
  465. if(dataCode != 'start'&&dataCode != 'conveyance'&&dataCode != 'calcType'&&dataCode != 'materialType'){
  466. value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
  467. }
  468. if(args.row >= me.freightDatas.length){//新增
  469. let newData = {};
  470. let tempFreight = null;
  471. if(dataCode == "start"){
  472. tempFreight = me.getSavedFreight(value,material);
  473. }
  474. if(tempFreight){
  475. newData = tempFreight;
  476. }else {
  477. newData = me.getNewFreightData(material);
  478. newData[dataCode] = value;
  479. newData.calcType = me.getDefualtCalcType();
  480. if(newData.calcType == "内蒙古") newData.materialType = "地方材料";
  481. }
  482. projectObj.project.projectGLJ.addFreightCalc([newData],material.id);
  483. }else {//修改
  484. let recode = me.freightDatas[args.row];
  485. if(recode[dataCode] == value) return;
  486. let doc = {};
  487. doc[dataCode] = value;
  488. if(dataCode == "conveyance"){//如果运输方式从自办运输切换成其它的东西时,要把底下挂的定额和定额工料机都清空
  489. if(args.oldValue == "自办运输"){
  490. doc["rations"] = [];
  491. doc["ration_gljs"] = [];
  492. }
  493. if(value == "自办运输"){//当运输工具下拉选择“自办运输”时,“Km运距”、“装卸费单价”、“装卸次数”、“运价增加率(%)”列数据归0,且灰选不可编辑
  494. doc["kmDistance"] = '0';
  495. doc["unitLoadingFee"] ='0';
  496. doc["loadingTimes"] = '0';
  497. doc["freightIncreaseRate"] = '0';
  498. }
  499. }
  500. if(dataCode == "calcType"){
  501. if(value == "全国") doc["materialType"] = "";
  502. if(value == "内蒙古"){
  503. doc["materialType"] = "地方材料";
  504. doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,"地方材料");
  505. }
  506. }
  507. if(recode.calcType == "内蒙古"){
  508. if(dataCode == "materialType") doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,value);
  509. if(dataCode == "kmDistance") doc["unitFreight"] = me.calcNeiMengUnitFreight(value,recode.materialType);
  510. }
  511. if(dataCode == "start"){
  512. let t_f = me.getSavedFreight(value,material);
  513. if(t_f) doc = t_f;
  514. }
  515. projectObj.project.projectGLJ.updateFreightCalc([{ID:recode.ID,doc:doc}],material.id);
  516. }
  517. },
  518. calcNeiMengUnitFreight:function (tkmDistance,tmaterialType) {
  519. if(!tkmDistance||tkmDistance == '0') return "0";
  520. let decimal = getDecimal("glj.unitPrice");
  521. tkmDistance = scMathUtil.roundForObj(tkmDistance,decimal);
  522. return scMathUtil.roundForObj(this.calNeiMengTotalFreight(tkmDistance,tmaterialType)/tkmDistance,decimal);
  523. },
  524. calNeiMengTotalFreight:function (kmDistance,materialType) {
  525. if(!kmDistance||kmDistance == '0') return 0;
  526. let decimal = getDecimal("glj.unitPrice");
  527. let baseMap = {"地方材料":6,"外购材料":13,"沥青、燃料等":19};//"地方材料","外购材料","沥青、燃料等"
  528. let baseFreight = baseMap[materialType];
  529. kmDistance = scMathUtil.roundForObj(kmDistance,decimal);
  530. //用截取的方式,一段段取值
  531. let less = kmDistance - 5;//kmDistance <= 5 这段
  532. if(less <= 0) return baseFreight ; //kmDistance <= 5 的时候直接取baseFreight
  533. //5< kmDistance <= 15 每增运1km 则增加0.6
  534. less = less - 10;
  535. if(less <=0) return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj((less + 10) * 0.6,6),decimal);//baseFreight + (less + 10) * 0.6;
  536. baseFreight = baseFreight + 10 * 0.6; //累加5到15这一段的运费;
  537. //15< kmDistance <= 100 每增运1km 则增加0.45
  538. less = less - 85;
  539. if(less <=0) return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj((less + 85)*0.45,6),decimal);//baseFreight + (less + 85)*0.45;
  540. baseFreight = scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj(85*0.45,6),6) ; //累加15到100这一段的运费;
  541. return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj(less * 0.35,6),decimal); // >100 的所有部分每增运1km 则增加0.35 baseFreight + less * 0.35
  542. },
  543. getNeiMengUnitFreightString:function (kmDistance,materialType) {
  544. if(!kmDistance||kmDistance == '0') return "0";
  545. let decimal = getDecimal("glj.unitPrice");
  546. let baseMap = {"地方材料":6,"外购材料":13,"沥青、燃料等":19};//"地方材料","外购材料","沥青、燃料等"
  547. let baseFreight = baseMap[materialType];
  548. kmDistance = scMathUtil.roundForObj(kmDistance,decimal);
  549. let resultString = baseFreight+"";
  550. //用截取的方式,一段段取值
  551. let less = kmDistance - 5;//kmDistance <= 5 这段
  552. if(less <= 0) return resultString ; //kmDistance <= 5 的时候直接取baseFreight
  553. //5< kmDistance <= 15 每增运1km 则增加0.6
  554. less = less - 10;
  555. if(less <=0) return `(${resultString}+0.6x${less + 10})`;//baseFreight + (less + 10) * 0.6;
  556. resultString = `${resultString}+0.6x10`;
  557. //15< kmDistance <= 100 每增运1km 则增加0.45
  558. less = less - 85;
  559. if(less <=0) return `(${resultString}+0.45x${less + 85})`; //baseFreight + (less + 85)*0.45;
  560. resultString = `${resultString}+0.45x85`;
  561. return `(${resultString}+0.35x${less})`;// >100 的所有部分每增运1km 则增加0.35 baseFreight + less * 0.35
  562. },
  563. onFreightRationValueChange:function (sender,args) {
  564. materialCalcObj.onRationValueChange(sender,args,"freight");
  565. },
  566. onPriceRationValueChange:function (sender,args) {
  567. materialCalcObj.onRationValueChange(sender,args,"price");
  568. },
  569. onRationValueChange:function (sender,args,type) {
  570. let me = materialCalcObj;
  571. let dataCode = me.rationSetting.header[args.col].dataCode;
  572. let value = args.newValue;
  573. let parent = type == "freight"? me.getSelectedFreight():me.getSelectedPrice();
  574. let dataList = type == "freight"?me.freightRations:me.priceRations;
  575. if(dataCode == "code" && args.row >= dataList.length) {//新增
  576. if(parent) projectObj.project.projectGLJ.addMaterialRation(value,type,parent.ID,parent.connect_key);
  577. }else { //修改
  578. let ration = dataList[args.row];
  579. if (value&&!sheetCommonObj.checkData(args.col,me.rationSetting,value)) {
  580. alert('输入的数据类型不对,请重新输入!');
  581. return type == "freight"?me.showFreightRationDatas(parent):me.showPriceRationDatas();
  582. }
  583. if(dataCode == 'quantity'){
  584. if(value){
  585. value = scMathUtil.roundForObj(parseFloat(value) / FilterNumberFromUnit(ration.unit),getDecimal("ration.quantity"))+"";
  586. }else {
  587. value = "0";
  588. }
  589. }
  590. let datas = {parentID:parent.ID,rationID:ration.ID,type:type,actionType:"update",field:dataCode,value:value};
  591. if(dataCode == "code"){ //这时是替换,替换比较麻烦
  592. datas.code = value;
  593. datas.row = args.row;
  594. let libIDs = rationLibObj.getStdRationLibIDs();
  595. let defaultLibID = rationLibObj.getDefaultStdRationLibID();
  596. let selectedLib = sessionStorage.getItem("stdRationLib");
  597. selectedLib&&selectedLib!='undefined'?libIDs.unshift(selectedLib):libIDs.unshift(defaultLibID);
  598. datas.userID = userID;
  599. datas.defaultLibID = defaultLibID;
  600. datas.rationRepIds = libIDs;
  601. datas.quantityDecimal = getDecimal("ration.quantity");
  602. datas.connect_key = parent.connect_key;
  603. datas.projectID = projectObj.project.ID();
  604. datas.rations = parent.rations;
  605. datas.ration_gljs = parent.ration_gljs;
  606. }
  607. projectObj.project.projectGLJ.updateMaterialRation(datas);
  608. }
  609. },
  610. onPriceValueChange:function(sender,args){
  611. let me = materialCalcObj;
  612. let dataCode = me.priceSetting.header[args.col].dataCode;
  613. let value = args.newValue;
  614. let material = me.getMaterialSelected();
  615. //输入有效性判断, to do
  616. if (value&&!sheetCommonObj.checkData(args.col,me.priceSetting,value)) {
  617. alert('输入的数据类型不对,请重新输入!');
  618. me.showDatas();
  619. return;
  620. }
  621. if(dataCode == 'coe'||dataCode == 'supplyPrice'){
  622. value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
  623. }
  624. if(args.row >= me.priceDatas.length){//新增
  625. let newData = {
  626. ID:uuid.v1(),
  627. supplyLocation:"",
  628. supplyPrice:'0',
  629. coe:'1',
  630. connect_key:gljUtil.getIndex(material),
  631. unit_price_file_id:material.unit_price.unit_price_file_id
  632. };
  633. newData[dataCode] = value;
  634. projectObj.project.projectGLJ.addPriceCalc([newData],material.id);
  635. }else {//修改
  636. let recode = me.priceDatas[args.row];
  637. if(recode[dataCode] == value) return;
  638. let doc = {};
  639. doc[dataCode] = value;
  640. projectObj.project.projectGLJ.updatePriceCalc([{ID:recode.ID,doc:doc}],material.id);
  641. }
  642. },
  643. deleteMaterialCal:function (row) {
  644. let record = this.materialDatas[row];//修改材料计算标记的同时还要删除原价计算,运费计算等
  645. if(record){
  646. projectObj.project.projectGLJ.updateCalcMaterial(record,'calcMaterial',0);
  647. }
  648. },
  649. deletePriceCalc:function (row) {
  650. let record = this.priceDatas[row];
  651. if(record){
  652. let material = this.getMaterialSelected();
  653. projectObj.project.projectGLJ.deletePriceCalc(record.ID,material.id);
  654. }
  655. },
  656. deleteFreightCalc:function (row) {
  657. let record = this.freightDatas[row];
  658. if(record){
  659. let material = this.getMaterialSelected();
  660. projectObj.project.projectGLJ.deleteFreightCalc(record.ID,material.id);
  661. }
  662. },
  663. deleteRation:function (row,type) {
  664. let me = this;
  665. let parent = type == "freight"?me.getSelectedFreight():me.getSelectedPrice();
  666. let ration = type == "freight"?me.freightRations[row]:me.priceRations[row];
  667. let datas = {parentID:parent.ID,rationID:ration.ID,type:type,actionType:"delete"};
  668. projectObj.project.projectGLJ.updateMaterialRation(datas);
  669. },
  670. saveFreight:function (row) {
  671. let me = this;
  672. let record = this.freightDatas[row];
  673. if(record){
  674. let exist = this.checkSavedFreight(record.start);
  675. if(exist){//已存在的情况,更新
  676. let info =`起讫地点“${record.start}”已存在,是否覆盖?`;
  677. //to do 检查是否已经存在,存在给出是否覆盖提示
  678. hintBox.infoBox('操作确认', info, 2, function () {
  679. me.updateUserFreight(record,exist)
  680. }, function () {
  681. //
  682. },['确定','取消'],false);
  683. return true;
  684. }
  685. let user_freight = {rootProjectID:projectObj.project.projectInfo.property.rootProjectID};
  686. let f = {};
  687. for(let key in record){
  688. f[key] = record[key];
  689. if(key =="ration" || key == "ration_gljs")f[key] = [];//下面的定额和工料机不用保存
  690. }
  691. user_freight.freight = f;
  692. projectObj.project.projectGLJ.updateUserFreight({freights:[user_freight],action:"add"});
  693. }
  694. },
  695. updateUserFreight:function (record,userFreight) {
  696. let t = {};
  697. for(let t_key in userFreight){
  698. if(t_key == "ID") continue;
  699. t[t_key] = userFreight[t_key];
  700. }
  701. t.rootProjectID = projectObj.project.projectInfo.property.rootProjectID;
  702. let f = {};
  703. for(let key in record){
  704. f[key] = record[key];
  705. if(key =="ration" || key == "ration_gljs")f[key] = [];//下面的定额和工料机不用保存
  706. }
  707. t.freight = f;
  708. projectObj.project.projectGLJ.updateUserFreight({ID:userFreight.ID,doc:t,action:"update"});
  709. },
  710. getSideResize: function () {
  711. let rg_sideResizeEles = {};
  712. rg_sideResizeEles.eleObj = {
  713. module: this.moduleName,
  714. resize: $('#mrResize'),
  715. parent: $('#projectGljBottom'),
  716. left: $('#materialCalcSheet'),
  717. right: $('#calcDiv')
  718. };
  719. rg_sideResizeEles.limit = {
  720. min: 100,
  721. max: `$('#projectGljBottom').width()-100`
  722. };
  723. return rg_sideResizeEles;
  724. },
  725. initRightClick:function (id,spread) {
  726. let me = this;
  727. $.contextMenu({
  728. selector: '#'+id,
  729. build: function ($trigger, e) {
  730. me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, spread);
  731. return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
  732. me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  733. },
  734. items: {
  735. "insertFreight":{
  736. name: "内蒙古计算",
  737. icon: 'fa-sign-in',
  738. visible:function () {
  739. return id == "freightSheet";
  740. },
  741. disabled: function (){
  742. let material = me.getMaterialSelected();
  743. return !material;
  744. },
  745. callback:function () {
  746. $("#insertNeimengDiv").modal("show");
  747. }
  748. },
  749. "saveFreight":{
  750. name: "保存运输起讫地点",
  751. icon: 'fa-sign-in',
  752. visible:function () {
  753. return id == "freightSheet";
  754. },
  755. disabled: function (){
  756. if(id == "freightSheet") return me.rightClickTarget.row >= me.freightDatas.length;
  757. return me.rightClickTarget.row === undefined;
  758. },
  759. callback:function () {
  760. let row = me.rightClickTarget.row;
  761. me.saveFreight(row);
  762. }
  763. },
  764. "delete": {
  765. name: "删除",
  766. icon: 'fa-trash-o',
  767. disabled: function () {
  768. if(id == "priceSheet") return me.rightClickTarget.row >= me.priceDatas.length;
  769. if(id == "freightSheet") return me.rightClickTarget.row >= me.freightDatas.length;
  770. if(id == "freight_ration_sheet") return me.rightClickTarget.row >= me.freightRations.length;
  771. if(id == "price_ration_sheet") return me.rightClickTarget.row >= me.priceRations.length;
  772. return me.rightClickTarget.row === undefined;
  773. },
  774. callback: function (key, opt) {
  775. let row = me.rightClickTarget.row;
  776. if (id == "materialCalcSheet") me.deleteMaterialCal(row);
  777. if (id == "priceSheet") me.deletePriceCalc(row);
  778. if (id == "freightSheet") me.deleteFreightCalc(row);
  779. if (id == "freight_ration_sheet") me.deleteRation(row,"freight");
  780. if (id == "price_ration_sheet") me.deleteRation(row,"price");
  781. }
  782. }
  783. }
  784. });
  785. },
  786. initTabWidth:function () {
  787. if($("#mix_ratio_sheet").is(':visible')) return ;//如果是组成物计算界面,返回
  788. let mr_sideResizeEles = this.getSideResize();
  789. SlideResize.loadHorizonWidth(mr_sideResizeEles.eleObj.module,
  790. [mr_sideResizeEles.eleObj.resize], [mr_sideResizeEles.eleObj.left, mr_sideResizeEles.eleObj.right],null,2);
  791. $("#spreadTabDiv").width( $('#calcDiv').width() - mr_sideResizeEles.eleObj.resize.width() - 32)
  792. },
  793. refreshRationView:function () {
  794. let freight = this.getSelectedFreight();
  795. let hide = true;
  796. let stats = $("#freight_ration").is(':visible');
  797. if(freight && freight.conveyance == "自办运输"){
  798. this.showFreightRationDatas(freight);
  799. $("#freightSheet").css("height","50%");
  800. $("#freight_ration").show();
  801. hide = false;
  802. }
  803. if(hide){
  804. $("#freightSheet").css("height","100%");
  805. $("#freight_ration").hide();
  806. }
  807. if(stats != $("#freight_ration").is(':visible')){//状态改变了才刷新
  808. this.freightSpread.refresh();
  809. this.freightRationSpread.refresh();
  810. }
  811. },
  812. refreshAssView:function () {
  813. let me = materialCalcObj;
  814. let sheet = $('#freightSheet').is(':visible')?me.freightRationSheet:me.priceRationSheet;
  815. let preString = $('#freightSheet').is(':visible')?"freight":"price";
  816. let show = false;
  817. let ass = null;
  818. let ration = me.getSelectedRation();
  819. let stats = $(`#${preString}_ration_ass`).is(':visible');
  820. if(ration && ration.rationAssList){
  821. for(let r of ration.rationAssList){
  822. if(r.name == "运距m"){//辅助定额只处理运距的情况,其它的都忽略
  823. show = true;
  824. ass = r;
  825. }
  826. }
  827. }
  828. if(show){
  829. $(`#${preString}_ration_sheet`).addClass("material-ration-left");
  830. $(`#${preString}_ration_ass`).addClass("material-ass");
  831. $(`#${preString}_ass_value`).val(ass.actualValue);
  832. $(`#${preString}_ration_ass`).show();
  833. }else {
  834. $(`#${preString}_ration_sheet`).removeClass("material-ration-left");
  835. $(`#${preString}_ration_ass`).removeClass("material-ass");
  836. $(`#${preString}_ration_ass`).hide();
  837. }
  838. if(stats != $(`#${preString}_ration_ass`).is(':visible')) sheet.parent.refresh();//状态改变了才刷新
  839. },
  840. updateMaterialRationAss:function (value,ele) {//to do 同步修改定额工料机的消耗量
  841. let parent = this.getSelectedRationParent(),ration = this.getSelectedRation();
  842. let replaceList = [];
  843. if(value && !number_util.isNum(value)){
  844. alert("输入的数据类型不对,请重新输入!");
  845. let a = _.find(ration.rationAssList,{'name':"运距m"});
  846. if(a)ele.val(a.actualValue);
  847. }
  848. for(let ass of ration.rationAssList){
  849. if(ass.name == "运距m"){
  850. ass.actualValue = value?scMathUtil.roundForObj(value,2):ass.stdValue;
  851. }
  852. replaceList.push(value);
  853. }
  854. let name = ration.caption;
  855. for(let re of replaceList){
  856. name = name.replace('%s',re);
  857. }
  858. let type = $('#freightSheet').is(':visible')?"freight":"price";
  859. //let ration_glj =
  860. let datas = {parentID:parent.ID,rationID:ration.ID,type:type,actionType:"update",field:"name",value:name,ext:{rationAssList:ration.rationAssList}};
  861. let ration_gljs = projectObj.project.projectGLJ.calcMaterialAssQuantity(parent,ration,ration.rationAssList);
  862. if(ration_gljs.length > 0) datas.ration_gljs = ration_gljs;
  863. projectObj.project.projectGLJ.updateMaterialRation(datas);
  864. },
  865. getSelectedRation:function () {
  866. if($('#freightSheet').is(':visible')){
  867. return this.getSelectedRecode(this.freightRationSheet,this.freightRations);
  868. }else {
  869. return this.getSelectedRecode(this.priceRationSheet,this.priceRations);
  870. }
  871. },
  872. getSelectedRationParent:function () {
  873. if($('#freightSheet').is(':visible')){
  874. return this.getSelectedFreight();
  875. }else {
  876. return this.getSelectedRecode(this.priceSheet,this.priceDatas);
  877. }
  878. },
  879. getSelectedFreight:function(){
  880. return this.getSelectedRecode(this.freightSheet,this.freightDatas);
  881. },
  882. getSelectedPrice:function () {
  883. return this.getSelectedRecode(this.priceSheet,this.priceDatas)
  884. },
  885. getSelectedRecode:function (sheet,datas) {
  886. let sel = sheet.getSelections()[0];
  887. let srow = sel.row == -1||sel.row == ""?0:sel.row;
  888. if(gljUtil.isDef(srow) && datas.length>srow){
  889. return datas[srow];
  890. }
  891. return null;
  892. }
  893. };
  894. $(function () {
  895. $("#calc-nav").on('shown.bs.tab', function () {
  896. materialCalcObj.initTabWidth();
  897. projectGljObject.refreshSubViews();
  898. });
  899. $("#calTab ul li a").on('shown.bs.tab', function () {
  900. materialCalcObj.showFreightDatas();
  901. materialCalcObj.showPriceDatas();
  902. projectGljObject.refreshSubViews();
  903. });
  904. $(".ration_ass_value").change(function () {
  905. let me = materialCalcObj;
  906. me.updateMaterialRationAss($(this).val(),$(this));
  907. });
  908. $('#calcCoeDiv').on('show.bs.modal', function () {
  909. $("#assistProductionFeeRate").val(scMathUtil.roundForObj(projectObj.project.projectGLJ.datas.constData.assistProductionFeeRate,getDecimal("feeRate")));
  910. })
  911. $("#calcCoeConfirm").click(function () {
  912. let feeRate = $("#assistProductionFeeRate").val();
  913. if(!number_util.isNum(feeRate)){
  914. alert("输入的数据类型不对,请重新输入!");
  915. return $("#assistProductionFeeRate").val(scMathUtil.roundForObj(projectObj.project.projectGLJ.datas.constData.assistProductionFeeRate,getDecimal("feeRate")));
  916. }
  917. feeRate = scMathUtil.roundForObj(feeRate,getDecimal("feeRate"));
  918. $("#calcCoeDiv").modal("hide");
  919. projectObj.project.projectGLJ.changeAssistProductionFeeRate(feeRate);
  920. });
  921. $("#insertFreightconfirm").click(function () {
  922. let me = materialCalcObj;
  923. let material = me.getMaterialSelected();
  924. let newData = me.getNewFreightData(material);
  925. let start = $("#freight_start").val();
  926. let kmDistance = $("#freight_kmDistance").val();
  927. let materialType = $("#freight_materialType").val();
  928. if(!number_util.isNum(kmDistance)){
  929. alert("运输距离数据类型不对,请重新输入!");
  930. return ;
  931. }
  932. kmDistance = scMathUtil.roundForObj(kmDistance,getDecimal("glj.unitPrice"))+'';
  933. newData.start = start;
  934. newData.kmDistance = kmDistance;
  935. newData.materialType = materialType;
  936. newData.calcType = "内蒙古";
  937. newData.unitFreight = me.calcNeiMengUnitFreight(kmDistance,materialType);
  938. $("#insertNeimengDiv").modal("hide");
  939. projectObj.project.projectGLJ.addFreightCalc([newData],material.id);
  940. })
  941. });
  942. let mr_sideResizeEles = materialCalcObj.getSideResize();
  943. SlideResize.horizontalSlide(mr_sideResizeEles.eleObj, mr_sideResizeEles.limit, function(){
  944. $("#spreadTabDiv").width( $('#calcDiv').width() - mr_sideResizeEles.eleObj.resize.width() - 32);
  945. projectGljObject.refreshSubViews();
  946. },2);