{"title":"CRUD基本操作","inframe":true,"hidden":false,"roles":{"demo":1,"dev":1},"pageLink":"","children":[{"configs":{"itemId":"module"},"events":{"initialize":"Wb.apply(app, {\n  doEdit: function(rec, handler) {\n    var panel = Wb.prompt({\n      title: rec ? '修改 - ' + rec.data.FIRST_NAME : '添加',\n      items: [{\n        label: '编号',\n        itemId: 'CONTACT_ID',\n        required: true\n      }, {\n        label: '名',\n        itemId: 'FIRST_NAME'\n      }, {\n        label: '姓',\n        itemId: 'LAST_NAME'\n      }, {\n        label: '注册日期',\n        xtype: 'datetimefield',\n        itemId: 'REG_DATE'\n      }],\n      handler: handler\n    });\n    if (rec)\n      Wb.setValue(panel, rec.data);\n  },\n  add: function() {\n    app.doEdit(null, function(values, panel) {\n      Wb.request({\n        url: 'm?xwl=apps/sys/demo/crud/basic/insert',\n        params: values,\n        success: function(resp) {\n          Wb.add(app.list1, values, 'first');\n          panel.destroy();\n        }\n      });\n    });\n  },\n  edit: function() {\n    var r = app.list1.getSelection()[0];\n    if (!r) {\n      Wb.warn('请选择一条记录。');\n      return;\n    }\n    app.doEdit(r, function(values, panel) {\n      Wb.request({\n        url: 'm?xwl=apps/sys/demo/crud/basic/update',\n        params: Wb.apply({\n          oldContactId: r.data.CONTACT_ID\n        }, values),\n        success: function(resp) {\n          Wb.update(r, values);\n          panel.destroy();\n        }\n      });\n    });\n  },\n  remove: function() {\n    Wb.confirmDo(app.list1.getSelection(), function() {\n      Wb.request({\n        url: 'm?xwl=apps/sys/demo/crud/basic/delete',\n        out: app.list1,\n        success: function() {\n          Wb.remove(app.list1);\n        }\n      });\n    });\n  },\n  refresh: function() {\n    app.store.load(); //不可使用app.store.reload，因为最后一次加载属于添加模式\n  }\n});"},"children":[{"configs":{"height":"160","hidden":"true","width":"180","layout":"fit","left":"0","itemId":"menu","modal":"true","top":"0","hideOnMaskTap":"true"},"children":[{"configs":{"itemTpl":"<div style='height:40px'><span class='wb_glyph'>&#x{glyph};<\/span>&nbsp;{text}<\/div>","scrollable":"false","itemId":"dataview1","padding":"8"},"events":{"itemtap":"app.menu.hide();\nrecord.get('handler')();"},"children":[{"configs":{"data":" [{\n   text: '添加',\n   glyph: 'f067',\n   handler: app.add\n }, {\n   text: '修改',\n   glyph: 'f044',\n   handler: app.edit\n }, {\n   text: '删除',\n   glyph: 'f00d',\n   handler: app.remove\n }, {\n   text: '刷新',\n   forSQL: true,\n   glyph: 'f021',\n   handler: app.refresh\n }]","itemId":"store","fields":"['text', 'glyph', 'handler']"},"children":[],"type":"tstore","expanded":false}],"type":"tdataview","expanded":true}],"type":"tpanel","expanded":true},{"configs":{"layout":"fit","itemId":"viewport1"},"children":[{"configs":{"layout":"fit","itemId":"container1"},"children":[{"configs":{"title":"联系人","docked":"top","itemId":"toolbar"},"children":[{"configs":{"glyph":"f0c9","align":"right","itemId":"menuBtn"},"events":{"tap":"app.menu.showBy(button);"},"children":[],"type":"tbutton","expanded":false}],"type":"ttitlebar","expanded":true},{"configs":{"itemTpl":"{FIRST_NAME} {LAST_NAME} ({CONTACT_ID})","autoPaging":"true","itemId":"list1"},"children":[{"configs":{"itemId":"store","autoLoad":"true","url":"m?xwl=apps/sys/demo/crud/basic/select"},"children":[],"type":"tstore","expanded":false}],"type":"tlist","expanded":true}],"type":"tcontainer","expanded":true}],"type":"tviewport","expanded":true}],"type":"module","expanded":true}],"iconCls":""}