installation.js 11 KB

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