installation.js 11 KB

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