| | |
| | | drag |
| | | :auto-upload="false" |
| | | :on-change="change" |
| | | @drop.native="drop" |
| | | accept=".fbx" |
| | | > |
| | | <!-- <i class="icon el-icon-plus"></i> --> |
| | | <div class="el-upload__text">将文件拖到此处,或点击此处选择文件</div> |
| | | <div class="el-upload__tip" slot="tip"> |
| | | 只能解析.fbx文件 |
| | | </div> |
| | | <div class="el-upload__text">将.fbx文件拖到此处,或点击此处选择文件</div> |
| | | <div class="el-upload__tip" slot="tip">只能解析.fbx文件</div> |
| | | </el-upload> |
| | | </div> |
| | | </template> |
| | |
| | | change(file) { |
| | | // let $el = this.$refs.input; |
| | | // console.log($el.files[0].path); |
| | | if (!file || !file.raw || !file.raw.path) { |
| | | if (!file || !file.raw) { |
| | | return false; |
| | | } |
| | | console.log(file); |
| | | if (!/\.fbx$/.test(file.raw.name.toLowerCase().trim())) { |
| | | this.$layer.msg('类型错误'); |
| | | this.loadFile(file.raw); |
| | | }, |
| | | loadFile(file) { |
| | | if (!/\.fbx$/.test(file.name.toLowerCase().trim())) { |
| | | this.$layer.msg("类型错误"); |
| | | return false; |
| | | } |
| | | axios({ |
| | | url: "readFboFile", |
| | | method: "POST", |
| | | params: { |
| | | filePath: file.raw.path, |
| | | filePath: file.path, |
| | | }, |
| | | }).then((res) => { |
| | | res = res.data; |
| | | console.log(res, res.code, "=========res"); |
| | | if (res.code) { |
| | | let data = res.data; |
| | | data.filePath = file.raw.path; |
| | | data.filePath = file.path; |
| | | // 解析成功 跳转到结果页面 |
| | | this.$router.push({ |
| | | path: "/result", |
| | |
| | | } |
| | | }); |
| | | }, |
| | | drop(e) { |
| | | // console.log(e); |
| | | //必须要阻止拖拽的默认事件 |
| | | e.preventDefault(); |
| | | e.stopPropagation(); |
| | | |
| | | //获得拖拽的文件集合 |
| | | var files = e.dataTransfer.files; |
| | | console.log(files); |
| | | if (!files) { |
| | | return false; |
| | | } |
| | | this.loadFile(files[0]); |
| | | }, |
| | | }, |
| | | |
| | | mounted() {}, |