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
cc872aa7
Commit
cc872aa7
authored
Jan 08, 2025
by
李苏
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
0db1d7e2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
271 additions
and
33 deletions
+271
-33
index.vue
src/views/fmegl/fmekpigl/biao/index.vue
+38
-33
api.js
src/views/fmegl/fmekpigl/biao/kpiImportButton/api.js
+10
-0
dialog.vue
src/views/fmegl/fmekpigl/biao/kpiImportButton/dialog.vue
+159
-0
index.vue
src/views/fmegl/fmekpigl/biao/kpiImportButton/index.vue
+64
-0
No files found.
src/views/fmegl/fmekpigl/biao/index.vue
View file @
cc872aa7
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* @Author: lisu lisu@gavelinfo.com
* @Author: lisu lisu@gavelinfo.com
* @Date: 2024-09-19 10:55:27
* @Date: 2024-09-19 10:55:27
* @LastEditors: lisu lisu@gavelinfo.com
* @LastEditors: lisu lisu@gavelinfo.com
* @LastEditTime: 202
4-10-30 09:58:21
* @LastEditTime: 202
5-01-08 15:50:43
* @FilePath: /zghywpc-vue/src/views/fmegl/fmekpigl/biao/index.vue
* @FilePath: /zghywpc-vue/src/views/fmegl/fmekpigl/biao/index.vue
-->
-->
<
template
>
<
template
>
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<
template
#
toolbar=
"ctx"
>
<
template
#
toolbar=
"ctx"
>
<!-- 嵌入默认页面工具栏的插槽 ctx.pagePage来操作默认页面 -->
<!-- 嵌入默认页面工具栏的插槽 ctx.pagePage来操作默认页面 -->
<!--
<el-button
@
click=
"demo(ctx.basePage)"
size=
'mini'
type=
"primary"
>
示例按钮
</el-button>
-->
<!--
<el-button
@
click=
"demo(ctx.basePage)"
size=
'mini'
type=
"primary"
>
示例按钮
</el-button>
-->
<ImportButton
@
success=
"()=>
{ctx.basePage.refresh()}" :url="'fme/ufmekpi/import'" />
<
Kpi
ImportButton
@
success=
"()=>
{ctx.basePage.refresh()}" :url="'fme/ufmekpi/import'" />
</
template
>
</
template
>
</BasePage>
</BasePage>
...
@@ -22,12 +22,13 @@
...
@@ -22,12 +22,13 @@
<
script
>
<
script
>
import
Edit
from
'./edit.vue'
import
Edit
from
'./edit.vue'
import
KpiImportButton
from
'./kpiImportButton/index.vue'
export
default
{
export
default
{
name
:
'template'
,
name
:
'template'
,
data
()
{
data
()
{
let
nowYear
=
new
Date
().
getFullYear
()
let
nowYear
=
new
Date
().
getFullYear
()
let
lastYearKpi
=
`
${
nowYear
-
1
}
年kpi`
let
lastYearKpi
=
`
${
nowYear
-
1
}
年kpi`
let
yearBeforeLastKpi
=
`
${
nowYear
-
2
}
年kpi`
let
yearBeforeLastKpi
=
`
${
nowYear
-
2
}
年kpi`
return
{
return
{
config
:
{
config
:
{
/* 基本配置*/
/* 基本配置*/
...
@@ -35,7 +36,12 @@
...
@@ -35,7 +36,12 @@
tableTitle
:
[{
tableTitle
:
[{
title
:
"名称"
,
title
:
"名称"
,
field
:
"jzmc"
,
field
:
"jzmc"
,
width
:
130
width
:
130
,
transform
:
{
"url"
:
"fme/ufmekpi/init/jz/type"
,
"label"
:
"name"
,
"value"
:
"id"
}
},
},
{
{
title
:
"FME1级别"
,
title
:
"FME1级别"
,
...
@@ -62,11 +68,11 @@
...
@@ -62,11 +68,11 @@
field
:
"yearBeforeLastKpi"
,
field
:
"yearBeforeLastKpi"
,
width
:
140
width
:
140
},
},
{
{
title
:
lastYearKpi
,
title
:
lastYearKpi
,
field
:
"lastYearKpi"
,
field
:
"lastYearKpi"
,
width
:
140
width
:
140
},
},
{
{
title
:
"kpi"
,
title
:
"kpi"
,
field
:
"kpi"
,
field
:
"kpi"
,
...
@@ -131,30 +137,29 @@
...
@@ -131,30 +137,29 @@
],
],
queryParams
:
[
queryParams
:
[
[{
[{
label
:
'年度'
,
label
:
'年度'
,
prop
:
'year'
,
prop
:
'year'
,
span
:
6
,
span
:
6
,
type
:
'year'
,
type
:
'year'
,
value
:
new
Date
().
getFullYear
(),
value
:
new
Date
().
getFullYear
(),
typeConfig
:
{
typeConfig
:
{
onChange
:
(
e
)
=>
{
onChange
:
(
e
)
=>
{
let
nowYear
=
this
.
$refs
.
basePage
.
queryParams
.
year
let
nowYear
=
this
.
$refs
.
basePage
.
queryParams
.
year
let
lastYearKpi
=
`
${
nowYear
-
1
}
年kpi`
let
lastYearKpi
=
`
${
nowYear
-
1
}
年kpi`
let
yearBeforeLastKpi
=
`
${
nowYear
-
2
}
年kpi`
let
yearBeforeLastKpi
=
`
${
nowYear
-
2
}
年kpi`
let
list
=
this
.
$refs
.
basePage
.
$refs
.
TablePager
.
newGridList
let
list
=
this
.
$refs
.
basePage
.
$refs
.
TablePager
.
newGridList
list
.
forEach
(
item
=>
{
list
.
forEach
(
item
=>
{
if
(
item
.
prop
==
'lastYearKpi'
){
if
(
item
.
prop
==
'lastYearKpi'
)
{
item
.
label
=
lastYearKpi
item
.
label
=
lastYearKpi
}
}
if
(
item
.
prop
==
'yearBeforeLastKpi'
){
if
(
item
.
prop
==
'yearBeforeLastKpi'
)
{
item
.
label
=
yearBeforeLastKpi
item
.
label
=
yearBeforeLastKpi
}
}
})
})
this
.
$refs
.
basePage
.
refresh
()
this
.
$refs
.
basePage
.
refresh
()
}
}
}
}
}
]
}
]
],
],
/* 默认启停用 */
/* 默认启停用 */
...
@@ -172,7 +177,7 @@
...
@@ -172,7 +177,7 @@
// demo(ctx){}
// demo(ctx){}
},
},
components
:
{
components
:
{
Edit
Edit
,
KpiImportButton
}
}
}
}
...
...
src/views/fmegl/fmekpigl/biao/kpiImportButton/api.js
0 → 100644
View file @
cc872aa7
import
request
from
'common/src/utils/request'
export
function
importTemp
(
query
,
url
)
{
return
request
({
'Content-type'
:
'multipart/form-data'
,
url
:
url
,
method
:
'post'
,
data
:
query
||
{}
})
}
\ No newline at end of file
src/views/fmegl/fmekpigl/biao/kpiImportButton/dialog.vue
0 → 100644
View file @
cc872aa7
<
template
>
<DefaultDialog
:app=
'app'
>
<div
v-loading=
'loading'
slot=
"form"
style=
"display: flex;padding: 20px;padding-bottom: 40px;"
>
<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'
: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: 50px;font-size: 14px;"
>
年份:
</span>
<RelYearSelect
v-model=
"year"
/>
</div>
<div
slot=
"tip"
class=
"el-upload__tip"
>
如没有模板文件请点击
<span
@
click=
"toDownload"
style=
"color: cornflowerblue;cursor: pointer;"
>
模板下载
</span>
。
</div>
</el-upload>
</div>
<div
slot=
"reFooter"
class=
"refooter"
>
<span
slot=
"footer"
class=
"dialog-footer"
>
<el-button
@
click=
"app.showDialog=false"
>
取 消
</el-button>
<el-button
type=
"primary"
@
click=
"submitUpload"
>
导 入
</el-button>
</span>
</div>
</DefaultDialog>
</
template
>
<
script
>
/* element 不支持formData格式 该组件在上传前钩子被该写,非原生请求方法请==注意 */
import
request
from
'common/src/utils/request'
import
{
importTemp
}
from
'./api.js'
const
baseurl
=
process
.
env
.
VUE_APP_BASE_API
export
default
{
props
:
{
app
:
{
type
:
Object
,
default
:
()
=>
{
return
{}
}
}
},
async
mounted
()
{
},
data
()
{
return
{
year
:
new
Date
().
getFullYear
(),
fileList
:
[],
loading
:
false
,
}
},
methods
:
{
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
worksheet
=
workbook
.
Sheets
[
workbook
.
SheetNames
[
0
]];
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
/* 拦截默认上传事件 */
let
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
)
formData
.
append
(
'year'
,
this
.
year
)
importTemp
(
formData
,
this
.
app
.
url
).
then
(
res
=>
{
if
(
res
.
success
)
{
this
.
$success
(
'上传成功'
)
this
.
app
.
showDialog
=
false
this
.
$emit
(
'success'
)
}
}).
finally
(
res
=>
{
this
.
loading
=
false
})
return
false
},
action
()
{
/* 作废 */
let
baseUrl
=
request
.
defaults
.
baseURL
let
url
=
this
.
app
.
url
if
(
url
[
0
]
===
'/'
)
{
url
=
url
.
substring
(
1
);
}
rconsole
.
log
(
baseUrl
+
url
)
return
baseUrl
+
'/'
+
url
},
success
()
{
/* 作废 */
// this.$success('上传成功')
// this.app.showDialog = false
// this.$emit('success')
},
error
()
{
this
.
$error
(
'上传失败'
)
},
exceed
()
{
this
.
$warning
(
'只能选择一个文件!'
)
},
submitUpload
()
{
if
(
this
.
$refs
.
upload
.
uploadFiles
.
length
==
0
)
{
this
.
$warning
(
'请选择一条数据!'
)
}
else
{
this
.
$refs
.
upload
.
submit
();
}
},
handleRemove
(
file
,
fileList
)
{
},
handlePreview
(
file
)
{
rconsole
.
log
(
file
);
this
.
readExcelFile
(
file
.
raw
).
then
((
data
)
=>
{
// 在这里处理读取到的Excel数据
}).
catch
((
error
)
=>
{
console
.
error
(
error
);
});
},
toDownload
()
{
/* let url=this.app.url+"/template/download"
this.$cDownload(url, {
}) */
/* 新版下载 */
let
url
=
this
.
app
.
url
+
"/template/download"
let
userToken
=
null
this
.
$post
(
'/userToken'
,{}).
then
(
res
=>
{
userToken
=
res
.
data
.
userToken
let
a
=
document
.
createElement
(
'a'
)
a
.
style
.
display
=
'none'
;
a
.
target
=
'_blank'
a
.
href
=
`
${
baseurl
}
/
${
url
}
?userToken=
${
userToken
}
`
document
.
body
.
appendChild
(
a
)
a
.
click
()
document
.
body
.
removeChild
(
a
)
})
}
}
}
</
script
>
<
style
scoped
>
</
style
>
src/views/fmegl/fmekpigl/biao/kpiImportButton/index.vue
0 → 100644
View file @
cc872aa7
<
template
>
<div
style=
"display: inline-block;margin-right: 0px;"
class=
""
>
<el-button
@
click=
"dr"
size=
"mini"
type=
"primary"
>
{{
name
}}
</el-button>
<Dialog
@
success=
'success'
v-if=
'showDialog'
:app=
'this'
/>
</div>
</
template
>
<
script
>
import
{
importTemp
}
from
'./api.js'
import
Dialog
from
'./dialog.vue'
export
default
{
props
:
{
name
:
{
type
:
String
,
default
:
'导入'
},
url
:
{
type
:
String
,
default
:
''
},
params
:
{
type
:
Object
,
default
:
()
=>
{
return
{}
}
},
exportName
:
{
type
:
String
,
default
:
'模板.xlsx'
}
},
components
:
{
Dialog
},
data
()
{
return
{
DialogWidth
:
'35vw'
,
showDialog
:
false
,
DialogTitle
:
'导入'
}
},
methods
:
{
success
(){
this
.
$emit
(
'success'
)
},
dr
()
{
if
(
this
.
url
){
this
.
showDialog
=
true
}
else
{
throw
Error
(
'no url'
)
}
},
}
}
</
script
>
<
style
>
</
style
>
\ No newline at end of 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