Commit ac677587 authored by shuaiqiang's avatar shuaiqiang 🇨🇳

refactor:调整结构

parent 229f4b7a
......@@ -27,11 +27,21 @@ export function fetchPctToCn(baseURL, data) {
})
}
// export function fetchConvertEquations(baseURL, data) {
// return service({
// baseURL: baseURL,
// url: 'Word/ConvertEquations',
// method: 'POST',
// data
// })
// }
\ No newline at end of file
export function fetchConvertEquations(baseURL, data) {
return service({
baseURL: baseURL,
url: 'Word/ConvertEquations',
method: 'POST',
data
})
}
export function fetchDownloadFile(baseURL, params) {
return service({
baseURL: baseURL,
url: 'RequestPayment/DownloadFile',
method: 'get',
responseType: 'blob',
params
})
}
\ No newline at end of file
import service from '@utils/requestService'
export function createHxRequestPaymentVerticalTotal(data) {
export function createHxRequestPaymentVerticalTotal(baseURL, data) {
return service({
baseURL: baseURL,
url: 'api/v1.0/RequestPayment/ChangeHXRequestPaymentVerticalTotal',
method: 'POST',
data
})
}
export function createHxRequestPaymentVerticalTotal2(data) {
export function createHxRequestPaymentVerticalTotal2(baseURL, data) {
return service({
baseURL: baseURL,
url: 'api/v1.0/RequestPayment/ChangeHXRequestPaymentVerticalTotal2',
method: 'POST',
data
})
}
export function downloadFile(params) {
export function downloadFile(baseURL,params) {
return service({
baseURL:baseURL,
url: 'api/v1.0/RequestPayment/DownloadFile',
method: 'GET',
params,
......
import service from '@utils/GraphApiService'
export function fetchEhrEmployeeByName(baseURL, params) {
return service({
baseURL: baseURL,
url: 'Wade/GetEhrEmployeeByName',
method: 'get',
params
})
}
export function fetchCaseLevelList(baseURL, data) {
return service({
baseURL: baseURL,
url: 'Wade/CreateCaseLevelList',
method: 'post',
data
})
}
\ No newline at end of file
......@@ -6,10 +6,8 @@ module.exports = {
VUE_APP_GRAPHAPI_URL: 'https://pvapi.purplevineip.com/graphAPI/api/v1.0/'
},
prod_test_sz: {
VUE_APP_GRAPHAPI_URL: 'https://dev.essenptl.com/graphAPITest/api/v1.0/'
},
prod_file_sz: {
VUE_APP_GRAPHAPI_URL: 'https://dev.essenptl.com/dev2/wade_ext/'
VUE_APP_GRAPHAPI_URL: 'https://dev.essenptl.com/graphAPITest/api/v1.0/',
VUE_FILE_URL: 'https://dev.essenptl.com/dev2/wade_ext/'
},
dev_tp: {
VUE_APP_GRAPHAPI_URL: 'http://localhost:64224/api/v1.0/'
......@@ -22,11 +20,6 @@ module.exports = {
},
dev_test_sz: {
VUE_APP_GRAPHAPI_URL: 'https://dev.essenptl.com/graphAPITest/api/v1.0/',
},
dev_file_tp: {
VUE_APP_GRAPHAPI_URL: 'https://dev.essenptl.com/dev2/wade_ext/'
},
dev_file_sz: {
VUE_APP_GRAPHAPI_URL: 'https://dev.essenptl.com/dev2/wade_ext/'
VUE_FILE_URL: 'https://dev.essenptl.com/dev2/wade_ext/'
}
}
\ No newline at end of file
......@@ -4,8 +4,8 @@
<pLink type="primary">Test</pLink>
<splitTool env="dev_test_sz"></splitTool>
<convertTool env="dev_test_sz"></convertTool>
<fileSplit env="dev_file_sz"></fileSplit>
<upload env="dev_file_sz"></upload>
<fileSplit env="dev_test_sz"></fileSplit>
<upload env="dev_test_sz"></upload>
<uploadExcel env="dev_test_sz"></uploadExcel>
</div>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
.p-link-default[data-v-30dd6ef1]{color:#606266}.p-link-primary[data-v-30dd6ef1]{color:#409eff}.el-form .el-form-item[data-v-8461da98]{margin:10px 0}.el-form .el-form-item .el-radio-group[data-v-8461da98]{margin-left:20px}.el-form .el-form-item input[data-v-8461da98]{width:126px;margin-left:10px;outline:none;border:0;background:#c6c6c6}.choose-box[data-v-8461da98]{margin-left:200px;border:1px solid #000;width:220px}.choose-box div>span[data-v-8461da98]{display:inline-block;width:56px;text-align:center;margin:10px 5px;border:1px solid #000}input[data-v-8461da98]::-webkit-input-placeholder{font-size:12px;opacity:.8}[data-v-8461da98] .el-form-item__content{line-height:1.5!important}.excel-upload-input[data-v-77bf1e84]{display:none;z-index:-9999}.drop[data-v-77bf1e84]{border:2px dashed #bbb;width:600px;height:160px;line-height:160px;margin:0 auto;font-size:24px;border-radius:5px;text-align:center;color:#bbb;position:relative}
\ No newline at end of file
.p-link-default[data-v-30dd6ef1]{color:#606266}.p-link-primary[data-v-30dd6ef1]{color:#409eff}.el-form .el-form-item[data-v-64794a36]{margin:10px 0}.el-form .el-form-item .el-radio-group[data-v-64794a36]{margin-left:20px}.el-form .el-form-item input[data-v-64794a36]{width:126px;margin-left:10px;outline:none;border:0;background:#c6c6c6}.choose-box[data-v-64794a36]{margin-left:200px;border:1px solid #000;width:220px}.choose-box div>span[data-v-64794a36]{display:inline-block;width:56px;text-align:center;margin:10px 5px;border:1px solid #000}input[data-v-64794a36]::-webkit-input-placeholder{font-size:12px;opacity:.8}[data-v-64794a36] .el-form-item__content{line-height:1.5!important}.excel-upload-input[data-v-77bf1e84]{display:none;z-index:-9999}.drop[data-v-77bf1e84]{border:2px dashed #bbb;width:600px;height:160px;line-height:160px;margin:0 auto;font-size:24px;border-radius:5px;text-align:center;color:#bbb;position:relative}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -47,7 +47,7 @@
</div>
</template>
<script>
import GraphApiService from '@utils/GraphApiService'
import { fetchCnToCpc,fetchDownloadFile } from "@api/convertApi"
export default {
name: 'Cn2CpcForm',
data: function() {
......@@ -63,7 +63,7 @@ export default {
},
methods: {
// 上传到服务器
submitUpload() {
async submitUpload() {
console.log(this.fileList)
if (this.fileList.length <= 0) {
this.$message.error('请先选择需要上传的文件!')
......@@ -73,48 +73,32 @@ export default {
this.fileList.forEach(e => {
formData.append('file', e.raw)
})
GraphApiService
.post('Word/CN2CPC', formData)
.then(res => {
const res = await fetchCnToCpc(this.baseUrl, formData)
if (res.status === 200) {
this.fileList = []
this.$refs.upload.clearFiles()
const excelFileName = res.data
GraphApiService
.get('RequestPayment/DownloadFile', {
params: {
fileName: excelFileName
},
responseType: 'blob'
})
.then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
const response = await fetchDownloadFile(this.baseUrl,{fileName: excelFileName})
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
})
// })
} else {
this.$refs.upload.abort()
this.$message.error('下载档案失败!')
}
console.log(res.data)
})
.catch(error => {
console.log('error', error)
this.$refs.upload.abort()
this.$message.error('下载档案失败!')
})
},
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
handelFileChange(file, fileList) {
// 存在文件标识
let existsFileFlag = false
for (let i = 0; i < this.fileList.length; i++) {
if (
file.name === this.fileList[i].name &&
......
......@@ -51,7 +51,7 @@
</div>
</template>
<script>
import GraphApiService from '@utils/GraphApiService'
import {fetchCntToPct,fetchDownloadFile} from "@api/convertApi"
export default {
name: 'Cn2PctForm',
data: function() {
......@@ -77,42 +77,26 @@ export default {
this.fileList.forEach(e => {
formData.append('file', e.raw)
})
GraphApiService
.post('Word/CN2PCT', formData)
.then(res => {
const res = await fetchCntToPct(this.baseUrl,formData)
if (res.status === 200) {
this.fileList = []
this.$refs.upload.clearFiles()
const excelFileName = res.data
GraphApiService
.get('RequestPayment/DownloadFile', {
params: {
fileName: excelFileName
},
responseType: 'blob'
})
.then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
})
const response = await fetchDownloadFile(this.baseUrl,{fileName: excelFileName})
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
} else {
this.$refs.upload.abort()
this.$message.error('下载档案失败!')
}
console.log(res.data)
})
.catch(error => {
console.log('error', error)
this.$refs.upload.abort()
this.$message.error('下载档案失败!')
})
},
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
handelFileChange(file, fileList) {
......
......@@ -47,7 +47,7 @@
</div>
</template>
<script>
import GraphApiService from '@utils/GraphApiService'
import { fetchPctToCn,fetchDownloadFile } from "@api/convertApi"
export default {
name: 'Cn2CpcForm',
data: function() {
......@@ -73,42 +73,26 @@ export default {
this.fileList.forEach(e => {
formData.append('file', e.raw)
})
GraphApiService
.post('Word/PCT2CN', formData)
.then(res => {
if (res.status === 200) {
this.fileList = []
this.$refs.upload.clearFiles()
const excelFileName = res.data
GraphApiService
.get('RequestPayment/DownloadFile', {
params: {
fileName: excelFileName
},
responseType: 'blob'
})
.then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
})
} else {
this.$refs.upload.abort()
this.$message.error('下载档案失败!')
}
console.log(res.data)
})
.catch(error => {
console.log('error', error)
const res = await fetchPctToCn(this.baseUrl,formData)
if (res.status === 200) {
this.fileList = []
this.$refs.upload.clearFiles()
const excelFileName = res.data
const response = await fetchDownloadFile(this.baseUrl,{fileName: excelFileName})
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
} else {
this.$refs.upload.abort()
this.$message.error('下载档案失败!')
})
}
console.log(res.data)
},
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
handelFileChange(file, fileList) {
......
......@@ -101,7 +101,7 @@
</div>
</template>
<script>
import GraphApiService from '@utils/GraphApiService'
import {fetchConvertEquations,fetchDownloadFile} from "@api/convertApi"
export default {
name: 'VisioForm',
data: function() {
......@@ -126,7 +126,7 @@ export default {
},
methods: {
// 上传到服务器
submitUpload() {
async submitUpload() {
console.log(this.fileList)
if (this.fileList.length <= 0) {
this.$message.error('请先选择需要上传的文件!')
......@@ -147,42 +147,27 @@ export default {
formData.append('includeType', this.form.includeType)
formData.append('isSetLineHeight', this.form.isSetLineHeight)
formData.append('lineHeight', this.form.lineHeight)
GraphApiService
.post('Word/ConvertEquations', formData)
.then(res => {
const res = await fetchConvertEquations(this.baseUrl,formData)
if (res.status === 200) {
this.fileList = []
this.$refs.upload.clearFiles()
const excelFileName = res.data
GraphApiService
.get('RequestPayment/DownloadFile', {
params: {
fileName: excelFileName
},
responseType: 'blob'
})
.then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
})
const response = await fetchDownloadFile(this.baseUrl,{fileName: excelFileName})
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
// })
} else {
this.$refs.upload.abort()
this.$message.error('下载档案失败!')
}
console.log(res.data)
})
.catch(error => {
console.log('error', error)
this.$refs.upload.abort()
this.$message.error('下载档案失败!')
})
},
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
handelFileChange(file, fileList) {
......
......@@ -75,10 +75,8 @@
</div>
</template>
<script>
import { SplitRevisionDoc } from '@api/fileApi'
import { SplitRevisionDoc} from '@api/fileApi'
import { mixins } from "../mixin/toolMixin";
import service from '@utils/requestService'
export default {
name: 'SplitWordForm',
mixins:["mixins"],
......
......@@ -23,7 +23,7 @@ export default {
computed:{
baseUrl(){
console.log('config', config, this.env)
return config[this.env].VUE_APP_GRAPHAPI_URL
return config[this.env].VUE_FILE_URL
}
},
}
......
......@@ -129,11 +129,17 @@ import {
createHxRequestPaymentVerticalTotal2,
downloadFile
}
from '@api/warningReportApi'
from '@api/uploadApi'
import moment from 'moment'
import config from '@config/index.js'
export default {
name: 'upload',
props:{
env:{
type: String,
default: 'prod_sz'
}
},
data: function() {
return {
activeName: 'first',
......@@ -147,6 +153,12 @@ export default {
createMonth: ''
}
},
computed:{
baseUrl(){
console.log('config', config, this.env)
return config[this.env].VUE_FILE_URL
}
},
created() {
// eslint-disable-next-line no-undef
this.createMonth = moment().format('YYYY年MM月')
......@@ -156,7 +168,7 @@ export default {
this.activeName = tab.name
},
// 上传到服务器
submitUpload() {
async submitUpload() {
console.log(this.fileList)
if (this.fileList.length <= 0) {
this.$message.error('请先选择需要上传的文件!')
......@@ -175,31 +187,25 @@ export default {
this.detailFileList.forEach(e => {
formData.append('detailFileList', e.raw)
})
createHxRequestPaymentVerticalTotal(formData)
.then(res => {
if (res.status === 200) {
excelFileName = res.data
downloadFile({
fileName: excelFileName
})
.then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
})
} else {
this.$message.error('下载档案失败!')
}
console.log(res.data)
})
const res = await createHxRequestPaymentVerticalTotal(this.baseUrl, formData)
if (res.status === 200) {
excelFileName = res.data
const response = downloadFile(this.baseUrl,{fileName: excelFileName})
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
} else {
this.$message.error('下载档案失败!')
}
console.log(res.data)
},
submitUpload2() {
async submitUpload2() {
console.log(this.detailFileList2)
if (this.detailFileList2.length <= 0) {
this.$message.error('请先选择需要上传的文件!')
......@@ -210,30 +216,23 @@ export default {
this.detailFileList2.forEach(e => {
formData.append('detailFileList', e.raw)
})
createHxRequestPaymentVerticalTotal2(formData)
.then(res => {
if (res.status === 200) {
excelFileName = res.data
// debugger
downloadFile({
fileName: excelFileName
})
.then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
})
} else {
this.$message.error('下载档案失败!')
}
console.log(res.data)
})
const res = await createHxRequestPaymentVerticalTotal2(this.baseUrl,formData)
if (res.status === 200) {
excelFileName = res.data
const response = downloadFile(this.baseUrl,{fileName: excelFileName})
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = excelFileName.split('/')[1]
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
} else {
this.$message.error('下载档案失败!')
}
console.log(res.data)
},
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
handelFileChange(file, fileList) {
......
......@@ -25,10 +25,17 @@
<script>
import { mapGetters } from 'vuex'
import UploadExcelComponent from './components/UploadExcel.vue'
import uploadApiService from '@utils/uploadAPiService'
import { fetchEhrEmployeeByName, fetchCaseLevelList } from "@api/uploadExcelApi"
import config from '@config/index.js'
export default {
name:'uploadExcel',
components: { UploadExcelComponent },
props:{
env:{
type: String,
default: 'prod_sz'
}
},
data() {
return {
tableData: [],
......@@ -42,7 +49,11 @@ export default {
}
},
computed: {
...mapGetters('user/', ['wadeUserID'])
...mapGetters('user/', ['wadeUserID']),
baseUrl(){
console.log('config', config, this.env)
return config[this.env].VUE_APP_GRAPHAPI_URL
}
},
methods: {
beforeUpload(file) {
......@@ -77,12 +88,8 @@ export default {
.filter(item => {
return item[level.value] === 'ν'
})
.map(item => {
uploadApiService
.get('/Wade/GetEhrEmployeeByName', {
params: { name: item['姓名'] }
})
.then(rest => {
.map(async item => {
const rest = await fetchEhrEmployeeByName(this.baseUrl,{ name: item['姓名'] })
if (rest.status === 200) {
if (rest.data === null || rest.data.wade_user_id === null) {
this.$message({
......@@ -99,28 +106,19 @@ export default {
match_type: '1',
update_user_id: this.wadeUserID
}
uploadApiService
.post('/Wade/CreateCaseLevelList', params)
.then(res => {
if (res.status === 200) {
console.log(
`${item[level.name]} isUpload: ${item['姓名']}`
)
item.isUpload = 'ν'
this.itemkey = Math.random() // 在这边给key赋随机值
this.$message({ type: 'success', message: '新增成功!' })
}
})
.catch(() => {
this.$message({
type: 'error',
message: '新增失败! 已有该笔资料!'
})
})
const res = await fetchCaseLevelList(this.baseUrl,params)
if (res.status === 200) {
console.log(
`${item[level.name]} isUpload: ${item['姓名']}`
)
item.isUpload = 'ν'
this.itemkey = Math.random() // 在这边给key赋随机值
this.$message({ type: 'success', message: '新增成功!' })
}
}
})
})
})
// })
},
searchitem(index) {
console.log(this.tableHeader[index])
......
import axios from 'axios'
import { Message } from 'element-ui'
// create an axios instance
const uploadApiService = axios.create({
baseURL: "https://dev.essenptl.com/graphAPITest/api/v1.0/",
// withCredentials: true, // send cookies when cross-domain requests
timeout: 300000, // request timeout
headers: {
'Content-Type': 'application/json'
}
})
// 請求攔截
uploadApiService.interceptors.request.use(
confing => {
return confing
},
error => {
console.log(error) // for debug
return Promise.reject(error)
}
)
// 響應攔截
uploadApiService.interceptors.response.use(
response => {
const res = response.data
if (
res.type &&
(res.type ===
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
res.type === 'application/zip')
) {
return res
}
if (res.status !== 200) {
// if the custom code is not 200, it is judged as an error.
Message({
message: res.message || 'Error',
type: 'error',
duration: 5 * 1000
})
return Promise.reject(new Error(res.message || 'Error'))
} else {
return res
}
},
error => {
console.log('err' + error) // for debug
Message({
message: error.message,
type: 'error',
duration: 5 * 1000
})
return Promise.reject(error)
}
)
export default uploadApiService
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