<template>
<div>
  <div class="container normal-panel normal-margin">
    <el-descriptions title="基础信息">
      <el-descriptions-item label="单号">{{mainData.billnum}}</el-descriptions-item>
      <el-descriptions-item label="预测模板">
        {{mainData.title}}
      </el-descriptions-item>
      <el-descriptions-item label="提报周期">
        <span v-for="i in mainData.periodpointchange" :key="i.index">
          {{mainData.periodtype === '周'?'周'+ `${i===7?'日':i}`:i+'日'}},
        </span>
      </el-descriptions-item>
      <el-descriptions-item label="提报要求">{{mainData.baseonproject === 1?'按项目预测':'无要求'}}</el-descriptions-item>
      <el-descriptions-item label="提报人">{{mainData.name}}</el-descriptions-item>
      <el-descriptions-item label="部门">{{mainData.depname}}</el-descriptions-item>
      <el-descriptions-item label="职位">{{mainData.position}}</el-descriptions-item>
      <el-descriptions-item label="提报时间">{{mainData.createdate}}</el-descriptions-item>
    </el-descriptions>
  </div>
  <div class="container normal-panel">
    <p class="normal-title normal-margin">提报内容</p>
    <div class="flex-align-center  search-panel normal-margin">
      <p>搜索:&nbsp;</p>
      <el-input style="width:200px" size="small" placeholder="产品类别" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" v-model="params.content.where.condition" prefix-icon="el-icon-search" clearable></el-input>
    </div>
    <tableLayout :layout="tablecols" :data="list" :custom="false" :fixedName="'operation'">

    </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>
  </div>
</div>
</template>

<script>
export default {
  data () {
    return {
      params:{
        "id": 20220906150503,
        "version":1,
        "content": {
          "sa_salesforecastbillid":this.$route.query.id,
          "pageNumber":1,
          "pageSize":10,
          "where":{
            "condition":"",
            "itemclassname":""
          }
        }
      },
      mainData:{},
      tablecols:[],
      list:[],
      total:0,
      currentPage:0,
    }
  },
  methods:{
    async headData () {
      const res = await this.$api.requested({
        "id": 20220906150403,
        "version":1,
        "content": {
          "sa_salesforecastmodelid":this.$route.query.modelid,
          "where":{
            "condition":"",
            "sa_salesforecastbillid":this.$route.query.id
          }
        }
      })
      this.mainData = res.data[0]
    },
    async listData () {
      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.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.params.content.pageNumber = val
      this.listData()
    },
  },
  mounted () {
    this.headData()
    this.listData()
  },
  created () {
    this.tablecols = this.tool.tabelCol(this.$route.name)['submitTable'].tablecols
  }
}

</script>
<style>
</style>