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.
117 lines
4.7 KiB
117 lines
4.7 KiB
/** |
|
* 对bi.subject.view组件的一些魔改 |
|
*/ |
|
;!(function () { |
|
BI.Front = BI.Front || {}; |
|
BI.Front = BI.extend(BI.Front, { |
|
subject_view: { |
|
store: null, |
|
model: null, |
|
} |
|
}); |
|
BI.Plugin.registerWidget("bi.subject.view", function (widget) { |
|
widget.beforeCreate = function () { |
|
var self = this; |
|
var service = BI.Services.getService("subject.report.service"); |
|
BI.Front.subject_view.store = self.store; |
|
BI.Front.subject_view.model = self.model; |
|
self.store.getExtendReportItem = function (item, type) { |
|
var find = BI.find(BI.Front.SUPPORT_REPORT, function (index, o) { |
|
return o.type === type || o.typeValue === type; |
|
}) |
|
if (find) { |
|
return { |
|
type: find.paneType.tab, |
|
id: item.id, |
|
name: item.name, |
|
report: item, |
|
reportType: find.type, |
|
iconCls: find.iconCls, |
|
onSelect: function () { |
|
BI.Front.showReportPage(item.id, find.type) |
|
}, |
|
listeners: [ |
|
{ |
|
eventName: "DELETE", |
|
action: function (id) { |
|
self.store.deleteExtendReport(id); |
|
} |
|
} |
|
], |
|
editable: self.options.subjectEntryType == 0 |
|
} |
|
} |
|
return { |
|
type: "bi.label", |
|
text: item.name |
|
} |
|
} |
|
self.store.addExtendReport = function (name, typeValue) { |
|
service.subjectAddReport(BI.Router.$router.history.current.params.subjectId, { |
|
name: name, |
|
type: typeValue |
|
}, function (res) { |
|
if (res.data) { |
|
const order = self.model.customOrder.slice(); |
|
order.push(res.data.id); |
|
self.store.sortLabels(order).then(function () { |
|
self.store.refreshTab().then(function () { |
|
BI.Front.showReportPage(res.data.id, typeValue); |
|
}) |
|
}); |
|
} |
|
}) |
|
} |
|
self.store.deleteExtendReport = function (id) { |
|
service.deleteSubjectReport(self.model.subjectInfo.id, id, function () { |
|
self.store.refreshTab(id); |
|
|
|
}) |
|
} |
|
/** |
|
* 初始化 |
|
*/ |
|
BI.each(self.model.subjectInfo.cptItems.availableReports, function (index, o) { |
|
self.model.labels.push(self.store.getExtendReportItem(o, "cpt")); |
|
}); |
|
BI.each(self.model.subjectInfo.frmItems.availableReports, function (index, o) { |
|
self.model.labels.push(self.store.getExtendReportItem(o, "frm")); |
|
}); |
|
const order = self.model.customOrder; |
|
if (BI.isEmptyArray(order)) { |
|
self.model.sortLabels = self.model.labels; |
|
} else { |
|
self.model.sortLabels = self.model.labels.sort(function (a, b) { |
|
return order.indexOf(a.id) - order.indexOf(b.id); |
|
}) |
|
} |
|
BI.Front.utils.injectionFunc(self.store._computedWatchers.labels, [ |
|
{ |
|
functionName: "getter", |
|
returnValue: true, |
|
afterFunc: function (oldLabel) { |
|
BI.each(self.model.subjectInfo.cptItems.availableReports, function (index, o) { |
|
oldLabel.push(self.store.getExtendReportItem(o, "cpt")); |
|
}); |
|
BI.each(self.model.subjectInfo.frmItems.availableReports, function (index, o) { |
|
oldLabel.push(self.store.getExtendReportItem(o, "frm")); |
|
}); |
|
return oldLabel; |
|
} |
|
} |
|
]) |
|
BI.Front.utils.injectionFunc(self.store, [ |
|
{ |
|
functionName: "refreshTab", |
|
afterFunc: function (value, id) { |
|
if (BI.isNotNull(id)) { |
|
return this.updateSubjectInfo(); |
|
} |
|
return value; |
|
}, |
|
returnValue: true |
|
} |
|
]) |
|
} |
|
}); |
|
})(); |