|
@@ -20,7 +20,7 @@
|
|
|
|
|
|
<!-- vue自定义 -->
|
|
<!-- vue自定义 -->
|
|
<template v-if="record.formTemplate.type === 1">
|
|
<template v-if="record.formTemplate.type === 1">
|
|
- <component :is="dyVueComponent" ref="dyVueComponentRef"></component>
|
|
|
|
|
|
+ <component :is="dyVueComponent" ref="dyVueComponentRef" @form-valid="onSubmit"></component>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<el-divider content-position="left">审批流程</el-divider>
|
|
<el-divider content-position="left">审批流程</el-divider>
|
|
@@ -30,7 +30,9 @@
|
|
|
|
|
|
<template #footer>
|
|
<template #footer>
|
|
<el-button @click="updateModelValue(false)">{{ $t('le.btn.cancel') }}</el-button>
|
|
<el-button @click="updateModelValue(false)">{{ $t('le.btn.cancel') }}</el-button>
|
|
- <el-button :disabled="validateForm.loading" type="primary" style="margin-left: 8px" @click="onSubmit">{{ $t('le.btn.confirm') }}</el-button>
|
|
|
|
|
|
+ <el-button :disabled="validateForm.loading" type="primary" style="margin-left: 8px" @click="handleFormValid">{{
|
|
|
|
+ $t('le.btn.confirm')
|
|
|
|
+ }}</el-button>
|
|
</template>
|
|
</template>
|
|
</el-drawer>
|
|
</el-drawer>
|
|
</template>
|
|
</template>
|
|
@@ -70,10 +72,34 @@ const dyVueForm = ref({})
|
|
|
|
|
|
provide('dyVueForm', dyVueForm) // 这里主要是存放动态的form的属性值
|
|
provide('dyVueForm', dyVueForm) // 这里主要是存放动态的form的属性值
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 1、校验表单
|
|
|
|
+ * 1.1 type=1 校验系统表单
|
|
|
|
+ * 1.2 type=0 校验表单设计
|
|
|
|
+ * 2、提交API
|
|
|
|
+ */
|
|
|
|
+const handleFormValid = () => {
|
|
|
|
+ const { type } = props.record.formTemplate
|
|
|
|
+ if (type) {
|
|
|
|
+ dyVueComponentRef.value.validateForm()
|
|
|
|
+ } else {
|
|
|
|
+ validateDesignForm()
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 校验表单设计
|
|
|
|
+const validateDesignForm = () => {
|
|
|
|
+ const form = EReditorRef.value.getSelfFormRef()
|
|
|
|
+ form.validate((valid: any) => {
|
|
|
|
+ if (!valid) return false
|
|
|
|
+ // 提交数据
|
|
|
|
+ onSubmit()
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
const onSubmit = async () => {
|
|
const onSubmit = async () => {
|
|
const processId = props.record.processId
|
|
const processId = props.record.processId
|
|
const { type } = props.record.formTemplate
|
|
const { type } = props.record.formTemplate
|
|
- let params = {}
|
|
|
|
// 这里要从子节点获取流程图信息 进行保存
|
|
// 这里要从子节点获取流程图信息 进行保存
|
|
const _assigneeMap = flowTrendRef.value.getAssigneeMap()
|
|
const _assigneeMap = flowTrendRef.value.getAssigneeMap()
|
|
const assigneeMap_ = Object.keys(_assigneeMap).reduce((obj, nodeKey: string) => {
|
|
const assigneeMap_ = Object.keys(_assigneeMap).reduce((obj, nodeKey: string) => {
|
|
@@ -84,63 +110,38 @@ const onSubmit = async () => {
|
|
}
|
|
}
|
|
return obj
|
|
return obj
|
|
}, {} as { [nodeKey: string]: any })
|
|
}, {} as { [nodeKey: string]: any })
|
|
- if (!type) {
|
|
|
|
- // type: 0 表单设计 1 vue自定义表单
|
|
|
|
- const form = EReditorRef.value.getSelfFormRef()
|
|
|
|
- form.validate((valid: any) => {
|
|
|
|
- if (!valid) return false
|
|
|
|
- // 表单验证通过 进行保存
|
|
|
|
- validateForm.value.loading = true
|
|
|
|
- const formData = EReditorRef.value.getData()
|
|
|
|
- let processForm = JSON.parse(cur_processForm_str)
|
|
|
|
- processForm = { ...processForm, formData }
|
|
|
|
- params = {
|
|
|
|
- id: props.record.rowId,
|
|
|
|
- test: '',
|
|
|
|
- processStart: {
|
|
|
|
- processId, // 流程ID
|
|
|
|
- processForm: JSON.stringify(processForm), // 流程表单JSON内容 & local_value 保存
|
|
|
|
- assigneeMap: assigneeMap_
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // 待优化
|
|
|
|
- purchaseOrder
|
|
|
|
- .postlaunchApi(params)
|
|
|
|
- .then(res => {
|
|
|
|
- ElMessage.success('提交成功')
|
|
|
|
- updateModelValue(false)
|
|
|
|
- })
|
|
|
|
- .finally(() => {
|
|
|
|
- validateForm.value.loading = false
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- const formData = dyVueComponentRef.value.getData()
|
|
|
|
|
|
+ const paramCommon = {
|
|
|
|
+ id: props.record.rowId,
|
|
|
|
+ test: '', // 系统表单JSON内容
|
|
|
|
+ processStart: {
|
|
|
|
+ processId, // 流程ID
|
|
|
|
+ processForm: '', // 设计表单JSON内容
|
|
|
|
+ assigneeMap: assigneeMap_
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ validateForm.value.loading = true
|
|
|
|
+ // type: 0 设计表单 1 vue系统表单
|
|
|
|
+ if (type) {
|
|
const testData = {
|
|
const testData = {
|
|
formStructure: '@/views/flow/test/test1.vue',
|
|
formStructure: '@/views/flow/test/test1.vue',
|
|
- formData: formData
|
|
|
|
|
|
+ formData: dyVueComponentRef.value.getComponentData()
|
|
}
|
|
}
|
|
- params = {
|
|
|
|
- id: props.record.rowId,
|
|
|
|
- test: JSON.stringify(testData),
|
|
|
|
- processStart: {
|
|
|
|
- processId, // 流程ID
|
|
|
|
- processForm: '', // 流程表单JSON内容 & local_value 保存
|
|
|
|
- assigneeMap: assigneeMap_
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // 待优化
|
|
|
|
- purchaseOrder
|
|
|
|
- .postlaunchApi(params)
|
|
|
|
- .then(res => {
|
|
|
|
- ElMessage.success('提交成功')
|
|
|
|
- updateModelValue(false)
|
|
|
|
- })
|
|
|
|
- .finally(() => {
|
|
|
|
- validateForm.value.loading = false
|
|
|
|
- })
|
|
|
|
|
|
+ paramCommon.test = JSON.stringify(testData)
|
|
|
|
+ } else {
|
|
|
|
+ const formData = EReditorRef.value.getData()
|
|
|
|
+ let processForm = JSON.parse(cur_processForm_str)
|
|
|
|
+ processForm = { ...processForm, formData }
|
|
|
|
+ paramCommon.processStart.processForm = JSON.stringify(processForm)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ purchaseOrder
|
|
|
|
+ .postlaunchApi(paramCommon)
|
|
|
|
+ .then(res => {
|
|
|
|
+ ElMessage.success('提交成功')
|
|
|
|
+ updateModelValue(false)
|
|
|
|
+ })
|
|
|
|
+ .finally(() => {
|
|
|
|
+ validateForm.value.loading = false
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
// 获取当前表单中的详情
|
|
// 获取当前表单中的详情
|