<template>
  <div class="app-container">
    <div class="title-container">
      <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
    </div>
    <y-page-list-layout :page-list="pageData" :page-para="listQuery" :get-page-list="getList">
      <template slot="left">
        <el-input v-model="listQuery.keyword" placeholder="关键字搜索..." clearable
          style="margin-left: 20px;width: 500px;float: left;">
        </el-input>
        <el-date-picker
          style="margin-left: 20px;float: left;"
          v-model="saveFileDate"
          type="daterange"
          align="center"
          unlink-panels
          range-separator="至"
          start-placeholder="归档日期（开始）"
          end-placeholder="归档日期（结束）"
          :picker-options="pickerOptions" value-format="yyyy-MM-dd">
        </el-date-picker>
        <el-button class="filter-item" style="margin-left: 10px;float: left;" type="primary" @click="searchList" round>搜索
        </el-button>
        <el-button class="filter-item" style="float: left;" round type="success" @click="resetSearch()">重置
        </el-button>
      </template>
      <parentTable  :data="pageData.records" slot="table" style="width: 100%;">
        <el-table-column label="坐落" align="center" width="200">
          <template slot-scope="{row}">
            <span>{{ row.location }}</span>
          </template>
        </el-table-column>
        <el-table-column label="项目编号" align="center" width="140" >
          <template slot-scope="{row}">
            <span>{{ row.orderId }}</span>
          </template>
        </el-table-column>
        <el-table-column label="面积" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.acreage }}</span>
          </template>
        </el-table-column>
        <el-table-column label="单价" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.price }}</span>
          </template>
        </el-table-column>
        <el-table-column label="总价" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.amount }}</span>
          </template>
        </el-table-column>
        <el-table-column label="客户名称" align="center" width="130">
          <template slot-scope="{row}">
            <span>{{ row.clientName==null?'-': row.clientName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="业务来源" align="center" width="130">
          <template slot-scope="{row}">
            <span>{{ row.clientSubName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="客户经理" align="center">
          <template slot-scope="{row}">
            <span>{{ row.clientManager }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实勘人" align="center">
          <template slot-scope="{row}">
            <span>{{ row.outwardStaffName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="内业人员" align="center">
          <template slot-scope="{row}">
            <span>{{ row.inwardStaffName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="定价人员" align="center">
          <template slot-scope="{row}">
            <span>{{ row.pricingStaffName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实收款(元)" align="center">
          <template slot-scope="{row}">
            <span style="color:red;font-weight:bold">{{ row.realAmount }}</span>
          </template>
        </el-table-column>
        <el-table-column label="下单时间" align="center" width="100">
          <template slot-scope="{row}">
            {{ row.created }}
          </template>
        </el-table-column>
        <el-table-column label="归档日期" align="center" width="100">
          <template slot-scope="{row}">
            <span>{{ row.saveFileDate }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="130">
          <template slot-scope="{row}">
            <el-button type="success" round @click="toDetail(row)">订单详情</el-button>
          </template>
        </el-table-column>
      </parentTable>
    </y-page-list-layout>
  </div>
</template>
<script>
import YPageListLayout from '@/components/YPageListLayout'
import Breadcrumb from '@/components/Breadcrumb'

export default {
  name: 'saveFileDonePersonalList',
  components: {
    Breadcrumb,
    YPageListLayout,
  },
  filters: {
    
  },
  data() {
    return {
      pageData: { records: [] },
      listQuery: {
        page: 1,
        size: 10,
        descs: 'id',
      },
      saveFileDate:'',
      pickerOptions: {
          shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }]
      },
    }
  },
  created() {
    this.getList();
  },
  methods: {
  
    resetSearch() {
      this.$router.push({ query: {} });
      this.saveFileDate='';
      this.listQuery = {
        current: 1,
        size: 10,
        descs: 'id',
      }
      this.getList()
    },
   
    searchList() {
      // 重置分页
      this.listQuery.page = 1
      this.listQuery.size = 10
      if (this.saveFileDate){
        this.listQuery.startDate = this.saveFileDate[0]+' 00:00:00';
        this.listQuery.endDate = this.saveFileDate[1]+ ' 23:59:59';
      }
      this.getList()
    },
    getList() {
      this.$api.personal.saveFileDone(this.listQuery).then(res=>{
        if (res.code ===200){
            this.pageData = res.data;
        }
      })
    },
   
    toDetail(row){
      this.$router.push(`/personal/readonly/detail?id=${row.id}&orderId=${row.orderId}&back=${'/personal/saveFile'}`)
    },
  },
  
}
</script>
<style lang="scss" scoped>

</style>
