Browse Source

修改 bug

master
王泽彦 8 months ago
parent
commit
6991970691
  1. 8
      niucloud/app/api/controller/apiController/Common.php
  2. 63
      niucloud/app/model/customer_resources/CustomerResources.php
  3. 27
      niucloud/app/model/six_speed/SixSpeed.php
  4. 26
      niucloud/app/service/api/apiService/CommonService.php
  5. 16
      niucloud/app/service/api/apiService/CustomerResourcesService.php
  6. 6
      uniapp/pages-market/clue/clue_info.vue
  7. 2
      uniapp/pages-market/clue/edit_clues.vue
  8. 78
      uniapp/pages-market/clue/index.vue

8
niucloud/app/api/controller/apiController/Common.php

@ -25,15 +25,15 @@ class Common extends BaseApiService
//获取字典
public function getDictionary(Request $request){
//获取员工信息
//获取字典数据
$where = [
'key'=>$request->param('key','')
];
$res = (new CommonService())->getDictionary($where);
if(!$res){
return fail('账户信息有误');
if(empty($res)){
return fail('字典数据不存在');
}
return success($res);
return success('操作成功', $res);
}
//忘记密码-通过短信验证码进行密码重置(学生/员工通用)

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

@ -116,6 +116,26 @@ class CustomerResources extends BaseModel
}
}
/**
* 获取字典数据的辅助方法
* @param string $key
* @return array
*/
private function getDictionaryData($key)
{
$dict = \think\facade\Db::table('school_sys_dict')->where('key', $key)->find();
$dictionary = [];
if ($dict && !empty($dict['dictionary'])) {
// 数据库中的字段是双层JSON编码,需要两次解码
$jsonString = json_decode($dict['dictionary'], true);
if (is_string($jsonString)) {
$dictionary = json_decode($jsonString, true) ?: [];
} else {
$dictionary = $jsonString ?: [];
}
}
return $dictionary;
}
/**
* 搜索器:客户资源联系电话
@ -184,8 +204,7 @@ class CustomerResources extends BaseModel
$key = 'preliminarycustomerintention';
$val = (String)$data['initial_intent'];
if ((!empty($val) || isset($val)) && $val !== '') {
$dict = Dict::where('key',$key)->find();
$dictionary = $dict['dictionary'] ?? [];
$dictionary = $this->getDictionaryData($key);
// 查找匹配的 name
$res = '';
foreach ($dictionary as $item) {
@ -211,8 +230,18 @@ class CustomerResources extends BaseModel
$key = 'SourceChannel';
$val = (String)$data['source_channel'];
if ((!empty($val) || isset($val)) && $val !== '') {
$dict = Dict::where('key',$key)->find();
$dictionary = $dict['dictionary'] ?? [];
// 直接查询正确的表名
$dict = \think\facade\Db::table('school_sys_dict')->where('key', $key)->find();
$dictionary = [];
if ($dict && !empty($dict['dictionary'])) {
// 数据库中的字段是双层JSON编码,需要两次解码
$jsonString = json_decode($dict['dictionary'], true);
if (is_string($jsonString)) {
$dictionary = json_decode($jsonString, true) ?: [];
} else {
$dictionary = $jsonString ?: [];
}
}
// 查找匹配的 name
$res = '';
$arr = [
@ -245,8 +274,18 @@ class CustomerResources extends BaseModel
$key = 'source';
$val = (String)$data['source'];
if ((!empty($val) || isset($val)) && $val !== '') {
$dict = Dict::where('key',$key)->find();
$dictionary = $dict['dictionary'] ?? [];
// 直接查询正确的表名
$dict = \think\facade\Db::table('school_sys_dict')->where('key', $key)->find();
$dictionary = [];
if ($dict && !empty($dict['dictionary'])) {
// 数据库中的字段是双层JSON编码,需要两次解码
$jsonString = json_decode($dict['dictionary'], true);
if (is_string($jsonString)) {
$dictionary = json_decode($jsonString, true) ?: [];
} else {
$dictionary = $jsonString ?: [];
}
}
// 查找匹配的 name
$res = '';
foreach ($dictionary as $item) {
@ -272,8 +311,7 @@ class CustomerResources extends BaseModel
$key = 'zy_sex';
$val = (String)$data['gender'];
if ((!empty($val) || isset($val)) && $val !== '') {
$dict = Dict::where('key',$key)->find();
$dictionary = $dict['dictionary'] ?? [];
$dictionary = $this->getDictionaryData($key);
// 查找匹配的 name
$res = '';
foreach ($dictionary as $item) {
@ -299,8 +337,7 @@ class CustomerResources extends BaseModel
$key = 'customer_purchasing_power';
$val = (String)$data['purchasing_power'];
if ((!empty($val) || isset($val)) && $val !== '') {
$dict = Dict::where('key',$key)->find();
$dictionary = $dict['dictionary'] ?? [];
$dictionary = $this->getDictionaryData($key);
// 查找匹配的 name
$res = '';
foreach ($dictionary as $item) {
@ -326,8 +363,7 @@ class CustomerResources extends BaseModel
$key = 'kh_status';
$val = (String)$data['status'];
if ((!empty($val) || isset($val)) && $val !== '') {
$dict = Dict::where('key',$key)->find();
$dictionary = $dict['dictionary'] ?? [];
$dictionary = $this->getDictionaryData($key);
// 查找匹配的 name
$res = '';
foreach ($dictionary as $item) {
@ -353,8 +389,7 @@ class CustomerResources extends BaseModel
$key = 'decision_maker';
$val = (String)$data['decision_maker'] ?? '';
if ((!empty($val) || isset($val)) && $val !== '') {
$dict = Dict::where('key',$key)->find();
$dictionary = $dict['dictionary'] ?? [];
$dictionary = $this->getDictionaryData($key);
// 查找匹配的 name
$res = $val;
foreach ($dictionary as $item) {

27
niucloud/app/model/six_speed/SixSpeed.php

@ -99,8 +99,7 @@ class SixSpeed extends BaseModel
$key = 'customer_purchasing_power';
$val = (String)$data['purchase_power'];
if ((!empty($val) || isset($val)) && $val !== '') {
$dict = Dict::where('key',$key)->find();
$dictionary = $dict['dictionary'] ?? [];
$dictionary = $this->getDictionaryData($key);
// 查找匹配的 name
$res = '';
foreach ($dictionary as $item) {
@ -115,6 +114,27 @@ class SixSpeed extends BaseModel
}
}
/**
* 获取字典数据的辅助方法
* @param string $key
* @return array
*/
private function getDictionaryData($key)
{
$dict = \think\facade\Db::table('school_sys_dict')->where('key', $key)->find();
$dictionary = [];
if ($dict && !empty($dict['dictionary'])) {
// 数据库中的字段是双层JSON编码,需要两次解码
$jsonString = json_decode($dict['dictionary'], true);
if (is_string($jsonString)) {
$dictionary = json_decode($jsonString, true) ?: [];
} else {
$dictionary = $jsonString ?: [];
}
}
return $dictionary;
}
/**
* 获取认知理念类型名称
* @param $value
@ -126,8 +146,7 @@ class SixSpeed extends BaseModel
$key = 'customer_purchasing_power';
$val = (String)$data['concept_awareness'];
if ((!empty($val) || isset($val)) && $val !== '') {
$dict = Dict::where('key',$key)->find();
$dictionary = $dict['dictionary'] ?? [];
$dictionary = $this->getDictionaryData($key);
// 查找匹配的 name
$res = '';
foreach ($dictionary as $item) {

26
niucloud/app/service/api/apiService/CommonService.php

@ -37,12 +37,32 @@ class CommonService extends BaseApiService
if(!empty($where['key'])){
$model = $model->where('key',$where['key']);
}
$res = $model->field($field)->find();//员工信息
$res = $model->field($field)->find();//字典信息
if($res){
$data = $res->toArray();
// 模型已经自动处理JSON转换,直接返回dictionary字段
$res = $data['dictionary'] ?? [];
// 手动解析JSON字符串
$dictionary = $data['dictionary'] ?? '';
if(is_string($dictionary)){
// 首先解码一层JSON(去掉外层引号)
$firstDecode = json_decode($dictionary, true);
if($firstDecode !== null && is_string($firstDecode)) {
// 如果第一次解码得到字符串,再次解码
$parsed = json_decode($firstDecode, true);
} else if($firstDecode !== null && is_array($firstDecode)) {
// 如果第一次解码就得到数组,直接使用
$parsed = $firstDecode;
} else {
// 如果第一次解码失败,可能不是JSON格式,直接尝试解码原字符串
$parsed = json_decode($dictionary, true);
}
$res = $parsed ?: [];
} else {
// 如果已经是数组,直接使用
$res = $dictionary;
}
}else{
$res = [];
}

16
niucloud/app/service/api/apiService/CustomerResourcesService.php

@ -653,8 +653,8 @@ class CustomerResourcesService extends BaseApiService
return [];
}
// 查询字典数据
$dictData = Dict::whereIn('key', $dictKeys)->select()->toArray();
// 查询字典数据 - 使用正确的表名
$dictData = \think\facade\Db::table('school_sys_dict')->whereIn('key', $dictKeys)->select()->toArray();
//使用 array_column 构建 key => dict 的映射
$dictMap = array_column($dictData, null, 'key'); // 以 key 字段为索引
@ -663,7 +663,17 @@ class CustomerResourcesService extends BaseApiService
// 构建字段 => 字典项的映射
$result = [];
foreach ($fieldDictMapping as $field => $key) {
$result[$field] = $dictMap[$key]['dictionary'] ?? [];
$dictionary = [];
if (isset($dictMap[$key]['dictionary']) && !empty($dictMap[$key]['dictionary'])) {
// 数据库中的字段是双层JSON编码,需要两次解码
$jsonString = json_decode($dictMap[$key]['dictionary'], true);
if (is_string($jsonString)) {
$dictionary = json_decode($jsonString, true) ?: [];
} else {
$dictionary = $jsonString ?: [];
}
}
$result[$field] = $dictionary;
//判断是不是获取的"来源渠道"的字典
if ($field == 'source_channel') {
$append_arr = [

6
uniapp/pages-market/clue/clue_info.vue

@ -536,9 +536,6 @@ export default {
this.currentRecord = null
},
async getCourseInfo(studentId = null) {
if (!this.clientInfo?.resource_id) return
try {
@ -645,9 +642,10 @@ export default {
if (tabId === 4) await this.getFitnessRecords()
if (tabId === 6) {
this.$navigateToPage(`/pages-market/clue/edit_clues_log`, {
resource_id: this.clientInfo.resource_id
resource_id: this.clientInfo.id
})
}
console.log('切换标签页:', this.clientInfo)
if (tabId === 7) this.$navigateToPage(`/pages-market/clue/edit_clues`, {
resource_sharing_id: this.clientInfo.id
})

2
uniapp/pages-market/clue/edit_clues.vue

@ -306,7 +306,7 @@
</view>
<!-- 选择器日期选择等控件保留原有 -->
<fui-date-picker :show="date_picker_show" type="3" @change="change_date" @cancel="cancel_date" :value="default_date_value"></fui-date-picker>
<fui-date-picker :show="date_picker_show" type="5" @change="change_date" @cancel="cancel_date" :value="default_date_value"></fui-date-picker>
<fui-picker :linkage='picker_linkage' :options="picker_options" :layer="1" :show="picker_show" @change="changeCicker" @cancel="cancelCicker"></fui-picker>
<!-- 快速填写弹窗 -->

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

@ -274,6 +274,19 @@
</view>
</view>
</view>
<view class="popup_filter_row">
<view class="popup_filter_item">
<text class="popup_filter_label">年龄</text>
<input class="popup_filter_input" placeholder="请输入年龄" v-model="searchForm.age" type="digit" />
</view>
<view class="popup_filter_item">
<text class="popup_filter_label">客户判断</text>
<picker :value="blacklistIndex" :range="blacklistOptions" @change="onBlacklistChange">
<view class="popup_filter_picker">{{ blacklistOptions[blacklistIndex] }}</view>
</picker>
</view>
</view>
</view>
</scroll-view>
@ -378,7 +391,9 @@
deal_type: '',
valid_type: '',
communication_status: '',
time_range: ''
time_range: '',
age: '', //
blacklist: '' // 12
},
//
@ -394,6 +409,8 @@
validOptions: ['全部', '有效', '无效'],
communicationIndex: 0,
communicationOptions: ['全部', '已沟通', '未沟通'],
blacklistIndex: 0,
blacklistOptions: ['全部', '可追单', '黑名单'],
//
filteredData: {
page: 1, //
@ -433,6 +450,8 @@
attendance_type: '', //
deal_type: '', //
valid_type: '', //
age: '', //
blacklist: '', //12
},
//
tableList_1: [], //
@ -448,6 +467,8 @@
phone_number: '', //-
name: '', //-
campus_name: '',
age: '', //
blacklist: '', //12
},
//
tableList_2: [], //
@ -511,6 +532,8 @@
},
//
async init() {
//
this.initSelectorsData();
await this.getUserInfo();
await this.initDictData(); //
if (this.segmented_type == 1) {
@ -519,6 +542,18 @@
await this.getList_2();
}
},
//
initSelectorsData() {
// blacklistIndex
if (this.blacklistIndex < 0 || this.blacklistIndex >= this.blacklistOptions.length) {
this.blacklistIndex = 0;
}
console.log('初始化选择器数据:', {
blacklistOptions: this.blacklistOptions,
blacklistIndex: this.blacklistIndex
});
},
//
async initDictData() {
@ -746,6 +781,8 @@
this.filteredData_1.phone_number = '' //-
this.filteredData_1.name = '' //-
this.filteredData_1.campus_name = ''
this.filteredData_1.age = '' //
this.filteredData_1.blacklist = '' //
//
//
@ -756,6 +793,8 @@
this.filteredData_2.phone_number = '' //-
this.filteredData_2.name = '' //-
this.filteredData_2.campus_name = ''
this.filteredData_2.age = '' //
this.filteredData_2.blacklist = '' //
//
//
await this.resetFilteredData_2()
@ -1073,6 +1112,20 @@
currentFilterData.course_search = ''
}
//
if (this.searchForm.age) {
currentFilterData.age = this.searchForm.age
} else {
currentFilterData.age = ''
}
//
if (this.searchForm.blacklist) {
currentFilterData.blacklist = this.searchForm.blacklist
} else {
currentFilterData.blacklist = ''
}
console.log('映射后的筛选数据:', currentFilterData)
//
@ -1137,6 +1190,24 @@
this.searchForm.communication_status = this.communicationOptions[this.communicationIndex]
},
//
onBlacklistChange(e) {
console.log('客户判断选择器变化:', e.detail.value)
console.log('当前blacklistOptions:', this.blacklistOptions)
this.blacklistIndex = e.detail.value
const selectedOption = this.blacklistOptions[this.blacklistIndex]
console.log('选中的选项:', selectedOption)
// ->1->2->''
if (selectedOption === '可追单') {
this.searchForm.blacklist = '1'
} else if (selectedOption === '黑名单') {
this.searchForm.blacklist = '2'
} else {
this.searchForm.blacklist = ''
}
console.log('设置blacklist值为:', this.searchForm.blacklist)
},
//
async resetSearch() {
this.searchForm = {
@ -1150,13 +1221,16 @@
deal_type: '',
valid_type: '',
communication_status: '',
time_range: ''
time_range: '',
age: '', //
blacklist: '' //
}
this.sourceIndex = 0
this.attendanceIndex = 0
this.dealIndex = 0
this.validIndex = 0
this.communicationIndex = 0
this.blacklistIndex = 0 //
//
if (this.segmented_type == 1) {

Loading…
Cancel
Save