You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
5.0 KiB
145 lines
5.0 KiB
;!(function () { |
|
var EDITOR_WIDTH = 440, EDITOR_HEIGHT = 22, LABEL_WIDTH = 140; |
|
|
|
var info = BI.inherit(BI.Widget, { |
|
props: { |
|
add: true, |
|
}, |
|
_store: function () { |
|
return BI.Models.getModel("dec.hw.table.col.attr.model", { |
|
add: this.options.add |
|
}); |
|
}, |
|
watch: { |
|
count: function (v) { |
|
this.pager.setCount(v); |
|
}, |
|
pages: function (v) { |
|
this.pager.setAllPages(v); |
|
}, |
|
perItems: function () { |
|
this.table.populate(this._getFieldItems(), this._getFieldHeader(), {freezeScroll: true}); |
|
this.pager.setVPage(this.model.page); |
|
}, |
|
page:function () { |
|
this.pager.setVPage(this.model.page); |
|
}, |
|
excelItems:function () { |
|
this.popularExcelBox(this.model.excelItems); |
|
} |
|
}, |
|
render: function () { |
|
var self = this, o = this.options; |
|
return { |
|
type: "bi.vertical", |
|
items: [{ |
|
type: "bi.components.preview_table", |
|
items: this._getFieldItems(), |
|
header: this._getFieldHeader(), |
|
columnSize: [480, 150], |
|
height: 300, |
|
tgap: 10, |
|
ref: function (_ref) { |
|
self.table = _ref; |
|
} |
|
}, { |
|
type: "bi.all_count_pager", |
|
cls: "page-table-pager", |
|
count: this.model.count, |
|
curr: this.model.page, |
|
pages: this.model.pages, |
|
listeners: [{ |
|
eventName: BI.Pager.EVENT_CHANGE, |
|
action: function () { |
|
self.store.setPage(this.getCurrentPage()); |
|
} |
|
}], |
|
ref: function (_ref) { |
|
self.pager = _ref; |
|
}, |
|
}] |
|
}; |
|
}, |
|
|
|
_getFieldHeader: function () { |
|
return [ |
|
BI.map(BI.Constants.getConstant("bi.conf.pack.excel.field.header"), function (idx, item) { |
|
return { |
|
text: item.text, |
|
textAlign: "left", |
|
hgap: 5 |
|
}; |
|
}) |
|
]; |
|
}, |
|
|
|
_getFieldItems: function () { |
|
var self = this; |
|
console.log("fieldItems", this.model.perItems) |
|
return BI.map(this.model.perItems, function (idx, field) { |
|
var items = [{ |
|
type: "bi.label", |
|
text: field.colName, |
|
title: field.colName, |
|
textAlign: "left", |
|
hgap: 5 |
|
}, { |
|
type: "bi.icon_text_item", |
|
cls: BI.Utils.getFieldIconByFieldType(field.colType), |
|
text: BI.Utils.getTextByFieldType(field.colType) |
|
}]; |
|
return items; |
|
}); |
|
}, |
|
|
|
_formatItems: function (items) { |
|
console.log("_formatItems"); |
|
var allResult=[]; |
|
var self = this, o = this.options; |
|
self.colName = []; |
|
self.excelBox= []; |
|
self.primaryKeyBox = []; |
|
for (var index = 0; index < items.length; index++) { |
|
var item = items[index]; |
|
self.colName.push(item.colName); |
|
var result = []; |
|
var colName = { |
|
type: "bi.label", |
|
textAlign: "left", |
|
width: "100%", |
|
value: item.colName |
|
}; |
|
result.push(colName); |
|
var colType = { |
|
type: "bi.text_value_combo", |
|
disabled: !o.add, |
|
widgetType: "bi.text_value_combo", |
|
value: item.colType+"", |
|
items: BI.Constants.getConstant("dec.hw.col.type"), |
|
id: item.id, |
|
listeners: [ |
|
{ |
|
eventName: "EVENT_CHANGE", |
|
action: function () { |
|
self.store.updateItemColType(this.options.id,this.getValue()[0]); |
|
} |
|
} |
|
] |
|
}; |
|
result.push(colType); |
|
allResult.push(result); |
|
} |
|
return allResult; |
|
}, |
|
|
|
popularExcelBox:function (vals) { |
|
console.log("popularExcelBox"); |
|
var self = this; |
|
BI.each(self.excelBox, function (index, item) { |
|
item.populate(vals); |
|
item.setValue(self.model.perItems[index].excelCol); |
|
}) |
|
} |
|
}); |
|
BI.shortcut("dec.hw.table.col.attr", info); |
|
})(); |