{"hidden":false,"children":[{"configs":{"itemId":"module"},"expanded":true,"children":[{"configs":{"baseParams":"{abc:123}","layout":"absolute","itemId":"form1","width":"456","height":"160"},"expanded":true,"children":[{"configs":{"allowBlank":"false","itemId":"file1","labelAlign":"right","fieldLabel":"上传文件","width":"360","x":"32","y":"24","height":"22"},"expanded":false,"children":[],"type":"file"},{"configs":{"itemId":"text1","labelAlign":"right","fieldLabel":"其他参数","width":"360","x":"32","y":"56","height":"22"},"expanded":false,"children":[],"type":"text"},{"configs":{"itemId":"successBtn","width":"88","x":"16","y":"96","text":"上传成功","height":"22"},"expanded":false,"children":[],"type":"button","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/file/download-upload/process-upload&type=1',\n  //out:[panel1, grid1],以控件列表的方式上传指定控件值\n  //showMask: false,上传过程不显示mask\n  //message: '正在上传中...',\n  //mask: app.form1, //mask遮盖对象，未指定默认为全屏，前2秒透明遮盖。\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});"}},{"configs":{"itemId":"failBtn","width":"88","x":"128","y":"96","text":"上传失败","height":"22"},"expanded":false,"children":[],"type":"button","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/file/download-upload/process-upload&type=2'\n});"}},{"configs":{"itemId":"uploadDownloadBtn","width":"88","x":"240","y":"96","text":"上传后下载","height":"22"},"expanded":false,"children":[],"type":"button","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});"}},{"configs":{"itemId":"downloadBtn","width":"88","x":"352","y":"96","text":"直接下载","height":"22"},"expanded":false,"children":[],"type":"button","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 指定是否是上传模式方式编码*/ );"}}],"type":"form"}],"type":"module"}],"roles":{"demo":1},"title":"上传下载","iconCls":"","inframe":false,"pageLink":""}