314 lines
8.0 KiB
Vue
314 lines
8.0 KiB
Vue
|
|
<template>
|
||
|
|
<div class="customer-page">
|
||
|
|
<!-- 顶部操作栏 -->
|
||
|
|
<div class="customer-toolbar boxshadow">
|
||
|
|
<div class="customer-search-group">
|
||
|
|
<el-form-item label="关键字:" label-width="70px">
|
||
|
|
<el-input style="min-width: 120px" v-model="keyword" placeholder="请输入关键字" />
|
||
|
|
</el-form-item>
|
||
|
|
<el-form-item label="状态:" label-width="50px">
|
||
|
|
<el-select v-model="selectValue" style="min-width: 120px">
|
||
|
|
<el-option label="全部" value="" />
|
||
|
|
<el-option label="正常" value="1" />
|
||
|
|
<el-option label="离职" value="2" />
|
||
|
|
</el-select>
|
||
|
|
</el-form-item>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="boxshadow">
|
||
|
|
<!-- 表格 -->
|
||
|
|
<ArtTable
|
||
|
|
ref="tableRef"
|
||
|
|
row-key="id"
|
||
|
|
:loading="loading"
|
||
|
|
:data="tableData"
|
||
|
|
:currentPage="pagination.currentPage"
|
||
|
|
:pageSize="pagination.pageSize"
|
||
|
|
:total="pagination.total"
|
||
|
|
@size-change="handleSizeChange"
|
||
|
|
@current-change="handleCurrentChange"
|
||
|
|
lass="customer-table"
|
||
|
|
>
|
||
|
|
<template #default>
|
||
|
|
<!-- <el-table-column prop="id" label="用户ID" align="center" /> -->
|
||
|
|
<el-table-column prop="sn" label="SN" align="center" />
|
||
|
|
<el-table-column prop="follow" label="头像" align="center">
|
||
|
|
<template #default="scope">
|
||
|
|
<img
|
||
|
|
:src="scope.row.avatar"
|
||
|
|
alt="头像"
|
||
|
|
class="avatar"
|
||
|
|
@click="handleAvatarClick(scope.row.avatar)"
|
||
|
|
style="cursor: pointer"
|
||
|
|
/>
|
||
|
|
</template>
|
||
|
|
</el-table-column>
|
||
|
|
<el-table-column prop="name" label="名字" align="center" />
|
||
|
|
<el-table-column prop="phone" label="电话" align="center" />
|
||
|
|
<el-table-column prop="email" label="邮箱" align="center" />
|
||
|
|
<!-- <el-table-column prop="corp_name" label="所属公司" align="center" /> -->
|
||
|
|
<el-table-column prop="follow" label="状态" align="center">
|
||
|
|
<template #default="scope">
|
||
|
|
<span :class="statusClass(scope.row.status)">
|
||
|
|
{{ scope.row.status == 1 ? '在职' : '离职' }}
|
||
|
|
</span>
|
||
|
|
</template>
|
||
|
|
</el-table-column>
|
||
|
|
<el-table-column prop="customer_count" label="客户数量" align="center" />
|
||
|
|
<el-table-column fixed="right" label="操作" width="200px" align="center">
|
||
|
|
<template #default="scope">
|
||
|
|
<el-link
|
||
|
|
type="warning"
|
||
|
|
underline="never"
|
||
|
|
style="margin-right: 8px"
|
||
|
|
@click="statusfn(scope.row)"
|
||
|
|
v-if="hasAuth('crm_customer@status') && scope.row.status == 1"
|
||
|
|
>
|
||
|
|
<i class="iconfont-sys"></i>标记离职
|
||
|
|
</el-link>
|
||
|
|
</template>
|
||
|
|
</el-table-column>
|
||
|
|
</template>
|
||
|
|
</ArtTable>
|
||
|
|
</div>
|
||
|
|
<!-- 图片预览组件 -->
|
||
|
|
<ElImageViewer
|
||
|
|
v-if="showImageViewer"
|
||
|
|
:url-list="[currentImageUrl]"
|
||
|
|
:hide-on-click-modal="true"
|
||
|
|
@close="showImageViewer = false"
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup lang="ts">
|
||
|
|
import { ref, reactive, onMounted, watch } from 'vue'
|
||
|
|
import { ElImageViewer } from 'element-plus'
|
||
|
|
import { CrmService } from '@/api/crmApi'
|
||
|
|
import { useAuth } from '@/composables/useAuth'
|
||
|
|
const { hasAuth } = useAuth()
|
||
|
|
const selectValue = ref<string[]>([])
|
||
|
|
const keyword = ref<string>('')
|
||
|
|
const loading = ref(false)
|
||
|
|
const pagination = reactive({
|
||
|
|
currentPage: 1,
|
||
|
|
pageSize: 10,
|
||
|
|
total: 0
|
||
|
|
})
|
||
|
|
// 表格数据
|
||
|
|
const tableData = ref<any[]>([])
|
||
|
|
onMounted(() => {
|
||
|
|
gettableList()
|
||
|
|
})
|
||
|
|
// tabs 切换联动
|
||
|
|
watch([selectValue, keyword], () => {
|
||
|
|
pagination.currentPage = 1
|
||
|
|
gettableList()
|
||
|
|
})
|
||
|
|
const gettableList = async () => {
|
||
|
|
loading.value = true
|
||
|
|
try {
|
||
|
|
const { currentPage, pageSize } = pagination
|
||
|
|
const params: any = {
|
||
|
|
current: currentPage,
|
||
|
|
size: pageSize
|
||
|
|
}
|
||
|
|
if (selectValue.value) {
|
||
|
|
params.status = selectValue.value
|
||
|
|
}
|
||
|
|
if (keyword.value) {
|
||
|
|
params.keyword = keyword.value
|
||
|
|
}
|
||
|
|
const { records, current, size, total } = await CrmService.getCustomerUserList(params)
|
||
|
|
tableData.value = records.map((item: any) => ({
|
||
|
|
...item
|
||
|
|
}))
|
||
|
|
Object.assign(pagination, { currentPage: current, pageSize: size, total })
|
||
|
|
} catch (error) {
|
||
|
|
console.error('获取用户列表失败:', error)
|
||
|
|
} finally {
|
||
|
|
loading.value = false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// 处理表格分页变化
|
||
|
|
const handleSizeChange = (newPageSize: number) => {
|
||
|
|
pagination.pageSize = newPageSize
|
||
|
|
gettableList()
|
||
|
|
}
|
||
|
|
const handleCurrentChange = (newCurrentPage: number) => {
|
||
|
|
pagination.currentPage = newCurrentPage
|
||
|
|
gettableList()
|
||
|
|
}
|
||
|
|
function statusClass(status: any) {
|
||
|
|
if (status === 1) return 'status-following'
|
||
|
|
if (status === 0) return 'status-lost'
|
||
|
|
return ''
|
||
|
|
}
|
||
|
|
// 图片预览相关
|
||
|
|
const showImageViewer = ref(false)
|
||
|
|
const currentImageUrl = ref('')
|
||
|
|
|
||
|
|
const handleAvatarClick = (avatarUrl: string) => {
|
||
|
|
if (avatarUrl) {
|
||
|
|
currentImageUrl.value = avatarUrl
|
||
|
|
showImageViewer.value = true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
const statusfn = (row?: any) => {
|
||
|
|
ElMessageBox.confirm('确定标记离职吗?', '标记确认', {
|
||
|
|
confirmButtonText: '确定',
|
||
|
|
cancelButtonText: '取消',
|
||
|
|
type: 'error'
|
||
|
|
}).then(async () => {
|
||
|
|
const { message } = await CrmService.markLeave({
|
||
|
|
user_id: row.id
|
||
|
|
})
|
||
|
|
ElMessage.success(message)
|
||
|
|
gettableList()
|
||
|
|
})
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style scoped lang="scss">
|
||
|
|
:deep(.el-badge) {
|
||
|
|
--el-badge-size: 16px;
|
||
|
|
}
|
||
|
|
.avatar {
|
||
|
|
width: 40px;
|
||
|
|
height: 40px;
|
||
|
|
border-radius: 50%;
|
||
|
|
transition: opacity 0.2s;
|
||
|
|
&:hover {
|
||
|
|
opacity: 0.8;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.itemtag {
|
||
|
|
margin-top: -16px;
|
||
|
|
margin-left: -13px;
|
||
|
|
}
|
||
|
|
:deep(.el-table__header th) {
|
||
|
|
background: #f7f9fa !important;
|
||
|
|
color: #333;
|
||
|
|
font-weight: bold;
|
||
|
|
}
|
||
|
|
:deep(.el-table__empty-block) {
|
||
|
|
height: 450px !important;
|
||
|
|
}
|
||
|
|
:deep(.el-table__body tr.custom-table-row td) {
|
||
|
|
border-bottom: 1px solid #f7f9fa !important;
|
||
|
|
border-right: 1px solid #f7f9fa !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
:deep(.el-table__body tr td:last-child) {
|
||
|
|
border-right: none !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
:deep(.el-table__body tr:last-child td) {
|
||
|
|
border-bottom: none !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
:deep(.el-table__header-wrapper th) {
|
||
|
|
border-bottom: 1px solid #f7f9fa !important;
|
||
|
|
border-right: 1px solid #f7f9fa !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
:deep(.el-table__header-wrapper th:last-child) {
|
||
|
|
border-right: none !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
:deep(.el-table) {
|
||
|
|
border: 1px solid #f7f9fa !important;
|
||
|
|
border-radius: 6px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.customer-page {
|
||
|
|
background: var(--art-main-bg-color);
|
||
|
|
min-height: 100vh;
|
||
|
|
}
|
||
|
|
|
||
|
|
.customer-toolbar {
|
||
|
|
display: flex;
|
||
|
|
justify-content: space-between;
|
||
|
|
align-items: center;
|
||
|
|
margin-bottom: 16px;
|
||
|
|
padding: 20px 20px;
|
||
|
|
background: var(--art-main-bg-color);
|
||
|
|
}
|
||
|
|
|
||
|
|
.customer-search-group {
|
||
|
|
display: flex;
|
||
|
|
gap: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.customer-tags {
|
||
|
|
background: var(--art-main-bg-color);
|
||
|
|
border-radius: 8px;
|
||
|
|
padding: 16px 20px;
|
||
|
|
margin-bottom: 16px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.filter-row {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
margin-bottom: 14px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.filter-label {
|
||
|
|
width: 120px;
|
||
|
|
color: #666;
|
||
|
|
margin-right: 8px;
|
||
|
|
flex-shrink: 0;
|
||
|
|
font-size: 14px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.filter-tags {
|
||
|
|
flex: 1;
|
||
|
|
color: #333;
|
||
|
|
font-weight: 500;
|
||
|
|
font-size: 14px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.customer-tabs {
|
||
|
|
margin-bottom: 8px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.status-following {
|
||
|
|
color: #00a43f;
|
||
|
|
font-weight: bold;
|
||
|
|
}
|
||
|
|
|
||
|
|
.status-dealed {
|
||
|
|
color: #3471ff;
|
||
|
|
font-weight: bold;
|
||
|
|
}
|
||
|
|
|
||
|
|
.status-lost {
|
||
|
|
color: #ff0000;
|
||
|
|
font-weight: bold;
|
||
|
|
}
|
||
|
|
|
||
|
|
.customer-table {
|
||
|
|
background: var(--art-main-bg-color);
|
||
|
|
border-radius: 8px;
|
||
|
|
margin-top: 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.filter-more-btn {
|
||
|
|
text-align: center;
|
||
|
|
margin-top: 8px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.fade-enter-active,
|
||
|
|
.fade-leave-active {
|
||
|
|
transition: opacity 0.2s;
|
||
|
|
}
|
||
|
|
|
||
|
|
.fade-enter-from,
|
||
|
|
.fade-leave-to {
|
||
|
|
opacity: 0;
|
||
|
|
}
|
||
|
|
.form-submit-row {
|
||
|
|
text-align: center;
|
||
|
|
}
|
||
|
|
</style>
|