作者 lyh

gx

@@ -8,6 +8,7 @@ use App\Models\RouteMap\RouteMap; @@ -8,6 +8,7 @@ use App\Models\RouteMap\RouteMap;
8 use App\Models\Service\Service as ServiceSettingModel; 8 use App\Models\Service\Service as ServiceSettingModel;
9 use App\Models\Template\BCustomTemplate; 9 use App\Models\Template\BCustomTemplate;
10 use App\Models\Template\BTemplateCommon; 10 use App\Models\Template\BTemplateCommon;
  11 +use App\Models\Template\BTemplateLog;
11 use App\Models\Template\Setting; 12 use App\Models\Template\Setting;
12 use App\Models\Template\BTemplate; 13 use App\Models\Template\BTemplate;
13 14
@@ -94,9 +95,16 @@ class CustomTemplateLogic extends BaseLogic @@ -94,9 +95,16 @@ class CustomTemplateLogic extends BaseLogic
94 $html = $this->param['html']; 95 $html = $this->param['html'];
95 $info = $this->model->read(['id'=>$this->param['id']],['id','is_visualization','url']); 96 $info = $this->model->read(['id'=>$this->param['id']],['id','is_visualization','url']);
96 if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){//非定制项目+可视化页面 97 if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){//非定制项目+可视化页面
97 - $this->saveCommonTemplate($html); 98 + //获取设置的默认模版
  99 + $bSettingModel = new Setting();
  100 + $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
  101 + if($bSettingInfo === false){
  102 + $this->fail('请先选择模版');
  103 + }
  104 + $this->saveCommonTemplate($html,$bSettingInfo['template_id']);
98 $this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'); 105 $this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
99 $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); 106 $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  107 + $this->setTemplateLog($bSettingInfo['template_id'],$html,$this->param['id']);
100 } 108 }
101 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 109 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
102 if($rs === false){ 110 if($rs === false){
@@ -108,19 +116,44 @@ class CustomTemplateLogic extends BaseLogic @@ -108,19 +116,44 @@ class CustomTemplateLogic extends BaseLogic
108 } 116 }
109 117
110 /** 118 /**
  119 + * @remark :生成记录
  120 + * @name :setTemplateLog
  121 + * @author :lyh
  122 + * @method :post
  123 + * @time :2023/8/23 11:16
  124 + */
  125 + public function setTemplateLog($template_id,$html,$source_id){
  126 + $data = [
  127 + 'template_id'=>$template_id,
  128 + 'project_id'=>$this->user['project_id'],
  129 + 'operator_id'=>$this->user['id'],
  130 + 'text'=>$html,
  131 + 'source'=>9,
  132 + 'source_id'=>$source_id,
  133 + 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
  134 + 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
  135 + 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
  136 + 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
  137 + 'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
  138 + 'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
  139 + 'other'=> str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"))
  140 + ];
  141 + $bTemplateLogModel = new BTemplateLog();
  142 + return $bTemplateLogModel->add($data);
  143 + }
  144 +
  145 + /**
111 * @remark :保存头部公共数据 146 * @remark :保存头部公共数据
112 * @name :saveCommonTemplate 147 * @name :saveCommonTemplate
113 * @author :lyh 148 * @author :lyh
114 * @method :post 149 * @method :post
115 * @time :2023/10/13 14:27 150 * @time :2023/10/13 14:27
116 */ 151 */
117 - public function saveCommonTemplate($html){ 152 + public function saveCommonTemplate($html,$template_id){
118 $type = $this->getType(); 153 $type = $this->getType();
119 - //获取设置的默认模版  
120 - $bSettingModel = new Setting();  
121 - $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]); 154 +
122 $templateCommonModel = new BTemplateCommon(); 155 $templateCommonModel = new BTemplateCommon();
123 - $info = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]); 156 + $info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);
124 $data = [ 157 $data = [
125 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), 158 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
126 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), 159 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
@@ -129,7 +162,7 @@ class CustomTemplateLogic extends BaseLogic @@ -129,7 +162,7 @@ class CustomTemplateLogic extends BaseLogic
129 ]; 162 ];
130 $other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")); 163 $other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"));
131 if($info === false){ 164 if($info === false){
132 - $data['template_id'] = $bSettingInfo['template_id']; 165 + $data['template_id'] = $template_id;
133 $data['project_id'] = $this->user['project_id']; 166 $data['project_id'] = $this->user['project_id'];
134 $data['type'] = $type; 167 $data['type'] = $type;
135 $templateCommonModel->add($data); 168 $templateCommonModel->add($data);