@ -1,6 +1,6 @@
< template >
< div class = "page-bg-wrap" >
< a-spin tip = "Loading..." :spinning = "loading" >
< a-spin :spinning = "loading" tip = "加载中..." >
< div class = "geg-flow-page" >
< div class = "top-toolbar" >
< a-space :size = "10" wrap >
@ -10,7 +10,7 @@
< / slot >
关闭
< / a-button >
< a-button type = "primary" :disabled = "data.submitLoading" @click ="saveLaunch" >
< a-button :disabled = "data.submitLoading" type = "primary" @click ="saveLaunch" >
< slot name = "icon" >
< send-outlined / >
< / slot >
@ -37,9 +37,7 @@
< / a-space >
< / div >
< div class = "flow-content" >
< FormInformation :key = "randKey" ref = "formInformation" :disabled = "false"
:formAssignmentData = "data.formAssignmentData" :formInfos = "data.formInfos"
:opinions = "data.opinions" :opinionsComponents = "data.opinionsComponents" / >
< FormInformation :key = "randKey" ref = "formInformation" :disabled = "false" :formAssignmentData = "data.formAssignmentData" :formInfos = "data.formInfos" :opinions = "data.opinions" :opinionsComponents = "data.opinionsComponents" / >
< / div >
< / div >
< a-modal :visible = "showFlowChart" centered class = "geg" closable title = "流程图" width = "1200px" >
@ -54,45 +52,45 @@
< / template >
< script setup >
import { useRouter } from 'vue-router' ;
import userTaskItem from '/@/views/workflow/task/hooks/userTaskItem' ;
import FormInformation from '/@/views/secondDev/FormInformation.vue' ;
import ProcessInformation from '/@/views/workflow/task/components/flow/ProcessInformation.vue' ;
import { getStartProcessInfo , getReStartProcessInfo , reLaunch , postLaunch , postApproval , postGetNextTaskMaybeArrival } from '/@/api/workflow/task' ;
import { useMultipleTabStore } from '/@/store/modules/multipleTab' ;
import { CloseOutlined , SendOutlined , ClockCircleOutlined , PrinterOutlined , ApartmentOutlined } from '@ant-design/icons-vue' ;
import { nextTick , onMounted , ref , toRaw , reactive } from 'vue' ;
import { postDraft , putDraft } from '/@/api/workflow/process' ;
import { useI18n } from '/@/hooks/web/useI18n' ;
import { separator } from '/@bpmn/config/info' ;
import { message } from 'ant-design-vue' ;
import OpinionDialog from '/@/components/SecondDev/OpinionDialog.vue' ;
import { ApproveCode , ApproveType } from '/@/enums/workflowEnum' ;
import useEventBus from '/@/hooks/event/useEventBus' ;
import { useRouter } from 'vue-router' ;
import userTaskItem from '/@/views/workflow/task/hooks/userTaskItem' ;
import FormInformation from '/@/views/secondDev/FormInformation.vue' ;
import ProcessInformation from '/@/views/workflow/task/components/flow/ProcessInformation.vue' ;
import { getStartProcessInfo , getReStartProcessInfo , reLaunch , postLaunch , postApproval , postGetNextTaskMaybeArrival } from '/@/api/workflow/task' ;
import { useMultipleTabStore } from '/@/store/modules/multipleTab' ;
import { CloseOutlined , SendOutlined , ClockCircleOutlined , PrinterOutlined , ApartmentOutlined } from '@ant-design/icons-vue' ;
import { nextTick , onMounted , ref , toRaw , reactive } from 'vue' ;
import { postDraft , putDraft } from '/@/api/workflow/process' ;
import { useI18n } from '/@/hooks/web/useI18n' ;
import { separator } from '/@bpmn/config/info' ;
import { message } from 'ant-design-vue' ;
import OpinionDialog from '/@/components/SecondDev/OpinionDialog.vue' ;
import { ApproveCode , ApproveType } from '/@/enums/workflowEnum' ;
import useEventBus from '/@/hooks/event/useEventBus' ;
const { bus , CREATE _FLOW } = useEventBus ( ) ;
const { bus , CREATE _FLOW } = useEventBus ( ) ;
const router = useRouter ( ) ;
const tabStore = useMultipleTabStore ( ) ;
const router = useRouter ( ) ;
const tabStore = useMultipleTabStore ( ) ;
const { t } = useI18n ( ) ;
const { data , approveUserData , initProcessData , notificationSuccess , notificationError } = userTaskItem ( ) ;
const currentRoute = router . currentRoute . value ;
const rParams = currentRoute . params ;
const fullPath = currentRoute . fullPath ; ;
const rSchemaId = rParams . arg1 ;
const rDraftsId = rParams . arg2 ;
const taskId = ref ( ) ;
const loading = ref ( false )
const draftsJsonStr = localStorage . getItem ( 'draftsJsonStr' ) ;
let formInformation = ref ( ) ;
const opinionDlg = ref ( ) ;
let pageMode = 'new' ;
const showFlowChart = ref ( false ) ;
const disableSubmit = ref ( false ) ;
const mainFormModels = ref ( ) ;
let randKey = ref ( 'randkey' ) ; // 强制表单重新渲染
let approvalData = reactive ( {
const { t } = useI18n ( ) ;
const { data , approveUserData , initProcessData , notificationSuccess , notificationError } = userTaskItem ( ) ;
const currentRoute = router . currentRoute . value ;
const rParams = currentRoute . params ;
const fullPath = currentRoute . fullPath ;
const rSchemaId = rParams . arg1 ;
const rDraftsId = rParams . arg2 ;
const taskId = ref ( ) ;
const loading = ref ( false ) ;
const draftsJsonStr = localStorage . getItem ( 'draftsJsonStr' ) ;
let formInformation = ref ( ) ;
const opinionDlg = ref ( ) ;
let pageMode = 'new' ;
const showFlowChart = ref ( false ) ;
const disableSubmit = ref ( false ) ;
const mainFormModels = ref ( ) ;
let randKey = ref ( 'randkey' ) ; // 强制表单重新渲染
let approvalData = reactive ( {
isCountersign : false ,
isAddOrSubSign : false ,
stampInfo : {
@ -107,32 +105,32 @@ let approvalData = reactive({
rejectNodeActivityIds : [ ] ,
circulateConfigs : [ ] ,
nextTaskUser : { } // 格式为taskKey: 用户id( 逗号分隔)
} ) ;
} ) ;
if ( draftsJsonStr ) {
if ( draftsJsonStr ) {
localStorage . removeItem ( 'draftsJsonStr' ) ;
pageMode = 'draft' ;
}
}
function closeFlowChart ( ) {
function closeFlowChart ( ) {
showFlowChart . value = false ;
}
}
function openFlowChart ( ) {
function openFlowChart ( ) {
showFlowChart . value = true ;
}
}
function close ( ) {
function close ( ) {
tabStore . closeTab ( currentRoute , router ) ;
}
}
const props = defineProps ( {
const props = defineProps ( {
rowKeyData : {
type : String
}
} ) ;
} ) ;
onMounted ( async ( ) => {
onMounted ( async ( ) => {
try {
// 发起流程
let res = await getStartProcessInfo ( rSchemaId ) ;
@ -142,14 +140,14 @@ onMounted(async () => {
tabStore . changeTitle ( fullPath , ` ${ tabPrefix } : ${ title } ` ) ;
}
initProcessData ( res ) ;
} catch ( error ) { }
} catch ( error ) { }
randKey . value = Math . random ( ) + '' ;
// 这里的顺序不能变 表单不渲染的时候 设置表单初值没用
await nextTick ( ) ;
await initDraftsFormData ( ) ;
} ) ;
} ) ;
async function initDraftsFormData ( ) {
async function initDraftsFormData ( ) {
//isPublish.value = Object.keys(data.formInfos).length > 0 ? false : true;
if ( draftsJsonStr ) {
let formDataJson = JSON . parse ( draftsJsonStr ) ;
@ -162,9 +160,9 @@ async function initDraftsFormData() {
} ) ;
await formInformation . value . setFormData ( formData ) ;
}
}
}
async function saveDraft ( ) {
async function saveDraft ( ) {
try {
disableSubmit . value = true ;
let formModels = await formInformation . value . saveDraftData ( ) ;
@ -178,18 +176,17 @@ async function saveDraft() {
} catch ( error ) {
notificationError ( '保存草稿' ) ;
}
}
}
function showResult ( res , title ) {
function showResult ( res , title ) {
if ( res ) {
notificationSuccess ( title ) ;
} else {
notificationError ( title ) ;
}
}
}
function createFlowSuccess ( taskList ) {
function createFlowSuccess ( taskList ) {
/*opinionDlg.value.toggleDialog({
isClose: true
});*/
@ -199,24 +196,23 @@ function createFlowSuccess(taskList) {
message . success ( '流程发起成功' ) ;
data . submitLoading = false ;
loading . value = false
loading . value = false ;
setTimeout ( ( ) => {
bus . emit ( CREATE _FLOW , { } ) ;
close ( ) ;
} , 500 ) ;
}
}
}
async function approvalCreate ( ) {
async function approvalCreate ( ) {
const params = await getApproveParams ( ) ;
let fileFolderIds = getUploadFileFolderIds ( mainFormModels . value ) ;
let system = formInformation . value . getSystemType ( ) ;
const nextNodes = await postGetNextTaskMaybeArrival ( params ) ;
opinionDlg . value . toggleDialog ( {
action : 'agree' ,
nextNodes ,
rejectCancel : ( ) => {
loading . value = false ;
data . submitLoading = false ;
} ,
callback : ( args ) => {
approvalData . approvedContent = args . opinion ;
@ -224,8 +220,9 @@ async function approvalCreate() {
onFinish ( { } ) ;
}
} ) ;
}
function flowSuccess ( ) {
}
function flowSuccess ( ) {
opinionDlg . value . toggleDialog ( {
isClose : true
} ) ;
@ -234,24 +231,27 @@ function flowSuccess() {
bus . emit ( CREATE _FLOW , { } ) ;
close ( ) ;
} , 500 ) ;
}
function flowFail ( ) {
}
function flowFail ( ) {
opinionDlg . value . stopLoading ( ) ;
}
async function onFinish ( values ) {
}
async function onFinish ( values ) {
try {
if ( /*validateSuccess.value*/ true ) {
let params = await getApproveParams ( ) ;
await postApproval ( params ) ;
flowSuccess ( ) ;
data . submitLoading = false ;
loading . value = false
loading . value = false ;
}
} catch ( error ) {
flowFail ( ) ;
}
}
async function getApproveParams ( ) {
}
async function getApproveParams ( ) {
let formModels = mainFormModels . value ;
let system = formInformation . value . getSystemType ( ) ;
let fileFolderIds = getUploadFileFolderIds ( formModels ) ;
@ -269,11 +269,11 @@ async function getApproveParams() {
isOldSystem : system ,
nextTaskUser : approvalData . nextTaskUser
} ;
}
}
async function saveLaunch ( ) {
async function saveLaunch ( ) {
data . submitLoading = true ;
loading . value = true
loading . value = true ;
try {
let validateForms = await formInformation . value . validateForm ( ) ;
let system = formInformation . value . getSystemType ( ) ;
@ -283,13 +283,13 @@ async function saveLaunch() {
return ele . validate ;
} ) ;
if ( successValidate . length == validateForms . length ) {
mainFormModels . value = await formInformation . value . getFormModels ( ) ;
mainFormModels . value = await formInformation . value . getFormModels ( true ) ;
for ( let i in mainFormModels . value ) {
const item = mainFormModels . value [ i ]
const item = mainFormModels . value [ i ] ;
if ( ! item [ '_id' ] ) {
throw new Error ( '发起失败' ) ;
} else {
delete item [ '_id' ]
delete item [ '_id' ] ;
}
}
let relationTasks = [ ] ;
@ -299,6 +299,10 @@ async function saveLaunch() {
} ) ;
}
let fileFolderIds = getUploadFileFolderIds ( mainFormModels . value ) ;
if ( taskId . value ) {
// 如果在草稿节点取消,重新从草稿开始走
return createFlowSuccess ( true ) ;
}
//如果传入了processId 代表是重新发起流程
let res ;
res = await postLaunch ( rSchemaId , mainFormModels . value , relationTasks , fileFolderIds , system ) ;
@ -306,7 +310,7 @@ async function saveLaunch() {
// 下一节点审批人
let taskList = [ ] ;
if ( res && res . length > 0 ) {
taskId . value = res [ 0 ] . taskId
taskId . value = res [ 0 ] . taskId ;
taskList = res
. filter ( ( ele ) => {
return ele . isMultiInstance == false && ele . isAppoint == true ;
@ -322,7 +326,7 @@ async function saveLaunch() {
if ( taskList . length > 0 ) {
notificationError ( '提交失败' , '流程设计错误,开始后的第一个节点必须是审批人为发起人的起草节点。' ) ;
data . submitLoading = false ;
loading . value = false
loading . value = false ;
} else {
createFlowSuccess ( taskList ) ;
}
@ -332,17 +336,17 @@ async function saveLaunch() {
} else {
data . submitLoading = false ;
notificationError ( t ( '发起流程' ) , t ( '表单校验未通过' ) ) ;
loading . value = false
loading . value = false ;
}
}
} catch ( error ) {
data . submitLoading = false ;
loading . value = false
loading . value = false ;
notificationError ( t ( '发起流程' ) , t ( '发起流程失败' ) ) ;
}
}
}
function getUploadFileFolderIds ( formModels ) {
function getUploadFileFolderIds ( formModels ) {
let fileFolderIds = [ ] ;
let uploadComponentIds = formInformation . value . getUploadComponentIds ( ) ;
uploadComponentIds . forEach ( ( ids ) => {
@ -358,7 +362,7 @@ function getUploadFileFolderIds(formModels) {
}
} ) ;
return fileFolderIds ;
}
}
< / script >
< style lang = "less" > < / style >