no commit message
This commit is contained in:
@@ -59,7 +59,9 @@ class Base extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function isAdmin()
|
public function isAdmin()
|
||||||
{
|
{
|
||||||
return in_array("Biz_system_admin", $this->userInfo['roleCode']);
|
return in_array("Biz_system_admin", $this->userInfo['roleCode']) ||
|
||||||
|
in_array("admin", $this->userInfo['roleCode']) ||
|
||||||
|
in_array("COM_TOP_ADMIN", $this->userInfo['roleCode']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ class Estimate extends Base
|
|||||||
// }
|
// }
|
||||||
$where[] = ['i.is_simple', '=', 0];
|
$where[] = ['i.is_simple', '=', 0];
|
||||||
$where[] = ['i.estimate_status', '=', $estimate_status];
|
$where[] = ['i.estimate_status', '=', $estimate_status];
|
||||||
|
$where[] = ['i.status', 'in', [9, 10, 11, 12]];
|
||||||
$start_time && $where[] = ['i.create_time', '>=', $start_time . " 00:00:00"];
|
$start_time && $where[] = ['i.create_time', '>=', $start_time . " 00:00:00"];
|
||||||
$end_time && $where[] = ['i.create_time', '<=', $end_time . " 23:59:59"];
|
$end_time && $where[] = ['i.create_time', '<=', $end_time . " 23:59:59"];
|
||||||
$is_multiple && $where[] = ['i.is_multiple', '=', $is_multiple];
|
$is_multiple && $where[] = ['i.is_multiple', '=', $is_multiple];
|
||||||
@@ -540,6 +541,10 @@ class Estimate extends Base
|
|||||||
if (!$in_upd) {
|
if (!$in_upd) {
|
||||||
return $this->buildFailed('操作失败!');
|
return $this->buildFailed('操作失败!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 推送预估数量更新给所有客户端
|
||||||
|
fetchAndPushEstimatePendingCount();
|
||||||
|
|
||||||
return $this->buildSuccess();
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,56 @@ class Pending extends Base
|
|||||||
return $this->buildSuccess(['count' => $count]);
|
return $this->buildSuccess(['count' => $count]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报告制作数量(status=9)
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function getReportPendingCount()
|
||||||
|
{
|
||||||
|
$Inquiry = new Inquiry();
|
||||||
|
|
||||||
|
// 查询 status = 9 的数量
|
||||||
|
$count = $Inquiry->where('status', 9)->count();
|
||||||
|
|
||||||
|
return $this->buildSuccess(['count' => $count]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有预估状态数量
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function getEstimatePendingCount()
|
||||||
|
{
|
||||||
|
$Inquiry = new Inquiry();
|
||||||
|
|
||||||
|
// 待制作:status=9
|
||||||
|
$pendingCount = $Inquiry->where('status', 9)->count();
|
||||||
|
|
||||||
|
// 二审待制作:status=10 且 estimate_status=2
|
||||||
|
$secondReviewCount = $Inquiry->where('status', 10)
|
||||||
|
->where('estimate_status', '=', '2', false)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
// 三审待制作:status=10 且 estimate_status=3
|
||||||
|
$thirdReviewCount = $Inquiry->where('status', 10)
|
||||||
|
->where('estimate_status', '=', '3', false)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
// 待签章:status=11
|
||||||
|
$signCount = $Inquiry->where('status', 11)->count();
|
||||||
|
|
||||||
|
// 总和
|
||||||
|
$total = $pendingCount + $secondReviewCount + $thirdReviewCount + $signCount;
|
||||||
|
|
||||||
|
return $this->buildSuccess([
|
||||||
|
'pending' => $pendingCount,
|
||||||
|
'secondReview' => $secondReviewCount,
|
||||||
|
'thirdReview' => $thirdReviewCount,
|
||||||
|
'sign' => $signCount,
|
||||||
|
'total' => $total
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
//询价编号前缀 - 住宅
|
//询价编号前缀 - 住宅
|
||||||
const INQUERY_NUMBER_RESIDENCE_PREFIX = "GZ01";
|
const INQUERY_NUMBER_RESIDENCE_PREFIX = "GZ01";
|
||||||
|
|
||||||
@@ -3687,6 +3737,9 @@ class Pending extends Base
|
|||||||
return $this->buildFailed("确认回价失败");
|
return $this->buildFailed("确认回价失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 推送预估数量更新到前端
|
||||||
|
fetchAndPushEstimatePendingCount();
|
||||||
|
|
||||||
return $this->buildSuccess();
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,15 @@ class Property_cert_info extends Base
|
|||||||
if ($result['code'] == -1) {
|
if ($result['code'] == -1) {
|
||||||
return $this->buildFailed($result['msg']);
|
return $this->buildFailed($result['msg']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 发起查勘成功后,推送查勘跟进中数量更新
|
||||||
|
error_log("=== reqApplySurvey 推送调试 ===");
|
||||||
|
error_log("用户ID: " . $this->userInfo['user_id']);
|
||||||
|
error_log("是否管理员: " . ($this->isAdmin() ? 'true' : 'false'));
|
||||||
|
|
||||||
|
$pushResult = fetchAndPushSurveyFollowCount($this->userInfo['user_id'], $this->isAdmin());
|
||||||
|
error_log("推送结果: " . ($pushResult ? '成功' : '失败'));
|
||||||
|
|
||||||
return $this->buildSuccess('发起查勘成功');
|
return $this->buildSuccess('发起查勘成功');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2848,6 +2848,55 @@ EOF;
|
|||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报告制作数量统计
|
||||||
|
* @return \think\response\Json
|
||||||
|
*/
|
||||||
|
public function getReportProduceCount() {
|
||||||
|
$pendingCount = Db::name('report')
|
||||||
|
->alias('r')
|
||||||
|
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
|
||||||
|
->where('r.report_source', 1)
|
||||||
|
->where('r.status', 1)
|
||||||
|
->where('r.create_time', 'gt', '2025-02-01 00:00:00');
|
||||||
|
$pending = $pendingCount->count();
|
||||||
|
|
||||||
|
// 二审待制作:以 pg_report 为主表,review_status=1 且 status=2,关联 pg_inquiry
|
||||||
|
$secondReviewCount = Db::name('report')
|
||||||
|
->alias('r')
|
||||||
|
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
|
||||||
|
->where('r.report_source', 1)
|
||||||
|
->where('r.review_status', 1)
|
||||||
|
->where('r.status', 2)
|
||||||
|
->where('r.create_time', 'gt', '2025-02-01 00:00:00')
|
||||||
|
->where('i.status', 7)
|
||||||
|
->group('r.quot_id');
|
||||||
|
|
||||||
|
$secondReview = $secondReviewCount->count();
|
||||||
|
|
||||||
|
// 三审待制作:以 pg_report 为主表,review_status=2 且 review2_status=1 且 status=2,关联 pg_inquiry
|
||||||
|
$thirdReviewCount = Db::name('report')
|
||||||
|
->alias('r')
|
||||||
|
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
|
||||||
|
->where('r.report_source', 1)
|
||||||
|
->where('r.review_status', 2)
|
||||||
|
->where('r.review2_status', 1)
|
||||||
|
->where('r.create_time', 'gt', '2025-02-01 00:00:00')
|
||||||
|
->where('r.status', 2);
|
||||||
|
|
||||||
|
$thirdReview = $thirdReviewCount->count();
|
||||||
|
|
||||||
|
// 计算总数
|
||||||
|
$total = $pending + $secondReview + $thirdReview;
|
||||||
|
|
||||||
|
return $this->buildSuccess([
|
||||||
|
'pending' => $pending,
|
||||||
|
'secondReview' => $secondReview,
|
||||||
|
'thirdReview' => $thirdReview,
|
||||||
|
'total' => $total
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function cancelAntiCounterfeitCode()
|
public function cancelAntiCounterfeitCode()
|
||||||
{
|
{
|
||||||
$reportid = $this->request->post("reportid");
|
$reportid = $this->request->post("reportid");
|
||||||
|
|||||||
@@ -561,9 +561,29 @@ class Survey extends Base
|
|||||||
if (is_array($list)) {
|
if (is_array($list)) {
|
||||||
$refer = array();
|
$refer = array();
|
||||||
foreach ($list as $key => $data) {
|
foreach ($list as $key => $data) {
|
||||||
|
// 跳过空数据或非数组数据
|
||||||
|
if (!is_array($data) || empty($data)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 确保主键字段存在
|
||||||
|
if (!isset($data[$pk])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$refer[$data[$pk]] = &$list[$key];
|
$refer[$data[$pk]] = &$list[$key];
|
||||||
}
|
}
|
||||||
foreach ($list as $key => $data) {
|
foreach ($list as $key => $data) {
|
||||||
|
// 跳过空数据或非数组数据
|
||||||
|
if (!is_array($data) || empty($data)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 确保父ID字段存在
|
||||||
|
if (!isset($data[$pid])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 确保code字段存在
|
||||||
|
if (!isset($data['code'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$parentId = $data[$pid];
|
$parentId = $data[$pid];
|
||||||
if ($root == $parentId) {
|
if ($root == $parentId) {
|
||||||
$tree[$data['code']] = &$list[$key];
|
$tree[$data['code']] = &$list[$key];
|
||||||
@@ -759,4 +779,53 @@ class Survey extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取查勘跟进中数量(当前登录人)
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function surveyFollowCount()
|
||||||
|
{
|
||||||
|
// 检查用户信息
|
||||||
|
if (empty($this->userInfo)) {
|
||||||
|
error_log("surveyFollowCount: userInfo is empty");
|
||||||
|
return $this->buildFailed('用户信息不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查用户ID
|
||||||
|
if (!isset($this->userInfo['user_id'])) {
|
||||||
|
error_log("surveyFollowCount: user_id is not set");
|
||||||
|
return $this->buildFailed('用户ID不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
$Survey = new SurveyModel();
|
||||||
|
|
||||||
|
// 如果是管理员(admin 或 COM_TOP_ADMIN),不限制 user_id
|
||||||
|
if ($this->isAdmin()) {
|
||||||
|
$count = $Survey->alias('s')
|
||||||
|
->join('pg_inquiry i', 's.order_no = i.order_no', 'INNER')
|
||||||
|
->where('i.status', 4)
|
||||||
|
->where('s.status', 2)
|
||||||
|
->where('s.assign_time', 'gt', '2025-02-01 00:00:00')
|
||||||
|
->group('s.id')
|
||||||
|
->count();
|
||||||
|
} else {
|
||||||
|
// 非管理员,只统计当前用户的查勘
|
||||||
|
$userId = $this->userInfo['user_id'];
|
||||||
|
$count = $Survey->alias('s')
|
||||||
|
->join('pg_inquiry i', 's.order_no = i.order_no', 'INNER')
|
||||||
|
->where('i.status', 4)
|
||||||
|
->where('s.status', 2)
|
||||||
|
->where('s.user_id', $userId)
|
||||||
|
->where('s.assign_time', 'gt', '2025-02-01 00:00:00')
|
||||||
|
->group('s.id')
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log("surveyFollowCount: count = $count, userId = " . $this->userInfo['user_id'] . ", isAdmin = " . ($this->isAdmin() ? 'true' : 'false'));
|
||||||
|
|
||||||
|
return $this->buildSuccess([
|
||||||
|
'count' => $count
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ class SurveyService extends CommonService
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新订单状态:查勘待派单
|
//更新订单状态:查勘待派单
|
||||||
if (!Db::name('inquiry')->where(['order_no' => $data['order_no']])->update(['status'=>4, 'update_time' => new \DateTime])) {
|
if (!Db::name('inquiry')->where(['order_no' => $data['order_no']])->update(['status'=>4, 'update_time' => date('Y-m-d H:i:s')])) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
return ['code'=>-1, 'msg'=>'更新订单状态失败'];
|
return ['code'=>-1, 'msg'=>'更新订单状态失败'];
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ class SurveyService extends CommonService
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新订单状态:查勘待派单
|
//更新订单状态:查勘待派单
|
||||||
if (!Db::name('inquiry')->where(['order_no' => $data['order_no']])->update(['status'=>4, 'update_time' => new \DateTime])) {
|
if (!Db::name('inquiry')->where(['order_no' => $data['order_no']])->update(['status'=>4, 'update_time' => date('Y-m-d H:i:s')])) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
return ['code'=>-1, 'msg'=>'更新订单状态失败'];
|
return ['code'=>-1, 'msg'=>'更新订单状态失败'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1650,6 +1650,11 @@ function pushToAllClients($eventName, $data) {
|
|||||||
'data' => json_encode($data)
|
'data' => json_encode($data)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
error_log("=== 推送调试 ===");
|
||||||
|
error_log("目标地址: $socketUrl");
|
||||||
|
error_log("事件名称: $eventName");
|
||||||
|
error_log("推送数据: " . json_encode($data));
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
'http' => [
|
'http' => [
|
||||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||||
@@ -1660,9 +1665,11 @@ function pushToAllClients($eventName, $data) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
$result = file_get_contents($socketUrl, false, $context);
|
$result = @file_get_contents($socketUrl, false, $context);
|
||||||
|
|
||||||
writeLog("Push result - event: $eventName, data: " . json_encode($data) . ", result: '$result'", 'push_log');
|
error_log("推送结果: '" . ($result !== false ? $result : 'false') . "'");
|
||||||
|
|
||||||
|
writeLog("Push result - event: $eventName, data: " . json_encode($data) . ", result: '" . ($result !== false ? $result : 'false') . "'", 'push_log');
|
||||||
|
|
||||||
return $result === 'ok';
|
return $result === 'ok';
|
||||||
}
|
}
|
||||||
@@ -1694,5 +1701,187 @@ function fetchAndPushUnreturnedPriceCount() {
|
|||||||
return pushUnreturnedPriceCount($count);
|
return pushUnreturnedPriceCount($count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送预估数量更新
|
||||||
|
* @param array $counts 预估数量数组
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function pushEstimatePendingCount($counts) {
|
||||||
|
return pushToAllClients('updateEstimatePendingCount', $counts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预估数量
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function getEstimatePendingCount() {
|
||||||
|
$Inquiry = new \app\model\Inquiry();
|
||||||
|
|
||||||
|
// 待制作:status=9
|
||||||
|
$pendingCount = $Inquiry->where('status', 9)->count();
|
||||||
|
|
||||||
|
// 二审待制作:status=10 且 estimate_status=2(兼容字符串和数字类型)
|
||||||
|
$secondReviewCount = $Inquiry->where('status', 10)
|
||||||
|
->where('estimate_status', '=', '2', false)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
// 三审待制作:status=10 且 estimate_status=3(兼容字符串和数字类型)
|
||||||
|
$thirdReviewCount = $Inquiry->where('status', 10)
|
||||||
|
->where('estimate_status', '=', '3', false)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
// 待签章:status=11
|
||||||
|
$signCount = $Inquiry->where('status', 11)->count();
|
||||||
|
|
||||||
|
// 总和
|
||||||
|
$total = $pendingCount + $secondReviewCount + $thirdReviewCount + $signCount;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'pending' => $pendingCount,
|
||||||
|
'secondReview' => $secondReviewCount,
|
||||||
|
'thirdReview' => $thirdReviewCount,
|
||||||
|
'sign' => $signCount,
|
||||||
|
'total' => $total
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预估数量并推送给所有客户端
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function fetchAndPushEstimatePendingCount() {
|
||||||
|
$counts = getEstimatePendingCount();
|
||||||
|
return pushEstimatePendingCount($counts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送查勘跟进中数量更新(推送刷新事件,让客户端主动获取自己的数量)
|
||||||
|
* @param int $count 查勘跟进中数量(当前用户的数量,用于发起者立即显示)
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function pushSurveyFollowCount($count) {
|
||||||
|
// 推送刷新事件,让所有客户端重新获取自己的查勘数量
|
||||||
|
return pushToAllClients('updateSurveyFollowCount', ['refresh' => true, 'count' => $count]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送报告制作数量更新
|
||||||
|
* @param array $counts 报告制作数量数组
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function pushReportProduceCount($counts) {
|
||||||
|
// 推送刷新事件,让所有客户端重新获取自己的报告制作数量
|
||||||
|
return pushToAllClients('updateReportProduceCount', ['refresh' => true, 'counts' => $counts]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报告制作数量并推送给所有客户端
|
||||||
|
* @param int $userId 用户ID
|
||||||
|
* @param bool $isAdmin 是否管理员
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function fetchAndPushReportProduceCount($userId, $isAdmin = false) {
|
||||||
|
$pendingCount = Db::name('report')
|
||||||
|
->alias('r')
|
||||||
|
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
|
||||||
|
->where('r.report_source', 1)
|
||||||
|
->where('r.status', 1)
|
||||||
|
->where('r.create_time', 'gt', '2025-02-01 00:00:00');
|
||||||
|
$pending = $pendingCount->count();
|
||||||
|
|
||||||
|
// 二审待制作:以 pg_report 为主表,review_status=1 且 status=2,关联 pg_inquiry
|
||||||
|
$secondReviewCount = Db::name('report')
|
||||||
|
->alias('r')
|
||||||
|
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
|
||||||
|
->where('r.report_source', 1)
|
||||||
|
->where('r.review_status', 1)
|
||||||
|
->where('r.status', 2)
|
||||||
|
->where('r.create_time', 'gt', '2025-02-01 00:00:00')
|
||||||
|
->where('i.status', 7)
|
||||||
|
->group('r.quot_id');
|
||||||
|
|
||||||
|
$secondReview = $secondReviewCount->count();
|
||||||
|
|
||||||
|
// 三审待制作:以 pg_report 为主表,review_status=2 且 review2_status=1 且 status=2,关联 pg_inquiry
|
||||||
|
$thirdReviewCount = Db::name('report')
|
||||||
|
->alias('r')
|
||||||
|
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
|
||||||
|
->where('r.report_source', 1)
|
||||||
|
->where('r.review_status', 2)
|
||||||
|
->where('r.review2_status', 1)
|
||||||
|
->where('r.create_time', 'gt', '2025-02-01 00:00:00')
|
||||||
|
->where('r.status', 2);
|
||||||
|
|
||||||
|
$thirdReview = $thirdReviewCount->count();
|
||||||
|
|
||||||
|
// 计算总数
|
||||||
|
$total = $pending + $secondReview + $thirdReview;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'pending' => $pending,
|
||||||
|
'secondReview' => $secondReview,
|
||||||
|
'thirdReview' => $thirdReview,
|
||||||
|
'total' => $total
|
||||||
|
];
|
||||||
|
|
||||||
|
error_log("查询到的报告制作数量: " . json_encode($counts));
|
||||||
|
|
||||||
|
$pushResult = pushReportProduceCount($counts);
|
||||||
|
error_log("推送结果: " . ($pushResult ? '成功' : '失败'));
|
||||||
|
|
||||||
|
return $pushResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取查勘跟进中数量(当前登录人)
|
||||||
|
* @param int $userId 用户ID
|
||||||
|
* @param bool $isAdmin 是否管理员
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function getSurveyFollowCount($userId, $isAdmin = false) {
|
||||||
|
$Survey = new \app\model\Survey();
|
||||||
|
|
||||||
|
// 如果是管理员,不限制 user_id
|
||||||
|
if ($isAdmin) {
|
||||||
|
$count = $Survey->alias('s')
|
||||||
|
->join('pg_inquiry i', 's.order_no = i.order_no', 'INNER')
|
||||||
|
->where('i.status', 4)
|
||||||
|
->where('s.status', 2)
|
||||||
|
->where('s.assign_time', 'gt', '2025-02-01 00:00:00')
|
||||||
|
->count();
|
||||||
|
} else {
|
||||||
|
// 非管理员,只统计当前用户的查勘
|
||||||
|
$count = $Survey->alias('s')
|
||||||
|
->join('pg_inquiry i', 's.order_no = i.order_no', 'INNER')
|
||||||
|
->where('i.status', 4)
|
||||||
|
->where('s.status', 2)
|
||||||
|
->where('s.user_id', $userId)
|
||||||
|
->where('s.assign_time', 'gt', '2025-02-01 00:00:00')
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取查勘跟进中数量并推送给所有客户端
|
||||||
|
* @param int $userId 用户ID
|
||||||
|
* @param bool $isAdmin 是否管理员
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function fetchAndPushSurveyFollowCount($userId, $isAdmin = false) {
|
||||||
|
error_log("=== fetchAndPushSurveyFollowCount 调试 ===");
|
||||||
|
error_log("用户ID: $userId");
|
||||||
|
error_log("是否管理员: " . ($isAdmin ? 'true' : 'false'));
|
||||||
|
|
||||||
|
$count = getSurveyFollowCount($userId, $isAdmin);
|
||||||
|
error_log("查询到的查勘数量: $count");
|
||||||
|
|
||||||
|
$pushResult = pushSurveyFollowCount($count);
|
||||||
|
error_log("推送结果: " . ($pushResult ? '成功' : '失败'));
|
||||||
|
|
||||||
|
return $pushResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$GLOBALS['console'] = '';
|
$GLOBALS['console'] = '';
|
||||||
|
|||||||
@@ -69,10 +69,19 @@ class Survey extends Base
|
|||||||
->order('id desc')
|
->order('id desc')
|
||||||
->field('eva_unit_price,eva_total_value,eva_net_value,eva_net_value2')
|
->field('eva_unit_price,eva_total_value,eva_net_value,eva_net_value2')
|
||||||
->find();
|
->find();
|
||||||
$item['eva_unit_price'] = $return_price_info['eva_unit_price'];
|
// 检查是否找到数据
|
||||||
$item['eva_total_value'] = $return_price_info['eva_total_value'];
|
if ($return_price_info) {
|
||||||
$item['eva_net_value'] = $return_price_info['eva_net_value'];
|
$item['eva_unit_price'] = $return_price_info['eva_unit_price'];
|
||||||
$item['eva_net_value2'] = $return_price_info['eva_net_value2'];
|
$item['eva_total_value'] = $return_price_info['eva_total_value'];
|
||||||
|
$item['eva_net_value'] = $return_price_info['eva_net_value'];
|
||||||
|
$item['eva_net_value2'] = $return_price_info['eva_net_value2'];
|
||||||
|
} else {
|
||||||
|
// 如果没有找到数据,设置默认值
|
||||||
|
$item['eva_unit_price'] = null;
|
||||||
|
$item['eva_total_value'] = null;
|
||||||
|
$item['eva_net_value'] = null;
|
||||||
|
$item['eva_net_value2'] = null;
|
||||||
|
}
|
||||||
$item['status_str'] = getDictionaryName('ORDER_STATUS', $item['status']);
|
$item['status_str'] = getDictionaryName('ORDER_STATUS', $item['status']);
|
||||||
$item['survey_status_str'] = getDictionaryName('SURVEY_STATUS', $item['survey_status']);
|
$item['survey_status_str'] = getDictionaryName('SURVEY_STATUS', $item['survey_status']);
|
||||||
$item['is_multi_str'] = getDictionaryName('INQUIRY_NUMBER', $item['is_multiple']);
|
$item['is_multi_str'] = getDictionaryName('INQUIRY_NUMBER', $item['is_multiple']);
|
||||||
@@ -576,8 +585,14 @@ class Survey extends Base
|
|||||||
->order('id desc')
|
->order('id desc')
|
||||||
->field('external_remarks,appraiser_name')
|
->field('external_remarks,appraiser_name')
|
||||||
->find();
|
->find();
|
||||||
$item['external_remarks'] = $return_price_info['external_remarks'];
|
// 检查是否找到数据
|
||||||
$item['appraiser_name'] = $return_price_info['appraiser_name'];
|
if ($return_price_info) {
|
||||||
|
$item['external_remarks'] = $return_price_info['external_remarks'];
|
||||||
|
$item['appraiser_name'] = $return_price_info['appraiser_name'];
|
||||||
|
} else {
|
||||||
|
$item['external_remarks'] = null;
|
||||||
|
$item['appraiser_name'] = null;
|
||||||
|
}
|
||||||
// $item['status_str'] = getDictionaryName('ORDER_STATUS', $item['status']);
|
// $item['status_str'] = getDictionaryName('ORDER_STATUS', $item['status']);
|
||||||
$item['survey_status_str'] = getDictionaryName('SURVEY_STATUS', $item['status']);
|
$item['survey_status_str'] = getDictionaryName('SURVEY_STATUS', $item['status']);
|
||||||
$item['is_multi_str'] = getDictionaryName('INQUIRY_NUMBER', $item['is_multiple']);
|
$item['is_multi_str'] = getDictionaryName('INQUIRY_NUMBER', $item['is_multiple']);
|
||||||
|
|||||||
@@ -28,30 +28,12 @@ $sender_io->on('connection', function($socket) use (&$push_value){
|
|||||||
// 客户端连接时立即发送当前数值
|
// 客户端连接时立即发送当前数值
|
||||||
$socket->emit('push_value', ['value' => $push_value]);
|
$socket->emit('push_value', ['value' => $push_value]);
|
||||||
|
|
||||||
// 连接时自动推送最新的未回价数量
|
// 连接时发送刷新事件,让客户端主动获取所有数量(避免重复查询逻辑)
|
||||||
try {
|
error_log("WebSocket客户端连接,发送4个刷新事件");
|
||||||
// 从ThinkPHP数据库配置文件读取数据库连接信息
|
$socket->emit('updateUnreturnedCount', ['refresh' => true]);
|
||||||
$db_config = require __DIR__ . '/config/database.php';
|
$socket->emit('updateEstimatePendingCount', ['refresh' => true]);
|
||||||
$db_host = isset($db_config['hostname']) ? $db_config['hostname'] : 'localhost';
|
$socket->emit('updateReportProduceCount', ['refresh' => true]);
|
||||||
$db_name = isset($db_config['database']) ? $db_config['database'] : 'pgserver';
|
$socket->emit('updateSurveyFollowCount', ['refresh' => true]);
|
||||||
$db_user = isset($db_config['username']) ? $db_config['username'] : 'root';
|
|
||||||
$db_pass = isset($db_config['password']) ? $db_config['password'] : '';
|
|
||||||
$db_port = isset($db_config['hostport']) ? $db_config['hostport'] : '3306';
|
|
||||||
$db_charset = isset($db_config['charset']) ? $db_config['charset'] : 'utf8';
|
|
||||||
|
|
||||||
// 使用PDO连接数据库查询最新数量
|
|
||||||
$dsn = "mysql:host=$db_host;port=$db_port;dbname=$db_name;charset=$db_charset";
|
|
||||||
$pdo = new PDO($dsn, $db_user, $db_pass);
|
|
||||||
$stmt = $pdo->query('SELECT COUNT(*) as count FROM pg_inquiry WHERE return_price_status = 2');
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
$count = $result['count'] ?? 0;
|
|
||||||
|
|
||||||
// 推送未回价数量
|
|
||||||
$socket->emit('updateUnreturnedCount', ['count' => $count]);
|
|
||||||
error_log("WebSocket连接时推送未回价数量: $count");
|
|
||||||
} catch (Exception $e) {
|
|
||||||
error_log("WebSocket连接时获取未回价数量失败: " . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$socket->on('login', function ($uid)use($socket){
|
$socket->on('login', function ($uid)use($socket){
|
||||||
global $uidConnectionMap;
|
global $uidConnectionMap;
|
||||||
@@ -65,6 +47,24 @@ $sender_io->on('connection', function($socket) use (&$push_value){
|
|||||||
++$uidConnectionMap[$uid];
|
++$uidConnectionMap[$uid];
|
||||||
$socket->join($uid);
|
$socket->join($uid);
|
||||||
$socket->uid = $uid;
|
$socket->uid = $uid;
|
||||||
|
|
||||||
|
// 登录时推送刷新事件,让客户端主动获取所有数量
|
||||||
|
$socket->emit('updateSurveyFollowCount', ['refresh' => true]);
|
||||||
|
$socket->emit('updateUnreturnedCount', ['refresh' => true]);
|
||||||
|
$socket->emit('updateEstimatePendingCount', ['refresh' => true]);
|
||||||
|
$socket->emit('updateReportProduceCount', ['refresh' => true]);
|
||||||
|
error_log("WebSocket登录时推送用户{$uid}的4个刷新事件");
|
||||||
|
});
|
||||||
|
|
||||||
|
// 处理客户端主动刷新请求
|
||||||
|
$socket->on('refreshAllCounts', function()use($socket){
|
||||||
|
error_log("收到客户端刷新请求");
|
||||||
|
// 发送刷新事件给当前客户端
|
||||||
|
$socket->emit('updateSurveyFollowCount', ['refresh' => true]);
|
||||||
|
$socket->emit('updateUnreturnedCount', ['refresh' => true]);
|
||||||
|
$socket->emit('updateEstimatePendingCount', ['refresh' => true]);
|
||||||
|
$socket->emit('updateReportProduceCount', ['refresh' => true]);
|
||||||
|
error_log("已向客户端发送刷新事件(包含报告数量)");
|
||||||
});
|
});
|
||||||
|
|
||||||
$socket->on('disconnect', function () use($socket) {
|
$socket->on('disconnect', function () use($socket) {
|
||||||
@@ -128,15 +128,24 @@ $sender_io->on('workerStart', function()use ($sender_io, $http_port){
|
|||||||
$event = isset($msgContent['event']) ? $msgContent['event'] : '';
|
$event = isset($msgContent['event']) ? $msgContent['event'] : '';
|
||||||
$eventData = isset($msgContent['data']) ? $msgContent['data'] : '';
|
$eventData = isset($msgContent['data']) ? $msgContent['data'] : '';
|
||||||
|
|
||||||
error_log("Broadcast check - event: '$event', data: '$eventData'");
|
error_log("=== WebSocket广播调试 ===");
|
||||||
|
error_log("事件名称: '$event'");
|
||||||
|
error_log("原始数据: '$eventData'");
|
||||||
|
|
||||||
if(!empty($event)){
|
if(!empty($event)){
|
||||||
if(is_string($eventData)){
|
if(is_string($eventData)){
|
||||||
$decoded = json_decode($eventData, true);
|
$decoded = json_decode($eventData, true);
|
||||||
$eventData = $decoded !== null ? $decoded : $eventData;
|
$eventData = $decoded !== null ? $decoded : $eventData;
|
||||||
}
|
}
|
||||||
$sender_io->emit($event, $eventData);
|
error_log("解码后数据: " . print_r($eventData, true));
|
||||||
error_log("Broadcast sent - event: $event, data: " . print_r($eventData, true));
|
|
||||||
|
// 获取所有连接的客户端并发送消息
|
||||||
|
// PHPSocketIO 1.x 使用 connections 数组获取所有连接
|
||||||
|
foreach ($sender_io->connections as $connection) {
|
||||||
|
$connection->emit($event, $eventData);
|
||||||
|
}
|
||||||
|
error_log("广播已发送到所有客户端 - 事件: $event");
|
||||||
|
|
||||||
return $http_connection->send('ok');
|
return $http_connection->send('ok');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,3 +146,21 @@ export async function getUnreturnedPriceCount (params) {
|
|||||||
const res = await post('admin/Pending/getUnreturnedPriceCount', params)
|
const res = await post('admin/Pending/getUnreturnedPriceCount', params)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取预估制作数量(status=9)
|
||||||
|
export async function getEstimatePendingCount (params) {
|
||||||
|
const res = await post('admin/Pending/getEstimatePendingCount', params)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取查勘跟进中数量(当前登录人)
|
||||||
|
export async function getSurveyFollowCount (params) {
|
||||||
|
const res = await post('admin/Survey/surveyFollowCount', params)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取报告制作数量统计
|
||||||
|
export async function getReportProduceCount (params) {
|
||||||
|
const res = await post('admin/ReportManage/getReportProduceCount', params)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
{{ replacePhrases(menuItem.title, replaceRule1) }}
|
{{ replacePhrases(menuItem.title, replaceRule1) }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isHuiJiaMenu(menuItem) && unreturnedCount >= 1" class="push-value-badge">{{ unreturnedCount }}</div>
|
<div v-if="isHuiJiaMenu(menuItem) && unreturnedCount >= 1" class="push-value-badge">{{ unreturnedCount }}</div>
|
||||||
|
<div v-if="isEstimateMenu(menuItem) && estimateCounts.total > 0" class="push-value-badge">{{ estimateCounts.total }}</div>
|
||||||
|
<div v-if="isSurveyMenu(menuItem) && surveyFollowCount > 0" class="push-value-badge">{{ surveyFollowCount }}</div>
|
||||||
|
<div v-if="isReportMenu(menuItem) && reportProduceCounts.total > 0" class="push-value-badge">{{ reportProduceCounts.total }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
@@ -29,6 +32,7 @@
|
|||||||
import "@/styles/globalSetting.less";
|
import "@/styles/globalSetting.less";
|
||||||
import { EventBus } from '@/libs/eventBus'
|
import { EventBus } from '@/libs/eventBus'
|
||||||
import socket from '@/libs/socket'
|
import socket from '@/libs/socket'
|
||||||
|
import { getSurveyFollowCount, getUnreturnedPriceCount, getEstimatePendingCount, getReportProduceCount } from '@/api/businessManage/inquiry'
|
||||||
export default {
|
export default {
|
||||||
name: 'NxIconMenu',
|
name: 'NxIconMenu',
|
||||||
props: {
|
props: {
|
||||||
@@ -45,6 +49,20 @@
|
|||||||
return {
|
return {
|
||||||
activeMenu: '1-4-1',
|
activeMenu: '1-4-1',
|
||||||
unreturnedCount: 0,
|
unreturnedCount: 0,
|
||||||
|
estimateCounts: {
|
||||||
|
pending: 0,
|
||||||
|
secondReview: 0,
|
||||||
|
thirdReview: 0,
|
||||||
|
sign: 0,
|
||||||
|
total: 0
|
||||||
|
},
|
||||||
|
surveyFollowCount: 0,
|
||||||
|
reportProduceCounts: {
|
||||||
|
pending: 0,
|
||||||
|
secondReview: 0,
|
||||||
|
thirdReview: 0,
|
||||||
|
total: 0
|
||||||
|
},
|
||||||
replaceRule1:[
|
replaceRule1:[
|
||||||
['询价项目','询价'],
|
['询价项目','询价'],
|
||||||
['回价项目','回价'],
|
['回价项目','回价'],
|
||||||
@@ -72,25 +90,179 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
// 监听EventBus事件
|
// 调试:打印左侧菜单数据
|
||||||
|
console.log('=== 左侧图标菜单调试 ===')
|
||||||
|
console.log('menuData:', this.menuData)
|
||||||
|
console.log('estimateCounts初始值:', this.estimateCounts)
|
||||||
|
|
||||||
|
// 主动获取所有数量,避免时序问题导致的红点不显示
|
||||||
|
this.fetchUnreturnedCount()
|
||||||
|
this.fetchEstimateCount()
|
||||||
|
this.fetchSurveyFollowCount()
|
||||||
|
this.fetchReportCount()
|
||||||
|
|
||||||
|
// 监听EventBus事件 - 未回价数量
|
||||||
this.eventBusCallback = (count) => {
|
this.eventBusCallback = (count) => {
|
||||||
|
console.log('=== 未回价EventBus事件 ===', count)
|
||||||
this.$set(this, 'unreturnedCount', count)
|
this.$set(this, 'unreturnedCount', count)
|
||||||
}
|
}
|
||||||
this.socketCallback = (data) => {
|
this.socketCallback = (data) => {
|
||||||
if (data && data.count !== undefined) {
|
console.log('=== 未回价WebSocket事件 ===', data)
|
||||||
|
if (data && data.refresh) {
|
||||||
|
// 收到刷新事件,主动获取数据
|
||||||
|
this.fetchUnreturnedCount()
|
||||||
|
} else if (data && data.count !== undefined) {
|
||||||
this.$set(this, 'unreturnedCount', data.count)
|
this.$set(this, 'unreturnedCount', data.count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EventBus.$on('updateUnreturnedCount', this.eventBusCallback)
|
EventBus.$on('updateUnreturnedCount', this.eventBusCallback)
|
||||||
socket.on('updateUnreturnedCount', this.socketCallback)
|
socket.on('updateUnreturnedCount', this.socketCallback)
|
||||||
|
|
||||||
|
// 监听EventBus事件 - 预估制作数量
|
||||||
|
this.estimateEventBusCallback = (counts) => {
|
||||||
|
console.log('=== 预估EventBus事件 ===', counts)
|
||||||
|
this.$set(this, 'estimateCounts', counts)
|
||||||
|
}
|
||||||
|
this.estimateSocketCallback = (data) => {
|
||||||
|
console.log('=== 预估WebSocket事件 ===', data)
|
||||||
|
if (data && data.refresh) {
|
||||||
|
// 收到刷新事件,主动获取数据
|
||||||
|
this.fetchEstimateCount()
|
||||||
|
} else if (data && data.pending !== undefined) {
|
||||||
|
this.$set(this, 'estimateCounts', data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EventBus.$on('updateEstimatePendingCount', this.estimateEventBusCallback)
|
||||||
|
socket.on('updateEstimatePendingCount', this.estimateSocketCallback)
|
||||||
|
|
||||||
|
// 监听EventBus事件 - 查勘跟进中数量
|
||||||
|
this.surveyEventBusCallback = (count) => {
|
||||||
|
this.$set(this, 'surveyFollowCount', count)
|
||||||
|
}
|
||||||
|
this.surveySocketCallback = (data) => {
|
||||||
|
console.log('=== 查勘WebSocket事件 ===', data)
|
||||||
|
if (data && data.refresh) {
|
||||||
|
// 收到刷新事件,主动重新获取查勘数量
|
||||||
|
console.log('收到查勘刷新事件,主动获取查勘数量')
|
||||||
|
this.fetchSurveyFollowCount()
|
||||||
|
} else if (data && data.count !== undefined) {
|
||||||
|
// 直接更新数量(兼容旧的推送格式)
|
||||||
|
console.log('收到查勘数量更新:', data.count)
|
||||||
|
this.$set(this, 'surveyFollowCount', data.count)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EventBus.$on('updateSurveyFollowCount', this.surveyEventBusCallback)
|
||||||
|
socket.on('updateSurveyFollowCount', this.surveySocketCallback)
|
||||||
|
|
||||||
|
// 监听EventBus事件 - 报告制作数量
|
||||||
|
this.reportEventBusCallback = (counts) => {
|
||||||
|
console.log('=== 报告EventBus事件 ===', counts)
|
||||||
|
this.$set(this, 'reportProduceCounts', counts)
|
||||||
|
}
|
||||||
|
this.reportSocketCallback = (data) => {
|
||||||
|
console.log('=== 报告WebSocket事件 ===', data)
|
||||||
|
if (data && data.refresh) {
|
||||||
|
// 收到刷新事件,主动获取数据
|
||||||
|
this.fetchReportCount()
|
||||||
|
} else if (data && data.counts !== undefined) {
|
||||||
|
this.$set(this, 'reportProduceCounts', data.counts)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EventBus.$on('updateReportProduceCount', this.reportEventBusCallback)
|
||||||
|
socket.on('updateReportProduceCount', this.reportSocketCallback)
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
EventBus.$off('updateUnreturnedCount', this.eventBusCallback)
|
EventBus.$off('updateUnreturnedCount', this.eventBusCallback)
|
||||||
socket.off('updateUnreturnedCount', this.socketCallback)
|
socket.off('updateUnreturnedCount', this.socketCallback)
|
||||||
|
EventBus.$off('updateEstimatePendingCount', this.estimateEventBusCallback)
|
||||||
|
socket.off('updateEstimatePendingCount', this.estimateSocketCallback)
|
||||||
|
EventBus.$off('updateSurveyFollowCount', this.surveyEventBusCallback)
|
||||||
|
socket.off('updateSurveyFollowCount', this.surveySocketCallback)
|
||||||
|
EventBus.$off('updateReportProduceCount', this.reportEventBusCallback)
|
||||||
|
socket.off('updateReportProduceCount', this.reportSocketCallback)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 主动获取未回价数量
|
||||||
|
async fetchUnreturnedCount() {
|
||||||
|
try {
|
||||||
|
console.log('开始获取未回价数量...')
|
||||||
|
const res = await getUnreturnedPriceCount()
|
||||||
|
console.log('未回价数量接口返回:', res)
|
||||||
|
if (res && res.code === 1 && res.data) {
|
||||||
|
console.log('未回价数量获取成功:', res.data.count)
|
||||||
|
this.$set(this, 'unreturnedCount', res.data.count)
|
||||||
|
} else {
|
||||||
|
console.log('未回价数量获取失败,响应格式不正确')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取未回价数量失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 主动获取预估制作数量
|
||||||
|
async fetchEstimateCount() {
|
||||||
|
try {
|
||||||
|
console.log('开始获取预估制作数量...')
|
||||||
|
const res = await getEstimatePendingCount()
|
||||||
|
console.log('预估制作数量接口返回:', res)
|
||||||
|
if (res && res.code === 1 && res.data) {
|
||||||
|
console.log('预估制作数量获取成功:', res.data)
|
||||||
|
this.$set(this, 'estimateCounts', res.data)
|
||||||
|
} else {
|
||||||
|
console.log('预估制作数量获取失败,响应格式不正确')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取预估制作数量失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 主动获取查勘跟进中数量
|
||||||
|
async fetchSurveyFollowCount() {
|
||||||
|
try {
|
||||||
|
console.log('开始获取查勘跟进中数量...')
|
||||||
|
const res = await getSurveyFollowCount()
|
||||||
|
console.log('查勘跟进中数量接口返回:', res)
|
||||||
|
if (res && res.code === 1 && res.data) {
|
||||||
|
console.log('查勘跟进中数量获取成功:', res.data.count)
|
||||||
|
this.$set(this, 'surveyFollowCount', res.data.count)
|
||||||
|
} else {
|
||||||
|
console.log('查勘跟进中数量获取失败,响应格式不正确')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取查勘跟进中数量失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 主动获取报告制作数量
|
||||||
|
async fetchReportCount() {
|
||||||
|
try {
|
||||||
|
console.log('===== 开始获取报告制作数量 =====')
|
||||||
|
const res = await getReportProduceCount()
|
||||||
|
console.log('报告制作数量接口返回:', JSON.stringify(res, null, 2))
|
||||||
|
if (res && res.code === 1 && res.data) {
|
||||||
|
const data = res.data
|
||||||
|
console.log('===== 报告制作数量统计 =====')
|
||||||
|
console.log('待制作数量:', data.pending)
|
||||||
|
console.log('二审待制作数量:', data.secondReview)
|
||||||
|
console.log('三审待制作数量:', data.thirdReview)
|
||||||
|
console.log('总数:', data.total)
|
||||||
|
console.log('============================')
|
||||||
|
this.$set(this, 'reportProduceCounts', data)
|
||||||
|
} else {
|
||||||
|
console.log('报告制作数量获取失败,响应格式不正确')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取报告制作数量失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
isHuiJiaMenu(menuItem) {
|
isHuiJiaMenu(menuItem) {
|
||||||
return menuItem.title === '回价项目' || menuItem.routerName === 'priceReturn'
|
return menuItem.title === '回价项目' || menuItem.title === '回价' || menuItem.routerName === 'priceReturn'
|
||||||
|
},
|
||||||
|
isEstimateMenu(menuItem) {
|
||||||
|
return menuItem.title === '预估项目' || menuItem.routerName === 'estimate' || menuItem.name === 'estimate'
|
||||||
|
},
|
||||||
|
isSurveyMenu(menuItem) {
|
||||||
|
return menuItem.title === '查勘' || menuItem.title === '查勘项目' || menuItem.routerName === 'survey' || menuItem.name === 'survey'
|
||||||
|
},
|
||||||
|
isReportMenu(menuItem) {
|
||||||
|
return menuItem.title === '报告' || menuItem.routerName === 'report' || menuItem.name === 'report'
|
||||||
},
|
},
|
||||||
handleSelect(key, item , externalInfo ) {
|
handleSelect(key, item , externalInfo ) {
|
||||||
this.$emit('menu-select', key, item.routerName, externalInfo);
|
this.$emit('menu-select', key, item.routerName, externalInfo);
|
||||||
|
|||||||
@@ -5,10 +5,22 @@
|
|||||||
<el-submenu style="height: 100%;" v-if="item.children && item.children.length > 0" :index="item.routerName" >
|
<el-submenu style="height: 100%;" v-if="item.children && item.children.length > 0" :index="item.routerName" >
|
||||||
<template slot="title">
|
<template slot="title">
|
||||||
{{ item.title }}
|
{{ item.title }}
|
||||||
<!-- 一级菜单【回价】显示无数量红点 -->
|
<!-- 一级菜单【回价项目】显示未回价数量 -->
|
||||||
<span v-if="isHuiJiaMenu && unreturnedCount >= 1" class="push-dot-badge"></span>
|
<!-- <span v-if="isHuiJiaMenu && unreturnedCount > 0" class="push-value-badge">{{ unreturnedCount }}</span> -->
|
||||||
<!-- 二级菜单【未回价】显示带数量红点 -->
|
<!-- 二级菜单【未回价】显示未回价数量 -->
|
||||||
<span v-else-if="isUnreturnedPriceMenu && unreturnedCount > 0" class="push-value-badge">{{ unreturnedCount }}</span>
|
<span v-if="isUnreturnedPriceMenu && unreturnedCount > 0" class="push-value-badge">{{ unreturnedCount }}</span>
|
||||||
|
<!-- 一级菜单【预估】显示预估总数 -->
|
||||||
|
<!-- <span v-if="isEstimateMenu && estimateCounts.total > 0" class="push-value-badge">{{ estimateCounts.total }}</span> -->
|
||||||
|
<!-- 二级菜单【预估单】显示预估总数 -->
|
||||||
|
<span v-if="isEstimatePendingMenu && estimateCounts.total > 0" class="push-value-badge">{{ estimateCounts.total }}</span>
|
||||||
|
<!-- 一级菜单【查勘项目】显示查勘跟进中数量 -->
|
||||||
|
<!-- <span v-if="isSurveyMenu && surveyFollowCount > 0" class="push-value-badge">{{ surveyFollowCount }}</span> -->
|
||||||
|
<!-- 二级菜单【查勘列表】显示查勘跟进中数量 -->
|
||||||
|
<span v-if="isSurveyListMenu && surveyFollowCount > 0" class="push-value-badge">{{ surveyFollowCount }}</span>
|
||||||
|
<!-- 一级菜单【报告项目】显示报告总数 -->
|
||||||
|
<!-- <span v-if="isReportMenu && reportProduceCounts.total > 0" class="push-value-badge">{{ reportProduceCounts.total }}</span> -->
|
||||||
|
<!-- 二级菜单【报告制作】显示报告总数 -->
|
||||||
|
<span v-if="isReportProduceMenu && reportProduceCounts.total > 0" class="push-value-badge">{{ reportProduceCounts.total }}</span>
|
||||||
</template>
|
</template>
|
||||||
<!-- 递归调用MenuItem组件 -->
|
<!-- 递归调用MenuItem组件 -->
|
||||||
<menu-item v-for="(child, index) in item.children" :key="index" :item="child" class="menu-custom"></menu-item>
|
<menu-item v-for="(child, index) in item.children" :key="index" :item="child" class="menu-custom"></menu-item>
|
||||||
@@ -16,10 +28,25 @@
|
|||||||
|
|
||||||
<!-- 如果没有子菜单,则渲染菜单项 -->
|
<!-- 如果没有子菜单,则渲染菜单项 -->
|
||||||
<el-menu-item v-else :index="item.routerName" class="menu-custom">
|
<el-menu-item v-else :index="item.routerName" class="menu-custom">
|
||||||
<!-- <i class="el-icon-document"></i> -->
|
|
||||||
{{ item.title }}
|
{{ item.title }}
|
||||||
<!-- 三级菜单【未回价列表】显示带数量红点 -->
|
<!-- 三级菜单【未回价列表】显示未回价数量 -->
|
||||||
<span v-if="isUnreturnedPriceListMenu && unreturnedCount > 0" class="push-value-badge">{{ unreturnedCount }}</span>
|
<span v-if="isUnreturnedPriceListMenu && unreturnedCount > 0" class="push-value-badge">{{ unreturnedCount }}</span>
|
||||||
|
<!-- 三级菜单【待制作】(预估)显示预估待制作数量 -->
|
||||||
|
<span v-if="isEstimatePendingListMenu && estimateCounts.pending > 0" class="push-value-badge">{{ estimateCounts.pending }}</span>
|
||||||
|
<!-- 三级菜单【二审待制作】(预估)显示预估二审数量 -->
|
||||||
|
<span v-if="isSecondReviewListMenu && estimateCounts.secondReview > 0" class="push-value-badge">{{ estimateCounts.secondReview }}</span>
|
||||||
|
<!-- 三级菜单【三审待制作】(预估)显示预估三审数量 -->
|
||||||
|
<span v-if="isThirdReviewListMenu && estimateCounts.thirdReview > 0" class="push-value-badge">{{ estimateCounts.thirdReview }}</span>
|
||||||
|
<!-- 三级菜单【待签章】(预估)显示预估待签章数量 -->
|
||||||
|
<span v-if="isSignListMenu && estimateCounts.sign > 0" class="push-value-badge">{{ estimateCounts.sign }}</span>
|
||||||
|
<!-- 三级菜单【跟进中】(查勘)显示查勘跟进中数量 -->
|
||||||
|
<span v-if="isSurveyFollowMenu && surveyFollowCount > 0" class="push-value-badge">{{ surveyFollowCount }}</span>
|
||||||
|
<!-- 三级菜单【待制作】(报告)显示报告待制作数量 -->
|
||||||
|
<span v-if="isReportPendingMenu && reportProduceCounts.pending > 0" class="push-value-badge">{{ reportProduceCounts.pending }}</span>
|
||||||
|
<!-- 三级菜单【二审待制作】(报告)显示报告二审待制作数量 -->
|
||||||
|
<span v-if="isReportSecondReviewMenu && reportProduceCounts.secondReview > 0" class="push-value-badge">{{ reportProduceCounts.secondReview }}</span>
|
||||||
|
<!-- 三级菜单【三审待制作】(报告)显示报告三审待制作数量 -->
|
||||||
|
<span v-if="isReportThirdReviewMenu && reportProduceCounts.thirdReview > 0" class="push-value-badge">{{ reportProduceCounts.thirdReview }}</span>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -28,6 +55,8 @@
|
|||||||
import "@/styles/globalSetting.less";
|
import "@/styles/globalSetting.less";
|
||||||
import { EventBus } from '@/libs/eventBus'
|
import { EventBus } from '@/libs/eventBus'
|
||||||
import socket from '@/libs/socket'
|
import socket from '@/libs/socket'
|
||||||
|
import { post } from '@/libs/request'
|
||||||
|
import { getEstimatePendingCount, getSurveyFollowCount, getReportProduceCount } from '@/api/businessManage/inquiry'
|
||||||
export default {
|
export default {
|
||||||
name: 'MenuItem',
|
name: 'MenuItem',
|
||||||
props: {
|
props: {
|
||||||
@@ -35,28 +64,144 @@
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
unreturnedCount: 0
|
unreturnedCount: 0,
|
||||||
|
estimateCounts: {
|
||||||
|
pending: 0,
|
||||||
|
secondReview: 0,
|
||||||
|
thirdReview: 0,
|
||||||
|
sign: 0,
|
||||||
|
total: 0
|
||||||
|
},
|
||||||
|
surveyFollowCount: 0,
|
||||||
|
reportProduceCounts: {
|
||||||
|
pending: 0,
|
||||||
|
secondReview: 0,
|
||||||
|
thirdReview: 0,
|
||||||
|
total: 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
// ==================== 回价项目 ====================
|
||||||
// 判断是否是一级菜单【回价项目】
|
// 判断是否是一级菜单【回价项目】
|
||||||
isHuiJiaMenu() {
|
isHuiJiaMenu() {
|
||||||
const isMatch = this.item.title === '回价项目' || this.item.routerName === 'priceReturn'
|
return this.item.routerName === 'priceReturn' || this.item.title === '回价项目'
|
||||||
return isMatch
|
|
||||||
},
|
},
|
||||||
// 判断是否是二级菜单【未回价】
|
// 判断是否是二级菜单【未回价】
|
||||||
isUnreturnedPriceMenu() {
|
isUnreturnedPriceMenu() {
|
||||||
const isMatch = this.item.path === '/priceReturn/unreturnedPrice' || this.item.title === '未回价' || this.item.routerName === 'unreturnedPrice'
|
return this.item.routerName === 'unreturnedPrice' || this.item.title === '未回价'
|
||||||
return isMatch
|
|
||||||
},
|
},
|
||||||
// 判断是否是三级菜单【未回价列表】
|
// 判断是否是三级菜单【未回价列表】- 使用routerName唯一标识
|
||||||
isUnreturnedPriceListMenu() {
|
isUnreturnedPriceListMenu() {
|
||||||
const isMatch = this.item.title === '未回价列表'
|
return this.item.routerName && this.item.routerName.includes('unreturnedPrice') ||
|
||||||
return isMatch
|
this.item.title === '未回价列表'
|
||||||
|
},
|
||||||
|
|
||||||
|
// ==================== 预估项目 ====================
|
||||||
|
// 判断是否是一级菜单【预估】- 只有当不是预估单时才匹配
|
||||||
|
isEstimateMenu() {
|
||||||
|
return (this.item.routerName === 'estimate' || this.item.title === '预估') &&
|
||||||
|
!this.isEstimatePendingMenu
|
||||||
|
},
|
||||||
|
// 判断是否是二级菜单【预估单】
|
||||||
|
isEstimatePendingMenu() {
|
||||||
|
return this.item.routerName === 'estimateMake-estimate' || this.item.title === '预估单'
|
||||||
|
},
|
||||||
|
// 判断是否是三级菜单【待制作】(预估)-使用routerName区分,避免与报告制作下的待制作混淆
|
||||||
|
isEstimatePendingListMenu() {
|
||||||
|
return this.item.routerName === 'estimateMake-estimateWaitMakeList' ||
|
||||||
|
this.item.routerName && this.item.routerName.includes('estimateWaitMakeList')
|
||||||
|
},
|
||||||
|
// 判断是否是三级菜单【二审待制作】(预估)-使用routerName区分
|
||||||
|
isSecondReviewListMenu() {
|
||||||
|
return this.item.routerName === 'estimateMake-estimateWaitMakeApprovalList' ||
|
||||||
|
this.item.routerName && this.item.routerName.includes('estimateWaitMakeApprovalList')
|
||||||
|
},
|
||||||
|
// 判断是否是三级菜单【三审待制作】(预估)-使用routerName区分
|
||||||
|
isThirdReviewListMenu() {
|
||||||
|
return this.item.routerName === 'estimateMake-estimateWaitMakeApprovalThirdList' ||
|
||||||
|
this.item.routerName && this.item.routerName.includes('estimateWaitMakeApprovalThirdList')
|
||||||
|
},
|
||||||
|
// 判断是否是三级菜单【待签章】(预估)
|
||||||
|
isSignListMenu() {
|
||||||
|
return this.item.routerName === 'estimateMake-estimateWaitSignSignList' ||
|
||||||
|
this.item.routerName && this.item.routerName.includes('estimateWaitSignSignList') ||
|
||||||
|
this.item.title === '待签章'
|
||||||
|
},
|
||||||
|
|
||||||
|
// ==================== 查勘项目 ====================
|
||||||
|
// 判断是否是一级菜单【查勘项目】
|
||||||
|
isSurveyMenu() {
|
||||||
|
return this.item.routerName === 'surveyManage-surveyManage' ||
|
||||||
|
this.item.routerName === 'survey' ||
|
||||||
|
this.item.title === '查勘项目' ||
|
||||||
|
this.item.title === '查勘'
|
||||||
|
},
|
||||||
|
// 判断是否是二级菜单【查勘列表】
|
||||||
|
isSurveyListMenu() {
|
||||||
|
return this.item.routerName && this.item.routerName.startsWith('surveyManage-') ||
|
||||||
|
this.item.title === '查勘列表'
|
||||||
|
},
|
||||||
|
// 判断是否是三级菜单【跟进中】(查勘)-使用routerName确保是查勘模块下的
|
||||||
|
isSurveyFollowMenu() {
|
||||||
|
return this.item.routerName === 'surveyManage-surveyWaitFollowList' ||
|
||||||
|
(this.item.title === '跟进中' && this.item.routerName && this.item.routerName.includes('survey'))
|
||||||
|
},
|
||||||
|
|
||||||
|
// ==================== 报告项目 ====================
|
||||||
|
// 判断是否是一级菜单【报告项目】
|
||||||
|
// isReportMenu() {
|
||||||
|
// return this.item.routerName === 'report' ||
|
||||||
|
// this.item.title === '报告项目' ||
|
||||||
|
// this.item.title === '报告制作'
|
||||||
|
// },
|
||||||
|
// 判断是否是二级菜单【报告制作】
|
||||||
|
isReportProduceMenu() {
|
||||||
|
return this.item.routerName && this.item.routerName.startsWith('report-') ||
|
||||||
|
this.item.title === '报告制作'
|
||||||
|
},
|
||||||
|
// 判断是否是三级菜单【待制作】(报告)-使用routerName区分,避免与预估单下的待制作混淆
|
||||||
|
isReportPendingMenu() {
|
||||||
|
return this.item.routerName === 'waitMake'
|
||||||
|
},
|
||||||
|
// 判断是否是三级菜单【二审待制作】(报告)-使用routerName区分
|
||||||
|
isReportSecondReviewMenu() {
|
||||||
|
return this.item.routerName === 'waitApproval'
|
||||||
|
},
|
||||||
|
// 判断是否是三级菜单【三审待制作】(报告)-使用routerName区分
|
||||||
|
isReportThirdReviewMenu() {
|
||||||
|
return this.item.routerName === 'waitApprovalThird'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log('菜单组件mounted - item:', this.item)
|
// 获取所有数据,确保每个菜单项都能显示正确的数值
|
||||||
|
// 回价相关菜单
|
||||||
|
// if (this.isHuiJiaMenu || this.isUnreturnedPriceMenu || this.isUnreturnedPriceListMenu) {
|
||||||
|
this.fetchUnreturnedCount()
|
||||||
|
// }
|
||||||
|
// 预估相关菜单 - 包含预估模块下的所有菜单
|
||||||
|
// if (this.isEstimateMenu || this.isEstimatePendingMenu || this.isEstimatePendingListMenu || this.isSecondReviewListMenu || this.isThirdReviewListMenu || this.isSignListMenu ||
|
||||||
|
// this.item.title === '预估' || this.item.title === '预估单' ||
|
||||||
|
// (this.item.title === '待制作' && this.item.parentName === '预估单') ||
|
||||||
|
// (this.item.title && this.item.title.includes('二审') && this.item.parentName === '预估单') ||
|
||||||
|
// (this.item.title && this.item.title.includes('三审') && this.item.parentName === '预估单') ||
|
||||||
|
// this.item.title === '待签章') {
|
||||||
|
this.fetchEstimateCount()
|
||||||
|
// }
|
||||||
|
// 查勘相关菜单 - 包含查勘模块下的所有菜单
|
||||||
|
// if (this.isSurveyMenu || this.isSurveyListMenu || this.isSurveyFollowMenu ||
|
||||||
|
// this.item.title === '查勘项目' || this.item.title === '查勘' ||
|
||||||
|
// this.item.title === '查勘列表' || this.item.title === '跟进中') {
|
||||||
|
this.fetchSurveyFollowCount()
|
||||||
|
// }
|
||||||
|
// 报告相关菜单 - 包含报告模块下的所有菜单
|
||||||
|
// if (this.isReportMenu || this.isReportProduceMenu || this.isReportPendingMenu || this.isReportSecondReviewMenu || this.isReportThirdReviewMenu ||
|
||||||
|
// this.item.title === '报告项目' || this.item.title === '报告制作' ||
|
||||||
|
// (this.item.title === '待制作' && this.item.parentName === '报告制作') ||
|
||||||
|
// (this.item.title && this.item.title.includes('二审') && this.item.parentName === '报告制作') ||
|
||||||
|
// (this.item.title && this.item.title.includes('三审') && this.item.parentName === '报告制作')) {
|
||||||
|
this.fetchReportCount()
|
||||||
|
// }
|
||||||
|
|
||||||
// 保存回调引用用于销毁时移除
|
// 保存回调引用用于销毁时移除
|
||||||
this.eventBusCallback = (count) => {
|
this.eventBusCallback = (count) => {
|
||||||
@@ -65,23 +210,135 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.socketCallback = (data) => {
|
this.socketCallback = (data) => {
|
||||||
if (data && data.count !== undefined) {
|
if (data && data.refresh) {
|
||||||
// 使用Vue.set确保响应式更新
|
// 收到刷新事件,只有回价相关菜单才主动获取数据
|
||||||
|
if (this.isHuiJiaMenu || this.isUnreturnedPriceMenu || this.isUnreturnedPriceListMenu) {
|
||||||
|
this.fetchUnreturnedCount()
|
||||||
|
}
|
||||||
|
} else if (data && data.count !== undefined) {
|
||||||
this.$set(this, 'unreturnedCount', data.count)
|
this.$set(this, 'unreturnedCount', data.count)
|
||||||
console.log('WebSocket收到未回价数量更新:', data.count, '当前item:', this.item.name || this.item.title)
|
console.log('WebSocket收到未回价数量更新:', data.count, '当前item:', this.item.name || this.item.title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听EventBus事件(页面初始化时)
|
// 预估制作数量回调
|
||||||
EventBus.$on('updateUnreturnedCount', this.eventBusCallback)
|
this.estimateEventBusCallback = (counts) => {
|
||||||
|
this.$set(this, 'estimateCounts', counts)
|
||||||
|
}
|
||||||
|
|
||||||
// 监听WebSocket推送的未回价数量更新
|
this.estimateSocketCallback = (data) => {
|
||||||
|
if (data && data.refresh) {
|
||||||
|
// 收到刷新事件,只有预估相关菜单才主动获取数据
|
||||||
|
if (this.isEstimateMenu || this.isEstimatePendingMenu || this.isEstimatePendingListMenu || this.isSecondReviewListMenu || this.isThirdReviewListMenu || this.isSignListMenu) {
|
||||||
|
this.fetchEstimateCount()
|
||||||
|
}
|
||||||
|
} else if (data && data.pending !== undefined) {
|
||||||
|
this.$set(this, 'estimateCounts', data)
|
||||||
|
console.log('WebSocket收到预估制作数量更新:', data, '当前item:', this.item.name || this.item.title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查勘跟进中数量回调
|
||||||
|
this.surveyEventBusCallback = (count) => {
|
||||||
|
this.$set(this, 'surveyFollowCount', count)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.surveySocketCallback = (data) => {
|
||||||
|
if (data && data.refresh) {
|
||||||
|
// 收到刷新事件,只有查勘相关菜单才主动获取数据
|
||||||
|
if (this.isSurveyMenu || this.isSurveyListMenu || this.isSurveyFollowMenu) {
|
||||||
|
this.fetchSurveyFollowCount()
|
||||||
|
}
|
||||||
|
} else if (data && data.count !== undefined) {
|
||||||
|
this.$set(this, 'surveyFollowCount', data.count)
|
||||||
|
console.log('WebSocket收到查勘跟进中数量更新:', data.count, '当前item:', this.item.name || this.item.title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 报告制作数量回调
|
||||||
|
this.reportEventBusCallback = (counts) => {
|
||||||
|
this.$set(this, 'reportProduceCounts', counts)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.reportSocketCallback = (data) => {
|
||||||
|
if (data && data.refresh) {
|
||||||
|
// 收到刷新事件,只有报告相关菜单才主动获取数据
|
||||||
|
if (this.isReportMenu || this.isReportProduceMenu || this.isReportPendingMenu || this.isReportSecondReviewMenu || this.isReportThirdReviewMenu) {
|
||||||
|
this.fetchReportCount()
|
||||||
|
}
|
||||||
|
} else if (data && data.pending !== undefined) {
|
||||||
|
this.$set(this, 'reportProduceCounts', data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听EventBus事件
|
||||||
|
EventBus.$on('updateUnreturnedCount', this.eventBusCallback)
|
||||||
|
EventBus.$on('updateEstimatePendingCount', this.estimateEventBusCallback)
|
||||||
|
EventBus.$on('updateSurveyFollowCount', this.surveyEventBusCallback)
|
||||||
|
EventBus.$on('updateReportProduceCount', this.reportEventBusCallback)
|
||||||
|
|
||||||
|
// 监听WebSocket事件
|
||||||
socket.on('updateUnreturnedCount', this.socketCallback)
|
socket.on('updateUnreturnedCount', this.socketCallback)
|
||||||
|
socket.on('updateEstimatePendingCount', this.estimateSocketCallback)
|
||||||
|
socket.on('updateSurveyFollowCount', this.surveySocketCallback)
|
||||||
|
socket.on('updateReportProduceCount', this.reportSocketCallback)
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
// 移除监听
|
// 移除监听
|
||||||
EventBus.$off('updateUnreturnedCount', this.eventBusCallback)
|
EventBus.$off('updateUnreturnedCount', this.eventBusCallback)
|
||||||
socket.off('updateUnreturnedCount', this.socketCallback)
|
socket.off('updateUnreturnedCount', this.socketCallback)
|
||||||
|
EventBus.$off('updateEstimatePendingCount', this.estimateEventBusCallback)
|
||||||
|
socket.off('updateEstimatePendingCount', this.estimateSocketCallback)
|
||||||
|
EventBus.$off('updateSurveyFollowCount', this.surveyEventBusCallback)
|
||||||
|
socket.off('updateSurveyFollowCount', this.surveySocketCallback)
|
||||||
|
EventBus.$off('updateReportProduceCount', this.reportEventBusCallback)
|
||||||
|
socket.off('updateReportProduceCount', this.reportSocketCallback)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async fetchUnreturnedCount() {
|
||||||
|
try {
|
||||||
|
const res = await post('admin/Pending/getUnreturnedPriceCount')
|
||||||
|
if (res && res.code === 1 && res.data) {
|
||||||
|
this.$set(this, 'unreturnedCount', res.data.count)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取未回价数量失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async fetchEstimateCount() {
|
||||||
|
try {
|
||||||
|
const res = await getEstimatePendingCount()
|
||||||
|
if (res && res.code === 1 && res.data) {
|
||||||
|
this.$set(this, 'estimateCounts', res.data)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取预估数量失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async fetchSurveyFollowCount() {
|
||||||
|
try {
|
||||||
|
const res = await getSurveyFollowCount()
|
||||||
|
if (res && res.code === 1 && res.data) {
|
||||||
|
this.$set(this, 'surveyFollowCount', res.data.count)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取查勘跟进中数量失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async fetchReportCount() {
|
||||||
|
try {
|
||||||
|
console.log('===== nxMenu 获取报告制作数量 =====')
|
||||||
|
const res = await getReportProduceCount()
|
||||||
|
console.log('报告制作数量接口返回:', JSON.stringify(res, null, 2))
|
||||||
|
if (res && res.code === 1 && res.data) {
|
||||||
|
const data = res.data
|
||||||
|
console.log('待制作:', data.pending, '二审:', data.secondReview, '三审:', data.thirdReview, '总数:', data.total)
|
||||||
|
this.$set(this, 'reportProduceCounts', data)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取报告制作数量失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -117,4 +374,4 @@
|
|||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
42
pgweb/src/libs/estimatePending.js
Normal file
42
pgweb/src/libs/estimatePending.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { EventBus } from './eventBus'
|
||||||
|
import { getEstimatePendingCount } from '@/api/businessManage/inquiry'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取并更新所有预估状态数量
|
||||||
|
* 调用API获取最新数量,并通过EventBus广播给所有监听者
|
||||||
|
*/
|
||||||
|
export const fetchAndUpdateEstimatePendingCount = async () => {
|
||||||
|
console.log('fetchAndUpdateEstimatePendingCount: 开始获取预估状态数量...')
|
||||||
|
try {
|
||||||
|
const response = await getEstimatePendingCount()
|
||||||
|
console.log('fetchAndUpdateEstimatePendingCount: 接口返回完整数据:', response)
|
||||||
|
if (response && response.code === 1) {
|
||||||
|
const data = response.data || {}
|
||||||
|
const pending = data.pending || 0
|
||||||
|
const secondReview = data.secondReview || 0
|
||||||
|
const thirdReview = data.thirdReview || 0
|
||||||
|
const sign = data.sign || 0
|
||||||
|
const total = data.total || 0
|
||||||
|
|
||||||
|
console.log('fetchAndUpdateEstimatePendingCount: 获取到预估状态数量:', { pending, secondReview, thirdReview, sign, total })
|
||||||
|
console.log('fetchAndUpdateEstimatePendingCount: 调试数据:', data.debug || '无')
|
||||||
|
|
||||||
|
// 通过事件总线传递数量给菜单组件
|
||||||
|
EventBus.$emit('updateEstimatePendingCount', {
|
||||||
|
pending,
|
||||||
|
secondReview,
|
||||||
|
thirdReview,
|
||||||
|
sign,
|
||||||
|
total
|
||||||
|
})
|
||||||
|
|
||||||
|
return { pending, secondReview, thirdReview, sign, total }
|
||||||
|
} else {
|
||||||
|
console.warn('fetchAndUpdateEstimatePendingCount: 接口返回异常:', response)
|
||||||
|
return { pending: 0, secondReview: 0, thirdReview: 0, sign: 0, total: 0 }
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('fetchAndUpdateEstimatePendingCount: 获取预估状态数量失败:', error)
|
||||||
|
return { pending: 0, secondReview: 0, thirdReview: 0, sign: 0, total: 0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,10 +19,14 @@ const socket = io(process.env.VUE_APP_SOCKET_URL, {
|
|||||||
// 添加连接状态监听
|
// 添加连接状态监听
|
||||||
socket.on('connect', () => {
|
socket.on('connect', () => {
|
||||||
console.log('WebSocket已成功连接到服务器:', process.env.VUE_APP_SOCKET_URL)
|
console.log('WebSocket已成功连接到服务器:', process.env.VUE_APP_SOCKET_URL)
|
||||||
|
// 连接成功后启动定时轮询
|
||||||
|
startPolling()
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('disconnect', (reason) => {
|
socket.on('disconnect', (reason) => {
|
||||||
console.log('WebSocket连接断开,原因:', reason)
|
console.log('WebSocket连接断开,原因:', reason)
|
||||||
|
// 断开连接后停止定时轮询
|
||||||
|
stopPolling()
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('connect_error', (error) => {
|
socket.on('connect_error', (error) => {
|
||||||
@@ -33,6 +37,30 @@ socket.on('connect_timeout', () => {
|
|||||||
console.error('WebSocket连接超时')
|
console.error('WebSocket连接超时')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 定时轮询定时器
|
||||||
|
let pollingTimer = null
|
||||||
|
|
||||||
|
// 启动定时轮询(每10秒)
|
||||||
|
function startPolling() {
|
||||||
|
if (pollingTimer) {
|
||||||
|
clearInterval(pollingTimer)
|
||||||
|
}
|
||||||
|
pollingTimer = setInterval(() => {
|
||||||
|
// 触发刷新事件,让客户端主动获取最新数据
|
||||||
|
socket.emit('refreshAllCounts')
|
||||||
|
}, 10000) // 每10秒刷新一次
|
||||||
|
console.log('定时轮询已启动,每5秒刷新一次')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 停止定时轮询
|
||||||
|
function stopPolling() {
|
||||||
|
if (pollingTimer) {
|
||||||
|
clearInterval(pollingTimer)
|
||||||
|
pollingTimer = null
|
||||||
|
}
|
||||||
|
console.log('定时轮询已停止')
|
||||||
|
}
|
||||||
|
|
||||||
// 连接方法
|
// 连接方法
|
||||||
export const connectSocket = () => {
|
export const connectSocket = () => {
|
||||||
console.log('尝试启动WebSocket连接...')
|
console.log('尝试启动WebSocket连接...')
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import * as localStore from 'store'
|
|||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import { connectSocket } from '@/libs/socket'
|
import { connectSocket } from '@/libs/socket'
|
||||||
import { fetchAndUpdateUnreturnedPriceCount } from '@/libs/unreturnedPrice'
|
import { fetchAndUpdateUnreturnedPriceCount } from '@/libs/unreturnedPrice'
|
||||||
|
import { fetchAndUpdateEstimatePendingCount } from '@/libs/estimatePending'
|
||||||
|
|
||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
let routers = routes
|
let routers = routes
|
||||||
@@ -33,11 +34,13 @@ router.beforeEach((to, from, next) => {
|
|||||||
iView.LoadingBar.start()
|
iView.LoadingBar.start()
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
|
|
||||||
// 如果用户已登录,确保WebSocket连接已建立并获取最新未回价数量
|
// 如果用户已登录,确保WebSocket连接已建立并获取最新数量
|
||||||
if (token && to.name !== LOGIN_PAGE_NAME) {
|
if (token && to.name !== LOGIN_PAGE_NAME) {
|
||||||
connectSocket()
|
connectSocket()
|
||||||
// 每次刷新页面都获取最新的未回价数量
|
// 每次刷新页面都获取最新的未回价数量
|
||||||
fetchAndUpdateUnreturnedPriceCount()
|
fetchAndUpdateUnreturnedPriceCount()
|
||||||
|
// 获取预估制作数量
|
||||||
|
fetchAndUpdateEstimatePendingCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!token && to.name !== LOGIN_PAGE_NAME) {
|
if (!token && to.name !== LOGIN_PAGE_NAME) {
|
||||||
|
|||||||
@@ -675,6 +675,9 @@ import{
|
|||||||
getReportObjTypeList
|
getReportObjTypeList
|
||||||
} from '@/api/report.js'
|
} from '@/api/report.js'
|
||||||
|
|
||||||
|
import { EventBus } from '@/libs/eventBus'
|
||||||
|
import { getSurveyFollowCount } from '@/api/businessManage/inquiry'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
reqBankList,
|
reqBankList,
|
||||||
getProduct,
|
getProduct,
|
||||||
@@ -2390,11 +2393,26 @@ export default {
|
|||||||
|
|
||||||
// init data
|
// init data
|
||||||
this.initData()
|
this.initData()
|
||||||
|
|
||||||
|
// 刷新查勘跟进中数量
|
||||||
|
this.refreshSurveyFollowCount()
|
||||||
} else {
|
} else {
|
||||||
this.$Message.error(res.msg)
|
this.$Message.error(res.msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 刷新查勘跟进中数量
|
||||||
|
async refreshSurveyFollowCount() {
|
||||||
|
try {
|
||||||
|
const res = await getSurveyFollowCount()
|
||||||
|
if (res && res.code === 1 && res.data) {
|
||||||
|
const count = res.data.count || 0
|
||||||
|
EventBus.$emit('updateSurveyFollowCount', count)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('刷新查勘跟进中数量失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
onCancelRejPress () {
|
onCancelRejPress () {
|
||||||
this.rejectModal = false
|
this.rejectModal = false
|
||||||
this.$refs['rejFormRef'].resetFields()
|
this.$refs['rejFormRef'].resetFields()
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
import homePage from './components/message'
|
import homePage from './components/message'
|
||||||
import { connectSocket } from '@/libs/socket'
|
import { connectSocket } from '@/libs/socket'
|
||||||
import { EventBus } from '@/libs/eventBus'
|
import { EventBus } from '@/libs/eventBus'
|
||||||
import { getUnreturnedPriceCount } from '@/api/businessManage/inquiry'
|
import { getUnreturnedPriceCount, getEstimatePendingCount, getSurveyFollowCount } from '@/api/businessManage/inquiry'
|
||||||
export default {
|
export default {
|
||||||
components: { homePage },
|
components: { homePage },
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -35,6 +35,10 @@ export default {
|
|||||||
|
|
||||||
// 获取未回价数量
|
// 获取未回价数量
|
||||||
this.getUnreturnedPriceCountData()
|
this.getUnreturnedPriceCountData()
|
||||||
|
// 获取预估制作数量
|
||||||
|
this.getEstimatePendingCountData()
|
||||||
|
// 获取查勘跟进中数量
|
||||||
|
this.getSurveyFollowCountData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 获取未回价数量
|
// 获取未回价数量
|
||||||
@@ -50,6 +54,41 @@ export default {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取未回价数量失败:', error)
|
console.error('获取未回价数量失败:', error)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// 获取预估制作数量
|
||||||
|
async getEstimatePendingCountData() {
|
||||||
|
try {
|
||||||
|
const response = await getEstimatePendingCount()
|
||||||
|
if (response && response.code === 1) {
|
||||||
|
const data = response.data || {}
|
||||||
|
const counts = {
|
||||||
|
pending: data.pending || 0,
|
||||||
|
secondReview: data.secondReview || 0,
|
||||||
|
thirdReview: data.thirdReview || 0,
|
||||||
|
sign: data.sign || 0,
|
||||||
|
total: data.total || 0
|
||||||
|
}
|
||||||
|
console.log('预估制作数量:', counts)
|
||||||
|
// 通过事件总线传递数量给菜单组件
|
||||||
|
EventBus.$emit('updateEstimatePendingCount', counts)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取预估制作数量失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 获取查勘跟进中数量
|
||||||
|
async getSurveyFollowCountData() {
|
||||||
|
try {
|
||||||
|
const response = await getSurveyFollowCount()
|
||||||
|
if (response && response.code === 1) {
|
||||||
|
const count = response.data.count || 0
|
||||||
|
console.log('查勘跟进中数量:', count)
|
||||||
|
// 通过事件总线传递数量给菜单组件
|
||||||
|
EventBus.$emit('updateSurveyFollowCount', count)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取查勘跟进中数量失败:', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,8 +160,10 @@ import {
|
|||||||
reqBankList,
|
reqBankList,
|
||||||
getProduct,
|
getProduct,
|
||||||
consultFiles,
|
consultFiles,
|
||||||
|
getSurveyFollowCount
|
||||||
} from '@/api/businessManage/inquiry'
|
} from '@/api/businessManage/inquiry'
|
||||||
import { reqDistrict } from '@/api/basicData'
|
import { reqDistrict } from '@/api/basicData'
|
||||||
|
import { EventBus } from '@/libs/eventBus'
|
||||||
import search from '@/mixins/search'
|
import search from '@/mixins/search'
|
||||||
import { getRole } from '@/api/surveyManage'
|
import { getRole } from '@/api/surveyManage'
|
||||||
import { getNowFormatDate } from '@/libs/tools'
|
import { getNowFormatDate } from '@/libs/tools'
|
||||||
@@ -1783,11 +1785,26 @@ export default {
|
|||||||
|
|
||||||
// init data
|
// init data
|
||||||
this.initData()
|
this.initData()
|
||||||
|
|
||||||
|
// 刷新查勘跟进中数量
|
||||||
|
this.refreshSurveyFollowCount()
|
||||||
} else {
|
} else {
|
||||||
this.$Message.error(res.msg)
|
this.$Message.error(res.msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 刷新查勘跟进中数量
|
||||||
|
async refreshSurveyFollowCount() {
|
||||||
|
try {
|
||||||
|
const res = await getSurveyFollowCount()
|
||||||
|
if (res && res.code === 1 && res.data) {
|
||||||
|
const count = res.data.count || 0
|
||||||
|
EventBus.$emit('updateSurveyFollowCount', count)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('刷新查勘跟进中数量失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
onCancelRejPress () {
|
onCancelRejPress () {
|
||||||
this.rejectModal = false
|
this.rejectModal = false
|
||||||
this.$refs['rejFormRef'].resetFields()
|
this.$refs['rejFormRef'].resetFields()
|
||||||
|
|||||||
Reference in New Issue
Block a user