mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-23 16:13:13 +08:00
流程模板
This commit is contained in:
26
admin/src/api/flow_template.ts
Normal file
26
admin/src/api/flow_template.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 流程模板列表
|
||||||
|
export function flow_template_lists(params?: Record<string, any>) {
|
||||||
|
return request.get({ url: '/flow_template/list', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 流程模板详情
|
||||||
|
export function flow_template_detail(params: Record<string, any>) {
|
||||||
|
return request.get({ url: '/flow_template/detail', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 流程模板新增
|
||||||
|
export function flow_template_add(params: Record<string, any>) {
|
||||||
|
return request.post({ url: '/flow_template/add', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 流程模板编辑
|
||||||
|
export function flow_template_edit(params: Record<string, any>) {
|
||||||
|
return request.post({ url: '/flow_template/edit', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 流程模板删除
|
||||||
|
export function flow_template_delete(params: Record<string, any>) {
|
||||||
|
return request.post({ url: '/flow_template/del', params })
|
||||||
|
}
|
148
admin/src/views/flow_template/edit.vue
Normal file
148
admin/src/views/flow_template/edit.vue
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
<template>
|
||||||
|
<div class="edit-popup">
|
||||||
|
<popup
|
||||||
|
ref="popupRef"
|
||||||
|
:title="popupTitle"
|
||||||
|
:async="true"
|
||||||
|
width="550px"
|
||||||
|
:clickModalClose="true"
|
||||||
|
@confirm="handleSubmit"
|
||||||
|
@close="handleClose"
|
||||||
|
>
|
||||||
|
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
|
||||||
|
<el-form-item label="流程名称" prop="flowName">
|
||||||
|
<el-input v-model="formData.flowName" placeholder="请输入流程名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="流程分类" prop="flowGroup">
|
||||||
|
<el-input v-model.number="formData.flowGroup" placeholder="请输入流程分类" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="流程描述" prop="flowRemark">
|
||||||
|
<el-input v-model="formData.flowRemark" placeholder="请输入流程描述" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="表单配置" prop="flowFormData">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.flowFormData"
|
||||||
|
placeholder="请输入表单配置"
|
||||||
|
type="textarea"
|
||||||
|
:autosize="{ minRows: 4, maxRows: 6 }"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="流程配置" prop="flowProcessData">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.flowProcessData"
|
||||||
|
placeholder="请输入流程配置"
|
||||||
|
type="textarea"
|
||||||
|
:autosize="{ minRows: 4, maxRows: 6 }"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</popup>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormInstance } from 'element-plus'
|
||||||
|
import { flow_template_edit, flow_template_add, flow_template_detail } from '@/api/flow_template'
|
||||||
|
import Popup from '@/components/popup/index.vue'
|
||||||
|
import feedback from '@/utils/feedback'
|
||||||
|
import type { PropType } from 'vue'
|
||||||
|
defineProps({
|
||||||
|
dictData: {
|
||||||
|
type: Object as PropType<Record<string, any[]>>,
|
||||||
|
default: () => ({})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['success', 'close'])
|
||||||
|
const formRef = shallowRef<FormInstance>()
|
||||||
|
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||||
|
const mode = ref('add')
|
||||||
|
const popupTitle = computed(() => {
|
||||||
|
return mode.value == 'edit' ? '编辑流程模板' : '新增流程模板'
|
||||||
|
})
|
||||||
|
|
||||||
|
const formData = reactive({
|
||||||
|
id: '',
|
||||||
|
flowName: '',
|
||||||
|
flowGroup: '',
|
||||||
|
flowRemark: '',
|
||||||
|
flowFormData: '',
|
||||||
|
flowProcessData: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const formRules = {
|
||||||
|
flowName: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入流程名称',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
flowGroup: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入流程分类',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
flowRemark: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入流程描述',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
flowFormData: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入表单配置',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
flowProcessData: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入流程配置',
|
||||||
|
trigger: ['blur']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
await formRef.value?.validate()
|
||||||
|
const data: any = { ...formData }
|
||||||
|
mode.value == 'edit' ? await flow_template_edit(data) : await flow_template_add(data)
|
||||||
|
popupRef.value?.close()
|
||||||
|
feedback.msgSuccess('操作成功')
|
||||||
|
emit('success')
|
||||||
|
}
|
||||||
|
|
||||||
|
const open = (type = 'add') => {
|
||||||
|
mode.value = type
|
||||||
|
popupRef.value?.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
const setFormData = async (data: Record<string, any>) => {
|
||||||
|
for (const key in formData) {
|
||||||
|
if (data[key] != null && data[key] != undefined) {
|
||||||
|
//@ts-ignore
|
||||||
|
formData[key] = data[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDetail = async (row: Record<string, any>) => {
|
||||||
|
const data = await flow_template_detail({
|
||||||
|
id: row.id
|
||||||
|
})
|
||||||
|
setFormData(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
open,
|
||||||
|
setFormData,
|
||||||
|
getDetail
|
||||||
|
})
|
||||||
|
</script>
|
115
admin/src/views/flow_template/index.vue
Normal file
115
admin/src/views/flow_template/index.vue
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<template>
|
||||||
|
<div class="index-lists">
|
||||||
|
<el-card class="!border-none" shadow="never">
|
||||||
|
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
|
||||||
|
<el-form-item label="流程名称" prop="flowName">
|
||||||
|
<el-input class="w-[280px]" v-model="queryParams.flowName" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="流程分类" prop="flowGroup">
|
||||||
|
<el-input class="w-[280px]" v-model="queryParams.flowGroup" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="流程描述" prop="flowRemark">
|
||||||
|
<el-input class="w-[280px]" v-model="queryParams.flowRemark" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||||
|
<el-button @click="resetParams">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
<el-card class="!border-none mt-4" shadow="never">
|
||||||
|
<div>
|
||||||
|
<el-button v-perms="['flow_template:add']" type="primary" @click="handleAdd()">
|
||||||
|
<template #icon>
|
||||||
|
<icon name="el-icon-Plus" />
|
||||||
|
</template>
|
||||||
|
新增
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<el-table
|
||||||
|
class="mt-4"
|
||||||
|
size="large"
|
||||||
|
v-loading="pager.loading"
|
||||||
|
:data="pager.lists"
|
||||||
|
>
|
||||||
|
<el-table-column label="流程名称" prop="flowName" min-width="100" />
|
||||||
|
<el-table-column label="流程分类" prop="flowGroup" min-width="100" />
|
||||||
|
<el-table-column label="流程描述" prop="flowRemark" min-width="100" />
|
||||||
|
<el-table-column label="表单配置" prop="flowFormData" min-width="100" />
|
||||||
|
<el-table-column label="流程配置" prop="flowProcessData" min-width="100" />
|
||||||
|
<el-table-column label="操作" width="120" fixed="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button
|
||||||
|
v-perms="['flow_template:edit']"
|
||||||
|
type="primary"
|
||||||
|
link
|
||||||
|
@click="handleEdit(row)"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-perms="['flow_template:del']"
|
||||||
|
type="danger"
|
||||||
|
link
|
||||||
|
@click="handleDelete(row.id)"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="flex justify-end mt-4">
|
||||||
|
<pagination v-model="pager" @change="getLists" />
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
<edit-popup
|
||||||
|
v-if="showEdit"
|
||||||
|
ref="editRef"
|
||||||
|
@success="getLists"
|
||||||
|
@close="showEdit = false"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup name="flow_template">
|
||||||
|
import { flow_template_delete, flow_template_lists } from '@/api/flow_template'
|
||||||
|
import { usePaging } from '@/hooks/usePaging'
|
||||||
|
import feedback from '@/utils/feedback'
|
||||||
|
import EditPopup from './edit.vue'
|
||||||
|
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||||
|
const showEdit = ref(false)
|
||||||
|
const queryParams = reactive({
|
||||||
|
flowName: '',
|
||||||
|
flowGroup: '',
|
||||||
|
flowRemark: '',
|
||||||
|
flowFormData: '',
|
||||||
|
flowProcessData: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
const { pager, getLists, resetPage, resetParams } = usePaging({
|
||||||
|
fetchFun: flow_template_lists,
|
||||||
|
params: queryParams
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const handleAdd = async () => {
|
||||||
|
showEdit.value = true
|
||||||
|
await nextTick()
|
||||||
|
editRef.value?.open('add')
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleEdit = async (data: any) => {
|
||||||
|
showEdit.value = true
|
||||||
|
await nextTick()
|
||||||
|
editRef.value?.open('edit')
|
||||||
|
editRef.value?.getDetail(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
await feedback.confirm('确定要删除?')
|
||||||
|
await flow_template_delete({ id })
|
||||||
|
feedback.msgSuccess('删除成功')
|
||||||
|
getLists()
|
||||||
|
}
|
||||||
|
|
||||||
|
getLists()
|
||||||
|
</script>
|
@@ -44,7 +44,9 @@ func RegisterGroup(rg *gin.RouterGroup) {
|
|||||||
dept.DeptRoute(rg)
|
dept.DeptRoute(rg)
|
||||||
system.RoleRoute(rg)
|
system.RoleRoute(rg)
|
||||||
log.LogRoute(rg)
|
log.LogRoute(rg)
|
||||||
|
|
||||||
ArticleCollectRoute(rg)
|
ArticleCollectRoute(rg)
|
||||||
|
FlowTemplateRoute(rg)
|
||||||
|
|
||||||
captcha.CaptchaRoute(rg)
|
captcha.CaptchaRoute(rg)
|
||||||
}
|
}
|
||||||
|
109
server/admin/flow_template/flow_template_ctl.go
Normal file
109
server/admin/flow_template/flow_template_ctl.go
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package flow_template
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"x_admin/core/request"
|
||||||
|
"x_admin/core/response"
|
||||||
|
"x_admin/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type FlowTemplateHandler struct {
|
||||||
|
Service IFlowTemplateService
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Summary 流程模板列表
|
||||||
|
// @Tags flow_template-流程模板
|
||||||
|
// @Produce json
|
||||||
|
// @Param Token header string true "token"
|
||||||
|
// @Param PageNo query int true "页码"
|
||||||
|
// @Param PageSize query int true "每页数量"
|
||||||
|
// @Param flowName query string false "流程名称"
|
||||||
|
// @Param flowGroup query int false "流程分类"
|
||||||
|
// @Param flowRemark query string false "流程描述"
|
||||||
|
// @Param flowFormData query string false "表单配置"
|
||||||
|
// @Param flowProcessData query string false "流程配置"
|
||||||
|
// @Success 200 {object} []FlowTemplateResp "成功"
|
||||||
|
// @Failure 400 {object} string "请求错误"
|
||||||
|
// @Router /api/flow_template/list [get]
|
||||||
|
func (hd FlowTemplateHandler) List(c *gin.Context) {
|
||||||
|
var page request.PageReq
|
||||||
|
var listReq FlowTemplateListReq
|
||||||
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &page)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := hd.Service.List(page, listReq)
|
||||||
|
response.CheckAndRespWithData(c, res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Summary 流程模板详情
|
||||||
|
// @Tags flow_template-流程模板
|
||||||
|
// @Produce json
|
||||||
|
// @Param Token header string true "token"
|
||||||
|
// @Param id query int false ""
|
||||||
|
// @Success 200 {object} FlowTemplateResp "成功"
|
||||||
|
// @Router /api/flow_template/detail [get]
|
||||||
|
func (hd FlowTemplateHandler) Detail(c *gin.Context) {
|
||||||
|
var detailReq FlowTemplateDetailReq
|
||||||
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := hd.Service.Detail(detailReq.Id)
|
||||||
|
response.CheckAndRespWithData(c, res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Summary 流程模板新增
|
||||||
|
// @Tags flow_template-流程模板
|
||||||
|
// @Produce json
|
||||||
|
// @Param Token header string true "token"
|
||||||
|
// @Param flowName body string false "流程名称"
|
||||||
|
// @Param flowGroup body int false "流程分类"
|
||||||
|
// @Param flowRemark body string false "流程描述"
|
||||||
|
// @Param flowFormData body string false "表单配置"
|
||||||
|
// @Param flowProcessData body string false "流程配置"
|
||||||
|
// @Success 200 {object} response.RespType "成功"
|
||||||
|
// @Router /api/flow_template/add [post]
|
||||||
|
func (hd FlowTemplateHandler) Add(c *gin.Context) {
|
||||||
|
var addReq FlowTemplateAddReq
|
||||||
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &addReq)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.CheckAndResp(c, hd.Service.Add(addReq))
|
||||||
|
}
|
||||||
|
// @Summary 流程模板编辑
|
||||||
|
// @Tags flow_template-流程模板
|
||||||
|
// @Produce json
|
||||||
|
// @Param Token header string true "token"
|
||||||
|
// @Param id body int false ""
|
||||||
|
// @Param flowName body string false "流程名称"
|
||||||
|
// @Param flowGroup body int false "流程分类"
|
||||||
|
// @Param flowRemark body string false "流程描述"
|
||||||
|
// @Param flowFormData body string false "表单配置"
|
||||||
|
// @Param flowProcessData body string false "流程配置"
|
||||||
|
// @Success 200 {object} response.RespType "成功"
|
||||||
|
// @Router /api/flow_template/edit [post]
|
||||||
|
func (hd FlowTemplateHandler) Edit(c *gin.Context) {
|
||||||
|
var editReq FlowTemplateEditReq
|
||||||
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &editReq)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.CheckAndResp(c, hd.Service.Edit(editReq))
|
||||||
|
}
|
||||||
|
// @Summary 流程模板删除
|
||||||
|
// @Tags flow_template-流程模板
|
||||||
|
// @Produce json
|
||||||
|
// @Param Token header string true "token"
|
||||||
|
// @Param id body int false ""
|
||||||
|
// @Success 200 {object} response.RespType "成功"
|
||||||
|
// @Router /api/flow_template/del [post]
|
||||||
|
func (hd FlowTemplateHandler) Del(c *gin.Context) {
|
||||||
|
var delReq FlowTemplateDelReq
|
||||||
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &delReq)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.CheckAndResp(c, hd.Service.Del(delReq.Id))
|
||||||
|
}
|
49
server/admin/flow_template/flow_template_schema.go
Normal file
49
server/admin/flow_template/flow_template_schema.go
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package flow_template
|
||||||
|
|
||||||
|
//FlowTemplateListReq 流程模板列表参数
|
||||||
|
type FlowTemplateListReq struct {
|
||||||
|
FlowName string `form:"flowName"` // 流程名称
|
||||||
|
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||||
|
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||||
|
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||||
|
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||||
|
}
|
||||||
|
|
||||||
|
//FlowTemplateDetailReq 流程模板详情参数
|
||||||
|
type FlowTemplateDetailReq struct {
|
||||||
|
Id int `form:"id"` //
|
||||||
|
}
|
||||||
|
|
||||||
|
//FlowTemplateAddReq 流程模板新增参数
|
||||||
|
type FlowTemplateAddReq struct {
|
||||||
|
FlowName string `form:"flowName"` // 流程名称
|
||||||
|
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||||
|
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||||
|
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||||
|
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||||
|
}
|
||||||
|
|
||||||
|
//FlowTemplateEditReq 流程模板新增参数
|
||||||
|
type FlowTemplateEditReq struct {
|
||||||
|
Id int `form:"id"` //
|
||||||
|
FlowName string `form:"flowName"` // 流程名称
|
||||||
|
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||||
|
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||||
|
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||||
|
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||||
|
}
|
||||||
|
|
||||||
|
//FlowTemplateDelReq 流程模板新增参数
|
||||||
|
type FlowTemplateDelReq struct {
|
||||||
|
Id int `form:"id"` //
|
||||||
|
}
|
||||||
|
|
||||||
|
//FlowTemplateResp 流程模板返回信息
|
||||||
|
type FlowTemplateResp struct {
|
||||||
|
Id int `json:"id" structs:"id"` //
|
||||||
|
FlowName string `json:"flowName" structs:"flowName"` // 流程名称
|
||||||
|
FlowGroup int `json:"flowGroup" structs:"flowGroup"` // 流程分类
|
||||||
|
FlowRemark string `json:"flowRemark" structs:"flowRemark"` // 流程描述
|
||||||
|
FlowFormData string `json:"flowFormData" structs:"flowFormData"` // 表单配置
|
||||||
|
FlowProcessData string `json:"flowProcessData" structs:"flowProcessData"` // 流程配置
|
||||||
|
}
|
128
server/admin/flow_template/flow_template_service.go
Normal file
128
server/admin/flow_template/flow_template_service.go
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
package flow_template
|
||||||
|
|
||||||
|
import (
|
||||||
|
"x_admin/core/request"
|
||||||
|
"x_admin/core/response"
|
||||||
|
"x_admin/model"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IFlowTemplateService interface {
|
||||||
|
List(page request.PageReq, listReq FlowTemplateListReq) (res response.PageResp, e error)
|
||||||
|
Detail(id int) (res FlowTemplateResp, e error)
|
||||||
|
Add(addReq FlowTemplateAddReq) (e error)
|
||||||
|
Edit(editReq FlowTemplateEditReq) (e error)
|
||||||
|
Del(id int) (e error)
|
||||||
|
}
|
||||||
|
|
||||||
|
//NewFlowTemplateService 初始化
|
||||||
|
func NewFlowTemplateService(db *gorm.DB) IFlowTemplateService {
|
||||||
|
return &flowTemplateService{db: db}
|
||||||
|
}
|
||||||
|
|
||||||
|
//flowTemplateService 流程模板服务实现类
|
||||||
|
type flowTemplateService struct {
|
||||||
|
db *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
//List 流程模板列表
|
||||||
|
func (Service flowTemplateService) List(page request.PageReq, listReq FlowTemplateListReq) (res response.PageResp, e error) {
|
||||||
|
// 分页信息
|
||||||
|
limit := page.PageSize
|
||||||
|
offset := page.PageSize * (page.PageNo - 1)
|
||||||
|
// 查询
|
||||||
|
dbModel := Service.db.Model(&model.FlowTemplate{})
|
||||||
|
if listReq.FlowName != "" {
|
||||||
|
dbModel = dbModel.Where("flow_name like ?", "%"+listReq.FlowName+"%")
|
||||||
|
}
|
||||||
|
if listReq.FlowGroup > 0 {
|
||||||
|
dbModel = dbModel.Where("flow_group = ?", listReq.FlowGroup)
|
||||||
|
}
|
||||||
|
if listReq.FlowRemark != "" {
|
||||||
|
dbModel = dbModel.Where("flow_remark = ?", listReq.FlowRemark)
|
||||||
|
}
|
||||||
|
if listReq.FlowFormData != "" {
|
||||||
|
dbModel = dbModel.Where("flow_form_data = ?", listReq.FlowFormData)
|
||||||
|
}
|
||||||
|
if listReq.FlowProcessData != "" {
|
||||||
|
dbModel = dbModel.Where("flow_process_data = ?", listReq.FlowProcessData)
|
||||||
|
}
|
||||||
|
// 总数
|
||||||
|
var count int64
|
||||||
|
err := dbModel.Count(&count).Error
|
||||||
|
if e = response.CheckErr(err, "List Count err"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 数据
|
||||||
|
var objs []model.FlowTemplate
|
||||||
|
err = dbModel.Limit(limit).Offset(offset).Order("id desc").Find(&objs).Error
|
||||||
|
if e = response.CheckErr(err, "List Find err"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resps := []FlowTemplateResp{}
|
||||||
|
response.Copy(&resps, objs)
|
||||||
|
return response.PageResp{
|
||||||
|
PageNo: page.PageNo,
|
||||||
|
PageSize: page.PageSize,
|
||||||
|
Count: count,
|
||||||
|
Lists: resps,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//Detail 流程模板详情
|
||||||
|
func (Service flowTemplateService) Detail(id int) (res FlowTemplateResp, e error) {
|
||||||
|
var obj model.FlowTemplate
|
||||||
|
err := Service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||||
|
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if e = response.CheckErr(err, "Detail First err"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.Copy(&res, obj)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add 流程模板新增
|
||||||
|
func (Service flowTemplateService) Add(addReq FlowTemplateAddReq) (e error) {
|
||||||
|
var obj model.FlowTemplate
|
||||||
|
response.Copy(&obj, addReq)
|
||||||
|
err := Service.db.Create(&obj).Error
|
||||||
|
e = response.CheckErr(err, "Add Create err")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//Edit 流程模板编辑
|
||||||
|
func (Service flowTemplateService) Edit(editReq FlowTemplateEditReq) (e error) {
|
||||||
|
var obj model.FlowTemplate
|
||||||
|
err := Service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
|
||||||
|
// 校验
|
||||||
|
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if e = response.CheckErr(err, "Edit First err"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 更新
|
||||||
|
response.Copy(&obj, editReq)
|
||||||
|
err = Service.db.Model(&obj).Updates(obj).Error
|
||||||
|
e = response.CheckErr(err, "Edit Updates err")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//Del 流程模板删除
|
||||||
|
func (Service flowTemplateService) Del(id int) (e error) {
|
||||||
|
var obj model.FlowTemplate
|
||||||
|
err := Service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||||
|
// 校验
|
||||||
|
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if e = response.CheckErr(err, "Del First err"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 删除
|
||||||
|
err = Service.db.Delete(&obj).Error
|
||||||
|
e = response.CheckErr(err, "Del Delete err")
|
||||||
|
return
|
||||||
|
}
|
42
server/admin/flow_template_route.go
Normal file
42
server/admin/flow_template_route.go
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"x_admin/core"
|
||||||
|
"x_admin/middleware"
|
||||||
|
"x_admin/admin/flow_template"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
集成
|
||||||
|
1. 导入
|
||||||
|
- 请先提交git避免文件覆盖!!!
|
||||||
|
- 下载并解压压缩包后,直接复制server、admin文件夹到项目根目录即可
|
||||||
|
|
||||||
|
2. 注册路由
|
||||||
|
请在 admin/entry.go 文件引入FlowTemplateRoute注册路由
|
||||||
|
|
||||||
|
3. 后台手动添加菜单和按钮
|
||||||
|
flow_template:add
|
||||||
|
flow_template:edit
|
||||||
|
flow_template:del
|
||||||
|
flow_template:list
|
||||||
|
flow_template:detail
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// FlowTemplateRoute(rg)
|
||||||
|
func FlowTemplateRoute(rg *gin.RouterGroup) {
|
||||||
|
db := core.GetDB()
|
||||||
|
|
||||||
|
server := flow_template.NewFlowTemplateService(db)
|
||||||
|
|
||||||
|
handle := flow_template.FlowTemplateHandler{Service: server}
|
||||||
|
|
||||||
|
rg = rg.Group("/", middleware.TokenAuth())
|
||||||
|
rg.GET("/flow_template/list", handle.List)
|
||||||
|
rg.GET("/flow_template/detail", handle.Detail)
|
||||||
|
rg.POST("/flow_template/add", handle.Add)
|
||||||
|
rg.POST("/flow_template/edit", handle.Edit)
|
||||||
|
rg.POST("/flow_template/del", handle.Del)
|
||||||
|
}
|
@@ -1,6 +1,5 @@
|
|||||||
package {{{ .ModuleName }}}
|
package {{{ .ModuleName }}}
|
||||||
|
|
||||||
import "x_admin/core"
|
|
||||||
|
|
||||||
//{{{ title (toCamelCase .EntityName) }}}ListReq {{{ .FunctionName }}}列表参数
|
//{{{ title (toCamelCase .EntityName) }}}ListReq {{{ .FunctionName }}}列表参数
|
||||||
type {{{ title (toCamelCase .EntityName) }}}ListReq struct {
|
type {{{ title (toCamelCase .EntityName) }}}ListReq struct {
|
||||||
|
11
server/model/flow_template.go
Normal file
11
server/model/flow_template.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
//FlowTemplate 流程模板实体
|
||||||
|
type FlowTemplate struct {
|
||||||
|
Id int `gorm:"primarykey;comment:''"` //
|
||||||
|
FlowName string `gorm:"comment:'流程名称'"` // 流程名称
|
||||||
|
FlowGroup int `gorm:"comment:'流程分类'"` // 流程分类
|
||||||
|
FlowRemark string `gorm:"comment:'流程描述'"` // 流程描述
|
||||||
|
FlowFormData string `gorm:"comment:'表单配置'"` // 表单配置
|
||||||
|
FlowProcessData string `gorm:"comment:'流程配置'"` // 流程配置
|
||||||
|
}
|
Reference in New Issue
Block a user