Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
owen 2024-02-04 19:42:14 +08:00
commit dd08fbcb46
36 changed files with 1905 additions and 240 deletions

25
src/api/crm/bi/rank.ts Normal file
View File

@ -0,0 +1,25 @@
import request from '@/config/axios'
export interface BiRankRespVO {
count: number
nickname: string
deptName: string
}
// 排行 API
export const RankApi = {
// 获得合同排行榜
getContractPriceRank: (params: any) => {
return request.get({
url: '/crm/bi-rank/get-contract-price-rank',
params
})
},
// 获得回款排行榜
getReceivablePriceRank: (params: any) => {
return request.get({
url: '/crm/bi-rank/get-receivable-price-rank',
params
})
}
}

View File

@ -1,4 +1,5 @@
import request from '@/config/axios' import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/customer'
export interface BusinessVO { export interface BusinessVO {
id: number id: number
@ -70,3 +71,8 @@ export const getBusinessPageByContact = async (params) => {
export const getBusinessListByIds = async (val: number[]) => { export const getBusinessListByIds = async (val: number[]) => {
return await request.get({ url: '/crm/business/list-by-ids', params: { ids: val.join(',') } }) return await request.get({ url: '/crm/business/list-by-ids', params: { ids: val.join(',') } })
} }
// 商机转移
export const transferBusiness = async (data: TransferReqVO) => {
return await request.put({ url: '/crm/business/transfer', data })
}

View File

@ -1,4 +1,5 @@
import request from '@/config/axios' import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/customer'
export interface ClueVO { export interface ClueVO {
id: number id: number
@ -44,3 +45,8 @@ export const deleteClue = async (id: number) => {
export const exportClue = async (params) => { export const exportClue = async (params) => {
return await request.download({ url: `/crm/clue/export-excel`, params }) return await request.download({ url: `/crm/clue/export-excel`, params })
} }
// 线索转移
export const transferClue = async (data: TransferReqVO) => {
return await request.put({ url: '/crm/clue/transfer', data })
}

View File

@ -1,4 +1,5 @@
import request from '@/config/axios' import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/customer'
export interface ContactVO { export interface ContactVO {
name: string name: string
@ -86,7 +87,7 @@ export const deleteContactBusinessList = async (data: ContactBusinessReqVO) => {
return await request.delete({ url: `/crm/contact/delete-business-list`, data }) return await request.delete({ url: `/crm/contact/delete-business-list`, data })
} }
// 查询联系人操作日志 // 联系人转移
export const getOperateLogPage = async (params: any) => { export const transferContact = async (data: TransferReqVO) => {
return await request.get({ url: '/crm/contact/operate-log-page', params }) return await request.put({ url: '/crm/contact/transfer', data })
} }

View File

@ -1,10 +1,13 @@
import request from '@/config/axios' import request from '@/config/axios'
import { ProductExpandVO } from '@/api/crm/product'
import { TransferReqVO } from '@/api/crm/customer'
export interface ContractVO { export interface ContractVO {
id: number id: number
name: string name: string
customerId: number customerId: number
businessId: number businessId: number
businessName: string
processInstanceId: number processInstanceId: number
orderDate: Date orderDate: Date
ownerUserId: number ownerUserId: number
@ -14,12 +17,19 @@ export interface ContractVO {
price: number price: number
discountPercent: number discountPercent: number
productPrice: number productPrice: number
roUserIds: string
rwUserIds: string
contactId: number contactId: number
signUserId: number signUserId: number
signUserName: string
contactLastTime: Date contactLastTime: Date
auditStatus: number
remark: string remark: string
productItems: ProductExpandVO[]
creatorName: string
updateTime?: Date
createTime?: Date
customerName: string
contactName: string
ownerUserName: string
} }
// 查询 CRM 合同列表 // 查询 CRM 合同列表
@ -56,3 +66,13 @@ export const deleteContract = async (id: number) => {
export const exportContract = async (params) => { export const exportContract = async (params) => {
return await request.download({ url: `/crm/contract/export-excel`, params }) return await request.download({ url: `/crm/contract/export-excel`, params })
} }
// 提交审核
export const submitContract = async (id: number) => {
return await request.put({ url: `/crm/contract/submit?id=${id}` })
}
// 合同转移
export const transferContract = async (data: TransferReqVO) => {
return await request.put({ url: '/crm/contract/transfer', data })
}

View File

@ -63,16 +63,16 @@ export const exportCustomer = async (params: any) => {
return await request.download({ url: `/crm/customer/export-excel`, params }) return await request.download({ url: `/crm/customer/export-excel`, params })
} }
// 下载客户导入模板
export const importCustomerTemplate = () => {
return request.download({ url: '/crm/customer/get-import-template' })
}
// 客户列表 // 客户列表
export const getSimpleCustomerList = async () => { export const getSimpleCustomerList = async () => {
return await request.get({ url: `/crm/customer/list-all-simple` }) return await request.get({ url: `/crm/customer/list-all-simple` })
} }
// 查询客户操作日志
export const getOperateLogPage = async (id: number) => {
return await request.get({ url: '/crm/customer/operate-log-page?id=' + id })
}
// ======================= 业务操作 ======================= // ======================= 业务操作 =======================
export interface TransferReqVO { export interface TransferReqVO {
@ -82,7 +82,7 @@ export interface TransferReqVO {
} }
// 客户转移 // 客户转移
export const transfer = async (data: TransferReqVO) => { export const transferCustomer = async (data: TransferReqVO) => {
return await request.put({ url: '/crm/customer/transfer', data }) return await request.put({ url: '/crm/customer/transfer', data })
} }
@ -100,3 +100,8 @@ export const receiveCustomer = async (ids: any[]) => {
export const putCustomerPool = async (id: number) => { export const putCustomerPool = async (id: number) => {
return await request.put({ url: `/crm/customer/put-pool?id=${id}` }) return await request.put({ url: `/crm/customer/put-pool?id=${id}` })
} }
// 进入公海客户提醒
export const getPutInPoolRemindCustomerPage = async (params) => {
return await request.get({ url: `/crm/customer/put-in-pool-remind-page`, params })
}

View File

@ -0,0 +1,11 @@
import request from '@/config/axios'
export interface OperateLogVO extends PageParam {
bizType: number
bizId: number
}
// 获得操作日志
export const getOperateLogPage = async (params: OperateLogVO) => {
return await request.get({ url: `/crm/operate-log/page`, params })
}

View File

@ -22,8 +22,11 @@ export enum BizTypeEnum {
CRM_LEADS = 1, // 线索 CRM_LEADS = 1, // 线索
CRM_CUSTOMER = 2, // 客户 CRM_CUSTOMER = 2, // 客户
CRM_CONTACT = 3, // 联系人 CRM_CONTACT = 3, // 联系人
CRM_BUSINESS = 5, // 商机 CRM_BUSINESS = 4, // 商机
CRM_CONTRACT = 6 // 合同 CRM_CONTRACT = 5, // 合同
CRM_PRODUCT = 6, // 产品
CRM_RECEIVABLE = 7, // 回款
CRM_RECEIVABLE_PLAN = 8 // 回款计划
} }
/** /**

View File

@ -12,6 +12,12 @@ export interface ProductVO {
ownerUserId: number ownerUserId: number
} }
export interface ProductExpandVO extends ProductVO {
count: number
discountPercent: number
totalPrice: number
}
// 查询产品列表 // 查询产品列表
export const getProductPage = async (params) => { export const getProductPage = async (params) => {
return await request.get({ url: `/crm/product/page`, params }) return await request.get({ url: `/crm/product/page`, params })
@ -41,8 +47,3 @@ export const deleteProduct = async (id: number) => {
export const exportProduct = async (params) => { export const exportProduct = async (params) => {
return await request.download({ url: `/crm/product/export-excel`, params }) return await request.download({ url: `/crm/product/export-excel`, params })
} }
// 查询产品操作日志
export const getOperateLogPage = async (params: any) => {
return await request.get({ url: '/crm/product/operate-log-page', params })
}

View File

@ -1,6 +1,7 @@
import Table from './src/Table.vue' import Table from './src/Table.vue'
import { ElTable } from 'element-plus' import { ElTable } from 'element-plus'
import { TableSetPropsType } from '@/types/table' import { TableSetPropsType } from '@/types/table'
import TableSelectForm from './src/TableSelectForm.vue'
export interface TableExpose { export interface TableExpose {
setProps: (props: Recordable) => void setProps: (props: Recordable) => void
@ -9,4 +10,4 @@ export interface TableExpose {
elTableRef: ComponentRef<typeof ElTable> elTableRef: ComponentRef<typeof ElTable>
} }
export { Table } export { Table, TableSelectForm }

View File

@ -0,0 +1,91 @@
<!-- 列表选择通用组件参考 ProductList 组件使用 -->
<template>
<Dialog v-model="dialogVisible" :appendToBody="true" :scroll="true" :title="title" width="60%">
<el-table
ref="multipleTableRef"
v-loading="loading"
:data="list"
:show-overflow-tooltip="true"
:stripe="true"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" />
<slot></slot>
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import { ElTable } from 'element-plus'
defineOptions({ name: 'TableSelectForm' })
withDefaults(
defineProps<{
modelValue: any[]
title: string
}>(),
{ modelValue: () => [], title: '选择' }
)
const list = ref([]) //
const total = ref(0) //
const loading = ref(false) //
const dialogVisible = ref(false) //
const formLoading = ref(false)
const queryParams = reactive({
pageNo: 1,
pageSize: 10
})
//
const emits = defineEmits<{
(e: 'update:modelValue', v: number[]): void
}>()
const multipleTableRef = ref<InstanceType<typeof ElTable>>()
const multipleSelection = ref<any[]>([])
const handleSelectionChange = (val: any[]) => {
multipleSelection.value = val
}
/** 触发 */
const submitForm = () => {
formLoading.value = true
try {
emits('update:modelValue', multipleSelection.value) // 使
} finally {
formLoading.value = false
//
dialogVisible.value = false
}
}
const getList = async (getListFunc: Function) => {
loading.value = true
try {
const data = await getListFunc(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 打开弹窗 */
const open = async (getListFunc: Function) => {
dialogVisible.value = true
await nextTick()
if (multipleSelection.value.length > 0) {
multipleTableRef.value!.clearSelection()
}
await getList(getListFunc)
}
defineExpose({ open }) // open
</script>

View File

@ -507,6 +507,17 @@ const remainingRouter: AppRouteRecordRaw[] = [
}, },
component: () => import('@/views/crm/customer/detail/index.vue') component: () => import('@/views/crm/customer/detail/index.vue')
}, },
{
path: 'contract/detail/:id',
name: 'CrmContractDetail',
meta: {
title: '合同详情',
noCache: true,
hidden: true,
activeMenu: '/crm/contract'
},
component: () => import('@/views/crm/contract/detail/index.vue')
},
{ {
path: 'contact/detail/:id', path: 'contact/detail/:id',
name: 'CrmContactDetail', name: 'CrmContactDetail',

View File

@ -10,7 +10,9 @@ interface UserVO {
id: number id: number
avatar: string avatar: string
nickname: string nickname: string
deptId: number
} }
interface UserInfoVO { interface UserInfoVO {
permissions: string[] permissions: string[]
roles: string[] roles: string[]
@ -26,7 +28,8 @@ export const useUserStore = defineStore('admin-user', {
user: { user: {
id: 0, id: 0,
avatar: '', avatar: '',
nickname: '' nickname: '',
deptId: 0
} }
}), }),
getters: { getters: {
@ -73,7 +76,8 @@ export const useUserStore = defineStore('admin-user', {
this.user = { this.user = {
id: 0, id: 0,
avatar: '', avatar: '',
nickname: '' nickname: '',
deptId: 0
} }
} }
} }

View File

@ -203,5 +203,8 @@ export enum DICT_TYPE {
CRM_PRODUCT_STATUS = 'crm_product_status', CRM_PRODUCT_STATUS = 'crm_product_status',
CRM_PERMISSION_LEVEL = 'crm_permission_level', // CRM 数据权限的级别 CRM_PERMISSION_LEVEL = 'crm_permission_level', // CRM 数据权限的级别
CRM_PRODUCT_UNIT = 'crm_product_unit', // 产品单位 CRM_PRODUCT_UNIT = 'crm_product_unit', // 产品单位
CRM_FOLLOW_UP_TYPE = 'crm_follow_up_type' // 跟进方式 CRM_FOLLOW_UP_TYPE = 'crm_follow_up_type', // 跟进方式
// ========== BI - 商业智能模块 ==========
BI_ANALYZE_TYPE = 'bi_analyze_type' // 分析类型
} }

View File

@ -1,7 +1,7 @@
<template> <template>
<div <div
:class="prefixCls" :class="prefixCls"
class="relative h-[100%] lt-xl:px-10px lt-md:px-10px lt-sm:px-10px lt-xl:px-10px" class="relative h-[100%] lt-md:px-10px lt-sm:px-10px lt-xl:px-10px lt-xl:px-10px"
> >
<div class="relative mx-auto h-full flex"> <div class="relative mx-auto h-full flex">
<div <div

View File

@ -1,3 +1,4 @@
<!-- TODO @dhb52: 存在很多重复的 table 定义如Customer: TodayCustomer,FollowCustomer,PutInPoolRemind -->
<template> <template>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="4" class="min-w-[200px]"> <el-col :span="4" class="min-w-[200px]">
@ -71,7 +72,6 @@ const leftSides = ref([
}, },
{ {
name: '待审核回款', name: '待审核回款',
crmType: 'receivables',
infoType: 'checkReceivables', infoType: 'checkReceivables',
msgCount: 0, msgCount: 0,
tips: '' tips: ''
@ -96,8 +96,8 @@ const leftSides = ref([
const sideClick = (item) => { const sideClick = (item) => {
leftType.value = item.infoType leftType.value = item.infoType
} }
// TODO @dhb52:
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.side-item-list { .side-item-list {
top: 0; top: 0;

View File

@ -1,15 +1,155 @@
<!-- 待进入公海的客户 --> <!-- 待进入公海的客户 -->
<!-- TODO: 后续再统一改名字 -->
<template> <template>
<div> <ContentWrap>
TODO: 待进入公海的客户 <div class="pb-5 text-xl"> 待进入公海的客户 </div>
</div> <!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="归属" prop="sceneType">
<el-select
v-model="queryParams.sceneType"
class="!w-240px"
placeholder="归属"
@change="handleQuery"
>
<el-option
v-for="(option, index) in SCENE_TYPES"
:label="option.label"
:value="option.value"
:key="index"
/>
</el-select>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="编号" prop="id" />
<el-table-column align="center" label="客户名称" prop="name" width="160">
<template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="手机" prop="mobile" width="120" />
<el-table-column align="center" label="电话" prop="telephone" width="120" />
<el-table-column align="center" label="客户来源" prop="source" width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" />
</template>
</el-table-column>
<el-table-column align="center" label="所属行业" prop="industryId" width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="scope.row.industryId" />
</template>
</el-table-column>
<el-table-column align="center" label="客户等级" prop="level" width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" />
</template>
</el-table-column>
<el-table-column align="center" label="网址" prop="website" width="200" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="下次联系时间"
prop="contactNextTime"
width="180px"
/>
<el-table-column align="center" label="备注" prop="remark" width="200" />
<el-table-column align="center" label="成交状态" prop="dealStatus">
<template #default="scope">
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.dealStatus" />
</template>
</el-table-column>
<el-table-column align="center" label="距进入公海天数" prop="poolDay" width="100px" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="最后跟进时间"
prop="contactLastTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="updateTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="负责人" prop="ownerUserName" width="100px" />
<el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
<el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
</template> </template>
<script setup lang="ts" name="PutInPoolRemind"> <script lang="ts" setup name="PutInPoolRemind">
import * as CustomerApi from '@/api/crm/customer'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import { SCENE_TYPES } from './common'
const { push } = useRouter()
const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
const queryParams = ref({
pageNo: 1,
pageSize: 10,
sceneType: 1, //
pool: true, // true
})
const queryFormRef = ref() //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await CustomerApi.getPutInPoolRemindCustomerPage(queryParams.value)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNo = 1
getList()
}
/** 打开客户详情 */
const openDetail = (id: number) => {
push({ name: 'CrmCustomerDetail', params: { id } })
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script> </script>
<style scoped> <style lang="scss"></style>
</style>

View File

@ -0,0 +1,107 @@
<!-- 合同金额排行 -->
<template>
<!-- 柱状图 -->
<el-card shadow="never">
<el-skeleton :loading="loading" animated>
<Echart :height="500" :options="echartsOption" />
</el-skeleton>
</el-card>
<!-- 排行列表 -->
<el-card shadow="never" class="mt-16px">
<el-table v-loading="loading" :data="list">
<el-table-column label="公司排名" align="center" type="index" width="80" />
<el-table-column label="签订人" align="center" prop="nickname" min-width="200" />
<el-table-column label="部门" align="center" prop="deptName" min-width="200" />
<el-table-column
label="合同金额(元)"
align="center"
prop="count"
min-width="200"
:formatter="fenToYuanFormat"
/>
</el-table>
</el-card>
</template>
<script setup lang="ts">
import { RankApi, BiRankRespVO } from '@/api/crm/bi/rank'
import { EChartsOption } from 'echarts'
import { fenToYuanFormat } from '@/utils/formatter'
import { fenToYuan } from '@/utils'
import { clone } from 'unocss'
defineOptions({ name: 'ContractPriceRank' })
const props = defineProps<{ queryParams: any }>() //
const loading = ref(false) //
const list = ref<BiRankRespVO[]>([]) //
/** 柱状图配置:横向 */
const echartsOption = reactive<EChartsOption>({
dataset: {
dimensions: ['nickname', 'count'],
source: []
},
grid: {
left: 20,
right: 20,
bottom: 20,
containLabel: true
},
legend: {
top: 50
},
series: [
{
name: '合同金额排行',
type: 'bar'
}
],
toolbox: {
feature: {
dataZoom: {
yAxisIndex: false // Y
},
brush: {
type: ['lineX', 'clear'] //
},
saveAsImage: { show: true, name: '合同金额排行' } //
}
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
valueFormatter: fenToYuan
},
xAxis: {
type: 'value',
name: '合同金额(元)'
},
yAxis: {
type: 'category',
name: '签订人'
}
}) as EChartsOption
/** 获取合同金额排行 */
const loadData = async () => {
// 1.
loading.value = true
const rankingList = await RankApi.getContractPriceRank(props.queryParams)
// 2.1 Echarts
if (echartsOption.dataset && echartsOption.dataset['source']) {
echartsOption.dataset['source'] = clone(rankingList).reverse()
}
// 2.2
list.value = rankingList
loading.value = false
}
defineExpose({ loadData })
/** 初始化 */
onMounted(() => {
loadData()
})
</script>

View File

@ -0,0 +1,108 @@
<!-- 回款金额排行 -->
<template>
<!-- 柱状图 -->
<el-card shadow="never">
<el-skeleton :loading="loading" animated>
<Echart :height="500" :options="echartsOption" />
</el-skeleton>
</el-card>
<!-- 排行列表 -->
<el-card shadow="never" class="mt-16px">
<el-table v-loading="loading" :data="list">
<el-table-column label="公司排名" align="center" type="index" width="80" />
<el-table-column label="签订人" align="center" prop="nickname" min-width="200" />
<el-table-column label="部门" align="center" prop="deptName" min-width="200" />
<el-table-column
label="回款金额(元)"
align="center"
prop="count"
min-width="200"
:formatter="fenToYuanFormat"
/>
</el-table>
</el-card>
</template>
<script setup lang="ts">
import { RankApi, BiRankRespVO } from '@/api/crm/bi/rank'
import { EChartsOption } from 'echarts'
import { fenToYuanFormat } from '@/utils/formatter'
import { fenToYuan } from '@/utils'
import { clone } from 'unocss'
defineOptions({ name: 'ReceivablePriceRank' })
const props = defineProps<{ queryParams: any }>() //
const loading = ref(false) //
const list = ref<BiRankRespVO[]>([]) //
/** 柱状图配置:横向 */
const echartsOption = reactive<EChartsOption>({
dataset: {
dimensions: ['nickname', 'count'],
source: []
},
grid: {
left: 20,
right: 20,
bottom: 20,
containLabel: true
},
legend: {
top: 50
},
series: [
{
name: '回款金额排行',
type: 'bar'
}
],
toolbox: {
feature: {
dataZoom: {
yAxisIndex: false // Y
},
brush: {
type: ['lineX', 'clear'] //
},
saveAsImage: { show: true, name: '回款金额排行' } //
}
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
valueFormatter: fenToYuan
},
xAxis: {
type: 'value',
name: '回款金额(元)'
},
yAxis: {
type: 'category',
name: '签订人',
nameGap: 30
}
}) as EChartsOption
/** 获取回款金额排行 */
const loadData = async () => {
// 1.
loading.value = true
const rankingList = await RankApi.getReceivablePriceRank(props.queryParams)
// 2.1 Echarts
if (echartsOption.dataset && echartsOption.dataset['source']) {
echartsOption.dataset['source'] = clone(rankingList).reverse()
}
// 2.2
list.value = rankingList
loading.value = false
}
defineExpose({ loadData })
/** 初始化 */
onMounted(() => {
loadData()
})
</script>

View File

@ -0,0 +1,100 @@
<!-- BI 排行版 -->
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="时间范围" prop="orderDate">
<el-date-picker
v-model="queryParams.times"
:shortcuts="defaultShortcuts"
class="!w-240px"
end-placeholder="结束日期"
start-placeholder="开始日期"
type="daterange"
value-format="YYYY-MM-DD HH:mm:ss"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
/>
</el-form-item>
<el-form-item label="归属部门" prop="deptId">
<el-tree-select
v-model="queryParams.deptId"
:data="deptList"
:props="defaultProps"
check-strictly
node-key="id"
placeholder="请选择归属部门"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 排行数据 -->
<el-col>
<el-tabs v-model="activeTab">
<!-- 合同金额排行 -->
<el-tab-pane label="合同金额排行" name="contractPriceRank" lazy>
<ContractPriceRank :query-params="queryParams" ref="contractPriceRankRef" />
</el-tab-pane>
<!-- 回款金额排行 -->
<el-tab-pane label="回款金额排行" name="receivablePriceRank" lazy>
<ReceivablePriceRank :query-params="queryParams" ref="receivablePriceRankRef" />
</el-tab-pane>
</el-tabs>
</el-col>
</template>
<script lang="ts" setup>
import ContractPriceRank from './ContractPriceRank.vue'
import ReceivablePriceRank from './ReceivablePriceRank.vue'
import { defaultProps, handleTree } from '@/utils/tree'
import * as DeptApi from '@/api/system/dept'
import { beginOfDay, defaultShortcuts, endOfDay, formatDate } from '@/utils/formatTime'
import { useUserStore } from '@/store/modules/user'
defineOptions({ name: 'CrmBiRank' })
const queryParams = reactive({
deptId: useUserStore().getUser.deptId,
times: [
//
formatDate(beginOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24 * 7))),
formatDate(endOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24)))
]
})
const queryFormRef = ref() //
const deptList = ref<Tree[]>([]) //
const activeTab = ref('contractPriceRank')
const contractPriceRankRef = ref() // ContractPriceRank
const receivablePriceRankRef = ref() // ReceivablePriceRank
/** 搜索按钮操作 */
const handleQuery = () => {
if (activeTab.value === 'contractPriceRank') {
contractPriceRankRef.value.loadData()
} else if (activeTab.value === 'receivablePriceRank') {
receivablePriceRankRef.value.loadData()
}
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
//
onMounted(async () => {
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
})
</script>
<style lang="scss" scoped></style>

View File

@ -10,9 +10,7 @@
</div> </div>
<div> <div>
<!-- 右上按钮 --> <!-- 右上按钮 -->
<el-button @click="openForm('update', contact.id)" v-hasPermi="['crm:contact:update']"> <slot></slot>
编辑
</el-button>
</div> </div>
</div> </div>
</div> </div>
@ -32,18 +30,10 @@
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 -->
<ContactForm ref="formRef" @success="emit('refresh')" />
</template> </template>
<script setup lang="ts"> <script lang="ts" setup>
import * as ContactApi from '@/api/crm/contact' import * as ContactApi from '@/api/crm/contact'
import ContactForm from '@/views/crm/contact/ContactForm.vue'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
//
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
const { contact } = defineProps<{ contact: ContactApi.ContactVO }>() const { contact } = defineProps<{ contact: ContactApi.ContactVO }>()
const emit = defineEmits(['refresh']) // success
</script> </script>

View File

@ -1,5 +1,12 @@
<template> <template>
<ContactDetailsHeader :contact="contact" :loading="loading" @refresh="getContactData(id)" /> <ContactDetailsHeader v-loading="loading" :contact="contact">
<el-button v-if="permissionListRef?.validateWrite" @click="openForm('update', contact.id)">
编辑
</el-button>
<el-button v-if="permissionListRef?.validateOwnerUser" type="primary" @click="transfer">
转移
</el-button>
</ContactDetailsHeader>
<el-col> <el-col>
<el-tabs> <el-tabs>
<el-tab-pane label="详细资料"> <el-tab-pane label="详细资料">
@ -8,8 +15,14 @@
<el-tab-pane label="操作日志"> <el-tab-pane label="操作日志">
<OperateLogV2 :log-list="logList" /> <OperateLogV2 :log-list="logList" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="团队成员" lazy> <el-tab-pane label="团队成员">
<PermissionList :biz-id="contact.id!" :biz-type="BizTypeEnum.CRM_CONTACT" /> <PermissionList
ref="permissionListRef"
:biz-id="contact.id!"
:biz-type="BizTypeEnum.CRM_CONTACT"
:show-action="!permissionListRef?.isPool || false"
@quit-team="close"
/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="商机" lazy> <el-tab-pane label="商机" lazy>
<BusinessList <BusinessList
@ -20,8 +33,11 @@
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-col> </el-col>
<!-- 表单弹窗添加/修改 -->
<ContactForm ref="formRef" @success="getContactData(contact.id)" />
<CrmTransferForm ref="crmTransferFormRef" @success="close" />
</template> </template>
<script setup lang="ts"> <script lang="ts" setup>
import { useTagsViewStore } from '@/store/modules/tagsView' import { useTagsViewStore } from '@/store/modules/tagsView'
import * as ContactApi from '@/api/crm/contact' import * as ContactApi from '@/api/crm/contact'
import ContactDetailsHeader from '@/views/crm/contact/detail/ContactDetailsHeader.vue' import ContactDetailsHeader from '@/views/crm/contact/detail/ContactDetailsHeader.vue'
@ -30,13 +46,18 @@ import BusinessList from '@/views/crm/business/components/BusinessList.vue' //
import PermissionList from '@/views/crm/permission/components/PermissionList.vue' // import PermissionList from '@/views/crm/permission/components/PermissionList.vue' //
import { BizTypeEnum } from '@/api/crm/permission' import { BizTypeEnum } from '@/api/crm/permission'
import { OperateLogV2VO } from '@/api/system/operatelog' import { OperateLogV2VO } from '@/api/system/operatelog'
import { getOperateLogPage } from '@/api/crm/operateLog'
import ContactForm from '@/views/crm/contact/ContactForm.vue'
import CrmTransferForm from '@/views/crm/permission/components/TransferForm.vue'
defineOptions({ name: 'CrmContactDetail' }) defineOptions({ name: 'CrmContactDetail' })
const route = useRoute() const route = useRoute()
const message = useMessage()
const id = Number(route.params.id) // const id = Number(route.params.id) //
const loading = ref(true) // const loading = ref(true) //
const contact = ref<ContactApi.ContactVO>({} as ContactApi.ContactVO) // const contact = ref<ContactApi.ContactVO>({} as ContactApi.ContactVO) //
const permissionListRef = ref<InstanceType<typeof PermissionList>>() // Ref
/** 获取详情 */ /** 获取详情 */
const getContactData = async (id: number) => { const getContactData = async (id: number) => {
@ -49,27 +70,43 @@ const getContactData = async (id: number) => {
} }
} }
/** /** 编辑 */
* 获取操作日志 const formRef = ref()
*/ const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 联系人转移 */
const crmTransferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // ref
const transfer = () => {
crmTransferFormRef.value?.open('联系人转移', contact.value.id, ContactApi.transferContact)
}
/** 获取操作日志 */
const logList = ref<OperateLogV2VO[]>([]) // const logList = ref<OperateLogV2VO[]>([]) //
const getOperateLog = async (contactId: number) => { const getOperateLog = async (contactId: number) => {
if (!contactId) { if (!contactId) {
return return
} }
const data = await ContactApi.getOperateLogPage({ const data = await getOperateLogPage({
bizType: BizTypeEnum.CRM_CONTACT,
bizId: contactId bizId: contactId
}) })
logList.value = data.list logList.value = data.list
} }
/** 关闭窗口 */
const close = () => {
delView(unref(currentRoute))
}
/** 初始化 */ /** 初始化 */
const { delView } = useTagsViewStore() // const { delView } = useTagsViewStore() //
const { currentRoute } = useRouter() // const { currentRoute } = useRouter() //
onMounted(async () => { onMounted(async () => {
if (!id) { if (!id) {
ElMessage.warning('参数错误,联系人不能为空!') message.warning('参数错误,联系人不能为空!')
delView(unref(currentRoute)) close()
return return
} }
await getContactData(id) await getContactData(id)

View File

@ -22,7 +22,7 @@
v-for="item in customerList" v-for="item in customerList"
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.id" :value="item.id!"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>

View File

@ -1,54 +1,69 @@
<template> <template>
<Dialog :title="dialogTitle" v-model="dialogVisible"> <Dialog v-model="dialogVisible" :title="dialogTitle" width="820">
<el-form <el-form
ref="formRef" ref="formRef"
v-loading="formLoading"
:model="formData" :model="formData"
:rules="formRules" :rules="formRules"
label-width="100px" label-width="110px"
v-loading="formLoading"
> >
<el-row> <el-row :gutter="20">
<el-col :span="12">
<el-form-item label="合同编号" prop="no">
<el-input v-model="formData.no" placeholder="请输入合同编号" />
</el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="合同名称" prop="name"> <el-form-item label="合同名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入合同名称" /> <el-input v-model="formData.name" placeholder="请输入合同名称" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="客户" prop="customerId"> <el-form-item label="客户名称" prop="customerId">
<el-input v-model="formData.customerId" placeholder="请选择对应客户" /> <el-select v-model="formData.customerId">
<el-option
v-for="item in customerList"
:key="item.id"
:label="item.name"
:value="item.id!"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="商机名称" prop="businessId">
<el-select v-model="formData.businessId">
<el-option
v-for="item in businessList"
:key="item.id"
:label="item.name"
:value="item.id!"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="下单日期" prop="orderDate">
<el-date-picker
v-model="formData.orderDate"
placeholder="选择下单日期"
type="date"
value-format="x"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="合同金额" prop="price">
<el-input v-model="formData.price" placeholder="请输入合同金额" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row>
<el-form-item label="商机名称" prop="businessId">
<el-input v-model="formData.businessId" placeholder="请选择对应商机" />
</el-form-item>
<el-form-item label="工作流" prop="processInstanceId">
<el-input v-model="formData.processInstanceId" placeholder="请选择工作流" />
</el-form-item>
<el-form-item label="下单日期" prop="orderDate">
<el-date-picker
v-model="formData.orderDate"
type="date"
value-format="x"
placeholder="选择下单日期"
/>
</el-form-item>
<el-form-item label="负责人" prop="ownerUserId">
<el-input v-model="formData.ownerUserId" placeholder="请选择负责人" />
</el-form-item>
<el-form-item label="合同编号" prop="no">
<el-input v-model="formData.no" placeholder="请输入合同编号" />
</el-form-item>
<el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="开始时间" prop="startTime"> <el-form-item label="开始时间" prop="startTime">
<el-date-picker <el-date-picker
v-model="formData.startTime" v-model="formData.startTime"
placeholder="选择开始时间"
type="date" type="date"
value-format="x" value-format="x"
placeholder="选择开始时间"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -56,72 +71,97 @@
<el-form-item label="结束时间" prop="endTime"> <el-form-item label="结束时间" prop="endTime">
<el-date-picker <el-date-picker
v-model="formData.endTime" v-model="formData.endTime"
placeholder="选择结束时间"
type="date" type="date"
value-format="x" value-format="x"
placeholder="选择结束时间"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="合同金额" prop="price">
<el-input v-model="formData.price" placeholder="请输入合同金额" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="整单折扣" prop="discountPercent">
<el-input v-model="formData.discountPercent" placeholder="请输入整单折扣" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="产品总金额" prop="productPrice">
<el-input v-model="formData.productPrice" placeholder="请输入产品总金额" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="只读权限的用户" prop="roUserIds">
<el-input v-model="formData.roUserIds" placeholder="请输入只读权限的用户" />
</el-form-item>
<el-form-item label="读写权限的用户" prop="rwUserIds">
<el-input v-model="formData.rwUserIds" placeholder="请输入读写权限的用户" />
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="联系人编号" prop="contactId">
<el-input v-model="formData.contactId" placeholder="请输入联系人编号" />
</el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="公司签约人" prop="signUserId"> <el-form-item label="公司签约人" prop="signUserId">
<el-input v-model="formData.signUserId" placeholder="请输入公司签约人" /> <el-select v-model="formData.signUserId">
<el-option
v-for="item in userList"
:key="item.id"
:label="item.nickname"
:value="item.id!"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="客户签约人" prop="contactId">
<el-select v-model="formData.contactId" :disabled="!formData.customerId">
<el-option
v-for="item in getContactOptions"
:key="item.id"
:label="item.name"
:value="item.id!"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="负责人" prop="ownerUserId">
<el-select v-model="formData.ownerUserId">
<el-option
v-for="item in userList"
:key="item.id"
:label="item.nickname"
:value="item.id!"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input
v-model="formData.remark"
:rows="3"
placeholder="请输入备注"
type="textarea"
/>
</el-form-item>
</el-col>
<!-- TODO @puhui999productItems 改成 products 会更好点因为它不是 item -->
<el-col :span="24">
<el-form-item label="产品列表" prop="productList">
<ProductList v-model="formData.productItems" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="整单折扣(%)" prop="discountPercent">
<el-input-number
v-model="formData.discountPercent"
:min="0"
:max="100"
:precision="0"
placeholder="请输入整单折扣"
class="!w-100%"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="产品总金额(元)" prop="productPrice">
{{ fenToYuan(formData.productPrice) }}
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-form-item label="最后跟进时间" prop="contactLastTime">
<el-date-picker
v-model="formData.contactLastTime"
type="date"
value-format="x"
placeholder="选择最后跟进时间"
/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" placeholder="请输入备注" />
</el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> <el-button :disabled="formLoading" type="primary" @click="submitForm">保存</el-button>
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="dialogVisible = false"> </el-button>
</template> </template>
</Dialog> </Dialog>
</template> </template>
<script setup lang="ts"> <script lang="ts" setup>
import * as CustomerApi from '@/api/crm/customer'
import * as ContractApi from '@/api/crm/contract' import * as ContractApi from '@/api/crm/contract'
import * as UserApi from '@/api/system/user'
import * as ContactApi from '@/api/crm/contact'
import * as BusinessApi from '@/api/crm/business'
import ProductList from './components/ProductList.vue'
import { fenToYuan } from '@/utils'
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -130,32 +170,34 @@ const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // const dialogTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formType = ref('') // create - update - const formType = ref('') // create - update -
const formData = ref({ const formData = ref<ContractApi.ContractVO>({} as ContractApi.ContractVO)
id: undefined,
name: undefined,
customerId: undefined,
businessId: undefined,
processInstanceId: undefined,
orderDate: undefined,
ownerUserId: undefined,
no: undefined,
startTime: undefined,
endTime: undefined,
price: undefined,
discountPercent: undefined,
productPrice: undefined,
roUserIds: undefined,
rwUserIds: undefined,
contactId: undefined,
signUserId: undefined,
contactLastTime: undefined,
remark: undefined
})
const formRules = reactive({ const formRules = reactive({
name: [{ required: true, message: '合同名称不能为空', trigger: 'blur' }] name: [{ required: true, message: '合同名称不能为空', trigger: 'blur' }],
customerId: [{ required: true, message: '客户不能为空', trigger: 'blur' }],
orderDate: [{ required: true, message: '下单日期不能为空', trigger: 'blur' }],
ownerUserId: [{ required: true, message: '负责人不能为空', trigger: 'blur' }],
no: [{ required: true, message: '合同编号不能为空', trigger: 'blur' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
/** 监听合同产品变化,计算合同产品总价 */
watch(
() => formData.value.productItems,
(val) => {
if (!val || val.length === 0) {
formData.value.productPrice = 0
return
}
// 使 reduce
formData.value.productPrice = val.reduce(
(accumulator, currentValue) =>
isNaN(accumulator + currentValue.totalPrice) ? 0 : accumulator + currentValue.totalPrice,
0
)
},
{ deep: true }
)
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
dialogVisible.value = true dialogVisible.value = true
@ -171,6 +213,7 @@ const open = async (type: string, id?: number) => {
formLoading.value = false formLoading.value = false
} }
} }
await getAllApi()
} }
defineExpose({ open }) // open defineExpose({ open }) // open
@ -184,7 +227,7 @@ const submitForm = async () => {
// //
formLoading.value = true formLoading.value = true
try { try {
const data = formData.value as unknown as ContractApi.ContractVO const data = unref(formData.value) as unknown as ContractApi.ContractVO
if (formType.value === 'create') { if (formType.value === 'create') {
await ContractApi.createContract(data) await ContractApi.createContract(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
@ -202,27 +245,39 @@ const submitForm = async () => {
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = () => {
formData.value = { formData.value = {} as ContractApi.ContractVO
id: undefined,
name: undefined,
customerId: undefined,
businessId: undefined,
processInstanceId: undefined,
orderDate: undefined,
ownerUserId: undefined,
no: undefined,
startTime: undefined,
endTime: undefined,
price: undefined,
discountPercent: undefined,
productPrice: undefined,
roUserIds: undefined,
rwUserIds: undefined,
contactId: undefined,
signUserId: undefined,
contactLastTime: undefined,
remark: undefined
}
formRef.value?.resetFields() formRef.value?.resetFields()
} }
/** 获取其它相关数据 */
const getAllApi = async () => {
await Promise.all([getCustomerList(), getUserList(), getContactListList(), getBusinessList()])
}
/** 获取客户 */
const customerList = ref<CustomerApi.CustomerVO[]>([])
const getCustomerList = async () => {
customerList.value = await CustomerApi.getSimpleCustomerList()
}
/** 动态获取客户联系人 */
const contactList = ref<ContactApi.ContactVO[]>([])
const getContactOptions = computed(() =>
contactList.value.filter((item) => item.customerId === formData.value.customerId)
)
const getContactListList = async () => {
contactList.value = await ContactApi.getSimpleContactList()
}
/** 获取用户列表 */
const userList = ref<UserApi.UserVO[]>([])
const getUserList = async () => {
userList.value = await UserApi.getSimpleUserList()
}
/** 获取商机 */
const businessList = ref<BusinessApi.BusinessVO[]>([])
const getBusinessList = async () => {
businessList.value = await BusinessApi.getSimpleBusinessList()
}
</script> </script>

View File

@ -0,0 +1,171 @@
<!-- 合同 Form 表单下的 Product 列表 -->
<template>
<el-row justify="end">
<el-button plain type="primary" @click="openForm">添加产品</el-button>
</el-row>
<el-table :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="产品名称" prop="name" width="120" />
<el-table-column
:formatter="fenToYuanFormat"
align="center"
label="价格"
prop="price"
width="100"
/>
<el-table-column align="center" label="产品类型" prop="categoryName" width="100" />
<el-table-column align="center" label="产品单位" prop="unit">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_PRODUCT_UNIT" :value="scope.row.unit" />
</template>
</el-table-column>
<el-table-column align="center" label="产品编码" prop="no" />
<el-table-column align="center" fixed="right" label="数量" prop="count" width="100">
<template #default="{ row }: { row: ProductApi.ProductExpandVO }">
<el-input-number
v-model="row.count"
controls-position="right"
:min="0"
:precision="0"
class="!w-100%"
/>
</template>
</el-table-column>
<el-table-column
align="center"
fixed="right"
label="折扣(%)"
prop="discountPercent"
width="120"
>
<template #default="{ row }: { row: ProductApi.ProductExpandVO }">
<el-input-number
v-model="row.discountPercent"
controls-position="right"
:min="0"
:max="100"
:precision="0"
class="!w-100%"
/>
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="合计" prop="totalPrice" width="100">
<template #default="{ row }: { row: ProductApi.ProductExpandVO }">
{{ fenToYuan(getTotalPrice(row)) }}
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="60">
<template #default="scope">
<el-button link type="danger" @click="handleDelete(scope.row.id)"> 移除</el-button>
</template>
</el-table-column>
</el-table>
<!-- table 选择表单 -->
<TableSelectForm ref="tableSelectFormRef" v-model="multipleSelection" title="选择产品">
<el-table-column align="center" label="产品名称" prop="name" width="160" />
<el-table-column align="center" label="产品类型" prop="categoryName" width="160" />
<el-table-column align="center" label="产品单位" prop="unit">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_PRODUCT_UNIT" :value="scope.row.unit" />
</template>
</el-table-column>
<el-table-column align="center" label="产品编码" prop="no" />
<el-table-column
:formatter="fenToYuanFormat"
align="center"
label="价格(元)"
prop="price"
width="100"
/>
</TableSelectForm>
</template>
<script lang="ts" setup>
import * as ProductApi from '@/api/crm/product'
import { DICT_TYPE } from '@/utils/dict'
import { fenToYuanFormat } from '@/utils/formatter'
import { TableSelectForm } from '@/components/Table/index'
import { fenToYuan, floatToFixed2, yuanToFen } from '@/utils'
defineOptions({ name: 'ProductList' })
const props = withDefaults(defineProps<{ modelValue: ProductApi.ProductExpandVO[] }>(), {
modelValue: () => []
})
const emits = defineEmits<{
(e: 'update:modelValue', v: any[]): void
}>()
const list = ref<ProductApi.ProductExpandVO[]>([]) //
const multipleSelection = ref<ProductApi.ProductExpandVO[]>([]) //
/** 处理删除 */
const handleDelete = (id: number) => {
const index = list.value.findIndex((item) => item.id === id)
if (index !== -1) {
list.value.splice(index, 1)
}
}
/** 打开 Product 弹窗 */
const tableSelectFormRef = ref<InstanceType<typeof TableSelectForm>>()
const openForm = () => {
tableSelectFormRef.value?.open(ProductApi.getProductPage)
}
/** 计算 totalPrice */
const getTotalPrice = computed(() => (row: ProductApi.ProductExpandVO) => {
const totalPrice =
(Number(row.price) / 100) * Number(row.count) * (1 - Number(row.discountPercent) / 100)
row.totalPrice = isNaN(totalPrice) ? 0 : yuanToFen(totalPrice)
return isNaN(totalPrice) ? 0 : totalPrice.toFixed(2)
})
/** 编辑时合同产品回显 */
const isSetListValue = ref(false) // list
watch(
() => props.modelValue,
(val) => {
if (!val || val.length === 0 || isSetListValue.value) {
return
}
list.value = [
...props.modelValue.map((item) => {
item.totalPrice = floatToFixed2(item.totalPrice) as unknown as number
return item
})
]
isSetListValue.value = true
},
{ immediate: true, deep: true }
)
/** 监听列表变化,动态更新合同产品列表 */
watch(
list,
(val) => {
if (!val || val.length === 0) {
return
}
emits('update:modelValue', list.value)
},
{ deep: true }
)
// ,
watch(
multipleSelection,
(val) => {
if (!val || val.length === 0) {
return
}
//
const ids = list.value.map((item) => item.id)
const productList = multipleSelection.value.filter((item) => ids.indexOf(item.id) === -1)
if (!productList || productList.length === 0) {
return
}
list.value.push(...productList)
},
{ deep: true }
)
</script>

View File

@ -0,0 +1,45 @@
<!-- 合同详情头部组件-->
<template>
<div>
<div class="flex items-start justify-between">
<div>
<el-col>
<el-row>
<span class="text-xl font-bold">{{ contract.name }}</span>
</el-row>
</el-col>
</div>
<div>
<!-- 右上按钮 -->
<slot></slot>
</div>
</div>
</div>
<ContentWrap class="mt-10px">
<el-descriptions :column="5" direction="vertical">
<el-descriptions-item label="客户名称">
{{ contract.customerName }}
</el-descriptions-item>
<el-descriptions-item label="合同金额(元)">
{{ floatToFixed2(contract.price) }}
</el-descriptions-item>
<el-descriptions-item label="下单时间">
{{ contract.orderDate ? formatDate(contract.orderDate) : '空' }}
</el-descriptions-item>
<el-descriptions-item label="回款金额(元)">
{{ floatToFixed2(contract.price) }}
</el-descriptions-item>
<el-descriptions-item label="负责人">
{{ contract.ownerUserName }}
</el-descriptions-item>
</el-descriptions>
</ContentWrap>
</template>
<script lang="ts" setup>
import * as ContractApi from '@/api/crm/contract'
import { formatDate } from '@/utils/formatTime'
import { floatToFixed2 } from '@/utils'
defineOptions({ name: 'ContractDetailsHeader' })
defineProps<{ contract: ContractApi.ContractVO }>()
</script>

View File

@ -0,0 +1,81 @@
<!-- 合同详情组件 -->
<template>
<ContentWrap>
<el-collapse v-model="activeNames">
<el-collapse-item name="contractInfo">
<template #title>
<span class="text-base font-bold">基本信息</span>
</template>
<el-descriptions :column="3">
<el-descriptions-item label="合同编号">
{{ contract.no }}
</el-descriptions-item>
<el-descriptions-item label="合同名称">
{{ contract.name }}
</el-descriptions-item>
<el-descriptions-item label="客户名称">
{{ contract.customerName }}
</el-descriptions-item>
<el-descriptions-item label="商机名称">
{{ contract.businessName }}
</el-descriptions-item>
<el-descriptions-item label="合同金额(元)">
{{ contract.price }}
</el-descriptions-item>
<el-descriptions-item label="下单时间">
{{ formatDate(contract.orderDate) }}
</el-descriptions-item>
<el-descriptions-item label="开始时间">
{{ formatDate(contract.startTime) }}
</el-descriptions-item>
<el-descriptions-item label="结束时间">
{{ formatDate(contract.endTime) }}
</el-descriptions-item>
<el-descriptions-item label="客户签约人">
{{ contract.contactName }}
</el-descriptions-item>
<el-descriptions-item label="公司签约人">
{{ contract.signUserName }}
</el-descriptions-item>
<el-descriptions-item label="备注">
{{ contract.remark }}
</el-descriptions-item>
<el-descriptions-item label="合同状态">
{{ contract.auditStatus }}
</el-descriptions-item>
</el-descriptions>
</el-collapse-item>
<el-collapse-item name="systemInfo">
<template #title>
<span class="text-base font-bold">系统信息</span>
</template>
<el-descriptions :column="2">
<el-descriptions-item label="负责人">
{{ contract.ownerUserName }}
</el-descriptions-item>
<el-descriptions-item label="创建人">
{{ contract.creatorName }}
</el-descriptions-item>
<el-descriptions-item label="创建时间">
{{ contract.createTime ? formatDate(contract.createTime) : '空' }}
</el-descriptions-item>
<el-descriptions-item label="更新时间">
{{ contract.updateTime ? formatDate(contract.updateTime) : '空' }}
</el-descriptions-item>
</el-descriptions>
</el-collapse-item>
</el-collapse>
</ContentWrap>
</template>
<script lang="ts" setup>
import * as ContractApi from '@/api/crm/contract'
import { formatDate } from '@/utils/formatTime'
defineOptions({ name: 'ContractDetailsInfo' })
defineProps<{
contract: ContractApi.ContractVO
}>()
//
const activeNames = ref(['contractInfo', 'systemInfo'])
</script>

View File

@ -0,0 +1,67 @@
<!-- 合同详情产品列表 -->
<template>
<el-table :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="产品名称" prop="name" width="160" />
<el-table-column align="center" label="产品类型" prop="categoryName" width="160" />
<el-table-column align="center" label="产品单位" prop="unit">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_PRODUCT_UNIT" :value="scope.row.unit" />
</template>
</el-table-column>
<el-table-column align="center" label="产品编码" prop="no" />
<el-table-column
:formatter="fenToYuanFormat"
align="center"
label="价格(元)"
prop="price"
width="100"
/>
<el-table-column align="center" label="数量" prop="count" width="200" />
<el-table-column align="center" label="折扣(%)" prop="discountPercent" width="200" />
<el-table-column align="center" label="合计" prop="totalPrice" width="100">
<template #default="{ row }: { row: ProductApi.ProductExpandVO }">
{{ getTotalPrice(row) }}
</template>
</el-table-column>
</el-table>
</template>
<script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict'
import { fenToYuanFormat } from '@/utils/formatter'
import * as ProductApi from '@/api/crm/product'
import { floatToFixed2, yuanToFen } from '@/utils'
defineOptions({ name: 'ContractProductList' })
const props = withDefaults(defineProps<{ modelValue: ProductApi.ProductExpandVO[] }>(), {
modelValue: () => []
})
const list = ref<ProductApi.ProductExpandVO[]>([]) //
/** 计算 totalPrice */
const getTotalPrice = computed(() => (row: ProductApi.ProductExpandVO) => {
const totalPrice =
(Number(row.price) / 100) * Number(row.count) * (1 - Number(row.discountPercent) / 100)
row.totalPrice = isNaN(totalPrice) ? 0 : yuanToFen(totalPrice)
return isNaN(totalPrice) ? 0 : totalPrice.toFixed(2)
})
/** 编辑时合同产品回显 */
const isSetListValue = ref(false) // list
watch(
() => props.modelValue,
(val) => {
if (!val || val.length === 0 || isSetListValue.value) {
return
}
list.value = [
...props.modelValue.map((item) => {
item.totalPrice = floatToFixed2(item.totalPrice) as unknown as number
return item
})
]
isSetListValue.value = true
},
{ immediate: true, deep: true }
)
</script>

View File

@ -0,0 +1,119 @@
<!-- 合同详情页面组件-->
<template>
<ContractDetailsHeader v-loading="loading" :contract="contract">
<el-button v-if="permissionListRef?.validateWrite" @click="openForm('update', contract.id)">
编辑
</el-button>
<el-button v-if="permissionListRef?.validateOwnerUser" type="primary" @click="transferContract">
转移
</el-button>
</ContractDetailsHeader>
<el-col>
<el-tabs>
<!-- TODO @puhui999跟进记录 -->
<el-tab-pane label="基本信息">
<ContractDetailsInfo :contract="contract" />
</el-tab-pane>
<!-- TODO @puhui999products 更合适哈 -->
<el-tab-pane label="产品">
<ContractProductList v-model="contract.productItems" />
</el-tab-pane>
<!-- TODO @puhui999回款信息 -->
<!-- TODO @puhui999这里是不是不用 isPool -->
<el-tab-pane label="团队成员">
<PermissionList
ref="permissionListRef"
:biz-id="contract.id!"
:biz-type="BizTypeEnum.CRM_CONTRACT"
:show-action="!permissionListRef?.isPool || false"
@quit-team="close"
/>
</el-tab-pane>
<el-tab-pane label="操作日志">
<OperateLogV2 :log-list="logList" />
</el-tab-pane>
</el-tabs>
</el-col>
<!-- 表单弹窗添加/修改 -->
<ContractForm ref="formRef" @success="getContractData" />
<CrmTransferForm ref="transferFormRef" @success="close" />
</template>
<script lang="ts" setup>
import { useTagsViewStore } from '@/store/modules/tagsView'
import { OperateLogV2VO } from '@/api/system/operatelog'
import * as ContractApi from '@/api/crm/contract'
import ContractDetailsHeader from './ContractDetailsHeader.vue'
import ContractDetailsInfo from './ContractDetailsInfo.vue'
import ContractProductList from './ContractProductList.vue'
import { BizTypeEnum } from '@/api/crm/permission'
import { getOperateLogPage } from '@/api/crm/operateLog'
import ContractForm from '@/views/crm/contract/ContractForm.vue'
import CrmTransferForm from '@/views/crm/permission/components/TransferForm.vue'
import PermissionList from '@/views/crm/permission/components/PermissionList.vue'
defineOptions({ name: 'CrmContractDetail' })
const route = useRoute()
const message = useMessage()
const contractId = ref(0) //
const loading = ref(true) //
const contract = ref<ContractApi.ContractVO>({} as ContractApi.ContractVO) //
const permissionListRef = ref<InstanceType<typeof PermissionList>>() // Ref
/** 编辑 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 获取详情 */
const getContractData = async () => {
loading.value = true
try {
await getOperateLog(contractId.value)
contract.value = await ContractApi.getContract(contractId.value)
} finally {
loading.value = false
}
}
/** 获取操作日志 */
const logList = ref<OperateLogV2VO[]>([]) //
const getOperateLog = async (contractId: number) => {
if (!contractId) {
return
}
const data = await getOperateLogPage({
bizType: BizTypeEnum.CRM_CONTRACT,
bizId: contractId
})
logList.value = data.list
}
/** 转移 */
// TODO @puhui999 title api
const transferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // ref
const transferContract = () => {
transferFormRef.value?.open('合同转移', contract.value.id, ContractApi.transferContract)
}
/** 关闭 */
const { delView } = useTagsViewStore() //
const { currentRoute } = useRouter() //
const close = () => {
delView(unref(currentRoute))
}
/** 初始化 */
onMounted(async () => {
const id = route.params.id
if (!id) {
message.warning('参数错误,合同不能为空!')
close()
return
}
contractId.value = id as unknown as number
await getContractData()
})
</script>

View File

@ -2,116 +2,170 @@
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form <el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef" ref="queryFormRef"
:inline="true" :inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px" label-width="68px"
> >
<el-form-item label="合同编号" prop="no"> <el-form-item label="合同编号" prop="no">
<el-input <el-input
v-model="queryParams.no" v-model="queryParams.no"
placeholder="请输入合同编号"
clearable
@keyup.enter="handleQuery"
class="!w-240px" class="!w-240px"
clearable
placeholder="请输入合同编号"
@keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="合同名称" prop="name"> <el-form-item label="合同名称" prop="name">
<el-input <el-input
v-model="queryParams.name" v-model="queryParams.name"
placeholder="请输入合同名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px" class="!w-240px"
clearable
placeholder="请输入合同名称"
@keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> <el-button @click="handleQuery">
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> <Icon class="mr-5px" icon="ep:search" />
<el-button type="primary" @click="openForm('create')" v-hasPermi="['crm:contract:create']"> 搜索
<Icon icon="ep:plus" class="mr-5px" /> 新增 </el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button v-hasPermi="['crm:contract:create']" type="primary" @click="openForm('create')">
<Icon class="mr-5px" icon="ep:plus" />
新增
</el-button> </el-button>
<el-button <el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['crm:contract:export']" v-hasPermi="['crm:contract:export']"
:loading="exportLoading"
plain
type="success"
@click="handleExport"
> >
<Icon icon="ep:download" class="mr-5px" /> 导出 <Icon class="mr-5px" icon="ep:download" />
导出
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</ContentWrap> </ContentWrap>
<!-- 列表 --> <!-- 列表 -->
<!-- TODO 芋艿各种字段要调整 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column label="合同编号" align="center" prop="id" /> <el-table-column align="center" fixed="left" label="合同编号" prop="no" width="130" />
<el-table-column label="合同名称" align="center" prop="name" /> <el-table-column align="center" label="合同名称" prop="name" width="130" />
<el-table-column label="客户名称" align="center" prop="customerId" /> <el-table-column align="center" label="客户名称" prop="customerName" width="120">
<el-table-column label="商机名称" align="center" prop="businessId" /> <template #default="scope">
<el-table-column label="工作流名称" align="center" prop="processInstanceId" /> <el-link
:underline="false"
type="primary"
@click="openCustomerDetail(scope.row.customerId)"
>
{{ scope.row.customerName }}
</el-link>
</template>
</el-table-column>
<!-- TODO @puhui999做了商机详情后可以把这个超链接加上 -->
<el-table-column align="center" label="商机名称" prop="businessName" width="130" />
<el-table-column <el-table-column
align="center"
label="下单时间" label="下单时间"
align="center"
prop="orderDate" prop="orderDate"
:formatter="dateFormatter" width="120"
width="180px" :formatter="dateFormatter2"
/> />
<el-table-column label="负责人" align="center" prop="ownerUserId" />
<el-table-column label="合同编号" align="center" prop="no" />
<el-table-column <el-table-column
label="开始时间"
align="center" align="center"
label="合同金额"
prop="price"
width="130"
:formatter="fenToYuanFormat"
/>
<el-table-column
align="center"
label="合同开始时间"
prop="startTime" prop="startTime"
:formatter="dateFormatter" width="120"
width="180px" :formatter="dateFormatter2"
/> />
<el-table-column <el-table-column
label="结束时间"
align="center" align="center"
label="合同结束时间"
prop="endTime" prop="endTime"
:formatter="dateFormatter" width="120"
width="180px" :formatter="dateFormatter2"
/> />
<el-table-column label="合同金额" align="center" prop="price" /> <el-table-column align="center" label="客户签约人" prop="contactName" width="130">
<el-table-column label="整单折扣" align="center" prop="discountPercent" /> <template #default="scope">
<el-table-column label="产品总金额" align="center" prop="productPrice" /> <el-link
<el-table-column label="联系人" align="center" prop="contactId" /> :underline="false"
<el-table-column label="公司签约人" align="center" prop="signUserId" /> type="primary"
@click="openContactDetail(scope.row.contactId)"
>
{{ scope.row.contactName }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="公司签约人" prop="signUserName" width="130" />
<el-table-column align="center" label="备注" prop="remark" width="130" />
<!-- TODO @puhui999后续可加 已收款金额未收款金额 -->
<el-table-column align="center" label="负责人" prop="ownerUserName" width="120" />
<el-table-column align="center" label="创建人" prop="creatorName" width="120" />
<el-table-column <el-table-column
label="最后跟进时间" :formatter="dateFormatter"
align="center" align="center"
prop="contactLastTime" label="更新时间"
:formatter="dateFormatter" prop="updateTime"
width="180px" width="180px"
/> />
<el-table-column <el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间" label="创建时间"
align="center"
prop="createTime" prop="createTime"
:formatter="dateFormatter"
width="180px" width="180px"
/> />
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column align="center" fixed="right" label="合同状态" prop="auditStatus" width="120">
<el-table-column label="操作" width="120px"> <template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="250">
<template #default="scope"> <template #default="scope">
<el-button <el-button
v-hasPermi="['crm:contract:update']"
link link
type="primary" type="primary"
@click="openForm('update', scope.row.id)" @click="openForm('update', scope.row.id)"
v-hasPermi="['crm:contract:update']"
> >
编辑 编辑
</el-button> </el-button>
<!-- TODO @puhui999可以加下判断什么情况下可以审批然后加个查看审批按钮 -->
<el-button <el-button
v-hasPermi="['crm:contract:update']"
link
type="primary"
@click="handleSubmit(scope.row)"
>
提交审核
</el-button>
<el-button
v-hasPermi="['crm:contract:query']"
link
type="primary"
@click="openDetail(scope.row.id)"
>
详情
</el-button>
<el-button
v-hasPermi="['crm:contract:delete']"
link link
type="danger" type="danger"
@click="handleDelete(scope.row.id)" @click="handleDelete(scope.row.id)"
v-hasPermi="['crm:contract:delete']"
> >
删除 删除
</el-button> </el-button>
@ -120,9 +174,9 @@
</el-table> </el-table>
<!-- 分页 --> <!-- 分页 -->
<Pagination <Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList" @pagination="getList"
/> />
</ContentWrap> </ContentWrap>
@ -130,11 +184,13 @@
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<ContractForm ref="formRef" @success="getList" /> <ContractForm ref="formRef" @success="getList" />
</template> </template>
<script setup lang="ts"> <script lang="ts" setup>
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import * as ContractApi from '@/api/crm/contract' import * as ContractApi from '@/api/crm/contract'
import ContractForm from './ContractForm.vue' import ContractForm from './ContractForm.vue'
import { fenToYuanFormat } from '@/utils/formatter'
import { DICT_TYPE } from '@/utils/dict'
defineOptions({ name: 'CrmContract' }) defineOptions({ name: 'CrmContract' })
@ -216,6 +272,30 @@ const handleExport = async () => {
} }
} }
/** 提交审核 **/
const handleSubmit = async (row: ContractApi.ContractVO) => {
await message.confirm(`您确定提交【${row.name}】审核吗?`)
await ContractApi.submitContract(row.id)
message.success('提交审核成功!')
await getList()
}
/** 打开合同详情 */
const { push } = useRouter()
const openDetail = (id: number) => {
push({ name: 'CrmContractDetail', params: { id } })
}
/** 打开客户详情 */
const openCustomerDetail = (id: number) => {
push({ name: 'CrmCustomerDetail', params: { id } })
}
/** 打开联系人详情 */
const openContactDetail = (id: number) => {
push({ name: 'CrmContactDetail', params: { id } })
}
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
getList() getList()

View File

@ -0,0 +1,221 @@
<!-- TODO @puhui999这个好像和 detail 重复了能不能复用 detail -->
<template>
<el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="110px">
<el-row>
<el-col :span="24" class="mb-10px">
<CardTitle title="基本信息" />
</el-col>
<el-col :span="12">
<el-form-item label="合同名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入合同名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="合同编号" prop="no">
<el-input v-model="formData.no" placeholder="请输入合同编号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="客户" prop="customerId">
<el-select v-model="formData.customerId">
<el-option
v-for="item in customerList"
:key="item.id"
:label="item.name"
:value="item.id!"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="客户签约人" prop="contactId">
<el-select v-model="formData.contactId" :disabled="!formData.customerId">
<el-option
v-for="item in getContactOptions"
:key="item.id"
:label="item.name"
:value="item.id!"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="公司签约人" prop="signUserId">
<el-select v-model="formData.signUserId">
<el-option
v-for="item in userList"
:key="item.id"
:label="item.nickname"
:value="item.id!"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="负责人" prop="ownerUserId">
<el-select v-model="formData.ownerUserId">
<el-option
v-for="item in userList"
:key="item.id"
:label="item.nickname"
:value="item.id!"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="商机名称" prop="businessId">
<el-select v-model="formData.businessId">
<el-option
v-for="item in businessList"
:key="item.id"
:label="item.name"
:value="item.id!"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="合同金额(元)" prop="price">
<el-input v-model="formData.price" placeholder="请输入合同金额" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="下单日期" prop="orderDate">
<el-date-picker
v-model="formData.orderDate"
placeholder="选择下单日期"
type="date"
value-format="x"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="开始时间" prop="startTime">
<el-date-picker
v-model="formData.startTime"
placeholder="选择开始时间"
type="date"
value-format="x"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="结束时间" prop="endTime">
<el-date-picker
v-model="formData.endTime"
placeholder="选择结束时间"
type="date"
value-format="x"
/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" :rows="3" placeholder="请输入备注" type="textarea" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="产品列表" prop="productList">
<ProductList v-model="formData.productItems" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="整单折扣(%)" prop="discountPercent">
<el-input v-model="formData.discountPercent" placeholder="请输入整单折扣" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="产品总金额(元)" prop="productPrice">
<el-input v-model="formData.productPrice" placeholder="请输入产品总金额" />
</el-form-item>
</el-col>
<el-col :span="24">
<CardTitle class="mb-10px" title="审批信息" />
</el-col>
<el-col :span="12">
<el-button
class="m-20px"
link
type="primary"
@click="BPMLModelRef?.handleBpmnDetail('contract-approve')"
>
查看工作流
</el-button>
</el-col>
</el-row>
</el-form>
<BPMLModel ref="BPMLModelRef" />
</template>
<script lang="ts" setup>
import * as CustomerApi from '@/api/crm/customer'
import * as ContractApi from '@/api/crm/contract'
import * as UserApi from '@/api/system/user'
import * as ContactApi from '@/api/crm/contact'
import * as BusinessApi from '@/api/crm/business'
import ProductList from '@/views/crm/contract/components/ProductList.vue'
import BPMLModel from '@/views/crm/contract/components/BPMLModel.vue'
defineOptions({ name: 'ContractDetailOA' })
const props = defineProps<{ id?: number }>()
const formLoading = ref(false) // 12
const formData = ref<ContractApi.ContractVO>({} as ContractApi.ContractVO)
const formRef = ref() // Ref
const BPMLModelRef = ref<InstanceType<typeof BPMLModel>>()
watch(
() => formData.value.productItems,
(val) => {
if (!val || val.length === 0) {
formData.value.productPrice = 0
return
}
// 使reduce
formData.value.productPrice = val.reduce(
(accumulator, currentValue) =>
isNaN(accumulator + currentValue.totalPrice) ? 0 : accumulator + currentValue.totalPrice,
0
)
},
{ deep: true }
)
/** 打开弹窗 */
const getFormData = async () => {
await getAllApi()
formLoading.value = true
try {
formData.value = await ContractApi.getContract(props.id!)
} finally {
formLoading.value = false
}
}
const getAllApi = async () => {
await Promise.all([getCustomerList(), getUserList(), getContactListList(), getBusinessList()])
}
const customerList = ref<CustomerApi.CustomerVO[]>([])
/** 获取客户 */
const getCustomerList = async () => {
customerList.value = await CustomerApi.getSimpleCustomerList()
}
const contactList = ref<ContactApi.ContactVO[]>([])
/** 动态获取客户联系人 */
const getContactOptions = computed(() =>
contactList.value.filter((item) => item.customerId === formData.value.customerId)
)
const getContactListList = async () => {
contactList.value = await ContactApi.getSimpleContactList()
}
const userList = ref<UserApi.UserVO[]>([])
/** 获取用户列表 */
const getUserList = async () => {
userList.value = await UserApi.getSimpleUserList()
}
const businessList = ref<BusinessApi.BusinessVO[]>([])
/** 获取商机 */
const getBusinessList = async () => {
businessList.value = await BusinessApi.getSimpleBusinessList()
}
onMounted(() => {
getFormData()
})
</script>

View File

@ -0,0 +1,135 @@
<!-- 客户导入窗口 -->
<template>
<Dialog v-model="dialogVisible" title="客户导入" width="400">
<el-upload
ref="uploadRef"
v-model:file-list="fileList"
:action="importUrl + '?updateSupport=' + updateSupport"
:auto-upload="false"
:disabled="formLoading"
:headers="uploadHeaders"
:limit="1"
:on-error="submitFormError"
:on-exceed="handleExceed"
:on-success="submitFormSuccess"
accept=".xlsx, .xls"
drag
>
<Icon icon="ep:upload" />
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<template #tip>
<div class="el-upload__tip text-center">
<div class="el-upload__tip">
<el-checkbox v-model="updateSupport" />
是否更新已经存在的客户数据客户名称重复
</div>
<span>仅允许导入 xlsxlsx 格式文件</span>
<el-link
:underline="false"
style="font-size: 12px; vertical-align: baseline"
type="primary"
@click="importTemplate"
>
下载模板
</el-link>
</div>
</template>
</el-upload>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import * as CustomerApi from '@/api/crm/customer'
import { getAccessToken, getTenantId } from '@/utils/auth'
import download from '@/utils/download'
defineOptions({ name: 'SystemUserImportForm' })
const message = useMessage() //
const dialogVisible = ref(false) //
const formLoading = ref(false) //
const uploadRef = ref()
const importUrl =
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/crm/customer/import'
const uploadHeaders = ref() // Header
const fileList = ref([]) //
const updateSupport = ref(0) //
/** 打开弹窗 */
const open = () => {
dialogVisible.value = true
fileList.value = []
resetForm()
}
defineExpose({ open }) // open
/** 提交表单 */
const submitForm = async () => {
if (fileList.value.length == 0) {
message.error('请上传文件')
return
}
//
uploadHeaders.value = {
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
}
formLoading.value = true
uploadRef.value!.submit()
}
/** 文件上传成功 */
const emits = defineEmits(['success'])
const submitFormSuccess = (response: any) => {
if (response.code !== 0) {
message.error(response.msg)
formLoading.value = false
return
}
//
const data = response.data
let text = '上传成功数量:' + data.createCustomerNames.length + ';'
for (let customerName of data.createCustomerNames) {
text += '< ' + customerName + ' >'
}
text += '更新成功数量:' + data.updateCustomerNames.length + ';'
for (const customerName of data.updateCustomerNames) {
text += '< ' + customerName + ' >'
}
text += '更新失败数量:' + Object.keys(data.failureCustomerNames).length + ';'
for (const customerName in data.failureCustomerNames) {
text += '< ' + customerName + ': ' + data.failureCustomerNames[customerName] + ' >'
}
message.alert(text)
//
emits('success')
}
/** 上传错误提示 */
const submitFormError = (): void => {
message.error('上传失败,请您重新上传!')
formLoading.value = false
}
/** 重置表单 */
const resetForm = () => {
//
formLoading.value = false
uploadRef.value?.clearFiles()
}
/** 文件数超出提示 */
const handleExceed = (): void => {
message.error('最多只能上传一个文件!')
}
/** 下载模板操作 */
const importTemplate = async () => {
const res = await CustomerApi.importCustomerTemplate()
download.excel(res, '客户导入模版.xls')
}
</script>

View File

@ -91,6 +91,7 @@ import CrmTransferForm from '@/views/crm/permission/components/TransferForm.vue'
import FollowUpList from '@/views/crm/followup/index.vue' import FollowUpList from '@/views/crm/followup/index.vue'
import { BizTypeEnum } from '@/api/crm/permission' import { BizTypeEnum } from '@/api/crm/permission'
import type { OperateLogV2VO } from '@/api/system/operatelog' import type { OperateLogV2VO } from '@/api/system/operatelog'
import { getOperateLogPage } from '@/api/crm/operateLog'
defineOptions({ name: 'CrmCustomerDetail' }) defineOptions({ name: 'CrmCustomerDetail' })
@ -123,7 +124,7 @@ const openForm = () => {
/** 客户转移 */ /** 客户转移 */
const crmTransferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // ref const crmTransferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // ref
const transfer = () => { const transfer = () => {
crmTransferFormRef.value?.open('客户转移', customerId.value, CustomerApi.transfer) crmTransferFormRef.value?.open('客户转移', customerId.value, CustomerApi.transferCustomer)
} }
/** 锁定客户 */ /** 锁定客户 */
@ -164,7 +165,10 @@ const getOperateLog = async () => {
if (!customerId.value) { if (!customerId.value) {
return return
} }
const data = await CustomerApi.getOperateLogPage(customerId.value) const data = await getOperateLogPage({
bizType: BizTypeEnum.CRM_CUSTOMER,
bizId: customerId.value
})
logList.value = data.list logList.value = data.list
} }

View File

@ -84,6 +84,10 @@
<Icon class="mr-5px" icon="ep:plus" /> <Icon class="mr-5px" icon="ep:plus" />
新增 新增
</el-button> </el-button>
<el-button v-hasPermi="['crm:customer:import']" plain type="warning" @click="handleImport">
<Icon icon="ep:upload" />
导入
</el-button>
<el-button <el-button
v-hasPermi="['crm:customer:export']" v-hasPermi="['crm:customer:export']"
:loading="exportLoading" :loading="exportLoading"
@ -204,6 +208,7 @@
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<CustomerForm ref="formRef" @success="getList" /> <CustomerForm ref="formRef" @success="getList" />
<CustomerImportForm ref="importFormRef" @success="getList" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -212,6 +217,7 @@ import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import * as CustomerApi from '@/api/crm/customer' import * as CustomerApi from '@/api/crm/customer'
import CustomerForm from './CustomerForm.vue' import CustomerForm from './CustomerForm.vue'
import CustomerImportForm from './CustomerImportForm.vue'
import { TabsPaneContext } from 'element-plus' import { TabsPaneContext } from 'element-plus'
defineOptions({ name: 'CrmCustomer' }) defineOptions({ name: 'CrmCustomer' })
@ -334,6 +340,12 @@ const handleDelete = async (id: number) => {
} catch {} } catch {}
} }
/** 导入按钮操作 */
const importFormRef = ref<InstanceType<typeof CustomerImportForm>>()
const handleImport = () => {
importFormRef.value?.open()
}
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = async () => { const handleExport = async () => {
try { try {

View File

@ -1,5 +1,5 @@
<template> <template>
<ProductDetailsHeader :product="product" :loading="loading" @refresh="getProductData(id)" /> <ProductDetailsHeader :loading="loading" :product="product" @refresh="getProductData(id)" />
<el-col> <el-col>
<el-tabs> <el-tabs>
<el-tab-pane label="详细资料"> <el-tab-pane label="详细资料">
@ -11,16 +11,19 @@
</el-tabs> </el-tabs>
</el-col> </el-col>
</template> </template>
<script setup lang="ts"> <script lang="ts" setup>
import { useTagsViewStore } from '@/store/modules/tagsView' import { useTagsViewStore } from '@/store/modules/tagsView'
import { OperateLogV2VO } from '@/api/system/operatelog' import { OperateLogV2VO } from '@/api/system/operatelog'
import * as ProductApi from '@/api/crm/product' import * as ProductApi from '@/api/crm/product'
import ProductDetailsHeader from '@/views/crm/product/detail/ProductDetailsHeader.vue' import ProductDetailsHeader from '@/views/crm/product/detail/ProductDetailsHeader.vue'
import ProductDetailsInfo from '@/views/crm/product/detail/ProductDetailsInfo.vue' import ProductDetailsInfo from '@/views/crm/product/detail/ProductDetailsInfo.vue'
import { BizTypeEnum } from '@/api/crm/permission'
import { getOperateLogPage } from '@/api/crm/operateLog'
defineOptions({ name: 'CrmProductDetail' }) defineOptions({ name: 'CrmProductDetail' })
const route = useRoute() const route = useRoute()
const message = useMessage()
const id = Number(route.params.id) // const id = Number(route.params.id) //
const loading = ref(true) // const loading = ref(true) //
const product = ref<ProductApi.ProductVO>({} as ProductApi.ProductVO) // const product = ref<ProductApi.ProductVO>({} as ProductApi.ProductVO) //
@ -42,7 +45,8 @@ const getOperateLog = async (productId: number) => {
if (!productId) { if (!productId) {
return return
} }
const data = await ProductApi.getOperateLogPage({ const data = await getOperateLogPage({
bizType: BizTypeEnum.CRM_PRODUCT,
bizId: productId bizId: productId
}) })
logList.value = data.list logList.value = data.list
@ -53,7 +57,7 @@ const { delView } = useTagsViewStore() // 视图操作
const { currentRoute } = useRouter() // const { currentRoute } = useRouter() //
onMounted(async () => { onMounted(async () => {
if (!id) { if (!id) {
ElMessage.warning('参数错误,产品不能为空!') message.warning('参数错误,产品不能为空!')
delView(unref(currentRoute)) delView(unref(currentRoute))
return return
} }

View File

@ -61,6 +61,7 @@ const updateSupport = ref(0) // 是否更新已经存在的用户数据
/** 打开弹窗 */ /** 打开弹窗 */
const open = () => { const open = () => {
dialogVisible.value = true dialogVisible.value = true
fileList.value = []
resetForm() resetForm()
} }
defineExpose({ open }) // open defineExpose({ open }) // open