Commit ec3e26fd by Sweet Zhang

对接导入联系人

parent fb8c4606
......@@ -10,10 +10,18 @@
<!-- 页面标题和操作按钮 -->
<div class="flex flex-col md:flex-row md:items-center md:justify-between mb-6 gap-4">
<div class="flex gap-3">
<!-- <button @click="showImportModal = true" class="btn-outline flex items-center">
<button @click="showImportModal = true" class="btn-primary flex items-center">
<i class="fas fa-upload mr-2"></i> 批量导入
</button> -->
<button @click="openAddContactModal()" class="btn-primary flex items-center">
</button>
<!-- 下载模版 -->
<a
href="http://yd-ali-oss.oss-cn-shanghai-finance-1-pub.aliyuncs.com/xlsx/2025/10/09/2b0ec7e9ab4443fb8530131c001b9a3d.xlsx"
download="contact_template.xlsx"
class="flex items-center text-blue-700"
>
下载模版
</a>
<button @click="openAddContactModal()" class="btn-outline flex items-center">
<i class="fas fa-plus mr-2"></i> 新增联系人
</button>
</div>
......@@ -344,6 +352,16 @@
@confirm="handleConfirm"
@cancel="handleCancel"
/>
<!-- 导入联系人 -->
<ImportDialog
v-model:visible="showImportModal"
:trigger-key="'importContactModal'"
:uploadUrl="uploadUrl"
:title="'导入联系人'"
@success="handleImportSuccess"
@error="handleImportError"
@cancel="handleImportCancel"
/>
</div>
</template>
......@@ -355,12 +373,13 @@ import type { Contact } from '@/types/index'
// 引入分页组件
import Pagination from '@/components/Pagination.vue'
import ImportDialog from '@/views/ImportDialog.vue'
// 初始数据
const total = ref(0)
const currentPage = ref(1)
const pageSize = ref(10)
const uploadUrl = `${import.meta.env.VITE_REMOTE_API_BASE_URL}/email/api/emailFile/import/excel/contact`
// 处理分页变化
const handlePageChange = (page: number, size: number) => {
console.log('分页变化:', page, size)
......@@ -377,6 +396,30 @@ const handlePageSizeUpdate = (size: number) => {
currentPage.value = 1 // 重置到第一页
}
const handleImportSuccess = (file: File) => {
console.log('导入成功:', file)
showImportModal.value = false
openModal({
triggerKey: '',
title: '成功',
message: '联系人导入成功',
})
}
const handleImportCancel = (triggerKey: string) => {
console.log('导入取消:', triggerKey)
showImportModal.value = false
}
const handleImportError = (error: string) => {
console.log('导入错误:', error)
showImportModal.value = false
openModal({
triggerKey: '',
title: '错误',
message: error,
})
}
// 引入弹窗组件
import CommonModal from '@/components/CommonModal.vue'
// 弹窗提示信息对象
......@@ -420,6 +463,9 @@ const handleConfirm = (triggerKey: string) => {
})
}
})
} else if (triggerKey === 'importContactModal') {
showImportModal.value = true
console.log('确认')
}
}
......
......@@ -76,11 +76,6 @@
<button
@click="saveVariableTemplate"
class="px-6 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-700 transition-colors"
:disabled="
!templateForm.groupName ||
!templateForm.variableBizIdList ||
templateForm.variableBizIdList.length === 0
"
>
{{ editingTemplateId ? '更新模板' : '创建模板' }}
</button>
......@@ -155,8 +150,10 @@ const saveVariableTemplate = () => {
!templateForm.value.groupName ||
!templateForm.value.variableBizIdList ||
templateForm.value.variableBizIdList.length === 0
)
) {
open('请输入模版名称和选择变量', '错误')
return
}
if (props.editingTemplateId) {
console.log('更新变量模版', templateForm.value)
......
......@@ -39,6 +39,14 @@ const props = defineProps({
type: String,
default: '.csv,.xlsx',
},
uploadUrl: {
type: String,
default: `${import.meta.env.VITE_REMOTE_API_BASE_URL}/email/api/emailFile/import/excel/variable`,
},
triggerKey: {
type: String,
default: 'importContactModal',
},
})
/**
* 文件上传配置
......@@ -48,7 +56,7 @@ import FileUploadComponent from '@/components/FileUploadComponent.vue'
import { UploadResult, UploadConfig } from '@/utils/fileUpload'
const uploadConfig: UploadConfig = {
url: `${import.meta.env.VITE_REMOTE_API_BASE_URL}/email/api/emailFile/import/excel/variable`,
url: props.uploadUrl,
fieldName: 'file',
maxSize: 10,
allowedTypes: [],
......@@ -59,17 +67,16 @@ const uploadConfig: UploadConfig = {
const uploadedFiles = ref<any[]>([])
// 处理文档上传成功
const handleDocumentUploadSuccess = (results: UploadResult[]) => {
emit('update:visible', false)
emit('file-selected', results[0])
emit('success', results[0], props.triggerKey)
}
// 处理文档上传失败
const handleDocumentUploadError = (error: string) => {
emit('error', error)
emit('error', error, props.triggerKey)
}
const emit = defineEmits(['update:visible', 'file-selected', 'error'])
const emit = defineEmits(['success', 'error', 'cancel'])
const handleCancel = () => {
emit('update:visible', false)
emit('cancel', props.triggerKey)
}
// 监听visible变化,重置文件输入
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment