|
|
@@ -4675,15 +4675,52 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$websiteServer = new \App\JsonRpc\WebsiteService();
|
|
|
$all_cate_data = $websiteServer->getWebsiteModelCategory($cate_column);
|
|
|
$all_cate = $all_cate_data['data'] ?? [];
|
|
|
+ return Result::success($all_cate);
|
|
|
+
|
|
|
if(count($all_cate) == 0){
|
|
|
return Result::error('栏目不存在!');
|
|
|
}
|
|
|
- $componentList = array_column($template_index,'component_id');·
|
|
|
+ $componentList = array_column($template_index,'componentList');
|
|
|
+ $componentData = [];
|
|
|
+ $cat_key = 0;
|
|
|
foreach ($componentList as $key => $item) {
|
|
|
- if(count($componentList) == 1){
|
|
|
-
|
|
|
+ $componentList[$key] = $item ?? [];
|
|
|
+ if(count($item) == 1 && isset($item[0]['componentData']['level']) && (empty($v['componentData']['level']) || $v['componentData']['level'] == "")){
|
|
|
+ // if(isset($item[0]) && !empty($item[0])){
|
|
|
+ $componentList[$key][0]['componentData']['name'] = $all_cate[$cat_key]['alias'] ?? '';
|
|
|
+ $componentList[$key][0]['componentData']['category_arr'] = $all_cate[$cat_key]['category_arr_id'] ?? '';
|
|
|
+ $componentList[$key][0]['componentData']['category_id'] = $all_cate[$cat_key]['category_id'] ?? '';
|
|
|
+ $cat_key++;
|
|
|
+ $template_index[$key]['componentList'] = $componentList[$key] ?? [];
|
|
|
+ $canvas_index[$key]['content']['componentList'] = $componentList[$key] ?? [];
|
|
|
+
|
|
|
+ // }
|
|
|
+ }else{
|
|
|
+ foreach ($item as $k => $v) {
|
|
|
+ $componentList[$key][$k] = $v ?? [];
|
|
|
+ if(isset($v['componentData']['level']) && (empty($v['componentData']['level']) || $v['componentData']['level'] == "")){
|
|
|
+ $componentList[$key][$k]['componentData']['name'] = $all_cate[$cat_key]['alias'] ?? '';
|
|
|
+ $componentList[$key][$k]['componentData']['category_arr'] = $all_cate[$cat_key]['category_arr_id'] ?? '';
|
|
|
+ $componentList[$key][$k]['componentData']['category_id'] = $all_cate[$cat_key]['category_id'] ?? '';
|
|
|
+ $cat_key++;
|
|
|
+ $template_index[$key]['componentList'][$k] = $componentList[$key][$k] ?? [];
|
|
|
+ $canvas_index[$key]['content']['componentList'][$k] = $componentList[$key][$k] ?? [];
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- return Result::success(['template_index'=>$template_index,'canvas_index'=>$canvas_index]);
|
|
|
+ // 从 componentList[0] 中取出 componentData 字段
|
|
|
+ $template_data['template']['index'] = $template_index;
|
|
|
+ $canvas_data['template']['index'] = $canvas_index;
|
|
|
+
|
|
|
+ // $componentData = $componentList[0] ?? [];
|
|
|
+ $result = TemplateDraftbox::where('session_id',$data['session_id'])->update([
|
|
|
+ 'template_data'=>json_encode($template_data,JSON_UNESCAPED_UNICODE),
|
|
|
+ 'canvas_data'=>json_encode($canvas_data,JSON_UNESCAPED_UNICODE),
|
|
|
+ ]);
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error('更新失败!');
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
}
|