Browse Source

修改 bug

master
王泽彦 6 months ago
parent
commit
1ef0881e92
  1. 26
      niucloud/app/job/transfer/schedule/PerformanceCalculation.php
  2. 22
      niucloud/app/model/customer_resources/CustomerResources.php
  3. 13
      niucloud/app/service/admin/customer_resources/CustomerResourcesService.php
  4. 280
      niucloud/app/service/api/apiService/ResourceSharingService.php
  5. 59
      uniapp/pages-market/clue/index.vue

26
niucloud/app/job/transfer/schedule/PerformanceCalculation.php

@ -5,7 +5,7 @@ namespace app\job\transfer\schedule;
use app\model\course\Course; use app\model\course\Course;
use app\model\order_table\OrderTable; use app\model\order_table\OrderTable;
use app\model\personnel\Personnel; use app\model\personnel\Personnel;
use app\model\resource_sharing\ResourceSharing; use app\model\resource_assignment\ResourceAssignment;
use app\model\six_speed\SixSpeed; use app\model\six_speed\SixSpeed;
use app\model\customer_resources\CustomerResources; use app\model\customer_resources\CustomerResources;
use app\service\admin\performance\PerformanceService; use app\service\admin\performance\PerformanceService;
@ -343,19 +343,20 @@ class PerformanceCalculation extends BaseJob
return false; return false;
} }
// 查询资源共享表中的记录 // 查询资源分配表中的记录
$resourceSharing = ResourceSharing::where('resource_id', $order['resource_id']) $resourceAssignment = ResourceAssignment::where('resource_id', $order['resource_id'])
->where('shared_by', '<>', 0) ->where('assigned_by', '<>', 0)
->where('assignee_type', 'user')
->order('id', 'asc') ->order('id', 'asc')
->find(); ->find();
// 如果没有找到资源共享记录,则不是多人介入 // 如果没有找到资源分配记录,则不是多人介入
if (empty($resourceSharing)) { if (empty($resourceAssignment)) {
return false; return false;
} }
// 如果资源共享记录中的user_id与订单的staff_id不同,则是多人介入 // 如果资源分配记录中的assignee_id与订单的staff_id不同,则是多人介入
return $resourceSharing['user_id'] != $order['staff_id']; return $resourceAssignment['assignee_id'] != $order['staff_id'];
} }
/** /**
@ -370,9 +371,10 @@ class PerformanceCalculation extends BaseJob
$resourceId = $order['resource_id']; $resourceId = $order['resource_id'];
$staffId = $order['staff_id']; $staffId = $order['staff_id'];
// 查询资源共享表中的记录(资源归属人) // 查询资源分配表中的记录(资源归属人)
$resourceOwner = ResourceSharing::where('resource_id', $resourceId) $resourceOwner = ResourceAssignment::where('resource_id', $resourceId)
->where('shared_by', '<>', 0) ->where('assigned_by', '<>', 0)
->where('assignee_type', 'user')
->order('id', 'asc') ->order('id', 'asc')
->find(); ->find();
@ -381,7 +383,7 @@ class PerformanceCalculation extends BaseJob
return []; return [];
} }
$resourceOwnerId = $resourceOwner['user_id']; $resourceOwnerId = $resourceOwner['assignee_id'];
// 查询六速表中的访问记录 // 查询六速表中的访问记录
$sixSpeed = SixSpeed::where('resource_id', $resourceId)->find(); $sixSpeed = SixSpeed::where('resource_id', $resourceId)->find();

22
niucloud/app/model/customer_resources/CustomerResources.php

@ -13,7 +13,7 @@ namespace app\model\customer_resources;
use app\model\dict\Dict; use app\model\dict\Dict;
use app\model\order_table\OrderTable; use app\model\order_table\OrderTable;
use app\model\resource_sharing\ResourceSharing; use app\model\resource_assignment\ResourceAssignment;
use app\model\six_speed\SixSpeed; use app\model\six_speed\SixSpeed;
use core\base\BaseModel; use core\base\BaseModel;
use think\db\Query; use think\db\Query;
@ -149,6 +149,18 @@ class CustomerResources extends BaseModel
} }
} }
/**
* 搜索器:黑名单状态
* @param $value
* @param $data
*/
public function searchBlacklistAttr($query, $value, $data)
{
if ($value !== '' && $value !== null) {
$query->where("blacklist", $value);
}
}
public function member(){ public function member(){
return $this->hasOne(Member::class, 'member_id', 'member_id'); return $this->hasOne(Member::class, 'member_id', 'member_id');
@ -167,8 +179,8 @@ class CustomerResources extends BaseModel
public function resourceSharing() public function resourceSharing()
{ {
return $this->hasOne(ResourceSharing::class, 'resource_id', 'resource_id')->joinType('left') return $this->hasOne(ResourceAssignment::class, 'resource_id', 'resource_id')->joinType('left')
->withField('id as sharin_id,shared_by'); ->withField('id as sharing_id,assigned_by as shared_by');
} }
@ -178,10 +190,10 @@ class CustomerResources extends BaseModel
return $this->hasOne(SixSpeed::class, 'resource_id', 'id'); return $this->hasOne(SixSpeed::class, 'resource_id', 'id');
} }
//一对多关联"资源共享表" //一对多关联"资源分配表"
public function resourceSharingHasMany() public function resourceSharingHasMany()
{ {
return $this->hasMany(ResourceSharing::class, 'resource_id', 'id'); return $this->hasMany(ResourceAssignment::class, 'resource_id', 'id');
} }
//一对一关联"用户账号登陆表" //一对一关联"用户账号登陆表"

13
niucloud/app/service/admin/customer_resources/CustomerResourcesService.php

@ -74,7 +74,7 @@ class CustomerResourcesService extends BaseAdminService
} }
if ($data['type'] == 'yjfp') { if ($data['type'] == 'yjfp') {
$where[] = ['b.shared_by', '=', 0]; $where[] = ['b.assigned_by', '=', 0];
} }
if ($data['member_label']) { if ($data['member_label']) {
@ -88,7 +88,7 @@ class CustomerResourcesService extends BaseAdminService
$search_model = $this->model $search_model = $this->model
->alias("a") ->alias("a")
->join(['school_resource_sharing' => 'b'], 'a.id = b.resource_id', 'left') ->join(['school_resource_assignment' => 'b'], 'a.id = b.resource_id', 'left')
->join(['school_campus' => 'c'], 'a.campus = c.id', 'left') ->join(['school_campus' => 'c'], 'a.campus = c.id', 'left')
->where($where) ->where($where)
->with(['personnel']) ->with(['personnel'])
@ -381,10 +381,11 @@ class CustomerResourcesService extends BaseAdminService
public function fp_edit($data) public function fp_edit($data)
{ {
$resourceSharing = new ResourceSharing(); // 使用 ResourceAssignment 表替代 ResourceSharing 表
$resourceSharing->where(['id' => $data['shared_id']])->update([ $resourceAssignment = new \app\model\resource_assignment\ResourceAssignment();
'shared_by' => $data['shared_by'], $resourceAssignment->where(['id' => $data['shared_id']])->update([
'shared_at' => date("Y-m-d H:i:s") 'assigned_by' => $data['shared_by'],
'assigned_at' => date("Y-m-d H:i:s")
]); ]);
return "分配成功"; return "分配成功";
} }

280
niucloud/app/service/api/apiService/ResourceSharingService.php

@ -155,10 +155,9 @@ class ResourceSharingService extends BaseApiService
return $model; return $model;
} }
//查询资源共享详情 //查询资源共享详情 - 修改为使用 ResourceAssignment 表
public function info(array $where, string $field = '*') public function info(array $where, string $field = '*')
{ {
$res = [ $res = [
'code' => 0, 'code' => 0,
'msg' => '操作失败', 'msg' => '操作失败',
@ -169,7 +168,8 @@ class ResourceSharingService extends BaseApiService
return $res; return $res;
} }
$model = $this->model; // 使用 ResourceAssignment 表查询,resource_sharing_id 现在是 assignment 表的 id
$model = $this->assignmentModel;
if (!empty($where['id'])) { if (!empty($where['id'])) {
$model = $model->where('id', $where['id']); $model = $model->where('id', $where['id']);
@ -197,9 +197,11 @@ class ResourceSharingService extends BaseApiService
]); ]);
} }
])->field($field)->find(); ])->field($field)->find();
if ($data) { if ($data) {
$data = $data->toArray(); $data = $data->toArray();
} }
if (!empty($data['customerResource'])) { if (!empty($data['customerResource'])) {
$data['customerResource']['cj_count'] = OrderTable::where('resource_id', $data['customerResource']['id']) $data['customerResource']['cj_count'] = OrderTable::where('resource_id', $data['customerResource']['id'])
->where('order_status', 'paid') ->where('order_status', 'paid')
@ -207,6 +209,13 @@ class ResourceSharingService extends BaseApiService
} }
if ($data) { if ($data) {
// 添加兼容字段
$data['resource_sharing_id'] = $data['id']; // assignment 表的 id
$data['user_id'] = ($data['assignee_type'] ?? '') === 'user' ? (int) $data['assignee_id'] : 0;
$data['role_id'] = ($data['assignee_type'] ?? '') === 'role' ? (int) $data['assignee_id'] : 0;
$data['shared_by'] = (int) ($data['assigned_by'] ?? 0);
$data['shared_at'] = $data['assigned_at'] ?? null;
$res['code'] = 1; $res['code'] = 1;
$res['msg'] = '操作成功'; $res['msg'] = '操作成功';
$res['data'] = $data; $res['data'] = $data;
@ -339,6 +348,16 @@ class ResourceSharingService extends BaseApiService
$resource_conditions[] = ['source_channel', 'like', '%' . $where['source_channel'] . '%']; $resource_conditions[] = ['source_channel', 'like', '%' . $where['source_channel'] . '%'];
} }
// 年龄查询
if (isset($where['age']) && $where['age'] !== '' && $where['age'] !== null) {
$resource_conditions[] = ['age', '=', $where['age']];
}
// 黑名单状态查询
if (isset($where['blacklist']) && $where['blacklist'] !== '' && $where['blacklist'] !== null) {
$resource_conditions[] = ['blacklist', '=', $where['blacklist']];
}
// 查询符合条件的资源ID // 查询符合条件的资源ID
$resource_ids = []; $resource_ids = [];
if (!empty($resource_conditions)) { if (!empty($resource_conditions)) {
@ -353,7 +372,7 @@ class ResourceSharingService extends BaseApiService
'data' => [] 'data' => []
]; ];
} }
$model = $model->whereIn('ra.resource_id', $resource_ids); $model = $model->whereIn('resource_id', $resource_ids);
} }
// 共享时间查询 // 共享时间查询
@ -387,7 +406,7 @@ class ResourceSharingService extends BaseApiService
'data' => [] 'data' => []
]; ];
} }
$model = $model->whereIn('ra.resource_id', $resource_ids); $model = $model->whereIn('resource_id', $resource_ids);
} }
} }
@ -424,7 +443,7 @@ class ResourceSharingService extends BaseApiService
'data' => [] 'data' => []
]; ];
} }
$model = $model->whereIn('ra.resource_id', $resource_ids); $model = $model->whereIn('resource_id', $resource_ids);
} }
} }
@ -455,7 +474,7 @@ class ResourceSharingService extends BaseApiService
'data' => [] 'data' => []
]; ];
} }
$model = $model->whereIn('ra.resource_id', $resource_ids); $model = $model->whereIn('resource_id', $resource_ids);
} }
} }
@ -497,7 +516,63 @@ class ResourceSharingService extends BaseApiService
'data' => [] 'data' => []
]; ];
} }
$model = $model->whereIn('ra.resource_id', $resource_ids); $model = $model->whereIn('resource_id', $resource_ids);
}
}
// 处理课程搜索查询 - 通过订单表关联课程表查询
if (!empty($where['course_search'])) {
// 通过订单表关联查询包含指定课程的资源ID
$order_model = new OrderTable();
// 先查询课程表中匹配的课程ID
$course_ids = \app\model\school\Course::where('course_name', 'like', '%' . $where['course_search'] . '%')
->column('course_id');
if (!empty($course_ids)) {
// 查询订单表中包含这些课程的订单
$course_resource_ids = $order_model->whereIn('course_id', $course_ids)
->distinct(true)
->column('resource_id');
if (empty($course_resource_ids)) {
// 没有匹配的资源,返回空结果
return [
'count' => 0,
'total' => 0,
'current_page' => $page,
'last_page' => 0,
'data' => []
];
}
} else {
// 没有匹配的课程,返回空结果
return [
'count' => 0,
'total' => 0,
'current_page' => $page,
'last_page' => 0,
'data' => []
];
}
if (isset($course_resource_ids)) {
if (empty($resource_ids)) {
$resource_ids = $course_resource_ids;
} else {
$resource_ids = array_intersect($resource_ids, $course_resource_ids);
}
if (empty($resource_ids)) {
return [
'count' => 0,
'total' => 0,
'current_page' => $page,
'last_page' => 0,
'data' => []
];
}
$model = $model->whereIn('resource_id', $resource_ids);
} }
} }
@ -531,28 +606,7 @@ class ResourceSharingService extends BaseApiService
$resource_ids = array_column($list['data'], 'resource_id'); $resource_ids = array_column($list['data'], 'resource_id');
$resource_ids = array_unique(array_filter($resource_ids)); $resource_ids = array_unique(array_filter($resource_ids));
// 映射 legacy 表中的资源共享记录 ID,兼容旧接口依赖 // resource_sharing_id 现在直接使用 ResourceAssignment 表的 id,不需要映射
$resource_sharing_map = [];
if (!empty($resource_ids)) {
$legacy_records = $this->model
->whereIn('resource_id', $resource_ids)
->order('id', 'desc')
->field('resource_id, id')
->select()
->toArray();
foreach ($legacy_records as $record) {
$resourceId = (int) ($record['resource_id'] ?? 0);
$recordId = (int) ($record['id'] ?? 0);
if ($resourceId === 0 || $recordId === 0) {
continue;
}
if (!isset($resource_sharing_map[$resourceId])) {
$resource_sharing_map[$resourceId] = $recordId;
}
}
}
// 获取分配人员ID列表 // 获取分配人员ID列表
$shared_by_ids = array_column($list['data'], 'assigned_by'); $shared_by_ids = array_column($list['data'], 'assigned_by');
$shared_by_ids = array_unique(array_filter($shared_by_ids)); $shared_by_ids = array_unique(array_filter($shared_by_ids));
@ -745,9 +799,8 @@ class ResourceSharingService extends BaseApiService
// 处理每条数据 // 处理每条数据
foreach ($list['data'] as &$item) { foreach ($list['data'] as &$item) {
$resourceId = (int) ($item['resource_id'] ?? 0); // resource_sharing_id 现在直接使用 ResourceAssignment 表的 id
$legacyResourceSharingId = $resource_sharing_map[$resourceId] ?? null; $item['resource_sharing_id'] = (int) ($item['id'] ?? 0);
$item['resource_sharing_id'] = $legacyResourceSharingId;
if (!empty($item['customerResource'])) { if (!empty($item['customerResource'])) {
// 确保数据类型转换:数据库中的数值需要转换为字符串 // 确保数据类型转换:数据库中的数值需要转换为字符串
@ -759,9 +812,8 @@ class ResourceSharingService extends BaseApiService
$item['customerResource']['source_channel'] = get_dict_value('SourceChannel', $source_channel_value); $item['customerResource']['source_channel'] = get_dict_value('SourceChannel', $source_channel_value);
$item['customerResource']['campus_name'] = $campus_names[$item['customerResource']['campus']] ?? ''; $item['customerResource']['campus_name'] = $campus_names[$item['customerResource']['campus']] ?? '';
if ($legacyResourceSharingId !== null) { // customerResource 中的 resource_sharing_id 也使用 assignment 表的 id
$item['customerResource']['resource_sharing_id'] = $legacyResourceSharingId; $item['customerResource']['resource_sharing_id'] = (int) ($item['id'] ?? 0);
}
if (!empty($item['customerResource']['consultant'])) { if (!empty($item['customerResource']['consultant'])) {
$item['customerResource']['consultant_name'] = $consultant_names[$item['customerResource']['consultant']] ?? ''; $item['customerResource']['consultant_name'] = $consultant_names[$item['customerResource']['consultant']] ?? '';
@ -940,6 +992,16 @@ class ResourceSharingService extends BaseApiService
$resource_conditions[] = ['source_channel', 'like', '%' . $where['source_channel'] . '%']; $resource_conditions[] = ['source_channel', 'like', '%' . $where['source_channel'] . '%'];
} }
// 年龄查询
if (isset($where['age']) && $where['age'] !== '' && $where['age'] !== null) {
$resource_conditions[] = ['age', '=', $where['age']];
}
// 黑名单状态查询
if (isset($where['blacklist']) && $where['blacklist'] !== '' && $where['blacklist'] !== null) {
$resource_conditions[] = ['blacklist', '=', $where['blacklist']];
}
// 查询符合条件的资源ID // 查询符合条件的资源ID
$resource_ids = []; $resource_ids = [];
if (!empty($resource_conditions)) { if (!empty($resource_conditions)) {
@ -954,7 +1016,7 @@ class ResourceSharingService extends BaseApiService
'data' => [] 'data' => []
]; ];
} }
$model = $model->whereIn('ra.resource_id', $resource_ids); $model = $model->whereIn('resource_id', $resource_ids);
} }
// 共享时间查询 // 共享时间查询
@ -988,7 +1050,7 @@ class ResourceSharingService extends BaseApiService
'data' => [] 'data' => []
]; ];
} }
$model = $model->whereIn('ra.resource_id', $resource_ids); $model = $model->whereIn('resource_id', $resource_ids);
} }
} }
@ -1025,7 +1087,7 @@ class ResourceSharingService extends BaseApiService
'data' => [] 'data' => []
]; ];
} }
$model = $model->whereIn('ra.resource_id', $resource_ids); $model = $model->whereIn('resource_id', $resource_ids);
} }
} }
@ -1056,7 +1118,63 @@ class ResourceSharingService extends BaseApiService
'data' => [] 'data' => []
]; ];
} }
$model = $model->whereIn('ra.resource_id', $resource_ids); $model = $model->whereIn('resource_id', $resource_ids);
}
}
// 处理课程搜索查询 - 通过订单表关联课程表查询
if (!empty($where['course_search'])) {
// 通过订单表关联查询包含指定课程的资源ID
$order_model = new OrderTable();
// 先查询课程表中匹配的课程ID
$course_ids = \app\model\school\Course::where('course_name', 'like', '%' . $where['course_search'] . '%')
->column('course_id');
if (!empty($course_ids)) {
// 查询订单表中包含这些课程的订单
$course_resource_ids = $order_model->whereIn('course_id', $course_ids)
->distinct(true)
->column('resource_id');
if (empty($course_resource_ids)) {
// 没有匹配的资源,返回空结果
return [
'count' => 0,
'total' => 0,
'current_page' => $page,
'last_page' => 0,
'data' => []
];
}
} else {
// 没有匹配的课程,返回空结果
return [
'count' => 0,
'total' => 0,
'current_page' => $page,
'last_page' => 0,
'data' => []
];
}
if (isset($course_resource_ids)) {
if (empty($resource_ids)) {
$resource_ids = $course_resource_ids;
} else {
$resource_ids = array_intersect($resource_ids, $course_resource_ids);
}
if (empty($resource_ids)) {
return [
'count' => 0,
'total' => 0,
'current_page' => $page,
'last_page' => 0,
'data' => []
];
}
$model = $model->whereIn('resource_id', $resource_ids);
} }
} }
@ -1102,6 +1220,7 @@ class ResourceSharingService extends BaseApiService
$resource_ids = array_column($list['data'], 'resource_id'); $resource_ids = array_column($list['data'], 'resource_id');
$resource_ids = array_unique(array_filter($resource_ids)); $resource_ids = array_unique(array_filter($resource_ids));
// resource_sharing_id 现在直接使用 ResourceAssignment 表的 id,不需要映射
// 获取分配人员ID列表 // 获取分配人员ID列表
$shared_by_ids = array_column($list['data'], 'shared_by'); $shared_by_ids = array_column($list['data'], 'shared_by');
$shared_by_ids = array_unique(array_filter($shared_by_ids)); $shared_by_ids = array_unique(array_filter($shared_by_ids));
@ -1294,7 +1413,12 @@ class ResourceSharingService extends BaseApiService
// 处理每条数据 // 处理每条数据
foreach ($list['data'] as &$item) { foreach ($list['data'] as &$item) {
// resource_sharing_id 现在直接使用 ResourceAssignment 表的 id
$item['resource_sharing_id'] = (int) ($item['id'] ?? 0);
if (!empty($item['customerResource'])) { if (!empty($item['customerResource'])) {
// customerResource 中的 resource_sharing_id 也使用 assignment 表的 id
$item['customerResource']['resource_sharing_id'] = (int) ($item['id'] ?? 0);
// 确保数据类型转换:数据库中的数值需要转换为字符串 // 确保数据类型转换:数据库中的数值需要转换为字符串
$source_value = (string) $item['customerResource']['source']; $source_value = (string) $item['customerResource']['source'];
$source_channel_value = (string) $item['customerResource']['source_channel']; $source_channel_value = (string) $item['customerResource']['source_channel'];
@ -1442,27 +1566,88 @@ class ResourceSharingService extends BaseApiService
/** /**
* 兼容旧接口的资源分配方法 * 兼容旧接口的资源分配方法
* @param int $resource_sharing_id 旧表记录ID(实际为resource_id) * @param int $resource_sharing_id 现在是 ResourceAssignment 表的 ID
* @param int $shared_by 分配给的用户ID * @param int $shared_by 分配给的用户ID
* @return array * @return array
*/ */
public function assignResourceLegacy(int $resource_sharing_id, int $shared_by): array public function assignResourceLegacy(int $resource_sharing_id, int $shared_by): array
{ {
// 首先检查旧表中的记录,获取resource_id // 检查 ResourceAssignment 表中是否存在该记录
$old_record = $this->model->where('id', $resource_sharing_id)->find(); $assignment_record = $this->assignmentModel->where('id', $resource_sharing_id)->find();
if (!$old_record) { if (!$assignment_record) {
return [ return [
'code' => 0, 'code' => 0,
'msg' => '资源记录不存在', 'msg' => '资源分配记录不存在',
'data' => [] 'data' => []
]; ];
} }
$resource_id = $old_record['resource_id']; $resource_id = $assignment_record['resource_id'];
$campus_id = $assignment_record['campus_id'];
// 使用新的分配方法 // 使用新的分配方法
return $this->assignResource($resource_id, 'user', $shared_by, true, $old_record['campus_id']); return $this->assignResource($resource_id, 'user', $shared_by, true, $campus_id);
}
/**
* 确保资源的 resource_sharing_id 映射存在
* @param array $resource_ids 资源ID数组
* @return array resource_id => resource_sharing_id 的映射
*/
protected function ensureResourceSharingIdMap(array $resource_ids): array
{
$resource_sharing_map = [];
if (empty($resource_ids)) {
return $resource_sharing_map;
}
// 查询现有的 legacy 记录
$legacy_records = $this->model
->whereIn('resource_id', $resource_ids)
->order('id', 'desc')
->field('resource_id, id')
->select()
->toArray();
foreach ($legacy_records as $record) {
$resourceId = (int) ($record['resource_id'] ?? 0);
$recordId = (int) ($record['id'] ?? 0);
if ($resourceId === 0 || $recordId === 0) {
continue;
}
if (!isset($resource_sharing_map[$resourceId])) {
$resource_sharing_map[$resourceId] = $recordId;
}
}
// 对于没有 legacy 记录的资源,自动创建或使用兜底方案
foreach ($resource_ids as $resource_id) {
$resource_id = (int) $resource_id;
if (!isset($resource_sharing_map[$resource_id])) {
// 尝试创建一条新的 legacy 记录以确保兼容性
try {
$new_legacy_record = [
'resource_id' => $resource_id,
'user_id' => 0,
'role_id' => 0,
'shared_by' => 0,
'shared_at' => date('Y-m-d H:i:s'),
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
];
$inserted_id = $this->model->insertGetId($new_legacy_record);
if ($inserted_id) {
$resource_sharing_map[$resource_id] = (int) $inserted_id;
}
} catch (\Exception $e) {
// 如果创建失败,使用 resource_id 作为兜底(确保总有值返回)
$resource_sharing_map[$resource_id] = $resource_id;
}
}
}
return $resource_sharing_map;
} }
/** /**
@ -1502,4 +1687,5 @@ class ResourceSharingService extends BaseApiService
return $assignments; return $assignments;
} }
} }

59
uniapp/pages-market/clue/index.vue

@ -294,7 +294,9 @@
<view class="popup_filter_row" v-if="sourceIndex === 1"> <view class="popup_filter_row" v-if="sourceIndex === 1">
<view class="popup_filter_item full_width"> <view class="popup_filter_item full_width">
<text class="popup_filter_label">来源渠道</text> <text class="popup_filter_label">来源渠道</text>
<input class="popup_filter_input" placeholder="来源渠道" v-model="searchForm.source_channel" /> <picker :value="sourceChannelIndex" :range="sourceChannelOptions" @change="onSourceChannelChange">
<view class="popup_filter_picker">{{ sourceChannelOptions[sourceChannelIndex] }}</view>
</picker>
</view> </view>
</view> </view>
</view> </view>
@ -469,6 +471,8 @@
sourceIndex: 0, sourceIndex: 0,
sourceOptions: ['全部', '线上', '线下'], // sourceOptions: ['全部', '线上', '线下'], //
sourceDict: {}, // ID sourceDict: {}, // ID
sourceChannelIndex: 0,
sourceChannelOptions: ['全部'], //
sourceChannelDict: {}, // ID sourceChannelDict: {}, // ID
attendanceIndex: 0, attendanceIndex: 0,
attendanceOptions: ['全部', '一访未到', '一访已到', '二访未到', '二访已到', '未到访'], attendanceOptions: ['全部', '一访未到', '一访已到', '二访未到', '二访已到', '未到访'],
@ -645,11 +649,12 @@
if (channelRes.code === 1 && channelRes.data) { if (channelRes.code === 1 && channelRes.data) {
// 使 // 使
const channelData = channelRes.data const channelData = channelRes.data
this.sourceChannelOptions = ['全部', ...channelData.map(item => item.name)]
this.sourceChannelDict = channelData.reduce((acc, item) => { this.sourceChannelDict = channelData.reduce((acc, item) => {
acc[item.name] = item.value acc[item.name] = item.value
return acc return acc
}, {}) }, {})
console.log('渠道字典加载成功:', this.sourceChannelDict) console.log('渠道字典加载成功:', this.sourceChannelOptions, this.sourceChannelDict)
} }
} catch (error) { } catch (error) {
console.error('字典数据加载失败:', error) console.error('字典数据加载失败:', error)
@ -1180,16 +1185,20 @@
currentFilterData.shared_at_str = '' currentFilterData.shared_at_str = ''
} }
// //
if (this.searchForm.source && this.searchForm.source !== '全部') { if (this.searchForm.source && this.searchForm.source !== '全部') {
currentFilterData.source = this.searchForm.source // 使
currentFilterData.source = this.sourceDict[this.searchForm.source] || this.searchForm.source
console.log('source字段转换:', this.searchForm.source, '->', currentFilterData.source)
} else { } else {
currentFilterData.source = '' currentFilterData.source = ''
} }
// //
if (this.searchForm.source_channel) { if (this.searchForm.source_channel && this.searchForm.source_channel !== '全部') {
currentFilterData.source_channel = this.searchForm.source_channel // 使
currentFilterData.source_channel = this.sourceChannelDict[this.searchForm.source_channel] || this.searchForm.source_channel
console.log('source_channel字段转换:', this.searchForm.source_channel, '->', currentFilterData.source_channel)
} else { } else {
currentFilterData.source_channel = '' currentFilterData.source_channel = ''
} }
@ -1232,9 +1241,10 @@
currentFilterData.age = '' currentFilterData.age = ''
} }
// //
if (this.searchForm.blacklist) { if (this.searchForm.blacklist && this.searchForm.blacklist !== '') {
currentFilterData.blacklist = this.searchForm.blacklist currentFilterData.blacklist = this.searchForm.blacklist
console.log('blacklist字段设置:', this.searchForm.blacklist)
} else { } else {
currentFilterData.blacklist = '' currentFilterData.blacklist = ''
} }
@ -1276,9 +1286,17 @@
// 线 // 线
if (this.sourceIndex !== 1) { if (this.sourceIndex !== 1) {
this.searchForm.source_channel = '' this.searchForm.source_channel = ''
this.sourceChannelIndex = 0
} }
}, },
//
onSourceChannelChange(e) {
this.sourceChannelIndex = e.detail.value
this.searchForm.source_channel = this.sourceChannelOptions[this.sourceChannelIndex]
console.log('来源渠道选择器变化:', e.detail.value, '选择的内容:', this.searchForm.source_channel)
},
// //
onAttendanceChange(e) { onAttendanceChange(e) {
this.attendanceIndex = e.detail.value this.attendanceIndex = e.detail.value
@ -1339,6 +1357,7 @@
blacklist: '' // blacklist: '' //
} }
this.sourceIndex = 0 this.sourceIndex = 0
this.sourceChannelIndex = 0 //
this.attendanceIndex = 0 this.attendanceIndex = 0
this.dealIndex = 0 this.dealIndex = 0
this.validIndex = 0 this.validIndex = 0
@ -1382,6 +1401,13 @@
extractResourceSharingId(item) { extractResourceSharingId(item) {
if (!item || typeof item !== 'object') return '' if (!item || typeof item !== 'object') return ''
//
console.log('extractResourceSharingId 调试 - 输入item:', item)
console.log('extractResourceSharingId 调试 - item.resource_sharing_id:', item.resource_sharing_id)
console.log('extractResourceSharingId 调试 - item.customerResource:', item.customerResource)
console.log('extractResourceSharingId 调试 - item.customerResource?.resource_sharing_id:', item.customerResource?.resource_sharing_id)
const candidates = [ const candidates = [
item._resourceSharingId, item._resourceSharingId,
item.resource_sharing_id, item.resource_sharing_id,
@ -1392,18 +1418,31 @@
item?.customerResource?.resourceSharing?.sharin_id, item?.customerResource?.resourceSharing?.sharin_id,
item?.customerResource?.resourceSharing?.id item?.customerResource?.resourceSharing?.id
] ]
for (const candidate of candidates) {
console.log('extractResourceSharingId 调试 - candidates:', candidates)
for (let i = 0; i < candidates.length; i++) {
const candidate = candidates[i]
console.log(`extractResourceSharingId 调试 - candidate[${i}]:`, candidate, typeof candidate, candidate !== undefined && candidate !== null && candidate !== '')
if (candidate !== undefined && candidate !== null && candidate !== '') { if (candidate !== undefined && candidate !== null && candidate !== '') {
console.log('extractResourceSharingId 调试 - 找到有效ID:', String(candidate))
return String(candidate) return String(candidate)
} }
} }
const relationList = item?.customerResource?.resourceSharingHasMany || item?.resourceSharingHasMany const relationList = item?.customerResource?.resourceSharingHasMany || item?.resourceSharingHasMany
console.log('extractResourceSharingId 调试 - relationList:', relationList)
if (Array.isArray(relationList) && relationList.length > 0) { if (Array.isArray(relationList) && relationList.length > 0) {
const maybeId = relationList[0]?.id ?? relationList[0]?.resource_sharing_id const maybeId = relationList[0]?.id ?? relationList[0]?.resource_sharing_id
console.log('extractResourceSharingId 调试 - relationList中的ID:', maybeId)
if (maybeId !== undefined && maybeId !== null && maybeId !== '') { if (maybeId !== undefined && maybeId !== null && maybeId !== '') {
console.log('extractResourceSharingId 调试 - 从relationList找到ID:', String(maybeId))
return String(maybeId) return String(maybeId)
} }
} }
console.log('extractResourceSharingId 调试 - 未找到任何有效ID,返回空字符串')
return '' return ''
}, },

Loading…
Cancel
Save