123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- 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) {
- "use strict";
- var PendingTaskTableLayoutView = Backbone.Marionette.LayoutView.extend({
- _viewName: "PendingTaskTableLayoutView",
- template: PendingTaskTableLayoutView_tmpl,
- regions: {
- RPendingTaskTableLayoutView: "#r_pendingTaskTableLayoutView"
- },
- ui: {
- refreshPendingTask: "[data-id='refreshPendingTask']"
- },
- events: function() {
- var events = {};
- return events["click " + this.ui.refreshPendingTask] = function(e) {
- this.fetchPendingTaskCollection();
- }, events;
- },
- initialize: function(options) {
- _.extend(this, _.pick(options, "guid", "entity", "entityName", "attributeDefs")),
- this.pendingTaskCollection = new VEntityList(), this.limit = 25, this.offset = 0,
- this.pendingTaskCollection.url = UrlLinks.pendingTaskApiUrl(), this.entityModel = new this.pendingTaskCollection.model(),
- this.pervOld = [], this.commonTableOptions = {
- collection: this.pendingTaskCollection,
- includeFilter: !1,
- includePagination: !1,
- includeAtlasPagination: !0,
- includeAtlasPageSize: !0,
- includeTableLoader: !0,
- includeAtlasTableSorting: !1,
- showDefaultTableSorted: !1,
- columnSorting: !1,
- includeFooterRecords: !1,
- gridOpts: {
- className: "table table-hover backgrid table-quickMenu",
- emptyText: "没有找到记录!"
- },
- isApiSorting: !1,
- atlasPaginationOpts: this.getPaginationOptions(),
- filterOpts: {},
- paginatorOpts: {}
- }, this.currPage = 1, this.fromSort = !1;
- },
- onRender: function() {
- this.fetchPendingTaskCollection();
- },
- fetchPendingTaskCollection: function() {
- this.commonTableOptions.atlasPaginationOpts = this.getPaginationOptions(), this.fetchCollection(),
- this.pendingTaskCollection.comparator = function(model) {
- return -model.get("createdBy");
- };
- },
- bindEvents: function() {},
- getPaginationOptions: function() {
- return {
- count: this.getPageCount(),
- offset: this.pendingTaskCollection.queryParams.offset || this.offset,
- fetchCollection: this.fetchCollection.bind(this)
- };
- },
- getPageCount: function() {
- return this.pendingTaskCollection.queryParams.limit || this.pendingTaskCollection.queryParams.count || this.limit;
- },
- fetchCollection: function(options) {
- var that = this;
- this.pendingTaskCollection.fetch({
- success: function(dataOrCollection, response) {
- that.pendingTaskCollection.state.pageSize = that.getPageCount(), that.pendingTaskCollection.fullCollection.reset(response);
- },
- complete: function() {
- that.$(".fontLoader").hide(), that.$(".tableOverlay").hide(), that.$(".auditTable").show(),
- that.renderTableLayoutView();
- },
- silent: !0
- });
- },
- renderTableLayoutView: function() {
- var that = this;
- require([ "utils/TableLayout" ], function(TableLayout) {
- var cols = new Backgrid.Columns(that.getAuditTableColumns());
- that.RPendingTaskTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
- columns: cols
- })));
- });
- },
- getAuditTableColumns: function() {
- return this.pendingTaskCollection.constructor.getTableCols({
- tool: {
- label: "",
- cell: "html",
- editable: !1,
- sortable: !1,
- fixWidth: "20",
- cell: Backgrid.ExpandableCell,
- accordion: !1,
- expand: function(el, model) {
- el.attr("colspan", "8");
- var parameters = (model.get("attemptCount"), _.omit(_.extend(model.get("parameters"), {
- attemptCount: model.get("attemptCount"),
- createdBy: model.get("createdBy")
- }), "entityGuid")), memoryTable = CommonViewFunction.propertyTable({
- scope: this,
- formatStringVal: !1,
- valueObject: parameters
- }), 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>";
- $(el).append($("<div>").html(tableData));
- }
- },
- type: {
- label: "类型",
- cell: "html",
- sortable: !1,
- editable: !1,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model) {
- return Enums.auditAction[model.get("type")] || rawValue;
- }
- })
- },
- guid: {
- label: "全局唯一标识符",
- cell: "html",
- sortable: !1,
- editable: !1
- },
- status: {
- label: "状态",
- cell: "html",
- sortable: !1,
- editable: !1
- },
- createdTime: {
- label: "创建时间",
- cell: "html",
- editable: !1,
- sortable: !1,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model) {
- return Utils.formatDate({
- date: rawValue
- });
- }
- })
- },
- updatedTime: {
- label: "更新时间",
- cell: "html",
- editable: !1,
- sortable: !1,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model) {
- return Utils.formatDate({
- date: rawValue
- });
- }
- })
- }
- }, this.pendingTaskCollection);
- }
- });
- return PendingTaskTableLayoutView;
- });
|