设置客户列表权限

This commit is contained in:
浅念
2025-07-23 14:07:13 +08:00
parent fc4de02582
commit 4a39387865
5 changed files with 457 additions and 381 deletions
+1
View File
@@ -3,6 +3,7 @@ node_modules
dist
dist-ssr
*.local
*.env
.cursorrules
src/types/components.d.ts
src/types/auto-imports.d.ts
-1
View File
@@ -1 +0,0 @@
pnpm dlx commitlint --edit $1
-1
View File
@@ -1 +0,0 @@
pnpm run lint:lint-staged
+41 -14
View File
@@ -1,7 +1,7 @@
<template>
<div class="customer-form-page">
<div class="form-header">
<el-link :underline="false" @click="goBack">
<el-link underline="never" @click="goBack">
<i class="iconfont-sys icon-reverse">&#xe772;</i> 返回
</el-link>
<span class="border"></span><span class="form-title">编辑客户资料</span>
@@ -18,19 +18,29 @@
<el-col :span="24">
<el-form-item label="客户渠道" prop="channel_id">
<el-select v-model="form.channel_id" filterable placeholder="请选择客户渠道">
<el-option v-for="item in channelOptions" :key="item.id" :label="item.name" :value="item.id" />
<el-option
v-for="item in channelOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="客户商机" prop="magnitude">
<el-select v-model="form.magnitude" placeholder="请选择客户商机">
<el-option v-for="item in opportunityOptions" :key="item.id" :label="item.name" :value="item.id" />
<el-option
v-for="item in opportunityOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="客户名称" prop="contacts">
<el-input v-model="form.contacts" placeholder="请输入客户名称" />
</el-form-item>
<el-form-item label="客户性别" prop="sex">
<el-radio-group v-model="form.sex" style="justify-content: flex-end;width: 100%;">
<el-radio-group v-model="form.sex" style="justify-content: flex-end; width: 100%">
<el-radio :label="0">未知</el-radio>
<el-radio :label="1">男</el-radio>
<el-radio :label="2">女</el-radio>
@@ -52,12 +62,22 @@
</el-form-item> -->
<el-form-item label="客户分级" prop="grade">
<el-select v-model="form.grade" placeholder="请选择客户分级">
<el-option v-for="item in levelOptions" :key="item.id" :label="item.name" :value="item.id" />
<el-option
v-for="item in levelOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="国家" prop="country_id">
<el-select v-model="form.country_id" filterable placeholder="请选择国家">
<el-option v-for="item in countryOptions" :key="item.id" :label="item.cn_addr" :value="item.id" />
<el-option
v-for="item in countryOptions"
:key="item.id"
:label="item.cn_addr"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="公司" prop="company">
@@ -85,7 +105,6 @@ const customerId = route.query.id
const router = useRouter()
const formRef = ref()
const rules = {
channel: [{ required: true, message: '请选择客户渠道', trigger: 'change' }],
name: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
@@ -94,7 +113,6 @@ const rules = {
const channelOptions = ref<any>()
const opportunityOptions = ref<any>()
const intentionOptions = ref<any>()
const levelOptions = ref<any>()
const countryOptions = ref<any>()
onMounted(async () => {
@@ -119,7 +137,9 @@ const getdetilfn = async() => {
const res = await CrmService.getcustomerdetail({ id: customerId })
customerInfo.value = res
form.value = res
} catch (error) { }
} catch (error) {
console.log(error)
}
}
//渠道
const getgetChannel = async () => {
@@ -127,7 +147,9 @@ const getgetChannel = async () => {
// 这里调用获取品牌列表的接口
const res = await CrmService.getChannel()
channelOptions.value = res || []
} catch (error) { channelOptions.value = [] }
} catch (error) {
console.log(error)
}
}
//商机
const getMagnitude = async () => {
@@ -135,7 +157,9 @@ const getMagnitude = async () => {
// 这里调用获取品牌列表的接口
const res = await CrmService.getMagnitude()
opportunityOptions.value = res || []
} catch (error) { opportunityOptions.value = [] }
} catch (error) {
console.log(error)
}
}
//客户等级
const getGrade = async () => {
@@ -143,7 +167,9 @@ const getGrade = async () => {
// 这里调用获取品牌列表的接口
const res = await CrmService.getGrade()
levelOptions.value = res || []
} catch (error) { levelOptions.value = [] }
} catch (error) {
console.log(error)
}
}
//国家
const getarea = async () => {
@@ -151,7 +177,9 @@ const getarea = async () => {
// 这里调用获取品牌列表的接口
const res = await CrmService.getCountry()
countryOptions.value = res || []
} catch (error) { countryOptions.value = [] }
} catch (error) {
console.log(error)
}
}
function goBack() {
router.back()
@@ -174,7 +202,6 @@ function submitForm() {
<style scoped>
.border {
margin: 0px 10px 0px 40px;
}
.submit-row .el-form-item__content {
+79 -29
View File
@@ -2,16 +2,14 @@
<div class="customer-page">
<!-- 顶部操作栏 -->
<div class="customer-toolbar boxshadow">
<el-button type="primary" @click="goAdd"><el-icon><Plus /></el-icon>添加</el-button>
<el-button type="primary" @click="goAdd" v-if="hasAuth('crm_customer@add')">
<el-icon><Plus /> </el-icon>
添加
</el-button>
<div class="customer-search-group">
<el-input v-model="searchValue" placeholder="请输入客户名称或电话" />
<el-select v-model="selectValue">
<el-option
v-for="v in selectOptions"
:key="v.value"
:label="v.label"
:value="v.value"
>
<el-option v-for="v in selectOptions" :key="v.value" :label="v.label" :value="v.value">
</el-option>
</el-select>
</div>
@@ -69,9 +67,18 @@
</el-tabs>
<!-- 表格 -->
<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">
<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="contacts" label="客户名称" align="center" />
<el-table-column prop="magnitude_txt" label="客户商机" align="center" />
@@ -87,14 +94,28 @@
</el-table-column>
<el-table-column fixed="right" label="操作" width="200px" align="center">
<template #default="scope">
<el-link type="primary" underline="never" style="margin-right: 8px;" @click="goEdit(scope.row)"> <i class="iconfont-sys"> &#xe70f;</i>查看</el-link>
<el-link type="primary" underline="never" @click="goAddFollow(scope.row)"> <i class="iconfont-sys"> &#xe6bf;</i> 添加跟进</el-link>
<el-link
type="primary"
underline="never"
style="margin-right: 8px"
@click="goEdit(scope.row)"
v-if="hasAuth('crm_customer@show')"
>
<i class="iconfont-sys"> &#xe70f;</i>查看
</el-link>
<el-link
type="primary"
underline="never"
@click="goAddFollow(scope.row)"
v-if="hasAuth('crm_customer@follow_add')"
>
<i class="iconfont-sys">&#xe6bf;</i> 添加跟进
</el-link>
</template>
</el-table-column>
</template>
</ArtTable>
</div>
</div>
</template>
@@ -102,6 +123,8 @@
import { ref, reactive, computed, onMounted, watch } from 'vue'
import { Plus } from '@element-plus/icons-vue'
import { CrmService } from '@/api/crmApi'
import { useAuth } from '@/composables/useAuth'
const { hasAuth } = useAuth()
const searchValue = ref('')
const selectValue = ref('')
const activeTab = ref('')
@@ -122,12 +145,11 @@ const selectOptions = [
type TagGroup = { id: string; name: string; tags: { id: string; name: string; count: number }[] }
const tagGroups = ref<TagGroup[]>([])
const tagGrouplistfn = async () => {
try {
const res = await CrmService.tagGrouplist({ scene: 'customers' })
tagGroups.value = res || []
} catch (error) { }
}
// 计算前3组和更多组
// eslint-disable-next-line vue/valid-define-props
defineProps()
const visibleTagGroups = computed(() => tagGroups.value.slice(0, 3))
const moreTagGroups = computed(() => tagGroups.value.slice(3))
@@ -162,7 +184,7 @@ const gettableList = async () => {
}
console.log(params)
const { data, current, size, total } = await CrmService.getcustomerList(params)
tableData.value = data.map((item: any, index: number) => ({
tableData.value = data.map((item: any) => ({
...item
}))
Object.assign(pagination, { currentPage: current, pageSize: size, total })
@@ -213,40 +235,47 @@ function handleTagClick(groupId: string, tagId: string) {
pagination.currentPage = 1
gettableList()
}
</script>
<style scoped>
<style scoped lang="scss">
:deep(.el-table__header th) {
background: #f7f9fa !important;
color: #333;
font-weight: bold;
}
:deep(.el-table__body tr.custom-table-row td) {
border-bottom: 1px solid #F7F9FA !important;
border-right: 1px solid #F7F9FA !important;
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;
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: 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;
@@ -255,21 +284,25 @@ function handleTagClick(groupId: string, tagId: string) {
padding: 20px 10px;
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;
margin-bottom: 16px;
}
.filter-row {
display: flex;
align-items: center;
margin-bottom: 14px;
}
.filter-label {
width: 120px;
color: #666;
@@ -277,45 +310,58 @@ function handleTagClick(groupId: string, tagId: string) {
flex-shrink: 0;
font-size: 14px;
}
.filter-tags {
flex: 1;
color: #333;
font-weight: 500;
font-size: 14px;
span {
margin-right: 20px;
}
}
.customer-tabs {
margin-bottom: 8px;
}
.status-following {
color: #00A43F;
color: #00a43f;
font-weight: bold;
}
.status-dealed {
color: #3471FF;
color: #3471ff;
font-weight: bold;
}
.status-lost {
color: #FF0000;
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 {
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.2s;
}
.fade-enter-from, .fade-leave-to {
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
.tag-item {
cursor: pointer;
border-radius: 4px;
@@ -325,5 +371,9 @@ function handleTagClick(groupId: string, tagId: string) {
min-width: 100px;
display: inline-block;
}
.tag-active { background: #3471FF; color: #fff; }
.tag-active {
background: #3471ff;
color: #fff;
}
</style>