{
 "hidden": false,
 "children": [{
  "configs": {
   "serverScript": "var sd=new Date();",
   "itemId": "module"
  },
  "expanded": true,
  "children": [
   {
    "configs": {"itemId": "seltbar"},
    "expanded": true,
    "children": [
     {
      "configs": {
       "itemId": "item31",
       "flex": "1",
       "disabled": "true"
      },
      "expanded": false,
      "children": [],
      "type": "item",
      "events": {"click": "app.selWin.hide();"}
     },
     {
      "configs": {
       "itemId": "item1",
       "text": "添加",
       "iconCls": "file_add_icon"
      },
      "expanded": false,
      "children": [],
      "type": "item",
      "events": {"click": "var vartextarea4, store = Ext.create('Ext.data.Store', { //关系\
  fields: ['ID', 'NAME'],\
  data: [{\
    \"ID\": \"and\",\
    \"NAME\": \"并且\"\
  }, {\
    \"ID\": \"or\",\
    \"NAME\": \"或者\"\
  }]\
});\
var vartextarea =\
  Ext.create('Ext.form.ComboBox', { //关系\
    store: store,\
    queryMode: 'local',\
    displayField: 'NAME',\
    valueField: 'ID',\
    renderTo: Ext.getBody(),\
    id: 'R_' + countMore,\
    width: 60,\
    height: '22',\
    value: 'and',\
    x: 0,\
    y: 4 + ((counnts.length + 1) * 26),\
    name: 'R_' + countMore\
  });\
var vartextarea1 = new Ext.form.field.Text({ //左括号\
  id: 'LEFT_' + countMore,\
  width: 50,\
  height: '22px',\
  x: 64,\
  y: 4 + ((counnts.length + 1) * 26),\
  name: 'R_' + countMore\
});\
store = app.getStoreList();\
var vartextarea2 = Ext.create('Ext.form.ComboBox', { //字段名\
  id: 'COLUMN_' + countMore,\
  store: store,\
  queryMode: 'local',\
  displayField: 'NAME',\
  valueField: 'ID',\
  renderTo: Ext.getBody(),\
  width: 100,\
  height: '22px',\
  x: 118,\
  y: 4 + ((counnts.length + 1) * 26),\
  name: 'R_' + countMore,\
  listeners: {\
    'select': function(r) {\
      var ID = this.id;\
      var dataArray = new Array();\
      Wb.each(app.moreGrid.columns, function(c) {\
        if (typeof(c.keyItems) != \"undefined\" && c.dataIndex == r.value) {\
          dataArray = c.keyItems;\
        }\
      });\
      var li = ID.replace(\"COLUMN_\", \"\");\
      var textColumn = Ext.getCmp(\"VALUE_\" + li);\
      var xx = textColumn.x,\
        yy = textColumn.y;\
      textColumn.destroy();\
      vartextarea4.destroy();\
      if (dataArray.length > 0) {\
        var store = Ext.create('Ext.data.Store', { //关系\
          fields: ['K', 'V'],\
          data: dataArray\
        });\
        vartextarea4 = Ext.create('Ext.form.ComboBox', { //值\
          id: 'VALUE_' + li,\
          store: store,\
          queryMode: 'local',\
          displayField: 'V',\
          valueField: 'K',\
          renderTo: Ext.getBody(),\
          width: 100,\
          height: '22px',\
          x: xx,\
          y: yy,\
          name: 'R_' + countMore\
        });\
\
      } else {\
        vartextarea4 = new Ext.form.field.Text({ //值\
          id: 'VALUE_' + li,\
          width: 100,\
          height: '22px',\
          x: xx,\
          y: yy,\
          name: 'R_' + countMore\
        });\
      }\
      app.morePanel.add(vartextarea4);\
    }\
  }\
});\
var store = Ext.create('Ext.data.Store', { //关系\
  fields: ['ID', 'NAME'],\
  data: [{\
    'ID': '=',\
    'NAME': '='\
  }, {\
    'ID': '<>',\
    'NAME': '<>'\
  }, {\
    'ID': '<',\
    'NAME': '<'\
  }, {\
    'ID': '<',\
    'NAME': '>'\
  }, {\
    'ID': \"like '|%'\",\
    'NAME': '以...开头'\
  }, {\
    'ID': \"like '%|'\",\
    'NAME': '以...结尾'\
  }, {\
    'ID': \"like '%|%'\",\
    'NAME': '包含字符'\
  }, {\
    'ID': \"not like '%|%'\",\
    'NAME': '不包含字符'\
  }, {\
    'ID': 'is null',\
    'NAME': '空白'\
  }, {\
    'ID': 'is not null',\
    'NAME': '非空白'\
  }]\
});\
var vartextarea3 = Ext.create('Ext.form.ComboBox', { //运算符\
  id: 'OPERATOR_' + countMore,\
  store: store,\
  queryMode: 'local',\
  displayField: 'NAME',\
  valueField: 'ID',\
  renderTo: Ext.getBody(),\
  width: 80,\
  value: '=',\
  height: '22px',\
  x: 222,\
  y: 4 + ((counnts.length + 1) * 26),\
  name: 'R_' + countMore\
\
});\
var vartextarea4 = new Ext.form.field.Text({ //值\
  id: 'VALUE_' + countMore,\
  width: 100,\
  height: '22px',\
  x: 306,\
  y: 4 + ((counnts.length + 1) * 26),\
  name: 'R_' + countMore\
});\
var vartextarea5 = new Ext.form.field.Text({ //右括号\
  id: 'RIGHT_' + countMore,\
  width: 50,\
  height: '22px',\
  x: 410,\
  y: 4 + ((counnts.length + 1) * 26),\
  name: 'R_' + countMore\
});\
\
var store = Ext.create('Ext.data.Store', { //字符类型\
  fields: ['ID', 'NAME'],\
  data: [{\
    'ID': 'DATE',\
    'NAME': '日期'\
  }, {\
    'ID': 'STRING',\
    'NAME': '字符串'\
  }, {\
    'ID': 'NUMBER',\
    'NAME': '数字'\
  }]\
});\
var vartextarea7 = Ext.create('Ext.form.ComboBox', { //运算符\
  id: 'VTYPE_' + countMore,\
  store: store,\
  queryMode: 'local',\
  displayField: 'NAME',\
  valueField: 'ID',\
  renderTo: Ext.getBody(),\
  width: 80,\
  height: '22px',\
  value: 'STRING',\
  x: 464,\
  y: 4 + ((counnts.length + 1) * 26),\
  name: 'VTYPE_' + countMore\
\
});\
var vartextarea6 = new Ext.Button({ //右括号\
  id: 'DEL_' + countMore,\
  width: 60,\
  height: '22px',\
  x: 548,\
  y: 4 + ((counnts.length + 1) * 26),\
  text: '删除本行',\
  name: 'DEL_' + countMore,\
  onClick: function(e) {\
    vartextarea.destroy();\
    vartextarea1.destroy();\
    vartextarea2.destroy();\
    vartextarea3.destroy();\
    vartextarea4.destroy();\
    vartextarea5.destroy();\
    vartextarea6.destroy();\
    vartextarea7.destroy();\
    // alert( vartextarea6.nextNode().getPosition());\
    var li = this.id.replace(\"DEL_\", \"\");\
    counnts.remove(li);\
    for (var i = 0; i < counnts.length; i++) {\
      if (counnts[i] > li) {\
        // alert(Ext.getCmp(\"R_\"+counnts[i]).y);\
        Ext.getCmp(\"R_\" + counnts[i]).setPosition(Ext.getCmp(\"R_\" + counnts[i]).x, Ext.getCmp(\"R_\" + counnts[i]).y - 26);\
        Ext.getCmp(\"LEFT_\" + counnts[i]).setPosition(Ext.getCmp(\"LEFT_\" + counnts[i]).x, Ext.getCmp(\"LEFT_\" + counnts[i]).y - 26);\
        Ext.getCmp(\"COLUMN_\" + counnts[i]).setPosition(Ext.getCmp(\"COLUMN_\" + counnts[i]).x, Ext.getCmp(\"COLUMN_\" + counnts[i]).y - 26);\
        Ext.getCmp(\"OPERATOR_\" + counnts[i]).setPosition(Ext.getCmp(\"OPERATOR_\" + counnts[i]).x, Ext.getCmp(\"OPERATOR_\" + counnts[i]).y - 26);\
        Ext.getCmp(\"VALUE_\" + counnts[i]).setPosition(Ext.getCmp(\"VALUE_\" + counnts[i]).x, Ext.getCmp(\"VALUE_\" + counnts[i]).y - 26);\
        Ext.getCmp(\"DEL_\" + counnts[i]).setPosition(Ext.getCmp(\"DEL_\" + counnts[i]).x, Ext.getCmp(\"DEL_\" + counnts[i]).y - 26);\
        Ext.getCmp(\"RIGHT_\" + counnts[i]).setPosition(Ext.getCmp(\"RIGHT_\" + counnts[i]).x, Ext.getCmp(\"RIGHT_\" + counnts[i]).y - 26);\
        Ext.getCmp(\"VTYPE_\" + counnts[i]).setPosition(Ext.getCmp(\"VTYPE_\" + counnts[i]).x, Ext.getCmp(\"VTYPE_\" + counnts[i]).y - 26);\
\
      }\
\
    }\
  }\
});\
/*\
var vartextarea6 =  new Ext.Button({//右括号\
\tid:'DEL_'+countMore,\
\twidth:60,\
\theight:'22px',\
    x:608,\
 \ty:4+((counnts.length+1)*26),\
    text: '删除本行',\
\tname: 'DEL_'+countMore,\
    onClick: function(e) {\
        alert( vartextarea.x+\"==\"+vartextarea.width);\
        alert( vartextarea1.x+\"==\"+vartextarea1.width);\
       alert( vartextarea2.x+\"==\"+vartextarea2.width);\
        alert( vartextarea3.x+\"==\"+vartextarea3.width);\
        alert( vartextarea4.x+\"==\"+vartextarea4.width);\
        alert( vartextarea5.x+\"==\"+vartextarea5.width);\
      alert( vartextarea6.x+\"==\"+vartextarea6.width);\
    }});*/\
app.morePanel.add(vartextarea);\
app.morePanel.add(vartextarea1);\
app.morePanel.add(vartextarea2);\
app.morePanel.add(vartextarea3);\
app.morePanel.add(vartextarea4);\
app.morePanel.add(vartextarea5);\
app.morePanel.add(vartextarea7);\
app.morePanel.add(vartextarea6);\
app.morePanel.doLayout();\
counnts.push(countMore);\
\
countMore++;"}
     },
     {
      "configs": {
       "itemId": "item2",
       "text": "确认",
       "iconCls": "record_edit_icon"
      },
      "expanded": false,
      "children": [],
      "type": "item",
      "events": {"click": "var whereSql = \" \",\
  spec = \" \";\
for (var i = 0; i < counnts.length; i++) {\
  var li = counnts[i]; //标签位数\
\
  var r = Ext.getCmp(\"R_\" + li).getValue();\
  var left = Ext.getCmp(\"LEFT_\" + li).getValue();\
  var column = Ext.getCmp(\"COLUMN_\" + li).getValue();\
  var operator = Ext.getCmp(\"OPERATOR_\" + li).getValue();\
  var value = Ext.getCmp(\"VALUE_\" + li).getValue();\
  var right = Ext.getCmp(\"RIGHT_\" + li).getValue();\
  var vtype = Ext.getCmp(\"VTYPE_\" + li).getValue();\
  if (vtype == 'DATE')\
    column = \"to_char('\" + column + \"','yyyy-mm-dd')\";\
\
  if (vtype == 'STRING')\
    value = \"'\" + value + \"'\";\
  if (operator == \"like '|%'\") {\
    operator = ' like ';\
    value = value + \"||'%'\";\
  } else if (operator == \"like '%|'\") {\
    operator = ' like ';\
    value = \"'%'||\" + value;\
  } else if (operator == \"like '%|%'\") {\
    operator = ' like ';\
    value = \"'%'||\" + value + \"||'%'\";\
  } else if (operator == \"not like '%|%'\") {\
    operator = ' not like ';\
    value = \"'%'||\" + value + \"||'%'\";\
  }\
  whereSql += r + spec + left + spec + column + spec + operator + value + spec + right;\
}\
app.whereSql = whereSql;\
contextOwner.moreSql(whereSql);"}
     },
     {
      "configs": {
       "itemId": "item3",
       "text": "取消",
       "iconCls": "record_delete_icon"
      },
      "expanded": false,
      "children": [],
      "type": "item",
      "events": {"click": "app.selWin.hide();"}
     }
    ],
    "type": "toolbar"
   },
   {
    "configs": {
     "layout": "absolute",
     "itemId": "selWin",
     "dialog": "true",
     "closeAction": "hide",
     "width": "682",
     "title": "组合查询条件",
     "height": "280"
    },
    "expanded": true,
    "children": [{
     "configs": {
      "layout": "absolute",
      "border": "false",
      "itemId": "morePanel",
      "width": "662",
      "x": "0",
      "y": "0",
      "autoScroll": "true",
      "height": "240",
      "frame": "true",
      "bbar": "app.seltbar"
     },
     "expanded": true,
     "children": [
      {
       "configs": {
        "itemId": "label1",
        "width": "50",
        "x": "8",
        "y": "8",
        "text": "关系",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "label"
      },
      {
       "configs": {
        "itemId": "label11",
        "width": "50",
        "x": "64",
        "y": "8",
        "text": "括号",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "label"
      },
      {
       "configs": {
        "itemId": "label111",
        "width": "100",
        "x": "120",
        "y": "8",
        "text": "字段",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "label"
      },
      {
       "configs": {
        "itemId": "label1111",
        "width": "82",
        "x": "224",
        "y": "8",
        "text": "关系符",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "label"
      },
      {
       "configs": {
        "itemId": "label11111",
        "width": "100",
        "x": "312",
        "y": "8",
        "text": "值",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "label"
      },
      {
       "configs": {
        "itemId": "label12",
        "width": "50",
        "x": "416",
        "y": "8",
        "text": "括号",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "label"
      },
      {
       "configs": {
        "itemId": "label121",
        "width": "50",
        "x": "468",
        "y": "8",
        "text": "值类型",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "label"
      }
     ],
     "type": "panel"
    }],
    "type": "window",
    "events": {
     "beforehide": "/* for(var i=0;i<counnts.length;i++){\
     \
         // alert(Ext.getCmp(\"R_\"+counnts[i]).y);\
        Ext.getCmp(\"R_\"+counnts[i]).destroy();\
        Ext.getCmp(\"LEFT_\"+counnts[i]).destroy();\
        Ext.getCmp(\"COLUMN_\"+counnts[i]).destroy();\
        Ext.getCmp(\"OPERATOR_\"+counnts[i]).destroy();\
        Ext.getCmp(\"VALUE_\"+counnts[i]).destroy();\
        Ext.getCmp(\"DEL_\"+counnts[i]).destroy();\
        Ext.getCmp(\"RIGHT_\"+counnts[i]).destroy();\
        Ext.getCmp(\"VTYPE_\"+counnts[i]).destroy();\
      \
      }\
countMore=1;\
counnts=new Array();*/",
     "show": "\
app.selWin.down('[iconCls=ok_icon]').hide();\
app.selWin.down('[iconCls=cancel_icon]').hide();"
    }
   }
  ],
  "type": "module",
  "events": {"initialize": "var countMore = 1,\
  storeList;\
\
var counnts = [];\
Array.prototype.indexOf = function(val) {\
  for (var i = 0; i < this.length; i++) {\
    if (this[i] == val) return i;\
  }\
  return -1;\
};\
\
Array.prototype.remove = function(val) {\
  var index = this.indexOf(val);\
  if (index > -1) {\
    this.splice(index, 1);\
  }\
};\
Wb.apply(app, {\
  whereSql: null,\
  moreGrid: null,\
  getStoreList: function() {\
    var datas = [];\
    var dataArray = [];\
    Wb.each(app.moreGrid.columns, function(c) {\
      var filename = c.dataIndex;\
      var text = c.text;\
      datas.push({\
        'ID': filename,\
        'NAME': text\
      });\
      if (text)\
        dataArray.push({\
          'K': filename,\
          'V': text\
        });\
    });\
    storeList = Ext.create('Ext.data.Store', {\
      storeId: 'store',\
      fields: ['ID', 'NAME'],\
      data: datas\
    });\
    return storeList;\
  }\
\
\
});"}
 }],
 "roles": {
  "default": 1,
  "DHSHIP": 1
 },
 "title": "高级查询",
 "iconCls": "law_icon",
 "inframe": false,
 "pageLink": ""
}