Browse Source

feat(cli): 视图页支持保存数据.

pull/772/head
cKey 3 years ago
parent
commit
696ce4fe53
  1. 38
      aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/UI/Vben/VbenViewScriptGenerator.cs
  2. 4
      aspnet-core/modules/cli/LINGYUN.Abp.Cli/Properties/launchSettings.json

38
aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/UI/Vben/VbenViewScriptGenerator.cs

@ -26,11 +26,30 @@ public class VbenViewScriptGenerator : IVbenViewScriptGenerator, ISingletonDepen
.Select(module => module.Value) .Select(module => module.Value)
.FirstOrDefault(); .FirstOrDefault();
var updateAction = controllerModel.Actions
.Where(action => action.Value.Name.Contains("UpdateAsync"))
.Select(action => action.Value)
.FirstOrDefault();
var createAction = controllerModel.Actions
.Where(action => action.Value.Name.Contains("CreateAsync"))
.Select(action => action.Value)
.FirstOrDefault();
var getAction = controllerModel.Actions
.Where(action => action.Value.Name.Contains("GetAsync"))
.Select(action => action.Value)
.FirstOrDefault();
var modalContent = await _templateRenderer.RenderAsync( var modalContent = await _templateRenderer.RenderAsync(
"VbenModalView", "VbenModalView",
new new
{ {
Key = "id", Key = "id",
HasCreate = createAction != null,
GetAction = getAction?.UniqueName ?? "GetAsyncById",
CreateAction = createAction?.UniqueName ?? "CreateAsyncByInput",
HasUpdate = updateAction != null,
UpdateAction = updateAction?.UniqueName ?? "UpdateAsyncByIdAndInput",
HasSubmit = createAction != null || updateAction != null,
Application = controllerModel.ControllerName, Application = controllerModel.ControllerName,
ApiPath = $"/@/api/{moduleDefinition.RemoteServiceName.ToKebabCase()}/{controllerModel.ControllerName.ToKebabCase()}", ApiPath = $"/@/api/{moduleDefinition.RemoteServiceName.ToKebabCase()}/{controllerModel.ControllerName.ToKebabCase()}",
RemoteService = moduleDefinition.RemoteServiceName, RemoteService = moduleDefinition.RemoteServiceName,
@ -62,6 +81,10 @@ public class VbenViewScriptGenerator : IVbenViewScriptGenerator, ISingletonDepen
.Where(action => action.Value.Name.Contains("UpdateAsync")) .Where(action => action.Value.Name.Contains("UpdateAsync"))
.Select(action => action.Value) .Select(action => action.Value)
.FirstOrDefault(); .FirstOrDefault();
var createAction = controllerModel.Actions
.Where(action => action.Value.Name.Contains("CreateAsync"))
.Select(action => action.Value)
.FirstOrDefault();
var tableContent = await _templateRenderer.RenderAsync( var tableContent = await _templateRenderer.RenderAsync(
"VbenTableView", "VbenTableView",
@ -69,10 +92,17 @@ public class VbenViewScriptGenerator : IVbenViewScriptGenerator, ISingletonDepen
{ {
Key = "id", Key = "id",
PagedRequest = pagedResultAction != null, PagedRequest = pagedResultAction != null,
UpdatePermission = updateAction != null && updateAction.AllowAnonymous != null && updateAction.AllowAnonymous != true, GetListAction = pagedResultAction?.UniqueName ?? "GetListAsyncByInput",
UpdatePermissionName = $"{moduleDefinition.RemoteServiceName.ToKebabCase()}.{controllerModel.ControllerName.ToKebabCase()}.Update", HasCreate = createAction != null,
DeletePermission = deleteAction != null && deleteAction.AllowAnonymous != null && deleteAction.AllowAnonymous != true, CreatePermission = true,
DeletePermissionName = $"{moduleDefinition.RemoteServiceName.ToKebabCase()}.{controllerModel.ControllerName.ToKebabCase()}.Delete", CreatePermissionName = $"{moduleDefinition.RemoteServiceName.ToPascalCase()}.{controllerModel.ControllerName.ToPascalCase()}.Create",
HasUpdate = updateAction != null,
UpdatePermission = true,
UpdatePermissionName = $"{moduleDefinition.RemoteServiceName.ToPascalCase()}.{controllerModel.ControllerName.ToPascalCase()}.Update",
HasDelete = deleteAction != null,
DeleteAction = deleteAction?.UniqueName ?? "DeleteAsyncById",
DeletePermission = true,
DeletePermissionName = $"{moduleDefinition.RemoteServiceName.ToPascalCase()}.{controllerModel.ControllerName.ToPascalCase()}.Delete",
Application = controllerModel.ControllerName, Application = controllerModel.ControllerName,
ModalName = $"{controllerModel.ControllerName.ToPascalCase()}Modal", ModalName = $"{controllerModel.ControllerName.ToPascalCase()}Modal",
ApiPath = $"/@/api/{moduleDefinition.RemoteServiceName.ToKebabCase()}/{controllerModel.ControllerName.ToKebabCase()}", ApiPath = $"/@/api/{moduleDefinition.RemoteServiceName.ToKebabCase()}/{controllerModel.ControllerName.ToKebabCase()}",

4
aspnet-core/modules/cli/LINGYUN.Abp.Cli/Properties/launchSettings.json

@ -2,8 +2,8 @@
"profiles": { "profiles": {
"LINGYUN.Abp.Cli": { "LINGYUN.Abp.Cli": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "generate-view -t vben-view -m auditing -o D:\\Projects\\Development\\view-script -url http://127.0.0.1:30000/" "commandLineArgs": "generate-view -t vben-view -m task-management -o D:\\Projects\\Development\\view-script -url http://127.0.0.1:30000/"
//"commandLineArgs": "generate-proxy -t ts -asp uni-app-axios -u http://127.0.0.1:30025 -m Platform -o D:\\Projects\\Development\\type-script" // "commandLineArgs": "generate-proxy -t ts -asp vben-dynamic -u http://127.0.0.1:30000 -m task-management -o D:\\Projects\\Development\\type-script"
} }
} }
} }
Loading…
Cancel
Save