Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
template_vue
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨硕
template_vue
Commits
b0c5b511
Commit
b0c5b511
authored
Mar 06, 2024
by
YLKCNK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
库存导入、下载模板(测试)
parent
872e65f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
17 deletions
+115
-17
magnagement.js
src/api/magnagement.js
+28
-1
index.vue
src/views/equipment/inventoryManagement/index.vue
+87
-16
No files found.
src/api/magnagement.js
View file @
b0c5b511
import
request
from
'@/utils/request'
import
Qs
from
'qs'
/* 分页查询 */
export
function
listdevice_t
(
query
)
{
...
...
@@ -30,12 +31,38 @@ export function updatadevice_t(data) {
/* 导出库存信息*/
export
function
exportWarehouse
(
query
)
{
return
request
({
// url: '/system/user
/export',
url
:
'/wbwarehouse-test
/export'
,
method
:
'get'
,
params
:
query
,
responseType
:
'blob'
})
}
// 导入库存信息
export
function
importExcel
(
data
)
{
return
request
({
url
:
'/wbwarehouse-test/importExcel'
,
method
:
'post'
,
headers
:
{
'Content-Type'
:
'multipart/form-data'
},
transformRequest
:
[(
data
)
=>
{
return
data
}],
data
})
}
// 下载错误文件
export
function
uploadFalseFile
(
params
)
{
params
=
Qs
.
stringify
(
params
)
return
request
({
url
:
'/wbwarehouse-test/downFalseFile'
,
method
:
'post'
,
data
:
params
,
responseType
:
'blob'
})
}
// 查询设备列表
export
function
listdevice
(
query
)
{
return
request
({
...
...
src/views/equipment/inventoryManagement/index.vue
View file @
b0c5b511
...
...
@@ -202,7 +202,7 @@
:on-progress=
"handleFileUploadProgress"
:on-success=
"handleFileSuccess"
:auto-upload=
"false"
:on-change=
"
employe
eUpload"
:on-change=
"
wareHors
eUpload"
:on-remove=
"handleRemove"
:before-remove=
"beforeRemove"
:on-preview=
"handlePreview"
...
...
@@ -229,7 +229,14 @@
</template>
<
script
>
import
{
listdevice_t
,
getDetailById_t
,
updatadevice_t
}
from
'@/api/magnagement'
import
{
listdevice_t
,
getDetailById_t
,
updatadevice_t
,
exportWarehouse
,
importExcel
,
uploadFalseFile
}
from
'@/api/magnagement'
import
{
resetForm
}
from
'@/utils/common'
import
{
getToken
}
from
'@/utils/auth'
...
...
@@ -295,8 +302,12 @@ export default {
// 设置上传的请求头部
headers
:
{
Authorization
:
'Bearer '
+
getToken
()
},
// 上传的地址
url
:
process
.
env
.
VUE_APP_BASE_API
+
'
导入接口
'
url
:
process
.
env
.
VUE_APP_BASE_API
+
'
/wbwarehouse-test/importExcel
'
},
// 导入列表
fileList
:
[],
importLoading
:
false
,
// 表单校验
rules
:
{
pn
:
[
...
...
@@ -421,18 +432,18 @@ export default {
type
:
'warning'
}).
then
(
function
()
{
console
.
log
(
'导出'
,
queryParams
)
// return exportUser
(queryParams).then(response => {
//
const blob = new Blob([response])
//
const downloadElement = document.createElement('a')
//
const href = window.URL.createObjectURL(blob)// 创建下载的链接
//
downloadElement.href = href
// downloadElement.download = '用户
信息' + '.xls' // 下载后文件名
//
document.body.appendChild(downloadElement)
//
downloadElement.click()// 点击下载
//
document.body.removeChild(downloadElement)// 下载完成移除元素
//
window.URL.revokeObjectURL(href)// 释放掉blob对象
//
// this.download(response.msg);
//
})
return
exportWarehouse
(
queryParams
).
then
(
response
=>
{
const
blob
=
new
Blob
([
response
])
const
downloadElement
=
document
.
createElement
(
'a'
)
const
href
=
window
.
URL
.
createObjectURL
(
blob
)
// 创建下载的链接
downloadElement
.
href
=
href
downloadElement
.
download
=
'库存
信息'
+
'.xls'
// 下载后文件名
document
.
body
.
appendChild
(
downloadElement
)
downloadElement
.
click
()
// 点击下载
document
.
body
.
removeChild
(
downloadElement
)
// 下载完成移除元素
window
.
URL
.
revokeObjectURL
(
href
)
// 释放掉blob对象
// this.download(response.msg);
})
})
},
/** 导入按钮操作 */
...
...
@@ -449,9 +460,69 @@ export default {
handleFileSuccess
(
response
,
file
,
fileList
)
{
this
.
upload
.
open
=
false
this
.
upload
.
isUploading
=
false
this
.
$refs
.
upload
.
clearFiles
()
this
.
$refs
.
upload
.
c
c
learFiles
()
this
.
$alert
(
response
.
msg
,
'导入结果'
,
{
dangerouslyUseHTMLString
:
true
})
this
.
getList
()
},
// 提交上传文件
submitFileForm
()
{
this
.
importLoading
=
true
if
(
this
.
fileList
.
length
===
0
)
{
this
.
$message
.
warning
(
'请上传文件'
)
// 导入成功后关闭弹出框
this
.
importLoading
=
false
this
.
upload
.
open
=
true
}
else
{
// 根据后台需求数据格式
var
formData
=
new
FormData
()
// 当前为空
formData
.
append
(
'file'
,
this
.
fileList
)
importExcel
(
formData
).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
if
(
res
.
data
.
filename
===
null
)
{
this
.
$message
.
success
(
'导入成功'
)
this
.
fileList
=
[]
// 导入成功后关闭弹出框
this
.
importLoading
=
false
this
.
upload
.
open
=
false
// 导入成功后刷新页面
this
.
getList
()
}
else
{
uploadFalseFile
({
fileName
:
res
.
data
.
filename
}).
then
(
res
=>
{
const
blob
=
new
Blob
([
res
])
const
downloadElement
=
document
.
createElement
(
'a'
)
const
href
=
window
.
URL
.
createObjectURL
(
blob
)
// 创建下载的链接
downloadElement
.
href
=
href
downloadElement
.
download
=
'模板错误提示'
+
'.txt'
// 下载后文件名
document
.
body
.
appendChild
(
downloadElement
)
downloadElement
.
click
()
// 点击下载
document
.
body
.
removeChild
(
downloadElement
)
// 下载完成移除元素
window
.
URL
.
revokeObjectURL
(
href
)
// 释放掉blob对象
})
}
this
.
importLoading
=
false
}
else
if
(
res
.
code
===
41020
)
{
this
.
$message
.
info
(
'上传超时,请重新上传'
)
this
.
importLoading
=
false
}
}).
catch
(
err
=>
{
this
.
importLoading
=
false
this
.
$message
.
success
(
err
.
message
)
})
}
},
wareHorseUpload
(
file
,
fileList
)
{
if
(
fileList
.
length
>
1
)
{
fileList
.
splice
(
0
,
1
)
}
this
.
fileList
=
fileList
[
0
].
raw
},
handleRemove
(
file
,
fileList
)
{
this
.
fileList
=
[]
},
beforeRemove
(
file
,
fileList
)
{
this
.
fileList
=
[]
},
/* 上传文件所需求 */
handlePreview
(
file
)
{
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment