1.递归方法实现树形结构
1formatCompanyTree(data, id) { 2 const newData = data.filter( 3 item => item.pid == id 4 ).map(item => ({ 5 ...item, 6 disabled: item.nodetype != '4', 7 children: this.formatCompanyTree(data, item.id) 8 })) 9 return newData 10 }, 11 12//data为后台请求回来的树形数据,id为树形数据的最外层节点的id 13 14 15 16
2.elementUI文件上传
1 uploadFile(file) { 2 const fileData = new FormData() 3 // 需要的参数 4 fileData.append('file', file.file) 5 fileData.append('resourceType', that.resourceType) 6 fileData.append('receiptsinfoId', that.receiptsinfoId) 7 this.$api 8 .uploadFile(fileData) 9 .then(res => { 10 if (res.code == 0) { 11 that.$message({ 12 type: 'success', 13 message: '上传成功!' 14 }) 15 } 16 }) 17 },
