From 7e33276e0c9397028b922a44d9b4b5cf8bea7009 Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Tue, 24 Nov 2020 16:07:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E4=BA=A7=E7=94=9F=E7=9A=84=E5=B7=A5=E4=BD=9C=E6=B5=81form?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/initialize/workflow.go | 8 +- server/model/exa_wf_leave.go | 2 +- server/resource/template/server/model.go.tpl | 25 ++- .../template/web/workflowForm.vue.tpl | 171 ++++++++++++++++++ server/service/sys_auto_code.go | 2 + 5 files changed, 202 insertions(+), 6 deletions(-) create mode 100644 server/resource/template/web/workflowForm.vue.tpl diff --git a/server/initialize/workflow.go b/server/initialize/workflow.go index 899864ea..1b4b47eb 100644 --- a/server/initialize/workflow.go +++ b/server/initialize/workflow.go @@ -2,14 +2,14 @@ package initialize import "gin-vue-admin/model" -func initWkModel() { +func initWorkflowModel() { model.WorkflowBusinessStruct = make(map[string]func() model.GVA_Workflow) model.WorkflowBusinessStruct["leave"] = func() model.GVA_Workflow { return new(model.ExaWfLeaveWorkflow) } } -func initWkTable() { +func initWorkflowTable() { model.WorkflowBusinessTable = make(map[string]func() interface{}) model.WorkflowBusinessTable["leave"] = func() interface{} { return new(model.ExaWfLeave) @@ -17,6 +17,6 @@ func initWkTable() { } func InitWkMode() { - initWkModel() - initWkTable() + initWorkflowModel() + initWorkflowTable() } diff --git a/server/model/exa_wf_leave.go b/server/model/exa_wf_leave.go index 56b96ac7..d12116da 100644 --- a/server/model/exa_wf_leave.go +++ b/server/model/exa_wf_leave.go @@ -20,6 +20,6 @@ type ExaWfLeaveWorkflow struct { ExaWfLeave `json:"business"` } -func (e ExaWfLeave) TableName() string { +func (ExaWfLeave) TableName() string { return "exa_wf_leaves" } diff --git a/server/resource/template/server/model.go.tpl b/server/resource/template/server/model.go.tpl index 8394f70f..2ca70d38 100644 --- a/server/resource/template/server/model.go.tpl +++ b/server/resource/template/server/model.go.tpl @@ -19,4 +19,27 @@ type {{.StructName}} struct { func ({{.StructName}}) TableName() string { return "{{.TableName}}" } -{{ end }} \ No newline at end of file +{{ end }} + +// 如果使用工作流功能 需要打开下方注释 并到initialize的workflow中进行注册 且必须指定TableName +// type {{.StructName}}Workflow struct { +// // 工作流操作结构体 +// WorkflowBase `json:"wf"` +// {{.StructName}} `json:"business"` +// } + +// func ({{.StructName}}) TableName() string { +// return "{{.TableName}}" +// } + +// 工作流注册代码 + +// initWorkflowModel内部注册 +// model.WorkflowBusinessStruct["{{.Abbreviation}}"] = func() model.GVA_Workflow { +// return new(model.{{.StructName}}Workflow) +// } + +// initWorkflowTable内部注册 +// model.WorkflowBusinessTable["{{.Abbreviation}}"] = func() interface{} { +// return new(model.{{.StructName}}) +// } diff --git a/server/resource/template/web/workflowForm.vue.tpl b/server/resource/template/web/workflowForm.vue.tpl new file mode 100644 index 00000000..dc4d6f70 --- /dev/null +++ b/server/resource/template/web/workflowForm.vue.tpl @@ -0,0 +1,171 @@ + + + + + \ No newline at end of file diff --git a/server/service/sys_auto_code.go b/server/service/sys_auto_code.go index d6fdf0b3..b673de11 100644 --- a/server/service/sys_auto_code.go +++ b/server/service/sys_auto_code.go @@ -201,6 +201,8 @@ func addAutoMoveFile(data *tplData) { } else if strings.Contains(data.autoCodePath, "web") { if strings.Contains(data.autoCodePath, "js") { data.autoMoveFilePath = filepath.Join("../", "web", "src", dir, base) + } else if strings.Contains(data.autoCodePath, "workflowForm") { + data.autoMoveFilePath = filepath.Join("../", "web", "src", "view", filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), strings.TrimSuffix(base, filepath.Ext(base))+"WorkflowForm.vue") } else if strings.Contains(data.autoCodePath, "form") { data.autoMoveFilePath = filepath.Join("../", "web", "src", "view", filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), strings.TrimSuffix(base, filepath.Ext(base))+"Form.vue") } else if strings.Contains(data.autoCodePath, "table") {