d2-crud-plus icon indicating copy to clipboard operation
d2-crud-plus copied to clipboard

功能开发 | 插件的整合导入和导出功能添加到项目模块中

Open arraycto opened this issue 4 years ago • 1 comments

 项目背景:人力项目,表格复杂,导出导出比较奇葩。

插件版本:crud-plus:目前最新版 vxe-table:3.0.8 版本

问题:目前已经使用crud-plus集成到项目中,客户非常满意。同时提出了复杂的导入导出需求,发现vxe-table能满足,但是二者无法有机的结合在一起(已经看了大佬例子中的vxe-table例子,略有不同),实现的效果如下:想兼容他的导入和导出,如下 地址:https://xuliangzhan_admin.gitee.io/vxe-table/#/table/grid/fullEdit

image

麻烦大佬提供一个二者兼容的思路,非常感谢。麻烦您了

arraycto avatar Dec 06 '20 13:12 arraycto

vxe-table示例中的导入也是直接导入到后台然后刷新数据,这个你自己做就好了

   importMethod ({ file }) {
              // 处理表单
              const formBody = new FormData()
              formBody.append('file', file)
              // 上传文件
              return XEAjax.post('https://api.xuliangzhan.com:10443/api/pub/import', formBody).then(data => {
                this.$XModal.message({ message: `成功导入 ${data.result.insertRows} 条记录!`, status: 'success' })
                // 导入完成,刷新表格
                this.$refs.xGrid.commitProxy('query')
              }).catch(() => {
                this.$XModal.message({ message: '导入失败,请检查数据是否正确!', status: 'error' })
              })
            },

greper avatar Dec 14 '20 14:12 greper