ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ // 这个重要 vsComponentModule.factory("$vcEngine", function () { // 这个函数是生成每个组件的id function c() { function e() { return Math.floor((1 + Math.random()) * 65536).toString(16).substring(1) } return e() + e() + e() + e() + e() + e() + e() + e() } // console.log(c()) // 获取的是图表和报表元素两大模块对象 var a = $vsPluginDescriptions.getCategories(); var b = function (e) { console.log(e) this.id = c(); this.type = e.type; this.category = e.category; this.group = e.group; this.title = vsLang.component_title; this.col = 0; this.row = 0; this.sizeY = 2; this.sizeX = d.device === "phone" ? d.gristerColumns : d.gristerColumns / 2; this.config = { backgroundColor: "#FFFFFF", eventConfig: {}, datasourceConfig: { bindingConfig: {}, bindingData: {} } }; this.description = {}; this.description.categories = [] // debugger console.log(this) }; // debugger var d = { deivce: null, // a是图表和报表元素 categories: a, gristerColumns: 4, gristerRowHeight: 20, componentInitSequence: 1, draggingComponent: null, // 初始化 序列 resetComponentInitSequence: function () { d.componentInitSequence = 1 }, resetComponentContext: function (e) { e.context = {}; e.context.resize = function () {}; e.context.watchers = []; e.description = {}; e.description.categories = [] }, // 复制报表 clone: function (f) { var e = angular.copy(f); e.context = {}; e.context.resize = function () {}; e.description.categories = []; e.id = c(); e.config._load_ = null; return e }, // 绑定组件 buildComponent: function (f) { var e = new b({ type: f.type, category: f.category, group: f.group }); this.resetComponentContext(e); e.row = parseInt($("#gridster").height() / this.gristerRowHeight); var g = $vsPluginDescriptions.findDescription(f.category, f.type); if (g && g.onBuildComponent) { g.onBuildComponent(e) } return e } }; console.log(d) return d }); console.log(vsComponentModule) // end // end // end // 函数对象初始化 var V = { name: "function", title: vsLang.menu_function, groups: [] }; console.log(V) console.log(J.showDataCategory) if (J.showDataCategory) { s.component.description.categories.push(V); var I = function (ae) { // ae传进来的参数是整个函数的配置项 // 如果没有数据直接终止程序 if (s.component.config.datasourceConfig == null || s.component.config.datasourceConfig.dimensions == null) { return } // 获取度量 var Y = s.component.config.datasourceConfig.dimensions; // 获取维度 var Z = s.component.config.datasourceConfig.measures; for (var af = 0; af < Y.length; af++) { // 这里的值是true // console.log(s.component.config["sum_" + Y[af].name] == null) if (s.component.config["sum_" + Y[af].name] == null) { // 设置为false s.component.config["sum_" + Y[af].name] = false } } // 如果度量大于o if (Y.length > 0) { // 度量合计模块 var ac = { title: { text: vsLang.dimension_summary }, elements: [] }; for (var af = 0; af < Y.length; af++) { ac.elements.push({ title: Y[af].label, bind: "sum_" + Y[af].name, type: "switch-55", on: vsLang.on, off: vsLang.off }) } // 度量合计模块push进ae数组里 // ae是整个函数配置项的对象 ae.push(ac) } // 如果y大于0 if (Y.length > 0) { // 度量合计别名 var ac = { title: { text: vsLang.dimension_summary_alias }, elements: [] }; console.log(ac) for (var af = 0; af < Y.length; af++) { ac.elements.push({ title: Y[af].label, type: "text-input-sl", dimensionName: Y[af].name, bind: "summaryAlias_" + Y[af].name, }) } ae.push(ac) } ae.push({ title: { text: vsLang.summary }, // 这个是合记模块 elements: [{ title: vsLang.position, type: "radio", bind: "summaryPosition", items: [{ name: vsLang.position_first, value: "first" }, { name: vsLang.position_last, value: "last" }] }] }); // 函数里的数据 脚本 // 数据脚本里的动态数据 var ab = { title: { text: vsLang.measures_script }, // 数据脚本模块 elements: [{ title: vsLang.measures_script, type: "script-editor", bind: "measureScript", btnClass: "btn-default", onClick: function (ah) { e.openScriptEditorWindow(c, b, s, r, ah.bind, "javascript", function () { b(function () { s.$broadcast(event_refreshBindingData, {}) }) }) } }] }; ae.push(ab); // Z是所有的度量 // 如果有Z则执行里面的循环体 // 循环出每一个度量 if (Z != null && Z.length > 0) { if (Z.length > 0) { for (var af = 0; af < Z.length; af++) { ab.elements.push({ title: Z[af].label, type: "text-input-sl", dimensionName: Z[af].name, bind: "measureScript_" + Z[af].name, }) } } } // 数组合并里的top和不包含指定值 var ag = [{ name: "TOP X", value: "excludeTopX" }, { name: "不包含指定值", value: "excludeValues" }]; // 数据合并 var ab = { title: { // 数据合并 text: vsLang.data_merge }, elements: [{ // 数据合并 title: vsLang.data_merge, type: "switch", bind: "enableDataMerge", on: vsLang.on, off: vsLang.off }, { // 维度 title: vsLang.dimension, type: "dimensionDropdownSelect", bind: "dataMergeDimension", show: function () { return s.component.config.enableDataMerge != null && s.component.config.enableDataMerge === true } }, { // 合并值别名 title: vsLang.merge_alias, type: "text-input-sl-s", bind: "dataMergeAlias", show: function () { return s.component.config.enableDataMerge != null && s.component.config.enableDataMerge === true } }, { // 策略 title: vsLang.merge_strategy, type: "select-s", bind: "dataMergeType", items: ag, show: function () { return s.component.config.enableDataMerge != null && s.component.config.enableDataMerge === true } }, { // 值 title: vsLang.value, type: "text-input-sl-s", bind: "dataMergeValue", show: function () { return s.component.config.enableDataMerge != null && s.component.config.enableDataMerge === true } }] }; ae.push(ab); var aa = [{ // 默认 name: vsLang.label_default, value: "sum" }, { // 加总 name: vsLang.function_sum, value: "sum" }, { // 平均值 name: vsLang.function_avg, value: "avg" }, { // 计数 name: vsLang.function_count, value: "count" }, { // 最大值 name: vsLang.function_max, value: "max" }, { // 最小值 name: vsLang.function_min, value: "min" }]; if (Z != null && Z.length > 0) { // 度量函数模块 var ac = { title: { text: vsLang.measures_function }, elements: [] }; for (var af = 0; af < Z.length; af++) { ac.elements.push({ title: Z[af].label, type: "select-s", //这里是循环以名字调用绑定6个函数 bind: "function_" + Z[af].name, // 这里得aa就是上面的aa对象 items: aa }) console.log(ac.elements) } var ad = s.component.config.datasourceConfig.queryProperties; if (ad != null && ad.length > 0) { for (var af = 0; af < ad.length; af++) { ac.elements.push({ title: ad[af].label, type: "select-s", bind: "function_" + ad[af].name, items: aa }) } } ae.push(ac) // console.log(ae) } }; // 把Z也就是函数右侧配置对象传进去 var v = function (Z) { if (s.component.config.datasourceConfig != null && s.component.config.datasourceConfig.dimensions != null) { var ab = s.component.config.datasourceConfig.dimensions; if (ab.length > 0) { var Y = { title: { text: vsLang.dimension_init_value }, elements: [] }; for (var aa = 0; aa < ab.length; aa++) { Y.elements.push({ title: ab[aa].label, bind: "initValue_" + ab[aa].name, type: "text-input-sl-s" }) } Z.push(Y) } } }; // console.log(Z) console.log(v) // 把Z也就是函数右侧配置对象传进去 var y = function (Z) { console.log(Z) var Y = { title: { text: vsLang.dimension_link }, elements: [{ title: vsLang.strategy, type: "radio", bind: "dimensionLinkage", items: [{ name: vsLang.auto, value: "auto" }, { name: vsLang.force_match, value: "force" }] }] }; Z.push(Y) }; s.$on(event_onCategoryTabSelected, function (Z, aa) { if (aa.componentId !== s.component.id) { return } if (aa.name !== "function") { return } if (s.component.config.datasourceConfig.metadataConfig == null) { return } // 设置空数组 var Y = []; console.log(Y) // 调用这三个函数 v(Y); I(Y); y(Y); V.groups = Y; // 绑定数据 Y.push({ title: { text: vsLang.query_properties }, elements: [{ title: vsLang.properties, type: "propertyMultiSelect", bind: "datasourceConfig" }] }); Y.push({ title: { text: "", show: false }, // 刷新组件的按钮模块里面有click方法 elements: [{ title: vsLang.reload_component, type: "button", btnClass: "btn-success", // 刷新组件的事件 onClick: function () { s.$parent.queryConditionDimensions = true; // 接收父控制器数据 s.$broadcast(event_refreshBindingData, {}) } }] }) }) } ~~~