<template>
  <div>
    <el-dialog title="借阅详情" :visible.sync="detailVisible">
      <span class="dialog-right-top" />
      <span class="dialog-left-bottom" />
      <div class="setting-dialog">
        <div class="dpflex">
          <p><span class="color-blue">单据号:</span><span class="color-white">{{ otherInfo.id }}</span></p>
          <p><span class="color-blue">借阅人:</span><span class="color-white">{{ borrowerInfo.borrowerName }}</span></p>
          <p><span class="color-blue">所属部门:</span><span class="color-white">{{ borrowerInfo.department }}</span></p>
          <p><span class="color-blue">证件类型:</span><span class="color-white">{{ borrowerInfo.cardType }}</span></p>
          <p><span class="color-blue">证件号码:</span><span class="color-white">{{ borrowerInfo.idcard }}</span></p>
          <p><span class="color-blue">电话号码:</span><span class="color-white">{{ borrowerInfo.phone }}</span></p>
          <p><span class="color-blue">借阅目的:</span><span class="color-white">{{ otherInfo.purpose }}</span></p>
          <p><span class="color-blue">借阅日期:</span><span class="color-white">{{ lendDatesInfo }}</span></p>
          <p><span class="color-blue">借阅状态:</span><span :class="borrowStyle(otherInfo.borrow_type)">{{ otherInfo.borrow_type | borrowStatus }}</span></p>
          <p><span class="color-blue">操作时间:</span><span class="color-white">{{ otherInfo.create_time | parseTime }}</span></p>
        </div>
        <el-table :data="tableData" max-height="400px" style="margin-top:15px;">
          <el-table-column type="index" label="序号" align="center" width="55" />
          <el-table-column prop="categoryName" label="门类名称" align="center" min-width="120" />
          <el-table-column prop="archiveNo" label="档号" align="center" width="160" show-overflow-tooltip />
          <el-table-column prop="maintitle" label="题名" align="center" width="180" show-overflow-tooltip />
          <el-table-column prop="caseName" label="盒名称" align="center" min-width="120" show-overflow-tooltip />
          <el-table-column prop="folderLocationDetails" label="存放位置" align="center" min-width="260">
            <template v-if="scope.row.folderLocationDetails !== null" slot-scope="scope">
              <div v-if="scope.row.folderLocationDetails.includes(',')">
                <el-tag
                  v-for="(item,index) in scope.row.folderLocationDetails.split(',')"
                  :key="index"
                  :type="item"
                  effect="dark"
                >
                  {{ item }}
                </el-tag>
              </div>
              <div v-else>
                <el-tag effect="dark">{{ scope.row.folderLocationDetails }}</el-tag>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="borrowType" label="借阅状态" align="center" min-width="100">
            <template slot-scope="scope">
              <!-- 待借阅 / 逾期 have-lend / 待归还 / 已归还 has-return -->
              <span :class="borrowStyle(scope.row.borrowType)" style="width:76px">{{ scope.row.borrowType | borrowStatus }}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { FetchInitBillDetails } from '@/api/archivesManage/lendManage'
import { lendingCrud } from '../mixins/lending'
import { parseTime } from '@/utils/index.js'
export default {
  name: 'ArchiveDetail',
  mixins: [lendingCrud],
  data() {
    return {
      detailVisible: false,
      rowData: {},
      borrowerInfo: {},
      otherInfo: {},
      tableData: [],
      lendDatesInfo: null
    }
  },
  methods: {
    getBillDetails() {
      const params = {
        'orderNo': this.rowData.orderNo
      }
      FetchInitBillDetails(params).then(data => {
        this.otherInfo = data
        this.borrowerInfo = data.borrower
        this.tableData = data.borrowArchives
        this.lendDatesInfo = parseTime(data.borrow_start, '{y}-{m}-{d}') + ' 至 ' + parseTime(data.borrow_end, '{y}-{m}-{d}')
      })
    }
  }
}
</script>

<style lang="scss" scoped>
@import '~@/assets/styles/lend-manage.scss';
::v-deep .el-dialog__body{
  padding: 20px 0 60px 0;
}
::v-deep .el-dialog{
  width: 1100px;
}
::v-deep .el-dialog .el-dialog__header .el-dialog__close::before{
  position: absolute;
  right: -260px;
  bottom: -10px;
}
.dpflex{
  display: flex;
  flex-wrap: wrap;
  padding: 0 30px;
  p{
    display: flex;
    align-items: center;
    width: 33%;
    height: 40px;
    line-height: 40px;
    span{
      display: block;
      line-height: 40px;
      &.color-blue{
        color: #3A99FD;
        width: 70px;
        text-align: right;
      }
      &.color-white{
        color: white;
        padding: 0 0 0 20px;
      }
      &.cell-lend{
        margin-left: 20px;
        width: 76px;
        line-height: 24px;
      }
    }
  }
}
</style>
