<template>
  <div class="task-detail-basicInfo-com">
    <div class="sub-title">任务信息</div>
    <dee-readable-form
      :form-data="basicInfo"
    />
  </div>
</template>

<script>
export default {
  name: 'BasicInfo',
  components: {
  },
  props: {
    basicData: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      basicInfo: []
    }
  },
  watch: {
    basicData: {
      deep: true,
      handler(val) {
        if (val.basicInfo) {
          this.initData(val.businessObject || null, val.basicInfo)
        }
      }
    }
  },
  mounted() {
    if (this.basicData.basicInfo) {
      this.initData(this.basicData.businessObject || null, this.basicData.basicInfo)
    }
  },
  methods: {
    initData(businessObject, basicInfo) {
      this.basicInfo = [
        { label: '任务对象:', value: basicInfo.bizExtInfo && basicInfo.bizExtInfo.taskTitle ? basicInfo.bizExtInfo.taskTitle : '',
          type: 'link',
          handler: {
            click: () => {
              let modelName = businessObject ? businessObject.dxClassname : ''
              modelName = this.$utils.getModelName4dxClassName(modelName)
              this.$utils.toObjectDetail(businessObject.id, businessObject.subTypeName, basicInfo.bizExtInfo && basicInfo.bizExtInfo.taskTitle ? basicInfo.bizExtInfo.taskTitle : businessObject.id, modelName)
              // this.$router.push({
              //   path: businessObject ? `/generalDetail/${businessObject.id}/${businessObject.subTypeName}/${modelName}` : '',
              //   query: {
              //     layoutId: basicInfo.layoutId,
              //     title: this.basicData.basicInfo && this.basicData.basicInfo.primaryBusinessObject && this.basicData.basicInfo.primaryBusinessObject.name
              //   }
              // })
              //   this.$router.push({
              //   path: `/configured-page/cd/${businessObject.subTypeName}/defaultInfo/${businessObject.id}`,
              //   query: { title: (basicInfo.bizExtInfo && basicInfo.bizExtInfo.taskTitle ? basicInfo.bizExtInfo.taskTitle : '' || businessObject.id) + '详情' }
              // })
            }
          }
        },
        // {
        //   width: 1,
        //   label: '',
        //   key: 'process',
        //   type: 'custom'
        // },
        // {
        //   width: 1,
        //   label: '',
        //   key: 'flow',
        //   type: 'custom'
        // },
        { label: '实例名称:', value: basicInfo.processInstanceName ? basicInfo.processInstanceName : '' },
        { label: '启动者:', value: basicInfo.processInstVO && basicInfo.processInstVO.ownerName ? basicInfo.processInstVO.ownerName : '' },
        { label: '任务执行者:', value: basicInfo.assigneeName },
        { label: '接收时间:', value: basicInfo.startTime },
        { label: '执行期限:', value: basicInfo.costTimeInMillis ? `${basicInfo.costTimeInMillis / 3600 / 1000 / 24}天` : '/' },
        { label: '说明:', value: basicInfo.description },
        { label: '指示:', value: basicInfo.instruction },
        { label: '备注:', value: basicInfo.lastComments && basicInfo.lastComments.length ? basicInfo.lastComments.join(',') : '' }
      ]
    },
    handleOpen() {
      this.$emit('handleOpen')
    }
  }
}
</script>

<style lang="scss">

</style>