Skip to content

Commit 6baeadc

Browse files
committed
✨ CRM:完善商机状态的实现
1 parent a2443e4 commit 6baeadc

File tree

5 files changed

+92
-96
lines changed

5 files changed

+92
-96
lines changed

src/api/crm/business/status/index.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import request from '@/config/axios'
2+
3+
export interface BusinessStatusTypeVO {
4+
id: number
5+
name: string
6+
deptIds: number[]
7+
statuses?: {
8+
id: number
9+
name: string
10+
percent: number
11+
}
12+
}
13+
14+
// 查询商机状态组列表
15+
export const getBusinessStatusPage = async (params: any) => {
16+
return await request.get({ url: `/crm/business-status/page`, params })
17+
}
18+
19+
// 新增商机状态组
20+
export const createBusinessStatus = async (data: BusinessStatusTypeVO) => {
21+
return await request.post({ url: `/crm/business-status/create`, data })
22+
}
23+
24+
// 修改商机状态组
25+
export const updateBusinessStatus = async (data: BusinessStatusTypeVO) => {
26+
return await request.put({ url: `/crm/business-status/update`, data })
27+
}
28+
29+
// 查询商机状态类型详情
30+
export const getBusinessStatus = async (id: number) => {
31+
return await request.get({ url: `/crm/business-status/get?id=` + id })
32+
}
33+
34+
// 获得商机状态组列表
35+
export const getBusinessStatusTypeSimpleList = async () => {
36+
return await request.get({ url: `/crm/business-status/type-simple-list` })
37+
}

src/api/crm/businessStatusType/index.ts

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

src/views/crm/business/BusinessForm.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
</template>
132132
<script setup lang="ts">
133133
import * as BusinessApi from '@/api/crm/business'
134-
import * as BusinessStatusTypeApi from '@/api/crm/businessStatusType'
134+
import * as BusinessStatusApi from '@/api/crm/business/status'
135135
import * as CustomerApi from '@/api/crm/customer'
136136
import * as UserApi from '@/api/system/user'
137137
import { useUserStore } from '@/store/modules/user'
@@ -212,7 +212,7 @@ const open = async (type: string, id?: number) => {
212212
}
213213
customerList.value = await CustomerApi.getCustomerSimpleList()
214214
// 加载商机状态类型列表
215-
statusTypeList.value = await BusinessStatusTypeApi.getBusinessStatusTypeList()
215+
statusTypeList.value = await BusinessStatusApi.getBusinessStatusTypeSimpleList()
216216
// 获得用户列表
217217
userOptions.value = await UserApi.getSimpleUserList()
218218
// 默认新建时选中自己

src/views/crm/businessStatusType/BusinessStatusTypeForm.vue renamed to src/views/crm/business/status/BusinessStatusForm.vue

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
label-width="100px"
88
v-loading="formLoading"
99
>
10-
<el-form-item label="状态类型名" prop="name">
11-
<el-input v-model="formData.name" placeholder="请输入状态类型名" />
10+
<el-form-item label="状态组名" prop="name">
11+
<el-input v-model="formData.name" placeholder="请输入状态组名" />
1212
</el-form-item>
1313
<el-form-item label="应用部门" prop="deptIds">
14+
<template #label>
15+
<Tooltip message="不选择部门时,默认全公司生效" title="应用部门" />
16+
</template>
1417
<el-tree
1518
ref="treeRef"
1619
:data="deptList"
@@ -21,31 +24,39 @@
2124
show-checkbox
2225
/>
2326
</el-form-item>
24-
<el-form-item label="状态设置" prop="statusList">
25-
<el-table border style="width: 100%" :data="formData.statusList">
26-
<el-table-column align="center" label="状态" width="120" prop="star">
27+
<el-form-item label="阶段设置" prop="statuses">
28+
<el-table border style="width: 100%" :data="formData.statuses">
29+
<el-table-column align="center" label="阶段" width="70">
2730
<template #default="scope">
28-
<el-text>状态{{ scope.$index + 1 }}</el-text>
31+
<el-text>阶段 {{ scope.$index + 1 }}</el-text>
2932
</template>
3033
</el-table-column>
31-
<el-table-column align="center" label="状态名称" width="120" prop="name">
34+
<el-table-column align="center" label="阶段名称" width="160" prop="name">
3235
<template #default="{ row }">
3336
<el-input v-model="row.name" placeholder="请输入状态名称" />
3437
</template>
3538
</el-table-column>
36-
<el-table-column width="120" align="center" label="赢单率" prop="percent">
39+
<el-table-column width="140" align="center" label="赢单率" prop="percent">
3740
<template #default="{ row }">
38-
<el-input v-model="row.percent" placeholder="请输入赢单率" />
41+
<el-input-number
42+
v-model="row.percent"
43+
placeholder="请输入赢单率"
44+
controls-position="right"
45+
:min="0"
46+
:max="100"
47+
:precision="2"
48+
class="!w-1/1"
49+
/>
3950
</template>
4051
</el-table-column>
41-
<el-table-column label="操作" align="center">
52+
<el-table-column label="操作" width="110" align="center">
4253
<template #default="scope">
4354
<el-button link type="primary" @click="addStatusArea(scope.$index)"> 添加 </el-button>
4455
<el-button
4556
link
4657
type="danger"
4758
@click="deleteStatusArea(scope.$index)"
48-
v-show="scope.$index > 0"
59+
:disabled="formData.statuses.length <= 1"
4960
>
5061
删除
5162
</el-button>
@@ -61,7 +72,7 @@
6172
</Dialog>
6273
</template>
6374
<script setup lang="ts">
64-
import * as BusinessStatusTypeApi from '@/api/crm/businessStatusType'
75+
import * as BusinessStatusApi from '@/api/crm/business/status'
6576
import { defaultProps, handleTree } from '@/utils/tree'
6677
import * as DeptApi from '@/api/system/dept'
6778
@@ -71,15 +82,15 @@ const message = useMessage() // 消息弹窗
7182
const dialogVisible = ref(false) // 弹窗的是否展示
7283
const dialogTitle = ref('') // 弹窗的标题
7384
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
74-
const formType = ref('') // 表单的类型:create - 新增;update - 修改
85+
const formType = ref('') // 表单的组:create - 新增;update - 修改
7586
const formData = ref({
7687
id: 0,
7788
name: '',
7889
deptIds: [],
79-
statusList: []
90+
statuses: []
8091
})
8192
const formRules = reactive({
82-
name: [{ required: true, message: '状态类型名不能为空', trigger: 'blur' }]
93+
name: [{ required: true, message: '状态组名不能为空', trigger: 'blur' }]
8394
})
8495
const formRef = ref() // 表单 Ref
8596
const deptList = ref<Tree[]>([]) // 树形结构
@@ -96,9 +107,9 @@ const open = async (type: string, id?: number) => {
96107
if (id) {
97108
formLoading.value = true
98109
try {
99-
formData.value = await BusinessStatusTypeApi.getBusinessStatusType(id)
110+
formData.value = await BusinessStatusApi.getBusinessStatus(id)
100111
treeRef.value.setCheckedKeys(formData.value.deptIds)
101-
if (formData.value.statusList.length == 0) {
112+
if (formData.value.statuses.length == 0) {
102113
addStatusArea(0)
103114
}
104115
} finally {
@@ -120,13 +131,13 @@ const submitForm = async () => {
120131
// 提交请求
121132
formLoading.value = true
122133
try {
123-
const data = formData.value as unknown as BusinessStatusTypeApi.BusinessStatusTypeVO
134+
const data = formData.value as unknown as BusinessStatusApi.BusinessStatusTypeVO
124135
data.deptIds = treeRef.value.getCheckedKeys(false)
125136
if (formType.value === 'create') {
126-
await BusinessStatusTypeApi.createBusinessStatusType(data)
137+
await BusinessStatusApi.createBusinessStatus(data)
127138
message.success(t('common.createSuccess'))
128139
} else {
129-
await BusinessStatusTypeApi.updateBusinessStatusType(data)
140+
await BusinessStatusApi.updateBusinessStatus(data)
130141
message.success(t('common.updateSuccess'))
131142
}
132143
dialogVisible.value = false
@@ -144,7 +155,7 @@ const resetForm = () => {
144155
id: 0,
145156
name: '',
146157
deptIds: [],
147-
statusList: []
158+
statuses: []
148159
}
149160
treeRef.value?.setCheckedNodes([])
150161
formRef.value?.resetFields()
@@ -153,15 +164,15 @@ const resetForm = () => {
153164
/** 添加状态 */
154165
const addStatusArea = () => {
155166
const data = formData.value
156-
data.statusList.push({
167+
data.statuses.push({
157168
name: '',
158-
percent: ''
169+
percent: undefined
159170
})
160171
}
161172
162173
/** 删除状态 */
163174
const deleteStatusArea = (index: number) => {
164175
const data = formData.value
165-
data.statusList.splice(index, 1)
176+
data.statuses.splice(index, 1)
166177
}
167178
</script>

src/views/crm/businessStatusType/index.vue renamed to src/views/crm/business/status/index.vue

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,30 @@
99
label-width="68px"
1010
>
1111
<el-form-item>
12-
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
13-
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
1412
<el-button
1513
type="primary"
1614
plain
1715
@click="openForm('create')"
18-
v-hasPermi="['crm:business-status-type:create']"
16+
v-hasPermi="['crm:business-status:create']"
1917
>
2018
<Icon icon="ep:plus" class="mr-5px" /> 新增
2119
</el-button>
22-
<el-button
23-
type="success"
24-
plain
25-
@click="handleExport"
26-
:loading="exportLoading"
27-
v-hasPermi="['crm:business-status-type:export']"
28-
>
29-
<Icon icon="ep:download" class="mr-5px" /> 导出
30-
</el-button>
3120
</el-form-item>
3221
</el-form>
3322
</ContentWrap>
3423

3524
<!-- 列表 -->
3625
<ContentWrap>
3726
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
38-
<el-table-column label="状态类型名" align="center" prop="name" />
39-
<el-table-column label="使用的部门" align="center" prop="deptNames" />
27+
<el-table-column label="状态组名" align="center" prop="name" />
28+
<el-table-column label="应用部门" align="center" prop="deptNames">
29+
<template #default="scope">
30+
<span v-if="scope.row?.deptNames?.length > 0">
31+
{{ scope.row.deptNames.join(' ') }}
32+
</span>
33+
<span v-else>全公司</span>
34+
</template>
35+
</el-table-column>
4036
<el-table-column label="创建人" align="center" prop="creator" />
4137
<el-table-column
4238
label="创建时间"
@@ -51,15 +47,15 @@
5147
link
5248
type="primary"
5349
@click="openForm('update', scope.row.id)"
54-
v-hasPermi="['crm:business-status-type:update']"
50+
v-hasPermi="['crm:business-status:update']"
5551
>
5652
编辑
5753
</el-button>
5854
<el-button
5955
link
6056
type="danger"
6157
@click="handleDelete(scope.row.id)"
62-
v-hasPermi="['crm:business-status-type:delete']"
58+
v-hasPermi="['crm:business-status:delete']"
6359
>
6460
删除
6561
</el-button>
@@ -76,16 +72,16 @@
7672
</ContentWrap>
7773

7874
<!-- 表单弹窗:添加/修改 -->
79-
<BusinessStatusTypeForm ref="formRef" @success="getList" />
75+
<BusinessStatusForm ref="formRef" @success="getList" />
8076
</template>
8177

8278
<script setup lang="ts">
8379
import { dateFormatter } from '@/utils/formatTime'
8480
import download from '@/utils/download'
85-
import * as BusinessStatusTypeApi from '@/api/crm/businessStatusType'
86-
import BusinessStatusTypeForm from './BusinessStatusTypeForm.vue'
81+
import * as BusinessStatusApi from '@/api/crm/business/status'
82+
import BusinessStatusForm from './BusinessStatusForm.vue'
8783
88-
defineOptions({ name: 'BusinessStatusType' })
84+
defineOptions({ name: 'CrmBusinessStatus' })
8985
9086
const message = useMessage() // 消息弹窗
9187
const { t } = useI18n() // 国际化
@@ -104,7 +100,7 @@ const exportLoading = ref(false) // 导出的加载中
104100
const getList = async () => {
105101
loading.value = true
106102
try {
107-
const data = await BusinessStatusTypeApi.getBusinessStatusTypePage(queryParams)
103+
const data = await BusinessStatusApi.getBusinessStatusPage(queryParams)
108104
list.value = data.list
109105
total.value = data.total
110106
} finally {
@@ -157,7 +153,7 @@ const handleExport = async () => {
157153
// 发起导出
158154
exportLoading.value = true
159155
const data = await BusinessStatusTypeApi.exportBusinessStatusType(queryParams)
160-
download.excel(data, '商机状态类型.xls')
156+
download.excel(data, '商机状态组.xls')
161157
} catch {
162158
} finally {
163159
exportLoading.value = false

0 commit comments

Comments
 (0)