zhangyanpeng
2024-03-04 6a72e9e44dc7278e18d55ccd5637b81a1cb2f047
src/views/common/process/viewNodes/ApprovalNode.vue
New file
@@ -0,0 +1,122 @@
<template>
  <node :title="config.name" :show-error="showError" :content="content"  :error-info="errorInfo"
        @selected="$emit('selected')" @delNode="$emit('delNode')" @insertNode="type => $emit('insertNode', type)"
        placeholder="请设置审批人" :header-bgc="headerBgc" header-icon="el-icon-s-check"/>
</template>
<script>
import Node from './Node.vue'
export default {
  name: "ApprovalNode",
  props:{
    config:{
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  components: {Node},
  data() {
    return {
      showError: false,
      errorInfo: '',
    }
  },
  computed:{
    headerBgc() {
      if (this.$store.state.diagramMode === 'viewer') {
        return this.config.props.headerBgc
      } else {
        return '#ff943e'
      }
    },
    content(){
      const config = this.config.props
      let texts = []
      config.assignedUser.forEach(org => texts.push(org.name))
      return String(texts).replaceAll(',', '、')
    },
    // flowText(){
    //   const config = this.config
    //   console.log("flowText-config",config);
    //
    //   // return config.approvalArr.filter(ite=>ite.node_id===config.id)[0].approval_time;
    //   if(config.approvalArr!==undefined){
    //     return "发起时间:"+config.approvalArr.filter(ite=>ite.node_id===config.id)[0].approval_time;
    //   }
    //
    //   return ''
    // }
  },
  created() {
  },
  methods: {
    getFormItemById(id){
      return this.$store.state.design.formItems.find(item => item.id === id)
    },
    //校验数据配置的合法性
    validate(err){
      try {
        this.showError = !this[`validate_${this.config.props.assignedType}`](err)
        if (this.config.props.nobody.handler === 'TO_USER' && this.config.props.nobody.assignedUser.length === 0) {
          this.errorInfo = '审批人为空时, 转交给指定人员:【请指定一个具体的人】'
          err.push('审批人为空时, 转交给指定人员:【请指定一个具体的人】')
          this.showError = true
        }
        return this.showError
      } catch (e) {
        return true;
      }
    },
    validate_ASSIGN_USER(err){
      if(this.config.props.assignedUser.length > 0){
        return true;
      }else {
        this.errorInfo = '请指定审批人员'
        err.push(`${this.config.name} 未指定审批人员`)
        return false
      }
    },
    validate_SELF_SELECT(err){
      return true;
    },
    validate_LEADER_TOP(err){
      return true;
    },
    validate_LEADER(err){
      return true;
    },
    validate_ROLE(err){
      if (this.config.props.assignedUser.length <= 0){
        this.errorInfo = '请指定负责审批的系统角色'
        err.push(`${this.config.name} 未指定审批角色`)
        return false
      }
      return true;
    },
    validate_SELF(err){
      return true;
    },
    validate_FORM_USER(err){
     if (this.config.props.formUser === ''){
       this.errorInfo = '请指定表单中的人员组件'
       err.push(`${this.config.name} 审批人为表单中人员,但未指定`)
       return false
     }
      return true;
    },
    validate_REFUSE(err){
      return true;
    },
  }
}
</script>
<style scoped>
</style>