Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
memberTag-web
Overview
Overview
Details
Activity
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
memberTag
memberTag-web
Commits
87e95f73
Commit
87e95f73
authored
Jan 13, 2020
by
member
Browse files
Options
Browse Files
Download
Plain Diff
路由模式切换
parents
bb71044b
39a6422d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
42 deletions
+67
-42
api.js
src/api/api.js
+1
-1
index.js
src/router/index.js
+3
-0
manual-tag-value-edit.vue
src/view/manualTag/manual-tag-value-edit.vue
+63
-41
No files found.
src/api/api.js
View file @
87e95f73
...
...
@@ -194,6 +194,6 @@ export const postForm = (url, params) => {
// return data
// }
// ],
headers
:
{}
//'content-type': 'application/x-www-form-urlencoded'multipart/form-data{"token": token}
headers
:
{
'Content-Type'
:
'multipart/form-data'
}
//'content-type': 'application/x-www-form-urlencoded'multipart/form-data{"token": token}
});
};
src/router/index.js
View file @
87e95f73
...
...
@@ -170,6 +170,8 @@ export const constantRouterMap = [
];
export
default
new
Router
({
// mode: 'history',
// base: '/member-tag/',
routes
:
constantRouterMap
,
scrollBehavior
:
()
=>
({
y
:
0
})
});
\ No newline at end of file
src/view/manualTag/manual-tag-value-edit.vue
View file @
87e95f73
...
...
@@ -81,7 +81,7 @@
<!-- excel导入 -->
<el-dialog
:title=
"importPop.title"
:visible
.
sync=
"importPop.isShow"
custom-class=
"manual-dialog"
>
<div
class=
"import"
>
<div
:class=
"['excel-icon',
importPop.excelData.length > 0
? 'excel-icon--active' : 'excel-icon--add']"
@
click=
"handleUpload"
>
<div
:class=
"['excel-icon',
filesData
? 'excel-icon--active' : 'excel-icon--add']"
@
click=
"handleUpload"
>
<span
v-show=
"importPop.excelData.length === 0"
class=
"import-btn"
>
点击上传会员
</span>
</div>
<div
class=
"import-cont"
>
...
...
@@ -98,7 +98,7 @@
</
template
>
</div>
<div
class=
"import-tip"
>
<span
class=
"import-tip-text"
>
只能上传一个exc
le文件(2003版本以上),且数据不超过5
000条
</span>
<span
class=
"import-tip-text"
>
只能上传一个exc
el文件(2003版本以上),且数据不超过50
000条
</span>
<el-button
type=
"text"
@
click=
"downloadExcelTemp"
>
<span
class=
"font-12"
>
下载Excel模板
</span>
</el-button>
...
...
@@ -128,7 +128,8 @@ import navCrumb from '@/components/nav/nav.vue';
import
{
export_json_to_excel
}
from
'@/vendor/Export2Excel'
;
import
showMsg
from
'@/common/js/showmsg'
;
import
errMsg
from
'@/common/js/error'
;
import
{
getRequest
,
postRequest
}
from
'@/api/api'
;
/* eslint-disable */
import
{
getRequest
,
postRequest
,
postForm
}
from
'@/api/api'
;
/**
* 通过excel导入会员的业务逻辑 2019-5-27
* 轮询接口的实现方式
...
...
@@ -175,6 +176,7 @@ export default {
// 当前上传 excel 表头的数据
excelHeader
:
[]
},
filesData
:
undefined
,
// 标签值列表的数据
tagValTableData
:
[],
...
...
@@ -383,31 +385,33 @@ export default {
e
.
target
.
value
=
''
;
return
;
}
this
.
importPop
.
excelName
=
files
.
name
;
const
reader
=
new
FileReader
();
reader
.
onload
=
e
=>
{
const
data
=
e
.
target
.
result
;
const
fixedData
=
this
.
fixData
(
data
);
const
workbook
=
XLSX
.
read
(
btoa
(
fixedData
),
{
type
:
'base64'
});
const
firstSheetName
=
workbook
.
SheetNames
[
0
];
const
worksheet
=
workbook
.
Sheets
[
firstSheetName
];
if
(
Object
.
keys
(
worksheet
).
indexOf
(
'!ref'
)
===
-
1
)
{
this
.
$message
.
error
({
duration
:
1000
,
message
:
'文档内容为空'
});
return
false
;
}
this
.
importPop
.
excelHeader
=
this
.
get_header_row
(
worksheet
);
this
.
importPop
.
excelData
=
XLSX
.
utils
.
sheet_to_json
(
worksheet
);
if
(
this
.
importPop
.
excelData
.
length
>
5000
)
{
this
.
$message
.
error
({
duration
:
1000
,
message
:
'单次上传数据不能超过 5000 条,请重新上传文件'
});
}
};
reader
.
readAsArrayBuffer
(
files
);
this
.
filesData
=
files
;
console
.
log
(
this
.
filesData
)
// this.importPop.excelName = files.name;
// const reader = new FileReader();
// reader.onload = e => {
// const data = e.target.result;
// const fixedData = this.fixData(data);
// const workbook = XLSX.read(btoa(fixedData), { type: 'base64' });
// const firstSheetName = workbook.SheetNames[0];
// const worksheet = workbook.Sheets[firstSheetName];
// if (Object.keys(worksheet).indexOf('!ref') === -1) {
// this.$message.error({
// duration: 1000,
// message: '文档内容为空'
// });
// return false;
// }
// this.importPop.excelHeader = this.get_header_row(worksheet);
// this.importPop.excelData = XLSX.utils.sheet_to_json(worksheet);
// if (this.importPop.excelData.length > 50000) {
// this.$message.error({
// duration: 1000,
// message: '单次上传数据不能超过 50000 条,请重新上传文件'
// });
// }
// };
// reader.readAsArrayBuffer(files);
},
fixData
(
data
)
{
...
...
@@ -450,25 +454,43 @@ export default {
// 导入数据到服务端
tagItemImport
()
{
if
(
this
.
importPop
.
excelData
.
length
===
0
)
{
this
.
$message
.
error
({
duration
:
1000
,
message
:
'导入数据有为空或者数据异常'
});
return
;
}
// if (this.importPop.excelData.length === 0) {
// this.$message.error({
// duration: 1000,
// message: '导入数据有为空或者数据异常'
// });
// return;
// }
if
(
!
this
.
filesData
)
return
this
.
$message
.
warning
(
'请上传文件'
);
this
.
$refs
.
upload
.
value
=
''
;
this
.
refreshTag
.
push
({
tagItemIndex
:
this
.
importPop
.
tagItemIndex
,
tagItemId
:
this
.
importPop
.
tagItemId
});
const
para
=
{
tagItemId
:
this
.
importPop
.
tagItemId
,
data
:
JSON
.
stringify
(
this
.
importPop
.
excelData
)
};
postRequest
(
'/memberTag/uploadHandTagItemImport'
,
para
).
then
((
res
)
=>
{
let
{
tagItemId
,
optType
}
=
this
.
importPop
;
// postRequest('/memberTag/uploadHandTagItemImport', para).then((res) => {
// const { errorCode } = res.data;
// errorCode === 1 ? this.handTagItemImport() : errMsg.errorMsg(res.data);
// }).catch(error => {
// this.$message.error({
// duration: 1000,
// message: error.message
// });
// });
const
param
=
new
FormData
();
param
.
append
(
"file"
,
this
.
filesData
);
param
.
append
(
"optType"
,
optType
?
1
:
0
);
param
.
append
(
"tagItemId"
,
tagItemId
);
postForm
(
'/memberTag/uploadTagItemExcel'
,
param
).
then
((
res
)
=>
{
const
{
errorCode
}
=
res
.
data
;
errorCode
===
1
?
this
.
handTagItemImport
()
:
errMsg
.
errorMsg
(
res
.
data
);
if
(
errorCode
===
1
)
{
// 关闭上传的弹窗
this
.
closeImportPop
();
// 查询上传进度
this
.
handleRefreshTag
();
}
else
{
errMsg
.
errorMsg
(
res
.
data
);
}
}).
catch
(
error
=>
{
this
.
$message
.
error
({
duration
:
1000
,
...
...
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