|
@@ -25,7 +25,7 @@ class VisualizationLogic extends BaseLogic |
|
@@ -25,7 +25,7 @@ class VisualizationLogic extends BaseLogic |
|
25
|
public function __construct()
|
25
|
public function __construct()
|
|
26
|
{
|
26
|
{
|
|
27
|
parent::__construct();
|
27
|
parent::__construct();
|
|
28
|
- $this->model = new Visualization();
|
28
|
+ $this->model = new BTemplateMain();
|
|
29
|
$this->param = $this->requestAll;
|
29
|
$this->param = $this->requestAll;
|
|
30
|
}
|
30
|
}
|
|
31
|
|
31
|
|
|
@@ -38,11 +38,36 @@ class VisualizationLogic extends BaseLogic |
|
@@ -38,11 +38,36 @@ class VisualizationLogic extends BaseLogic |
|
38
|
*/
|
38
|
*/
|
|
39
|
public function saveVisualization(){
|
39
|
public function saveVisualization(){
|
|
40
|
try {
|
40
|
try {
|
|
41
|
- if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
42
|
- $this->model->edit($this->param,['id'=>$this->param['id']]);
|
41
|
+ $type = $this->getType($this->param['source'],$this->param['source_id']);
|
|
|
|
42
|
+ $typeArray = [1,3,5,7];//单页数据
|
|
|
|
43
|
+ if(in_array($type,$typeArray)){
|
|
|
|
44
|
+ $bTemplateModel = new BTemplate();
|
|
|
|
45
|
+ $templateInfo = $bTemplateModel->read(['source'=>$this->param['source'],'template_id'=>0]);
|
|
|
|
46
|
+ if($templateInfo === false){
|
|
|
|
47
|
+ $data = [
|
|
|
|
48
|
+ 'html'=>$this->param['html'],
|
|
|
|
49
|
+ 'project_id'=>$this->user['project_id'],
|
|
|
|
50
|
+ 'source'=>$this->param['source'],
|
|
|
|
51
|
+ 'source_id'=>$this->param['source_id'],
|
|
|
|
52
|
+ 'section_list_id'=>$this->param['section_list_id'],
|
|
|
|
53
|
+ ];
|
|
|
|
54
|
+ $bTemplateModel->add($data);
|
|
43
|
}else{
|
55
|
}else{
|
|
44
|
- $this->param['project_id'] = $this->user['project_id'];
|
|
|
|
45
|
- $this->model->add($this->param);
|
56
|
+ $bTemplateModel->edit(['html'=>$this->param['html']],['id'=>$templateInfo['id']]);
|
|
|
|
57
|
+ }
|
|
|
|
58
|
+ }else{//模块数据
|
|
|
|
59
|
+ $bTemplateMainModel = new BTemplateMain();
|
|
|
|
60
|
+ $mainInfo = $bTemplateMainModel->read(['type'=>$type]);
|
|
|
|
61
|
+ if($mainInfo === false){
|
|
|
|
62
|
+ $mainData = [
|
|
|
|
63
|
+ 'project_id'=>$this->user['project_id'],
|
|
|
|
64
|
+ 'type'=>$type,
|
|
|
|
65
|
+ 'main_html'=>$this->param['html']
|
|
|
|
66
|
+ ];
|
|
|
|
67
|
+ $bTemplateMainModel->add($mainData);
|
|
|
|
68
|
+ }else{
|
|
|
|
69
|
+ $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
|
|
|
|
70
|
+ }
|
|
46
|
}
|
71
|
}
|
|
47
|
}catch (\Exception $e){
|
72
|
}catch (\Exception $e){
|
|
48
|
$this->fail('系统错误,请联系管理员');
|
73
|
$this->fail('系统错误,请联系管理员');
|
|
@@ -58,54 +83,51 @@ class VisualizationLogic extends BaseLogic |
|
@@ -58,54 +83,51 @@ class VisualizationLogic extends BaseLogic |
|
58
|
* @time :2023/11/15 11:30
|
83
|
* @time :2023/11/15 11:30
|
|
59
|
*/
|
84
|
*/
|
|
60
|
public function getHtml(){
|
85
|
public function getHtml(){
|
|
61
|
- $TemplateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);
|
|
|
|
62
|
- $type = $this->getType($this->param['source'],$this->param['source_id']);
|
|
|
|
63
|
- $page_array = (array)$this->user['is_visualization']->page_array;
|
|
|
|
64
|
- if($TemplateInfo === false){
|
|
|
|
65
|
- if(in_array($type,$page_array)){//定制页面
|
|
|
|
66
|
- $info = $this->model->read(['source'=>$type],['html','source','id','project_id']);
|
|
|
|
67
|
- if($info === false){
|
86
|
+ $type = $this->getType($this->param['source'],$this->param['source_id']);//获取类型
|
|
|
|
87
|
+ $page_array = (array)$this->user['is_visualization']->page_array;//获取定制界面
|
|
|
|
88
|
+ //查看当前类型是否是定制界面
|
|
|
|
89
|
+ if(in_array($type,$page_array)){//是定制界面
|
|
|
|
90
|
+ if(in_array($type,[1,3,5,7])){//单页
|
|
|
|
91
|
+ $templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前定制单页是否有代码块
|
|
|
|
92
|
+ if($templateInfo === false){
|
|
68
|
$this->fail('请先上传定制代码块');
|
93
|
$this->fail('请先上传定制代码块');
|
|
69
|
}
|
94
|
}
|
|
70
|
- return $info['html'];
|
95
|
+ return ['html'=>$templateInfo['html']];
|
|
|
|
96
|
+ }else{//模块页
|
|
|
|
97
|
+ $templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前页面是否可视化
|
|
|
|
98
|
+ if($templateInfo === false){//获取代码块
|
|
|
|
99
|
+ $bTemplateMainModel = new BTemplateMain();
|
|
|
|
100
|
+ $mainInfo = $bTemplateMainModel->read(['type'=>$type]);
|
|
|
|
101
|
+ if($mainInfo === false){
|
|
|
|
102
|
+ $this->fail('请先上传定制代码块');
|
|
|
|
103
|
+ }
|
|
|
|
104
|
+ return ['html'=>$mainInfo['main_html']];
|
|
|
|
105
|
+ }
|
|
|
|
106
|
+ return ['html'=>$templateInfo['html']];
|
|
|
|
107
|
+ }
|
|
71
|
}else{//非定制界面
|
108
|
}else{//非定制界面
|
|
72
|
$bSettingModel = new Setting();
|
109
|
$bSettingModel = new Setting();
|
|
73
|
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
110
|
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
74
|
if($settingInfo === false){
|
111
|
if($settingInfo === false){
|
|
75
|
$this->fail('请先选择模版');
|
112
|
$this->fail('请先选择模版');
|
|
76
|
}
|
113
|
}
|
|
77
|
- //获取公共头部底部
|
|
|
|
78
|
- $commonInfo = $this->getCommonPage($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);
|
|
|
|
79
|
- if($commonInfo === false){
|
|
|
|
80
|
- //保存一次首页头部底部
|
|
|
|
81
|
- $ATemplateModel = new Template();
|
|
|
|
82
|
- $aTemplateInfo = $ATemplateModel->read(['id'=>$settingInfo['template_id']]);
|
|
|
|
83
|
- $commonInfo = $this->saveHomeHeaderFooter($settingInfo['template_id'],$aTemplateInfo);
|
|
|
|
84
|
- }
|
114
|
+ $templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);//查看当前页面是否可视化
|
|
|
|
115
|
+ if($templateInfo === false){
|
|
85
|
//根据类型在获取中间部分
|
116
|
//根据类型在获取中间部分
|
|
86
|
$mainData = $this->getCommonMain($this->param['source'],$this->param['source_id']);
|
117
|
$mainData = $this->getCommonMain($this->param['source'],$this->param['source_id']);
|
|
87
|
- //拼接数据
|
|
|
|
88
|
- $html = $commonInfo['head_css'].$mainData['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
89
|
- $commonInfo['head_html'].$mainData['main_html'].$commonInfo['footer_html'];
|
|
|
|
90
|
- $html = $this->getHeadFooter($html);
|
|
|
|
91
|
- return ['html'=>$html,'template_id'=>$settingInfo['template_id']];
|
|
|
|
92
|
- }
|
|
|
|
93
|
}else{
|
118
|
}else{
|
|
94
|
- if($TemplateInfo['template_id'] != 0){
|
|
|
|
95
|
- $bSettingModel = new Setting();
|
|
|
|
96
|
- $settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
97
|
- if($settingInfo === false){
|
|
|
|
98
|
- $this->fail('请先选择模版');
|
119
|
+ $mainData = [
|
|
|
|
120
|
+ 'main_html'=>$templateInfo['main_html'],
|
|
|
|
121
|
+ 'main_css'=>$templateInfo['main_css']
|
|
|
|
122
|
+ ];
|
|
99
|
}
|
123
|
}
|
|
100
|
- //获取头部信息
|
124
|
+ //获取公共头部底部
|
|
101
|
$commonInfo = $this->getCommonPage($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);
|
125
|
$commonInfo = $this->getCommonPage($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);
|
|
102
|
- $html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
103
|
- $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
126
|
+ //拼接数据
|
|
|
|
127
|
+ $html = $commonInfo['head_css'].$mainData['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
128
|
+ $commonInfo['head_html'].$mainData['main_html'].$commonInfo['footer_html'];
|
|
104
|
$html = $this->getHeadFooter($html);
|
129
|
$html = $this->getHeadFooter($html);
|
|
105
|
return ['html'=>$html,'template_id'=>$settingInfo['template_id']];
|
130
|
return ['html'=>$html,'template_id'=>$settingInfo['template_id']];
|
|
106
|
- }else{
|
|
|
|
107
|
- return $TemplateInfo['html'];
|
|
|
|
108
|
- }
|
|
|
|
109
|
}
|
131
|
}
|
|
110
|
}
|
132
|
}
|
|
111
|
|
133
|
|
|
@@ -139,14 +161,16 @@ class VisualizationLogic extends BaseLogic |
|
@@ -139,14 +161,16 @@ class VisualizationLogic extends BaseLogic |
|
139
|
* @method :post
|
161
|
* @method :post
|
|
140
|
* @time :2023/11/16 11:21
|
162
|
* @time :2023/11/16 11:21
|
|
141
|
*/
|
163
|
*/
|
|
142
|
- public function getWebTemplate($source,$source_id){
|
164
|
+ public function getWebTemplate($source,$source_id,$template_id = 0){
|
|
143
|
//查询可视化是否第一次保存
|
165
|
//查询可视化是否第一次保存
|
|
144
|
$bTemplateModel = new BTemplate();
|
166
|
$bTemplateModel = new BTemplate();
|
|
145
|
- return $bTemplateModel->read([
|
167
|
+ $param = [
|
|
146
|
'source'=>$source,
|
168
|
'source'=>$source,
|
|
147
|
'project_id'=>$this->user['project_id'],
|
169
|
'project_id'=>$this->user['project_id'],
|
|
148
|
'source_id'=>$source_id,
|
170
|
'source_id'=>$source_id,
|
|
149
|
- ]);
|
171
|
+ 'template_id'=>$template_id
|
|
|
|
172
|
+ ];
|
|
|
|
173
|
+ return $bTemplateModel->read($param);
|
|
150
|
}
|
174
|
}
|
|
151
|
|
175
|
|
|
152
|
/**
|
176
|
/**
|
|
@@ -203,6 +227,7 @@ class VisualizationLogic extends BaseLogic |
|
@@ -203,6 +227,7 @@ class VisualizationLogic extends BaseLogic |
|
203
|
public function saveHtml(){
|
227
|
public function saveHtml(){
|
|
204
|
$page_array = (array)$this->user['is_visualization']->page_array;
|
228
|
$page_array = (array)$this->user['is_visualization']->page_array;
|
|
205
|
$type = $this->getType($this->param['source'],$this->param['source_id']);
|
229
|
$type = $this->getType($this->param['source'],$this->param['source_id']);
|
|
|
|
230
|
+ try {
|
|
206
|
if(in_array($type,$page_array)){//定制页面
|
231
|
if(in_array($type,$page_array)){//定制页面
|
|
207
|
$bTemplateModel = new BTemplate();
|
232
|
$bTemplateModel = new BTemplate();
|
|
208
|
$templateInfo = $bTemplateModel->read([
|
233
|
$templateInfo = $bTemplateModel->read([
|
|
@@ -210,6 +235,12 @@ class VisualizationLogic extends BaseLogic |
|
@@ -210,6 +235,12 @@ class VisualizationLogic extends BaseLogic |
|
210
|
'project_id'=>$this->user['project_id'],
|
235
|
'project_id'=>$this->user['project_id'],
|
|
211
|
'source_id'=>$this->param['source_id'],
|
236
|
'source_id'=>$this->param['source_id'],
|
|
212
|
]);
|
237
|
]);
|
|
|
|
238
|
+ if($templateInfo === false){
|
|
|
|
239
|
+ $this->param['project_id'] = $this->user['project_id'];
|
|
|
|
240
|
+ $bTemplateModel->add($this->param);
|
|
|
|
241
|
+ }else{
|
|
|
|
242
|
+ $bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
|
|
|
|
243
|
+ }
|
|
213
|
}else{
|
244
|
}else{
|
|
214
|
$bTemplateModel = new BTemplate();
|
245
|
$bTemplateModel = new BTemplate();
|
|
215
|
$templateInfo = $bTemplateModel->read([
|
246
|
$templateInfo = $bTemplateModel->read([
|
|
@@ -222,17 +253,17 @@ class VisualizationLogic extends BaseLogic |
|
@@ -222,17 +253,17 @@ class VisualizationLogic extends BaseLogic |
|
222
|
$this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
253
|
$this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
223
|
//保存头部
|
254
|
//保存头部
|
|
224
|
$this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
|
255
|
$this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
|
|
225
|
- }
|
|
|
|
226
|
- try {
|
|
|
|
227
|
if($templateInfo === false){
|
256
|
if($templateInfo === false){
|
|
228
|
$this->param['project_id'] = $this->user['project_id'];
|
257
|
$this->param['project_id'] = $this->user['project_id'];
|
|
229
|
$bTemplateModel->add($this->param);
|
258
|
$bTemplateModel->add($this->param);
|
|
230
|
}else{
|
259
|
}else{
|
|
231
|
$bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
|
260
|
$bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
|
|
232
|
}
|
261
|
}
|
|
|
|
262
|
+ }
|
|
233
|
}catch (\Exception $e){
|
263
|
}catch (\Exception $e){
|
|
234
|
- $this->fail('系统错误请联系管理员');
|
264
|
+ $this->fail('系统错误,请联系管理员');
|
|
235
|
}
|
265
|
}
|
|
|
|
266
|
+
|
|
236
|
return $this->success();
|
267
|
return $this->success();
|
|
237
|
|
268
|
|
|
238
|
}
|
269
|
}
|
|
@@ -282,8 +313,7 @@ class VisualizationLogic extends BaseLogic |
|
@@ -282,8 +313,7 @@ class VisualizationLogic extends BaseLogic |
|
282
|
if ($source == 4) {if ($source_id != 0) {$type = 6;} else {$type = 7;}}
|
313
|
if ($source == 4) {if ($source_id != 0) {$type = 6;} else {$type = 7;}}
|
|
283
|
if ($source == 5) {$type = 8;}
|
314
|
if ($source == 5) {$type = 8;}
|
|
284
|
//查询有没有公共详情模板
|
315
|
//查询有没有公共详情模板
|
|
285
|
- $bTemplateMainModel = new BTemplateMain();
|
|
|
|
286
|
- $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]);
|
316
|
+ $mainInfo = $this->model->read(['type'=>$type]);
|
|
287
|
if($mainInfo === false){
|
317
|
if($mainInfo === false){
|
|
288
|
$data['main_html'] = $this->getModule($type);
|
318
|
$data['main_html'] = $this->getModule($type);
|
|
289
|
$data['main_css'] = "<style id='globalsojs-styles'></style>";
|
319
|
$data['main_css'] = "<style id='globalsojs-styles'></style>";
|