<template>
  <a-modal
    :title="modalTitle"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
  >
    <detail-list title="" :col="2">
      <detail-list-item term="检定单号">{{ model.no }}</detail-list-item>
      <detail-list-item term="检定人">{{ model.name }}</detail-list-item>
      <detail-list-item term="检定日期">{{ model.lastDate }}</detail-list-item>
      <detail-list-item term="创建时间">{{ model.createdTime }}</detail-list-item>
    </detail-list>
    <detail-list title="" :col="1">
      <detail-list-item term="备注">{{ model.remark }}</detail-list-item>
    </detail-list>
    <detail-list title="标准图片" :col="8">
      <detail-list-item v-for="item in model.checkImgList" term="">
        <img :src="BaseTool.Constant.FILE_URL + item.url" width="200px" height="200px"/>
      </detail-list-item>
    </detail-list>
    <detail-list title="" :col="8">
      <detail-list-item term="文件">
        <a-upload
          :multiple="true"
          :fileList="BaseTool.UPLOAD.transImg(model.checkFileList)"
        >
        </a-upload>
      </detail-list-item>
    </detail-list>
<!--    <a-tabs type="card" default-active-key="1">
      <a-tab-pane key="1" tab="点检标准参数">
        <a-table
          bordered
          :data-source="data"
          :columns="columns"
          tableLayout="auto"
          rowKey="id"
        >
        </a-table>
      </a-tab-pane>
    </a-tabs>-->
    <template slot="footer">
      <a-button :loading="confirmLoading" type="primary" @click="handleCancel()">返回</a-button>
    </template>
  </a-modal>
</template>

<script>
import DetailList from '@/components/tools/DetailList'

const DetailListItem = DetailList.Item

export default {
  name: 'CheckStandardDetail',
  components: {
    DetailList,
    DetailListItem
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      // 下拉框map
      typeMap: {},
      periodTypeMap: {},
      actionTypeMap: {},
      enableMap: {},
      model: {
        'name': null,
        'no': null,
        'type': null,
        'part': null,
        'enable': null,
        'requirement': null,
        'standardHours': null,
        'remark': null,
        'createdUserId': null,
        'updateUserId': null,
        'updateUserName': null,
        'updateTime': null
      },
      rowSelection: {
        onChange: (selectedRowKeys, selectedRows) => {
          this.selectedRowKeys = selectedRowKeys
          this.selectedRows = selectedRows
        }
      },
      // 表头
      columns: [
        {
          title: '名称',
          dataIndex: 'name',
          scopedSlots: { customRender: 'name' }
        },
        {
          title: '类型',
          dataIndex: 'type',
          scopedSlots: { customRender: 'type' }
          // customRender: (text, record, index) => {
          //   return this.BaseTool.Table.getMapText(this.typeMap, text)
          // }
        },
        {
          title: '上限',
          dataIndex: 'upperLimit',
          scopedSlots: { customRender: 'upperLimit' }
        },
        {
          title: '下限',
          dataIndex: 'lowerrLimit',
          scopedSlots: { customRender: 'lowerrLimit' }
        },
        {
          title: '参考值',
          dataIndex: 'referenceValue',
          scopedSlots: { customRender: 'referenceValue' }
        },
        {
          title: '正常选型',
          dataIndex: 'normalSelection',
          scopedSlots: { customRender: 'normalSelection' }
        },
        {
          title: '说明',
          dataIndex: 'instruction',
          scopedSlots: { customRender: 'instruction' }
        }
      ],
      data: [],
      options: {
        rowSelection: {
          selectedRowKeys: this.selectedRowKeys
        }
      }
    }
  },
  created () {
    // 下拉框map
    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
    this.enableMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
    this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
    this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)

  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
      this.data = record.paramList
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
    }

  }
}
</script>
