installation.js 11 KB

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