Skip to content

Commit 31a42fc

Browse files
committed
crm:增加合同 List 组件
1 parent 5f26c4a commit 31a42fc

File tree

11 files changed

+168
-329
lines changed

11 files changed

+168
-329
lines changed

src/api/crm/contract/index.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,37 @@ export interface ContractVO {
2222
remark: string
2323
}
2424

25-
// 查询合同列表
25+
// 查询 CRM 合同列表
2626
export const getContractPage = async (params) => {
2727
return await request.get({ url: `/crm/contract/page`, params })
2828
}
2929

30-
// 查询合同详情
30+
// 查询 CRM 联系人列表,基于指定客户
31+
export const getContractPageByCustomer = async (params: any) => {
32+
return await request.get({ url: `/crm/contract/page-by-customer`, params })
33+
}
34+
35+
// 查询 CRM 合同详情
3136
export const getContract = async (id: number) => {
3237
return await request.get({ url: `/crm/contract/get?id=` + id })
3338
}
3439

35-
// 新增合同
40+
// 新增 CRM 合同
3641
export const createContract = async (data: ContractVO) => {
3742
return await request.post({ url: `/crm/contract/create`, data })
3843
}
3944

40-
// 修改合同
45+
// 修改 CRM 合同
4146
export const updateContract = async (data: ContractVO) => {
4247
return await request.put({ url: `/crm/contract/update`, data })
4348
}
4449

45-
// 删除合同
50+
// 删除 CRM 合同
4651
export const deleteContract = async (id: number) => {
4752
return await request.delete({ url: `/crm/contract/delete?id=` + id })
4853
}
4954

50-
// 导出合同 Excel
55+
// 导出 CRM 合同 Excel
5156
export const exportContract = async (params) => {
5257
return await request.download({ url: `/crm/contract/export-excel`, params })
5358
}

src/api/crm/permission/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface PermissionVO {
2020
export enum BizTypeEnum {
2121
CRM_LEADS = 1, // 线索
2222
CRM_CUSTOMER = 2, // 客户
23-
CRM_CONTACTS = 3, // 联系人
23+
CRM_CONTACT = 3, // 联系人
2424
CRM_BUSINESS = 5, // 商机
2525
CRM_CONTRACT = 6 // 合同
2626
}

src/utils/dict.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,12 @@ export enum DICT_TYPE {
190190
PROMOTION_BANNER_POSITION = 'promotion_banner_position', // banner 定位
191191

192192
// ========== CRM - 客户管理模块 ==========
193-
CRM_RECEIVABLE_CHECK_STATUS = 'crm_receivable_check_status',
193+
CRM_AUDIT_STATUS = 'crm_audit_status', // CRM 审批状态
194+
CRM_BIZ_TYPE = 'crm_biz_type', // CRM 业务类型
194195
CRM_RETURN_TYPE = 'crm_return_type',
195196
CRM_CUSTOMER_INDUSTRY = 'crm_customer_industry',
196197
CRM_CUSTOMER_LEVEL = 'crm_customer_level',
197198
CRM_CUSTOMER_SOURCE = 'crm_customer_source',
198199
CRM_PRODUCT_STATUS = 'crm_product_status',
199-
200-
// ========== CRM - 数据权限模块 ==========
201-
CRM_BIZ_TYPE = 'crm_biz_type', // CRM 业务类型
202200
CRM_PERMISSION_LEVEL = 'crm_permission_level' // CRM 数据权限的级别
203201
}

src/views/crm/contact/components/ContactList.vue

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<!-- 操作栏 -->
33
<el-row justify="end">
4-
<el-button>
4+
<el-button @click="openForm">
55
<Icon class="mr-5px" icon="system-uicons:contacts" />
66
创建联系人
77
</el-button>
@@ -25,26 +25,6 @@
2525
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.master" />
2626
</template>
2727
</el-table-column>
28-
<el-table-column label="操作" align="center" fixed="right" width="200">
29-
<template #default="scope">
30-
<el-button
31-
plain
32-
type="primary"
33-
@click="openForm('update', scope.row.id)"
34-
v-hasPermi="['crm:contact:update']"
35-
>
36-
编辑
37-
</el-button>
38-
<el-button
39-
plain
40-
type="danger"
41-
@click="handleDelete(scope.row.id)"
42-
v-hasPermi="['crm:contact:delete']"
43-
>
44-
删除
45-
</el-button>
46-
</template>
47-
</el-table-column>
4828
</el-table>
4929
<!-- 分页 -->
5030
<Pagination
@@ -55,7 +35,7 @@
5535
/>
5636
</ContentWrap>
5737

58-
<!-- 表单弹窗:添加/修改 -->
38+
<!-- 表单弹窗:添加 -->
5939
<ContactForm ref="formRef" @success="getList" />
6040
</template>
6141
<script setup lang="ts">
@@ -70,9 +50,6 @@ const props = defineProps<{
7050
bizId: number // 业务编号
7151
}>()
7252
73-
const message = useMessage() // 消息弹窗
74-
const { t } = useI18n() // 国际化
75-
7653
const loading = ref(true) // 列表的加载中
7754
const total = ref(0) // 列表的总页数
7855
const list = ref([]) // 列表的数据
@@ -111,26 +88,13 @@ const handleQuery = () => {
11188
getList()
11289
}
11390
114-
/** 添加/修改操作 */
91+
/** 添加操作 */
11592
const formRef = ref()
116-
const openForm = (type: string, id?: number) => {
117-
formRef.value.open(type, id)
118-
}
119-
120-
/** 删除按钮操作 */
121-
const handleDelete = async (id: number) => {
122-
try {
123-
// 删除的二次确认
124-
await message.delConfirm()
125-
// 发起删除
126-
await ContactApi.deleteContact(id)
127-
message.success(t('common.delSuccess'))
128-
// 刷新列表
129-
await getList()
130-
} catch {}
93+
const openForm = () => {
94+
formRef.value.open('create')
13195
}
13296
133-
/** 打开客户详情 */
97+
/** 打开联系人详情 */
13498
const { push } = useRouter()
13599
const openDetail = (id: number) => {
136100
push({ name: 'CrmContactDetail', params: { id } })
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<template>
2+
<!-- 操作栏 -->
3+
<el-row justify="end">
4+
<el-button @click="openForm">
5+
<Icon class="mr-5px" icon="clarity:contract-line" />
6+
创建合同
7+
</el-button>
8+
</el-row>
9+
10+
<!-- 列表 -->
11+
<ContentWrap class="mt-10px">
12+
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
13+
<el-table-column label="合同名称" fixed="left" align="center" prop="name">
14+
<template #default="scope">
15+
<el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
16+
{{ scope.row.name }}
17+
</el-link>
18+
</template>
19+
</el-table-column>
20+
<el-table-column label="合同编号" align="center" prop="no" />
21+
<el-table-column label="客户名称" align="center" prop="customerName" />
22+
<el-table-column
23+
label="合同金额(元)"
24+
align="center"
25+
prop="price"
26+
:formatter="fenToYuanFormat"
27+
/>
28+
<el-table-column
29+
label="开始时间"
30+
align="center"
31+
prop="startTime"
32+
:formatter="dateFormatter"
33+
width="180px"
34+
/>
35+
<el-table-column
36+
label="结束时间"
37+
align="center"
38+
prop="endTime"
39+
:formatter="dateFormatter"
40+
width="180px"
41+
/>
42+
<el-table-column align="center" label="状态" prop="auditStatus">
43+
<template #default="scope">
44+
<dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
45+
</template>
46+
</el-table-column>
47+
</el-table>
48+
<!-- 分页 -->
49+
<Pagination
50+
:total="total"
51+
v-model:page="queryParams.pageNo"
52+
v-model:limit="queryParams.pageSize"
53+
@pagination="getList"
54+
/>
55+
</ContentWrap>
56+
57+
<!-- 表单弹窗:添加 -->
58+
<ContractForm ref="formRef" @success="getList" />
59+
</template>
60+
<script setup lang="ts">
61+
import * as ContractApi from '@/api/crm/contract'
62+
import ContractForm from './../ContractForm.vue'
63+
import { BizTypeEnum } from '@/api/crm/permission'
64+
import { fenToYuanFormat } from '@/utils/formatter'
65+
import { dateFormatter } from '@/utils/formatTime'
66+
import { DICT_TYPE } from '@/utils/dict'
67+
68+
defineOptions({ name: 'CrmContractList' })
69+
const props = defineProps<{
70+
bizType: number // 业务类型
71+
bizId: number // 业务编号
72+
}>()
73+
74+
const loading = ref(true) // 列表的加载中
75+
const total = ref(0) // 列表的总页数
76+
const list = ref([]) // 列表的数据
77+
const queryParams = reactive({
78+
pageNo: 1,
79+
pageSize: 10,
80+
customerId: undefined as unknown // 允许 undefined + number
81+
})
82+
83+
/** 查询列表 */
84+
const getList = async () => {
85+
loading.value = true
86+
try {
87+
// 置空参数
88+
queryParams.customerId = undefined
89+
// 执行查询
90+
let data = { list: [], total: 0 }
91+
switch (props.bizType) {
92+
case BizTypeEnum.CRM_CUSTOMER:
93+
queryParams.customerId = props.bizId
94+
data = await ContractApi.getContractPageByCustomer(queryParams)
95+
break
96+
default:
97+
return
98+
}
99+
list.value = data.list
100+
total.value = data.total
101+
} finally {
102+
loading.value = false
103+
}
104+
}
105+
106+
/** 搜索按钮操作 */
107+
const handleQuery = () => {
108+
queryParams.pageNo = 1
109+
getList()
110+
}
111+
112+
/** 添加 */
113+
const formRef = ref()
114+
const openForm = () => {
115+
formRef.value.open('create')
116+
}
117+
118+
/** 打开合同详情 */
119+
const { push } = useRouter()
120+
const openDetail = (id: number) => {
121+
push({ name: 'CrmContractDetail', params: { id } })
122+
}
123+
124+
/** 监听打开的 bizId + bizType,从而加载最新的列表 */
125+
watch(
126+
() => [props.bizId, props.bizType],
127+
() => {
128+
handleQuery()
129+
},
130+
{ immediate: true, deep: true }
131+
)
132+
</script>

0 commit comments

Comments
 (0)