mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-05 16:17:00 +08:00
字典加入颜色方便使用
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<template v-for="(item, index) in getOptions" :key="index">
|
||||
<span>{{ index != 0 ? '、' : '' }}{{ item.name }}</span>
|
||||
<span :style="{ color: item.color }">{{ index != 0 ? '、' : '' }}{{ item.name }}</span>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
@@ -91,15 +91,14 @@ const formRules = {
|
||||
}
|
||||
]
|
||||
}
|
||||
function open(row) {
|
||||
function open(applyId) {
|
||||
console.log('open')
|
||||
Object.assign(formData, new formDataState())
|
||||
formData.id = row.id
|
||||
formData.id = applyId
|
||||
dialogVisible.value = true
|
||||
|
||||
flow_history_next_node({
|
||||
applyId: row.id,
|
||||
currentNodeId: ''
|
||||
applyId: applyId
|
||||
}).then((res) => {
|
||||
console.log('res', res)
|
||||
next_nodes.value = res
|
||||
@@ -122,14 +121,13 @@ function BeforeClose() {
|
||||
function getData() {
|
||||
console.log('getData', next_nodes)
|
||||
|
||||
if (!formData.applyUserId) {
|
||||
if (userTask.value && !formData.applyUserId) {
|
||||
feedback.msgWarning('请选择审批人')
|
||||
return
|
||||
}
|
||||
flow_history_pass({
|
||||
applyId: formData.id,
|
||||
currentNodeId: '',
|
||||
nextNodeAdminId: formData.applyUserId,
|
||||
nextNodeAdminId: formData.applyUserId || 0,
|
||||
passRemark: formData.passRemark
|
||||
}).then(() => {
|
||||
BeforeClose()
|
||||
|
@@ -2,9 +2,9 @@
|
||||
<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="templateId">
|
||||
<!-- <el-form-item label="模板" prop="templateId">
|
||||
<el-input v-model="queryParams.templateId" />
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<!-- <el-form-item label="申请人id" prop="applyUserId">
|
||||
<el-input v-model="queryParams.applyUserId" />
|
||||
</el-form-item>
|
||||
@@ -17,9 +17,9 @@
|
||||
<el-form-item label="流程分类" prop="flowGroup">
|
||||
<el-input v-model="queryParams.flowGroup" />
|
||||
</el-form-item>
|
||||
<el-form-item label="流程描述" prop="flowRemark">
|
||||
<!-- <el-form-item label="流程描述" prop="flowRemark">
|
||||
<el-input v-model="queryParams.flowRemark" />
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" clearable>
|
||||
<el-option label="全部" value="" />
|
||||
@@ -115,7 +115,12 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { flow_apply_delete, flow_apply_lists, flow_apply_edit } from '@/api/flow_apply'
|
||||
import {
|
||||
flow_apply_delete,
|
||||
flow_apply_lists,
|
||||
flow_apply_edit,
|
||||
flow_apply_detail
|
||||
} from '@/api/flow_apply'
|
||||
import { useDictData } from '@/hooks/useDictOptions'
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import feedback from '@/utils/feedback'
|
||||
@@ -175,27 +180,28 @@ const handleDelete = async (id: number) => {
|
||||
getLists()
|
||||
}
|
||||
|
||||
const OpenViewForm = async (data: any) => {
|
||||
const OpenViewForm = async (row: any) => {
|
||||
const detail = await flow_apply_detail({ id: row.id })
|
||||
let form_data = {}
|
||||
try {
|
||||
form_data = JSON.parse(data.formValue)
|
||||
form_data = JSON.parse(row.formValue)
|
||||
} catch (error) {
|
||||
// 解析失败
|
||||
}
|
||||
let form_json = {}
|
||||
try {
|
||||
form_json = JSON.parse(data.flowFormData)
|
||||
form_json = JSON.parse(detail.flowFormData)
|
||||
} catch (error) {
|
||||
// 解析失败
|
||||
}
|
||||
console.log(data, form_data, form_json)
|
||||
|
||||
viewFormRef.value?.open(data, form_json, form_data)
|
||||
console.log(detail, form_data, form_json)
|
||||
viewFormRef.value?.open(detail, form_json, form_data)
|
||||
}
|
||||
const OpenApplySubmit = async (data: any) => {
|
||||
console.log('OpenApplySubmit')
|
||||
|
||||
ApplySubmitRef.value?.open(data)
|
||||
ApplySubmitRef.value?.open(data.id)
|
||||
}
|
||||
const SaveViewForm = (id, form_data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -203,13 +209,13 @@ const SaveViewForm = (id, form_data) => {
|
||||
id: id,
|
||||
formValue: JSON.stringify(form_data)
|
||||
})
|
||||
.then(() => {
|
||||
.then(async () => {
|
||||
feedback.msgSuccess('保存成功')
|
||||
getLists()
|
||||
await getLists()
|
||||
|
||||
const row = pager.lists.find((item) => item.id === id)
|
||||
|
||||
ApplySubmitRef.value?.open(row)
|
||||
ApplySubmitRef.value?.open(row.id)
|
||||
|
||||
resolve(true)
|
||||
})
|
||||
|
@@ -1,165 +0,0 @@
|
||||
<!-- 审批 -->
|
||||
|
||||
<!-- 预览和编辑
|
||||
-->
|
||||
<!-- 审批记录备注 -->
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:show-close="true"
|
||||
:fullscreen="false"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
:destroy-on-close="true"
|
||||
title="审批"
|
||||
top="1px"
|
||||
>
|
||||
<v-form-render
|
||||
v-if="render"
|
||||
:form-json="formJson"
|
||||
:form-data="formRenderData"
|
||||
:option-data="optionData"
|
||||
ref="vFormRef"
|
||||
>
|
||||
</v-form-render>
|
||||
|
||||
<el-divider> 审批 </el-divider>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
label-position="top"
|
||||
label-width="110px"
|
||||
:rules="formRules"
|
||||
>
|
||||
<el-form-item v-if="userTask" :label="`${userTask?.label}节点审批人`" prop="templateId">
|
||||
<el-select
|
||||
class="flex-1"
|
||||
v-if="approverUserList.length"
|
||||
v-model="formData.applyUserId"
|
||||
placeholder="请选择审批人"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in approverUserList"
|
||||
:key="index"
|
||||
:label="item.nickname"
|
||||
:value="item.id"
|
||||
clearable
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="审批意见" prop="passRemark">
|
||||
<el-input
|
||||
v-model="formData.passRemark"
|
||||
:rows="2"
|
||||
type="textarea"
|
||||
placeholder="请输入审批意见"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">关闭</el-button>
|
||||
<el-button type="primary" @click="save"> 通过 </el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import 'vform3-builds/dist/designer.style.css' //引入VForm3样式
|
||||
import {
|
||||
flow_history_next_node,
|
||||
flow_history_get_approver,
|
||||
flow_history_pass
|
||||
} from '@/api/flow_history'
|
||||
import { flow_apply_detail } from '@/api/flow_apply'
|
||||
import { defineExpose, defineProps, defineOptions, reactive, ref, computed } from 'vue'
|
||||
defineOptions({
|
||||
name: 'todo-approve'
|
||||
})
|
||||
// 表单
|
||||
const formJson = ref({})
|
||||
const formRenderData = ref({})
|
||||
const optionData = reactive({})
|
||||
const vFormRef = ref(null)
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
|
||||
// 审批
|
||||
class formDataState {
|
||||
id = ''
|
||||
passRemark = ''
|
||||
applyUserId = ''
|
||||
}
|
||||
const formData = reactive(new formDataState())
|
||||
const next_nodes = ref([])
|
||||
const userTask = computed(() => {
|
||||
return next_nodes.value.find((item) => item.type == 'bpmn:userTask')
|
||||
})
|
||||
const approverUserList = ref([])
|
||||
const formRules = {
|
||||
applyUserId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择',
|
||||
trigger: ['blur']
|
||||
}
|
||||
]
|
||||
}
|
||||
const render = ref(false)
|
||||
function reset() {
|
||||
render.value = false
|
||||
}
|
||||
async function open(row) {
|
||||
reset()
|
||||
if (row) {
|
||||
dialogVisible.value = true
|
||||
|
||||
const flowFormData = await flow_apply_detail({
|
||||
id: row.applyId
|
||||
})
|
||||
|
||||
formRenderData.value = JSON.parse(row.formValue)
|
||||
formJson.value = JSON.parse(flowFormData.flowFormData)
|
||||
|
||||
render.value = true
|
||||
flow_history_next_node({
|
||||
applyId: row.applyId,
|
||||
currentNodeId: row.nodeId
|
||||
}).then((res) => {
|
||||
console.log('res', res)
|
||||
next_nodes.value = res
|
||||
|
||||
res.map((item) => {
|
||||
if (item.type == 'bpmn:userTask') {
|
||||
flow_history_get_approver(item).then((user) => {
|
||||
console.log('user', user)
|
||||
approverUserList.value = user
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
function save() {
|
||||
vFormRef.value.getFormData().then((formData) => {
|
||||
console.log('formData', formData)
|
||||
|
||||
flow_history_pass({
|
||||
applyId: formData.id,
|
||||
passRemark: formData.passRemark,
|
||||
applyUserId: formData.applyUserId
|
||||
}).then((res) => {
|
||||
console.log('res', res)
|
||||
dialogVisible.value = false
|
||||
})
|
||||
})
|
||||
}
|
||||
defineExpose({
|
||||
open
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.el-range-editor.el-input__wrapper {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
@@ -7,13 +7,6 @@
|
||||
<el-input v-model="queryParams.applyUserNickname" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="审批用户昵称" prop="approverNickname">
|
||||
<el-input v-model="queryParams.approverNickname" />
|
||||
</el-form-item>
|
||||
<el-form-item label="节点" prop="nodeId">
|
||||
<el-input v-model="queryParams.nodeId" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
@@ -21,25 +14,12 @@
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none mt-4" shadow="never">
|
||||
<div>
|
||||
<el-button v-perms="['flow_history:add']" type="primary" @click="handleAdd()">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
</div>
|
||||
<!-- <div></div> -->
|
||||
<el-table class="mt-4" size="large" v-loading="pager.loading" :data="pager.lists">
|
||||
<el-table-column label="申请人昵称" prop="applyUserNickname" min-width="100" />
|
||||
<!-- <el-table-column label="审批人id" prop="approverId" min-width="100" />
|
||||
<el-table-column label="审批用户昵称" prop="approverNickname" min-width="100" /> -->
|
||||
<el-table-column label="节点" prop="nodeId" min-width="100" />
|
||||
<el-table-column label="表单值" prop="formValue" min-width="100" />
|
||||
<el-table-column
|
||||
label="通过状态:1待处理,2通过,3拒绝"
|
||||
prop="passStatus"
|
||||
min-width="100"
|
||||
>
|
||||
<el-table-column label="申请人" prop="applyUserNickname" min-width="100" />
|
||||
|
||||
<!-- <el-table-column label="表单值" prop="formValue" min-width="100" /> -->
|
||||
<el-table-column label="通过状态" prop="passStatus" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<dict-value
|
||||
:options="dictData.flow_history_status"
|
||||
@@ -52,13 +32,29 @@
|
||||
<el-table-column label="创建时间" prop="createTime" min-width="150" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
<!-- <el-button
|
||||
v-perms="['flow_history:edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleOpen(row)"
|
||||
>
|
||||
审批
|
||||
</el-button> -->
|
||||
<el-button
|
||||
v-perms="['flow_apply:edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="OpenViewForm(row)"
|
||||
>
|
||||
{{ row.status == 1 ? '编辑表单' : '预览' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['flow_apply:edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="OpenApplySubmit(row)"
|
||||
>
|
||||
审批
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -68,35 +64,34 @@
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<Approve ref="ApproveRef"></Approve>
|
||||
<!-- <Approve ref="ApproveRef"></Approve> -->
|
||||
|
||||
<ViewForm ref="viewFormRef" :save="SaveViewForm"></ViewForm>
|
||||
<ApplySubmit ref="ApplySubmitRef" @close="getLists"></ApplySubmit>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { flow_history_list } from '@/api/flow_history'
|
||||
import { flow_apply_detail } from '@/api/flow_apply'
|
||||
import { flow_history_list, flow_history_edit } from '@/api/flow_history'
|
||||
import { useDictData } from '@/hooks/useDictOptions'
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import feedback from '@/utils/feedback'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
import Approve from './components/todo/approve.vue'
|
||||
|
||||
import ApplySubmit from '@/views/flow_apply/components/apply_submit.vue'
|
||||
import ViewForm from '@/components/flow/XForm/view.vue'
|
||||
const userStore = useUserStore()
|
||||
|
||||
defineOptions({
|
||||
name: 'todo'
|
||||
})
|
||||
const ApproveRef = shallowRef<InstanceType<typeof ApproveRef>>()
|
||||
const viewFormRef = shallowRef<InstanceType<typeof ViewForm>>()
|
||||
const ApplySubmitRef = shallowRef<InstanceType<typeof ApplySubmit>>()
|
||||
|
||||
const queryParams = reactive({
|
||||
applyId: '',
|
||||
templateId: '',
|
||||
applyUserId: '',
|
||||
applyUserNickname: '',
|
||||
approverId: userStore?.userInfo?.id,
|
||||
approverNickname: '',
|
||||
nodeId: '',
|
||||
formValue: '',
|
||||
passStatus: 1,
|
||||
passRemark: ''
|
||||
applyUserNickname: '',
|
||||
passStatus: 1
|
||||
})
|
||||
|
||||
const { pager, getLists, resetPage, resetParams } = usePaging({
|
||||
@@ -106,9 +101,55 @@ const { pager, getLists, resetPage, resetParams } = usePaging({
|
||||
const { dictData } = useDictData<{
|
||||
flow_history_status: any[]
|
||||
}>(['flow_history_status'])
|
||||
const handleOpen = async (row) => {
|
||||
ApproveRef.value?.open(toRaw(row))
|
||||
// const handleOpen = async (row) => {
|
||||
// ApproveRef.value?.open(toRaw(row))
|
||||
// }
|
||||
const OpenViewForm = async (row: any) => {
|
||||
const detail = await flow_apply_detail({ id: row.applyId })
|
||||
|
||||
let form_data = {}
|
||||
try {
|
||||
form_data = JSON.parse(row.formValue)
|
||||
} catch (error) {
|
||||
// 解析失败
|
||||
}
|
||||
let form_json = {}
|
||||
try {
|
||||
form_json = JSON.parse(detail.flowFormData)
|
||||
} catch (error) {
|
||||
// 解析失败
|
||||
}
|
||||
|
||||
console.log(detail, form_data, form_json)
|
||||
|
||||
viewFormRef.value?.open(detail, form_json, form_data)
|
||||
}
|
||||
const SaveViewForm = (id, form_data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
flow_history_edit({
|
||||
id: id,
|
||||
formValue: JSON.stringify(form_data)
|
||||
})
|
||||
.then(async () => {
|
||||
feedback.msgSuccess('保存成功')
|
||||
await getLists()
|
||||
|
||||
const row = pager.lists.find((item) => item.id === id)
|
||||
|
||||
ApplySubmitRef.value?.open(row.applyId)
|
||||
|
||||
resolve(true)
|
||||
})
|
||||
.catch((err) => {
|
||||
feedback.msgError(err.message)
|
||||
reject()
|
||||
})
|
||||
})
|
||||
}
|
||||
const OpenApplySubmit = async (row: any) => {
|
||||
console.log('OpenApplySubmit')
|
||||
|
||||
ApplySubmitRef.value?.open(row.applyId)
|
||||
}
|
||||
getLists()
|
||||
</script>
|
||||
|
@@ -29,6 +29,13 @@
|
||||
<el-form-item label="数据值" prop="value">
|
||||
<el-input v-model="formData.value" placeholder="请输入数据值" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="颜色" prop="color">
|
||||
<el-input
|
||||
v-model="formData.color"
|
||||
placeholder="请输入颜色值(可选)"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<div>
|
||||
<el-input-number v-model="formData.sort" :min="0" :max="9999" />
|
||||
@@ -73,6 +80,7 @@ const formData = reactive({
|
||||
typeValue: '',
|
||||
name: '',
|
||||
value: '',
|
||||
color: '',
|
||||
sort: 0,
|
||||
status: 1,
|
||||
remark: '',
|
||||
|
@@ -5,12 +5,21 @@
|
||||
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" inline>
|
||||
<el-form-item label="字典名称">
|
||||
<el-select class="w-[280px]" v-model="queryParams.dictType" @change="getLists">
|
||||
<el-option v-for="item in optionsData.dictType" :label="item.dictName" :value="item.dictType"
|
||||
:key="item.id" />
|
||||
<el-option
|
||||
v-for="item in optionsData.dictType"
|
||||
:label="item.dictName"
|
||||
:value="item.dictType"
|
||||
:key="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据名称">
|
||||
<el-input class="w-[280px]" v-model="queryParams.name" clearable @keyup.enter="resetPage" />
|
||||
<el-input
|
||||
class="w-[280px]"
|
||||
v-model="queryParams.name"
|
||||
clearable
|
||||
@keyup.enter="resetPage"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据状态">
|
||||
<el-select class="w-[280px]" v-model="queryParams.status">
|
||||
@@ -33,8 +42,12 @@
|
||||
</template>
|
||||
添加数据
|
||||
</el-button>
|
||||
<el-button v-perms="['setting:dict:data:del']" :disabled="!selectData.length" type="danger"
|
||||
@click="handleDelete(selectData)">
|
||||
<el-button
|
||||
v-perms="['setting:dict:data:del']"
|
||||
:disabled="!selectData.length"
|
||||
type="danger"
|
||||
@click="handleDelete(selectData)"
|
||||
>
|
||||
<template #icon>
|
||||
<icon name="el-icon-Delete" />
|
||||
</template>
|
||||
@@ -43,27 +56,45 @@
|
||||
</div>
|
||||
<div class="mt-4" v-loading="pager.loading">
|
||||
<div>
|
||||
<el-table :data="pager.lists" size="large" @selection-change="handleSelectionChange">
|
||||
<el-table
|
||||
:data="pager.lists"
|
||||
size="large"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="ID" prop="id" />
|
||||
<el-table-column label="数据名称" prop="name" min-width="120" />
|
||||
<el-table-column label="数据值" prop="value" min-width="120" />
|
||||
<el-table-column label="颜色" prop="color" min-width="120" />
|
||||
<el-table-column label="状态">
|
||||
<template v-slot="{ row }">
|
||||
<el-tag v-if="row.status == 1">正常</el-tag>
|
||||
<el-tag v-else type="danger">停用</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" prop="remark" min-width="120" show-tooltip-when-overflow />
|
||||
<el-table-column
|
||||
label="备注"
|
||||
prop="remark"
|
||||
min-width="120"
|
||||
show-tooltip-when-overflow
|
||||
/>
|
||||
<el-table-column label="排序" prop="sort" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-perms="['setting:dict:data:edit']" link type="primary"
|
||||
@click="handleEdit(row)">
|
||||
<el-button
|
||||
v-perms="['setting:dict:data:edit']"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button v-perms="['setting:dict:data:del']" link type="danger"
|
||||
@click="handleDelete([row.id])">
|
||||
<el-button
|
||||
v-perms="['setting:dict:data:del']"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete([row.id])"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
|
@@ -141,11 +141,11 @@ func (hd FlowHistoryHandler) Del(c *gin.Context) {
|
||||
//
|
||||
// @Router /api/flow_apply/SubmitApply [post]
|
||||
func (hd FlowHistoryHandler) Pass(c *gin.Context) {
|
||||
var nextNode NextNodeReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &nextNode)) {
|
||||
var pass PassReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &pass)) {
|
||||
return
|
||||
}
|
||||
err := Service.Pass(nextNode)
|
||||
err := Service.Pass(pass)
|
||||
response.CheckAndResp(c, err)
|
||||
|
||||
// 申请流程id,
|
||||
@@ -174,7 +174,7 @@ func (hd FlowHistoryHandler) NextNode(c *gin.Context) {
|
||||
}
|
||||
|
||||
// response.CheckAndResp(c, Service.GetNextNode(nextNode))
|
||||
res, _, err := Service.GetNextNode(nextNode)
|
||||
res, _, _, err := Service.GetNextNode(nextNode.ApplyId)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
|
@@ -72,12 +72,6 @@ type FlowHistoryResp struct {
|
||||
CreateTime core.TsTime `json:"createTime" structs:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
type NextNodeReq struct {
|
||||
ApplyId int `form:"applyId"` // 申请id
|
||||
CurrentNodeId string `form:"currentNodeId"` // 流程里的节点id
|
||||
FormValue string `form:"formValue"`
|
||||
NextNodeAdminId int `form:"nextNodeAdminId"` // 下一个节点的审批用户id
|
||||
}
|
||||
type FlowTree struct {
|
||||
Id string `json:"id"`
|
||||
Pid string `json:"pid"`
|
||||
@@ -92,3 +86,17 @@ type FlowTree struct {
|
||||
|
||||
Children *[]FlowTree `json:"children"`
|
||||
}
|
||||
type NextNodeReq struct {
|
||||
ApplyId int `form:"applyId"` // 申请id
|
||||
// CurrentNodeId string `form:"currentNodeId"` // 流程里的节点id
|
||||
// FormValue string `form:"formValue"`
|
||||
// NextNodeAdminId int `form:"nextNodeAdminId"` // 下一个节点的审批用户id
|
||||
}
|
||||
type PassReq struct {
|
||||
ApplyId int `form:"applyId"` // 申请id
|
||||
|
||||
// CurrentNodeId string `form:"currentNodeId"` // 流程里的节点id
|
||||
// FormValue string `form:"formValue"`
|
||||
NextNodeAdminId int `form:"nextNodeAdminId"` // 下一个节点的审批用户id
|
||||
PassRemark string `form:"passRemark"` // 通过备注
|
||||
}
|
||||
|
@@ -215,84 +215,111 @@ func (Service flowHistoryService) GetApprover(node FlowTree) (res []admin.System
|
||||
return adminResp, nil
|
||||
}
|
||||
|
||||
func (Service flowHistoryService) Pass(nextNode NextNodeReq) (e error) {
|
||||
nextNodes, applyDetail, err := Service.GetNextNode(nextNode)
|
||||
func (Service flowHistoryService) Pass(pass PassReq) (e error) {
|
||||
nextNodes, applyDetail, LastHistory, err := Service.GetNextNode(pass.ApplyId)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
isEnd := false // 是否是最后一个节点
|
||||
|
||||
FormValue := applyDetail.FormValue
|
||||
if LastHistory.Id != 0 {
|
||||
FormValue = LastHistory.FormValue
|
||||
}
|
||||
var flows = []model.FlowHistory{}
|
||||
|
||||
isEnd := false
|
||||
if err == nil {
|
||||
for _, v := range nextNodes {
|
||||
// if v.Type == "bpmn:exclusiveGateway" {
|
||||
// 这里网关不用处理,顶多加一条历史记录
|
||||
// }
|
||||
var flow = model.FlowHistory{
|
||||
ApplyId: applyDetail.Id,
|
||||
NodeId: v.Id,
|
||||
FormValue: FormValue,
|
||||
PassStatus: 1,
|
||||
ApplyUserId: applyDetail.ApplyUserId,
|
||||
TemplateId: applyDetail.TemplateId,
|
||||
ApplyUserNickname: applyDetail.ApplyUserNickname,
|
||||
ApproverId: 0,
|
||||
}
|
||||
if v.Type == "bpmn:serviceTask" {
|
||||
// 发邮件之类的,待完善
|
||||
} else if v.Type == "bpmn:userTask" {
|
||||
var addReq = FlowHistoryAddReq{}
|
||||
addReq.ApplyId = applyDetail.Id
|
||||
addReq.FormValue = applyDetail.FormValue
|
||||
addReq.NodeId = v.Id
|
||||
addReq.ApproverId = nextNode.NextNodeAdminId
|
||||
|
||||
// addReq.ApproverNickname = applyDetail.ApproverNickname
|
||||
|
||||
addReq.TemplateId = applyDetail.TemplateId
|
||||
addReq.ApplyUserId = applyDetail.ApplyUserId
|
||||
addReq.ApplyUserNickname = applyDetail.ApplyUserNickname
|
||||
addReq.PassStatus = 1
|
||||
err = Service.Add(addReq)
|
||||
flow.ApproverId = pass.NextNodeAdminId
|
||||
flow.PassStatus = 1 //1待处理
|
||||
} else if v.Type == "bpmn:endEvent" {
|
||||
isEnd = true
|
||||
var addReq = FlowHistoryAddReq{}
|
||||
addReq.ApplyId = applyDetail.Id
|
||||
addReq.FormValue = applyDetail.FormValue
|
||||
addReq.NodeId = v.Id
|
||||
addReq.ApproverId = 0
|
||||
flow.ApproverId = 0
|
||||
flow.PassStatus = 2 //2通过
|
||||
}
|
||||
flows = append(flows, flow)
|
||||
}
|
||||
|
||||
// addReq.ApproverNickname = applyDetail.ApproverNickname
|
||||
err = Service.db.Transaction(func(tx *gorm.DB) error {
|
||||
// 在事务中执行一些 db 操作(从这里开始,您应该使用 'tx' 而不是 'db')
|
||||
if err := tx.Create(&flows).Error; err != nil {
|
||||
// 返回任何错误都会回滚事务
|
||||
return err
|
||||
}
|
||||
// LastHistory
|
||||
tx.Model(&LastHistory).Update("pass_status", 2)
|
||||
if LastHistory.Id > 0 {
|
||||
LastHistory.PassStatus = 2
|
||||
LastHistory.PassRemark = pass.PassRemark
|
||||
tx.Save(&LastHistory)
|
||||
}
|
||||
|
||||
addReq.TemplateId = applyDetail.TemplateId
|
||||
addReq.ApplyUserId = applyDetail.ApplyUserId
|
||||
addReq.ApplyUserNickname = applyDetail.ApplyUserNickname
|
||||
addReq.PassStatus = 2
|
||||
err = Service.Add(addReq)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 待提交或者有结束节点,修改申请状态
|
||||
if applyDetail.Status == 1 || isEnd {
|
||||
status := 2 //审批中
|
||||
if isEnd {
|
||||
status = 3 //审批通过
|
||||
}
|
||||
// 更改状态
|
||||
err = flow_apply.Service.Edit(flow_apply.FlowApplyEditReq{
|
||||
Id: nextNode.ApplyId,
|
||||
Status: status,
|
||||
})
|
||||
tx.Model(&model.FlowApply{}).Where(model.FlowApply{
|
||||
Id: pass.ApplyId,
|
||||
}).Update("status", status)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一批流程,直到审批或结束节点
|
||||
*/
|
||||
func (Service flowHistoryService) GetNextNode(nextNode NextNodeReq) (res []FlowTree, apply flow_apply.FlowApplyResp, e error) {
|
||||
var applyDetail, err = flow_apply.Service.Detail(nextNode.ApplyId)
|
||||
func (Service flowHistoryService) GetNextNode(ApplyId int) (res []FlowTree, apply flow_apply.FlowApplyResp, LastHistory model.FlowHistory, e error) {
|
||||
var applyDetail, err = flow_apply.Service.Detail(ApplyId)
|
||||
|
||||
if e = response.CheckErr(err, "获取审批申请失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// 获取最后一条历史记录
|
||||
// var LastHistory model.FlowHistory
|
||||
result := Service.db.Where(model.FlowHistory{
|
||||
ApplyId: ApplyId,
|
||||
}).Limit(1).Last(&LastHistory)
|
||||
|
||||
// start
|
||||
var flowTree []FlowTree
|
||||
json.Unmarshal([]byte(applyDetail.FlowProcessDataList), &flowTree)
|
||||
var formValue map[string]interface{}
|
||||
json.Unmarshal([]byte(nextNode.FormValue), &formValue)
|
||||
|
||||
if result.RowsAffected == 1 { //有最新审批记录
|
||||
json.Unmarshal([]byte(LastHistory.FormValue), &formValue)
|
||||
|
||||
} else {
|
||||
json.Unmarshal([]byte(applyDetail.FormValue), &formValue)
|
||||
}
|
||||
|
||||
var next []FlowTree
|
||||
|
||||
if nextNode.CurrentNodeId == "" {
|
||||
if result.RowsAffected == 0 {
|
||||
// if nextNode.CurrentNodeId == "" {
|
||||
for _, v := range flowTree {
|
||||
if v.Type == "bpmn:startEvent" {
|
||||
next = *v.Children
|
||||
@@ -301,7 +328,7 @@ func (Service flowHistoryService) GetNextNode(nextNode NextNodeReq) (res []FlowT
|
||||
}
|
||||
} else {
|
||||
for _, v := range flowTree {
|
||||
if v.Id == nextNode.CurrentNodeId {
|
||||
if v.Id == LastHistory.NodeId {
|
||||
next = *v.Children
|
||||
break
|
||||
}
|
||||
@@ -309,7 +336,7 @@ func (Service flowHistoryService) GetNextNode(nextNode NextNodeReq) (res []FlowT
|
||||
}
|
||||
var nextNodes []FlowTree
|
||||
res = DeepNextNode(nextNodes, &next, formValue)
|
||||
return res, applyDetail, e
|
||||
return res, applyDetail, LastHistory, e
|
||||
}
|
||||
|
||||
// 返回节点数组,最后一个节点为用户或结束节点
|
||||
|
@@ -8,6 +8,7 @@ type SettingDictDataResp struct {
|
||||
TypeId uint `json:"typeId" structs:"typeId"` // 类型
|
||||
Name string `json:"name" structs:"name"` // 键
|
||||
Value string `json:"value" structs:"value"` // 值
|
||||
Color string `json:"color" structs:"color"` // 颜色
|
||||
Remark string `json:"remark" structs:"remark"` // 备注
|
||||
Sort uint16 `json:"sort" structs:"sort"` // 排序
|
||||
Status uint8 `json:"status" structs:"status"` // 状态: [0=停用, 1=禁用]
|
||||
@@ -33,7 +34,8 @@ type SettingDictDataAddReq struct {
|
||||
TypeId uint `form:"typeId" binding:"required,gt=0"` // 类型
|
||||
Name string `form:"name" binding:"required,max=100"` // 键
|
||||
Value string `form:"value" binding:"required,max=200"` // 值
|
||||
remark string `form:"remark" binding:"max=200"` // 备注
|
||||
Color string `form:"color"` // 颜色
|
||||
Remark string `form:"remark" binding:"max=200"` // 备注
|
||||
Sort int `form:"sort" binding:"gte=0"` // 排序
|
||||
Status int8 `form:"status,default=-1" binding:"oneof=-1 0 1"` // 状态: 0=停用,1=启用
|
||||
}
|
||||
@@ -44,7 +46,8 @@ type SettingDictDataEditReq struct {
|
||||
TypeId uint `form:"typeId" binding:"required,gte=0"` // 类型
|
||||
Name string `form:"name" binding:"required,max=100"` // 键
|
||||
Value string `form:"value" binding:"required,max=200"` // 值
|
||||
remark string `form:"remark" binding:"max=200"` // 备注
|
||||
Color string `form:"color"` // 颜色
|
||||
Remark string `form:"remark" binding:"max=200"` // 备注
|
||||
Sort int `form:"sort" binding:"gte=0"` // 排序
|
||||
Status int8 `form:"status,default=-1" binding:"oneof=-1 0 1"` // 状态: 0=停用,1=启用
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ func main() {
|
||||
fmt.Println("格式化文档注释:", "swag fmt")
|
||||
fmt.Println("生成文档:", "swag init")
|
||||
|
||||
fmt.Println("文档:", "http://localhost:8001/swagger/index.html")
|
||||
fmt.Printf("文档: http://localhost:%v/swagger/index.html", config.Config.ServerPort)
|
||||
// 初始化server
|
||||
s := initServer(router)
|
||||
// 运行服务
|
||||
|
@@ -6,6 +6,7 @@ type DictData struct {
|
||||
TypeId uint `gorm:"not null;default:0;comment:'类型'"`
|
||||
Name string `gorm:"not null;default:'';comment:'键名''"`
|
||||
Value string `gorm:"not null;default:'';comment:'数值'"`
|
||||
Color string `gorm:"default:'';comment:'颜色'"`
|
||||
Remark string `gorm:"not null;default:'';comment:'备注'"`
|
||||
Sort uint16 `gorm:"not null;default:0;comment:'排序'"`
|
||||
Status uint8 `gorm:"not null;default:1;comment:'字典状态: 0=停用, 1=正常'"`
|
||||
|
Reference in New Issue
Block a user