Skip to content

Commit 3ad68c3

Browse files
committed
CRM:合同的 code review
1 parent fffc9ae commit 3ad68c3

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/views/crm/contract/ContractForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ const formRules = reactive({
192192
const formRef = ref() // 表单 Ref
193193
const BPMLModelRef = ref<InstanceType<typeof BPMLModel>>() // TODO @puhui999:这个变量不太对;另外,可以不做 bpm model 窗口,而是可以点击跳转到工作流详情里;
194194
195-
// 监听合同商品变化,计算合同商品总价
195+
// 监听合同产品变化,计算合同产品总价
196196
watch(
197197
() => formData.value.productItems,
198198
(val) => {

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</el-table>
4343

4444
<!-- table 选择表单 -->
45-
<TableSelectForm ref="tableSelectFormRef" v-model="multipleSelection" title="选择商品">
45+
<TableSelectForm ref="tableSelectFormRef" v-model="multipleSelection" title="选择产品">
4646
<el-table-column align="center" label="产品名称" prop="name" width="160" />
4747
<el-table-column align="center" label="产品类型" prop="categoryName" width="160" />
4848
<el-table-column align="center" label="产品单位" prop="unit">
@@ -76,7 +76,7 @@ const emits = defineEmits<{
7676
(e: 'update:modelValue', v: any[]): void
7777
}>()
7878
79-
const list = ref<ProductApi.ProductExpandVO[]>([]) // 列表数量
79+
const list = ref<ProductApi.ProductExpandVO[]>([]) // 已添加的产品列表
8080
const multipleSelection = ref<ProductApi.ProductExpandVO[]>([]) // 多选
8181
8282
/** 处理删除 */
@@ -100,8 +100,9 @@ const getTotalPrice = computed(() => (row: ProductApi.ProductExpandVO) => {
100100
row.totalPrice = isNaN(totalPrice) ? 0 : yuanToFen(totalPrice)
101101
return isNaN(totalPrice) ? 0 : totalPrice.toFixed(2)
102102
})
103-
const isSetListValue = ref(false) // 判断是否已经给 list 赋值过,用于编辑表单商品回显
104-
// 编辑时合同商品回显
103+
104+
/** 编辑时合同产品回显 */
105+
const isSetListValue = ref(false) // 判断是否已经给 list 赋值过,用于编辑表单产品回显
105106
watch(
106107
() => props.modelValue,
107108
(val) => {
@@ -118,7 +119,8 @@ watch(
118119
},
119120
{ immediate: true, deep: true }
120121
)
121-
// 监听列表变化,动态更新合同商品列表
122+
123+
/** 监听列表变化,动态更新合同产品列表 */
122124
watch(
123125
list,
124126
(val) => {
@@ -130,14 +132,14 @@ watch(
130132
{ deep: true }
131133
)
132134
133-
// 监听商品选择结果动态添加商品到列表中,如果商品存在则不放入列表中
135+
// 监听产品选择结果动态添加产品到列表中,如果产品存在则不放入列表中
134136
watch(
135137
multipleSelection,
136138
(val) => {
137139
if (!val || val.length === 0) {
138140
return
139141
}
140-
// 过滤出不在列表中的商品
142+
// 过滤出不在列表中的产品
141143
const ids = list.value.map((item) => item.id)
142144
const productList = multipleSelection.value.filter((item) => ids.indexOf(item.id) === -1)
143145
if (!productList || productList.length === 0) {

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- 合同详情:产品列表 -->
12
<template>
23
<el-table :data="list" :show-overflow-tooltip="true" :stripe="true">
34
<el-table-column align="center" label="产品名称" prop="name" width="160" />
@@ -35,16 +36,18 @@ defineOptions({ name: 'ContractProductList' })
3536
const props = withDefaults(defineProps<{ modelValue: ProductApi.ProductExpandVO[] }>(), {
3637
modelValue: () => []
3738
})
38-
const list = ref<ProductApi.ProductExpandVO[]>([]) // 列表数量
39+
const list = ref<ProductApi.ProductExpandVO[]>([]) // 产品列表
40+
3941
/** 计算 totalPrice */
4042
const getTotalPrice = computed(() => (row: ProductApi.ProductExpandVO) => {
4143
const totalPrice =
4244
(Number(row.price) / 100) * Number(row.count) * (1 - Number(row.discountPercent) / 100)
4345
row.totalPrice = isNaN(totalPrice) ? 0 : yuanToFen(totalPrice)
4446
return isNaN(totalPrice) ? 0 : totalPrice.toFixed(2)
4547
})
46-
const isSetListValue = ref(false) // 判断是否已经给 list 赋值过,用于编辑表单商品回显
47-
// 编辑时合同商品回显
48+
49+
/** 编辑时合同产品回显 */
50+
const isSetListValue = ref(false) // 判断是否已经给 list 赋值过,用于编辑表单产品回显
4851
watch(
4952
() => props.modelValue,
5053
(val) => {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const getOperateLog = async (contractId: number) => {
8787
}
8888
8989
/** 转移 */
90+
// TODO @puhui999:这个组件,要不传递业务类型,然后组件里判断 title 和 api 能调用哪个;整体治理掉;
9091
const transferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // 合同转移表单 ref
9192
const transferContract = () => {
9293
transferFormRef.value?.open('合同转移', contract.value.id, ContractApi.transferContract)

0 commit comments

Comments
 (0)