<template>
  <div class="fileList">
    <div class="fileList-title">
      <span class="fileList-title-side"></span>
      资料下载
      <span class="fileList-title-more" @click="handleMore">
        <span>更多</span>
        <Icon type="ios-arrow-forward" class="more-icon"/>
      </span>
    </div>
    <div class="fileList-content">
      <file-item v-for="item in fileList" :file="item" :key="item.id" :fileWidth="fileWidth"></file-item>
    </div>

    <Modal class-name="file-modal" v-model="modalShow" title="资料下载">
      <div style="height:500px;overflow:auto">
        <file-item v-for="item in fileList" :file="item" :key="item.id"></file-item>
      </div>
    </Modal>
  </div>
</template>
<script>

import fileItem from './fileItem.vue'

export default {
  components: {
    fileItem
  },
  props: {
    itemSetting: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      fileList: [],
      fileWidth: '100%',
      modalShow: false
    }
  },
  created() {
    let prop = this.itemSetting.properties
    if (prop && Array.isArray(prop)) {
      let num = prop[0]? prop[0].num: 2
      let str = Math.floor(100 / num) + '%'
      this.fileWidth = `calc(${str} - 10px)`
    }
  },
  mounted() {
    this.getFileLList()
  },

  methods: {
    async getFileLList() {
      const url = `/common/attachment/owner/00000000-0000-0000-0000-000000000000`
      const { data } = await GMS.$http.get(url)
      this.fileList = data
      console.log({ data })
    },
    handleMore() {
      this.modalShow = true
      
    }
  },
}
</script>
<style lang="less" scoped>
.fileList {
  height: 100%;
  padding: 16px;
  border-radius: 6px;
  border: 1px solid #E5E5E5;
  overflow: hidden;
  background-color: white;
  &-title {
    text-align: left;
    font-size: 16px;
    font-weight: 500;
    height: 22px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #0f0f0f;
    line-height: 22px;
    margin-bottom: 16px;
    &-side {
      display: inline-block;
      width: 3px;
      height: 14px;
      background: #5369d8;
      border-radius: 2px;
      margin-right: 5px;
    }
    &-more {
      float: right;
      width: 45px;
      height: 20px;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #5369d8;
      line-height: 20px;
      cursor: pointer;
      .more-icon {
        background: rgba(83, 105, 216, 0.11);
        border-radius: 2px;
      }
    }
  }
  &-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }

}
.file-modal {
  /deep/ .ivu-modal {
    .ivu-modal-body {
      height: 500px;
      overflow: auto;
    }
  }

}
</style>