Commit 36f5e22c authored by 王飞龙's avatar 王飞龙

导入

parent 6647dc57
......@@ -3,7 +3,7 @@ import { Notification, MessageBox, Message, Loading } from 'element-ui'
import store from '@/store'
import { getToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { tansParams, blobValidate } from "@/utils/ruoyi";
import { tansParams, blobValidate, blobValidate1 } from '@/utils/ruoyi'
import cache from '@/plugins/cache'
import { saveAs } from 'file-saver'
......@@ -152,17 +152,18 @@ export function importExclusive(url, params, filename, config) {
...config
}).then(async (data) => {
console.log("导入返回的数据流",data)
const isBlob = blobValidate(data);
const isBlob = blobValidate1(data);
const resText = await data.text();
console.log("导入返回的数据流",isBlob)
console.log("报错信息",resText)
if (isBlob) {
Message.error('导入失败')
const blob = new Blob([data])
console.log("这是错误名字",filename)
saveAs(blob, filename)
} else if (resText=='{"msg":"上传模板与系统模板不匹配,请使用平台模板上传数据","code":500}') {
} else if (resText=='{"msg":"请上传正确的模板文件","code":500}') {
Message.error("请上传正确的模板文件")
} else if (resText=='{"msg":"null文件内容为空,请编辑模板文件内容重新上传","code":500}') {
} else if (resText=='{"msg":"药品库存文件内容为空,请编辑模板文件内容重新上传","code":500}') {
Message.error(filename+"文件内容为空,请编辑模板文件内容重新上传")
} else{
Message.success('导入成功');
......
......@@ -238,3 +238,7 @@ export function tansParams(params) {
export function blobValidate(data) {
return data.type !== 'application/json'
}
export function blobValidate1(data) {
return data.type !== 'application/json' && data.type!=='text/xml';
// return data.type !== 'text/xml'
}
......@@ -335,7 +335,8 @@
</el-col>
<el-col :span="8">
<el-form-item label="标准价格">
<el-input :value="'¥'+form.standardAmount" placeholder="-" style="width: 250px" disabled />
<el-input :value="+form.standardAmount" placeholder="-" style="width: 230px" disabled />
<span style="margin-left: 10px"></span>
</el-form-item>
</el-col>
<el-col :span="8">
......@@ -348,7 +349,8 @@
<el-row>
<el-col :span="8">
<el-form-item label="支付金额">
<el-input :value="'¥'+form.payAmount" placeholder="-" style="width: 250px" disabled />
<el-input :value="+form.payAmount" placeholder="-" style="width: 230px" disabled />
<span style="margin-left: 10px"></span>
</el-form-item>
</el-col>
<el-col :span="8">
......
......@@ -673,7 +673,7 @@ export default {
if (fileType === 'xlsx' || fileType === 'xlr' || fileType === 'xls') {
console.log(file)
} else {
this.$modal.msgWarning('仅支持扩展名: .xlsx.xlr.xls')
this.$modal.msgWarning(file.name + '文件格式不正确,请上传正确的模板文件')
// 返回false 就不会执行上传操作了
return false
}
......@@ -699,15 +699,9 @@ export default {
console.log('response', response)
const url = response.msg
console.log(' data.url', url)
// uploadByUrl(url).then(res => {
// console.log(res)
// })
this.importExclusive('/finance/stock/drug/manage/uploadByUrl?url=' + url, {}, `error_${new Date().getTime()}.xlsx`)
// this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + '</div>', '导入结果', { dangerouslyUseHTMLString: true })
this.importExclusive('/finance/stock/drug/manage/uploadByUrl?url=' + url, {}, `error_${this.exportFormatTime(new Date())}.xlsx`)
this.handleQuery()
this.closeImport()
this.getList()
},
// 提交上传文件
submitUpload() {
......
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