|
...
|
...
|
@@ -21,6 +21,8 @@ use App\Models\Template\Setting; |
|
|
|
use App\Models\Template\BTemplate;
|
|
|
|
use App\Models\Template\BTemplateLog;
|
|
|
|
use App\Models\Template\Template;
|
|
|
|
use App\Models\Template\TemplateReplaceHtml;
|
|
|
|
use App\Models\Template\TemplateReplaceHtmlLog;
|
|
|
|
use App\Models\Template\TemplateTypeMain;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
...
|
...
|
@@ -965,25 +967,65 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2024/5/7 15:52
|
|
|
|
*/
|
|
|
|
public function replaceHtml(){
|
|
|
|
$type = $this->getCustomizedType($this->param['type'], $this->param['is_list']);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
if (in_array($type, $page_array)) {//当前页面是定制界面
|
|
|
|
$this->param['template_id'] = 0;
|
|
|
|
}
|
|
|
|
$replaceId = $this->saveReplaceHtml($this->param);
|
|
|
|
//TODO::生成一条任务记录
|
|
|
|
//查询当前所有装修的
|
|
|
|
$condition = ['source'=>$this->param['type'],'is_custom'=>$this->param['is_custom'],'is_list'=>$this->param['is_list'],
|
|
|
|
'template_id'=>$this->param['template_id']];
|
|
|
|
$list = $this->model->list($condition);
|
|
|
|
foreach ($list as $v){
|
|
|
|
$main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']);
|
|
|
|
$this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);
|
|
|
|
//写入日志
|
|
|
|
$logData = [
|
|
|
|
'old_html'=>$v['main_html'],
|
|
|
|
'html'=>$main_html,
|
|
|
|
'type'=>$v['type'],
|
|
|
|
'is_custom'=>$v['is_custom'],
|
|
|
|
'is_list'=>$v['is_list'],
|
|
|
|
'mid'=>$v['id'],
|
|
|
|
'uid'=>$this->user['manager_id'],
|
|
|
|
];
|
|
|
|
//TODO::执行添加记录
|
|
|
|
if($v['type'] == 0){
|
|
|
|
$main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']);
|
|
|
|
$this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);
|
|
|
|
}else{
|
|
|
|
$html = str_replace($this->param['old_html'],$this->param['html'],$v['html']);
|
|
|
|
$this->model->edit(['html'=>$html],['id'=>$v['id']]);
|
|
|
|
}
|
|
|
|
$this->saveReplaceHtmlLog($replaceId,$v['id']);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :生成一条记录
|
|
|
|
* @name :saveTemplateLog
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/5/8 9:23
|
|
|
|
*/
|
|
|
|
public function saveReplaceHtml($data,$template_id){
|
|
|
|
$logData = [
|
|
|
|
'type'=>$data['type'],
|
|
|
|
'is_custom'=>$data['is_custom'],
|
|
|
|
'is_list'=>$data['is_list'],
|
|
|
|
'template_id'=>$template_id,
|
|
|
|
'old_html'=>$data['old_html'],
|
|
|
|
'html'=>$data['html'],
|
|
|
|
];
|
|
|
|
$replaceHtmlModel = new TemplateReplaceHtml();
|
|
|
|
return $replaceHtmlModel->addReturnId($logData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存每条替换记录
|
|
|
|
* @name :saveReplaceHtmlLog
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/5/8 9:37
|
|
|
|
*/
|
|
|
|
public function saveReplaceHtmlLog($replace_id,$replace_template_id){
|
|
|
|
$logData = [
|
|
|
|
'replace_id'=>$replace_id,
|
|
|
|
'replace_template_id'=>$replace_template_id,
|
|
|
|
'uid'=>$this->user['manager_id'],
|
|
|
|
];
|
|
|
|
$replaceHtmlModel = new TemplateReplaceHtmlLog();
|
|
|
|
return $replaceHtmlModel->add($logData);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|