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
a51fe745
Commit
a51fe745
authored
Aug 27, 2020
by
renjintao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changeExcel
parent
51a0cf28
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
119 deletions
+110
-119
detailExcel.vue
pages/import/detailExcel.vue
+35
-0
process.vue
pages/import/process.vue
+75
-119
No files found.
pages/import/detailExcel.vue
View file @
a51fe745
...
...
@@ -27,6 +27,8 @@ export default {
rows
:
10
,
placeholder
:
"请从Excel复制一段表格数据,粘贴在这里"
,
},
columnsImport
:
[],
excelData
:
[]
};
},
...
...
@@ -77,6 +79,39 @@ export default {
}
}
},
//粘贴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
l
(
key
)
{
key
=
"import_center"
+
"."
+
key
;
return
this
.
$t
(
key
);
...
...
pages/import/process.vue
View file @
a51fe745
<
template
>
<div
class=
"table-content"
>
<TablePaste
hide-table
:input-props=
"inputProps"
@
on-success=
"handleSuccess"
@
on-error=
"handleError"
v-show=
"showTablePaste"
/>
<div
class=
"table-tools"
>
<div
class=
"table-search"
>
<Form
inline
>
...
...
@@ -14,7 +13,7 @@
<div
class=
"tip mr20"
>
共
{{
excelData
.
length
}}
条数据
</div>
</FormItem>
<FormItem>
<Button
type=
"primary"
@
click=
"openInfoModal"
>
导入
</Button>
<Button
type=
"primary"
@
click=
"openInfoModal"
:disabled=
"btnIm"
>
导入
</Button>
</FormItem>
<FormItem>
<div
style=
"height:34px;overflow: hidden;padding:0"
>
...
...
@@ -38,11 +37,8 @@
<Icon
type=
"md-eye"
/>
预览
</a>
</FormItem>
<FormItem
v-if=
"show"
>
<Button
@
click=
"openPaste"
:type=
"btnType"
:ghost=
"ghostStatus"
>
{{
btnTxt
}}
</Button>
</FormItem>
<FormItem>
<RadioGroup
v
alue=
"0
"
type=
"button"
@
on-change=
"changeExcel"
>
<RadioGroup
v
-model=
"excelType
"
type=
"button"
@
on-change=
"changeExcel"
>
<Radio
label=
"0"
>
<Icon
type=
"md-list"
/>
列表
</Radio>
...
...
@@ -55,10 +51,9 @@
</div>
</div>
<div
class=
"table-main"
ref=
"main"
>
<Table
border=
"true"
:columns=
"columnsImport"
:data=
"excelData"
:height=
"tdHeightExcel"
ref=
"table"
class=
"tableCommon"
v-if=
"tableImport"
></Table>
<component
:is=
"detailExcel"
/>
<Table
:
border=
"true"
:columns=
"columnsImport"
:data=
"excelData"
:height=
"tdHeightExcel"
ref=
"table"
class=
"tableCommon"
v-if=
"tableImport"
></Table>
<component
:is=
"detailExcel"
ref=
"comExcel"
/>
</div>
<FooterToolbar
v-if=
"sheetNames.length>1&&tableImport"
>
<Form
inline
>
<FormItem>
...
...
@@ -68,8 +63,12 @@
</FormItem>
</Form>
</FooterToolbar>
<Modal
v-model=
"infoModal"
title=
"提示信息"
@
on-ok=
"importOk"
>
<p>
确定批量导入数据到
<span
class=
"red f16 fwBold ml10 mr10"
>
用户管理
</span>
模块下?
</p>
<Modal
v-model=
"infoModal"
title=
"确定批量导入"
fullscreen
>
<DataGrid
:tool=
"false"
:page=
"false"
:columns=
"colsIm"
:data=
"dataIm"
:height=
"tdHeightExcel+30"
ref=
"dataImport"
></DataGrid>
<div
slot=
"footer"
>
<Button
@
click=
"infoModal=false"
>
关闭
</Button>
<Button
type=
"primary"
@
click=
"importOk"
>
确定导入
</Button>
</div>
</Modal>
</div>
</
template
>
...
...
@@ -334,15 +333,11 @@ export default {
workBook
:
{},
openDatas
:
[],
dataType
:
0
,
//粘贴excel内容start
btnType
:
"default"
,
ghostStatus
:
false
,
btnTxt
:
"打开粘贴Excel"
,
showTablePaste
:
false
,
inputProps
:
{
rows
:
10
,
placeholder
:
"请从Excel复制一段表格数据,粘贴在这里"
,
},
//new
colsIm
:
[],
dataIm
:
[],
excelType
:
'0'
,
btnIm
:
true
,
};
},
props
:
{
...
...
@@ -365,11 +360,7 @@ export default {
///浏览器窗口大小变化
return
(()
=>
{
window
.
screenHeight
=
window
.
innerHeight
;
if
(
this
.
showTablePaste
)
{
this
.
tdHeightExcel
=
window
.
screenHeight
-
180
-
220
;
}
else
{
this
.
tdHeightExcel
=
window
.
screenHeight
-
180
;
}
this
.
tdHeightExcel
=
window
.
screenHeight
-
180
;
})();
};
...
...
@@ -423,11 +414,17 @@ export default {
ele
.
hide
=
true
;
}
});
this
.
col
umnsImport
=
tempCol
;
this
.
col
sIm
=
tempCol
;
//处理原始数据和表头进行对应
let
temCol
=
this
.
$u
.
clone
(
this
.
col
umnsImport
);
//原始数据表头
let
temCol
=
this
.
$u
.
clone
(
this
.
col
sIm
);
//原始数据表头
let
temColPage
=
this
.
$u
.
clone
(
columns
);
//需要显示的页面的表头
let
temData
=
this
.
$u
.
clone
(
this
.
excelDataBack
);
//原始数据
//let temData = this.$u.clone(this.excelDataBack); //原始数据
let
temData
=
[];
//原始数据
if
(
this
.
excelType
==
"0"
)
{
temData
=
this
.
$u
.
clone
(
this
.
excelDataBack
)
}
else
{
temData
=
this
.
$u
.
clone
(
this
.
$refs
.
comExcel
.
excelData
)
}
let
arrTitleUse
=
[];
////使用数据字典的字段
temColPage
.
forEach
((
elCode
)
=>
{
if
(
elCode
.
code
)
{
...
...
@@ -482,7 +479,7 @@ export default {
}
});
})
this
.
excelData
=
useData
;
this
.
dataIm
=
useData
;
},
//下载原excel文件
downFile
()
{
...
...
@@ -503,10 +500,6 @@ export default {
//打开传时初始化
resetParms
()
{
this
.
pageType
=
undefined
;
this
.
btnTxt
=
"打开粘贴Excel"
;
this
.
showTablePaste
=
false
;
this
.
btnType
=
"default"
;
this
.
ghostStatus
=
false
;
this
.
tdHeightExcel
=
window
.
innerHeight
-
180
;
},
async
beforeUpload
(
file
)
{
...
...
@@ -556,6 +549,7 @@ export default {
}
this
.
excelData
=
result
;
this
.
excelDataBack
=
result
;
this
.
changeExcel
(
0
)
},
//切换sheet表重新加载
sheetClick
(
val
)
{
...
...
@@ -571,23 +565,13 @@ export default {
},
//选择导入的模块 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);
this
.
btnIm
=
false
if
(
val
==
undefined
)
{
this
.
btnIm
=
true
}
else
{
this
.
btnIm
=
false
}
},
handleClose
()
{
this
.
$emit
(
"on-close"
);
...
...
@@ -608,67 +592,28 @@ export default {
})
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
;
if
(
this
.
excelType
==
1
)
{
this
.
changeExcel
(
0
)
}
},
openInfoModal
()
{
if
(
this
.
excelData
.
length
>
0
&&
this
.
pageType
!=
undefined
)
{
switch
(
this
.
pageType
)
{
case
0
:
this
.
loadColum
(
this
.
columns0
);
break
;
case
1
:
this
.
loadColum
(
this
.
columns1
);
break
;
default
:
this
.
loadColum
(
this
.
columns0
);
}
this
.
infoModal
=
true
}
else
{
if
(
this
.
excelData
.
length
==
0
)
{
...
...
@@ -685,15 +630,15 @@ export default {
this
.
importUser
();
break
;
case
1
:
this
.
loadColum
(
this
.
columns1
);
//
this.loadColum(this.columns1);
break
;
default
:
this
.
loadColum
(
this
.
columns1
);
//
this.loadColum(this.columns1);
}
},
//批量导入用户
importUser
()
{
let
tempData
=
this
.
$u
.
clone
(
this
.
excelData
);
let
tempData
=
this
.
$u
.
clone
(
this
.
dataIm
);
let
tempList
=
[];
tempData
.
forEach
((
ele
)
=>
{
let
obj
=
{
...
...
@@ -711,30 +656,41 @@ export default {
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
(
"批量导入用户管理失败!"
);
if
(
ele
.
userName
&&
ele
.
userName
!=
''
&&
ele
.
cardNo
&&
ele
.
cardNo
!=
''
&&
ele
.
departmentId
&&
ele
.
departmentId
!=
''
&&
ele
.
phone
&&
ele
.
phone
!=
''
)
{
tempList
.
push
(
obj
);
}
});
if
(
tempList
.
length
==
0
)
{
this
.
$Message
.
error
(
"所有导入的数据均不合法!"
);
}
else
{
let
parms
=
{
list
:
tempList
,
};
Api
.
importUser
(
parms
).
then
((
res
)
=>
{
if
(
res
.
success
)
{
this
.
$Message
.
success
(
"成功批量导入用户管理成功模块 "
+
tempList
.
length
+
" 条数据"
);
this
.
cancelExcel
();
}
else
{
this
.
$Message
.
error
(
"批量导入用户管理失败!"
);
}
});
}
},
changeExcel
(
val
)
{
if
(
val
==
1
)
{
this
.
tableImport
=
false
this
.
detailExcel
=
()
=>
import
(
"./detailExcel"
);
this
.
pageType
=
undefined
this
.
excelType
=
'1'
;
}
else
{
this
.
detailExcel
=
null
;
this
.
tableImport
=
true
this
.
tableImport
=
true
;
this
.
pageType
=
undefined
this
.
excelType
=
'0'
;
}
},
l
(
key
)
{
key
=
"user"
+
"."
+
key
;
...
...
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