<template>
  <div class="container normal-panel">
    <!-- 表格 -->
    <excel class="normal-margin" :tablecols="tablecols" :param="params" excelTitle="提报明细"></excel>
    <tableLayout :layout="tablecols" :data="list" :custom="false" height="calc(100vh - 131px)">
      <template v-slot:customcol="scope">
        <p>{{scope.column.data[scope.column.columnname]}}</p>
      </template>
      <template v-slot:opreation="scope">
        <el-button class="inline-16" type="text" size="mini" @click="getFileData(scope.data)">附 件</el-button>
        <el-popconfirm
          title="确定删除当前提报吗？"
          @confirm="returnSubmit(scope.data)">
          <el-button slot="reference" size="small" type="text">退 回</el-button>
        </el-popconfirm>
      </template>
    </tableLayout>
    <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,
      list:[],
      tablecols:[],
      attinfos:[],
      params:{
        "classname": "webmanage.saletool.submitedit.submitedit",
        "method": "selectSubmitDetailList",
        "content": {
          "sat_submiteditmodelid": this.$route.query.id
        }
      }
    }
  },
  methods:{
    async selectSubmitDetailList () {
      const res = await this.$api.requested({
        "classname": "webmanage.saletool.submitedit.submitedit",
        "method": "selectSubmitDetailList",
        "content": {
          "sat_submiteditmodelid": this.$route.query.id
        }
      })
      this.list = res.data
    },
    getFileData (row) {
      this.dialogTableVisible = true
      this.attinfos = row.attinfos
    },
    async returnSubmit (row) {
      console.log(row)
      const res = await this.$api.requested({
       "classname": "webmanage.saletool.submitedit.submitedit",
        "method": "returnsubmitdetailed",
        "content": {
          "sat_submiteditmodelid":row.sat_submiteditmodelid,
          "sat_submiteditid":row.sat_submiteditid
        }
      })
      this.tool.showMessage(res,this.selectSubmitDetailList)
      
    },
  },
  mounted () {
    this.selectSubmitDetailList()
  },
  created () {
    //获取表结构
    this.tablecols = this.tool.tabelCol(this.$route.name)['tablePateContent'].tablecols
  }
}

</script>
<style>
</style>