forked from ezreal/BI-FR-MIX-FRONT
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.
203 lines
7.0 KiB
203 lines
7.0 KiB
/** |
|
* finereport的tab组件 |
|
*/ |
|
;!(function () { |
|
var widget = BI.inherit(BI.BasicButton, { |
|
props: { |
|
baseCls: 'bi-subject-tab-report-item', |
|
report: {}, |
|
height: 30, |
|
editable: true, |
|
showCombo: true, |
|
allowRename: true, |
|
reportType: "cpt", |
|
forceSelected: true, |
|
showChecker: function () { |
|
return false; |
|
}, |
|
showValueItems: [1, 7, 21, 22, 445] |
|
}, |
|
watch: { |
|
name: function (v) { |
|
this.textEditor.setValue(v); |
|
} |
|
}, |
|
_store: function () { |
|
return BI.Models.getModel("bi.subject.tab.extend.report.item.model", { |
|
id: this.options.id, |
|
name: this.options.name, |
|
reportType: this.options.reportType, |
|
report: this.options.report |
|
}); |
|
}, |
|
beforeInit: function (callback) { |
|
this.store.initData(callback); |
|
}, |
|
render: function () { |
|
var self = this, o = this.options; |
|
return { |
|
type: "bi.vertical_adapt", |
|
cls: "bi-hover-visible-container", |
|
columnSize: [16, "fill", ""], |
|
items: [ |
|
{ |
|
el: { |
|
type: "bi.icon_label", |
|
cls: o.iconCls, |
|
height: 16, |
|
iconHeight: 16, |
|
iconWidth: 16, |
|
}, |
|
lgap: 6 |
|
|
|
}, |
|
self._createShowTextWidget(), |
|
self._createToolCombo() |
|
] |
|
} |
|
|
|
}, |
|
_createShowTextWidget: function () { |
|
const {height, editable, allowRename, id, name} = this.options; |
|
var self = this; |
|
if (editable && allowRename) { |
|
return { |
|
type: "bi.shelter_editor", |
|
hgap: 2, |
|
// stopPropagation: true, |
|
height: 20, |
|
textAlign: "left", |
|
allowBlank: false, |
|
cls: "label-text", |
|
errorText: function (e) { |
|
return "" === e ? "报表名称不能为空" : "报表名称不能重复"; |
|
// return BI.i18nText("" === e ? "BI-Conf_Widget_Name_Cannot_Empty" : "BI-Conf_Widget_Name_Cannot_Repeat") |
|
}, |
|
validationChecker: function (v) { |
|
var id = (self.model.namesMap)[v]; |
|
if (!id) { |
|
return true; |
|
} |
|
return false; |
|
}, |
|
ref: function (_ref) { |
|
self.textEditor = _ref; |
|
}, |
|
value: name, |
|
listeners: [ |
|
{ |
|
eventName: "EVENT_CONFIRM", |
|
action: function () { |
|
const text = self.textEditor.getValue(); |
|
if (self.model.name !== text) { |
|
self.store.reNameReport(text); |
|
} |
|
} |
|
} |
|
] |
|
} |
|
} |
|
return { |
|
type: "bi.label", |
|
text: name, height: 20, |
|
_hgap: 4, |
|
textAlign: 'left', |
|
cls: "tab-item-text" |
|
} |
|
}, |
|
_createToolCombo: function () { |
|
const {editable, showChecker, showCombo, id} = this.options; |
|
var self = this; |
|
if (editable && showCombo) { |
|
return { |
|
el: { |
|
type: "bi.down_list_combo", |
|
stopPropagation: true, |
|
invisible: false, |
|
cls: "tab-item-hover-active bi-hover-visible-item", |
|
iconCls: "vertical-more-item-font", |
|
el: { |
|
type: "bi.icon_trigger" |
|
}, |
|
height: 24, |
|
width: 24, |
|
ref: function (_ref) { |
|
self.setting = _ref; |
|
}, |
|
listeners: [ |
|
{ |
|
eventName: "EVENT_BEFORE_POPUPVIEW", |
|
action: function () { |
|
self.setting.populate(self.createItems()); |
|
self.setting.adjustWidth(); |
|
self.setting.adjustHeight(); |
|
} |
|
}, |
|
{ |
|
eventName: "EVENT_CHANGE", |
|
action: BI.bind(self.operator, self) |
|
} |
|
|
|
] |
|
}, |
|
rgap: 6 |
|
} |
|
} |
|
return { |
|
el: { |
|
type: "bi.label", |
|
text: "" |
|
}, |
|
rgap: 8 |
|
} |
|
|
|
}, |
|
createItems: function () { |
|
var self = this; |
|
var items = BI.Providers.getProvider("bi.provider.conf.list.report.item").getItems(); |
|
const toolItems = []; |
|
var showValueItems = this.options.showValueItems; |
|
BI.each(items, function (i, groupItems) { |
|
const itemArr = []; |
|
BI.each(groupItems, function (index, groupItem) { |
|
if (showValueItems.indexOf(groupItem.value) >= 0) { |
|
|
|
itemArr.push(BI.extend(groupItem, { |
|
invisible: function () { |
|
return false; |
|
}, |
|
reportInfoGetter: function () { |
|
return { |
|
id: self.model.id, |
|
name: self.model.name |
|
} |
|
}, isOwn: true, |
|
refresh: function () { |
|
} |
|
})) |
|
} |
|
}) |
|
if (itemArr.length > 0) { |
|
toolItems.push(itemArr); |
|
} |
|
}) |
|
return toolItems; |
|
}, |
|
focus: function () { |
|
this.textEditor.focus() |
|
}, |
|
operator: function (v) { |
|
debugger; |
|
if (v == 7) { |
|
this.fireEvent("DELETE", this.options.id); |
|
} |
|
if (v == 1) { |
|
this.focus(); |
|
} |
|
}, |
|
mounted: function () { |
|
|
|
}, |
|
}); |
|
BI.shortcut("bi.subject.tab.extend.report.item", widget); |
|
})(); |