installation.js 12 KB

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