item_increase_fee_view.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * Created by zhang on 2020/1/17.
  3. */
  4. let itemBaseOptions = ["人工费","材料费","机械费","人工费+材料费","人工费+机械费","人工费+材料费","材料费+机械费","人工费+材料费+机械费"];
  5. let itemIncreaseFeeObj = {
  6. settingSpread:null,
  7. itemSetting:{
  8. header:[
  9. {headerName: "名称", headerWidth: 270, dataCode: "name", dataType: "String"},
  10. {headerName: "范围", headerWidth: 70, dataCode: "displayScope",hAlign: "center",dataType: "String"},
  11. {headerName: "取费基数", headerWidth: 150, dataCode: "base", hAlign: "center", dataType: "String",cellType:'comboBox',options:itemBaseOptions},
  12. {headerName: "系数(%)", headerWidth: 55, dataCode: "coe", hAlign: "center", dataType: "Number",validator:"number"}
  13. ],
  14. view: {
  15. lockColumns: ["code","specs"],
  16. rowHeaderWidth:25,
  17. colHeaderHeight:36
  18. },
  19. autoFit:true,
  20. fitRow:['name']
  21. },
  22. settingDatas:[],
  23. initSpread:function () {
  24. if(this.settingSpread) return this.settingSpread.refresh();
  25. this.settingSpread = SheetDataHelper.createNewSpread($("#itemIncreaseFee_sheet")[0]);
  26. sheetCommonObj.spreadDefaultStyle(this.settingSpread);
  27. this.settingSheet = this.settingSpread.getSheet(0);
  28. sheetCommonObj.initSheet(this.settingSheet, this.itemSetting, 4);
  29. this.settingSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onItemSelectionChange);
  30. this.settingSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onItemValueChange);
  31. /* ;
  32. this.settingSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onElectrovalenceEditStarting);*/
  33. /*
  34. ;*/
  35. this.settingSheet.name('itemIncreaseFee_sheet');
  36. if(projectReadOnly){
  37. disableSpread(this.settingSpread);
  38. }
  39. },
  40. onItemSelectionChange:function (sender,args) {
  41. args.sheet.repaint();
  42. },
  43. showDatas:function(datas){
  44. let sel = this.settingSheet.getSelections()[0];
  45. let oldData = sel.row<this.settingDatas.length?this.settingDatas[sel.row]:"";
  46. this.settingSheet.setRowCount(0);
  47. this.settingDatas = datas?datas:this.getItemSettingDatas();
  48. sheetCommonObj.showData(this.settingSheet, this.itemSetting,this.settingDatas);
  49. this.settingSheet.setRowCount(this.settingDatas.length);
  50. sel.row = oldData?_.findIndex(this.settingDatas,{'name':oldData.name}):sel.row ;
  51. this.settingSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
  52. },
  53. getItemSettingDatas:function () {
  54. let datas = [];
  55. if(projectObj.project.property.itemIncreaseSetting){
  56. for(let i of projectObj.project.property.itemIncreaseSetting){
  57. let d = {name:i.name,displayScope:"范围",scope:i.scope,base:i.base,coe:i.coe};
  58. if(_.isEmpty(d.scope)){
  59. d.foreColor = "#ff2a23";
  60. d.styleCol = 1;
  61. }
  62. datas.push(d);
  63. }
  64. }
  65. return datas;
  66. },
  67. onItemValueChange:function (sender,args) {
  68. let me = itemIncreaseFeeObj;
  69. let dataCode = me.itemSetting.header[args.col].dataCode;
  70. let value = args.newValue;
  71. let tem = me.settingDatas[args.row];
  72. if (value&&!sheetCommonObj.checkData(args.col,me.itemSetting,value)) {
  73. alert('输入的数据类型不对,请重新输入!');
  74. return me.showDatas(me.settingDatas);
  75. }
  76. if(dataCode == 'coe') {
  77. if (value) value = scMathUtil.roundForObj(value, 2);
  78. }
  79. tem[dataCode] = value;
  80. me.showDatas(me.settingDatas);
  81. }
  82. };
  83. $(function () {
  84. /* $("#areaIncreaseFeeConfirm").on("click",async function(e){
  85. areaIncreaseFeeObj.confirmAreaIncreaseFeeSetting();
  86. });*/
  87. $('#itemIncreaseFeeDiv').on('shown.bs.modal', function (e) {
  88. itemIncreaseFeeObj.initSpread();
  89. itemIncreaseFeeObj.showDatas();
  90. });
  91. });