{"title":"上传下载","inframe":false,"hidden":false,"roles":{"demo":1,"dev":1},"pageLink":"","children":[{"configs":{"itemId":"module"},"children":[{"configs":{"height":"160","baseParams":"{abc:123}","layout":"absolute","width":"456","itemId":"form1"},"children":[{"configs":{"height":"22","allowBlank":"false","width":"360","labelAlign":"right","itemId":"file1","fieldLabel":"上传文件","y":"24","x":"32"},"children":[],"type":"file","expanded":false},{"configs":{"height":"22","width":"360","labelAlign":"right","itemId":"text1","fieldLabel":"其他参数","y":"56","x":"32"},"children":[],"type":"text","expanded":false},{"configs":{"text":"上传成功","height":"22","width":"88","itemId":"successBtn","y":"96","x":"16"},"events":{"click":"//文件上传必须使用form控件,form控件可以嵌套在任何容器中，包括panel,window和viewport等。\nif (!Wb.verify(app.form1)) //验证值是否合法\n  return;\n//上传数据。此方法采用multipart/form-data编码上传数据，因此后台必须通过request.getAttribute(itemId)获取指定控件数据\nWb.upload({\n  form: app.form1, //上传的表单控件，必选项\n  showProgress: true, //显示上传进度条\n  url: 'm?xwl=examples/basic/data-submit/download-upload/process-upload&type=1',\n  //out:[panel1, grid1],以控件列表的方式上传指定控件值\n  //showMask: false,上传过程不显示mask\n  //message: '正在上传中...',\n  //mask: app.form1, //mask遮盖对象，未指定默认为全屏，前1.5秒透明遮盖。\n  params: { //以json对象表达的参数列表\n    foo: 'bar',\n    num: 123,\n    date: new Date()\n  },\n  //上传成功之后的回调方法\n  success: function(form, action, value) {\n    //value为服务器返回的值，action.response.responseText为服务器返回的原始值\n    Wb.info(value);\n  }\n});"},"children":[],"type":"button","expanded":false},{"configs":{"text":"上传失败","height":"22","width":"88","itemId":"failBtn","y":"96","x":"128"},"events":{"click":"if (!Wb.verify(app.form1))\n  return;\n//此操作将触发后台异常，但前台不会重置，类似ajax效果。\nWb.upload({\n  form: app.form1,\n  //showError: false,屏蔽自动显示的错误信息\n  url: 'm?xwl=examples/basic/data-submit/download-upload/process-upload&type=2'\n});"},"children":[],"type":"button","expanded":false},{"configs":{"text":"上传后下载","height":"22","width":"88","itemId":"uploadDownloadBtn","y":"96","x":"240"},"events":{"click":"if (!Wb.verify(app.form1)) //验证值是否合法\n  return;\nWb.upload({\n  form: app.form1,\n  showMask: false, //如果上传后下载文件，必须设置为false，否则下载后无法移除mask。（因为下载不会触发回调）\n  url: 'download', //公共下载服务 m?xwl=sys/service/download\n  params: {\n    files: ['wb/images/site/wb.gif']\n  }\n});"},"children":[],"type":"button","expanded":false},{"configs":{"text":"直接下载","height":"22","width":"88","itemId":"downloadBtn","y":"96","x":"352"},"events":{"click":"//该示例演示使用Wb.download方法下载文件，第一个参数为url，第二参数为参数对象，具体见Wb.download文档\n//使用普通编码下载的在后台使用request.getParameter获取参数，文件上传模式使用request.getAttribute获取参数\nWb.download('download', {\n  files: ['wb/images/site/wb.gif'],\n  foo: 'bar'\n} /*,isUpload 指定是否是上传模式方式编码*/ );"},"children":[],"type":"button","expanded":false}],"type":"form","expanded":true}],"type":"module","expanded":true}],"iconCls":""}