<template>
  <div style="width: 100%;">
    <a-button style="width: 100%;" :disabled="readonly" @click="performProcess">{{ buttonText }}</a-button>
  </div>
</template>

<script>


import Common from '../../common/Common.js';

export default {

  components: {
  },
  
  props: {
   
    readonly: {
      type: Boolean,
      default: null,
    },
    className: {
      type: String,
      default: null,
    },
    field: {
      type: Object,
      default : function(){
        return null;
      },
    },
    fieldValue: {
      type: Object,
      default : function(){
        return null;
      },
    },
  },

  
  emits: ['executeCallout'],

  data: function () {
    return {
      newFieldValue: {
        displayValue: [],
        displayType: 'String',
      },
    };
  },

  computed: {
    /**
         * 计算按钮文字
         */
    'buttonText': function () {
      if (this.fieldValue == null || this.fieldValue.displayValue == null || this.fieldValue.displayValue.length == 0) {
        if (this.field != null) {
          return this.field.displayName;
        } else {
          return '';
        }
      } else {
        return this.fieldValue.displayValue[0];
      }
    },
  },

  mounted: function () {

  },

  methods: {
    /**
         * 执行流程
         */
    performProcess: function () {
      // 1.获取流程和报表的定义
      if (this.field != null
                && this.field.calloutProcessReportNo != null) {
        this.$emit('executeCallout', this.field);
      }
      // 2.1 调用后台执行流程和报表

      // 2.2 调用前台执行执行js
    },
  },
};
</script>