Skip to content

Commit ed94205

Browse files
author
puhui999
committed
CRM-合同:完善合同表单
1 parent a64d424 commit ed94205

File tree

7 files changed

+374
-114
lines changed

7 files changed

+374
-114
lines changed

src/api/crm/business/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import request from '@/config/axios'
2+
import { TransferReqVO } from '@/api/crm/customer'
23

34
export interface BusinessVO {
45
id: number
@@ -70,3 +71,8 @@ export const getBusinessPageByContact = async (params) => {
7071
export const getBusinessListByIds = async (val: number[]) => {
7172
return await request.get({ url: '/crm/business/list-by-ids', params: { ids: val.join(',') } })
7273
}
74+
75+
// 商机转移
76+
export const transfer = async (data: TransferReqVO) => {
77+
return await request.put({ url: '/crm/business/transfer', data })
78+
}

src/api/crm/contract/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import request from '@/config/axios'
2+
import { ProductExpandVO } from '@/api/crm/product'
23

34
export interface ContractVO {
45
id: number
@@ -20,6 +21,7 @@ export interface ContractVO {
2021
signUserId: number
2122
contactLastTime: Date
2223
remark: string
24+
productItems: ProductExpandVO[]
2325
}
2426

2527
// 查询 CRM 合同列表

src/api/crm/product/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export interface ProductVO {
1212
ownerUserId: number
1313
}
1414

15+
export interface ProductExpandVO extends ProductVO {
16+
count: number
17+
discountPercent: number
18+
totalPrice: number
19+
}
20+
1521
// 查询产品列表
1622
export const getProductPage = async (params) => {
1723
return await request.get({ url: `/crm/product/page`, params })

src/components/Table/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Table from './src/Table.vue'
22
import { ElTable } from 'element-plus'
33
import { TableSetPropsType } from '@/types/table'
4+
import TableSelectForm from './src/TableSelectForm.vue'
45

56
export interface TableExpose {
67
setProps: (props: Recordable) => void
@@ -9,4 +10,4 @@ export interface TableExpose {
910
elTableRef: ComponentRef<typeof ElTable>
1011
}
1112

12-
export { Table }
13+
export { Table, TableSelectForm }
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<template>
2+
<Dialog v-model="dialogVisible" :appendToBody="true" :scroll="true" :title="title" width="60%">
3+
<el-table
4+
ref="multipleTableRef"
5+
v-loading="loading"
6+
:data="list"
7+
:show-overflow-tooltip="true"
8+
:stripe="true"
9+
@selection-change="handleSelectionChange"
10+
>
11+
<el-table-column type="selection" width="55" />
12+
<slot></slot>
13+
</el-table>
14+
<!-- 分页 -->
15+
<Pagination
16+
v-model:limit="queryParams.pageSize"
17+
v-model:page="queryParams.pageNo"
18+
:total="total"
19+
@pagination="getList"
20+
/>
21+
<template #footer>
22+
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
23+
<el-button @click="dialogVisible = false">取 消</el-button>
24+
</template>
25+
</Dialog>
26+
</template>
27+
28+
<script lang="ts" setup>
29+
import { ElTable } from 'element-plus'
30+
31+
defineOptions({ name: 'TableSelectForm' })
32+
withDefaults(
33+
defineProps<{
34+
modelValue: any[]
35+
title: string
36+
}>(),
37+
{ modelValue: () => [], title: '选择' }
38+
)
39+
const list = ref([]) // 列表的数据
40+
const total = ref(0) // 列表的总页数
41+
const loading = ref(false) // 列表的加载中
42+
const dialogVisible = ref(false) // 弹窗的是否展示
43+
const formLoading = ref(false)
44+
const queryParams = reactive({
45+
pageNo: 1,
46+
pageSize: 10
47+
})
48+
// 确认选择时的触发事件
49+
const emits = defineEmits<{
50+
(e: 'update:modelValue', v: number[]): void
51+
}>()
52+
const multipleTableRef = ref<InstanceType<typeof ElTable>>()
53+
const multipleSelection = ref<any[]>([])
54+
const handleSelectionChange = (val: any[]) => {
55+
multipleSelection.value = val
56+
}
57+
/** 触发 */
58+
const submitForm = () => {
59+
formLoading.value = true
60+
try {
61+
emits('update:modelValue', multipleSelection.value) // 返回选择的原始数据由使用方处理
62+
} finally {
63+
formLoading.value = false
64+
// 关闭弹窗
65+
dialogVisible.value = false
66+
}
67+
}
68+
69+
const getList = async (getListFunc: Function) => {
70+
loading.value = true
71+
try {
72+
const data = await getListFunc(queryParams)
73+
list.value = data.list
74+
total.value = data.total
75+
} finally {
76+
loading.value = false
77+
}
78+
}
79+
80+
/** 打开弹窗 */
81+
const open = async (getListFunc: Function) => {
82+
dialogVisible.value = true
83+
await nextTick()
84+
if (multipleSelection.value.length > 0) {
85+
multipleTableRef.value!.clearSelection()
86+
}
87+
await getList(getListFunc)
88+
}
89+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
90+
</script>

0 commit comments

Comments
 (0)