|
@@ -22,6 +22,8 @@ use App\Models\Template\Setting; |
|
@@ -22,6 +22,8 @@ use App\Models\Template\Setting; |
|
22
|
use App\Models\Template\BTemplate;
|
22
|
use App\Models\Template\BTemplate;
|
|
23
|
use App\Models\Template\BTemplateLog;
|
23
|
use App\Models\Template\BTemplateLog;
|
|
24
|
use App\Models\Template\Template;
|
24
|
use App\Models\Template\Template;
|
|
|
|
25
|
+use App\Models\Template\TemplateReplaceHtml;
|
|
|
|
26
|
+use App\Models\Template\TemplateReplaceHtmlLog;
|
|
25
|
use App\Models\Template\TemplateTypeMain;
|
27
|
use App\Models\Template\TemplateTypeMain;
|
|
26
|
use Illuminate\Support\Facades\Cache;
|
28
|
use Illuminate\Support\Facades\Cache;
|
|
27
|
use Illuminate\Support\Facades\DB;
|
29
|
use Illuminate\Support\Facades\DB;
|
|
@@ -924,25 +926,65 @@ class BTemplateLogic extends BaseLogic |
|
@@ -924,25 +926,65 @@ class BTemplateLogic extends BaseLogic |
|
924
|
* @time :2024/5/7 15:52
|
926
|
* @time :2024/5/7 15:52
|
|
925
|
*/
|
927
|
*/
|
|
926
|
public function replaceHtml(){
|
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::生成一条任务记录
|
|
927
|
//查询当前所有装修的
|
937
|
//查询当前所有装修的
|
|
928
|
$condition = ['source'=>$this->param['type'],'is_custom'=>$this->param['is_custom'],'is_list'=>$this->param['is_list'],
|
938
|
$condition = ['source'=>$this->param['type'],'is_custom'=>$this->param['is_custom'],'is_list'=>$this->param['is_list'],
|
|
929
|
'template_id'=>$this->param['template_id']];
|
939
|
'template_id'=>$this->param['template_id']];
|
|
930
|
$list = $this->model->list($condition);
|
940
|
$list = $this->model->list($condition);
|
|
931
|
foreach ($list as $v){
|
941
|
foreach ($list as $v){
|
|
932
|
- $main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']);
|
|
|
|
933
|
- $this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);
|
|
|
|
934
|
- //写入日志
|
|
|
|
935
|
- $logData = [
|
|
|
|
936
|
- 'old_html'=>$v['main_html'],
|
|
|
|
937
|
- 'html'=>$main_html,
|
|
|
|
938
|
- 'type'=>$v['type'],
|
|
|
|
939
|
- 'is_custom'=>$v['is_custom'],
|
|
|
|
940
|
- 'is_list'=>$v['is_list'],
|
|
|
|
941
|
- 'mid'=>$v['id'],
|
|
|
|
942
|
- 'uid'=>$this->user['manager_id'],
|
|
|
|
943
|
- ];
|
|
|
|
944
|
- //TODO::执行添加记录
|
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']);
|
|
945
|
}
|
950
|
}
|
|
946
|
return $this->success();
|
951
|
return $this->success();
|
|
947
|
}
|
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
|
+ }
|
|
948
|
} |
990
|
} |