diff --git a/niucloud/app/job/transfer/schedule/PerformanceCalculation.php b/niucloud/app/job/transfer/schedule/PerformanceCalculation.php index f3c32020..68c83c36 100644 --- a/niucloud/app/job/transfer/schedule/PerformanceCalculation.php +++ b/niucloud/app/job/transfer/schedule/PerformanceCalculation.php @@ -5,7 +5,7 @@ namespace app\job\transfer\schedule; use app\model\course\Course; use app\model\order_table\OrderTable; 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\customer_resources\CustomerResources; use app\service\admin\performance\PerformanceService; @@ -343,19 +343,20 @@ class PerformanceCalculation extends BaseJob return false; } - // 查询资源共享表中的记录 - $resourceSharing = ResourceSharing::where('resource_id', $order['resource_id']) - ->where('shared_by', '<>', 0) + // 查询资源分配表中的记录 + $resourceAssignment = ResourceAssignment::where('resource_id', $order['resource_id']) + ->where('assigned_by', '<>', 0) + ->where('assignee_type', 'user') ->order('id', 'asc') ->find(); - - // 如果没有找到资源共享记录,则不是多人介入 - if (empty($resourceSharing)) { + + // 如果没有找到资源分配记录,则不是多人介入 + if (empty($resourceAssignment)) { return false; } - - // 如果资源共享记录中的user_id与订单的staff_id不同,则是多人介入 - return $resourceSharing['user_id'] != $order['staff_id']; + + // 如果资源分配记录中的assignee_id与订单的staff_id不同,则是多人介入 + return $resourceAssignment['assignee_id'] != $order['staff_id']; } /** @@ -370,18 +371,19 @@ class PerformanceCalculation extends BaseJob $resourceId = $order['resource_id']; $staffId = $order['staff_id']; - // 查询资源共享表中的记录(资源归属人) - $resourceOwner = ResourceSharing::where('resource_id', $resourceId) - ->where('shared_by', '<>', 0) + // 查询资源分配表中的记录(资源归属人) + $resourceOwner = ResourceAssignment::where('resource_id', $resourceId) + ->where('assigned_by', '<>', 0) + ->where('assignee_type', 'user') ->order('id', 'asc') ->find(); - + if (empty($resourceOwner)) { Log::write('未找到资源归属人,订单ID:' . $order['id']); return []; } - - $resourceOwnerId = $resourceOwner['user_id']; + + $resourceOwnerId = $resourceOwner['assignee_id']; // 查询六速表中的访问记录 $sixSpeed = SixSpeed::where('resource_id', $resourceId)->find(); diff --git a/niucloud/app/model/customer_resources/CustomerResources.php b/niucloud/app/model/customer_resources/CustomerResources.php index 6380ef00..ca4d4da6 100644 --- a/niucloud/app/model/customer_resources/CustomerResources.php +++ b/niucloud/app/model/customer_resources/CustomerResources.php @@ -13,7 +13,7 @@ namespace app\model\customer_resources; use app\model\dict\Dict; 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 core\base\BaseModel; 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(){ return $this->hasOne(Member::class, 'member_id', 'member_id'); @@ -167,8 +179,8 @@ class CustomerResources extends BaseModel public function resourceSharing() { - return $this->hasOne(ResourceSharing::class, 'resource_id', 'resource_id')->joinType('left') - ->withField('id as sharin_id,shared_by'); + return $this->hasOne(ResourceAssignment::class, 'resource_id', 'resource_id')->joinType('left') + ->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'); } - //一对多关联"资源共享表" + //一对多关联"资源分配表" public function resourceSharingHasMany() { - return $this->hasMany(ResourceSharing::class, 'resource_id', 'id'); + return $this->hasMany(ResourceAssignment::class, 'resource_id', 'id'); } //一对一关联"用户账号登陆表" diff --git a/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php b/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php index 0fef21af..58158fe5 100644 --- a/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php +++ b/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php @@ -74,7 +74,7 @@ class CustomerResourcesService extends BaseAdminService } if ($data['type'] == 'yjfp') { - $where[] = ['b.shared_by', '=', 0]; + $where[] = ['b.assigned_by', '=', 0]; } if ($data['member_label']) { @@ -88,7 +88,7 @@ class CustomerResourcesService extends BaseAdminService $search_model = $this->model ->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') ->where($where) ->with(['personnel']) @@ -381,10 +381,11 @@ class CustomerResourcesService extends BaseAdminService public function fp_edit($data) { - $resourceSharing = new ResourceSharing(); - $resourceSharing->where(['id' => $data['shared_id']])->update([ - 'shared_by' => $data['shared_by'], - 'shared_at' => date("Y-m-d H:i:s") + // 使用 ResourceAssignment 表替代 ResourceSharing 表 + $resourceAssignment = new \app\model\resource_assignment\ResourceAssignment(); + $resourceAssignment->where(['id' => $data['shared_id']])->update([ + 'assigned_by' => $data['shared_by'], + 'assigned_at' => date("Y-m-d H:i:s") ]); return "分配成功"; } diff --git a/niucloud/app/service/api/apiService/ResourceSharingService.php b/niucloud/app/service/api/apiService/ResourceSharingService.php index 007f5f9b..5df15c3d 100644 --- a/niucloud/app/service/api/apiService/ResourceSharingService.php +++ b/niucloud/app/service/api/apiService/ResourceSharingService.php @@ -155,10 +155,9 @@ class ResourceSharingService extends BaseApiService return $model; } - //查询资源共享详情 + //查询资源共享详情 - 修改为使用 ResourceAssignment 表 public function info(array $where, string $field = '*') { - $res = [ 'code' => 0, 'msg' => '操作失败', @@ -169,7 +168,8 @@ class ResourceSharingService extends BaseApiService return $res; } - $model = $this->model; + // 使用 ResourceAssignment 表查询,resource_sharing_id 现在是 assignment 表的 id + $model = $this->assignmentModel; if (!empty($where['id'])) { $model = $model->where('id', $where['id']); @@ -197,9 +197,11 @@ class ResourceSharingService extends BaseApiService ]); } ])->field($field)->find(); + if ($data) { $data = $data->toArray(); } + if (!empty($data['customerResource'])) { $data['customerResource']['cj_count'] = OrderTable::where('resource_id', $data['customerResource']['id']) ->where('order_status', 'paid') @@ -207,6 +209,13 @@ class ResourceSharingService extends BaseApiService } 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['msg'] = '操作成功'; $res['data'] = $data; @@ -339,6 +348,16 @@ class ResourceSharingService extends BaseApiService $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 $resource_ids = []; if (!empty($resource_conditions)) { @@ -353,7 +372,7 @@ class ResourceSharingService extends BaseApiService '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' => [] ]; } - $model = $model->whereIn('ra.resource_id', $resource_ids); + $model = $model->whereIn('resource_id', $resource_ids); } } @@ -424,7 +443,7 @@ class ResourceSharingService extends BaseApiService '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' => [] ]; } - $model = $model->whereIn('ra.resource_id', $resource_ids); + $model = $model->whereIn('resource_id', $resource_ids); } } @@ -497,7 +516,63 @@ class ResourceSharingService extends BaseApiService '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_unique(array_filter($resource_ids)); - // 映射 legacy 表中的资源共享记录 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; - } - } - } - + // resource_sharing_id 现在直接使用 ResourceAssignment 表的 id,不需要映射 // 获取分配人员ID列表 $shared_by_ids = array_column($list['data'], 'assigned_by'); $shared_by_ids = array_unique(array_filter($shared_by_ids)); @@ -745,9 +799,8 @@ class ResourceSharingService extends BaseApiService // 处理每条数据 foreach ($list['data'] as &$item) { - $resourceId = (int) ($item['resource_id'] ?? 0); - $legacyResourceSharingId = $resource_sharing_map[$resourceId] ?? null; - $item['resource_sharing_id'] = $legacyResourceSharingId; + // resource_sharing_id 现在直接使用 ResourceAssignment 表的 id + $item['resource_sharing_id'] = (int) ($item['id'] ?? 0); 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']['campus_name'] = $campus_names[$item['customerResource']['campus']] ?? ''; - if ($legacyResourceSharingId !== null) { - $item['customerResource']['resource_sharing_id'] = $legacyResourceSharingId; - } + // customerResource 中的 resource_sharing_id 也使用 assignment 表的 id + $item['customerResource']['resource_sharing_id'] = (int) ($item['id'] ?? 0); if (!empty($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'] . '%']; } + // 年龄查询 + 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 $resource_ids = []; if (!empty($resource_conditions)) { @@ -954,7 +1016,7 @@ class ResourceSharingService extends BaseApiService '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' => [] ]; } - $model = $model->whereIn('ra.resource_id', $resource_ids); + $model = $model->whereIn('resource_id', $resource_ids); } } @@ -1025,7 +1087,7 @@ class ResourceSharingService extends BaseApiService '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' => [] ]; } - $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_unique(array_filter($resource_ids)); + // resource_sharing_id 现在直接使用 ResourceAssignment 表的 id,不需要映射 // 获取分配人员ID列表 $shared_by_ids = array_column($list['data'], 'shared_by'); $shared_by_ids = array_unique(array_filter($shared_by_ids)); @@ -1294,7 +1413,12 @@ class ResourceSharingService extends BaseApiService // 处理每条数据 foreach ($list['data'] as &$item) { + // resource_sharing_id 现在直接使用 ResourceAssignment 表的 id + $item['resource_sharing_id'] = (int) ($item['id'] ?? 0); + 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_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 * @return array */ public function assignResourceLegacy(int $resource_sharing_id, int $shared_by): array { - // 首先检查旧表中的记录,获取resource_id - $old_record = $this->model->where('id', $resource_sharing_id)->find(); + // 检查 ResourceAssignment 表中是否存在该记录 + $assignment_record = $this->assignmentModel->where('id', $resource_sharing_id)->find(); - if (!$old_record) { + if (!$assignment_record) { return [ 'code' => 0, - 'msg' => '资源记录不存在', + 'msg' => '资源分配记录不存在', '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; } -} + + } diff --git a/uniapp/pages-market/clue/index.vue b/uniapp/pages-market/clue/index.vue index b94828ae..f69230c1 100644 --- a/uniapp/pages-market/clue/index.vue +++ b/uniapp/pages-market/clue/index.vue @@ -294,7 +294,9 @@ 来源渠道 - + + {{ sourceChannelOptions[sourceChannelIndex] }} + @@ -469,6 +471,8 @@ sourceIndex: 0, sourceOptions: ['全部', '线上', '线下'], // 默认值,会被动态替换 sourceDict: {}, // 来源名称到ID的映射 + sourceChannelIndex: 0, + sourceChannelOptions: ['全部'], // 渠道选项,会被动态替换 sourceChannelDict: {}, // 渠道名称到ID的映射 attendanceIndex: 0, attendanceOptions: ['全部', '一访未到', '一访已到', '二访未到', '二访已到', '未到访'], @@ -645,11 +649,12 @@ if (channelRes.code === 1 && channelRes.data) { // 直接使用返回的数据数组 const channelData = channelRes.data + this.sourceChannelOptions = ['全部', ...channelData.map(item => item.name)] this.sourceChannelDict = channelData.reduce((acc, item) => { acc[item.name] = item.value return acc }, {}) - console.log('渠道字典加载成功:', this.sourceChannelDict) + console.log('渠道字典加载成功:', this.sourceChannelOptions, this.sourceChannelDict) } } catch (error) { console.error('字典数据加载失败:', error) @@ -1180,16 +1185,20 @@ currentFilterData.shared_at_str = '' } - // 处理来源字段:将中文名称直接传给后端(后端已支持中文名称搜索) + // 处理来源字段:将中文名称转换为对应的数字值 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 { currentFilterData.source = '' } - // 处理渠道字段 - if (this.searchForm.source_channel) { - currentFilterData.source_channel = this.searchForm.source_channel + // 处理渠道字段:将中文名称转换为对应的数字值 + if (this.searchForm.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 { currentFilterData.source_channel = '' } @@ -1232,9 +1241,10 @@ currentFilterData.age = '' } - // 处理客户判断字段 - if (this.searchForm.blacklist) { + // 处理客户判断字段:将中文选择转换为数据库值 + if (this.searchForm.blacklist && this.searchForm.blacklist !== '') { currentFilterData.blacklist = this.searchForm.blacklist + console.log('blacklist字段设置:', this.searchForm.blacklist) } else { currentFilterData.blacklist = '' } @@ -1276,9 +1286,17 @@ // 如果不是线上,清空来源渠道 if (this.sourceIndex !== 1) { 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) { this.attendanceIndex = e.detail.value @@ -1339,6 +1357,7 @@ blacklist: '' // 重置客户判断字段 } this.sourceIndex = 0 + this.sourceChannelIndex = 0 // 重置来源渠道选择器索引 this.attendanceIndex = 0 this.dealIndex = 0 this.validIndex = 0 @@ -1382,6 +1401,13 @@ extractResourceSharingId(item) { 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 = [ item._resourceSharingId, item.resource_sharing_id, @@ -1392,18 +1418,31 @@ item?.customerResource?.resourceSharing?.sharin_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 !== '') { + console.log('extractResourceSharingId 调试 - 找到有效ID:', String(candidate)) return String(candidate) } } + const relationList = item?.customerResource?.resourceSharingHasMany || item?.resourceSharingHasMany + console.log('extractResourceSharingId 调试 - relationList:', relationList) + if (Array.isArray(relationList) && relationList.length > 0) { const maybeId = relationList[0]?.id ?? relationList[0]?.resource_sharing_id + console.log('extractResourceSharingId 调试 - relationList中的ID:', maybeId) if (maybeId !== undefined && maybeId !== null && maybeId !== '') { + console.log('extractResourceSharingId 调试 - 从relationList找到ID:', String(maybeId)) return String(maybeId) } } + + console.log('extractResourceSharingId 调试 - 未找到任何有效ID,返回空字符串') return '' },