<template>
  <a-modal
    :title="modalTitle"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
  >
    <detail-list title="" :col="2">
      <detail-list-item term="标准名称">{{ model.name }}</detail-list-item>
      <detail-list-item term="排序">{{ model.sort }}</detail-list-item>
<!--      <detail-list-item term="编码">{{ model.no }}</detail-list-item>-->
      <detail-list-item term="检查类型">{{ BaseTool.Object.getField(typeMap,model.type) }}</detail-list-item>
      <detail-list-item term="计划周期">{{ model.period }}{{ BaseTool.Object.getField(periodTypeMap,model.periodType) }}</detail-list-item>
      <detail-list-item term="标准工时">{{ model.standardHours }}</detail-list-item>
<!--      <detail-list-item term="动作类型">{{ BaseTool.Object.getField(actionTypeMap,model.actionType) }}</detail-list-item>-->
      <detail-list-item term="部位">{{ model.partName }}</detail-list-item>
<!--      <detail-list-item term="是否启用"><badge :status="DictCache.COLOR.YES_NO[model.enable]" :text="enableMap[model.enable]"></badge></detail-list-item>-->
      <!--      <detail-list-item term="创建人">{{ model.createdUserName }}</detail-list-item>
          <detail-list-item term="更新人">{{ model.updateUserName }}</detail-list-item>
           <detail-list-item term="创建时间">{{ model.updateTime }}</detail-list-item>
           <detail-list-item term="更新时间">{{ model.updateTime }}</detail-list-item>-->
    </detail-list>
    <detail-list title="" :col="1">
      <detail-list-item term="检查项目">{{ model.requirement }}</detail-list-item>
      <detail-list-item term="执行标准">{{ model.remark }}</detail-list-item>
    </detail-list>
    <title-divider title="标准图片" width="90px"></title-divider>
    <detail-list title="" :col="1">
      <detail-list-item term="" v-if="model.checkImgList != null && model.checkImgList.length > 0">
        <viewer :images="model.checkImgList" @inited="inited" ref="viewer" :index="1" >
          <img v-for="item in model.checkImgList" :src="item.url" :key="item.id" class="image">
        </viewer>
      </detail-list-item>
      <detail-list-item term="" v-if="model.checkImgList == null || model.checkImgList.length === 0">
        暂无
      </detail-list-item>
    </detail-list>
    <title-divider title="标准文件" width="90px"></title-divider>
    <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>-->
    <title-divider title="关联备件" width="90px"></title-divider>
    <a-table
      :data-source="data"
      :columns="columns"
      bordered
      tableLayout="auto"
      rowKey="bomId">
    </a-table>
    <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: 'spareName'
        },
        {
          title: '规格型号',
          dataIndex: 'ggxh'
        },
        {
          title: '数量',
          dataIndex: 'num',
          width: 150,
          scopedSlots: { customRender: 'num' }
        }
      ],
      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: {
    inited (viewer) {
      this.$viewer = viewer
      // this.$viewer.index = 0
      // // 不要他的按钮
      // this.$viewer.options.button = false
      // // 不要他的底部缩略图
      // this.$viewer.options.navbar = false
      // // 不要他的底部标题
      // this.$viewer.options.title = false
      // // 不要他的底部工具栏
      // this.$viewer.options.toolbar = false
    },
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
      this.data = record.detailList
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
    }

  }
}
</script>
