add 法规入库/变更流程

This commit is contained in:
赵霄
2023-12-01 17:39:22 +08:00
parent 7189765b73
commit a119192823
8 changed files with 335 additions and 26 deletions
@@ -0,0 +1,360 @@
<template>
<process-common-layout class="page-box" :loading="loading" :process-key="ProcessKey.FB_ENTRY_CHANGE.value" ref="personInfo">
<template v-slot:process>
<!--流程信息-->
<div class="process-part">
<div class="process-part-title">{{ $t('processInformation') }}</div>
<van-form input-align="right">
<!--流程名称-->
<van-field v-model="processInfo.processName"
:label="$t('processName')"
type="textarea"
autosize
readonly
rows="1"
:placeholder="$t('pleaseEnter')+$t('processName')"
:border="false" />
<!--截止日期-->
<van-field v-model="processInfo.processDueDate"
:label="$t('expirationDate')"
type="textarea"
autosize
readonly
rows="1"
:placeholder="$t('pleaseSelect')+$t('expirationDate')"
:border="false" />
<!--流程说明-->
<van-field v-model="processInfo.processDescription"
:label="$t('processExplain')"
type="textarea"
autosize
disabled
rows="1"
:placeholder="$t('pleaseEnter')+$t('processExplain')"
:border="false"
input-align="left"
class="vertical-form-item">
</van-field>
</van-form>
</div>
<!--业务信息,循环展示-->
<template v-for="(part,index) in formList">
<div class="process-part" :key="'part' + index" v-if="(part && part.length > 0) || formPartList.findIndex(index) === 0">
<div class="process-part-title">{{ index }}</div>
<van-form input-align="right">
<!--来源-->
<van-field v-model="formInline.source_dictText"
:label="$t('standardEntryOrChange.source')"
type="textarea"
autosize
readonly
rows="1"
:border="false" />
<!--操作类型-->
<van-field v-model="formInline.operateType_dictText"
:label="$t('standardEntryOrChange.operationType')"
type="textarea"
autosize
readonly
rows="1"
:border="false" />
<van-field v-for="formItem in part"
:key="formItem.id"
v-model="formInline[dictField.includes(formItem.dbFieldName) ? formItem.dbFieldName + '_dictText' : formItem.dbFieldName]"
:label="formItem.dbFieldTxt"
type="textarea"
autosize
readonly
rows="1"
:border="false">
<template v-slot:input v-if="fileField.includes(formItem.dbFieldName)">
<file-display :file-ids="formInline[formItem.dbFieldName]" />
</template>
</van-field>
</van-form>
</div>
</template>
<!--流程审批信息-->
<div class="process-part">
<div class="process-part-title">{{ $t('processApprovalInfo') }}</div>
<van-form input-align="right" ref="approvalForm">
<!--备注-->
<van-field v-model="approvalInfo.handleText"
:label="$t('remark')"
type="textarea"
autosize
rows="1"
:placeholder="$t('pleaseEnter')+$t('remark')"
:border="false"
input-align="left"
:rules="rules.handleText"
class="vertical-form-item">
</van-field>
</van-form>
</div>
</template>
<template v-slot:operation>
<van-button icon="revoke" class="operation-common-btn" @click="handleTurnTo">{{ $t('turnTo') }}</van-button>
<van-button icon="revoke" class="operation-common-btn" type="primary" @click="handleAgree">{{ $t('agree') }}</van-button>
<van-button icon="revoke" class="operation-common-btn light-color-button" @click="handleReject">{{ $t('reject') }}</van-button>
</template>
<select-user ref="selectUser" @selected-change="continueTurnTo" />
</process-common-layout>
</template>
<script>
import ProcessCommonLayout from '../../../components/ProcessCommonLayout'
import {
queryStandardECProcessData,
getDomesticStandardFormModal,
getOverseasStandardForm,
turnToStandardECProcess,
agreeStandardECProcess,
rejectStandardECProcess
} from '../../../api/api'
import { FieldType, StandardSource, ProcessKey } from '../../../enums/commonEnums'
import FileDisplay from '../../../components/FileDisplay'
import SelectUser from '../../../components/SelectUser'
export default {
name: 'StandardEntryOrChangeProcess',
components: { ProcessCommonLayout, FileDisplay, SelectUser },
data () {
return {
ProcessKey,
loading: false,
processInfo: {}, // 流程信息数据
businessId: null,
formInline: {}, // 业务信息表单数据
formList: [], // 表单
dictField: [], // 需要翻译的字段
fileField: [], // 文件字段
formPartList: [], // 展示区域信息
approvalInfo: {}, // 流程审批信息
rules: {
handleText: [{ required: false, message: this.$t('pleaseEnter') + this.$t('remark'), trigger: 'onBlur' }]
}
}
},
created () {
this.initProcessData()
},
methods: {
/**
* 获取流程数据
*/
initProcessData () {
this.loading = true
const { processInstanceId, taskId } = this.$route.query
queryStandardECProcessData({ processInstanceId, taskId }).then(async res => {
if (res.success) {
const { result = {} } = res
this.processInfo = Object.assign({}, result.basicProcessInfoDTO)
this.formInline = { ...result.businessInfoDTO.businessMap }
switch (this.formInline.source) {
case StandardSource.DOMESTIC.value:
await this.getDomesticFormItem()
break
case StandardSource.OVERSEAS.value:
await this.getOverseasFormItem()
break
default:
break
}
} else {
this.$message(res.message)
}
}).finally(() => {
this.loading = false
})
},
/**
* 获取国标的表单
*/
getDomesticFormItem () {
return new Promise(resolve => {
getDomesticStandardFormModal({
module: StandardSource.DOMESTIC.value,
type: 2 // 2是新增;1是详情
}).then(res => {
if (res.success) {
this.formList = res.result
this.dealFileAndDict()
} else {
this.$message(res.message)
}
}).finally(() => {
resolve()
})
})
},
/**
* 获取海外表单
*/
getOverseasFormItem () {
return new Promise(resolve => {
getOverseasStandardForm({
module: StandardSource.OVERSEAS.value,
type: 2 // 2是新增;1是详情
}).then(res => {
if (res.success) {
this.formList = res.result
this.dealFileAndDict()
} else {
this.$message(res.message)
}
}).finally(() => {
resolve()
})
})
},
dealFileAndDict () {
this.formPartList = Object.keys(this.formList)
// 字段列表
const formArr = Object.values(this.formList).reduce((acc, cur) => acc.concat(cur), [])
this.fileField = []
this.dictField = []
formArr.forEach(item => {
if (item.fieldShowType === FieldType.FILE_UP.value) {
this.fileField.push(item.dbFieldName)
}
const dictType = [FieldType.USER_SINGLE.value, FieldType.ORGAN_SINGLE.value, FieldType.ORGAN_MORE.value, FieldType.OPTION_SINGLE.value, FieldType.OPTION_MORE.value, FieldType.TREE.value, FieldType.TREE_SINGLE.value]
if (dictType.includes(item.fieldShowType)) {
this.dictField.push(item.dbFieldName)
}
})
},
/**
* 处理提交的表单数据
* @returns {{}|boolean}
*/
dealFormData () {
const formData = {}
let flag = true
// 流程信息
formData.basicProcessInfoDTO = { ...this.processInfo }
// 业务信息
const formInline = { ...this.formInline }
Object.keys(formInline).forEach(res => {
if (formInline[res] instanceof Array) {
if (formInline[res][0] instanceof Object) {
// 说明是树选择
formInline[res] = formInline[res].map(item => item.value).join(',')
} else {
formInline[res] = formInline[res].join(',')
}
}
})
formData.businessInfoDTO = {
businessMap: formInline,
id: this.businessId
}
// 流程审批信息,需要进行表单校验
formData.basicTaskInfoDTO = { ...this.approvalInfo }
formData.basicTaskInfoDTO.taskId = this.$route.query.taskId
// 处理人员信息
const userInfo = this.$refs.personInfo.getDataObjVerify()
if (!userInfo) {
flag = false
} else {
formData.userInfoMap = userInfo
}
if (flag) {
return formData
}
return flag
},
validateForm () {
let flag = true
return new Promise(resolve => {
this.$refs.approvalForm.validate().then(() => {
}).catch(() => {
flag = false
}).finally(() => {
resolve(flag)
})
})
},
/**
* 转办
*/
handleTurnTo () {
this.$refs.selectUser.open()
},
continueTurnTo (value) {
const params = {
taskId: this.$route.query.taskId,
userId: value
}
this.loading = true
turnToStandardECProcess(params).then(res => {
this.$message(res.message)
if (res.success) {
this.goBack()
}
}).finally(() => {
this.loading = false
})
},
/**
* 同意
*/
handleAgree () {
this.rules.handleText[0].required = false
this.approvalInfo.handleText = '同意'
const formData = this.dealFormData()
if (!formData) {
return
}
this.loading = true
agreeStandardECProcess(formData).then(res => {
this.$message(res.message)
if (res.success) {
this.goBack()
}
}).finally(() => {
this.loading = false
})
},
/**
* 驳回
*/
async handleReject () {
this.rules.handleText[0].required = true
const validateResult = await this.validateForm()
if (!validateResult) {
return
}
const formData = this.dealFormData()
if (!formData) {
return
}
this.loading = true
rejectStandardECProcess(formData).then(res => {
this.$message(res.message)
if (res.success) {
this.goBack()
}
}).finally(() => {
this.loading = false
})
},
goBack () {
let timer = setTimeout(() => {
clearTimeout(timer)
timer = null
this.$router.go(-1)
}, 700)
}
}
}
</script>
<style scoped lang="less">
@import '~../../../assets/less/common.less';
</style>