作者 Your Name
@@ -6,6 +6,8 @@ use App\Enums\Common\Code; @@ -6,6 +6,8 @@ use App\Enums\Common\Code;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\BTemplate\CustomTemplateLogic; 7 use App\Http\Logic\Bside\BTemplate\CustomTemplateLogic;
8 use App\Http\Requests\Bside\Template\CustomTemplateRequest; 8 use App\Http\Requests\Bside\Template\CustomTemplateRequest;
  9 +use App\Models\Template\BTemplate;
  10 +use App\Models\Template\BTemplateLog;
9 11
10 /** 12 /**
11 * @remark :自定义模块 13 * @remark :自定义模块
@@ -107,4 +109,22 @@ class CustomTemplateController extends BaseController @@ -107,4 +109,22 @@ class CustomTemplateController extends BaseController
107 $customTemplateLogic->saveHtml(); 109 $customTemplateLogic->saveHtml();
108 $this->response('success'); 110 $this->response('success');
109 } 111 }
  112 +
  113 + /**
  114 + * @remark :获取自定义界面的保存记录
  115 + * @name :getCustomTemplateLog
  116 + * @author :lyh
  117 + * @method :post
  118 + * @time :2024/4/23 11:07
  119 + */
  120 + public function getCustomTemplateLog(BTemplateLog $bTemplateLog){
  121 + $this->request->validate([
  122 + 'id'=>['required'],
  123 + ],[
  124 + 'id.required' => 'ID不能为空',
  125 + ]);
  126 + $this->map['source'] = 9;
  127 + $lists = $bTemplateLog->lists($this->map,$this->page,$this->row);
  128 + $this->response('success',Code::SUCCESS,$lists);
  129 + }
110 } 130 }
@@ -39,38 +39,43 @@ class BTemplateLogLogic extends BaseLogic @@ -39,38 +39,43 @@ class BTemplateLogLogic extends BaseLogic
39 $this->fail('error'); 39 $this->fail('error');
40 } 40 }
41 $bTemplateModel = new BTemplate(); 41 $bTemplateModel = new BTemplate();
42 - if($info['template_id'] == 0){//定制项目  
43 - //TODO::还原头部+底部  
44 - $bTemplateModel->edit(['html'=>$info['text']],['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);  
45 - return $this->success();  
46 - }  
47 //演示项目,不允许其他号码编辑 42 //演示项目,不允许其他号码编辑
48 if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){ 43 if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){
49 $this->fail('演示项目仅支持演示功能,无法更改首页'); 44 $this->fail('演示项目仅支持演示功能,无法更改首页');
50 } 45 }
51 - //获取当前项目的模版 46 + if($info['template_id'] == 0){//todo::定制项目
  47 + $condition = ['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id'],'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
  48 + //TODO::还原头部+底部
  49 + $bTemplateModel->edit(['html'=>$info['text']],$condition);
  50 + $commonData = $this->setCommonParam($info);
  51 + $commonTemplateModel = new BTemplateCommon();
  52 + $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$info['type'],'project_id'=>$this->user['project_id']]);
  53 + return $this->success();
  54 + }
  55 + //TODO::非定制项目,获取当前项目的模版
52 $bSettingModel = new Setting(); 56 $bSettingModel = new Setting();
53 $settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]); 57 $settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
54 if($settingInfo === false){ 58 if($settingInfo === false){
55 $this->fail('请先选择模版'); 59 $this->fail('请先选择模版');
56 } 60 }
57 - //切换模版  
58 - if($info['template_id'] != $settingInfo['template_id']){  
59 - $bSettingModel->edit(['template_id'=>$info['template_id']],['id'=>$settingInfo['id']]);  
60 - }  
61 try { 61 try {
  62 + //切换模版
  63 + if($info['template_id'] != $settingInfo['template_id']){
  64 + $bSettingModel->edit(['template_id'=>$info['template_id']],['id'=>$settingInfo['id']]);
  65 + }
62 $data = $this->setParam($info); 66 $data = $this->setParam($info);
63 - $bTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]); 67 + $condition = ['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id'],'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
  68 + $bTemplateModel->edit($data,$condition);
  69 + //还原头部+底部
64 $commonData = $this->setCommonParam($info); 70 $commonData = $this->setCommonParam($info);
65 $commonTemplateModel = new BTemplateCommon(); 71 $commonTemplateModel = new BTemplateCommon();
66 - $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]);  
67 - //更新所有界面的other 72 + $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$info['type'],'project_id'=>$this->user['project_id']]);
68 if(!empty($info['other'])){ 73 if(!empty($info['other'])){
69 - $commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]); 74 + $commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);
70 }else{ 75 }else{
71 $footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s')); 76 $footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
72 $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); 77 $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
73 - $commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]); 78 + $commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);
74 } 79 }
75 }catch (\Exception $e){ 80 }catch (\Exception $e){
76 $this->fail('系统错误,请联系管理员'); 81 $this->fail('系统错误,请联系管理员');
@@ -417,7 +417,7 @@ class BTemplateLogic extends BaseLogic @@ -417,7 +417,7 @@ class BTemplateLogic extends BaseLogic
417 } 417 }
418 //更新头部信息 418 //更新头部信息
419 $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']); 419 $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']);
420 - $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']); 420 + $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']);
421 //通知更新 421 //通知更新
422 $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']); 422 $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
423 return $this->success(); 423 return $this->success();
@@ -646,7 +646,7 @@ class BTemplateLogic extends BaseLogic @@ -646,7 +646,7 @@ class BTemplateLogic extends BaseLogic
646 * @method :post 646 * @method :post
647 * @time :2023/8/23 11:16 647 * @time :2023/8/23 11:16
648 */ 648 */
649 - public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){ 649 + public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom = 0,$is_list = 0,$type = 0){
650 if($is_custom != BTemplate::IS_NO_CUSTOM){ 650 if($is_custom != BTemplate::IS_NO_CUSTOM){
651 return true; 651 return true;
652 } 652 }
@@ -657,6 +657,7 @@ class BTemplateLogic extends BaseLogic @@ -657,6 +657,7 @@ class BTemplateLogic extends BaseLogic
657 'text'=>$html, 657 'text'=>$html,
658 'type'=>$type, 658 'type'=>$type,
659 'is_custom'=>$is_custom, 659 'is_custom'=>$is_custom,
  660 + 'is_list'=>$is_list,
660 'source'=>$source, 661 'source'=>$source,
661 'source_id'=>$source_id, 662 'source_id'=>$source_id,
662 'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'), 663 'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
@@ -364,4 +364,5 @@ class CustomTemplateLogic extends BaseLogic @@ -364,4 +364,5 @@ class CustomTemplateLogic extends BaseLogic
364 } 364 }
365 return $this->success($data); 365 return $this->success($data);
366 } 366 }
  367 +
367 } 368 }
@@ -396,6 +396,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -396,6 +396,7 @@ Route::middleware(['bloginauth'])->group(function () {
396 Route::any('/saveHtml', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'saveHtml'])->name('custom_saveHtml'); 396 Route::any('/saveHtml', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'saveHtml'])->name('custom_saveHtml');
397 Route::any('/statusNum', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'statusNumber'])->name('custom_statusNum'); 397 Route::any('/statusNum', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'statusNumber'])->name('custom_statusNum');
398 Route::any('/del', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'del'])->name('custom_del'); 398 Route::any('/del', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'del'])->name('custom_del');
  399 + Route::any('/getCustomTemplateLog', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'getCustomTemplateLog'])->name('custom_getCustomTemplateLog');
399 }); 400 });
400 // 菜单组 401 // 菜单组
401 Route::prefix('nav_group')->group(function () { 402 Route::prefix('nav_group')->group(function () {