|
@@ -21,6 +21,8 @@ use App\Models\Template\Setting; |
|
@@ -21,6 +21,8 @@ use App\Models\Template\Setting; |
|
21
|
use App\Models\Template\BTemplate;
|
21
|
use App\Models\Template\BTemplate;
|
|
22
|
use App\Models\Template\BTemplateLog;
|
22
|
use App\Models\Template\BTemplateLog;
|
|
23
|
use App\Models\Template\Template;
|
23
|
use App\Models\Template\Template;
|
|
|
|
24
|
+use App\Models\Template\TemplateReplaceHtml;
|
|
|
|
25
|
+use App\Models\Template\TemplateReplaceHtmlLog;
|
|
24
|
use App\Models\Template\TemplateTypeMain;
|
26
|
use App\Models\Template\TemplateTypeMain;
|
|
25
|
use Illuminate\Support\Facades\Cache;
|
27
|
use Illuminate\Support\Facades\Cache;
|
|
26
|
use Illuminate\Support\Facades\DB;
|
28
|
use Illuminate\Support\Facades\DB;
|
|
@@ -965,25 +967,65 @@ class BTemplateLogic extends BaseLogic |
|
@@ -965,25 +967,65 @@ class BTemplateLogic extends BaseLogic |
|
965
|
* @time :2024/5/7 15:52
|
967
|
* @time :2024/5/7 15:52
|
|
966
|
*/
|
968
|
*/
|
|
967
|
public function replaceHtml(){
|
969
|
public function replaceHtml(){
|
|
|
|
970
|
+ $type = $this->getCustomizedType($this->param['type'], $this->param['is_list']);//获取定制界面类型
|
|
|
|
971
|
+ //查看当前页面是否定制,是否开启可视化
|
|
|
|
972
|
+ $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
973
|
+ if (in_array($type, $page_array)) {//当前页面是定制界面
|
|
|
|
974
|
+ $this->param['template_id'] = 0;
|
|
|
|
975
|
+ }
|
|
|
|
976
|
+ $replaceId = $this->saveReplaceHtml($this->param);
|
|
|
|
977
|
+ //TODO::生成一条任务记录
|
|
968
|
//查询当前所有装修的
|
978
|
//查询当前所有装修的
|
|
969
|
$condition = ['source'=>$this->param['type'],'is_custom'=>$this->param['is_custom'],'is_list'=>$this->param['is_list'],
|
979
|
$condition = ['source'=>$this->param['type'],'is_custom'=>$this->param['is_custom'],'is_list'=>$this->param['is_list'],
|
|
970
|
'template_id'=>$this->param['template_id']];
|
980
|
'template_id'=>$this->param['template_id']];
|
|
971
|
$list = $this->model->list($condition);
|
981
|
$list = $this->model->list($condition);
|
|
972
|
foreach ($list as $v){
|
982
|
foreach ($list as $v){
|
|
973
|
- $main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']);
|
|
|
|
974
|
- $this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);
|
|
|
|
975
|
- //写入日志
|
|
|
|
976
|
- $logData = [
|
|
|
|
977
|
- 'old_html'=>$v['main_html'],
|
|
|
|
978
|
- 'html'=>$main_html,
|
|
|
|
979
|
- 'type'=>$v['type'],
|
|
|
|
980
|
- 'is_custom'=>$v['is_custom'],
|
|
|
|
981
|
- 'is_list'=>$v['is_list'],
|
|
|
|
982
|
- 'mid'=>$v['id'],
|
|
|
|
983
|
- 'uid'=>$this->user['manager_id'],
|
|
|
|
984
|
- ];
|
|
|
|
985
|
- //TODO::执行添加记录
|
983
|
+ if($v['type'] == 0){
|
|
|
|
984
|
+ $main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']);
|
|
|
|
985
|
+ $this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);
|
|
|
|
986
|
+ }else{
|
|
|
|
987
|
+ $html = str_replace($this->param['old_html'],$this->param['html'],$v['html']);
|
|
|
|
988
|
+ $this->model->edit(['html'=>$html],['id'=>$v['id']]);
|
|
|
|
989
|
+ }
|
|
|
|
990
|
+ $this->saveReplaceHtmlLog($replaceId,$v['id']);
|
|
986
|
}
|
991
|
}
|
|
987
|
return $this->success();
|
992
|
return $this->success();
|
|
988
|
}
|
993
|
}
|
|
|
|
994
|
+
|
|
|
|
995
|
+ /**
|
|
|
|
996
|
+ * @remark :生成一条记录
|
|
|
|
997
|
+ * @name :saveTemplateLog
|
|
|
|
998
|
+ * @author :lyh
|
|
|
|
999
|
+ * @method :post
|
|
|
|
1000
|
+ * @time :2024/5/8 9:23
|
|
|
|
1001
|
+ */
|
|
|
|
1002
|
+ public function saveReplaceHtml($data,$template_id){
|
|
|
|
1003
|
+ $logData = [
|
|
|
|
1004
|
+ 'type'=>$data['type'],
|
|
|
|
1005
|
+ 'is_custom'=>$data['is_custom'],
|
|
|
|
1006
|
+ 'is_list'=>$data['is_list'],
|
|
|
|
1007
|
+ 'template_id'=>$template_id,
|
|
|
|
1008
|
+ 'old_html'=>$data['old_html'],
|
|
|
|
1009
|
+ 'html'=>$data['html'],
|
|
|
|
1010
|
+ ];
|
|
|
|
1011
|
+ $replaceHtmlModel = new TemplateReplaceHtml();
|
|
|
|
1012
|
+ return $replaceHtmlModel->addReturnId($logData);
|
|
|
|
1013
|
+ }
|
|
|
|
1014
|
+
|
|
|
|
1015
|
+ /**
|
|
|
|
1016
|
+ * @remark :保存每条替换记录
|
|
|
|
1017
|
+ * @name :saveReplaceHtmlLog
|
|
|
|
1018
|
+ * @author :lyh
|
|
|
|
1019
|
+ * @method :post
|
|
|
|
1020
|
+ * @time :2024/5/8 9:37
|
|
|
|
1021
|
+ */
|
|
|
|
1022
|
+ public function saveReplaceHtmlLog($replace_id,$replace_template_id){
|
|
|
|
1023
|
+ $logData = [
|
|
|
|
1024
|
+ 'replace_id'=>$replace_id,
|
|
|
|
1025
|
+ 'replace_template_id'=>$replace_template_id,
|
|
|
|
1026
|
+ 'uid'=>$this->user['manager_id'],
|
|
|
|
1027
|
+ ];
|
|
|
|
1028
|
+ $replaceHtmlModel = new TemplateReplaceHtmlLog();
|
|
|
|
1029
|
+ return $replaceHtmlModel->add($logData);
|
|
|
|
1030
|
+ }
|
|
989
|
} |
1031
|
} |