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.
 
 
 
 
 
 

140 lines
5.8 KiB

  1. /*
  2. * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  3. * Copyright (c) 2013-2018 北京泉江科技有限公司
  4. * 创建人:陈彬彬
  5. * 日 期:2017.03.22
  6. * 描 述:数据表管理
  7. */
  8. var selectedRow;
  9. var refreshGirdData;
  10. var bootstrap = function ($, learun) {
  11. "use strict";
  12. var databaseLinkId = '';
  13. var page = {
  14. init: function () {
  15. page.inittree();
  16. page.initGrid();
  17. page.bind();
  18. },
  19. bind: function () {
  20. // 查询
  21. $('#btn_Search').on('click', function () {
  22. var keyword = $('#txt_Keyword').val();
  23. page.search({ tableName: keyword });
  24. });
  25. // 刷新
  26. $('#lr_refresh').on('click', function () {
  27. location.reload();
  28. });
  29. // 新增
  30. $('#lr_add').on('click', function () {
  31. if (databaseLinkId == '') {
  32. learun.alert.warning('请选择数据库!');
  33. } else {
  34. learun.layerForm({
  35. id: 'form',
  36. title: '新建表',
  37. url: top.$.rootUrl + '/LR_SystemModule/DatabaseTable/EditTableForm?databaseLinkId=' + databaseLinkId,
  38. width: 800,
  39. height: 600,
  40. btn: null,
  41. callBack: function (id) {
  42. return top[id].acceptClick(refreshGirdData);
  43. }
  44. });
  45. }
  46. });
  47. /*打开表数据*/
  48. $('#lr_tabledata').on('click', function () {
  49. var tableName = $('#gridtable').jfGridValue('name');
  50. if (learun.checkrow(tableName)) {
  51. learun.layerForm({
  52. id: 'TableIndex',
  53. title: '打开表数据【' + tableName + "】",
  54. url: top.$.rootUrl + '/LR_SystemModule/DatabaseTable/TableIndex?tableName=' + tableName + '&databaseLinkId=' + databaseLinkId,
  55. width: 1000,
  56. height: 800,
  57. maxmin: true,
  58. btn: null
  59. });
  60. }
  61. });
  62. },
  63. inittree: function () {
  64. $('#db_tree').lrtree({
  65. url: top.$.rootUrl + '/LR_SystemModule/DatabaseLink/GetTreeList',
  66. nodeClick: page.treeNodeClick
  67. });
  68. },
  69. treeNodeClick: function (item) {
  70. if (!item.hasChildren) {
  71. databaseLinkId = item.id;
  72. $('#titleinfo').html('[' + item.text + '] [' + item.parent.text + '] [' + item.value + ']');
  73. page.search();
  74. }
  75. },
  76. initGrid: function () {
  77. $('#gridtable').jfGrid({
  78. url: top.$.rootUrl + '/LR_SystemModule/DatabaseTable/GetList',
  79. headData: [
  80. { label: "表名", name: "name", width: 300, align: "left"},
  81. {
  82. label: "记录数", name: "sumrows", width: 100, align: "center",
  83. formatter: function (cellvalue) {
  84. return cellvalue + "条";
  85. }
  86. },
  87. { label: "使用大小", name: "reserved", width: 100, align: "center" },
  88. { label: "索引使用大小", name: "index_size", width: 120, align: "center"},
  89. { label: "说明", name: "tdescription", width: 200, align: "left" }
  90. ],
  91. reloadSelected: true,
  92. mainId: 'name',
  93. isSubGrid: true, // 是否有子表
  94. subGridExpanded: function (subid, rowdata) {
  95. $('#' + subid).jfGrid({
  96. url: top.$.rootUrl + '/LR_SystemModule/DatabaseTable/GetFieldList',
  97. headData: [
  98. { label: "列名", name: "f_column", width: 300, align: "left" },
  99. { label: "数据类型", name: "f_datatype", width: 120, align: "center"},
  100. { label: "长度", name: "f_length", width: 57, align: "center" },
  101. {
  102. label: "允许空", name: "f_isnullable", width: 50, align: "center",
  103. formatter: function (cellvalue) {
  104. return cellvalue == 1 ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
  105. }
  106. },
  107. { label: "标识", name: "f_identity", width: 58, align: "center" },
  108. {
  109. label: "主键", name: "f_key", width: 50, align: "center",
  110. formatter: function (cellvalue) {
  111. return cellvalue == 1 ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
  112. }
  113. },
  114. { label: "默认值", name: "f_default", width: 120, align: "center"},
  115. { label: "说明", name: "f_remark", width: 200, align: "left" }
  116. ]
  117. });
  118. $('#' + subid).jfGridSet('reload', { databaseLinkId: databaseLinkId, tableName: rowdata.name });
  119. }// 子表展开后调用函数
  120. });
  121. },
  122. search: function (param) {
  123. param = param || {};
  124. param.databaseLinkId = databaseLinkId;
  125. $('#gridtable').jfGridSet('reload', param);
  126. }
  127. };
  128. refreshGirdData = function () {
  129. page.search();
  130. };
  131. page.init();
  132. }