<template>
    <div>
        <Modal :title="modalTitle" v-model="modalShow" :width="modalWidth">
          <!-- 订单进度模态框 -->
            <Steps :current="stepObj.step_num" direction="vertical" style="margin-left: 100px;width: 70%;">
              <Step v-for="(item, index) in stepObj.process_list" v-bind:key="index"
                    :title="item.step_title" :content="item.text"></Step>
            </Steps>
            <div slot="footer">
                <Button type="text" @click="cancelOption">关闭</Button>
            </div>
        </Modal>
    </div>
</template>

<script>
import {
  orderProcess
} from '@/api/eventlist'
// import { formatDate } from '@/components/dateFormat'
export default {
  name: 'processModal',
  props: {
    modalTitle: {
      type: String,
      default: () => {
        return ''
      }
    },
    modalType: {
      type: String,
      default: () => {
        return 'info'
      }
    },
    modalWidth: {
      type: Number,
      default: () => {
        return 600
      }
    },
    dataObj: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data () {
    return {
      modalShow: false,
      btnLoading: false,
      stepObj: {}
    }
  },
  methods: {
    modalAction () {
      this.modalShow = !this.modalShow
    },
    cancelOption () {
      this.modalShow = false
    },
    success (val) {
      val = this.$common.xeUtils.isEmpty(val) ? '操作成功' : val
      this.$Message.success(val)
    },
    error (data) {
      this.$Message.error({
        content: '操作失败,\n' + data.errmsg
      })
    },
    init () {
      orderProcess({ order_code: this.dataObj.code }).then(ret => {
        let data = ret.data
        if (data.errcode === 0) {
          this.stepObj = data.data
          this.stepObj.process_list = []
          this.stepObj.forEach(item => {
            let temp = {}
            temp.step_title = item.process_name + '  ' + item.create_time
            if (item.status === '0') {
              temp.text = '未处理'
              if (item.process_id === '8') {
                temp.text += '（接收社区：' + item.accept_company_name + '）'
              }
            } else {
              if (item.handle_by === 'system') {
                temp.text = '操作人：' + item.handle_byname
              } else {
                temp.text = '操作人：' + item.accept_company_name + '-' + item.handle_byname
              }
            }
            this.stepObj.process_list.push(temp)
          })
          this.stepObj.step_num = this.stepObj.process_list.length
          if (data.data[data.data.length - 1].state === '1') {
            this.stepObj.step_num += 1
          }
        } else {
          this.error(data)
        }
      })
    }
  },
  mounted () {
    // this.init()
  },
  watch: {
    dataObj () {
      this.init()
    }
  },
  computed: {}
}
</script>

<style lang="less" scoped>
</style>
