zmhs_view.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /**
  2. * Created by zhang on 2018/5/30.
  3. */
  4. let zmhs_obj = {
  5. module: 'subZmhs',
  6. coeSpread:null,
  7. coeSheet:null,
  8. coeSheetData:[],
  9. coeSetting: {
  10. header: [
  11. {headerName: "调整", headerWidth: 35, dataCode: "isAdjust", dataType: "String", cellType: "checkBox"},
  12. {headerName: "条件", headerWidth: 180, dataCode: "name", dataType: "String", cellType: "button",getText:'forName'},
  13. {headerName: "内容", headerWidth: 70, dataCode: "content", dataType: "String", hAlign: "left",getText:'forContent',cellType:'tipsCell'}
  14. ],
  15. view: {
  16. lockColumns:[0,1,2],
  17. rowHeaderWidth:25
  18. },
  19. getText:{
  20. forContent:function (item) {//所选人材机,内容和条件互换位置
  21. if(gljUtil.isDef(item.option_codes)&&item.option_codes!=""){
  22. return item.name;
  23. }else if(item.assistCode &&item.assistCode!="" ){//是辅助定额行,显示实际值
  24. return item.actualValue;
  25. } else {
  26. return item.content;
  27. }
  28. },
  29. forName:function (item) {
  30. if(gljUtil.isDef(item.select_code)&&item.select_code!=""){
  31. let option = _.find(item.option_list,{"value":item.select_code})
  32. return option?option.text:item.select_code;
  33. }else {
  34. return item.name;
  35. }
  36. }
  37. },
  38. emptyRowHeader: true,
  39. autoFit:true,
  40. fitRow:['name']
  41. },
  42. cusSpread:null,
  43. cusSheet:null,
  44. cusSheetData:null,
  45. cusSetting:{
  46. header: [
  47. {headerName: "类型", headerWidth: 100, dataCode: "coeType", dataType: "String",hAlign: "left"},
  48. {headerName: "系数", headerWidth: 80, dataCode: "amount", dataType: "String", hAlign: "right",validator:"number"}
  49. ],
  50. view: {
  51. lockColumns:["coeType"],
  52. rowHeaderWidth:25
  53. },
  54. emptyRowHeader: true
  55. },
  56. assSpread:null,
  57. assSheet:null,
  58. assSheetData: [],
  59. assFirstIndex:0,
  60. assSetting: {
  61. header: [
  62. {headerName: "调整名称", headerWidth: 100, dataCode: "name", dataType: "String"},
  63. {headerName: "定额值", headerWidth: 80, dataCode: "stdValue", hAlign: "right", dataType: "String"},
  64. {headerName: "实际值", headerWidth: 80, dataCode: "actualValue", hAlign: "right", dataType: "String"}
  65. ],
  66. view: {
  67. lockColumns: [0, 1],
  68. rowHeaderWidth:25
  69. },
  70. emptyRowHeader: true
  71. },
  72. initSpread:function () {
  73. this.initCoeSpread();
  74. this.initAssSpread();
  75. },
  76. initCoeSpread:function () {
  77. if(zmhs_obj.coeSpread == null){
  78. this.coeSpread = SheetDataHelper.createNewSpread($("#coeSpread")[0]);
  79. sheetCommonObj.spreadDefaultStyle(this.coeSpread);
  80. this.coeSheet = this.coeSpread.getSheet(0);
  81. sheetCommonObj.initSheet(this.coeSheet, this.coeSetting, 30);
  82. this.coeSheet.name('ration_coe');
  83. //this.coeSheet.bind(GC.Spread.Sheets.Events.CellClick, this.onCoeCellClick); 配合自定义系数使用,现在自定义系数不在这显示了
  84. this.coeSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onButtonClick);
  85. this.coeSheet.bind(GC.Spread.Sheets.Events.ValueChanged,this.onCoeValueChange);
  86. this.coeSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onCoeRangeChanged);
  87. this.coeSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, function (e,args) {
  88. args.sheet.repaint();
  89. });
  90. SheetDataHelper.protectdSheet(this.coeSheet);
  91. }
  92. },
  93. initCusSpread:function () {
  94. if(zmhs_obj.cusSpread == null){
  95. this.cusSpread = SheetDataHelper.createNewSpread($("#cusSpread")[0]);
  96. sheetCommonObj.spreadDefaultStyle(this.cusSpread);
  97. this.cusSheet = this.cusSpread.getSheet(0);
  98. sheetCommonObj.initSheet(this.cusSheet, this.cusSetting, 30);
  99. this.cusSheet.name('ration_cus');
  100. this.cusSheet.bind(GC.Spread.Sheets.Events.ValueChanged,this.onCusValueChange);
  101. this.cusSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onCusRangeChanged);
  102. SheetDataHelper.protectdSheet(this.cusSheet);
  103. }
  104. },
  105. initAssSpread:function () {
  106. if(zmhs_obj.assSheet == null){
  107. this.assSpread = SheetDataHelper.createNewSpread($("#assSpread")[0]);
  108. sheetCommonObj.spreadDefaultStyle(this.assSpread);
  109. this.assSheet = this.assSpread.getSheet(0);
  110. sheetCommonObj.initSheet(this.assSheet, this.assSetting, 30);
  111. this.assSheet.bind(GC.Spread.Sheets.Events.EditEnded, this.onAssEditEnded);
  112. this.assSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onAssRangeChanged);
  113. this.assSheet.name('ration_ass');
  114. SheetDataHelper.protectdSheet(this.assSheet);
  115. }
  116. },
  117. showCoeData:function (node) {
  118. let preSelections = this.coeSheet.getSelections();
  119. let selected = node?node:projectObj.project.mainTree.selected;
  120. let ration_coe = projectObj.project.ration_coe;
  121. let coeList = [];
  122. if(selected&&selected.sourceType == "ration"){
  123. let ration = selected.data;
  124. coeList = ration_coe.getCoeByRationID(ration.ID);
  125. _.remove(coeList,{"coeID":-1})//2018-12-24 新需求,把自定义乘系数分离出来,这里排除自定义乘系数行
  126. this.assFirstIndex = coeList.length;//辅助定额的起始下标
  127. coeList = coeList.concat(this.getAssList(node)) //2019-01-23 新需求,将辅助定额合并到一个表显示
  128. }
  129. this.coeSheet.setRowCount(0);
  130. sheetCommonObj.showData(this.coeSheet, this.coeSetting,coeList);
  131. if (coeList.length > 0) {
  132. this.coeSheet.suspendPaint();
  133. this.coeSheet.suspendEvent();
  134. for(let i =0;i<coeList.length;i++ ){
  135. if(gljUtil.isDef(coeList[i].option_codes)&&coeList[i].option_codes!=""){
  136. this.getComboBoxForCodes(coeList[i],i);//设置可选类型的下拉框
  137. // sheet.setValue(row, col, val, ch);
  138. } else if(coeList[i].assistCode && coeList[i].assistCode !=''){//是辅助定额列
  139. this.coeSheet.getCell(i, 2, GC.Spread.Sheets.SheetArea.viewport).locked(false);
  140. } else if(coeList[i].coeID == -1){ //自定义系数列
  141. this.coeSheet.getCell(i, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
  142. this.coeSheet.setCellType(i, 1, sheetCommonObj.getCustomerCoeCellType(this.generateHtmlString,this.bindCusEditorValue,this.updateCusCoeAfterEditor), GC.Spread.Sheets.SheetArea.viewport);
  143. }
  144. }
  145. this.coeSheet.resumeEvent();
  146. this.coeSheet.resumePaint();
  147. }
  148. this.coeSheetData = coeList;
  149. if(projectReadOnly){
  150. disableSpread(zmhs_obj.coeSpread);
  151. }
  152. if(preSelections){//定位光标到之前的位置
  153. this.coeSheet.setSelection(preSelections[0].row,preSelections[0].col,preSelections[0].rowCount,preSelections[0].colCount);
  154. }
  155. },
  156. showCusData:function (node) {
  157. let selected = node?node:projectObj.project.mainTree.selected;
  158. let ration_coe = projectObj.project.ration_coe;
  159. let cusList = [];
  160. if(selected&&selected.sourceType == "ration"){
  161. let ration = selected.data;
  162. let coeList = ration_coe.getCoeByRationID(ration.ID);
  163. this.cusSheetData = _.find(coeList,{"coeID":-1});
  164. if(this.cusSheetData) cusList = this.cusSheetData.coes;
  165. }
  166. sheetCommonObj.showData(this.cusSheet, this.cusSetting,cusList);
  167. this.cusSheet.getRange(cusList.length,-1,this.cusSheet.getRowCount()-cusList.length, -1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  168. if(projectReadOnly){
  169. disableSpread(zmhs_obj.cusSpread);
  170. }
  171. },
  172. getComboBoxForCodes:function (coe,i) {
  173. this.coeSheet.getCell(i, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
  174. let options = coe.option_list; //coe.option_codes.split("|");
  175. let combo = sheetCommonObj.getDynamicCombo(true);
  176. let buttonRow = this.coeSheet.getViewportBottomRow(1);
  177. combo.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
  178. combo.items(options).maxDropDownItems(buttonRow - i -1 < 3 ?3:buttonRow - i -1 );//itemHeight(options.length).
  179. this.coeSheet.setCellType(i, 1, combo, GC.Spread.Sheets.SheetArea.viewport);
  180. this.coeSheet.setValue(i, 1, coe.select_code);
  181. },
  182. showAssData:function (node) {
  183. this.assSheet.suspendPaint();
  184. this.assSheet.suspendEvent();
  185. let selected = node?node:projectObj.project.mainTree.selected;
  186. let assList = selected&&selected.data.rationAssList ? selected.data.rationAssList : [];
  187. this.assSheet.setRowCount(0);
  188. sheetCommonObj.showData(this.assSheet, this.assSetting, assList);
  189. this.assSheetData = assList;
  190. this.assSheet.getRange(assList.length,-1,this.assSheet.getRowCount()-assList.length, -1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  191. this.assSheet.resumePaint();
  192. this.assSheet.resumeEvent();
  193. if(projectReadOnly){
  194. disableSpread(this.assSpread);
  195. }
  196. },
  197. getAssList:function (node) {
  198. let selected = node?node:projectObj.project.mainTree.selected;
  199. let assList = selected&&selected.data.rationAssList ? selected.data.rationAssList : [];
  200. this.assSheetData = assList;
  201. return assList;
  202. },
  203. refreshAfterUpdate:function(result,reload){
  204. let ration_glj = projectObj.project.ration_glj;
  205. let calcInstall = false;//是否记录安装增加费
  206. let nodes = projectObj.project.updateNodesCache([{type:ModuleNames.ration,data:result.ration}]);
  207. if(result.add && result.add.length > 0){//需添加定额工料机的情况
  208. ration_glj.datas = ration_glj.datas.concat(result.add);
  209. gljOprObj.sheetData = gljOprObj.sheetData.concat(result.add);
  210. }
  211. if(result.delete && result.delete.length > 0 && this.deleteGLJs(result.delete)) calcInstall = true; //这样保证delete返回值是true的时候才改变变量类型
  212. if(result.replace && result.replace.length > 0){ //替换工料机的情况
  213. for(let r of result.replace){//替换缓存内容
  214. ration_glj.datas.splice(_.findIndex(ration_glj.datas,{'ID': r.ID}),1,r);
  215. gljOprObj.sheetData.splice(_.findIndex(gljOprObj.sheetData,{'ID': r.ID}),1,r);
  216. let node = ration_glj.updateGLJNodeAfterReplace(r);
  217. if(node) nodes.push(node);
  218. }
  219. }
  220. projectObj.mainController.refreshTreeNode(nodes, false);
  221. let rationID= ration_glj.updateCacheAfterAdjust(result.ration_glj);
  222. if(reload == true){//有添加、替换、工料机等需重新加载的情况
  223. $.bootstrapLoading.start();
  224. projectObj.project.projectGLJ.loadData(function () {
  225. $.bootstrapLoading.end();
  226. if(result.add && result.add.length > 0) ration_glj.addToMainTree(result.add);//这个方法有再去项目工料机那里取价格,所以要在回调里调用,不像替换工料的情况
  227. ration_glj.reCalcWhenGLJChange({rationID:rationID});
  228. if(result.delete && result.delete.length > 0 && calcInstall) installationFeeObj.calcInstallationFee();//如果是删除节点的话,
  229. });
  230. }else {
  231. ration_glj.reCalcWhenGLJChange({rationID:rationID});
  232. }
  233. gljOprObj.showRationGLJSheetData(true);
  234. },
  235. deleteGLJs:function (IDs) {
  236. let ration_glj = projectObj.project.ration_glj;
  237. let glj_list = ration_glj.datas;
  238. let calcInstall = false;
  239. let oldData = _.remove(glj_list, function (o) {
  240. return _.includes(IDs,o.ID);
  241. });
  242. _.remove(gljOprObj.sheetData, function (o) {
  243. return _.includes(IDs,o.ID);
  244. });
  245. for (let o of oldData) {
  246. if (ration_glj.needShowToTree(o)) {
  247. let node = ration_glj.findGLJNodeByID(o.ID); //找到对应的树节点
  248. projectObj.mainController.deleteNode(node, null);
  249. calcInstall = true;
  250. }
  251. }
  252. return calcInstall;
  253. },
  254. refresh:function () {
  255. $('#coeSpread').is(':visible')&&this.coeSpread?this.coeSpread.refresh():'';
  256. $('#coeSpread').is(':visible')&&this.coeSpread?this.showDatas():'';//这里combobox下拉框要重新加载一下
  257. $('#cusSpread').is(':visible')&&this.cusSpread?this.cusSpread.refresh():'';
  258. $('#assSpread').is(':visible')&&this.assSpread?this.assSpread.refresh():'';
  259. },
  260. showDatas:function () {
  261. if($('#itemCharacterText').is(':visible'))MaterialController.showItemCharacterText()
  262. if($('#coeSpread').is(':visible')) this.showCoeData();
  263. if($('#cusSpread').is(':visible')) this.showCusData();
  264. if($('#assSpread').is(':visible')) this.showAssData();
  265. },
  266. showZMHSData:function (node) {
  267. if(this.coeSpread&& this.assSpread && $('#linkZMHS').hasClass('active')){
  268. this.showCoeData(node);
  269. this.showAssData(node);
  270. }
  271. },
  272. onCoeCellClick: function (sender, args) {
  273. let me = zmhs_obj;
  274. let sheet = args.sheet, row = args.row, col = args.col;
  275. if(sheet.getCell(row, col).locked() !=true){
  276. if(!sheet.isEditing()) sheet.startEdit();
  277. }
  278. },
  279. onButtonClick:function (sender, args) {
  280. let me = zmhs_obj;
  281. let sheet = args.sheet, row = args.row, col = args.col;
  282. let cellType = sheet.getCellType(row, col);
  283. if (args.sheetName == 'ration_coe' && cellType instanceof GC.Spread.Sheets.CellTypes.CheckBox) {
  284. me.onCoeCheckBoxClick(sender, args)
  285. }
  286. },
  287. bindCusEditorValue:function(context){
  288. let me = zmhs_obj;
  289. if(me.coeSheetData[context.row]){
  290. let data = me.coeSheetData[context.row];
  291. for(let c of data.coes){
  292. $("#"+ c.coeType).val(c.amount);
  293. }
  294. /*$('#coe_ration').val(data.coes[0].amount);
  295. $('#manual').val(data.coes[1].amount);
  296. $('#material').val(data.coes[2].amount);
  297. $('#manchine').val(data.coes[3].amount);
  298. $('#mainM').val(data.coes[4].amount);
  299. $('#equipment').val(data.coes[5].amount);*/
  300. }
  301. },
  302. updateCusCoeAfterEditor:function(){
  303. let me = zmhs_obj;
  304. let result = me.checkIfNeedUpdate();
  305. if (result.isNeed) {
  306. projectObj.project.ration_coe.updateCustomerCoe(result);
  307. }
  308. },
  309. onInputChange(id, name){
  310. var coe = _.find(zmhs_obj.coeSheetData, function (c) {
  311. return c.coeID == -1;
  312. });
  313. if(coe){
  314. let newValue = zmhs_obj.numberValueChecking($('#' + id).val());
  315. if (newValue) {
  316. newValue = _.round(newValue, 2);
  317. if (newValue == coe.coes[name].amount) return;
  318. if (id == '定额') {
  319. for(let c of coe.coes){
  320. $('#'+c.coeType).val(newValue)
  321. }
  322. } else {
  323. $('#' + id).val(newValue);
  324. }
  325. } else {
  326. $('#' + id).val(coe.coes[name].amount);
  327. }
  328. }
  329. },
  330. onInputClick(ele){//点中系数单元格,则默认选中系数值
  331. setSelection(ele,0,$(ele).val().length)
  332. },
  333. checkIfNeedUpdate(){
  334. let data = _.find(zmhs_obj.coeSheetData, function (c) {
  335. return c.coeID == -1;
  336. });
  337. let result = {isNeed: false};
  338. if(data){
  339. for(let c of data.coes){
  340. let amount = $("#"+c.coeType).val();
  341. if(amount!=c.amount){
  342. result.isNeed = true;
  343. c.amount = amount;
  344. }
  345. }
  346. if (result.isNeed) {
  347. result.doc = {
  348. coes: data.coes
  349. };
  350. result.query = {
  351. projectID: data.projectID,
  352. ID: data.ID,
  353. rationID: data.rationID
  354. };
  355. }
  356. }
  357. return result;
  358. },
  359. numberValueChecking: function (val) {
  360. var newval = Number(val);
  361. if (number_util.isNumber(newval)) {
  362. return newval;
  363. } else {
  364. if (val) {
  365. alert('您输入的数据类型不正确,请重新输入。');
  366. }
  367. newval = null;
  368. }
  369. return newval;
  370. },
  371. onCoeCheckBoxClick:function (sender, args) {
  372. let me = zmhs_obj;
  373. let checkboxValue = args.sheet.getCell(args.row, args.col).value();
  374. let newval = 0;
  375. if (checkboxValue) {
  376. newval = 0;
  377. args.sheet.getCell(args.row, args.col).value(newval);
  378. } else {
  379. newval = 1;
  380. args.sheet.getCell(args.row, args.col).value(newval);
  381. }
  382. let recode = me.coeSheetData[args.row];
  383. recode.assistCode && recode.assistCode != "" ? me.adjustAssClick(args,newval) : projectObj.project.ration_coe.adjustCoeClick(recode, newval);
  384. },
  385. generateHtmlString: function (context,cellRect,$editor) {//这里要改成动态的了,根据自定义系数内容生成对应的输入框
  386. let me = zmhs_obj;
  387. let height = cellRect.height;
  388. let offect = 0;
  389. let newString = "<form style='margin-top:1px' ><table width='100%' cellpadding='0' border='1px' bordercolor='#CCCCCC' cellspacing='0px' style='border-collapse:collapse;'>";
  390. let cus_coe = me.coeSheetData[context.row];
  391. if(cus_coe){
  392. for(let i =0;i< cus_coe.coes.length;i++){
  393. newString += me.getOneRow(cus_coe.coes[i].coeType, i, cus_coe.coes[i].coeType,height);
  394. offect += height +3
  395. }
  396. }
  397. newString += "</table></form><div style='height:"+ height+"px'><div onclick='zmhs_obj.coeSheet.endEdit()' style='margin:-1px 1px 0px'>自定义系数</div></div>";
  398. $editor.html(newString);
  399. $editor.css("margin-top",-(offect+2));
  400. return newString;
  401. },
  402. getOneRow: function (text, name, id,inputHeight) {
  403. var rowstr = "<tr ><td style='width: 50%'>" + text
  404. + ":</td><td style='width: 50%' align='right'><input class='text-right' type='text' value='1' name=" + name
  405. + " style='width:100%;border:0;height:"+ inputHeight+"px;' align='right' id=" + id + " onchange='zmhs_obj.onInputChange(this.id,this.name)' onclick='zmhs_obj.onInputClick(this)' autocomplete='off'></td></tr>";
  406. return rowstr;
  407. },
  408. coeStartEdit(){
  409. if(zmhs_obj.coeSheet.isEditing()){
  410. return;
  411. }else {
  412. zmhs_obj.coeSheet.startEdit();
  413. }
  414. },
  415. onCoeRangeChanged:function(e,args){
  416. if(args.action == GC.Spread.Sheets.RangeChangedAction.clear){
  417. args.newValue = null;//目前只支持delete清除辅助定额
  418. zmhs_obj.onCoeValueChange(e,args);
  419. }
  420. },
  421. onCoeValueChange:function (e,args) {
  422. let fieldID = zmhs_obj.coeSetting.header[args.col].dataCode;
  423. let recode = zmhs_obj.coeSheetData[args.row];
  424. if(gljUtil.isDef(recode.option_codes)&&recode.option_codes!=""&& fieldID == 'name'){//说明是选择了下拉框
  425. projectObj.project.ration_coe.adjustCoeClick(recode, 1,{'select_code':args.newValue});
  426. }else if(recode.assistCode &&recode.assistCode!=""){//编辑的是辅助定额
  427. zmhs_obj.updateRationAss({editingText:args.newValue,row:args.row - zmhs_obj.assFirstIndex})//转换一下
  428. }
  429. },
  430. onCusValueChange:function (e,args) {
  431. zmhs_obj.changeCusValue([{row:args.row,col:args.col,value:args.newValue}]);
  432. },
  433. changeCusValue:function (datas) {//[{row:,col,value}]
  434. if(this.cusSheetData){
  435. let tem_coes = _.cloneDeep(this.cusSheetData.coes);
  436. for(let d of datas){
  437. if(d.value&&!sheetCommonObj.checkData(d.col,this.cusSetting,d.value)){
  438. this.showDatas();
  439. alert('输入的数据类型不对,请重新输入!');
  440. return;
  441. }
  442. if(gljUtil.isDef(d.value)&&d.value !=""){
  443. if(tem_coes[d.row].coeType=="定额"){
  444. for(let t of tem_coes){
  445. t.amount = d.value;
  446. }
  447. }else {
  448. tem_coes[d.row].amount = d.value;
  449. }
  450. }
  451. }
  452. let doc = {'coes':tem_coes,'content':this.generationContent(tem_coes)};
  453. projectObj.project.ration_coe.adjustCoeClick(this.cusSheetData, 1,doc);
  454. }
  455. },
  456. generationContent:function (coes) {
  457. let rationAmount = coes[0].amount;
  458. let string ='';
  459. if(_.every(coes,'amount',rationAmount)){
  460. string = coes[0].coeType + 'x'+rationAmount;
  461. }else {
  462. let context_arr =[];
  463. for(let i =1;i<coes.length;i++){
  464. context_arr.push( coes[i].coeType + 'x'+coes[i].amount);
  465. }
  466. string = context_arr.join(',');
  467. }
  468. return string;
  469. },
  470. onAssEditEnded:function (e,args) {
  471. var me = zmhs_obj;
  472. if (args.row >= me.assSheetData.length) {
  473. me.assSheet.getCell(args.row, args.col).value(null);
  474. return;
  475. }
  476. if (me.assSetting.header[args.col].dataCode == 'actualValue') {//实际值
  477. me.updateRationAss(args);
  478. }
  479. },
  480. onCusRangeChanged:function (e,args) {
  481. let datas = [];
  482. for(let c of args.changedCells){
  483. let value= args.sheet.getCell(c.row, c.col).text();
  484. datas.push({row:c.row,col:c.col,value:value})
  485. }
  486. zmhs_obj.changeCusValue(datas);
  487. },
  488. onAssRangeChanged:function (e,args) {
  489. let me = zmhs_obj;
  490. if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
  491. args.editingText = null;
  492. }else if(args.action == GC.Spread.Sheets.RangeChangedAction.paste){
  493. args.editingText = args.sheet.getCell(args.row,args.col).value();
  494. }
  495. if (args.sheetName == 'ration_ass') {
  496. me.updateRationAss(args);
  497. }
  498. },
  499. adjustAssClick:function (args,newval) {
  500. let me = zmhs_obj, row = args.row - me.assFirstIndex;
  501. projectObj.project.ration_ass.updateActualValue(me.assSheetData, row,null,newval);
  502. },
  503. updateRationAss: function (args) {
  504. var me = zmhs_obj;
  505. var newval;
  506. newval = me.numberValueChecking(args.editingText);
  507. var recode = me.assSheetData[args.row];
  508. if (args.editingText === null) {
  509. newval = parseFloat(recode.stdValue);
  510. }
  511. var isValidate = false;
  512. if (newval) {
  513. isValidate = me.checkingActualValue(recode, newval)
  514. }
  515. if (isValidate) {
  516. newval = scMathUtil.roundTo(newval, -2);
  517. projectObj.project.ration_ass.updateActualValue(me.assSheetData, args.row, newval);
  518. } else {
  519. me.showDatas();
  520. }
  521. },
  522. checkingActualValue(record, newval){
  523. let minExist = record.minValue && record.minValue != '0' ? true : false;
  524. let maxExist = record.maxValue && record.maxValue != '0' ? true : false;
  525. let minValue = parseFloat(record.minValue);
  526. let maxValue = parseFloat(record.maxValue);
  527. if (!maxExist && minExist) {
  528. if (newval < minValue) {
  529. alert('实际值应≥' + minValue);
  530. return false;
  531. }
  532. }
  533. if (maxExist && !minExist) {
  534. if (newval > maxValue) {
  535. alert('实际值应≤' + maxValue);
  536. return false;
  537. }
  538. }
  539. if (maxExist && minExist) {
  540. if (newval < minValue || newval > maxValue) {
  541. alert('实际值应介于' + minValue + '~' + maxValue + '之间');
  542. return false;
  543. }
  544. }
  545. return true;
  546. },
  547. getSideResize: function () {
  548. let zmhs_sideResizeEles = {};
  549. zmhs_sideResizeEles.eleObj = {
  550. module: zmhs_obj.module,
  551. resize: $('#zmhsResize'),
  552. parent: $('#tabZMHS'),
  553. left: $('#coeSpread'),
  554. right: $('#assDiv')
  555. };
  556. zmhs_sideResizeEles.limit = {
  557. min: 100,
  558. max: `$('#tabZMHS').width()-100`
  559. };
  560. return zmhs_sideResizeEles;
  561. },
  562. loadSideResize: function () {
  563. let resizeObj = this.getSideResize();
  564. SlideResize.loadHorizonWidth(resizeObj.eleObj.module, [resizeObj.eleObj.resize], [resizeObj.eleObj.left, resizeObj.eleObj.right]);
  565. }
  566. };