Skip to content

Commit 213af42

Browse files
YunaiVgitee-org
authored andcommitted
!366 fix: 修复 CRM 的一些 bug
Merge pull request !366 from puhui999/dev-crm
2 parents 948ef08 + d735f78 commit 213af42

File tree

19 files changed

+375
-283
lines changed

19 files changed

+375
-283
lines changed

src/api/crm/followup/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export interface FollowUpRecordVO {
77
bizId: number // 数据编号
88
type: number // 跟进类型
99
content: string // 跟进内容
10+
picUrls: string[]
11+
fileUrls: string[]
1012
nextTime: Date // 下次联系时间
1113
businessIds: number[] // 关联的商机编号数组
1214
contactIds: number[] // 关联的联系人编号数组

src/api/crm/permission/index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import request from '@/config/axios'
22

33
export interface PermissionVO {
44
id?: number // 数据权限编号
5-
userId: number | undefined // 用户编号
6-
bizType: number | undefined // Crm 类型
7-
bizId: number | undefined // Crm 类型数据编号
8-
level: number | undefined // 权限级别
5+
userId: number // 用户编号
6+
bizType: number // Crm 类型
7+
bizId: number // Crm 类型数据编号
8+
level: number // 权限级别
99
deptName?: string // 部门名称
1010
nickname?: string // 用户昵称
1111
postNames?: string[] // 岗位名称数组
1212
createTime?: Date
13+
ids?: number[]
1314
}
1415

1516
/**
@@ -50,11 +51,11 @@ export const updatePermission = async (data) => {
5051
}
5152

5253
// 删除数据权限(删除团队成员)
53-
export const deletePermissionBatch = async (params) => {
54-
return await request.delete({ url: '/crm/permission/delete', params })
54+
export const deletePermissionBatch = async (val: number[]) => {
55+
return await request.delete({ url: '/crm/permission/delete?ids=' + val.join(',') })
5556
}
5657

5758
// 删除自己的数据权限(退出团队)
58-
export const deleteSelfPermission = async (id) => {
59-
return await request.delete({ url: '/crm/permission/quit-team?id=' + id })
59+
export const deleteSelfPermission = async (id: number) => {
60+
return await request.delete({ url: '/crm/permission/delete-self?id=' + id })
6061
}

src/components/UploadFile/src/UploadImgs.vue

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<Icon icon="ep:zoom-in" />
2929
<span>查看</span>
3030
</div>
31-
<div class="handle-icon" @click="handleRemove(file)" v-if="!disabled">
31+
<div v-if="!disabled" class="handle-icon" @click="handleRemove(file)">
3232
<Icon icon="ep:delete" />
3333
<span>删除</span>
3434
</div>
@@ -46,7 +46,6 @@
4646
</div>
4747
</template>
4848
<script lang="ts" setup>
49-
import { PropType } from 'vue'
5049
import type { UploadFile, UploadProps, UploadUserFile } from 'element-plus'
5150
import { ElNotification } from 'element-plus'
5251
@@ -70,10 +69,7 @@ type FileTypes =
7069
| 'image/x-icon'
7170
7271
const props = defineProps({
73-
modelValue: {
74-
type: Array as PropType<UploadUserFile[]>,
75-
required: true
76-
},
72+
modelValue: propTypes.oneOfType<string | string[]>([String, Array<String>]).isRequired,
7773
updateUrl: propTypes.string.def(import.meta.env.VITE_UPLOAD_URL),
7874
drag: propTypes.bool.def(true), // 是否支持拖拽上传 ==> 非必传(默认为 true)
7975
disabled: propTypes.bool.def(false), // 是否禁用上传组件 ==> 非必传(默认为 false)
@@ -91,18 +87,8 @@ const uploadHeaders = ref({
9187
})
9288
9389
const fileList = ref<UploadUserFile[]>([])
94-
// fix: 改为动态监听赋值解决图片回显问题
95-
watch(
96-
() => props.modelValue,
97-
(data) => {
98-
if (!data) return
99-
fileList.value = data
100-
},
101-
{
102-
deep: true,
103-
immediate: true
104-
}
105-
)
90+
const uploadNumber = ref<number>(0)
91+
const uploadList = ref<UploadUserFile[]>([])
10692
/**
10793
* @description 文件上传之前判断
10894
* @param rawFile 上传的文件
@@ -122,29 +108,61 @@ const beforeUpload: UploadProps['beforeUpload'] = (rawFile) => {
122108
message: `上传图片大小不能超过 ${props.fileSize}M!`,
123109
type: 'warning'
124110
})
111+
uploadNumber.value++
125112
return imgType.includes(rawFile.type as FileTypes) && imgSize
126113
}
127114
128115
// 图片上传成功
129116
interface UploadEmits {
130-
(e: 'update:modelValue', value: UploadUserFile[]): void
117+
(e: 'update:modelValue', value: string[]): void
131118
}
132119
133120
const emit = defineEmits<UploadEmits>()
134-
const uploadSuccess = (response, uploadFile: UploadFile) => {
135-
if (!response) return
136-
// TODO 多图上传组件成功后只是把保存成功后的url替换掉组件选图时的文件路径,所以返回的fileList包含的是一个包含文件信息的对象列表
137-
uploadFile.url = response.data
138-
emit('update:modelValue', fileList.value)
121+
const uploadSuccess: UploadProps['onSuccess'] = (res: any): void => {
139122
message.success('上传成功')
123+
// 删除自身
124+
debugger
125+
const index = fileList.value.findIndex((item) => item.response?.data === res.data)
126+
fileList.value.splice(index, 1)
127+
uploadList.value.push({ name: res.data, url: res.data })
128+
if (uploadList.value.length == uploadNumber.value) {
129+
fileList.value.push(...uploadList.value)
130+
uploadList.value = []
131+
uploadNumber.value = 0
132+
emitUpdateModelValue()
133+
}
140134
}
141135
136+
// 监听模型绑定值变动
137+
watch(
138+
() => props.modelValue,
139+
(val: string | string[]) => {
140+
if (!val) {
141+
fileList.value = [] // fix:处理掉缓存,表单重置后上传组件的内容并没有重置
142+
return
143+
}
144+
145+
fileList.value = [] // 保障数据为空
146+
fileList.value.push(
147+
...(val as string[]).map((url) => ({ name: url.substring(url.lastIndexOf('/') + 1), url }))
148+
)
149+
},
150+
{ immediate: true, deep: true }
151+
)
152+
// 发送图片链接列表更新
153+
const emitUpdateModelValue = () => {
154+
let result: string[] = fileList.value.map((file) => file.url!)
155+
emit('update:modelValue', result)
156+
}
142157
// 删除图片
143158
const handleRemove = (uploadFile: UploadFile) => {
144159
fileList.value = fileList.value.filter(
145160
(item) => item.url !== uploadFile.url || item.name !== uploadFile.name
146161
)
147-
emit('update:modelValue', fileList.value)
162+
emit(
163+
'update:modelValue',
164+
fileList.value.map((file) => file.url!)
165+
)
148166
}
149167
150168
// 图片上传错误提示

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
:biz-id="customer.id!"
5252
:biz-type="BizTypeEnum.CRM_CUSTOMER"
5353
:show-action="!permissionListRef?.isPool || false"
54+
@quit-team="close"
5455
/>
5556
</el-tab-pane>
5657
<el-tab-pane label="商机" lazy>

src/views/crm/followup/FollowUpRecordForm.vue

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,52 +31,38 @@
3131
/>
3232
</el-form-item>
3333
</el-col>
34-
<!-- TODO @puhui999:不搞富文本哈;然后加个附件、图片两个 form-item 哈 -->
3534
<el-col :span="24">
3635
<el-form-item label="跟进内容" prop="content">
37-
<Editor v-model="formData.content" height="300px" />
36+
<el-input v-model="formData.content" :rows="3" type="textarea" />
37+
</el-form-item>
38+
</el-col>
39+
<el-col :span="24">
40+
<el-form-item label="图片" prop="content">
41+
<UploadImgs v-model="formData.picUrls" class="min-w-80px" />
42+
</el-form-item>
43+
</el-col>
44+
<el-col :span="24">
45+
<el-form-item label="附件" prop="content">
46+
<UploadFile v-model="formData.fileUrls" class="min-w-80px" />
3847
</el-form-item>
3948
</el-col>
40-
<!-- TODO @puhui999:因为不考虑编辑的情况,是不是关联要是个弹窗选择哈? -->
4149
<el-col :span="24">
4250
<el-form-item label="关联联系人" prop="contactIds">
43-
<el-select v-model="formData.contactIds" multiple placeholder="请选择">
44-
<el-option
45-
v-for="item in allContactList"
46-
:key="item.id"
47-
:label="item.name"
48-
:value="item.id"
49-
/>
50-
</el-select>
51+
<el-button @click="handleAddContact">
52+
<Icon class="mr-5px" icon="ep:plus" />
53+
添加联系人
54+
</el-button>
5155
<contact-list v-model:contactIds="formData.contactIds" />
5256
</el-form-item>
53-
<!-- <el-form-item label="关联联系人" prop="contactIds">-->
54-
<!-- <el-button @click="handleAddContact">-->
55-
<!-- <Icon class="mr-5px" icon="ep:plus" />-->
56-
<!-- 选择添加联系人-->
57-
<!-- </el-button>-->
58-
<!-- <contact-list v-model:contactIds="formData.contactIds" />-->
59-
<!-- </el-form-item>-->
6057
</el-col>
6158
<el-col :span="24">
6259
<el-form-item label="关联商机" prop="businessIds">
63-
<el-select v-model="formData.businessIds" multiple placeholder="请选择">
64-
<el-option
65-
v-for="item in allBusinessList"
66-
:key="item.id"
67-
:label="item.name"
68-
:value="item.id"
69-
/>
70-
</el-select>
60+
<el-button @click="handleAddBusiness">
61+
<Icon class="mr-5px" icon="ep:plus" />
62+
添加商机
63+
</el-button>
7164
<business-list v-model:businessIds="formData.businessIds" />
7265
</el-form-item>
73-
<!-- <el-form-item label="关联商机" prop="businessIds">-->
74-
<!-- <el-button @click="handleAddBusiness">-->
75-
<!-- <Icon class="mr-5px" icon="ep:plus" />-->
76-
<!-- 选择添加商机-->
77-
<!-- </el-button>-->
78-
<!-- <business-list v-model:businessIds="formData.businessIds" />-->
79-
<!-- </el-form-item>-->
8066
</el-col>
8167
</el-row>
8268
</el-form>
@@ -85,13 +71,13 @@
8571
<el-button @click="dialogVisible = false">取 消</el-button>
8672
</template>
8773
</Dialog>
74+
<ContactTableSelect ref="contactTableSelectRef" v-model="formData.contactIds" />
75+
<BusinessTableSelect ref="businessTableSelectRef" v-model="formData.businessIds" />
8876
</template>
8977
<script lang="ts" setup>
9078
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
9179
import { FollowUpRecordApi, FollowUpRecordVO } from '@/api/crm/followup'
92-
import { BusinessList, ContactList } from './components'
93-
import * as ContactApi from '@/api/crm/contact'
94-
import * as BusinessApi from '@/api/crm/business'
80+
import { BusinessList, BusinessTableSelect, ContactList, ContactTableSelect } from './components'
9581
9682
defineOptions({ name: 'FollowUpRecordForm' })
9783
@@ -110,8 +96,6 @@ const formRules = reactive({
11096
})
11197
11298
const formRef = ref() // 表单 Ref
113-
const allContactList = ref<ContactApi.ContactVO[]>([]) // 所有联系人列表
114-
const allBusinessList = ref<BusinessApi.BusinessVO[]>([]) // 所有商家列表
11599
116100
/** 打开弹窗 */
117101
const open = async (bizType: number, bizId: number, type: string, id?: number) => {
@@ -121,8 +105,6 @@ const open = async (bizType: number, bizId: number, type: string, id?: number) =
121105
resetForm()
122106
formData.value.bizType = bizType
123107
formData.value.bizId = bizId
124-
allContactList.value = await ContactApi.getSimpleContactList()
125-
allBusinessList.value = await BusinessApi.getSimpleBusinessList()
126108
// 修改时,设置数据
127109
if (id) {
128110
formLoading.value = true
@@ -159,6 +141,14 @@ const submitForm = async () => {
159141
}
160142
}
161143
144+
const contactTableSelectRef = ref<InstanceType<typeof ContactTableSelect>>()
145+
const handleAddContact = () => {
146+
contactTableSelectRef.value?.open()
147+
}
148+
const businessTableSelectRef = ref<InstanceType<typeof BusinessTableSelect>>()
149+
const handleAddBusiness = () => {
150+
businessTableSelectRef.value?.open()
151+
}
162152
/** 重置表单 */
163153
const resetForm = () => {
164154
formRef.value?.resetFields()

src/views/crm/followup/components/BusinessList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ watch(
5252
if (!val || val.length === 0) {
5353
return
5454
}
55-
list.value = BusinessApi.getBusinessListByIds(val) as unknown as BusinessApi.BusinessVO[]
55+
list.value = BusinessApi.getBusinessListByIds(unref(val)) as unknown as BusinessApi.BusinessVO[]
5656
}
5757
)
5858
const emits = defineEmits<{

src/views/crm/followup/components/BusinessListSelectForm.vue

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)