{
 "hidden": false,
 "children": [{
  "configs": {"itemId": "module"},
  "expanded": true,
  "children": [{
   "configs": {
    "layout": "border",
    "itemId": "viewport"
   },
   "expanded": true,
   "children": [
    {
     "configs": {
      "itemId": "tbar",
      "region": "north"
     },
     "expanded": true,
     "children": [{
      "configs": {"itemId": "dockedItems"},
      "expanded": true,
      "children": [
       {
        "configs": {"itemId": "tbar1"},
        "expanded": true,
        "children": [
         {
          "configs": {
           "itemId": "searchItem",
           "text": "查询",
           "iconCls": "search_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "Wb.request({\
  url: 'm?xwl=examples/tabulator/datasource/select',\
  out:app.tbar,\
  success: function(rec) {\
//     console.log(Wb.decode(rec.responseText).rows);\
    app.table1.setData(Wb.decode(rec.responseText).rows);\
  }\
});"}
         },
         {
          "configs": {
           "itemId": "addItem",
           "text": "增加选项",
           "iconCls": "record_add_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "//获取编辑的单元格\
app.table1.addData([{\"CREATED_BY\":'{#sys.username#}',\"UPDATED_BY\":'{#sys.username#}',\
                     \"SYS_CATEGORY\":\"\",\"CREATED_ON\":new Date().toLocaleString(),\
                     \"ID\":Wb.getUuid(),\"SYS_VALUE\":\"\",\"UPDATED_ON\":new Date().toLocaleString(),\
                     \"SYS_KEY\":\"\",\"SYS_SEQ\":0}],true);"}
         },
         {
          "configs": {
           "itemId": "delItem",
           "text": "删除选项",
           "iconCls": "record_delete_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "//获取编辑的单元格\
const rows = app.table1.getSelectedRows();\
if (rows.length > 0) {\
  rows.forEach(function(v) {\
    v.delete();\
  })\
}"}
         },
         {
          "configs": {
           "itemId": "getDataAllItem",
           "text": "获取表中全部数据",
           "iconCls": "book_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "console.log(app.table1.getData());"}
         },
         {
          "configs": {
           "itemId": "getSelectedDataItem",
           "text": "获取选中行数据",
           "iconCls": "book_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "//获取数据\
console.log(app.table1.getSelectedData());\
//获取选中行组件\
// console.log(app.table1.getSelectedRows());"}
         },
         {
          "configs": {
           "itemId": "getEditedDataItem",
           "text": "获取编辑数据",
           "iconCls": "book_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "//获取编辑的单元格\
console.log(app.table1.getEditedCells());"}
         },
         {
          "configs": {
           "itemId": "getEditedDataItem1",
           "text": "获取编辑历史",
           "iconCls": "book_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "//获取编辑的单元格\
const history = app.table1.modules.history.history;\
console.log(history);\
console.log(getEditedResult(history));\
//如果获取编辑后数据\
function getEditedResult(h) {\
  const result = {\
    create: [],\
    update: [],\
    destroy: []\
  };\
  h.forEach(function(v) {\
    if (v.type === \"rowAdd\") {\
      result.create.push(v.data.data);\
    }\
    if (v.type === \"rowDelete\") {\
      result.destroy.push(v.data.data);\
    }\
    if (v.type === \"cellEdit\") {\
      if (result.update.indexOf(v.component.row.data) === -1) {\
        result.update.push(v.component.row.data);\
      }\
    }\
  });\
  return result;\
}"}
         },
         {
          "configs": {
           "itemId": "downloadAllItem",
           "text": "下载全部数据至xlxs",
           "iconCls": "book_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "app.table1.download(\"xlsx\", \"data.xlsx\", {sheetName:\"MyData\"});"}
         },
         {
          "configs": {
           "itemId": "downloadSelectedItem",
           "text": "下载选中数据xlxs",
           "iconCls": "book_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "//获取编辑的单元格\
app.table1.download(\"xlsx\", \"data.xlsx\", {sheetName:\"MyData\"},\"selected\");"}
         }
        ],
        "type": "toolbar"
       },
       {
        "configs": {"itemId": "tbar2"},
        "expanded": true,
        "children": [{
         "configs": {
          "itemId": "categray",
          "labelAlign": "right",
          "fieldLabel": "代码类别",
          "labelWidth": "50"
         },
         "expanded": false,
         "children": [],
         "type": "text"
        }],
        "type": "toolbar"
       }
      ],
      "type": "array"
     }],
     "type": "panel"
    },
    {
     "configs": {
      "layout": "fit",
      "itemId": "tablePanel",
      "region": "center"
     },
     "expanded": false,
     "children": [],
     "type": "panel",
     "events": {"afterrender": "app.table1 = new Tabulator(\"#\" + panel.id, {\
  locale: true,\
  //如果是分页 设置小于100%否则wb导致无法显示分页footer\
  height: \"100%\",\
  history:true,\
  //开启选中模式\
  selectable: true,\
  columns: [{\
    formatter: \"rowSelection\",\
    titleFormatter: \"rowSelection\",\
    hozAlign: \"center\",\
    headerSort: false,\
    //无需导出列\
    download: false,\
    cellClick: function(e, cell) {\
      cell.getRow().toggleSelect();\
    }\
  }, {\
    title: \"序号\",\
    formatter: \"rownum\",\
    hozAlign: \"center\",\
    headerSort:false\
  }, {\
    title: \"类别\",\
    field: \"SYS_CATEGORY\",\
    sorter: \"string\",\
    headerFilter: true,\
    //wb导致input search无法使用回退键\
    headerFilterLiveFilter: false,\
    //可编辑\
    editor: \"input\"\
  }, {\
    title: \"key\",\
    field: \"SYS_KEY\",\
    sorter: \"string\",\
    headerFilter: true,\
    editor: \"input\"\
  }, {\
    title: \"value\",\
    field: \"SYS_VALUE\",\
    sorter: \"string\",\
    headerFilter: true,\
    editor: \"input\"\
  }, {\
    title: \"代码序号\",\
    field: \"SYS_SEQ\",\
    sorter: \"number\",\
    headerFilter: true,\
    editor: \"number\"\
  }, {\
    title: \"创建人\",\
    field: \"CREATED_BY\",\
    sorter: \"string\"\
  }, {\
    title: \"创建时间\",\
    field: \"CREATED_ON\",\
    sorter: \"string\"\
  }, {\
    title: \"修改人\",\
    field: \"UPDATED_BY\",\
    sorter: \"string\"\
  }, {\
    title: \"修改时间\",\
    field: \"UPDATED_ON\",\
    sorter: \"string\"\
  }]\
});"}
    }
   ],
   "type": "viewport"
  }],
  "type": "module"
 }],
 "roles": {"default": 1},
 "title": "进阶编辑",
 "iconCls": "",
 "inframe": false,
 "pageLink": ""
}