Skip to content

Commit fffc9ae

Browse files
YunaiVgitee-org
authored andcommitted
!381 CRM-合同:完善 TODO
Merge pull request !381 from puhui999/dev-crm
2 parents 4549f8e + fe91c5e commit fffc9ae

File tree

16 files changed

+190
-76
lines changed

16 files changed

+190
-76
lines changed

src/api/crm/business/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export const getBusinessListByIds = async (val: number[]) => {
7373
}
7474

7575
// 商机转移
76-
// TODO @puhui999:transferBusiness
77-
export const transfer = async (data: TransferReqVO) => {
76+
export const transferBusiness = async (data: TransferReqVO) => {
7877
return await request.put({ url: '/crm/business/transfer', data })
7978
}

src/api/crm/clue/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 ClueVO {
45
id: number
@@ -44,3 +45,8 @@ export const deleteClue = async (id: number) => {
4445
export const exportClue = async (params) => {
4546
return await request.download({ url: `/crm/clue/export-excel`, params })
4647
}
48+
49+
// 线索转移
50+
export const transferClue = async (data: TransferReqVO) => {
51+
return await request.put({ url: '/crm/clue/transfer', data })
52+
}

src/api/crm/contact/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ export const deleteContactBusinessList = async (data: ContactBusinessReqVO) => {
8888
}
8989

9090
// 联系人转移
91-
export const transfer = async (data: TransferReqVO) => {
91+
export const transferContact = async (data: TransferReqVO) => {
9292
return await request.put({ url: '/crm/contact/transfer', data })
9393
}

src/api/crm/contract/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface ContractVO {
77
name: string
88
customerId: number
99
businessId: number
10+
businessName: string
1011
processInstanceId: number
1112
orderDate: Date
1213
ownerUserId: number
@@ -18,8 +19,9 @@ export interface ContractVO {
1819
productPrice: number
1920
contactId: number
2021
signUserId: number
22+
signUserName: string
2123
contactLastTime: Date
22-
status: number
24+
auditStatus: number
2325
remark: string
2426
productItems: ProductExpandVO[]
2527
creatorName: string
@@ -71,7 +73,6 @@ export const handleApprove = async (id: number) => {
7173
}
7274

7375
// 合同转移
74-
// TODO @puhui999:transfer 相关方法,这块要补充下;
75-
export const transfer = async (data: TransferReqVO) => {
76+
export const transferContract = async (data: TransferReqVO) => {
7677
return await request.put({ url: '/crm/contract/transfer', data })
7778
}

src/api/crm/customer/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export interface TransferReqVO {
8282
}
8383

8484
// 客户转移
85-
export const transfer = async (data: TransferReqVO) => {
85+
export const transferCustomer = async (data: TransferReqVO) => {
8686
return await request.put({ url: '/crm/customer/transfer', data })
8787
}
8888

src/components/Table/src/TableSelectForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- TODO @puhui999:这个最好加个注释哈 -->
1+
<!-- 列表选择通用组件,参考 ProductList 组件使用 -->
22
<template>
33
<Dialog v-model="dialogVisible" :appendToBody="true" :scroll="true" :title="title" width="60%">
44
<el-table

src/views/crm/contact/detail/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const openForm = (type: string, id?: number) => {
7979
/** 联系人转移 */
8080
const crmTransferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // 联系人转移表单 ref
8181
const transfer = () => {
82-
crmTransferFormRef.value?.open('联系人转移', contact.value.id, ContactApi.transfer)
82+
crmTransferFormRef.value?.open('联系人转移', contact.value.id, ContactApi.transferContact)
8383
}
8484
8585
/** 获取操作日志 */

src/views/crm/contract/ContractForm.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:rules="formRules"
88
label-width="110px"
99
>
10-
<el-row>
10+
<el-row :gutter="20">
1111
<el-col :span="24" class="mb-10px">
1212
<CardTitle title="基本信息" />
1313
</el-col>
@@ -138,7 +138,7 @@
138138
</el-col>
139139
<el-col :span="12">
140140
<el-form-item label="产品总金额(元)" prop="productPrice">
141-
<el-input v-model="formData.productPrice" placeholder="请输入产品总金额" />
141+
{{ floatToFixed2(formData.productPrice) }}
142142
</el-form-item>
143143
</el-col>
144144
<el-col :span="24">
@@ -172,6 +172,7 @@ import * as ContactApi from '@/api/crm/contact'
172172
import * as BusinessApi from '@/api/crm/business'
173173
import ProductList from './components/ProductList.vue'
174174
import BPMLModel from '@/views/crm/contract/components/BPMLModel.vue'
175+
import { floatToFixed2 } from '@/utils'
175176
176177
const { t } = useI18n() // 国际化
177178
const message = useMessage() // 消息弹窗
@@ -191,7 +192,7 @@ const formRules = reactive({
191192
const formRef = ref() // 表单 Ref
192193
const BPMLModelRef = ref<InstanceType<typeof BPMLModel>>() // TODO @puhui999:这个变量不太对;另外,可以不做 bpm model 窗口,而是可以点击跳转到工作流详情里;
193194
194-
// TODO @puhui999:加个注释哈
195+
// 监听合同商品变化,计算合同商品总价
195196
watch(
196197
() => formData.value.productItems,
197198
(val) => {

src/views/crm/contract/components/ProductList.vue

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,17 @@ import * as ProductApi from '@/api/crm/product'
6666
import { DICT_TYPE } from '@/utils/dict'
6767
import { fenToYuanFormat } from '@/utils/formatter'
6868
import { TableSelectForm } from '@/components/Table/index'
69+
import { floatToFixed2, yuanToFen } from '@/utils'
6970
7071
defineOptions({ name: 'ProductList' })
71-
withDefaults(defineProps<{ modelValue: any[] }>(), { modelValue: () => [] })
72+
const props = withDefaults(defineProps<{ modelValue: ProductApi.ProductExpandVO[] }>(), {
73+
modelValue: () => []
74+
})
7275
const emits = defineEmits<{
7376
(e: 'update:modelValue', v: any[]): void
7477
}>()
7578
76-
const list = ref<ProductApi.ProductExpandVO[]>([]) // TODO @puhui999
79+
const list = ref<ProductApi.ProductExpandVO[]>([]) // 列表数量
7780
const multipleSelection = ref<ProductApi.ProductExpandVO[]>([]) // 多选
7881
7982
/** 处理删除 */
@@ -92,12 +95,30 @@ const openForm = () => {
9295
9396
/** 计算 totalPrice */
9497
const getTotalPrice = computed(() => (row: ProductApi.ProductExpandVO) => {
95-
const totalPrice = (row.price * row.count * row.discountPercent) / 100
96-
row.totalPrice = isNaN(totalPrice) ? 0 : totalPrice
97-
return isNaN(totalPrice) ? 0 : totalPrice
98+
const totalPrice =
99+
(Number(row.price) / 100) * Number(row.count) * (1 - Number(row.discountPercent) / 100)
100+
row.totalPrice = isNaN(totalPrice) ? 0 : yuanToFen(totalPrice)
101+
return isNaN(totalPrice) ? 0 : totalPrice.toFixed(2)
98102
})
99-
100-
// TODO @puhui999:注释下
103+
const isSetListValue = ref(false) // 判断是否已经给 list 赋值过,用于编辑表单商品回显
104+
// 编辑时合同商品回显
105+
watch(
106+
() => props.modelValue,
107+
(val) => {
108+
if (!val || val.length === 0 || isSetListValue.value) {
109+
return
110+
}
111+
list.value = [
112+
...props.modelValue.map((item) => {
113+
item.totalPrice = floatToFixed2(item.totalPrice) as unknown as number
114+
return item
115+
})
116+
]
117+
isSetListValue.value = true
118+
},
119+
{ immediate: true, deep: true }
120+
)
121+
// 监听列表变化,动态更新合同商品列表
101122
watch(
102123
list,
103124
(val) => {
@@ -109,15 +130,20 @@ watch(
109130
{ deep: true }
110131
)
111132
112-
// TODO @puhui999:注释下
133+
// 监听商品选择结果动态添加商品到列表中,如果商品存在则不放入列表中
113134
watch(
114135
multipleSelection,
115136
(val) => {
116137
if (!val || val.length === 0) {
117138
return
118139
}
140+
// 过滤出不在列表中的商品
119141
const ids = list.value.map((item) => item.id)
120-
list.value.push(...multipleSelection.value.filter((item) => ids.indexOf(item.id) === -1))
142+
const productList = multipleSelection.value.filter((item) => ids.indexOf(item.id) === -1)
143+
if (!productList || productList.length === 0) {
144+
return
145+
}
146+
list.value.push(...productList)
121147
},
122148
{ deep: true }
123149
)

src/views/crm/contract/detail/ContractDetailsHeader.vue

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- TODO @puhui999:这个组件的注释加下,方便大家打开就知道哈 -->
1+
<!-- 合同详情头部组件-->
22
<template>
33
<div>
44
<div class="flex items-start justify-between">
@@ -17,24 +17,28 @@
1717
</div>
1818
<ContentWrap class="mt-10px">
1919
<el-descriptions :column="5" direction="vertical">
20-
<el-descriptions-item label="客户">
20+
<el-descriptions-item label="客户名称">
2121
{{ contract.customerName }}
2222
</el-descriptions-item>
23-
<el-descriptions-item label="客户签约人">
24-
{{ contract.contactName }}
23+
<el-descriptions-item label="合同金额(元)">
24+
{{ floatToFixed2(contract.price) }}
2525
</el-descriptions-item>
26-
<el-descriptions-item label="合同金额">
27-
{{ contract.productPrice }}
26+
<el-descriptions-item label="下单时间">
27+
{{ contract.orderDate ? formatDate(contract.orderDate) : '空' }}
2828
</el-descriptions-item>
29-
<el-descriptions-item label="创建时间">
30-
{{ contract.createTime ? formatDate(contract.createTime) : '空' }}
29+
<el-descriptions-item label="回款金额(元)">
30+
{{ floatToFixed2(contract.price) }}
31+
</el-descriptions-item>
32+
<el-descriptions-item label="负责人">
33+
{{ contract.ownerUserName }}
3134
</el-descriptions-item>
3235
</el-descriptions>
3336
</ContentWrap>
3437
</template>
3538
<script lang="ts" setup>
3639
import * as ContractApi from '@/api/crm/contract'
3740
import { formatDate } from '@/utils/formatTime'
41+
import { floatToFixed2 } from '@/utils'
3842
3943
defineOptions({ name: 'ContractDetailsHeader' })
4044
defineProps<{ contract: ContractApi.ContractVO }>()

0 commit comments

Comments
 (0)