Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mes-ui
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
周远喜
mes-ui
Commits
1e8f8db5
Commit
1e8f8db5
authored
Aug 26, 2020
by
renjintao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
processBack
parent
c3be47cb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
813 additions
and
17 deletions
+813
-17
process.vue
pages/import/process.vue
+76
-17
processBack.vue
pages/import/processBack.vue
+737
-0
No files found.
pages/import/process.vue
View file @
1e8f8db5
<
template
>
<div
class=
"content"
>
<div
class=
"
table-
content"
>
<TablePaste
hide-table
:input-props=
"inputProps"
@
on-success=
"handleSuccess"
@
on-error=
"handleError"
v-show=
"showTablePaste"
/>
<
DataGrid
border
:height=
"tdHeightExcel"
:columns=
"columnsImport"
:data=
"excelData"
:page=
"false"
:set=
"false
"
>
<
template
slot=
"easyS
earch"
>
<
div
class=
"table-tools
"
>
<
div
class=
"table-s
earch"
>
<Form
inline
>
<FormItem>
<span>
导入到
</span>
...
...
@@ -16,13 +16,6 @@
<FormItem>
<Button
type=
"primary"
@
click=
"openInfoModal"
>
导入
</Button>
</FormItem>
</Form>
</
template
>
<
template
slot=
"buttons"
>
<Form
inline
>
<FormItem>
<Button
@
click=
"downFile"
>
下载原始文件
</Button>
</FormItem>
<FormItem>
<div
style=
"height:34px;overflow: hidden;padding:0"
>
<Upload
action
:before-upload=
"beforeUpload"
ref=
"uploadfile"
:format=
"formatList"
>
...
...
@@ -30,15 +23,33 @@
</Upload>
</div>
</FormItem>
</Form>
</div>
<div
class=
"btns"
>
<Form
inline
>
<FormItem>
原文件:
<a
@
click=
"downFile"
>
{{
entity
.
file
}}
</a>
</FormItem>
<FormItem>
<a
class=
"ml10 mr10"
@
click=
"resetTable"
>
刷新
</a>
</FormItem>
<FormItem>
<Button
@
click=
"openPaste"
:type=
"btnType"
:ghost=
"ghostStatus"
>
{{
btnTxt
}}
</Button>
</FormItem>
<FormItem>
<Button
@
click=
"resetTable"
>
还原到原始文件
</Button>
<RadioGroup
value=
"large"
type=
"button"
>
<Radio
label=
"large"
>
数据展示
</Radio>
<Radio
label=
"default"
>
粘贴Excel
</Radio>
</RadioGroup>
</FormItem>
</Form>
</
template
>
</DataGrid>
</div>
</div>
<div
class=
"table-main"
ref=
"main"
>
<Table
border=
"true"
:columns=
"columnsImport"
:data=
"excelData"
:height=
"tdHeightExcel"
ref=
"table"
class=
"tableCommon"
></Table>
</div>
<FooterToolbar
v-if=
"sheetNames.length>1"
>
<Form
inline
>
<FormItem>
...
...
@@ -551,10 +562,10 @@ export default {
pageChange
(
val
)
{
switch
(
val
)
{
case
0
:
this
.
loadColum
(
this
.
columns0
);
//
this.loadColum(this.columns0);
break
;
case
1
:
this
.
loadColum
(
this
.
columns1
);
//
this.loadColum(this.columns1);
break
;
case
undefined
:
if
(
this
.
dataType
==
0
)
{
...
...
@@ -564,7 +575,7 @@ export default {
}
break
;
default
:
this
.
loadColum
(
this
.
columns1
);
//
this.loadColum(this.columns1);
}
},
handleClose
()
{
...
...
@@ -720,7 +731,54 @@ export default {
</
script
>
<
style
lang=
"less"
>
.content {
.table-content {
position: relative;
height: 100%;
display: flex;
flex-direction: column;
.tip {
display: inline;
}
form {
display: inline-block;
.ivu-form-item {
margin: 0;
vertical-align: middle;
}
}
.table-main {
width: 100%;
text-align: left;
padding: 0;
display: block;
overflow-y: auto;
flex-grow: 1;
tr td .ivu-table-cell {
padding: 0 5px;
}
overflow-x: hidden;
}
.table-tools {
display: flex;
line-height: 50px;
.table-search {
flex-grow: 1;
}
.btns {
min-width: 200px;
text-align: right;
}
}
.table-footer {
line-height: 45px;
background: #f5f5f5;
...
...
@@ -728,6 +786,7 @@ export default {
.ivu-footer-toolbar {
text-align: left;
background: #f5f5f5;
.ivu-footer-toolbar-right {
float: left;
...
...
pages/import/processBack.vue
0 → 100644
View file @
1e8f8db5
<
template
>
<div
class=
"content"
>
<TablePaste
hide-table
:input-props=
"inputProps"
@
on-success=
"handleSuccess"
@
on-error=
"handleError"
v-show=
"showTablePaste"
/>
<DataGrid
border
:height=
"tdHeightExcel"
:columns=
"columnsImport"
:data=
"excelData"
:page=
"false"
:set=
"false"
>
<template
slot=
"easySearch"
>
<Form
inline
>
<FormItem>
<span>
导入到
</span>
</FormItem>
<FormItem>
<dictionary
code=
"import.im.page"
style=
"width:160px"
@
on-change=
"pageChange"
v-model=
"pageType"
></dictionary>
</FormItem>
<FormItem>
<div
class=
"tip mr20"
>
共
{{
excelData
.
length
}}
条数据
</div>
</FormItem>
<FormItem>
<Button
type=
"primary"
@
click=
"openInfoModal"
>
导入
</Button>
</FormItem>
</Form>
</
template
>
<
template
slot=
"buttons"
>
<Form
inline
>
<FormItem>
<Button
@
click=
"downFile"
>
下载原始文件
</Button>
</FormItem>
<FormItem>
<div
style=
"height:34px;overflow: hidden;padding:0"
>
<Upload
action
:before-upload=
"beforeUpload"
ref=
"uploadfile"
:format=
"formatList"
>
<Button
icon=
"ios-cloud-upload-outline"
@
click=
"resetParms"
>
重新上传
</Button>
</Upload>
</div>
</FormItem>
<FormItem>
<Button
@
click=
"openPaste"
:type=
"btnType"
:ghost=
"ghostStatus"
>
{{
btnTxt
}}
</Button>
</FormItem>
<FormItem>
<Button
@
click=
"resetTable"
>
还原到原始文件
</Button>
</FormItem>
</Form>
</
template
>
</DataGrid>
<FooterToolbar
v-if=
"sheetNames.length>1"
>
<Form
inline
>
<FormItem>
<Tabs
:animated=
"false"
:value=
"0"
@
on-click=
"sheetClick"
>
<TabPane
:label=
"item"
v-for=
"(item,index) in sheetNames"
></TabPane>
</Tabs>
</FormItem>
</Form>
</FooterToolbar>
<Modal
v-model=
"infoModal"
title=
"提示信息"
@
on-ok=
"importOk"
>
<p>
确定批量导入数据到
<span
class=
"red f16 fwBold ml10 mr10"
>
用户管理
</span>
模块下?
</p>
</Modal>
</div>
</template>
<
script
>
import
Api
from
"./api"
;
import
XLSX
from
"xlsx"
;
import
{
Switch
}
from
"view-design"
;
export
default
{
name
:
"Edit"
,
data
()
{
return
{
pageType
:
undefined
,
tabVal
:
0
,
infoModal
:
false
,
entity
:
{},
downUrl
:
fileUrlDown
,
fileUrlPath
:
""
,
disabled
:
false
,
columns0
:
[{
key
:
"userName"
,
title
:
this
.
l
(
"userName"
),
align
:
"left"
,
easy
:
true
,
},
{
key
:
"cardNo"
,
title
:
this
.
l
(
"cardNo"
),
align
:
"left"
,
easy
:
true
,
high
:
true
,
},
{
key
:
"gender"
,
title
:
this
.
l
(
"gender"
),
align
:
"center"
,
high
:
true
,
code
:
"User.base.gender"
,
},
{
key
:
"birthday"
,
title
:
this
.
l
(
"birthday"
),
align
:
"center"
,
high
:
true
,
type
:
"date"
,
},
{
key
:
"degreeId"
,
title
:
this
.
l
(
"degreeId"
),
align
:
"left"
,
high
:
true
,
code
:
"User.base.degree"
,
},
{
key
:
"status"
,
title
:
this
.
l
(
"status"
),
align
:
"center"
,
high
:
true
,
code
:
"User.base.status"
,
},
{
key
:
"departmentId"
,
title
:
this
.
l
(
"departmentId"
),
align
:
"right"
,
easy
:
true
,
high
:
true
,
},
{
key
:
"departmentTitle"
,
title
:
this
.
l
(
"departmentTitle"
),
align
:
"left"
,
easy
:
true
,
high
:
true
,
},
{
key
:
"roleTitles"
,
title
:
this
.
l
(
"roleTitles"
),
align
:
"left"
,
easy
:
true
,
high
:
true
,
hide
:
true
,
render
:
(
h
,
params
)
=>
{
return
h
(
"div"
,
{
class
:
"action"
,
},
[
h
(
"op"
,
{
attrs
:
{
oprate
:
"detail"
,
class
:
params
.
row
.
roleTitles
==
null
||
params
.
row
.
roleTitles
==
""
?
"empower"
:
"detail"
,
},
on
:
{
click
:
()
=>
this
.
authorize
(
params
.
row
.
id
),
},
},
params
.
row
.
roleTitles
==
null
||
params
.
row
.
roleTitles
==
""
?
"授权"
:
params
.
row
.
roleTitles
),
]
);
},
},
{
key
:
"accountId"
,
title
:
this
.
l
(
"accountId"
),
hide
:
true
,
align
:
"left"
,
},
{
key
:
"phone"
,
title
:
this
.
l
(
"phone"
),
align
:
"left"
,
easy
:
true
,
high
:
true
,
},
{
key
:
"email"
,
title
:
this
.
l
(
"email"
),
align
:
"left"
,
easy
:
true
,
high
:
true
,
},
{
key
:
"licensedToWork"
,
title
:
this
.
l
(
"licensedToWork"
),
align
:
"left"
,
},
{
key
:
"positionId"
,
title
:
this
.
l
(
"positionId"
),
align
:
"left"
,
high
:
true
,
code
:
"User.base.position"
,
},
{
key
:
"titleId"
,
title
:
this
.
l
(
"titleId"
),
align
:
"left"
,
high
:
true
,
code
:
"User.base.jobtitle"
,
},
{
key
:
"creatorUserId"
,
title
:
this
.
l
(
"creatorUserId"
),
align
:
"left"
,
import
:
false
,
hide
:
true
,
},
{
key
:
"creationTime"
,
title
:
this
.
l
(
"creationTime"
),
align
:
"left"
,
import
:
false
,
hide
:
true
,
},
{
key
:
"lastModifierUserId"
,
title
:
this
.
l
(
"lastModifierUserId"
),
align
:
"left"
,
import
:
false
,
hide
:
true
,
},
{
key
:
"lastModificationTime"
,
title
:
this
.
l
(
"lastModificationTime"
),
align
:
"left"
,
import
:
false
,
hide
:
true
,
},
{
title
:
"操作"
,
key
:
"action"
,
width
:
180
,
align
:
"right"
,
import
:
false
,
render
:
(
h
,
params
)
=>
{
return
h
(
"div"
,
{
class
:
"action"
,
},
[
h
(
"op"
,
{
attrs
:
{
oprate
:
"detail"
,
class
:
"empower"
,
},
on
:
{
click
:
()
=>
this
.
syncAccount
(
params
.
row
),
},
},
params
.
row
.
accountId
==
0
?
"同步"
:
""
),
h
(
"op"
,
{
attrs
:
{
oprate
:
"edit"
,
},
on
:
{
click
:
()
=>
this
.
edit
(
params
.
row
.
id
),
},
},
"编辑"
),
h
(
"op"
,
{
attrs
:
{
oprate
:
"remove"
,
},
on
:
{
click
:
()
=>
this
.
remove
(
params
.
row
),
},
},
"删除"
),
h
(
"op"
,
{
attrs
:
{
oprate
:
"detail"
,
},
on
:
{
click
:
()
=>
this
.
openReset
(
params
.
row
),
},
},
"重置密码"
),
]
);
},
},
],
columns1
:
[{
key
:
"userName"
,
title
:
this
.
l
(
"userName"
),
align
:
"left"
,
},
{
key
:
"status"
,
title
:
this
.
l
(
"status"
),
align
:
"center"
,
code
:
"User.base.status"
,
},
],
tdHeightExcel
:
""
,
excelData
:
[],
excelDataBack
:
[],
//临时存储原始数据
formatList
:
[
"xlsx"
],
columnsImport
:
[],
departArr
:
[],
//部门list
sheetNames
:
[],
//excel的表明
workBook
:
{},
openDatas
:
[],
dataType
:
0
,
//粘贴excel内容start
btnType
:
"default"
,
ghostStatus
:
false
,
btnTxt
:
"打开粘贴Excel"
,
showTablePaste
:
false
,
inputProps
:
{
rows
:
10
,
placeholder
:
"请从Excel复制一段表格数据,粘贴在这里"
,
},
};
},
props
:
{
eid
:
Number
,
},
created
()
{
this
.
tdHeightExcel
=
window
.
innerHeight
-
180
;
//导出对列表头进行预加载start
this
.
$api
.
get
(
`
${
systemUrl
}
/Department/GetDepartments`
).
then
((
r
)
=>
{
this
.
departArr
=
r
.
result
.
items
;
});
//导出对列表头进行预加载end
},
mounted
()
{
if
(
this
.
eid
>
0
)
{
this
.
load
(
this
.
eid
);
}
window
.
onresize
=
()
=>
{
///浏览器窗口大小变化
return
(()
=>
{
window
.
screenHeight
=
window
.
innerHeight
;
if
(
this
.
showTablePaste
)
{
this
.
tdHeightExcel
=
window
.
screenHeight
-
180
-
220
;
}
else
{
this
.
tdHeightExcel
=
window
.
screenHeight
-
180
;
}
})();
};
},
methods
:
{
load
(
v
)
{
Api
.
get
({
id
:
v
,
}).
then
((
r
)
=>
{
this
.
entity
=
r
.
result
||
{};
});
this
.
dataType
=
0
;
this
.
sheetNames
=
[];
this
.
excelData
=
[];
this
.
excelDataBack
=
[];
Api
.
openExcel
({
id
:
v
,
}).
then
((
res
)
=>
{
if
(
res
.
success
)
{
this
.
openDatas
=
res
.
result
||
[];
this
.
dealOpenTable
(
0
);
//获取excel sheetname
if
(
res
.
result
.
length
>
0
)
{
res
.
result
.
forEach
((
el
)
=>
{
this
.
sheetNames
.
push
(
el
.
title
);
});
}
}
});
},
//加载原文件列表
dealOpenTable
(
val
)
{
this
.
excelData
=
this
.
openDatas
[
val
].
dataTable
;
this
.
excelDataBack
=
this
.
openDatas
[
val
].
dataTable
;
var
tempCos
=
Object
.
keys
(
this
.
openDatas
[
val
].
dataTable
[
0
]);
//获取列表标题
this
.
columnsImport
=
[];
var
headersNow
=
[];
tempCos
.
forEach
((
el
)
=>
{
let
headObj
=
{};
headObj
.
title
=
el
;
headObj
.
key
=
el
;
headersNow
.
push
(
headObj
);
});
this
.
columnsImport
=
headersNow
;
},
//重新处理colum
loadColum
(
columns
)
{
let
tempCol
=
this
.
$u
.
clone
(
columns
);
tempCol
.
forEach
((
ele
,
index
)
=>
{
if
(
ele
.
key
==
"action"
)
{
ele
.
hide
=
true
;
}
});
this
.
columnsImport
=
tempCol
;
//处理原始数据和表头进行对应
let
temCol
=
this
.
$u
.
clone
(
this
.
columnsImport
);
//原始数据表头
let
temColPage
=
this
.
$u
.
clone
(
columns
);
//需要显示的页面的表头
let
temData
=
this
.
$u
.
clone
(
this
.
excelDataBack
);
//原始数据
let
arrTitleUse
=
[];
////使用数据字典的字段
temColPage
.
forEach
((
elCode
)
=>
{
if
(
elCode
.
code
)
{
arrTitleUse
.
push
({
key
:
elCode
.
key
,
code
:
elCode
.
code
,
});
}
});
let
useData
=
[];
//重新组织list列表数据
temData
.
forEach
((
elData
,
index
)
=>
{
let
objTm
=
{};
temCol
.
forEach
((
elTitle
)
=>
{
objTm
[
elTitle
.
key
]
=
elData
[
elTitle
.
title
];
});
useData
.
push
(
objTm
);
});
//对列表里的部门及数据字典项进行处理
useData
.
forEach
(
eles
=>
{
//如果导入文件没有departmentid,但存在departmentTitle的话,通过title获取id
if
(
eles
.
departmentTitle
&&
eles
.
departmentTitle
!=
""
&&
(
!
eles
.
departmentId
||
eles
.
departmentId
==
""
)
)
{
this
.
departArr
.
forEach
((
e
)
=>
{
if
(
eles
.
departmentTitle
&&
eles
.
departmentTitle
==
e
.
name
)
{
eles
.
departmentId
=
e
.
id
;
}
});
}
else
if
(
//如果导入文件没有departmentTitle,但存在departmentid的话,通过id获取departmentTitle
eles
.
departmentId
&&
eles
.
departmentId
+
""
!=
""
&&
(
!
eles
.
departmentTitle
||
eles
.
departmentTitle
==
""
)
)
{
this
.
departArr
.
forEach
((
e
)
=>
{
if
(
eles
.
departmentId
&&
eles
.
departmentId
==
e
.
id
)
{
eles
.
departmentTitle
=
e
.
name
;
}
});
}
arrTitleUse
.
forEach
((
elem
)
=>
{
if
(
eles
[
elem
.
key
]
&&
eles
[
elem
.
key
]
!=
""
&&
eles
[
elem
.
key
]
!=
null
)
{
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值
eles
[
elem
.
key
]
=
this
.
$u
.
dirCode
(
this
.
$store
.
getters
.
dictionaryByKey
(
elem
.
code
),
eles
[
elem
.
key
]
);
}
});
})
this
.
excelData
=
useData
;
},
//下载原excel文件
downFile
()
{
let
truePath
=
this
.
entity
.
path
;
if
(
truePath
.
length
>
2
)
{
if
(
truePath
.
substring
(
0
,
7
).
toLowerCase
()
==
"http://"
||
truePath
.
substring
(
0
,
8
).
toLowerCase
()
==
"https://"
)
{
window
.
open
(
truePath
,
"_blank"
);
}
else
{
this
.
fileUrlPath
=
this
.
downUrl
+
this
.
entity
.
path
;
window
.
open
(
this
.
fileUrlPath
,
"_blank"
);
}
}
},
//导入excel文件
//打开传时初始化
resetParms
()
{
this
.
pageType
=
undefined
;
this
.
btnTxt
=
"打开粘贴Excel"
;
this
.
showTablePaste
=
false
;
this
.
btnType
=
"default"
;
this
.
ghostStatus
=
false
;
this
.
tdHeightExcel
=
window
.
innerHeight
-
180
;
},
async
beforeUpload
(
file
)
{
//初始化
this
.
sheetNames
=
[];
this
.
workBook
=
{};
this
.
$refs
.
uploadfile
.
clearFiles
();
//清除上一次上传文件列表
//上传成功后的读取到excel信息
this
.
workBook
=
await
this
.
$u
.
readXLSX
(
file
);
this
.
sheetNames
=
this
.
workBook
.
SheetNames
;
//execel里的表明
this
.
dealSheet
(
0
);
//默认显示第一个表
return
false
;
},
//对上传的excel表信息进行处理,不对表头进行处理
dealSheet
(
index
)
{
this
.
dataType
=
1
;
this
.
columnsImport
=
[];
this
.
excelData
=
[];
this
.
excelDataBack
=
[];
const
sheet2JSONOpts
=
{
defval
:
""
,
//给defval赋值为空的字符串
};
var
csv
=
XLSX
.
utils
.
sheet_to_csv
(
this
.
workBook
.
Sheets
[
this
.
workBook
.
SheetNames
[
index
]],
sheet2JSONOpts
);
var
lines
=
csv
.
split
(
"
\n
"
);
//第一行标题
var
headers
=
lines
[
0
].
split
(
","
);
var
headersNow
=
[];
headers
.
forEach
((
elHead
)
=>
{
let
headObj
=
{};
headObj
.
title
=
elHead
;
headObj
.
key
=
elHead
;
headersNow
.
push
(
headObj
);
});
this
.
columnsImport
=
headersNow
;
var
result
=
[];
for
(
var
i
=
1
;
i
<
lines
.
length
-
1
;
i
++
)
{
var
obj
=
{};
var
currentline
=
lines
[
i
].
split
(
","
);
for
(
var
j
=
0
;
j
<
headers
.
length
;
j
++
)
{
obj
[
headers
[
j
]]
=
currentline
[
j
];
}
result
.
push
(
obj
);
}
this
.
excelData
=
result
;
this
.
excelDataBack
=
result
;
},
//切换sheet表重新加载
sheetClick
(
val
)
{
this
.
tabVal
=
val
if
(
this
.
dataType
==
0
)
{
this
.
dealOpenTable
(
val
);
}
else
{
this
.
dealSheet
(
val
);
}
if
(
this
.
pageType
!=
undefined
)
{
this
.
pageChange
(
this
.
pageType
)
}
},
//选择导入的模块 0:用户管理
pageChange
(
val
)
{
switch
(
val
)
{
case
0
:
this
.
loadColum
(
this
.
columns0
);
break
;
case
1
:
this
.
loadColum
(
this
.
columns1
);
break
;
case
undefined
:
if
(
this
.
dataType
==
0
)
{
this
.
load
(
this
.
eid
);
}
else
{
this
.
dealSheet
(
this
.
tabVal
);
}
break
;
default
:
this
.
loadColum
(
this
.
columns1
);
}
},
handleClose
()
{
this
.
$emit
(
"on-close"
);
},
cancelExcel
()
{
this
.
excelData
=
[];
this
.
excelDataBack
=
[];
this
.
$refs
.
uploadfile
.
clearFiles
();
let
parms
=
{
status
:
1
,
id
:
this
.
eid
}
//导入中心列表数据状态更新
Api
.
updateimportstatus
(
parms
).
then
(
res
=>
{
if
(
res
.
success
)
{
this
.
$emit
(
"on-ok"
);
}
})
this
.
$emit
(
"on-close"
);
},
//粘贴excel相关start
openPaste
()
{
if
(
this
.
btnTxt
==
"打开粘贴Excel"
)
{
this
.
btnType
=
"primary"
;
this
.
ghostStatus
=
true
;
this
.
showTablePaste
=
true
;
this
.
btnTxt
=
"关闭粘贴Excel"
;
this
.
tdHeightExcel
=
window
.
innerHeight
-
180
-
220
;
}
else
{
this
.
btnType
=
"default"
;
this
.
ghostStatus
=
false
;
this
.
showTablePaste
=
false
;
this
.
btnTxt
=
"打开粘贴Excel"
;
this
.
tdHeightExcel
=
window
.
innerHeight
-
180
;
}
},
//粘贴excel成功
handleSuccess
(
tableData
)
{
//初始化数据
this
.
excelData
=
[];
this
.
excelDataBack
=
[];
this
.
columnsImport
=
[];
this
.
sheetNames
=
[];
this
.
pageType
=
undefined
;
//处理colum和data
let
tabColum
=
tableData
.
columns
let
tabData
=
tableData
.
data
let
arrData
=
[]
tabData
.
forEach
(
ele
=>
{
let
objData
=
{}
tabColum
.
forEach
(
el
=>
{
objData
[
el
.
title
]
=
ele
[
el
.
key
]
})
arrData
.
push
(
objData
)
})
//处理title和key一致
tabColum
.
forEach
(
el
=>
{
el
.
key
=
el
.
title
})
this
.
columnsImport
=
tabColum
;
this
.
excelData
=
arrData
;
this
.
excelDataBack
=
arrData
;
},
//粘贴excel失败
handleError
(
tableData
,
errorIndex
)
{
//console.log(tableData, errorIndex);
this
.
$Message
.
error
(
"表格数据有误"
);
},
//粘贴excel相关end
//重新加载excel
resetTable
()
{
this
.
pageType
=
undefined
;
this
.
btnTxt
=
"打开粘贴Excel"
;
this
.
showTablePaste
=
false
;
this
.
btnType
=
"default"
;
this
.
ghostStatus
=
false
;
this
.
load
(
this
.
eid
);
this
.
tdHeightExcel
=
window
.
innerHeight
-
180
;
},
openInfoModal
()
{
if
(
this
.
excelData
.
length
>
0
&&
this
.
pageType
!=
undefined
)
{
this
.
infoModal
=
true
}
else
{
if
(
this
.
excelData
.
length
==
0
)
{
this
.
$Message
.
error
(
"表【"
+
this
.
sheetNames
[
this
.
tabVal
]
+
"】没有可导入的数据!"
)
}
else
if
(
this
.
pageType
==
undefined
)
{
this
.
$Message
.
error
(
"请选择需要批量导入到的模块!"
)
}
}
},
//导入按钮操作
importOk
()
{
switch
(
this
.
pageType
)
{
case
0
:
this
.
importUser
();
break
;
case
1
:
this
.
loadColum
(
this
.
columns1
);
break
;
default
:
this
.
loadColum
(
this
.
columns1
);
}
},
//批量导入用户
importUser
()
{
let
tempData
=
this
.
$u
.
clone
(
this
.
excelData
);
let
tempList
=
[];
tempData
.
forEach
((
ele
)
=>
{
let
obj
=
{
userName
:
ele
.
userName
,
cardNo
:
ele
.
cardNo
,
gender
:
ele
.
gender
,
birthday
:
ele
.
birthday
,
degreeId
:
ele
.
degreeId
,
departmentId
:
ele
.
departmentId
,
status
:
ele
.
status
,
phone
:
ele
.
phone
,
email
:
ele
.
email
,
licensedToWork
:
ele
.
licensedToWork
,
positionId
:
ele
.
positionId
,
titleId
:
ele
.
titleId
,
departmentTitle
:
ele
.
departmentTitle
,
};
tempList
.
push
(
obj
);
});
let
parms
=
{
list
:
tempList
,
};
Api
.
importUser
(
parms
).
then
((
res
)
=>
{
if
(
res
.
success
)
{
this
.
$Message
.
success
(
"批量导入用户管理成功!"
);
this
.
cancelExcel
();
}
else
{
this
.
$Message
.
error
(
"批量导入用户管理失败!"
);
}
});
},
l
(
key
)
{
key
=
"user"
+
"."
+
key
;
return
this
.
$t
(
key
);
},
},
watch
:
{
eid
(
v
)
{
if
(
v
!=
0
)
{
this
.
load
(
v
);
}
},
},
};
</
script
>
<
style
lang=
"less"
>
.content {
.table-footer {
line-height: 45px;
background: #f5f5f5;
}
.ivu-footer-toolbar {
text-align: left;
.ivu-footer-toolbar-right {
float: left;
}
}
}
</
style
>
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