Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zghywpc-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
李苏
zghywpc-vue
Commits
3e33a507
Commit
3e33a507
authored
Apr 25, 2025
by
李苏
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
f2bcfe56
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
20 deletions
+49
-20
dialog.vue
src/views/jyfkgl/ywsjlr/kpiImportButton/dialog.vue
+49
-20
No files found.
src/views/jyfkgl/ywsjlr/kpiImportButton/dialog.vue
View file @
3e33a507
...
...
@@ -4,15 +4,18 @@
<el-upload
:accept=
"'.xls,.xlsx,.csv'"
:before-upload=
"BeforeUnloadEvent"
:headers=
"
{
'Content-Type': 'multipart/form-data'
}" :on-exceed='exceed' :limit='1' class="upload-demo" ref="upload" :action="action()" :on-preview="handlePreview"
:on-remove="handleRemove" :file-list="fileList" :on-success='success' :on-error='error'
:on-remove="handleRemove" :file-list="fileList" :on-success='success'
:on-change='change'
:on-error='error'
:auto-upload="false">
<el-button
slot=
"trigger"
size=
"small"
type=
"primary"
>
选择文件
</el-button>
<div
class=
"flex"
style=
"margin-top: 10px;"
>
<span
style=
"line-height: 30px;width: 45px;font-size: 12px;"
>
日期:
</span>
<el-date-picker
type=
"
date"
v-model=
"date"
/>
<span
style=
"line-height: 30px;width: 45px;font-size: 12px;"
>
日期:
</span>
<el-date-picker
type=
"
month"
v-model=
"date"
/>
</div>
<div
slot=
"tip"
class=
"el-upload__tip"
>
如没有模板文件请点击
<span
@
click=
"toDownload"
style=
"color: cornflowerblue;cursor: pointer;"
>
模板下载
</span>
。
</div>
style=
"color: cornflowerblue;cursor: pointer;"
>
模板下载
</span>
。
<br>
<span>
备注:模板内容的异物发现时间要在同一个年份和月份中。此处的选择日期要和模板的年月一致
</span>
</div>
</el-upload>
</div>
<div
slot=
"reFooter"
class=
"refooter"
>
...
...
@@ -26,7 +29,7 @@
<
script
>
import
*
as
XLSX
from
'xlsx'
;
import
request
from
'common/src/utils/request'
import
{
importTemp
...
...
@@ -49,29 +52,51 @@
},
data
()
{
return
{
date
:
new
Date
().
getTime
()
,
date
:
''
,
fileList
:
[],
loading
:
false
,
}
},
methods
:
{
change
(
file
)
{
// const name = file.name
// if (name.includes('xlsx')) {
// this.readExcelFile(file.raw).then(data => {
// if(data[1][1]){
// const dateStr = data[1][1];
// this.date= Date.parse(dateStr);
// }else{
// this.$warning('未读取到日期')
// }
// })
// }
},
readExcelFile
(
file
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
reader
=
new
FileReader
();
reader
.
onload
=
(
e
)
=>
{
const
data
=
new
Uint8Array
(
e
.
target
.
result
);
const
workbook
=
XLSX
.
read
(
data
,
{
type
:
'array'
});
const
workbook
=
XLSX
.
read
(
data
,
{
type
:
'array'
});
const
worksheet
=
workbook
.
Sheets
[
workbook
.
SheetNames
[
0
]];
const
jsonData
=
XLSX
.
utils
.
sheet_to_json
(
worksheet
,
{
header
:
1
});
const
jsonData
=
XLSX
.
utils
.
sheet_to_json
(
worksheet
,
{
header
:
1
});
resolve
(
jsonData
);
};
reader
.
onerror
=
(
e
)
=>
{
reject
(
e
);
};
reader
.
readAsArrayBuffer
(
file
);
})},
})
},
BeforeUnloadEvent
(
file
)
{
this
.
loading
=
true
...
...
@@ -113,6 +138,10 @@
this
.
$warning
(
'只能选择一个文件!'
)
},
submitUpload
()
{
if
(
!
this
.
date
){
this
.
$warning
(
'日期必填!'
)
return
}
if
(
this
.
$refs
.
upload
.
uploadFiles
.
length
==
0
)
{
this
.
$warning
(
'请选择一条数据!'
)
}
else
{
...
...
@@ -125,7 +154,7 @@
handlePreview
(
file
)
{
rconsole
.
log
(
file
);
this
.
readExcelFile
(
file
.
raw
).
then
((
data
)
=>
{
console
.
log
(
data
,
'excel'
)
// 在这里处理读取到的Excel数据
}).
catch
((
error
)
=>
{
console
.
error
(
error
);
...
...
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