{
 "hidden": false,
 "children": [{
  "configs": {
   "itemId": "module",
   "serverScript": "\
var jsArray,\
  jndiList = [];\
 \
\
\
\
jndiList = Object.keys(Wb.readJson(new File(Base.path, 'wb/system/var.json')).sys.jndi);\
  jsArray = Wb.reverse(jndiList); //javaArray转jsArray\
\
app.set(\"jndiList\",jsArray);"
  },
  "expanded": true,
  "children": [
   {
    "configs": {
     "layout": "absolute",
     "itemId": "editwin",
     "dialog": "true",
     "closeAction": "hide",
     "autoReset": "true",
     "width": "804",
     "height": "492"
    },
    "expanded": false,
    "children": [
     {
      "configs": {
       "itemId": "COD",
       "allowBlank": "false",
       "labelAlign": "right",
       "fieldLabel": "COD",
       "width": "200",
       "x": "0",
       "y": "16",
       "isUpperCase": "true",
       "labelWidth": "60",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "itemId": "PID",
       "allowBlank": "false",
       "hidden": "true",
       "labelAlign": "right",
       "fieldLabel": "PID",
       "width": "200",
       "x": "0",
       "y": "16",
       "labelWidth": "60",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "itemId": "SOURCE_NAME",
       "labelAlign": "right",
       "fieldLabel": "名称",
       "width": "300",
       "x": "200",
       "y": "16",
       "labelWidth": "60",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "itemId": "CONTENT",
       "width": "778",
       "x": "0",
       "y": "72",
       "height": "188"
      },
      "expanded": false,
      "children": [],
      "type": "comp"
     },
     {
      "configs": {
       "itemId": "E_COLUMN",
       "emptyText": "英文列名",
       "x": "8",
       "width": "388",
       "y": "270",
       "height": "165"
      },
      "expanded": false,
      "children": [],
      "type": "textarea"
     },
     {
      "configs": {
       "itemId": "C_COLUMN",
       "emptyText": "中文列名",
       "x": "400",
       "width": "388",
       "y": "270",
       "height": "165"
      },
      "expanded": false,
      "children": [],
      "type": "textarea"
     },
     {
      "configs": {
       "itemId": "formatBtn",
       "x": "696",
       "width": "72",
       "y": "16",
       "text": "初始化",
       "iconCls": "navview_icon",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "button",
      "events": {"click": "Wb.request({\
  url: 'm?xwl=system/common/report/sourceEdit/getMetaData',\
  params: {SQL: app.editor.getValue()},\
  success: function(resp) {\
  app.E_COLUMN.setValue(resp.responseText);}\
});"}
     },
     {
      "configs": {
       "itemId": "JNDI",
       "labelAlign": "right",
       "fieldLabel": "JNDI",
       "x": "496.0000305175781",
       "width": "200",
       "y": "16",
       "displayField": "ID",
       "labelWidth": "40",
       "valueField": "ID",
       "height": "22"
      },
      "expanded": false,
      "children": [{
       "configs": {
        "itemId": "store",
        "data": "app.jndiList",
        "fields": "[{name:\"ID\"}]"
       },
       "expanded": false,
       "children": [],
       "type": "store"
      }],
      "type": "combo"
     },
     {
      "configs": {
       "itemId": "COLUMNS",
       "labelAlign": "right",
       "fieldLabel": "缓存列",
       "x": "0",
       "width": "344",
       "y": "44",
       "labelWidth": "75",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "itemId": "VCOLUMNS",
       "labelAlign": "right",
       "fieldLabel": "缓存值",
       "x": "352",
       "width": "344",
       "y": "44",
       "labelWidth": "75",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     }
    ],
    "type": "window",
    "events": {"ok": "var marks = app.editor.getAllMarks();\
for (var m in marks)\
  if (marks[m].className === \"CodeMirror-lint-mark-error\")\
    return;\
\
var values = Wb.apply(Wb.getValue(app.editwin), {\
  SQL: app.editor.getValue()\
});\
\
if (app.isEdit) {\
  //点击修改按钮的处理过程\
  Wb.request({\
    url: 'm?xwl=system/common/report/sourceEdit/update',\
    params: Wb.applyIf(values, Wb.getData(app.selRec, true)), //合并窗口和记录数据作为参数，后者为默认值\
    success: function() {\
      //把窗口数据更新到选择记录中\
      //隐藏对话框，在模块关闭时自动销毁对话框\
      app.editwin.close();\
        Wb.info(\"成功\");\
      app.findmenu.fireEvent('click');\
    }\
  });\
} else {\
  //点击添加按钮的处理过程\
  Wb.request({\
    url: 'm?xwl=system/common/report/sourceEdit/insert',\
    params: values,\
    success: function(resp) {\
      //把服务器返回的数据合并窗口数据（公司名称等数据）添加到表格中\
      //隐藏对话框，在模块关闭时自动销毁对话框\
      app.editwin.close();\
      Wb.info(\"成功\");\
      app.findmenu.fireEvent('click');\
    }\
  });\
}"}
   },
   {
    "configs": {
     "layout": "fit",
     "itemId": "viewport1"
    },
    "expanded": true,
    "children": [{
     "configs": {
      "itemId": "tree1",
      "root": "{\
  text: '报表',id:'-1'\
}",
      "tools": "Wb.getTreeTools()",
      "rootVisible": "false"
     },
     "expanded": true,
     "children": [
      {
       "configs": {
        "itemId": "store",
        "url": "m?xwl=system/common/report/sourceEdit/select"
       },
       "expanded": false,
       "children": [],
       "type": "treestore",
       "events": {"beforeload": "var node = operation.node;\
operation.params={pId:node.isRoot() ? -1 : operation.node.data.ID};\
//.parentDept = node.isRoot() ? -1 : operation.node.data.DEPT_ID;"}
      },
      {
       "configs": {
        "itemId": "viewConfig",
        "markDirty": "false"
       },
       "expanded": false,
       "children": [],
       "type": "tableview"
      },
      {
       "configs": {"itemId": "columns"},
       "expanded": true,
       "children": [
        {
         "configs": {
          "itemId": "ID",
          "xtype": "treecolumn",
          "dataIndex": "COD",
          "width": "200",
          "text": "COD",
          "align": "left"
         },
         "expanded": false,
         "children": [],
         "type": "column"
        },
        {
         "configs": {
          "itemId": "JS",
          "dataIndex": "SOURCE_NAME",
          "width": "200",
          "text": "名称"
         },
         "expanded": false,
         "children": [],
         "type": "column"
        },
        {
         "configs": {
          "itemId": "JS1",
          "hidden": "true",
          "dataIndex": "TENANCY_ID",
          "text": "租户"
         },
         "expanded": false,
         "children": [],
         "type": "column"
        },
        {
         "configs": {
          "itemId": "CREATED_BY",
          "dataIndex": "CREATED_BY",
          "text": "创建人",
          "align": "left"
         },
         "expanded": false,
         "children": [],
         "type": "column"
        },
        {
         "configs": {
          "itemId": "CREATED_ON",
          "dataIndex": "CREATED_ON",
          "text": "创建日期",
          "align": "left"
         },
         "expanded": false,
         "children": [],
         "type": "column"
        },
        {
         "configs": {
          "itemId": "UPDATED_BY",
          "dataIndex": "UPDATED_BY",
          "text": "最后修改人",
          "align": "left"
         },
         "expanded": false,
         "children": [],
         "type": "column"
        },
        {
         "configs": {
          "itemId": "UPDATED_ON",
          "dataIndex": "UPDATED_ON",
          "text": "修改时间",
          "align": "left"
         },
         "expanded": false,
         "children": [],
         "type": "column"
        },
        {
         "configs": {
          "itemId": "testButton",
          "renderer": "return '<button type=\"button\" method=\"buttonMethod\" onclick=\"Wb.invoke(this,' + rowIndex + ');\">测试<\/a>';",
          "hidden": "true"
         },
         "expanded": true,
         "children": [],
         "type": "column"
        }
       ],
       "type": "array"
      },
      {
       "configs": {"itemId": "tbar"},
       "expanded": true,
       "children": [
        {
         "configs": {
          "itemId": "id",
          "labelAlign": "right",
          "emptyText": "ID、名称过滤",
          "fieldLabel": "功能过滤",
          "isUpperCase": "true",
          "labelWidth": "80"
         },
         "expanded": false,
         "children": [],
         "type": "text",
         "events": {"specialkey": "if(e.type === \"keydown\" && e.keyCode === 13)\
  app.findmenu.fireEvent('click');"}
        },
        {
         "configs": {
          "itemId": "findmenu",
          "text": "查询",
          "iconCls": "seek_icon"
         },
         "expanded": false,
         "children": [],
         "type": "item",
         "events": {"click": "\
app.tree1.store.load({out:app.tbar});//把所有数据取出来放到out里面"}
        },
        {
         "configs": {
          "itemId": "addmenu",
          "text": "添加",
          "iconCls": "record_add_icon"
         },
         "expanded": false,
         "children": [],
         "type": "item",
         "events": {"click": "var s = app.tree1.getSelection();\
if (s.length > 0) {\
  app.editwin.setTitle('添加 - 数据源功能');\
  app.editwin.setIconCls('record_add_icon');\
  app.ID.setDisabled(false);\
  app.editwin.show();\
  app.setJs(\"\");\
  var s = app.tree1.getSelection();\
  // var s=Wb.getSection(app.tree1);\
\
  app.PID.setValue(s[0].data.ID);\
  app.JNDI.setValue(\"default\");\
  app.isEdit = false; //标识是否为添加或修改状态，在editWin的ok事件中用到此属性\
} else\
  Wb.warn(\"请选中数据\");"}
        },
        {
         "configs": {
          "itemId": "modifymenu",
          "text": "修改",
          "iconCls": "record_edit_icon"
         },
         "expanded": false,
         "children": [],
         "type": "item",
         "events": {"click": "var sels = app.tree1.getSelection();\
if (sels.length != 1) {\
  Wb.warn('请选择 1 条需要修改的记录。');\
  return;\
}\
app.selRec = sels[0];\
app.editwin.setTitle('修改功能ID - ' + app.selRec.data.SOURCE_NAME);\
app.editwin.setIconCls('record_edit_icon');\
Wb.setValue(app.editwin, app.selRec.data);\
//app.ID.setDisabled(true);\
app.editwin.show();\
app.setJs(app.selRec.data.SQL);\
app.isEdit = true; //标识是否为添加或修改状态，在editWin的ok事件中用到此属性"}
        },
        {
         "configs": {
          "itemId": "deletemenu",
          "text": "删除",
          "iconCls": "record_delete_icon"
         },
         "expanded": false,
         "children": [],
         "type": "item",
         "events": {"click": "var sels = app.tree1.getSelection();\
Wb.confirmDo(sels, function() {\
  Wb.request({\
    url: 'm?xwl=system/common/report/sourceEdit/delete',\
    params: {\
      destroy: Wb.getData(sels, true)\
    },\
    success: function() {\
      Wb.remove(app.tree1, sels);\
    }\
  });\
}, 'ID');"}
        }
       ],
       "type": "toolbar"
      }
     ],
     "type": "tree"
    }],
    "type": "viewport"
   }
  ],
  "type": "module",
  "events": {"initialize": "var jndiList=Wb.decode('{#jndiList#}');\
 app.jndiList =[];\
 for(var i=0;i<jndiList.length;i++){\
 app.jndiList.push({ID:jndiList[i]});\
 }\
console.log( app.jndiList);\
app.buttonMethod = function(rowIndex) {\
  var funId = app.grid1.store.getAt(rowIndex).data.ID;\
  Wb.open({\
    url: \"/appFun?funId=\" + funId,\
    title: funId\
  });\
};\
var config = {\
 mode: 'application/xml',\
  \
    lineNumbers: true,\
    lineWrapping: true,\
    htmlMode: true,\
  //  cursorBlinkRate: -1,\
  showCursorWhenSelecting: true,\
 \
 autofocus:true,\
  theme: Wb.editTheme,\
  isServerScript: true,\
  extraKeys: {\
    'Ctrl-/': 'toggleComment',\
    'Ctrl-,': function(doc) {\
      if (doc.modifyCursor)\
        doc.setCursor(doc.modifyCursor);\
    },\
    'Shift-Ctrl-F': function(doc) {\
      if (doc.options.readOnly)\
        return;\
      var cursor = doc.getCursor(),\
        scroll = doc.getScrollInfo();\
      doc.autoFormatRange({\
        line: 0,\
        ch: 0\
      }, {\
        line: Number.MAX_VALUE,\
        ch: Number.MAX_VALUE\
      });\
      doc.scrollTo(scroll.left, scroll.top);\
      doc.setCursor(cursor);\
    },\
    'Alt-/': 'autocomplete',\
    '.': function(doc) {\
      if (doc.options.readOnly)\
        return;\
      doc.replaceSelection('.');\
      if (doc.hintTimer)\
        clearTimeout(doc.hintTimer);\
      doc.hintTimer = setTimeout(function() {\
        CodeMirror.showHint(doc);\
      }, 100);\
    }\
  }\
};\
\
Wb.apply(app, {\
  /**\
   * 设置脚本编辑器中的脚本内容。\
   * @param {String} value 脚本内容。\
   */\
  setJs: function(value) {\
    app.valueParam = value;\
    if (window.CodeMirror)\
      app.doSetJs();\
    else {\
      Wb.addLink(['wb/libs/cm/cmirror.css', 'wb/libs/cm/cmirror-debug.js'],\
        app.doSetJs\
      );\
    }\
  },\
  doSetJs: function() {\
    if (!app.editor)\
      app.renderEditor();\
    app.editor.setValue(app.valueParam || '');\
    app.editor.clearHistory();\
    setTimeout(function() {\
      app.editor.focus();\
    }, 10);\
  },\
  renderEditor: function() {\
    var comp = app.CONTENT;\
    comp.update('<textarea><\/textarea>');\
    app.editor = CodeMirror.fromTextArea(comp.el.down('textarea', true), config);\
  }\
});"}
 }],
 "roles": {
  "default": 1,
  "xlwmcgs": 1,
  "SWGCWJS": 1,
  "DHSHIP": 1,
  "SWGCWQT": 1,
  "zsadmin": 1
 },
 "title": "数据源维护",
 "iconCls": "li_icon",
 "inframe": false,
 "pageLink": ""
}