Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
26daa3a1
authored
Jan 27, 2024
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CRM-客户:完善客户导入
parent
64cfcbf6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
150 additions
and
1 deletions
+150
-1
src/api/crm/customer/index.ts
+5
-0
src/views/crm/customer/CustomerImportForm.vue
+134
-0
src/views/crm/customer/index.vue
+10
-1
src/views/system/user/UserImportForm.vue
+1
-0
No files found.
src/api/crm/customer/index.ts
View file @
26daa3a1
...
@@ -63,6 +63,11 @@ export const exportCustomer = async (params: any) => {
...
@@ -63,6 +63,11 @@ export const exportCustomer = async (params: any) => {
return
await
request
.
download
({
url
:
`/crm/customer/export-excel`
,
params
})
return
await
request
.
download
({
url
:
`/crm/customer/export-excel`
,
params
})
}
}
// 下载客户导入模板
export
const
importCustomerTemplate
=
()
=>
{
return
request
.
download
({
url
:
'/crm/customer/get-import-template'
})
}
// 客户列表
// 客户列表
export
const
getSimpleCustomerList
=
async
()
=>
{
export
const
getSimpleCustomerList
=
async
()
=>
{
return
await
request
.
get
({
url
:
`/crm/customer/list-all-simple`
})
return
await
request
.
get
({
url
:
`/crm/customer/list-all-simple`
})
...
...
src/views/crm/customer/CustomerImportForm.vue
0 → 100644
View file @
26daa3a1
<
template
>
<Dialog
v-model=
"dialogVisible"
title=
"客户导入"
width=
"400"
>
<el-upload
ref=
"uploadRef"
v-model:file-list=
"fileList"
:action=
"importUrl + '?updateSupport=' + updateSupport"
:auto-upload=
"false"
:disabled=
"formLoading"
:headers=
"uploadHeaders"
:limit=
"1"
:on-error=
"submitFormError"
:on-exceed=
"handleExceed"
:on-success=
"submitFormSuccess"
accept=
".xlsx, .xls"
drag
>
<Icon
icon=
"ep:upload"
/>
<div
class=
"el-upload__text"
>
将文件拖到此处,或
<em>
点击上传
</em></div>
<template
#
tip
>
<div
class=
"el-upload__tip text-center"
>
<div
class=
"el-upload__tip"
>
<el-checkbox
v-model=
"updateSupport"
/>
是否更新已经存在的客户数据
</div>
<span>
仅允许导入 xls、xlsx 格式文件。
</span>
<el-link
:underline=
"false"
style=
"font-size: 12px; vertical-align: baseline"
type=
"primary"
@
click=
"importTemplate"
>
下载模板
</el-link>
</div>
</
template
>
</el-upload>
<
template
#
footer
>
<el-button
:disabled=
"formLoading"
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
<el-button
@
click=
"dialogVisible = false"
>
取 消
</el-button>
</
template
>
</Dialog>
</template>
<
script
lang=
"ts"
setup
>
import
*
as
CustomerApi
from
'@/api/crm/customer'
import
{
getAccessToken
,
getTenantId
}
from
'@/utils/auth'
import
download
from
'@/utils/download'
defineOptions
({
name
:
'SystemUserImportForm'
})
const
message
=
useMessage
()
// 消息弹窗
const
dialogVisible
=
ref
(
false
)
// 弹窗的是否展示
const
formLoading
=
ref
(
false
)
// 表单的加载中
const
uploadRef
=
ref
()
const
importUrl
=
import
.
meta
.
env
.
VITE_BASE_URL
+
import
.
meta
.
env
.
VITE_API_URL
+
'/crm/customer/import'
const
uploadHeaders
=
ref
()
// 上传 Header 头
const
fileList
=
ref
([])
// 文件列表
const
updateSupport
=
ref
(
0
)
// 是否更新已经存在的客户数据
/** 打开弹窗 */
const
open
=
()
=>
{
dialogVisible
.
value
=
true
fileList
.
value
=
[]
resetForm
()
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
/** 提交表单 */
const
submitForm
=
async
()
=>
{
if
(
fileList
.
value
.
length
==
0
)
{
message
.
error
(
'请上传文件'
)
return
}
// 提交请求
uploadHeaders
.
value
=
{
Authorization
:
'Bearer '
+
getAccessToken
(),
'tenant-id'
:
getTenantId
()
}
formLoading
.
value
=
true
uploadRef
.
value
!
.
submit
()
}
/** 文件上传成功 */
const
emits
=
defineEmits
([
'success'
])
const
submitFormSuccess
=
(
response
:
any
)
=>
{
if
(
response
.
code
!==
0
)
{
message
.
error
(
response
.
msg
)
formLoading
.
value
=
false
return
}
// 拼接提示语
const
data
=
response
.
data
let
text
=
'上传成功数量:'
+
data
.
createCustomerNames
.
length
+
';'
for
(
let
customerName
of
data
.
createCustomerNames
)
{
text
+=
'
<
' + customerName + '
>
'
}
text += '
更新成功数量:
' + data.updateCustomerNames.length + '
;
'
for (const customerName of data.updateCustomerNames) {
text += '
<
' + customerName + '
>
'
}
text += '
更新失败数量:
' + Object.keys(data.failureCustomerNames).length + '
;
'
for (const customerName in data.failureCustomerNames) {
text += '
<
' + customerName + '
:
' + data.failureCustomerNames[customerName] + '
>
'
}
message.alert(text)
// 发送操作成功的事件
emits('
success
')
}
/** 上传错误提示 */
const submitFormError = (): void => {
message.error('
上传失败,请您重新上传!
')
formLoading.value = false
}
/** 重置表单 */
const resetForm = () => {
// 重置上传状态和文件
formLoading.value = false
uploadRef.value?.clearFiles()
}
/** 文件数超出提示 */
const handleExceed = (): void => {
message.error('
最多只能上传一个文件!
')
}
/** 下载模板操作 */
const importTemplate = async () => {
const res = await CustomerApi.importCustomerTemplate()
download.excel(res, '
客户导入模版
.
xls
'
)
}
</
script
>
src/views/crm/customer/index.vue
View file @
26daa3a1
...
@@ -84,6 +84,10 @@
...
@@ -84,6 +84,10 @@
<Icon
class=
"mr-5px"
icon=
"ep:plus"
/>
<Icon
class=
"mr-5px"
icon=
"ep:plus"
/>
新增
新增
</el-button>
</el-button>
<el-button
v-hasPermi=
"['crm:customer:import']"
plain
type=
"warning"
@
click=
"handleImport"
>
<Icon
icon=
"ep:upload"
/>
导入
</el-button>
<el-button
<el-button
v-hasPermi=
"['crm:customer:export']"
v-hasPermi=
"['crm:customer:export']"
:loading=
"exportLoading"
:loading=
"exportLoading"
...
@@ -204,6 +208,7 @@
...
@@ -204,6 +208,7 @@
<!-- 表单弹窗:添加/修改 -->
<!-- 表单弹窗:添加/修改 -->
<CustomerForm
ref=
"formRef"
@
success=
"getList"
/>
<CustomerForm
ref=
"formRef"
@
success=
"getList"
/>
<CustomerImportForm
ref=
"customerImportFormRef"
@
success=
"getList"
/>
</template>
</template>
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
...
@@ -212,6 +217,7 @@ import { dateFormatter } from '@/utils/formatTime'
...
@@ -212,6 +217,7 @@ import { dateFormatter } from '@/utils/formatTime'
import
download
from
'@/utils/download'
import
download
from
'@/utils/download'
import
*
as
CustomerApi
from
'@/api/crm/customer'
import
*
as
CustomerApi
from
'@/api/crm/customer'
import
CustomerForm
from
'./CustomerForm.vue'
import
CustomerForm
from
'./CustomerForm.vue'
import
CustomerImportForm
from
'./CustomerImportForm.vue'
import
{
TabsPaneContext
}
from
'element-plus'
import
{
TabsPaneContext
}
from
'element-plus'
defineOptions
({
name
:
'CrmCustomer'
})
defineOptions
({
name
:
'CrmCustomer'
})
...
@@ -333,7 +339,10 @@ const handleDelete = async (id: number) => {
...
@@ -333,7 +339,10 @@ const handleDelete = async (id: number) => {
await
getList
()
await
getList
()
}
catch
{}
}
catch
{}
}
}
const
customerImportFormRef
=
ref
<
InstanceType
<
typeof
CustomerImportForm
>>
()
const
handleImport
=
()
=>
{
customerImportFormRef
.
value
?.
open
()
}
/** 导出按钮操作 */
/** 导出按钮操作 */
const
handleExport
=
async
()
=>
{
const
handleExport
=
async
()
=>
{
try
{
try
{
...
...
src/views/system/user/UserImportForm.vue
View file @
26daa3a1
...
@@ -61,6 +61,7 @@ const updateSupport = ref(0) // 是否更新已经存在的用户数据
...
@@ -61,6 +61,7 @@ const updateSupport = ref(0) // 是否更新已经存在的用户数据
/** 打开弹窗 */
/** 打开弹窗 */
const
open
=
()
=>
{
const
open
=
()
=>
{
dialogVisible
.
value
=
true
dialogVisible
.
value
=
true
fileList
.
value
=
[]
resetForm
()
resetForm
()
}
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
...
...
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