installation.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /**
  2. * Created by Zhong on 2018/1/19.
  3. **/
  4. $(document).ready(function () {
  5. feeItemObj.buildSheet();
  6. });
  7. //费用项
  8. let feeItemObj = {
  9. rationRepId: null,
  10. workBook: null,
  11. sheet: null,
  12. cache: [],
  13. currentFeeItem: null,
  14. setting: {
  15. header:[
  16. {headerName:"费用项",headerWidth:120,dataCode:"feeItem", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
  17. {headerName:"费用类型",headerWidth:260,dataCode:"feeType", dataType: "String", hAlign: "center", vAlign: "center"},
  18. {headerName:"记取位置",headerWidth:260,dataCode:"position", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"}
  19. ],
  20. view: {lockColumns: []},
  21. options: {
  22. tabStripVisible: false,
  23. allowCopyPasteExcelStyle : false,
  24. allowExtendPasteRange: false,
  25. allowUserDragDrop : false,
  26. allowUserDragFill: false,
  27. scrollbarMaxAlign : true
  28. }
  29. },
  30. isDef: function (v) {
  31. return v !== undefined && v !== null;
  32. },
  33. //sheet things
  34. setOptions: function (workbook, opts) {
  35. for(let opt in opts){
  36. workbook.options[opt] = opts[opt];
  37. }
  38. },
  39. buildSheet: function () {
  40. let me = this, se = sectionObj, fr = feeRuleObj;
  41. if(!this.isDef(this.workBook)){
  42. this.workBook = sheetCommonObj.buildSheet($('#feeItemSpread')[0], this.setting, 10);
  43. this.sheet = this.workBook.getActiveSheet();
  44. this.setOptions(this.workBook, this.setting.options);
  45. this.bindEvents(this.sheet);
  46. this.rationRepId = parseInt(getQueryString("repository"));
  47. CommonAjax.post('/complementaryRation/api/getRationLibs', {ids: [this.rationRepId]}, function (rstData) {
  48. if(rstData.length > 0){
  49. let libName = rstData[0].dispName;
  50. if (libName) {
  51. let $rationName = $(`<div id='rationname' class='navbar-text'>${libName}</div>`);
  52. $('.header-logo').after($rationName);
  53. }
  54. //init sectionSpread
  55. se.buildSheet();
  56. //init feeRuleSpread
  57. fr.buildSheet();
  58. //init installation
  59. me.getInstallation(me.rationRepId, function (rstData) {
  60. me.cache = rstData;
  61. sheetCommonObj.showData(me.sheet, me.setting, me.cache);
  62. me.initSelection(me.cache[0]);
  63. });
  64. //init batchSectionSpread
  65. }
  66. });
  67. }
  68. },
  69. bindEvents: function (sheet) {
  70. let me = this;
  71. const Events = GC.Spread.Sheets.Events;
  72. sheet.bind(Events.SelectionChanged, me.onSelectionChanged);
  73. sheet.bind(Events.EditStarting, me.onEditStarting);
  74. sheet.bind(Events.ClipboardPasting, me.onClipboardPasting);
  75. me.feeItemDelOpr();
  76. },
  77. initSelection: function (feeItem) {
  78. let me = this, se = sectionObj, fr = feeRuleObj;
  79. sheetCommonObj.cleanSheet(se.sheet, se.setting, -1);
  80. sheetCommonObj.cleanSheet(fr.sheet, fr.setting, -1);
  81. me.workBook.focus(true);
  82. if(!me.isDef(feeItem)){
  83. me.currentFeeItem = null;
  84. return;
  85. }
  86. fr.addObj = null;
  87. fr.updateObj = null;
  88. me.currentFeeItem = feeItem;
  89. se.cache = feeItem.section;
  90. sheetCommonObj.showData(se.sheet, se.setting, se.cache);
  91. se.initSelection(se.cache[0]);
  92. },
  93. onSelectionChanged: function (sender, info) {
  94. let me = feeItemObj;
  95. if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
  96. let row = info.newSelections[0].row;
  97. let node = me.cache[row];
  98. me.initSelection(node);
  99. }
  100. },
  101. onEditStarting: function (sender, args) {
  102. args.cancel = true;
  103. },
  104. onClipboardPasting: function (sender, info) {
  105. info.cancel = true;
  106. },
  107. feeItemDelOpr: function () {
  108. let me = this;
  109. me.workBook.commandManager().register('feeItemDel', function () {
  110. });
  111. me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
  112. me.workBook.commandManager().setShortcutKey('feeItemDel', GC.Spread.Commands.Key.del, false, false, false, false);
  113. },
  114. getInstallation: function (rationRepId, callback) {
  115. let me = this;
  116. CommonAjax.post('/complementaryRation/api/getInstallation', {rationRepId: rationRepId}, function (rstData) {
  117. me.cache = rstData;
  118. if(callback){
  119. callback(rstData);
  120. }
  121. });
  122. }
  123. };
  124. //分册章节
  125. let sectionObj = {
  126. workBook: null,
  127. sheet: null,
  128. cache: [],
  129. currentSection: null,
  130. setting: {
  131. header:[
  132. {headerName:"分册章节",headerWidth:800,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"}
  133. ],
  134. view: {lockColumns: []},
  135. options: {
  136. tabStripVisible: false,
  137. allowCopyPasteExcelStyle : false,
  138. allowExtendPasteRange: false,
  139. allowUserDragDrop : false,
  140. allowUserDragFill: false,
  141. scrollbarMaxAlign : true
  142. }
  143. },
  144. isDef: function (v) {
  145. return v !== undefined && v !== null;
  146. },
  147. //sheet things
  148. setOptions: function (workbook, opts) {
  149. for(let opt in opts){
  150. workbook.options[opt] = opts[opt];
  151. }
  152. },
  153. buildSheet: function () {
  154. if(!this.isDef(this.workBook)){
  155. this.workBook = sheetCommonObj.buildSheet($('#instSectionSpread')[0], this.setting, 10);
  156. this.sheet = this.workBook.getActiveSheet();
  157. this.setOptions(this.workBook, this.setting.options);
  158. this.sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
  159. this.bindEvents(this.sheet);
  160. }
  161. },
  162. bindEvents: function (sheet) {
  163. let me = sectionObj;
  164. const Events = GC.Spread.Sheets.Events;
  165. sheet.bind(Events.SelectionChanged, me.onSelectionChanged);
  166. sheet.bind(Events.EditStarting, me.onEditStarting);
  167. sheet.bind(Events.ClipboardPasting, me.onClipboardPasting);
  168. me.sectionDelOpr();
  169. },
  170. initSelection: function (section) {
  171. let me = sectionObj, fr = feeRuleObj;
  172. sheetCommonObj.cleanSheet(fr.sheet, fr.setting, -1);
  173. this.workBook.focus(true);
  174. if(!this.isDef(section)){
  175. me.currentSection = null;
  176. return;
  177. }
  178. me.currentSection = section;
  179. fr.addObj = null;
  180. fr.updateObj = null;
  181. fr.cache = section.feeRule;
  182. sheetCommonObj.showData(fr.sheet, fr.setting, fr.cache);
  183. },
  184. onSelectionChanged: function (sender, info) {
  185. let me = sectionObj;
  186. if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
  187. let row = info.newSelections[0].row;
  188. let section = me.cache[row];
  189. me.initSelection(section);
  190. }
  191. },
  192. onEditStarting: function (sender, args) {
  193. args.cancel = true;
  194. },
  195. onClipboardPasting: function (sender, info) {
  196. info.cancel = true;
  197. },
  198. sectionDelOpr: function () {
  199. let me = this;
  200. me.workBook.commandManager().register('sectionDel', function () {
  201. });
  202. me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
  203. me.workBook.commandManager().setShortcutKey('sectionDel', GC.Spread.Commands.Key.del, false, false, false, false);
  204. }
  205. };
  206. //费用规则
  207. let feeRuleObj = {
  208. workBook: null,
  209. sheet: null,
  210. addObj: null,
  211. updateObj: null,
  212. cache: [],
  213. setting: {
  214. header:[
  215. {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
  216. {headerName:"费用规则",headerWidth:240,dataCode:"rule", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
  217. {headerName:"基数",headerWidth:120,dataCode:"base", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
  218. {headerName:"费率(%)",headerWidth:120,dataCode:"feeRate", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center"},
  219. {headerName:"其中人工(%)",headerWidth:120,dataCode:"labour", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center"},
  220. {headerName:"其中材料(%)",headerWidth:120,dataCode:"material", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center"},
  221. {headerName:"其中机械(%)",headerWidth:120,dataCode:"machine", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center"}
  222. ],
  223. view: {lockColumns: []},
  224. options: {
  225. tabStripVisible: false,
  226. allowCopyPasteExcelStyle : false,
  227. allowExtendPasteRange: false,
  228. allowUserDragDrop : false,
  229. allowUserDragFill: false,
  230. scrollbarMaxAlign : true
  231. }
  232. },
  233. isDef: function (v) {
  234. return v !== undefined && v !== null;
  235. },
  236. //sheet things
  237. setOptions: function (workbook, opts) {
  238. for(let opt in opts){
  239. workbook.options[opt] = opts[opt];
  240. }
  241. },
  242. buildSheet: function () {
  243. if(!this.isDef(this.workBook)){
  244. this.workBook = sheetCommonObj.buildSheet($('#instFeeRuleSpread')[0], this.setting, 10);
  245. console.log(`this.workBook`);
  246. console.log(this.workBook);
  247. this.sheet = this.workBook.getActiveSheet();
  248. this.setOptions(this.workBook, this.setting.options);
  249. this.bindEvents(this.sheet);
  250. }
  251. },
  252. bindEvents: function (sheet) {
  253. let me = feeRuleObj;
  254. const Events = GC.Spread.Sheets.Events;
  255. sheet.bind(Events.EditStarting, me.onEditStarting);
  256. sheet.bind(Events.ClipboardPasting, me.onClipboardPasting);
  257. me.feeRuleDelOpr();
  258. },
  259. onEditStarting: function (sender, args) {
  260. args.cancel = true;
  261. },
  262. onClipboardPasting: function (sender, info) {
  263. info.cancel = true;
  264. },
  265. feeRuleDelOpr: function () {
  266. let me = feeRuleObj, se = sectionObj;
  267. me.workBook.commandManager().register('feeRuleDel', function () {
  268. });
  269. me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
  270. me.workBook.commandManager().setShortcutKey('feeRuleDel', GC.Spread.Commands.Key.del, false, false, false, false);
  271. }
  272. };