Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qr-consistency-vue3
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
刘怀志
qr-consistency-vue3
Commits
97e91406
Commit
97e91406
authored
May 06, 2025
by
wangjiancheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:添加导出后自动导入
parent
af871147
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
205 additions
and
162 deletions
+205
-162
BaseIntlPartTemplate.js
src/api/BaseIntlPartTemplate/BaseIntlPartTemplate.js
+23
-0
index.vue
...riticalPartsList/BaseInternationalKeyComponents/index.vue
+56
-47
index.vue
...lPartsList/BaseInternationalKeyComponentsDetail/index.vue
+126
-115
No files found.
src/api/BaseIntlPartTemplate/BaseIntlPartTemplate.js
View file @
97e91406
...
@@ -42,3 +42,26 @@ export function getAllUnit(data) {
...
@@ -42,3 +42,26 @@ export function getAllUnit(data) {
method
:
'get'
method
:
'get'
})
})
}
}
/** 下载二进制流文件
* @param binFile 二进制文件流
* @param fileName 文件名,例如:测试文本.txt
* @param blobType Blob 对象的 type 属性给出文件的 MIME 类型,默认:'application/octet-stream'(用于通用二进制数据)
*/
export
function
downloadBinaryFile
(
binFile
,
fileName
,
blobType
=
'application/octet-stream'
)
{
// 处理二进制数据并创建 Blob 对象
const
blobObj
=
new
Blob
([
binFile
],
{
type
:
blobType
})
// 创建一个链接并设置下载属性
const
downloadLink
=
document
.
createElement
(
'a'
)
let
url
=
window
.
URL
||
window
.
webkitURL
||
window
.
moxURL
// 兼容不同浏览器的 URL 对象
url
=
url
.
createObjectURL
(
blobObj
)
downloadLink
.
href
=
url
downloadLink
.
download
=
fileName
// 设置下载的文件名
// 将链接添加到 DOM 中,模拟点击
document
.
body
.
appendChild
(
downloadLink
)
downloadLink
.
click
()
// 移除创建的链接和释放 URL 对象
document
.
body
.
removeChild
(
downloadLink
)
window
.
URL
.
revokeObjectURL
(
url
)
}
src/views/baseData/criticalPartsList/BaseInternationalKeyComponents/index.vue
View file @
97e91406
...
@@ -285,10 +285,10 @@
...
@@ -285,10 +285,10 @@
<
/el-row
>
<
/el-row
>
<
el
-
form
-
item
label
=
"关键零部件清单文件"
prop
=
"file"
>
<
el
-
form
-
item
label
=
"关键零部件清单文件"
prop
=
"file"
>
<
el
-
upload
<
el
-
upload
ref
=
"upload"
ref
=
"upload"
:
auto
-
upload
=
"false"
:
auto
-
upload
=
"false"
:
limit
=
"1"
:
limit
=
"1"
:
on
-
change
=
"handleFileChange"
:
on
-
change
=
"handleFileChange"
>
>
<
el
-
button
>
选择文件
<
/el-button
>
<
el
-
button
>
选择文件
<
/el-button
>
<
/el-upload
>
<
/el-upload
>
...
@@ -451,7 +451,8 @@
...
@@ -451,7 +451,8 @@
<!--
上传文件对话框
-->
<!--
上传文件对话框
-->
<
el
-
dialog
v
-
model
=
"openUpload"
title
=
"上传文件"
width
=
"600px"
>
<
el
-
dialog
v
-
model
=
"openUpload"
title
=
"上传文件"
width
=
"600px"
>
<
el
-
form
ref
=
"baseInternationalRef"
:
model
=
"form"
label
-
width
=
"auto"
:
rules
=
"rules"
label
-
position
=
"top"
label
-
suffix
=
":"
>
<
el
-
form
ref
=
"baseInternationalRef"
:
model
=
"form"
label
-
width
=
"auto"
:
rules
=
"rules"
label
-
position
=
"top"
label
-
suffix
=
":"
>
<
el
-
form
-
item
label
=
"关键零部件清单文件"
prop
=
"file"
>
<
el
-
form
-
item
label
=
"关键零部件清单文件"
prop
=
"file"
>
<
el
-
upload
<
el
-
upload
ref
=
"upload"
ref
=
"upload"
...
@@ -560,10 +561,10 @@ import {
...
@@ -560,10 +561,10 @@ import {
addBaseInternational
,
addBaseInternational
,
updateBaseInternational
,
updateBaseInternational
,
getBaseInternationalNo
,
getBaseInternationalNo
,
getBaseInternationalDepartment
,
upgradeBaseInternational
,
getBrandName
getBaseInternationalDepartment
,
upgradeBaseInternational
,
getBrandName
}
from
"@/api/BaseInternationalKeyComponents/BaseInternationalKeyComponents.js"
;
}
from
"@/api/BaseInternationalKeyComponents/BaseInternationalKeyComponents.js"
;
import
{
getMarket
}
from
"@/api/BaseIntlPartTemplate/BaseIntlPartTemplateDetail.js"
;
import
{
getMarket
}
from
"@/api/BaseIntlPartTemplate/BaseIntlPartTemplateDetail.js"
;
import
{
getAllUnit
}
from
"@/api/BaseIntlPartTemplate/BaseIntlPartTemplate.js"
;
import
{
downloadBinaryFile
,
getAllUnit
}
from
"@/api/BaseIntlPartTemplate/BaseIntlPartTemplate.js"
;
import
{
WarningFilled
}
from
"@element-plus/icons-vue"
;
import
{
WarningFilled
}
from
"@element-plus/icons-vue"
;
import
request
from
'@/utils/request'
import
request
from
'@/utils/request'
...
@@ -622,7 +623,7 @@ const data = reactive({
...
@@ -622,7 +623,7 @@ const data = reactive({
powerType
:
[{
required
:
true
,
message
:
"动力类型不能为空"
,
trigger
:
"blur"
}
],
powerType
:
[{
required
:
true
,
message
:
"动力类型不能为空"
,
trigger
:
"blur"
}
],
listVersion
:
[{
required
:
true
,
message
:
"清单版本号不能为空"
,
trigger
:
"blur"
}
],
listVersion
:
[{
required
:
true
,
message
:
"清单版本号不能为空"
,
trigger
:
"blur"
}
],
listCode
:
[{
required
:
true
,
message
:
"清单编号不能为空"
,
trigger
:
"blur"
}
],
listCode
:
[{
required
:
true
,
message
:
"清单编号不能为空"
,
trigger
:
"blur"
}
],
file
:
[{
required
:
true
,
message
:
"关键零部件清单文件不能为空"
,
trigger
:
"blur"
}
]
file
:
[{
required
:
true
,
message
:
"关键零部件清单文件不能为空"
,
trigger
:
"blur"
}
]
}
}
}
);
}
);
...
@@ -769,6 +770,7 @@ function getApplicableMarket() {
...
@@ -769,6 +770,7 @@ function getApplicableMarket() {
}
}
]
]
}
}
// 根据品牌id获取品牌名称
// 根据品牌id获取品牌名称
const
getBrandLabelsByIds
=
(
brandIds
)
=>
{
const
getBrandLabelsByIds
=
(
brandIds
)
=>
{
if
(
!
Array
.
isArray
(
brandIds
))
return
'--'
;
if
(
!
Array
.
isArray
(
brandIds
))
return
'--'
;
...
@@ -845,6 +847,7 @@ const handleFileChange = (file) => {
...
@@ -845,6 +847,7 @@ const handleFileChange = (file) => {
}
}
const
uploadId
=
ref
(
null
)
const
uploadId
=
ref
(
null
)
// 上传文件
// 上传文件
function
handleUpload
(
row
)
{
function
handleUpload
(
row
)
{
openUpload
.
value
=
true
;
openUpload
.
value
=
true
;
...
@@ -957,7 +960,7 @@ function submitForm() {
...
@@ -957,7 +960,7 @@ function submitForm() {
}
);
}
);
}
else
{
}
else
{
form
.
value
.
model
=
addForm
.
value
.
model
;
form
.
value
.
model
=
addForm
.
value
.
model
;
if
(
!
fileNew
.
value
){
if
(
!
fileNew
.
value
)
{
proxy
.
$modal
.
msgError
(
"请上传文件"
);
proxy
.
$modal
.
msgError
(
"请上传文件"
);
return
;
return
;
}
}
...
@@ -965,11 +968,13 @@ function submitForm() {
...
@@ -965,11 +968,13 @@ function submitForm() {
const
formData
=
new
FormData
();
const
formData
=
new
FormData
();
formData
.
append
(
'baseInternationalKeyComponentsList'
,
JSON
.
stringify
(
form
.
value
));
formData
.
append
(
'baseInternationalKeyComponentsList'
,
JSON
.
stringify
(
form
.
value
));
formData
.
append
(
'file'
,
fileNew
.
value
);
formData
.
append
(
'file'
,
fileNew
.
value
);
addBaseInternational
(
formData
).
then
(
response
=>
{
addBaseInternational
(
formData
).
then
(
response
=>
{
proxy
.
$refs
.
upload
.
clearFiles
()
proxy
.
$modal
.
msgSuccess
(
"新增成功"
);
openAdd
.
value
=
false
;
downloadBinaryFile
(
response
,
'错误信息.xlsx'
)
fileNew
.
value
=
null
;
proxy
.
$refs
.
upload
.
clearFiles
()
getList
();
openAdd
.
value
=
false
;
fileNew
.
value
=
null
;
getList
();
}
);
}
);
}
}
}
}
...
@@ -979,47 +984,51 @@ function submitForm() {
...
@@ -979,47 +984,51 @@ function submitForm() {
// 升版--提交按钮
// 升版--提交按钮
function
submitUpgradeForm
(
id
)
{
function
submitUpgradeForm
(
id
)
{
const
formData
=
new
FormData
();
const
formData
=
new
FormData
();
if
(
fileNew
.
value
)
{
if
(
fileNew
.
value
)
{
formData
.
append
(
'file'
,
fileNew
.
value
);
formData
.
append
(
'file'
,
fileNew
.
value
);
}
else
{
}
else
{
proxy
.
$modal
.
msgError
(
"请上传文件"
);
proxy
.
$modal
.
msgError
(
"请上传文件"
);
return
;
return
;
}
}
upgradeBaseInternational
(
formData
,
id
).
then
(
response
=>
{
upgradeBaseInternational
(
formData
,
id
).
then
(
response
=>
{
//proxy.$modal.msgSuccess("升版成功");
proxy
.
$modal
.
msgSuccess
(
"升版成功"
);
proxy
.
$refs
.
upload
.
clearFiles
()
downloadBinaryFile
(
response
,
'错误信息.xlsx'
)
openUpgrade
.
value
=
false
;
proxy
.
$refs
.
upload
.
clearFiles
()
fileNew
.
value
=
null
openUpgrade
.
value
=
false
;
getList
();
fileNew
.
value
=
null
}
)
getList
();
}
)
}
}
// 上传文件--提交按钮
// 上传文件--提交按钮
function
submitUploadForm
()
{
function
submitUploadForm
()
{
const
formData
=
new
FormData
();
const
formData
=
new
FormData
();
if
(
fileNew
.
value
)
{
if
(
fileNew
.
value
)
{
formData
.
append
(
'file'
,
fileNew
.
value
);
formData
.
append
(
'file'
,
fileNew
.
value
);
}
else
{
}
else
{
proxy
.
$modal
.
msgError
(
"请上传文件"
);
proxy
.
$modal
.
msgError
(
"请上传文件"
);
return
;
return
;
}
request
(
'/control/baseInternationalKeyComponentsDetail/importData/'
+
uploadId
.
value
,
{
method
:
'post'
,
data
:
formData
,
headers
:
{
'Content-Type'
:
'multipart/form-data'
}
}
request
(
'/control/baseInternationalKeyComponentsDetail/importData/'
+
uploadId
.
value
,
{
}
).
then
(
response
=>
{
method
:
'post'
,
proxy
.
$modal
.
msgSuccess
(
"上传成功"
);
data
:
formData
,
downloadBinaryFile
(
response
,
'错误信息.xlsx'
)
headers
:
{
proxy
.
$refs
.
upload
.
clearFiles
()
'Content-Type'
:
'multipart/form-data'
openUpload
.
value
=
false
;
}
uploadId
.
value
=
null
;
}
).
then
(
response
=>
{
fileNew
.
value
=
null
proxy
.
$refs
.
upload
.
clearFiles
()
getList
();
openUpload
.
value
=
false
;
}
)
uploadId
.
value
=
null
;
fileNew
.
value
=
null
getList
();
}
)
}
}
const
delId
=
ref
(
null
)
const
delId
=
ref
(
null
)
// 打开删除对话框
// 打开删除对话框
function
handleUndo
(
row
)
{
function
handleUndo
(
row
)
{
undoDialogVisible
.
value
=
true
;
undoDialogVisible
.
value
=
true
;
...
...
src/views/baseData/criticalPartsList/BaseInternationalKeyComponentsDetail/index.vue
View file @
97e91406
This diff is collapsed.
Click to expand it.
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