PendingTaskTableLayoutView.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. define([ "require", "backbone", "hbs!tmpl/detail_page/PendingTaskTableLayoutView_tmpl", "collection/VEntityList", "utils/Utils", "utils/Enums", "utils/UrlLinks", "utils/CommonViewFunction" ], function(require, Backbone, PendingTaskTableLayoutView_tmpl, VEntityList, Utils, Enums, UrlLinks, CommonViewFunction) {
  2. "use strict";
  3. var PendingTaskTableLayoutView = Backbone.Marionette.LayoutView.extend({
  4. _viewName: "PendingTaskTableLayoutView",
  5. template: PendingTaskTableLayoutView_tmpl,
  6. regions: {
  7. RPendingTaskTableLayoutView: "#r_pendingTaskTableLayoutView"
  8. },
  9. ui: {
  10. refreshPendingTask: "[data-id='refreshPendingTask']"
  11. },
  12. events: function() {
  13. var events = {};
  14. return events["click " + this.ui.refreshPendingTask] = function(e) {
  15. this.fetchPendingTaskCollection();
  16. }, events;
  17. },
  18. initialize: function(options) {
  19. _.extend(this, _.pick(options, "guid", "entity", "entityName", "attributeDefs")),
  20. this.pendingTaskCollection = new VEntityList(), this.limit = 25, this.offset = 0,
  21. this.pendingTaskCollection.url = UrlLinks.pendingTaskApiUrl(), this.entityModel = new this.pendingTaskCollection.model(),
  22. this.pervOld = [], this.commonTableOptions = {
  23. collection: this.pendingTaskCollection,
  24. includeFilter: !1,
  25. includePagination: !1,
  26. includeAtlasPagination: !0,
  27. includeAtlasPageSize: !0,
  28. includeTableLoader: !0,
  29. includeAtlasTableSorting: !1,
  30. showDefaultTableSorted: !1,
  31. columnSorting: !1,
  32. includeFooterRecords: !1,
  33. gridOpts: {
  34. className: "table table-hover backgrid table-quickMenu",
  35. emptyText: "没有找到记录!"
  36. },
  37. isApiSorting: !1,
  38. atlasPaginationOpts: this.getPaginationOptions(),
  39. filterOpts: {},
  40. paginatorOpts: {}
  41. }, this.currPage = 1, this.fromSort = !1;
  42. },
  43. onRender: function() {
  44. this.fetchPendingTaskCollection();
  45. },
  46. fetchPendingTaskCollection: function() {
  47. this.commonTableOptions.atlasPaginationOpts = this.getPaginationOptions(), this.fetchCollection(),
  48. this.pendingTaskCollection.comparator = function(model) {
  49. return -model.get("createdBy");
  50. };
  51. },
  52. bindEvents: function() {},
  53. getPaginationOptions: function() {
  54. return {
  55. count: this.getPageCount(),
  56. offset: this.pendingTaskCollection.queryParams.offset || this.offset,
  57. fetchCollection: this.fetchCollection.bind(this)
  58. };
  59. },
  60. getPageCount: function() {
  61. return this.pendingTaskCollection.queryParams.limit || this.pendingTaskCollection.queryParams.count || this.limit;
  62. },
  63. fetchCollection: function(options) {
  64. var that = this;
  65. this.pendingTaskCollection.fetch({
  66. success: function(dataOrCollection, response) {
  67. that.pendingTaskCollection.state.pageSize = that.getPageCount(), that.pendingTaskCollection.fullCollection.reset(response);
  68. },
  69. complete: function() {
  70. that.$(".fontLoader").hide(), that.$(".tableOverlay").hide(), that.$(".auditTable").show(),
  71. that.renderTableLayoutView();
  72. },
  73. silent: !0
  74. });
  75. },
  76. renderTableLayoutView: function() {
  77. var that = this;
  78. require([ "utils/TableLayout" ], function(TableLayout) {
  79. var cols = new Backgrid.Columns(that.getAuditTableColumns());
  80. that.RPendingTaskTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
  81. columns: cols
  82. })));
  83. });
  84. },
  85. getAuditTableColumns: function() {
  86. return this.pendingTaskCollection.constructor.getTableCols({
  87. tool: {
  88. label: "",
  89. cell: "html",
  90. editable: !1,
  91. sortable: !1,
  92. fixWidth: "20",
  93. cell: Backgrid.ExpandableCell,
  94. accordion: !1,
  95. expand: function(el, model) {
  96. el.attr("colspan", "8");
  97. var parameters = (model.get("attemptCount"), _.omit(_.extend(model.get("parameters"), {
  98. attemptCount: model.get("attemptCount"),
  99. createdBy: model.get("createdBy")
  100. }), "entityGuid")), memoryTable = CommonViewFunction.propertyTable({
  101. scope: this,
  102. formatStringVal: !1,
  103. valueObject: parameters
  104. }), tableData = ' <div class="col-sm-12"> <div class="card-container panel panel-default custom-panel"><div class="panel-heading">Parameters</div> <div class="panel-body"><table class="table stat-table task-details"><tbody data-id="memory-card">' + memoryTable + "</tbody></table> </div> </div> </div>";
  105. $(el).append($("<div>").html(tableData));
  106. }
  107. },
  108. type: {
  109. label: "类型",
  110. cell: "html",
  111. sortable: !1,
  112. editable: !1,
  113. formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
  114. fromRaw: function(rawValue, model) {
  115. return Enums.auditAction[model.get("type")] || rawValue;
  116. }
  117. })
  118. },
  119. guid: {
  120. label: "全局唯一标识符",
  121. cell: "html",
  122. sortable: !1,
  123. editable: !1
  124. },
  125. status: {
  126. label: "状态",
  127. cell: "html",
  128. sortable: !1,
  129. editable: !1
  130. },
  131. createdTime: {
  132. label: "创建时间",
  133. cell: "html",
  134. editable: !1,
  135. sortable: !1,
  136. formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
  137. fromRaw: function(rawValue, model) {
  138. return Utils.formatDate({
  139. date: rawValue
  140. });
  141. }
  142. })
  143. },
  144. updatedTime: {
  145. label: "更新时间",
  146. cell: "html",
  147. editable: !1,
  148. sortable: !1,
  149. formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
  150. fromRaw: function(rawValue, model) {
  151. return Utils.formatDate({
  152. date: rawValue
  153. });
  154. }
  155. })
  156. }
  157. }, this.pendingTaskCollection);
  158. }
  159. });
  160. return PendingTaskTableLayoutView;
  161. });