Browse Source

发布兼容以及处理好js合并

master
ezreal 11 months ago
parent
commit
5023bb2a9e
  1. 2
      src/main/java/com/fr/plugin/bi/fusion/web/DecisionWebBridge.java
  2. 2
      src/main/java/com/fr/plugin/bi/fusion/web/SubjectWebBridge.java
  3. 31
      src/main/resources/com/fr/plugin/bi/web/js/bi.subject.js
  4. 23
      src/main/resources/com/fr/plugin/bi/web/js/core/front.dec.bi.publish.filter.js
  5. 177
      src/main/resources/com/fr/plugin/bi/web/js/core/front.dec.publish.list.item.js
  6. 1
      src/main/resources/com/fr/plugin/bi/web/js/decision.index.js
  7. 1
      src/main/resources/com/fr/plugin/bi/web/js/report/subject.report.tab.js
  8. 77
      webcode/Gulpfile.js
  9. 23
      webcode/package.json
  10. 140
      webcode/src/common/base.common.js
  11. 35
      webcode/src/common/core/front.subject.tab.js
  12. 114
      webcode/src/common/core/front.subject.view.js
  13. 68
      webcode/src/common/report/subject.report.add.pop.js
  14. 32
      webcode/src/common/report/subject.report.service.js
  15. 202
      webcode/src/common/report/subject.report.tab.js
  16. 61
      webcode/src/common/report/subject.report.tab.model.js
  17. 123
      webcode/src/common/report/subject.report.view.js
  18. 57
      webcode/src/common/report/subject.report.view.model.js
  19. 105
      webcode/src/common/utils/bi.front.js
  20. 33
      webcode/src/decision/core/front.branch_map.js
  21. 86
      webcode/src/decision/core/front.conf.pack.table.usage.js
  22. 24
      webcode/src/decision/core/front.dec.bi.publish.filter.js
  23. 177
      webcode/src/decision/core/front.dec.publish.list.item.js
  24. 22
      webcode/src/decision/decision.index.js
  25. 13
      webcode/src/subject/bi.subject.js
  26. 16
      webcode/src/subject/core/front.subject.js
  27. 40
      webcode/src/subject/core/front.subject.relationship.map.button.js
  28. 142
      webcode/src/subject/core/front.subject.relationship.pane.header.js
  29. 93
      webcode/src/subject/core/front.subject.relationship.pane.js
  30. 21
      webcode/src/subject/core/front.subject.relationship.pane.map.js

2
src/main/java/com/fr/plugin/bi/fusion/web/DecisionWebBridge.java

@ -28,7 +28,7 @@ public class DecisionWebBridge extends AbstractWebResourceProvider {
return new Component() {
@Override
public ScriptPath script(RequestClient req) {
return ScriptPath.build("com/fr/plugin/bi/web/js/decision.index.js", ParserType.DYNAMIC);
return ScriptPath.build("com/fr/plugin/bi/mix/web/js/decision/fr.mix.bi.decision.min.js", ParserType.DYNAMIC);
}
@Override
public StylePath style(RequestClient req) {

2
src/main/java/com/fr/plugin/bi/fusion/web/SubjectWebBridge.java

@ -25,7 +25,7 @@ public class SubjectWebBridge extends AbstractWebResourceProvider {
return new Component() {
@Override
public ScriptPath script(RequestClient req) {
return ScriptPath.build("com/fr/plugin/bi/web/js/bi.subject.js", ParserType.DYNAMIC);
return ScriptPath.build("com/fr/plugin/bi/mix/web/js/subject/fr.mix.bi.subject.min.js", ParserType.DYNAMIC);
}
@Override

31
src/main/resources/com/fr/plugin/bi/web/js/bi.subject.js

@ -50,7 +50,6 @@
},
addAction: function () {
BI.Msg.prompt("新增cpt报表", "输入名称", function (value) {
debugger;
if (BI.isNotNull(value)) {
BI.Front.subject_view.store.addExtendReport(value);
} else {
@ -138,34 +137,6 @@
}
}
});
/**
* 处理路径会被编码问题cpt就不编码了
* @type {BI.Utils.multiUpdateDashboardShareAuthorityQueue}
*/
BI.Utils.oldMultiUpdateDashboardShareAuthorityQueue = BI.Utils.multiUpdateDashboardShareAuthorityQueue;
BI.Utils.multiUpdateDashboardShareAuthorityQueue = function (e, t, i) {
function filter(path) {
var x = BI.find(BI.Front.SUPPORT_REPORT, function (index, item) {
return path.endWith(item.suffix);
});
return x ? true : false;
}
if (BI.isKey(e) && filter(e)) {
Dec.reqPut("/v10/dashboard/share?entityId=" + e, t, i)
} else {
BI.Utils.oldMultiUpdateDashboardShareAuthorityQueue(e, t, i);
}
}
/**
* 公共链接更新问题调用的产品方案这个时候的id和创建id不一样兼容一下
* @type {BI.Utils.updatePublicLink}
*/
BI.Utils.oldUpdatePublicLink = BI.Utils.updatePublicLink;
BI.Utils.updatePublicLink = function (e, t, i, n) {
t.reportId = t.reportId.replaceAll("_@_", "/");
BI.Utils.oldUpdatePublicLink(e, t, i, n);
}
function importResource(path, type) {
var url = Dec.fineServletURL + "/file?path=" + path;
@ -188,6 +159,8 @@
importResource("com/fr/plugin/bi/web/js/core/front.conf.pack.table.usage.js", "js");
importResource("com/fr/plugin/bi/web/js/core/front.branch_map.js", "js");
importResource("com/fr/plugin/bi/web/js/report/subject.report.add.pop.js", "js");
importResource("com/fr/plugin/bi/web/js/core/front.dec.publish.list.item.js", "js");
importResource("com/fr/plugin/bi/web/js/core/front.dec.bi.publish.filter.js", "js");
//ezreal:协助开发的,后续删

23
src/main/resources/com/fr/plugin/bi/web/js/core/front.dec.bi.publish.filter.js

@ -0,0 +1,23 @@
;!(function () {
BI.Plugin.registerWidget("dec.bi_publish.filter", function (widget) {
widget.beforeCreate = function () {
var self = this;
self.oldCreateTypeFilter = self.createTypeFilter;
self.createTypeFilter = function () {
let result = self.oldCreateTypeFilter();
let chooser = (result.items)[1];
var x = chooser.el || chooser;
var items = x.items;
BI.each(BI.Front.SUPPORT_REPORT, function (index, o) {
items.push({
value: o.typeValue,
text: o.text
})
})
return result;
}
}
return widget;
})
})();

177
src/main/resources/com/fr/plugin/bi/web/js/core/front.dec.publish.list.item.js

@ -0,0 +1,177 @@
;!(function () {
function getStatusIconCls(status) {
switch (status) {
case 1://申请发布
return 'resource-publish-font';
case 3://已发布
return 'resource-published-font';
default:
return 'resource-cancel-publish-font';
}
}
function getStatus(status) {
switch (status) {
case 1://申请发布
return BI.i18nText('Dec-BI_Apply_Publish');
case 2://取消发布
return BI.i18nText('Dec-BI_Apply_Cancel_Publish');
case 3://已发布
default:
return BI.i18nText('Dec-BI_Apply_Published');
}
}
function getFormatTime(timeStamp) {
return BI.getDate(timeStamp).print('%Y-%X-%d %H:%M:%S');
}
BI.Plugin.registerWidget("dec.management.bi_publish.list.item", function (widget) {
var x = BI.find(BI.Front.SUPPORT_REPORT, function (index, item) {
return item.typeValue === widget.itemType;
})
if (x) {
widget.oldItemType = widget.itemType;
widget.itemType = 1;//部分逻辑按照仪表板处理
widget.reportType = x;
/*
BI.each(widget.listeners, function (index, item) {
if (item.eventName === "EVENT_PREVIEW") {
item.oldAction = item.action;
item.action = function () {
/!* const dialog = BI.createTopIframe(BI.UUID(), {
isFullScreen: false,
header: widget.name,
});
var url = Dec.fineServletURL;
if (x.type === "cpt") {
url = Dec.fineServletURL + "/view/report?" + "viewlet=" + widget.itemId;
} else if (x.type === "frm") {
url = Dec.fineServletURL + "/view/form?" + "viewlet=" + widget.itemId;
}
dialog.setSrc(url);*!/
}
}
})*/
//不好处理,只能单独写这个的render函数,来改一些逻辑
widget.render = function () {
var self = this;
const {itemType, publishStatus, applyTime, itemId, name, username, department, role} = this.options;
return {
type: "bi.htape",
cls: "bi-border-bottom",
height: 32,
items: [
{
type: "bi.htape",
columnSize: ['fill', 0.2, 0.2, 0.2, 0.2],
items: [
{
el: {
type: "bi.htape",
items: [
{
el: {
type: "bi.icon_label",
cls: x.iconCls,
height: 32,
width: 16,
iconHeight: 16,
iconWidth: 16,
}, width: 16, lgap: 8
}, {
el: {
type: "bi.label",
height: 32,
whiteSpace: "nowrap",
textAlign: "left",
text: name,
title: name,
}, width: "fill", lgap: 8
}
]
}, lgap: 10
},
/* {
el: {
type: "bi.icon_text_item",
height: 16,
width: 16,
iconWidth: 16,
iconHeight: 16,
whiteSpace: "nowrap",
text: name,
title: name,
cls: x.iconCls
}, lgap: 10
},*/
{
el: {
type: "bi.icon_text_item",
iconWrapperWidth: 24,
iconCls: getStatusIconCls(publishStatus),
text: getStatus(publishStatus),
title: getStatus(publishStatus)
}
},
{
el: self.createLabel(username)
},
{
el: self.createLabel(department)
},
{
el: self.createLabel(role)
}
]
},
{
type: "bi.label",
width: 130,
textAlign: "left",
text: getFormatTime(applyTime),
title: getFormatTime(applyTime)
},
{
type: "bi.vertical_adapt",
width: 100,
items: [
{
type: "bi.text_button",
rgap: 10,
cls: "bi-high-light",
text: BI.i18nText('Dec-Basic_Preview'),
handler: function () {
const dialog = BI.createTopIframe(BI.UUID(), {
isFullScreen: false,
header: widget.name,
});
var url = Dec.fineServletURL;
if (x.type === "cpt") {
url = Dec.fineServletURL + "/view/report?" + "viewlet=" + widget.itemId;
} else if (x.type === "frm") {
url = Dec.fineServletURL + "/view/form?" + "viewlet=" + widget.itemId;
}
dialog.setSrc(url);
self.fireEvent("EVENT_PREVIEW", itemType);
}
},
{
type: "bi.text_button",
cls: "bi-high-light",
text: BI.i18nText('Dec-BI_Apply_Deal'),
handler: function () {
self.openDealPopover();
self.fireEvent("EVENT_DEAL", itemType, publishStatus);
}
}
]
}
]
}
}
}
return widget;
});
})();

1
src/main/resources/com/fr/plugin/bi/web/js/decision.index.js

@ -8,7 +8,6 @@
var perentRoute = BI.find(BI.AnalysisRoutes, function (index, item) {
return item.name === "analysis_subject";
});
if (perentRoute.children) {
BI.each(BI.Front.SUPPORT_REPORT, function (index, item) {
perentRoute.children.push(item.route.view);

1
src/main/resources/com/fr/plugin/bi/web/js/report/subject.report.tab.js

@ -187,7 +187,6 @@
this.textEditor.focus()
},
operator: function (v) {
debugger;
if (v == 7) {
this.fireEvent("DELETE", this.options.id);
}

77
webcode/Gulpfile.js

@ -0,0 +1,77 @@
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
const babel = require('gulp-babel');
const cssmin = require('gulp-cssmin')
const subjectSrcTargetPath = "../src/main/resources/com/fr/plugin/bi/mix/web/js/subject";
const decisionSrcTargetPath = "../src/main/resources/com/fr/plugin/bi/mix/web/js/decision";
const subjectPluginTargetPath = "../../../webroot/WEB-INF/plugins/plugin-com.fr.plugin.BI.fusion.front-1.0/classes/com/fr/plugin/bi/mix/web/js/subject";
const decisionPluginTargetPath = "../../../webroot/WEB-INF/plugins/plugin-com.fr.plugin.BI.fusion.front-1.0/classes/com/fr/plugin/bi/mix/web/js/decision";
//const pluginTargetPath = "distTest";
// Lint JS
gulp.task('lint', function () {
return gulp.src('src/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Concat & Minify JS
gulp.task('decision', buildMinifyTask(['src/common/**/*.js', 'src/decision/**/*.js'], 'fr.mix.bi.decision', 'js', decisionSrcTargetPath, decisionPluginTargetPath, true, false))
gulp.task('subject', buildMinifyTask(['src/common/**/*.js', 'src/subject/**/*.js'], 'fr.mix.bi.subject', 'js', subjectSrcTargetPath, subjectPluginTargetPath, true, false))
function buildMinifyTask(src, name, fileType, srcTargetPath, pluginTargetPath, isDev = false, isUglify = true) {
return function () {
var task = gulp.src(src)
.pipe(concat(name + '.' + fileType))
.pipe(gulp.dest('dist'))
.pipe(rename(name + '.min.' + fileType))
.pipe(babel({
presets: ['@babel/preset-env']
}));
if (isUglify) {
task = task.pipe(uglify(
{
compress: {
drop_console: false, // 过滤 console
drop_debugger: false // 过滤 debugger
}
}
));
}
task = task.pipe(gulp.dest('dist'))
.pipe(gulp.dest(srcTargetPath));
return isDev ? task.pipe(gulp.dest(pluginTargetPath)) : task;
};
}
function buildMinifyCssTask(src, name, isDev = false) {
return function () {
var task = gulp.src(src)
.pipe(concat(name + '.css'))
.pipe(gulp.dest('dist'))
.pipe(rename(name + '.min.css'))
.pipe(cssmin())
.pipe(gulp.dest('dist'))
.pipe(gulp.dest(reportSrcTargetPath));
return isDev ? task.pipe(gulp.dest(pluginTargetPath)) : task;
};
}
// Watch Our Files
gulp.task('watch', function () {
gulp.watch('src/**/*.js', gulp.series('buildTask'));
// gulp.watch('src/**/*.css', gulp.series('minifyBiShowCssDev'));
});
// buildTask
gulp.task('buildTask', gulp.series('decision', 'subject'));
// devTask
//gulp.task('devTask', gulp.series('lint', 'minifyDev', 'minifyBiShow', 'minifyBiShowCssDev', 'minifyBiEditDev', 'watch'));
gulp.task('default', gulp.series('buildTask', 'watch'))

23
webcode/package.json

@ -0,0 +1,23 @@
{
"name": "webcode",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "gulp buildTask",
"dev": "gulp devTask"
},
"author": "fanruan.zhanying",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-concat": "^2.6.1",
"gulp-cssmin": "^0.2.0",
"gulp-jshint": "^2.1.0",
"gulp-rename": "^2.0.0",
"gulp-uglify": "^3.0.2"
}
}

140
webcode/src/common/base.common.js

@ -0,0 +1,140 @@
;!(function () {
BI.Front = BI.Front || {};
BI.Front = BI.extend(BI.Front, {
SUPPORT_REPORT: [
{
typeValue: 101,
type: "cpt",
name: "cpt",
suffix: ".cpt",
iconCls: "fanruan-cpt-logo",
text: "CPT报表",
showPage: function (id) {
const {params} = BI.Router.$router.history.current;
BI.Router.$router.push({
name: "finereport_cpt",
params: Object.assign(Object.assign({}, params), {id: id})
});
},
route: {
edit: {
name: "finereport_cpt",
// path: "/:subjectId/cpt/:id",
path: "cpt/:id",
// path: "/:cpt",
// parent: parentRoute,
children: [],
components: {
analysis: {
type: "bi.subject.view.extend.report",
reportType: "cpt"
}
},
beforeEnter: (to, _from, next) => {
next();
},
},
view: {
name: "finereport_cpt",
path: "cpt/:id",
// path: "/:cpt",
// parent: parentRoute,
children: [],
components: {
analysis: {
type: "bi.subject.view.extend.report",
reportType: "cpt"
}
}
}
},
addAction: function () {
BI.Msg.prompt("新增cpt报表", "输入名称", function (value) {
if (BI.isKey(value.name)) {
BI.Front.subject_view.store.addExtendReport(value);
} else {
BI.Msg.toast("名称为空", {level: "error"});
}
}, {
type: "bi.subject.report.cpt.add.pop",
width: 300
})
},
paneType: {
tab: "bi.subject.tab.extend.report.item",
}
},
{
type: "frm",
typeValue: 102,
name: "frm",
suffix: ".frm",
iconCls: "fanruan-frm-logo",
text: "决策报表",
showPage: function (id) {
const {params} = BI.Router.$router.history.current;
BI.Router.$router.push({
name: "finereport_frm",
params: Object.assign(Object.assign({}, params), {id: id})
});
},
addAction: function () {
BI.Msg.prompt("新增决策报表", "输入名称", function (value) {
if (BI.isKey(value)) {
BI.Front.subject_view.store.addExtendReport({
name: value,
type: 102
});
} else {
BI.Msg.toast("名称为空", {level: "error"});
}
})
},
route: {
edit: {
name: "finereport_frm",
// path: "/:subjectId/frm/:id",
path: "frm/:id",
// path: "/:cpt",
// parent: parentRoute,
children: [],
components: {
analysis: {
type: "bi.subject.view.extend.report",
reportType: "frm"
}
},
beforeEnter: (to, _from, next) => {
next();
}
},
view: {
name: "finereport_frm",
path: "frm/:id",
// path: "/:cpt",
// parent: parentRoute,
children: [],
components: {
analysis: {
type: "bi.subject.view.extend.report",
reportType: "frm"
}
}
}
},
paneType: {
tab: "bi.subject.tab.extend.report.item",
}
}
],
showReportPage: function (reportId, reportType) {
var find = BI.find(BI.Front.SUPPORT_REPORT, function (index, o) {
return o.type === reportType || o.typeValue === reportType;
})
if (find) {
find.showPage(reportId);
}
}
});
})();

35
webcode/src/common/core/front.subject.tab.js

@ -0,0 +1,35 @@
/**
* 对bi.subject.tab的魔改
*/
;!(function () {
/**
* 新增下面tab栏的图标
* important
*/
BI.Plugin.configRender("bi.subject.tab", function (renderObj) {
/**
* 可以修改render方法返回的json对象
* important
*/
var items = ((((renderObj.items)[1]).items)[2]).items;
/*var x = BI.deepClone(items[1]);
x.title = "新增复杂报表";*/
BI.each(BI.Front.SUPPORT_REPORT, function (index, item) {
items.push({
type: "bi.icon_button",
cls: item.iconCls,
forceNotSelected: true,
height: 16,
iconHeight: 16,
iconWidth: 16,
title: "新增"+item.text,
width: 32,
handler: function () {
BI.isFunction(item.addAction) && item.addAction();
}
})
})
return renderObj;
});
})();

114
webcode/src/common/core/front.subject.view.js

@ -0,0 +1,114 @@
/**
* 对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 (data) {
service.subjectAddReport(BI.Router.$router.history.current.params.subjectId, data, 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, data.type);
})
});
}
})
}
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
}
])
}
});
})();

68
webcode/src/common/report/subject.report.add.pop.js

@ -0,0 +1,68 @@
;!(function () {
var widget = BI.inherit(BI.Widget, {
props: {},
watch: {},
/* _store: function () {
return BI.Models.getModel("");
},*/
beforeInit: function (callback) {
callback()
},
render: function () {
var self = this;
return {
type: "bi.horizontal",
// horizontalAlign: "center",
verticalAlign: "middle",
items: [
{
el: {
type: "bi.text_editor",
ref: function (_ref) {
self.textEditor = _ref;
},
width: 100,
}
},
{
el: {
type: "bi.label",
text: "预览类型"
}, lgap: 10
}, {
el: {
type: "bi.text_value_combo",
width: 100,
value: "page",
ref: function (_ref) {
self.previewModel = _ref;
},
items: [{
value: "page",
text: "分页预览"
}, {
value: "write",
text: "填报预览"
}]
},lgap: 10
}
]
}
},
mounted: function () {
},
getValue: function () {
return {
type: 101,
name: this.textEditor.getValue(),
op: this.previewModel.getValue()[0],
}
}
});
BI.shortcut("bi.subject.report.cpt.add.pop", widget);
})();

32
webcode/src/common/report/subject.report.service.js

@ -0,0 +1,32 @@
;!(function () {
var CLIENTID = "e43e37dd7794460f8f81731eda84b2d8";
var SECRET = "3429e051e025412d8426bcf30d60b2cb";
var Service = BI.inherit(BI.OB, {
/**
* 增加主题的报表
* @param subjectId
* @param data
* @param callback
*/
subjectAddReport: function (subjectId, data, callback) {
BI.CLI.template.add(subjectId, data, callback);
},
getSubjectReport: function (subjectid) {
var url = "/front/subject/report?subjectid=" + subjectid;
var result = {};
Dec.syncAjax({
type: "GET",
url: url,
success: function (res) {
result = res;
}
})
return Promise.resolve(result);
},
deleteSubjectReport: function (subjectId, reportId, callback) {
BI.CLI.template.delete(subjectId, reportId, callback);
}
});
BI.service("subject.report.service", Service);
})();

202
webcode/src/common/report/subject.report.tab.js

@ -0,0 +1,202 @@
/**
* 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) {
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);
})();

61
webcode/src/common/report/subject.report.tab.model.js

@ -0,0 +1,61 @@
;!(function () {
var store = BI.inherit(Fix.Model, {
state: function () {
// const {params} = BI.Router.$router.history.current;
return {
id: this.options.id,
name: this.options.name,
reportType: this.options.reportType,
report: this.options.report
}
},
context: ['subjectInfo', 'tables', 'resourceOperationInfo'],
childContext: [],
computed: {
reportItems: function () {
var self = this;
var reportItems = [];
if (self.model.reportType === "cpt") {
reportItems = self.model.subjectInfo.cptItems.availableReports
} else if (self.model.reportType === "frm") {
reportItems = self.model.subjectInfo.frmItems.availableReports
}
return reportItems;
},
namesMap: function () {
var self = this;
var namesMap = {};
BI.each(self.model.reportItems, function (index, item) {
if (item.id != self.model.id) {
namesMap[item.name] = item.id;
}
})
return namesMap;
}
},
actions: {
initData: function (callback) {
var self = this;
BI.isFunction(callback) && callback()
},
reNameReport: function (newName) {
var self = this;
var oldName = self.model.name;
self.model.name = newName;
BI.CLI.template.rename(self.model.subjectInfo.id,
{
id: self.model.id,
name: newName
}, function (res) {
if (res.errorCode) {
BI.Msg.toast(res.errorMsg, {level: "error"});
self.model.name = oldName;
return
}
self.model.report.name = newName;
})
}
}
});
BI.model("bi.subject.tab.extend.report.item.model", store);
})();

123
webcode/src/common/report/subject.report.view.js

@ -0,0 +1,123 @@
/**
* 展示cpt模板
*/
;!(function () {
var RGAP = 15;
BI.CPTVIEW = BI.inherit(BI.Widget, {
props: {
reportType: "cpt"
},
watch: {},
_store: function () {
return BI.Models.getModel("bi.subject.view.extend.report.model", {
reportType: this.options.reportType
});
},
beforeInit: function (callback) {
this.store.initData(callback);
},
render: function () {
var self = this;
var o = this.options;
return {
type: "bi.absolute",
items: [
{
el: {
type: "bi.left_right_vertical_adapt",
cls: "bi-border-bottom",
height: 25,
items: {
left: [
{
type: "bi.label",
text: "",
// css: {"font-size": "large"},
height: 25
}
],
right: self._createRightItem()
}
}, left: 10, right: 10, top: 5, height: 25
},
{
el: {
type: "bi.iframe",
src: self.model.src,
ref: function (_ref) {
self.iframe = _ref;
}
/*type: "bi.label",
text: self.model.newId*/
}, left: 10, right: 10, top: 30, bottom: 0
}
]
}
},
mounted: function () {
},
_createRightItem: function () {
var self = this;
let rightItems = BI.Providers.getProvider("bi.provider.dashboard_toolbar").getRightItems(self.model.id);
rightItems = BI.map(rightItems, function (index, item) {
/*var cptId = self.model.subjectInfo.id + "/" + self.model.id;
if (item.text === "公共链接") {
cptId = self.model.subjectInfo.id + "_@_" + self.model.id;
}*/
return {
el: BI.extend(item, {
type: "bi.icon_text_item",
height: 25,
extraCls: "bi-list-item",
invisible: function () {
return false;
},
reportInfoGetter: function () {
return {
id: self.model.id,
name: self.model.name
}
},
isOwn: true,
refresh: function () {
}
}), rgap: RGAP
}
});
return BI.concat(rightItems, [
{
el: {
type: "bi.icon_text_item",
cls: "refresh-font",
extraCls: "bi-list-item",
height: 25,
text: "刷新",
handler: function () {
self.iframe.setSrc(self.model.src);
// self.iframe.reset();
}
}, rgap: RGAP
},
{
el: {
type: "bi.icon_text_item",
cls: "widget-edit-liner-font",
extraCls: "bi-list-item",
height: 25,
text: "打开设计器编辑",
handler: function () {
var url = "fanruan://" + window.location.origin + Dec.fineServletURL + "?" + Dec.personal.username + "?" + Dec.personal.username + "?reportlets/" + self.model.subjectInfo.id + "/" + self.model.id;
console.log(url);
window.open(url);
}
}, rgap: RGAP
}
])
}
});
BI.shortcut("bi.subject.view.extend.report", BI.CPTVIEW);
})();

57
webcode/src/common/report/subject.report.view.model.js

@ -0,0 +1,57 @@
;!(function () {
var store = BI.inherit(Fix.Model, {
state: function () {
const {params} = BI.Router.$router.history.current;
return {
id: params.id,
op: "page",
reportType: this.options.reportType
}
},
context: ['subjectInfo', 'tables', 'resourceOperationInfo'],
childContext: [],
computed: {
reportItem: function () {
var self = this;
var result = {};
var reportItems = [];
if (self.model.reportType === "cpt") {
reportItems = self.model.subjectInfo.cptItems.availableReports
} else if (self.model.reportType === "frm") {
reportItems = self.model.subjectInfo.frmItems.availableReports
}
return BI.find(reportItems, function (index, item) {
return item.id === self.model.id;
});
},
name: function () {
if (this.model.reportItem) {
return this.model.reportItem.name;
}
return "";
},
src: function () {
var self = this;
var config = BI.find(BI.Front.SUPPORT_REPORT, function (index, item) {
return item.type === self.model.reportType
})
if (config) {
if (self.model.reportType === "cpt") {
return Dec.fineServletURL + "/view/report?" + "viewlet=" + self.model.id;
} else if (self.model.reportType === "frm") {
return Dec.fineServletURL + "/view/form?" + "viewlet=" + self.model.id;
}
}
return Dec.fineServletURL;
}
},
actions: {
initData: function (callback) {
var self = this;
BI.isFunction(callback) && callback()
}
}
});
BI.model("bi.subject.view.extend.report.model", store);
})();

105
webcode/src/common/utils/bi.front.js

@ -0,0 +1,105 @@
;!(function () {
BI.Front = BI.Front || {};
BI.Front = BI.extend(BI.Front, {
utils: {
injectionFunc: function (o, configs) {
if (BI.isNotEmptyArray(configs)) {
BI.each(configs, function (index, item) {
let functionName = item.functionName;
if (functionName) {
let oldFunction = o[functionName];
let beforeFunc = item.beforeFunc;//执行前的函数
let afterFunc = item.afterFunc;//执行后函数
let returnValue = item.returnValue;//是否返回值
let replaceFunc = item.replaceFunc;//替换函数,如果不传递那么就会执行下默认的
o[functionName] = function () {
let para = [];
let len = arguments.length;
for (let i = 0; i < len; i++) {
para.push(arguments[i]);
}
if (BI.isFunction(beforeFunc)) {
beforeFunc.apply(o, para);
}
if (returnValue) {
let value = null;
if (BI.isFunction(replaceFunc)) {
value = replaceFunc.apply(o, para);
} else {
value = oldFunction.apply(o, para);
}
if (BI.isFunction(afterFunc)) {
para.unshift(value)
value = afterFunc.apply(o, para);
}
return value;
} else {
if (BI.isFunction(replaceFunc)) {
replaceFunc.apply(o, para);
} else {
oldFunction.apply(o, para);
}
if (BI.isFunction(afterFunc)) {
afterFunc.apply(o, para);
}
}
}
}
})
}
}
}
});
$.extend(BI.Msg, {
/**
* 弹出框然后有个输入确认返回输入的值
* @param title 标题
* @param content 标签
* @param callback 回调函数
* @param validationChecker 文本框的校验
*/
prompt: function (title, content, callback, config) {
BI.Popovers.removeAll();
var id = BI.UUID();
var textEditor = {
type: "bi.text_editor",
ref: function (_ref) {
BI[id] = _ref;
},
width: 200,
}
textEditor = BI.extend(textEditor, config ? config : {});
var widget = BI.Popovers.create(id, {
type: "bi.bar_popover",
// String或者是json都行
header: title,
size: "small",
body: {
type: "bi.horizontal",
horizontalAlign: "center",
verticalAlign: "middle",
hgap: 10,
items: [{
type: "bi.label",
text: content,
}, textEditor]
},
listeners: [{
eventName: "EVENT_CANCEL",
action: function () {
}
}, {
eventName: "EVENT_CONFIRM",
action: function () {
BI.isFunction(callback) && callback(BI[id].getValue());
}
}]
});
widget.show(id);
}
})
})();

33
webcode/src/decision/core/front.branch_map.js

@ -0,0 +1,33 @@
;!(function () {
BI.Plugin.registerWidget("bi.branch_map", function (widget) {
if (BI.isFunction(widget.contentGetter)) {
var oldcontentGetter = widget.contentGetter;
widget.contentGetter = function (ob) {
var result = oldcontentGetter.apply(this, arguments);
var itemType = ob.itemType;
var find = BI.find(BI.Front.SUPPORT_REPORT, function (index, item) {
return itemType === item.typeValue;
});
if (find && result.listeners) {
var jumpAction = BI.find(result.listeners, function (i, o) {
return o.eventName === "EVENT_JUMP"
});
if (jumpAction) {
jumpAction.action = function () {
//ezreal:当前路由的方式判断下是怎么打开吧。
var currentRoute = BI.Router.$router.currentRoute;
if (currentRoute && currentRoute.name == "subject_table") {
BI.Front.showReportPage(ob.value.id, find.type)
} else {
var url = Dec.fineServletURL + "/v5/conf/subject/page/edit/" + ob.value.parentId + "/" + find.type + "/" + ob.value.id;
window.open(url);
}
}
}
}
return result;
}
}
return widget;
})
})();

86
webcode/src/decision/core/front.conf.pack.table.usage.js

@ -0,0 +1,86 @@
;!(function () {
BI.Plugin.registerWidget("bi.conf.pack.table.usage", function (widget) {
widget.beforeInit = function (callback) {
var self = this;
self.store.cptMap = {};
self.store.frmMap = {};
/**
* 初始化一些数据的
* @type {self.store.buildItemMap}
*/
self.store.oldBuildItemMap = self.store.buildItemMap;
self.store.buildItemMap = function (usageInfo) {
self.store.oldBuildItemMap(usageInfo);
BI.each(usageInfo.cptMap, (key, value) => {
self.store.cptMap[key] = value;
});
BI.each(usageInfo.frmMap, (key, value) => {
self.store.frmMap[key] = value;
});
}
/**
* 创建节点
* @type {function(*=, *=, *=): (*|null)}
*/
self.store.oldGetNodeByItem = self.store.getNodeByItem;
self.store.getNodeByItem = function (pId, item, direction) {
var find = BI.find(BI.Front.SUPPORT_REPORT, function (index, o) {
return item.type === o.typeValue;
})
if (find) {
var info = {
isParent: item.knots > 0,
count: item.knots,
childrenItems: item.usageItemBeans,
direction,
};
var reportMap = {};
if (find.typeValue === 101) {
reportMap = self.store.cptMap
} else if (find.typeValue === 102) {
reportMap = self.store.frmMap
}
if (reportMap[item.id]) {
return BI.extend(self.store.createExtendReportNode(pId, reportMap[item.id], find.typeValue), info)
}
return null;
}
return self.store.oldGetNodeByItem(pId, item, direction);
}
self.store.createExtendReportNode = function (pId, report, itemType) {
return {
text: report.name,
title: function () {
return report.name
},
value: Object.assign(Object.assign({}, report), {moduleType: 2}),
id: BI.UUID(),
pId: pId,
itemType: itemType,
}
}
/**
* 图标
* @type {function(*=): (*)}
*/
self.oldGetIconCls = self.getIconCls;
self.getIconCls = function (ob) {
var find = BI.find(BI.Front.SUPPORT_REPORT, function (index, o) {
return ob.itemType === o.typeValue;
});
if (find) {
return find.iconCls;
}
return self.oldGetIconCls(ob)
}
BI.isFunction(callback) && callback();
};
return widget;
});
BI.Plugin.configRender("bi.conf.pack.table.usage", function (renderObject) {
return renderObject;
})
})();

24
webcode/src/decision/core/front.dec.bi.publish.filter.js

@ -0,0 +1,24 @@
;!(function () {
BI.Plugin.registerWidget("dec.bi_publish.filter", function (widget) {
widget.beforeCreate = function () {
var self = this;
self.oldCreateTypeFilter = self.createTypeFilter;
self.createTypeFilter = function () {
let result = self.oldCreateTypeFilter();
let chooser = (result.items)[1];
var x = chooser.el || chooser;
var items = BI.deepClone(x.items);
BI.each(BI.Front.SUPPORT_REPORT, function (index, o) {
items.push({
value: o.typeValue,
text: o.text
})
})
x.items = items;
return result;
}
}
return widget;
})
})();

177
webcode/src/decision/core/front.dec.publish.list.item.js

@ -0,0 +1,177 @@
;!(function () {
function getStatusIconCls(status) {
switch (status) {
case 1://申请发布
return 'resource-publish-font';
case 3://已发布
return 'resource-published-font';
default:
return 'resource-cancel-publish-font';
}
}
function getStatus(status) {
switch (status) {
case 1://申请发布
return BI.i18nText('Dec-BI_Apply_Publish');
case 2://取消发布
return BI.i18nText('Dec-BI_Apply_Cancel_Publish');
case 3://已发布
default:
return BI.i18nText('Dec-BI_Apply_Published');
}
}
function getFormatTime(timeStamp) {
return BI.getDate(timeStamp).print('%Y-%X-%d %H:%M:%S');
}
BI.Plugin.registerWidget("dec.management.bi_publish.list.item", function (widget) {
var x = BI.find(BI.Front.SUPPORT_REPORT, function (index, item) {
return item.typeValue === widget.itemType;
})
if (x) {
widget.oldItemType = widget.itemType;
widget.itemType = 1;//部分逻辑按照仪表板处理
widget.reportType = x;
/*
BI.each(widget.listeners, function (index, item) {
if (item.eventName === "EVENT_PREVIEW") {
item.oldAction = item.action;
item.action = function () {
/!* const dialog = BI.createTopIframe(BI.UUID(), {
isFullScreen: false,
header: widget.name,
});
var url = Dec.fineServletURL;
if (x.type === "cpt") {
url = Dec.fineServletURL + "/view/report?" + "viewlet=" + widget.itemId;
} else if (x.type === "frm") {
url = Dec.fineServletURL + "/view/form?" + "viewlet=" + widget.itemId;
}
dialog.setSrc(url);*!/
}
}
})*/
//不好处理,只能单独写这个的render函数,来改一些逻辑
widget.render = function () {
var self = this;
const {itemType, publishStatus, applyTime, itemId, name, username, department, role} = this.options;
return {
type: "bi.htape",
cls: "bi-border-bottom",
height: 32,
items: [
{
type: "bi.htape",
columnSize: ['fill', 0.2, 0.2, 0.2, 0.2],
items: [
{
el: {
type: "bi.htape",
items: [
{
el: {
type: "bi.icon_label",
cls: x.iconCls,
height: 32,
width: 16,
iconHeight: 16,
iconWidth: 16,
}, width: 16, lgap: 8
}, {
el: {
type: "bi.label",
height: 32,
whiteSpace: "nowrap",
textAlign: "left",
text: name,
title: name,
}, width: "fill", lgap: 8
}
]
}, lgap: 10
},
/* {
el: {
type: "bi.icon_text_item",
height: 16,
width: 16,
iconWidth: 16,
iconHeight: 16,
whiteSpace: "nowrap",
text: name,
title: name,
cls: x.iconCls
}, lgap: 10
},*/
{
el: {
type: "bi.icon_text_item",
iconWrapperWidth: 24,
iconCls: getStatusIconCls(publishStatus),
text: getStatus(publishStatus),
title: getStatus(publishStatus)
}
},
{
el: self.createLabel(username)
},
{
el: self.createLabel(department)
},
{
el: self.createLabel(role)
}
]
},
{
type: "bi.label",
width: 130,
textAlign: "left",
text: getFormatTime(applyTime),
title: getFormatTime(applyTime)
},
{
type: "bi.vertical_adapt",
width: 100,
items: [
{
type: "bi.text_button",
rgap: 10,
cls: "bi-high-light",
text: BI.i18nText('Dec-Basic_Preview'),
handler: function () {
const dialog = BI.createTopIframe(BI.UUID(), {
isFullScreen: false,
header: widget.name,
});
var url = Dec.fineServletURL;
if (x.type === "cpt") {
url = Dec.fineServletURL + "/view/report?" + "viewlet=" + widget.itemId;
} else if (x.type === "frm") {
url = Dec.fineServletURL + "/view/form?" + "viewlet=" + widget.itemId;
}
dialog.setSrc(url);
self.fireEvent("EVENT_PREVIEW", itemType);
}
},
{
type: "bi.text_button",
cls: "bi-high-light",
text: BI.i18nText('Dec-BI_Apply_Deal'),
handler: function () {
self.openDealPopover();
self.fireEvent("EVENT_DEAL", itemType, publishStatus);
}
}
]
}
]
}
}
}
return widget;
});
})();

22
webcode/src/decision/decision.index.js

@ -0,0 +1,22 @@
;!(function () {
function importResource(path, type) {
var url = Dec.fineServletURL + "/file?path=" + path;
BI.$import(url, type);
}
var perentRoute = BI.find(BI.AnalysisRoutes, function (index, item) {
return item.name === "analysis_subject";
});
if (perentRoute.children) {
BI.each(BI.Front.SUPPORT_REPORT, function (index, item) {
perentRoute.children.push(item.route.view);
})
}
//ezreal:协助开发的,后续删
BI.Plugin.config(function (type, options) {
}, function (type, object) {
object.element.attr("shortcut", object.options.type);
});
})();

13
webcode/src/subject/bi.subject.js

@ -0,0 +1,13 @@
;!(function () {
function importResource(path, type) {
var url = Dec.fineServletURL + "/file?path=" + path;
BI.$import(url, type);
}
//ezreal:协助开发的,后续删
BI.Plugin.config(function (type, options) {
}, function (type, object) {
object.element.attr("shortcut", object.options.type);
});
})();

16
webcode/src/subject/core/front.subject.js

@ -0,0 +1,16 @@
/**
* bi.subject的魔改
*/
;!(function () {
/**
* 新增路由可以切换在当前的组件
* important
*/
BI.Plugin.configRender("bi.subject", function (renderObject) {
var childrenItems = ((renderObject.routes)[0]).children;
BI.each(BI.Front.SUPPORT_REPORT,function (index,item){
childrenItems.push(item.route.edit);
})
return renderObject;
});
})();

40
webcode/src/subject/core/front.subject.relationship.map.button.js

@ -0,0 +1,40 @@
;!(function () {
BI.Plugin.registerWidget("bi.subject.relationship.map.button", function (widget) {
widget.beforeCreate = function () {
var self = this;
/**
* 修改图标
* @type {function(): (*)}
*/
self.oldGetIconCls = self.getIconCls;
self.getIconCls = function () {
const {itemType, nodeInfo} = this.options;
var find = BI.find(BI.Front.SUPPORT_REPORT, function (index, item) {
return itemType === item.typeValue;
})
if (find) {
return find.iconCls;
}
return self.oldGetIconCls();
}
/**
* 修改title
* @type {function(*=, *=): (*)}
*/
self.store.oldGetTitle = self.store.getTitle;
self.store.getTitle = function (itemType, nodeInfo) {
var find = BI.find(BI.Front.SUPPORT_REPORT, function (index, item) {
return itemType === item.typeValue;
})
if (find) {
var result = [];
result.push("报表名称:" + nodeInfo.name);
result.push("创建用户:" + nodeInfo.createBy);
return result.join('\n');
}
return self.store.oldGetTitle(itemType, nodeInfo);
}
}
})
})();

142
webcode/src/subject/core/front.subject.relationship.pane.header.js

@ -0,0 +1,142 @@
;!(function () {
BI.Front = BI.Front || {};
BI.Front = BI.extend(BI.Front, {
relation_pane_header: {
widget: null
}
})
BI.Plugin.registerWidget("bi.subject.relationship.pane.header", function (widget) {
widget.beforeCreate = function () {
BI.Front.relation_pane_header.widget = this;
var self = this;
/**
* 搜索结果
* @type {function(*=, *=): *}
*/
self.store.oldBuildSearchResult = self.store.buildSearchResult;
self.store.buildSearchResult = function (keywords, originData) {
BI.Front.relation_pane.widget.store._computedWatchers.shownList.value = BI.Front.relation_pane.widget.store._computedWatchers.shownList.getter.call(BI.Front.relation_pane.widget.store);
originData = self.model.shownList;
var result = self.store.oldBuildSearchResult(keywords, originData);
BI.each(BI.Front.SUPPORT_REPORT, function (index, item) {
var x = originData[item.type] && BI.Func.getSearchResult(Object.values(originData[item.type]), keywords, 'name');
result[item.type] = x || {};
})
return result;
}
/**
* 处理搜索结果
*/
self.oldCreatItems = self.creatItems;
self.creatItems = function (source) {
var result = self.oldCreatItems(source);
BI.each(BI.Front.SUPPORT_REPORT, function (index, item) {
var x = source[item.type];
result = BI.concat(result, self.creatCptOrFrmItems(x, item));
})
return result;
}
self.creatCptOrFrmItems = function (items, o) {
var finds = items.find || [];
var match = items.match || [];
finds = BI.concat(finds, match);
if (finds.length > 0) {
var label = {
type: "bi.label",
cls: 'bi-secondary-text bi-font-bold',
height: 30,
id: BI.UUID(),
key: BI.UUID(),
text: o.text,
textAlign: 'left',
lgap: 12
}
var x = BI.map(finds, function (index, item) {
return {
type: "bi.basic_button",
cls: 'bi-list-item-text',
forceNotSelected: true,
id: BI.UUID(),
key: BI.UUID(),
render: function () {
return {
type: "bi.vertical_adapt",
columnSize: [24, 'fill'],
items: [
{
type: "bi.icon_label",
cls: o.iconCls,
height: 16,
iconWidth: 16,
iconHeight: 16,
_lgap: 8
},
{
type: "bi.label",
cls: 'item-name',
text: item.name,
keyword: self.model.keywords,
height: 30,
textHeight: 30,
textAlign: 'left'
}
]
}
},
handler: function () {
self.fireEvent("EVENT_CHANGE", item.id, o.typeValue);
self.combo.hideView();
}
}
});
x.unshift(label);
return x;
}
return [];
}
}
})
BI.Plugin.configRender("bi.subject.relationship.pane.header", function (renderObject) {
var self = renderObject;
function findObject(value) {
if (BI.isNotEmptyArray(value)) {
BI.each(value, function (index, item) {
if (BI.isObject(item) && item.value === "table" && item.text === BI.i18nText('BI-Basic_Data')) {
self.result = value;
return false;
}
findObject(item);
})
} else if (BI.isObject(value)) {
BI.each(value, function (k, v) {
findObject(v);
})
}
}
self.result = [];
findObject(renderObject,);
if (BI.isNotEmptyArray(self.result)) {
BI.each(BI.Front.SUPPORT_REPORT, function (index, item) {
self.result.push({
type: "bi.multi_select_item",
value: item.type,
text: item.text,
handler: function () {
BI.Front.relation_pane_header.widget.fireEvent("EVENT_FILTER", item.type, this.isSelected());
BI.Front.relation_pane.widget.store.setLayout(true);//传递一个参数,刷新的时候需要单独处理下
BI.Front.relation_pane.widget.map.populate();
},
selected: function () {
return (BI.Front.relation_pane_header.widget.model.shownTypeMap)[item.type]
}
})
})
}
return renderObject;
})
})();

93
webcode/src/subject/core/front.subject.relationship.pane.js

@ -0,0 +1,93 @@
/**
* 对bi.subject.relationship.pane魔改
*/
;!(function () {
BI.Front = BI.Front || {};
BI.Front = BI.extend(BI.Front, {
relation_pane: {
widget: null
}
});
BI.Plugin.registerWidget("bi.subject.relationship.pane", function (widget) {
widget.beforeCreate = function () {
var self = this;
BI.Front.relation_pane.widget = self;
BI.each(BI.Front.SUPPORT_REPORT, function (index, item) {
(self.model.shownTypeMap)[item.type] = true;
})
self.store.oldSetLayout = self.store.setLayout;
self.store.setLayout = function (v) {
if (v) {
self.store._computedWatchers.shownIdsMap.value = self.store._computedWatchers.shownIdsMap.getter.call(self.store);
}
self.store.oldSetLayout();
}
}
})
BI.Plugin.registerObject("bi.subject.relationship.pane", function (object) {
var self = object;
object.populate = function () {
self.loading();
return self.store.initData().then(function () {
BI.each(BI.Front.SUPPORT_REPORT, function (index, item) {
var reportInfo = {};
var reportType = item.type;
var reportItems = [];
if (reportType === "cpt") {
reportItems = self.model.subjectInfo.cptItems.availableReports
} else if (reportType === "frm") {
reportItems = self.model.subjectInfo.frmItems.availableReports
} else {
return
}
BI.each(reportItems, function (i, o) {
reportInfo[o.id] = BI.extend({
available:true
},o);
var find = BI.find(self.model.itemBeans, function (a, b) {
return b.id === o.id;
})
if (!find) {//甘老师后台接口没有返回无血缘的数据,所以找不到就也要装进去,父节点为空
self.model.itemBeans.push({
id: o.id,
type: item.typeValue,
fatherItemIds: []
})
}
});
(self.model.resourceMap)[reportType] = reportInfo;
});
self.store._computedWatchers.shownIdsMap.value = self.store._computedWatchers.shownIdsMap.getter.call(self.store);
self.store._computedWatchers.shownList.value = self.store._computedWatchers.shownList.getter.call(self.store);
self.store._computedWatchers.shownEdges.value = self.store._computedWatchers.shownEdges.getter.call(self.store);
self.store.setLayout();
}).then(function () {
self.loaded();
if (BI.isNotEmptyArray(self.model.relationMapLayout)) {
self.map.initMap();
}
});
}
/**
* 血缘关系视图 点击切换tab的方法
* @type {object.store.showSelect}
*/
self.store.oldShowSelect = self.store.showSelect;
self.store.showSelect = function (id, type) {
var find = BI.find(BI.Front.SUPPORT_REPORT, function (index, item) {
return item.typeValue === type;
});
if (find) {
BI.isFunction(find.showPage) && find.showPage(id);
return;
}
self.store.oldShowSelect(id, type);
}
return object;
})
})();

21
webcode/src/subject/core/front.subject.relationship.pane.map.js

@ -0,0 +1,21 @@
;!(function () {
BI.Plugin.registerObject("bi.subject.relationship.pane.map", function (object) {
var self = object;
self.oldGetSourceType = self.getSourceType;
self.getSourceType = function (id) {
var find = BI.find(BI.Front.SUPPORT_REPORT, function (index, item) {
var x = (self.model.resourceMap)[item.type];
if (x && x[id]) {
return true;
}
return false;
})
if (find) {
return find.typeValue;
}
return self.oldGetSourceType(id);
}
})
})();
Loading…
Cancel
Save