CRM: 修复客户导入

This commit is contained in:
puhui999 2024-04-24 22:55:14 +08:00
parent f405ac3293
commit 6ff31b90c7
4 changed files with 50 additions and 30 deletions

View File

@ -6,11 +6,11 @@
"private": false, "private": false,
"scripts": { "scripts": {
"i": "pnpm install", "i": "pnpm install",
"dev": "vite --mode local-dev", "local-dev": "vite --mode local-dev",
"dev-server": "vite --mode dev", "dev": "vite --mode dev",
"ts:check": "vue-tsc --noEmit", "ts:check": "vue-tsc --noEmit",
"build:local-dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode local-dev", "build:local-dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode local-dev",
"build:dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode local-dev", "build:dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode dev",
"build:test": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode test", "build:test": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode test",
"build:stage": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode stage", "build:stage": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode stage",
"build:prod": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode prod", "build:prod": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode prod",

View File

@ -1,16 +1,24 @@
<!-- 客户导入窗口 --> <!-- 客户导入窗口 -->
<template> <template>
<Dialog v-model="dialogVisible" title="客户导入" width="400"> <Dialog v-model="dialogVisible" title="客户导入" width="400">
<div class="flex items-center my-10px">
<span class="mr-10px">负责人</span>
<el-select v-model="ownerUserId" class="!w-240px" clearable>
<el-option
v-for="item in userOptions"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</div>
<el-upload <el-upload
ref="uploadRef" ref="uploadRef"
v-model:file-list="fileList" v-model:file-list="fileList"
:auto-upload="false" :auto-upload="false"
:disabled="formLoading" :disabled="formLoading"
:headers="uploadHeaders"
:limit="1" :limit="1"
:on-error="submitFormError"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:on-success="submitFormSuccess"
accept=".xlsx, .xls" accept=".xlsx, .xls"
action="none" action="none"
drag drag
@ -43,9 +51,10 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import * as CustomerApi from '@/api/crm/customer' import * as CustomerApi from '@/api/crm/customer'
import { getAccessToken, getTenantId } from '@/utils/auth'
import download from '@/utils/download' import download from '@/utils/download'
import type { UploadUserFile } from 'element-plus' import type { UploadUserFile } from 'element-plus'
import * as UserApi from '@/api/system/user'
import { useUserStore } from '@/store/modules/user'
defineOptions({ name: 'SystemUserImportForm' }) defineOptions({ name: 'SystemUserImportForm' })
@ -54,15 +63,18 @@ const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const formLoading = ref(false) // const formLoading = ref(false) //
const uploadRef = ref() const uploadRef = ref()
const uploadHeaders = ref() // Header
const fileList = ref<UploadUserFile[]>([]) // const fileList = ref<UploadUserFile[]>([]) //
const updateSupport = ref(false) // const updateSupport = ref(false) //
const ownerUserId = ref<undefined | number>() //
const userOptions = ref<UserApi.UserVO[]>([]) //
/** 打开弹窗 */ /** 打开弹窗 */
const open = () => { const open = async () => {
dialogVisible.value = true dialogVisible.value = true
fileList.value = [] await resetForm()
resetForm() //
userOptions.value = await UserApi.getSimpleUserList()
ownerUserId.value = useUserStore().getUser.id
} }
defineExpose({ open }) // open defineExpose({ open }) // open
@ -72,17 +84,20 @@ const submitForm = async () => {
message.error('请上传文件') message.error('请上传文件')
return return
} }
//
uploadHeaders.value = {
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
}
formLoading.value = true formLoading.value = true
const formData = new FormData() try {
formData.append('updateSupport', updateSupport.value) const formData = new FormData()
formData.append('file', fileList.value[0].raw) formData.append('updateSupport', String(updateSupport.value))
// TODO @ uploadHeaders formData.append('file', fileList.value[0].raw as Blob)
await CustomerApi.handleImport(formData) formData.append('ownerUserId', String(ownerUserId.value))
const res = await CustomerApi.handleImport(formData)
submitFormSuccess(res)
} catch {
submitFormError()
} finally {
formLoading.value = false
}
} }
/** 文件上传成功 */ /** 文件上传成功 */
@ -108,6 +123,8 @@ const submitFormSuccess = (response: any) => {
text += '< ' + customerName + ': ' + data.failureCustomerNames[customerName] + ' >' text += '< ' + customerName + ': ' + data.failureCustomerNames[customerName] + ' >'
} }
message.alert(text) message.alert(text)
formLoading.value = false
dialogVisible.value = false
// //
emits('success') emits('success')
} }
@ -119,9 +136,12 @@ const submitFormError = (): void => {
} }
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = async () => {
// //
formLoading.value = false fileList.value = []
updateSupport.value = false
ownerUserId.value = undefined
await nextTick()
uploadRef.value?.clearFiles() uploadRef.value?.clearFiles()
} }

View File

@ -79,7 +79,7 @@
<Icon class="mr-5px" icon="ep:search" /> <Icon class="mr-5px" icon="ep:search" />
搜索 搜索
</el-button> </el-button>
<el-button @click="resetQuery(undefined)"> <el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" /> <Icon class="mr-5px" icon="ep:refresh" />
重置 重置
</el-button> </el-button>
@ -113,7 +113,7 @@
<el-tab-pane label="下属负责的" name="3" /> <el-tab-pane label="下属负责的" name="3" />
</el-tabs> </el-tabs>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true"> <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="客户名称" fixed="left" prop="name" width="160"> <el-table-column align="center" fixed="left" label="客户名称" prop="name" width="160">
<template #default="scope"> <template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)"> <el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }} {{ scope.row.name }}
@ -125,9 +125,9 @@
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" /> <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="手机" align="center" prop="mobile" width="120" /> <el-table-column align="center" label="手机" prop="mobile" width="120" />
<el-table-column label="电话" align="center" prop="telephone" width="130" /> <el-table-column align="center" label="电话" prop="telephone" width="130" />
<el-table-column label="邮箱" align="center" prop="email" width="180" /> <el-table-column align="center" label="邮箱" prop="email" width="180" />
<el-table-column align="center" label="客户级别" prop="level" width="135"> <el-table-column align="center" label="客户级别" prop="level" width="135">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" /> <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" />
@ -164,7 +164,7 @@
width="180px" width="180px"
/> />
<el-table-column align="center" label="最后跟进记录" prop="contactLastContent" width="200" /> <el-table-column align="center" label="最后跟进记录" prop="contactLastContent" width="200" />
<el-table-column label="地址" align="center" prop="detailAddress" width="180" /> <el-table-column align="center" label="地址" prop="detailAddress" width="180" />
<el-table-column align="center" label="距离进入公海天数" prop="poolDay" width="140"> <el-table-column align="center" label="距离进入公海天数" prop="poolDay" width="140">
<template #default="scope"> {{ scope.row.poolDay }} </template> <template #default="scope"> {{ scope.row.poolDay }} </template>
</el-table-column> </el-table-column>
@ -254,7 +254,7 @@ const activeName = ref('1') // 列表 tab
/** tab 切换 */ /** tab 切换 */
const handleTabClick = (tab: TabsPaneContext) => { const handleTabClick = (tab: TabsPaneContext) => {
queryParams.sceneType = tab.paneName queryParams.sceneType = tab.paneName as string
handleQuery() handleQuery()
} }