Explorar el Código

修复第二次点击退回按钮时校验异常的问题

luoaoxuan hace 1 año
padre
commit
b3f77ce4e5
Se han modificado 1 ficheros con 155 adiciones y 155 borrados
  1. 155 155
      src/business/platform/bpmn/form-ext/reject.vue

+ 155 - 155
src/business/platform/bpmn/form-ext/reject.vue

@@ -81,7 +81,7 @@
                 </el-select>
             </el-form-item>
             <el-form-item v-if="!hideOpinion" label="审批意见:" prop="opinion">
-                <approval-opinion v-model="form.opinion" :action="action" />
+                <approval-opinion v-if="dialogVisible" v-model="form.opinion" :action="action" />
             </el-form-item>
         </el-form>
         <div slot="footer" class="el-dialog--center">
@@ -99,174 +99,174 @@
     </el-dialog>
 </template>
 <script>
-    import { toReject, toRejectToPrevious, toRejectToStart } from '@/api/platform/bpmn/bpmTask'
-    import ApprovalOpinion from '@/business/platform/bpmn/components/approval-opinion'
-    import { queryIncludeNull } from '@/api/platform/bpmn/bpmCommonStatment'
-    import ActionUtils from '@/utils/action'
+import { toReject, toRejectToPrevious, toRejectToStart } from '@/api/platform/bpmn/bpmTask'
+import ApprovalOpinion from '@/business/platform/bpmn/components/approval-opinion'
+import { queryIncludeNull } from '@/api/platform/bpmn/bpmCommonStatment'
+import ActionUtils from '@/utils/action'
 
-    export default {
-        components: {
-            ApprovalOpinion
+export default {
+    components: {
+        ApprovalOpinion
+    },
+    props: {
+        className: String,
+        visible: Boolean,
+        action: String,
+        title: String,
+        taskId: String,
+        data: [String, Object],
+        hideOpinion: {
+            // 隐藏意见
+            type: Boolean,
+            default: false
         },
-        props: {
-            className: String,
-            visible: Boolean,
-            action: String,
-            title: String,
-            taskId: String,
-            data: [String, Object],
-            hideOpinion: {
-                // 隐藏意见
-                type: Boolean,
-                default: false
+        formOpinion: {
+            // 表单意见
+            type: String
+        }
+    },
+    data () {
+        return {
+            dialogVisible: this.visible,
+            dialogLoading: false,
+            formName: 'form',
+            formLabelWidth: '130px',
+            actionName: '',
+            userNodeList: [],
+            bpmExecUserNode: [],
+            bpmExecGoMapUserNode: [],
+            form: {
+                rejectMode: 'reject',
+                backHandMode: 'normal',
+                destination: '',
+                opinion: ''
             },
-            formOpinion: {
-                // 表单意见
-                type: String
+            rules: {
+                destination: [
+                    {
+                        required: true,
+                        message: this.$t('validate.required')
+                    }
+                ],
+                opinion: [
+                    {
+                        required: true,
+                        message: this.$t('validate.required')
+                    }
+                ]
             }
-        },
-        data() {
-            return {
-                dialogVisible: this.visible,
-                dialogLoading: false,
-                formName: 'form',
-                formLabelWidth: '130px',
-                actionName: '',
-                userNodeList: [],
-                bpmExecUserNode: [],
-                bpmExecGoMapUserNode: [],
-                form: {
-                    rejectMode: 'reject',
-                    backHandMode: 'normal',
-                    destination: '',
-                    opinion: ''
-                },
-                rules: {
-                    destination: [
-                        {
-                            required: true,
-                            message: this.$t('validate.required')
-                        }
-                    ],
-                    opinion: [
-                        {
-                            required: true,
-                            message: this.$t('validate.required')
-                        }
-                    ]
-                }
+        }
+    },
+    computed: {
+        actionTitle () {
+            if (this.title) {
+                return this.title
             }
-        },
-        computed: {
-            actionTitle() {
-                if (this.title) {
-                    return this.title
-                }
-                if (this.actionName === 'rejectToPrevious') {
-                    return '驳回上一步'
-                } else if (this.actionName === 'rejectToStart') {
-                    return '驳回发起人'
-                } else if (this.actionName === 'reject') {
-                    return '驳回审批'
-                } else {
-                    return '驳回'
-                }
+            if (this.actionName === 'rejectToPrevious') {
+                return '驳回上一步'
+            } else if (this.actionName === 'rejectToStart') {
+                return '驳回发起人'
+            } else if (this.actionName === 'reject') {
+                return '驳回审批'
+            } else {
+                return '驳回'
+            }
+        }
+    },
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = this.visible
+                this.actionName = this.action
+            },
+            immediate: true
+        }
+    },
+    methods: {
+        openedDialog () {
+            if (this.$utils.isNotEmpty(this.formOpinion)) {
+                this.form.opinion = this.formOpinion
+            } else {
+                queryIncludeNull(
+                    ActionUtils.formatParams({
+                        'Q^ACTION_^S': this.action,
+                        'Q^CREATE_BY_^S': this.$store.getters.userId
+                    })
+                ).then((response) => {
+                    const data = response.variables && response.variables.def ? response.variables.def.value || '' : ''
+                    if (this.$utils.isNotEmpty(data)) {
+                        this.form.opinion = data
+                    }
+                })
             }
         },
-        watch: {
-            visible: {
-                handler: function (val, oldVal) {
-                    this.dialogVisible = this.visible
-                    this.actionName = this.action
-                },
-                immediate: true
+        changeBackHandMode () {
+            if (this.actionName === 'reject' && this.form.rejectMode === 'rejectDest') {
+                this.formValidate()
+                this.userNodeList = this.form.backHandMode === 'normal' ? this.bpmExecGoMapUserNode : this.bpmExecUserNode
             }
         },
-        methods: {
-            openedDialog() {
-                if (this.$utils.isNotEmpty(this.formOpinion)) {
-                    this.form.opinion = this.formOpinion
+        closeDialog () {
+            this.form.opinion = ''
+            this.$emit('close', false)
+        },
+        handleSave () {
+            this.$refs[this.formName].validate((valid) => {
+                if (valid) {
+                    this.$emit('action-event', this.action, this.form)
                 } else {
-                    queryIncludeNull(
-                        ActionUtils.formatParams({
-                            'Q^ACTION_^S': this.action,
-                            'Q^CREATE_BY_^S': this.$store.getters.userId
-                        })
-                    ).then((response) => {
-                        const data = response.variables && response.variables.def ? response.variables.def.value || '' : ''
-                        if (this.$utils.isNotEmpty(data)) {
-                            this.form.opinion = data
-                        }
-                    })
-                }
-            },
-            changeBackHandMode() {
-                if (this.actionName === 'reject' && this.form.rejectMode === 'rejectDest') {
-                    this.formValidate()
-                    this.userNodeList = this.form.backHandMode === 'normal' ? this.bpmExecGoMapUserNode : this.bpmExecUserNode
+                    ActionUtils.saveErrorMessage()
                 }
-            },
-            closeDialog() {
-                this.form.opinion = ''
-                this.$emit('close', false)
-            },
-            handleSave() {
-                this.$refs[this.formName].validate((valid) => {
-                    if (valid) {
-                        this.$emit('action-event', this.action, this.form)
-                    } else {
-                        ActionUtils.saveErrorMessage()
-                    }
-                })
-            },
-            /**
+            })
+        },
+        /**
              * 表单验证
              */
-            formValidate() {
-                this.$nextTick(() => {
-                    this.$refs[this.formName].validate(() => {})
-                })
-            },
-            getFormData() {
-                this.openedDialog()
-                this.$nextTick(() => {
-                    this.$refs[this.formName].resetFields()
-                })
-                this.dialogLoading = true
-                switch (this.actionName) {
-                    case 'reject': // 驳回
-                        toReject({ taskId: this.taskId }).then((response) => {
-                            this.formValidate()
-                            this.dialogLoading = false
-                            const data = response.data
-                            this.userNodeList = this.bpmExecUserNode = data.bpmExecUserNode
-                            this.bpmExecGoMapUserNode = data.bpmExecGoMapUserNode
-                        }).catch(() => {
-                            this.dialogLoading = false
-                        })
-                        break
-                    case 'rejectToPrevious': // 驳回上一步
-                        toRejectToPrevious({ taskId: this.taskId }).then((response) => {
-                            this.formValidate()
-                            this.dialogLoading = false
-                            // TODO:默认意见
-                        }).catch(() => {
-                            this.dialogLoading = false
-                        })
-                        break
-                    case 'rejectToStart':
-                        toRejectToStart({ taskId: this.taskId }).then((response) => {
-                            this.formValidate()
-                            this.dialogLoading = false
-                            // TODO:默认意见
-                        }).catch(() => {
-                            this.dialogLoading = false
-                        })
-                        break
-                    default:
-                        break
-                }
+        formValidate () {
+            this.$nextTick(() => {
+                this.$refs[this.formName].validate(() => {})
+            })
+        },
+        getFormData () {
+            this.openedDialog()
+            this.$nextTick(() => {
+                this.$refs[this.formName].resetFields()
+            })
+            this.dialogLoading = true
+            switch (this.actionName) {
+                case 'reject': // 驳回
+                    toReject({ taskId: this.taskId }).then((response) => {
+                        this.formValidate()
+                        this.dialogLoading = false
+                        const data = response.data
+                        this.userNodeList = this.bpmExecUserNode = data.bpmExecUserNode
+                        this.bpmExecGoMapUserNode = data.bpmExecGoMapUserNode
+                    }).catch(() => {
+                        this.dialogLoading = false
+                    })
+                    break
+                case 'rejectToPrevious': // 驳回上一步
+                    toRejectToPrevious({ taskId: this.taskId }).then((response) => {
+                        this.formValidate()
+                        this.dialogLoading = false
+                        // TODO:默认意见
+                    }).catch(() => {
+                        this.dialogLoading = false
+                    })
+                    break
+                case 'rejectToStart':
+                    toRejectToStart({ taskId: this.taskId }).then((response) => {
+                        this.formValidate()
+                        this.dialogLoading = false
+                        // TODO:默认意见
+                    }).catch(() => {
+                        this.dialogLoading = false
+                    })
+                    break
+                default:
+                    break
             }
         }
     }
+}
 </script>