Browse Source

feat: 联调 流程审批 同意 表单提交成功

lanceJiang 1 year ago
parent
commit
9ffe3eb131

+ 25 - 16
src/views/approve/components/approvedContent.vue

@@ -111,7 +111,8 @@
 			v-if="consentOrRefuseVisible"
 			v-model="consentOrRefuseVisible"
 			:task-id="taskId"
-			:current-type="currentDialog"
+			:current-type="currentType"
+			:form-data="currentFormData"
 			@success-cb="closeDetailEv"
 		></consent-or-refuse-dialog>
 
@@ -163,8 +164,10 @@ const loseSignVisible = ref(false)
 const rollbackVisible = ref(false)
 // 各种操作弹窗显示隐藏 end
 const activeData = ref([])
-const currentDialog = ref(null)
-
+const currentType = ref(null)
+const currentFormData = ref({})
+// 当前form 表单数据字符串
+let cur_processForm_str = '[]'
 const taskId = computed(() => {
 	return currentTaskRow.value.taskId || ''
 })
@@ -193,10 +196,10 @@ const closeDetailEv = () => {
 
 /**
  * 详情按钮各个操作弹窗
- * @param type 评论 拒绝 同意等
+ * @param visibleType 评论 拒绝 同意等
  */
-const openComment = (type, item) => {
-	switch (type) {
+const openComment = async (visibleType, item) => {
+	switch (visibleType) {
 		case 'reviewVisible':
 			reviewVisible.value = !reviewVisible.value
 			break
@@ -204,23 +207,28 @@ const openComment = (type, item) => {
 			addSignVisible.value = !addSignVisible.value
 			break
 		case 'consentOrRefuseVisible':
+			currentFormData.value = {}
 			// 点击同意
+			let bool = true
 			if (item === 'agree') {
-				debugger
-				// 验证表单 todo...
 				const api = validateForm.value.api
-				api.validate((valid, fail) => {
+				bool = await api.validate((valid, fail) => {
 					if (valid) {
+            // 表单验证通过
 						const values = api.formData()
-						console.warn(values, 'values')
-						//todo 表单验证通过
-					} else {
-						//todo 表单验证未通过
+						const processForm = JSON.parse(cur_processForm_str)
+						processForm.forEach(v => {
+							// 填写的数据存储(local_: 本地数据处理标识)
+							v.local_value = values[v.field]
+						})
+						console.warn(processForm, 'processForm')
+						// 流程表单JSON内容 & local_value 保存
+						currentFormData.value = { processForm: JSON.stringify(processForm) }
 					}
 				})
-				// return
 			}
-			currentDialog.value = item
+			if (!bool) return
+			currentType.value = item
 			consentOrRefuseVisible.value = !consentOrRefuseVisible.value
 			break
 		case 'deliverToReviewVisible':
@@ -272,6 +280,7 @@ const getTaskDetail = () => {
 					}
 				})*/
 				const forms = JSON.parse(data.formContent)
+				cur_processForm_str = data.formContent
 				if (Array.isArray(forms)) {
 					validateForm.value.rule = forms
 					const api = validateForm.value.api
@@ -418,7 +427,7 @@ watch(
 		justify-content: flex-end;
 		height: 52px;
 		//border-top: 1px solid var(--color-neutral-3);
-		border-top: 1px solid black;
+		border-top: 1px solid #e5e6ec;
 		padding: 0 20px;
 	}
 }

+ 13 - 3
src/views/approve/components/consentOrRefuseDialog.vue

@@ -31,6 +31,7 @@
 import { computed, reactive, ref } from 'vue'
 import FileUpload from '@/components/FileUpload.vue'
 import { processConsentTaskApi, processRejectionTaskApi } from '@/api/flow/processTask'
+import { ElMessage } from 'element-plus'
 
 const props = defineProps({
 	// 弹窗是否显示
@@ -47,11 +48,16 @@ const props = defineProps({
 	currentType: {
 		type: String,
 		default: 'agree'
+	},
+	// 额外 表单数据
+	formData: {
+		type: Object,
+		default: () => ({})
 	}
 })
 const btnDisabled = ref(false)
 const form = reactive({
-	content: '',
+	content: ''
 	// attachment: []
 })
 const formRef = ref(null)
@@ -61,14 +67,18 @@ const $myEmit = defineEmits(['update:modelValue', 'successCb'])
 
 const submitForm = () => {
 	btnDisabled.value = true
-	const formData = { ...form, taskId: props.taskId }
+	const formData = { taskId: props.taskId, ...props.formData, ...form }
 	formRef.value
 		.validate()
 		.then(async valid => {
 			if (valid) {
-				if (currentTip.value) {
+				const isAgree = props.currentType === 'agree'
+				if (isAgree) {
+					// 同意
 					await processConsentTaskApi(formData)
+					ElMessage.success('执行成功')
 				} else {
+					// 拒绝
 					await processRejectionTaskApi(formData)
 				}
 				closeDialog()