ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
一.模板文件在index.jsp 大概在325行 ~~~ /* 在报表设计页的选择数据源弹框 */ <script type="text/ng-template" id="selectReportDataModal.html"> <div class="modal-header" style="padding: 10px 15px;"> <h4>请{{vsLang.choose_metadata}}</h4> </div> <div class="modal-body" style="padding:0;"> <div class="tree-container" ng-controller="MetadataTreeCtrl" style="top:0;"> <div class="tree-content"> <div ui-tree="treeOptions" data-drag-enabled="false"> <ol ui-tree-nodes="" ng-model="data" id="tree-root"> <li ng-repeat="node in data" ui-tree-node ng-include="'nodes_renderer.html'"></li> </ol> </div> </div> </div> <div style="position:absolute;left:250px;top:0;bottom:0;right:0;"> <table ng-show="data.length > 0" class="doc-list-table" style="width:100%;height:44px;border-bottom:1px solid #f0f0f0;table-layout: fixed;"> <thead> <th style="min-width:40px;width:40px;height:43px;"> </th> <th>{{vsLang.name}}</th> <th style="min-width:100px;width:100px;text-align:center;">{{vsLang.metadata_table_count}}</th> <th style="min-width:140px;width:140px;text-align:center;">{{vsLang.last_update}}</th> </thead> </table> <div style="position:absolute;left:0;top:44px;bottom:0;right:0;overflow-y:auto;"> <div style="height:100px;line-height:100px;text-align:center;color:#999;" ng-show="data.length == 0">{{vsLang.no_metadata_found}}</div> <table ng-show="data.length > 0" class="doc-list-table" style="width:100%;table-layout: fixed;"> <tbody> <tr ng-repeat="item in data" ng-click="onItemClicked(item)" ng-mouseover="hoverIn(item)" ng-mouseleave="hoverOut(item)" ng-style="{'background-color': selectedId === item.id ? '#E6F0F8':''}"> <td style="min-width:40px;width:40px;"> <label style="margin-left:10px;cursor:pointer;" ng-click="onItemClicked(item)"> <input type="checkbox" ng-model="selectedIdMap[item.id]" style="cursor:pointer;" ng-click="onItemClicked(item)"> </label> </td> <td> <div class="name"> {{item.name}} </div> </td> <td style="min-width:100px;width:100px;text-align:center;"> {{item.tableCount}} </td> <td style="min-width:140px;width:140px;text-align:center;"> {{item.updateDate}}{{vsLang.ago}} </td> </tr> </tbody> </table> </div> </div> </div> <div class="modal-footer" style="padding: 10px 15px;"> <button type="button" class="btn btn-success" ng-click="confirm()">{{vsLang.save}}</button> <button type="button" class="btn btn-default" ng-click="dismissWindow()">{{vsLang.cancel}}</button> </div> </script> ~~~ 二.通过点击时间控制器找到点击使用的函数分析找到核心函数 点击函数datasourceConfig.onMetadataDatasourceSelected() 三.判断有没有数据源,改写成没有数据源直接弹弹框 vs-designer-component.js 大概2008行 ~~~ // 判断有没有数据源 var g = function () { k.fetchingMetadataTables = true; var p = { method: "POST", url: "datasource/metadata/tables.do", params: { reportId: reportId } }; j(p).then(function n(q) { console.log(q) k.datasourceConfig.fetchingMetadataTables = false; if (q.data.success) { k.datasourceConfig.metadataTables = q.data.data; f() } else { // i.error({ // body: q.data.message // }) // 谷建文 var p = b.open({ templateUrl: "selectReportDataModal.html", controller: "SelectReportDataModalCtrl", scope: k, size: "lg", windowClass: "select-report-data-modal", resolve: { param: function () { return {} } } }) console.log(k) // end } }, function o(q) { k.datasourceConfig.fetchingMetadataTables = false; i.error({ body: vsLang.connection_failed }) console.log(i) console.log(vsLang.connection_failed) }) }; ~~~ ps(scope: k)这里的k是当前控制器的作用域,模板层在最大的Appctrl控制器里,angular特性子级控制器里没有的变量和方法,会顺着作用域链一直往上查找