<template>
  <a-modal
    :title="modalTitle"
    :width="850"
    :visible="visible"
    :confirmLoading="confirmLoading"
    class="ant-modal2"
    @cancel="handleCancel"
  >
    <detail-list title="" :col="2">
      <detail-list-item term="设备名称">{{ model.sbName }}</detail-list-item>
      <detail-list-item term="设备编号">{{ model.sbNo }}</detail-list-item>
      <detail-list-item term="仓库名称">{{ model.storeName }}</detail-list-item>
      <detail-list-item term="申请人">{{ model.userName }}</detail-list-item>
      <detail-list-item term="燃油类型">{{ model.spareName }}</detail-list-item>
      <detail-list-item v-show="false" term="工程项目">{{ model.projectQuantityName }}</detail-list-item>
      <detail-list-item term="用途">{{ model.reason }}</detail-list-item>
      <detail-list-item term="处理人">{{ model.storeUserName }}</detail-list-item>
      <detail-list-item term="状态"><badge :status="DictCache.COLOR.SB_OIL_STATUS[model.status]" :text="statusMap[model.status]"></badge></detail-list-item>
      <detail-list-item term="申请油量">{{ BaseTool.Amount.formatter(model.applyOil) }}升</detail-list-item>
      <detail-list-item term="实际加油量">{{ BaseTool.Amount.formatter(model.realOil) }}升</detail-list-item>
      <detail-list-item term="创建日期">{{ model.createdTime }}</detail-list-item>
      <detail-list-item term="更新日期">{{ model.updateTime }}</detail-list-item>
      <detail-list-item term="申请说明">{{ model.applyRemark }}&nbsp;</detail-list-item>
      <detail-list-item term="加油说明">{{ model.handleRemark }}&nbsp;</detail-list-item>
    </detail-list>

    <template slot="footer">
      <a-button :loading="confirmLoading" type="primary" @click="save()">确定</a-button>
    </template>
  </a-modal>
</template>

<script>
import DetailList from '@/components/tools/DetailList'
import { updateConfirmSbOil } from '@/api/sb/oil'
const DetailListItem = DetailList.Item

export default {
  name: 'SbOilDetail',
  components: {
    DetailList,
    DetailListItem
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      // 下拉框map
      statusMap: {},
      model: {
        'sbId': null,
        'storeId': null,
        'userId': null,
        'userName': null,
        'storeUserId': null,
        'storeUserName': null,
        'status': null,
        'applyOil': null,
        'realOil': null,
        'applyRemark': null,
        'handleRemark': null,
        'remark': null,
        'createdUserId': null,
        'updateUserId': null,
        'updateUserName': null,
        'updateTime': null,
        'isOiL': null,
        'isAudit': null
      }
    }
  },
  created () {
    // 下拉框map
    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_OIL_STATUS)
  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
    },
    save () {
      updateConfirmSbOil({ id: this.model.id })
        .then(() => {
          this.handleCancel({ id: this.model.id })
        }).catch(() => {
          this.confirmLoading = false
        })
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
      this.$emit('ok', '')
    }

  }
}
</script>
