Commit a9fa7fc7 authored by shuaiqiang's avatar shuaiqiang 🇨🇳

refactor:调整文件拖拽问题

parent ebfe74d3
import service from '@utils/GraphApiService' import service from '@utils/GraphApiService'
export function CnConversionPCT(baseURL, data) { // export function CnConversionPCT(baseURL, data) {
// return service({
// baseURL: baseURL,
// url: 'Word/CN2PCT',
// method: 'post',
// data
// })
// }
export function fetchPctToCn(baseURL, data) {
return service({ return service({
baseURL: baseURL, baseURL: baseURL,
url: 'Word/CN2PCT', url: 'Word/PCT2CN',
method: 'post', method: 'POST',
data data
}) })
} }
export function fetchDownloadFile(baseURL, params) { // export function fetchConvertEquations(baseURL, data) {
return service({
baseURL: baseURL,
url: 'RequestPayment/DownloadFile',
method: 'get',
responseType: 'blob',
params
})
}
// export function CnConversionPCT(baseURL, data) {
// return service({ // return service({
// baseURL: baseURL, // baseURL: baseURL,
// url: 'Word/CN2PCT', // url: 'Word/ConvertEquations',
// method: 'post', // method: 'POST',
// data // data
// }) // })
// } // }
\ No newline at end of file
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
<div id="app"> <div id="app">
Hi app Hi app
<pLink type="primary">Test</pLink> <pLink type="primary">Test</pLink>
<!-- <splitTool env="dev_test_sz"></splitTool> --> <splitTool env="dev_test_sz"></splitTool>
<!-- <convertTool env="dev_test_sz"></convertTool> --> <convertTool env="dev_test_sz"></convertTool>
<!-- <upload env="dev_file_sz"></upload> --> <fileSplit env="dev_file_sz"></fileSplit>
<upload env="dev_file_sz"></upload>
<uploadExcel env="dev_test_sz"></uploadExcel> <uploadExcel env="dev_test_sz"></uploadExcel>
<!-- <fileSplit env="dev_file_sz"></fileSplit> -->
</div> </div>
</template> </template>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
:on-remove="handleFileRemove" :on-remove="handleFileRemove"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:auto-upload="false" :auto-upload="false"
accept="application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" accept=".docx, .doc"
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
<div class="el-upload__text"> <div class="el-upload__text">
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
</div> </div>
</template> </template>
<script> <script>
import { CnConversionPCT,fetchDownloadFile } from "@api/convertApi";
import GraphApiService from '@utils/GraphApiService' import GraphApiService from '@utils/GraphApiService'
export default { export default {
name: 'Cn2CpcForm', name: 'Cn2CpcForm',
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
:on-remove="handleFileRemove" :on-remove="handleFileRemove"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:auto-upload="false" :auto-upload="false"
accept="application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" accept=".docx, .doc"
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
<div class="el-upload__text"> <div class="el-upload__text">
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
</div> </div>
</template> </template>
<script> <script>
import { CnConversionPCT,fetchDownloadFile } from "@api/convertApi";
import GraphApiService from '@utils/GraphApiService' import GraphApiService from '@utils/GraphApiService'
export default { export default {
name: 'Cn2PctForm', name: 'Cn2PctForm',
...@@ -78,7 +77,6 @@ export default { ...@@ -78,7 +77,6 @@ export default {
this.fileList.forEach(e => { this.fileList.forEach(e => {
formData.append('file', e.raw) formData.append('file', e.raw)
}) })
console.log(this.baseUrl)
GraphApiService GraphApiService
.post('Word/CN2PCT', formData) .post('Word/CN2PCT', formData)
.then(res => { .then(res => {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
:on-remove="handleFileRemove" :on-remove="handleFileRemove"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:auto-upload="false" :auto-upload="false"
accept="application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" accept=".docx, .doc"
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
<div class="el-upload__text"> <div class="el-upload__text">
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
</template> </template>
<script> <script>
import GraphApiService from '@utils/GraphApiService' import GraphApiService from '@utils/GraphApiService'
import { fetchPctToCn } from '@api/convertApi'
export default { export default {
name: 'Cn2CpcForm', name: 'Cn2CpcForm',
data: function() { data: function() {
...@@ -64,7 +64,7 @@ export default { ...@@ -64,7 +64,7 @@ export default {
}, },
methods: { methods: {
// 上传到服务器 // 上传到服务器
submitUpload() { async submitUpload() {
console.log(this.fileList) console.log(this.fileList)
if (this.fileList.length <= 0) { if (this.fileList.length <= 0) {
this.$message.error('请先选择需要上传的文件!') this.$message.error('请先选择需要上传的文件!')
...@@ -74,13 +74,12 @@ export default { ...@@ -74,13 +74,12 @@ export default {
this.fileList.forEach(e => { this.fileList.forEach(e => {
formData.append('file', e.raw) formData.append('file', e.raw)
}) })
GraphApiService
.post('Word/PCT2CN', formData) const response = await fetchPctToCn(this.baseUrl, formData)
.then(res => { if (response.status === 200) {
if (res.status === 200) {
this.fileList = [] this.fileList = []
this.$refs.upload.clearFiles() this.$refs.upload.clearFiles()
const excelFileName = res.data const excelFileName = response.data
GraphApiService GraphApiService
.get('RequestPayment/DownloadFile', { .get('RequestPayment/DownloadFile', {
params: { params: {
...@@ -88,8 +87,8 @@ export default { ...@@ -88,8 +87,8 @@ export default {
}, },
responseType: 'blob' responseType: 'blob'
}) })
.then(response => { .then(res => {
const blob = new Blob([response]) const blob = new Blob([res])
const downloadElement = document.createElement('a') const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob) const href = window.URL.createObjectURL(blob)
downloadElement.href = href downloadElement.href = href
...@@ -103,13 +102,7 @@ export default { ...@@ -103,13 +102,7 @@ export default {
this.$refs.upload.abort() this.$refs.upload.abort()
this.$message.error('下载档案失败!') this.$message.error('下载档案失败!')
} }
console.log(res.data) console.log(response.data)
})
.catch(error => {
console.log('error', error)
this.$refs.upload.abort()
this.$message.error('下载档案失败!')
})
}, },
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用 // 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
handelFileChange(file, fileList) { handelFileChange(file, fileList) {
......
...@@ -75,13 +75,13 @@ ...@@ -75,13 +75,13 @@
</div> </div>
</template> </template>
<script> <script>
// import { SplitRevisionDoc } from '@api/fileApi' import { SplitRevisionDoc } from '@api/fileApi'
import { mixins } from "../mixin/toolMixin"; import { mixins } from "../mixin/toolMixin";
import service from '@utils/requestService' import service from '@utils/requestService'
export default { export default {
name: 'SplitWordForm', name: 'SplitWordForm',
mixins:["mixin"], mixins:["mixins"],
props:{ props:{
baseUrl:{ baseUrl:{
type: String type: String
...@@ -176,8 +176,7 @@ export default { ...@@ -176,8 +176,7 @@ export default {
// formData.append('claimPageRange', '') // formData.append('claimPageRange', '')
// formData.append('figPageRange', '') // formData.append('figPageRange', '')
// } // }
const response = await service.post(`api/v1.0/Word/SplitRevisionDoc`, formData) const response = await SplitRevisionDoc(this.baseUrl, formData)
// const response = await SplitRevisionDoc(this.baseUrl, formData)
if (response) { if (response) {
this.fileList = [] this.fileList = []
this.$refs.upload.clearFiles() this.$refs.upload.clearFiles()
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
:on-change="handelDetailFileChange" :on-change="handelDetailFileChange"
:on-remove="handleDetailFileRemove" :on-remove="handleDetailFileRemove"
:auto-upload="false" :auto-upload="false"
accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" accept=".xls, .xlsx"
multiple multiple
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
:on-change="handelFileChange" :on-change="handelFileChange"
:on-remove="handleFileRemove" :on-remove="handleFileRemove"
:auto-upload="false" :auto-upload="false"
accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" accept=".xls, .xlsx"
multiple multiple
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
:on-change="handelDetail2FileChange" :on-change="handelDetail2FileChange"
:on-remove="handleDetail2FileRemove" :on-remove="handleDetail2FileRemove"
:auto-upload="false" :auto-upload="false"
accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" accept=".xls, .xlsx"
multiple multiple
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment