<template>
  <div>
    <tableLayout :layout="tablecols" :data="list" fixedName="" :custom="true" >
      <template v-slot:customcol="scope" >
        <div v-if="scope.column.columnname === 'billno'" >
            <el-button type="text" @click="detailGo(scope.column.data)">
              {{scope.column.data[scope.column.columnname]}}
            </el-button>
        </div>
        <div v-else-if="scope.column.columnname === 'specialoffer'" >
          <div v-if="scope.column.data.specialoffer === 0">
            否
          </div>
          <div v-else-if="scope.column.data.specialoffer === 1">
            是
          </div>
        </div>
        <div v-else-if="scope.column.columnname === 'invaliddate'">
          <p>{{scope.column.data.begdate?scope.column.data.begdate+ '至' + scope.column.data.enddate:'--'}}</p>
        </div>
        <div v-else-if="scope.column.columnname === 'operation'">
          <p>{{scope.column.data[scope.column.columnname]}}</p>
        </div>
        <div v-else>
          {{scope.column.data[scope.column.columnname]?scope.column.data[scope.column.columnname]:'--'}}
        </div>
      </template>
      <template v-slot:opreation="scope">
        <el-button size="mini" type="text" @click="detailGo(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="param.content.pageSize"
          layout="total, prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  name: "index",
  props:["data"],
  data(){
    return {
      tablecols:[],
      list:[],
      total:0,
      currentPage:0,
      param:{
        "content": {
          "isExport": 0,
          "pageNumber": 1,
          "pageSize": 20,
          "where": {
            "status": "",
            "isproject": "",
            "startdate": "",
            "enddate": ""
          },
          "type": "0",
          "sa_quotedpriceid":""
        },
        "id": 20221209093003,
      }
    }
  },
  methods:{
    detailGo(row){
      console.log(row,'输出')
      this.$store.dispatch('changeDetailDrawer',false)
      setTimeout(()=>{
        this.$router.replace({
          path:'/quotedPriceDetail',
          query:{
            id:row.sa_quotedpriceid,
            rowindex:row.rowindex
          }
        })
        this.$store.dispatch('changeDetailDrawer',true)
      },500)

    },
    async listData(){
      this.param.content.sa_quotedpriceid = this.data.sa_quotedpriceid
      const res = await this.$api.requested(this.param)
      this.list = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.param.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.param.content.pageNumber = val
      this.listData()
    },
  },
  mounted() {
    this.listData()
  },
  created() {
    this.tablecols = this.tool.tabelCol(this.$route.name).historicalQuotation.tablecols
  },
}
</script>

<style scoped>

</style>