<template>
  <div class="container normal-panel">
    <div class="flex-align-center flex-between normal-margin">
      <p class="title">已提报经销商</p>
      <excel :tablecols="tablecols" :param="params" excelTitle="已提报经销商"></excel>
    </div>
    <tableLayout :layout="tablecols" :data="list" :custom="true" :height="310">
      <template v-slot:customcol="scope">
        <div v-if="scope.column.columnname === 'province'">
         {{scope.column.data.province}}-{{scope.column.data.city}}-{{scope.column.data.county}}
        </div>
        <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
      </template>
      <template v-slot:opreation="scope">
        <el-button size="mini" type="text"  @click="showAttinfos(scope.data)" >附 件</el-button>
      </template>
    </tableLayout>
    <div style="margin-top:16px;text-align:right">
      <el-pagination
        background
        small
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-size="params.content.pageSize"
        layout="total, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
    <el-dialog title="附件列表" :visible.sync="dialogTableVisible">
      <el-table size="small" :data="attinfos">
        <el-table-column property="document" label="文件名称"></el-table-column>
        <el-table-column property="createdate" label="上传时间"></el-table-column>
        <el-table-column
          prop="contentlength"
          label="文件大小"
          width="90">
          <template slot-scope="scope">
            {{scope.row.contentlength > 1073741824?(scope.row.contentlength / Math.pow(1024,3)).toFixed(2)+'GB':scope.row.contentlength > 1048576?(scope.row.contentlength / Math.pow(1024,2)).toFixed(2)+'MB':scope.row.contentlength > 1024?(scope.row.contentlength / Math.pow(1024,1)).toFixed(2)+'KB':scope.row.contentlength+'B'}}
          </template>
        </el-table-column>
        <el-table-column
          prop="contentlength"
          label="操作"
          width="90">
          <template slot-scope="scope">
            <a class="inline-16" :href="scope.row.url" style="color:#3874F6;margin-ri">下 载</a>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import excel from '@/components/export_excel/index.vue'

export default {
  components:{
    excel
  },
  data () {
    return {
      dialogTableVisible:false,
      params:{
        "classname": "webmanage.saletool.submitedit.statistics.agent",
        "method": "getSubmitList",
        "content": {
          "sat_submiteditmodelid": this.$route.query.id,
          "pageNumber": 1,
          "pageSize": 20
        }
      },
      tablecols:[],
      attinfos:[],
      list:[],
      total:0,
      currentPage:0
    }
  },
  methods:{
    async getSubmitList () {
      const res = await this.$api.requested(this.params)
      this.list = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.params.content.pageSize = val
      this.getSubmitList()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.params.content.pageNumber = val
      this.getSubmitList()
    },
    showAttinfos (row) {
      this.dialogTableVisible = true
      this.attinfos = row.attinfos
    }
  },
  mounted () {
    this.getSubmitList()
  },
  created () {
    this.tablecols = this.tool.tabelCol(this.$route.name)['tableSubmit'].tablecols
  }
}

</script>
<style>

</style>
<style scoped>
.title{
  height: 20px;
  line-height: 20px;
  font-size: 14px;
  text-indent: 7px;
  font-weight: bold;
  color: #333333;
  margin-bottom: 20px;
  border-left: .3rem solid #3874F6;
}
</style>