作者 张关杰

Merge branch 'lyh_edit' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -170,29 +170,4 @@ class BTemplateController extends BaseController @@ -170,29 +170,4 @@ class BTemplateController extends BaseController
170 $info = $bTemplateModel->sourceMap(); 170 $info = $bTemplateModel->sourceMap();
171 $this->response('success',Code::SUCCESS,$info); 171 $this->response('success',Code::SUCCESS,$info);
172 } 172 }
173 -  
174 - /**  
175 - * @remark :替换同一种类型的html代码  
176 - * @name :replaceTemplateMainHtml  
177 - * @author :lyh  
178 - * @method :post  
179 - * @time :2024/5/7 14:39  
180 - */  
181 - public function replaceTemplateMainHtml(BTemplateLogic $BTemplateLogic){  
182 - $this->request->validate([  
183 - 'old_html'=>'required',  
184 - 'html'=>'required',  
185 - 'type'=>'required',  
186 - 'is_list'=>'required',  
187 - 'is_custom'=>'required',  
188 - ],[  
189 - 'old_html.required' => '需替换的html不能为空',  
190 - 'html.required' => 'html不能为空',  
191 - 'type.required' => '类型type不能为空',  
192 - 'is_custom.required' => '类型is_custom不能为空',  
193 - 'is_list.required' => '类型is_list不能为空',  
194 - ]);  
195 - $BTemplateLogic->replaceHtml();  
196 - $this->response('success');  
197 - }  
198 } 173 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ReplaceHtmlController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/8 10:02
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Template;
  11 +
  12 +use App\Http\Controllers\Bside\BaseController;
  13 +use App\Http\Logic\Bside\BTemplate\BTemplateLogic;
  14 +use App\Http\Logic\Bside\BTemplate\ReplaceHtmlLogic;
  15 +
  16 +class ReplaceHtmlController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :替换同一种类型的html代码
  20 + * @name :replaceTemplateMainHtml
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2024/5/7 14:39
  24 + */
  25 + public function replaceTemplateMainHtml(ReplaceHtmlLogic $logic){
  26 + $this->request->validate([
  27 + 'old_html'=>'required',
  28 + 'html'=>'required',
  29 + 'type'=>'required',
  30 + 'is_list'=>'required',
  31 + 'is_custom'=>'required',
  32 + ],[
  33 + 'old_html.required' => '需替换的html不能为空',
  34 + 'html.required' => 'html不能为空',
  35 + 'type.required' => '类型type不能为空',
  36 + 'is_custom.required' => '类型is_custom不能为空',
  37 + 'is_list.required' => '类型is_list不能为空',
  38 + ]);
  39 + $logic->replaceHtml();
  40 + $this->response('success');
  41 + }
  42 +}
@@ -917,74 +917,4 @@ class BTemplateLogic extends BaseLogic @@ -917,74 +917,4 @@ class BTemplateLogic extends BaseLogic
917 } 917 }
918 return $this->success(); 918 return $this->success();
919 } 919 }
920 -  
921 - /**  
922 - * @remark :替换可视化的html代码(按类型)  
923 - * @name :replaceHtml  
924 - * @author :lyh  
925 - * @method :post  
926 - * @time :2024/5/7 15:52  
927 - */  
928 - public function replaceHtml(){  
929 - $type = $this->getCustomizedType($this->param['type'], $this->param['is_list']);//获取定制界面类型  
930 - //查看当前页面是否定制,是否开启可视化  
931 - $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面  
932 - if (in_array($type, $page_array)) {//当前页面是定制界面  
933 - $this->param['template_id'] = 0;  
934 - }  
935 - $replaceId = $this->saveReplaceHtml($this->param);  
936 - //TODO::生成一条任务记录  
937 - //查询当前所有装修的  
938 - $condition = ['source'=>$this->param['type'],'is_custom'=>$this->param['is_custom'],'is_list'=>$this->param['is_list'],  
939 - 'template_id'=>$this->param['template_id']];  
940 - $list = $this->model->list($condition);  
941 - foreach ($list as $v){  
942 - if($v['type'] == 0){  
943 - $main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']);  
944 - $this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);  
945 - }else{  
946 - $html = str_replace($this->param['old_html'],$this->param['html'],$v['html']);  
947 - $this->model->edit(['html'=>$html],['id'=>$v['id']]);  
948 - }  
949 - $this->saveReplaceHtmlLog($replaceId,$v['id']);  
950 - }  
951 - return $this->success();  
952 - }  
953 -  
954 - /**  
955 - * @remark :生成一条记录  
956 - * @name :saveTemplateLog  
957 - * @author :lyh  
958 - * @method :post  
959 - * @time :2024/5/8 9:23  
960 - */  
961 - public function saveReplaceHtml($data,$template_id){  
962 - $logData = [  
963 - 'type'=>$data['type'],  
964 - 'is_custom'=>$data['is_custom'],  
965 - 'is_list'=>$data['is_list'],  
966 - 'template_id'=>$template_id,  
967 - 'old_html'=>$data['old_html'],  
968 - 'html'=>$data['html'],  
969 - ];  
970 - $replaceHtmlModel = new TemplateReplaceHtml();  
971 - return $replaceHtmlModel->addReturnId($logData);  
972 - }  
973 -  
974 - /**  
975 - * @remark :保存每条替换记录  
976 - * @name :saveReplaceHtmlLog  
977 - * @author :lyh  
978 - * @method :post  
979 - * @time :2024/5/8 9:37  
980 - */  
981 - public function saveReplaceHtmlLog($replace_id,$replace_template_id){  
982 - $logData = [  
983 - 'replace_id'=>$replace_id,  
984 - 'replace_template_id'=>$replace_template_id,  
985 - 'uid'=>$this->user['manager_id'],  
986 - ];  
987 - $replaceHtmlModel = new TemplateReplaceHtmlLog();  
988 - return $replaceHtmlModel->add($logData);  
989 - }  
990 } 920 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ReplaceHtmlLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/8 10:03
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\BTemplate;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\Template\BTemplate;
  14 +use App\Models\Template\TemplateReplaceHtml;
  15 +use App\Models\Template\TemplateReplaceHtmlLog;
  16 +
  17 +class ReplaceHtmlLogic extends BaseLogic
  18 +{
  19 + public function __construct()
  20 + {
  21 + parent::__construct();
  22 + $this->model = new TemplateReplaceHtml();
  23 + $this->param = $this->requestAll;
  24 + }
  25 +
  26 + /**
  27 + * @remark :替换可视化的html代码(按类型)
  28 + * @name :replaceHtml
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2024/5/7 15:52
  32 + */
  33 + public function replaceHtml(){
  34 + $type = $this->getCustomizedType($this->param['type'], $this->param['is_list']);//获取定制界面类型
  35 + //查看当前页面是否定制,是否开启可视化
  36 + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
  37 + if (in_array($type, $page_array)) {//当前页面是定制界面
  38 + $this->param['template_id'] = 0;
  39 + }
  40 + $replaceId = $this->saveReplaceHtml($this->param);
  41 + //TODO::生成一条任务记录
  42 + //查询当前所有装修的
  43 + $condition = ['source'=>$this->param['type'],'is_custom'=>$this->param['is_custom'],'is_list'=>$this->param['is_list'],
  44 + 'template_id'=>$this->param['template_id']];
  45 + $list = $this->model->list($condition);
  46 + foreach ($list as $v){
  47 + if($v['type'] == 0){
  48 + $main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']);
  49 + $this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);
  50 + }else{
  51 + $html = str_replace($this->param['old_html'],$this->param['html'],$v['html']);
  52 + $this->model->edit(['html'=>$html],['id'=>$v['id']]);
  53 + }
  54 + $this->saveReplaceHtmlLog($replaceId,$v['id']);
  55 + }
  56 + return $this->success();
  57 + }
  58 +
  59 + /**
  60 + * @remark :生成一条记录
  61 + * @name :saveTemplateLog
  62 + * @author :lyh
  63 + * @method :post
  64 + * @time :2024/5/8 9:23
  65 + */
  66 + public function saveReplaceHtml($data,$template_id){
  67 + $logData = [
  68 + 'type'=>$data['type'],
  69 + 'is_custom'=>$data['is_custom'],
  70 + 'is_list'=>$data['is_list'],
  71 + 'template_id'=>$template_id,
  72 + 'old_html'=>$data['old_html'],
  73 + 'html'=>$data['html'],
  74 + ];
  75 + return $this->model->addReturnId($logData);
  76 + }
  77 +
  78 + /**
  79 + * @remark :保存每条替换记录
  80 + * @name :saveReplaceHtmlLog
  81 + * @author :lyh
  82 + * @method :post
  83 + * @time :2024/5/8 9:37
  84 + */
  85 + public function saveReplaceHtmlLog($replace_id,$replace_template_id){
  86 + $logData = [
  87 + 'replace_id'=>$replace_id,
  88 + 'replace_template_id'=>$replace_template_id,
  89 + 'uid'=>$this->user['manager_id'],
  90 + ];
  91 + $replaceHtmlModel = new TemplateReplaceHtmlLog();
  92 + return $replaceHtmlModel->add($logData);
  93 + }
  94 +}