Browse Source

feat: 添加回退策略

luoyali 6 months ago
parent
commit
9488de4ddc

+ 4 - 1
src/views/approve/components/approvedContent.vue

@@ -208,6 +208,7 @@
 			:task-id="taskId"
 			:current-type="currentType"
 			:form-data="currentFormData"
+			:reject-strategy="currentDataDetail.value?.rejectStrategy"
 			@success-cb="closeDetailEv"
 		></consent-or-refuse-dialog>
 
@@ -304,7 +305,7 @@ const loseSignVisible = ref(false)
 const rollbackVisible = ref(false)
 const printerVisible = ref(false)
 const printOpts = ref({})
-
+const currentDataDetail = ref({})
 const allowReject = ref(false)
 const allowRevocation = ref(false)
 
@@ -401,6 +402,7 @@ const openComment = async (visibleType, item) => {
 					}
 					currentFormData.value = { processForm: JSON.stringify(saveData) }
 				} else {
+					// rejectStrategy === 3,回退到 回退节点
 					const formData = EReditorRef.value.getData()
 					let processForm = JSON.parse(cur_processForm_str)
 					processForm = { ...processForm, formData }
@@ -438,6 +440,7 @@ const getTaskDetail = () => {
 		instanceState: cur.instanceState
 	})
 		.then(data => {
+			currentDataDetail.value = data
 			const activeList = data.processApprovals
 			activeList.forEach(v => {
 				v.local_timestamp = v.id && formatTimestamp(v.createTime)

+ 31 - 4
src/views/approve/components/consentOrRefuseDialog.vue

@@ -2,6 +2,12 @@
 	<!-- 同意 拒绝 弹窗  同意/拒绝审批 -->
 	<el-dialog v-model="operaVisibleDialog" class="le-dialog" :title="currentTip + '审批'" width="700" destroy-on-close :close-on-click-modal="false">
 		<el-form ref="formRef" v-loading="uploadLoading" label-position="top" element-loading-text="图片上传中..." :model="form" label-width="80px">
+			<el-form-item label="回退节点" prop="nodeKey" :rules="[{ required: true, message: '请选择回退节点' }]" v-if="props.rejectStrategy === 3">
+				<el-select v-model="form.nodeKey" placeholder="请选择回退节点">
+					<el-option v-for="item in rollbackOptions" :key="item.nodeKey" :label="item.nodeName" :value="item.nodeKey" />
+				</el-select>
+			</el-form-item>
+
 			<el-form-item label="审批意见" prop="content" :rules="[{ required: true, message: '审批意见不能为空' }]">
 				<el-input v-model="form.content" type="textarea" placeholder="请输入内容" maxlength="64" show-word-limit> </el-input>
 			</el-form-item>
@@ -31,11 +37,11 @@
 </template>
 
 <script setup>
-import { computed, reactive, ref } from 'vue'
+import { computed, onMounted, reactive, ref, watch } from 'vue'
 import FileUpload from '@/components/FileUpload.vue'
-import { processConsentTaskApi, processRejectionTaskApi } from '@/api/flow/processTask'
+import { processConsentTaskApi, processPreviousNodeNameApi, processRejectionTaskApi } from '@/api/flow/processTask'
 import { ElMessage } from 'element-plus'
-import {debounce} from "lodash-es";
+import { debounce } from 'lodash-es'
 
 const props = defineProps({
 	// 弹窗是否显示
@@ -57,16 +63,22 @@ const props = defineProps({
 	formData: {
 		type: Object,
 		default: () => ({})
+	},
+	// 拒绝策略
+	rejectStrategy: {
+		type: Number || undefined,
+		default: undefined
 	}
 })
 const btnDisabled = ref(false)
 const form = reactive({
+	nodeKey: undefined,
 	content: ''
 	// attachment: []
 })
 const formRef = ref(null)
 const uploadLoading = ref(false)
-
+const rollbackOptions = ref([])
 const $myEmit = defineEmits(['update:modelValue', 'successCb'])
 
 const submitForm = debounce(() => {
@@ -121,6 +133,21 @@ const currentTip = computed(() => {
 })
 
 const clearValidate = () => {}
+
+// 回退节点列表
+const getProcessPreviousNodeNameApi = async () => {
+	const res = await processPreviousNodeNameApi(props.taskId)
+	rollbackOptions.value = res || []
+}
+
+watch(
+	() => props.rejectStrategy,
+	item => {
+		if (+item === 3) {
+			getProcessPreviousNodeNameApi()
+		}
+	}
+)
 </script>
 
 <style scoped lang="scss">