<template>
|
<view class="sales-account">
|
<!-- 通用头部 -->
|
<PageHeader title="商机管理" @back="goBack" />
|
|
<!-- 搜索区域 -->
|
<view class="search-section">
|
<view class="search-bar">
|
<view class="search-input">
|
<up-input
|
class="search-text"
|
placeholder="请输入客户名称搜索"
|
v-model="customerName"
|
@change="getList"
|
clearable
|
/>
|
</view>
|
<view class="filter-button" @click="getList">
|
<up-icon name="search" size="24" color="#999"></up-icon>
|
</view>
|
</view>
|
</view>
|
|
<!-- 商机列表 -->
|
<view class="ledger-list" v-if="opportunityList.length > 0">
|
<view v-for="(item, index) in opportunityList" :key="item.id || index">
|
<view class="ledger-item" @click="openOpportunity('detail', item)">
|
<view class="item-header">
|
<view class="item-left">
|
<view class="document-icon">
|
<up-icon name="file-text" size="16" color="#ffffff"></up-icon>
|
</view>
|
<text class="item-id">{{ item.customerName || '-' }}</text>
|
</view>
|
<view class="item-right">
|
<u-tag
|
size="mini"
|
:type="getStatusTagType(item.status)"
|
>
|
{{ getStatusText(item.status) }}
|
</u-tag>
|
</view>
|
</view>
|
<up-divider></up-divider>
|
|
<view class="item-details">
|
<view class="detail-row">
|
<text class="detail-label">城市</text>
|
<text class="detail-value">{{ item.city || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">商机来源</text>
|
<text class="detail-value">{{ item.businessSource || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">合同金额(元)</text>
|
<text class="detail-value highlight">{{ item.contractAmount || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">录入人</text>
|
<text class="detail-value">{{ item.entryPerson || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">更新时间</text>
|
<text class="detail-value">
|
{{ formatDate(item.updateTime || item.entryDate) || '-' }}
|
</text>
|
</view>
|
</view>
|
|
<!-- 操作按钮 -->
|
<view class="action-buttons">
|
<u-button
|
type="primary"
|
size="small"
|
class="action-btn"
|
@click.stop="openOpportunity('edit', item)"
|
>
|
编辑
|
</u-button>
|
<u-button
|
type="warning"
|
size="small"
|
class="action-btn"
|
@click.stop="openOpportunity('addOperation', item)"
|
>
|
添加拜访记录
|
</u-button>
|
<u-button
|
type="default"
|
size="small"
|
class="action-btn"
|
@click.stop="openOpportunity('detail', item)"
|
>
|
详情
|
</u-button>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view v-else class="no-data">
|
<text>暂无商机数据</text>
|
</view>
|
|
<!-- 浮动新增按钮 -->
|
<view class="fab-button" @click="addOpportunity">
|
<up-icon name="plus" size="24" color="#ffffff"></up-icon>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref } from 'vue'
|
import { onShow } from '@dcloudio/uni-app'
|
import dayjs from 'dayjs'
|
import PageHeader from '@/components/PageHeader.vue'
|
import { opportunityListPage } from '@/api/salesManagement/opportunityManagement.js'
|
|
// 搜索条件
|
const customerName = ref('')
|
|
// 列表数据
|
const opportunityList = ref([])
|
const total = ref(0)
|
|
// 返回
|
const goBack = () => {
|
uni.navigateBack()
|
}
|
|
// 加载中提示
|
const showLoadingToast = (message) => {
|
uni.showLoading({
|
title: message,
|
mask: true
|
})
|
}
|
|
const closeToast = () => {
|
uni.hideLoading()
|
}
|
|
// 状态标签类型
|
const getStatusTagType = (status) => {
|
const typeMap = {
|
'新建': 'info',
|
'项目跟踪': 'primary',
|
'放弃': 'error',
|
'合同签约': 'warning',
|
'备案申报': 'primary',
|
'项目交付': 'success',
|
'项目验收': 'success',
|
'项目回款': 'success',
|
'回补贴': 'success'
|
}
|
return typeMap[status] || 'default'
|
}
|
|
// 状态文本
|
const getStatusText = (status) => {
|
const textMap = {
|
'新建': '新建',
|
'项目跟踪': '项目跟踪',
|
'放弃': '放弃',
|
'合同签约': '合同签约',
|
'备案申报': '备案申报',
|
'项目交付': '项目交付',
|
'项目验收': '项目验收',
|
'项目回款': '项目回款',
|
'回补贴': '回补贴'
|
}
|
return textMap[status] || '未知'
|
}
|
|
// 格式化日期
|
const formatDate = (date) => {
|
if (!date) return ''
|
return dayjs(date).format('YYYY-MM-DD')
|
}
|
|
// 获取列表
|
const getList = () => {
|
showLoadingToast('加载中...')
|
const params = {
|
current: -1,
|
size: -1,
|
customerName: customerName.value || undefined
|
}
|
|
opportunityListPage(params)
|
.then((res) => {
|
const data = res.data || res
|
opportunityList.value = data.records || []
|
total.value = data.total || 0
|
})
|
.catch(() => {
|
uni.showToast({
|
title: '获取商机数据失败',
|
icon: 'none'
|
})
|
opportunityList.value = []
|
total.value = 0
|
})
|
.finally(() => {
|
closeToast()
|
})
|
}
|
|
// 打开商机操作页面(新增、编辑、详情、添加描述)
|
const openOpportunity = (type, row) => {
|
console.log('openOpportunity called with type:', type, 'row:', row)
|
try {
|
uni.setStorageSync('opportunityOperationType', type)
|
if (row) {
|
uni.setStorageSync('opportunityData', JSON.stringify(row))
|
} else {
|
uni.removeStorageSync('opportunityData')
|
}
|
uni.navigateTo({
|
url: '/pages/opportunityManagement/detail'
|
})
|
} catch (error) {
|
console.error('打开商机页面失败:', error)
|
uni.showToast({
|
title: '操作失败,请重试',
|
icon: 'none'
|
})
|
}
|
}
|
|
// 新建商机
|
const addOpportunity = () => {
|
openOpportunity('add')
|
}
|
|
onShow(() => {
|
getList()
|
})
|
</script>
|
|
<style scoped lang="scss">
|
@import '@/styles/sales-common.scss';
|
</style>
|