<template>
  <div class="app-container">
    <!-- 搜索 -->
    <div class="filter-container">
      <el-form :inline="true" :model="searchForm">
        <el-form-item label="收款" >
          <el-input v-model="searchForm.advice_man" placeholder="请输入收款" />
        </el-form-item>
        <el-form-item label="付款" >
          <el-input v-model="searchForm.advice_content" placeholder="请输入付款" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="fetchData">搜索</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格 -->
    <el-table v-loading="listLoading" :data="firmList" border fit  highlight-current-row style="width: 100%;">
      <el-table-column label="ID" prop="id" align="center" width="80"></el-table-column>
      <el-table-column label="日期" prop="time" align="center"></el-table-column>
      <el-table-column label="单据编号" prop="documentNumber" align="center"></el-table-column>
      <el-table-column label="单据类型" prop="documentType" align="center"></el-table-column>
      <el-table-column label="结算单位全名" prop="settlementCompanyFullName" align="center"></el-table-column>
      <el-table-column label="收货单位全名" prop="receivingCompanyFullName" align="center"></el-table-column>
      <el-table-column label="单据金额" prop="documentAmount" align="center"></el-table-column>
      <el-table-column label="合计结算金额" prop="settlementAmount" align="center"></el-table-column>
      <el-table-column label="未结算金额" prop="unSettlementAmount" align="center"></el-table-column>
      
      <el-table-column label="操作" align="center" width="220">
        <template slot-scope="scope">
          <el-button class="ml-10" size="mini" type="primary" @click="handleDetail(scope.row.advice_content)"> 详情 </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 翻页 -->
    <pagination v-show="total>0" 
      :total="total" 
      :page.sync="searchForm.page" 
      :page_len.sync="searchForm.page_len"
      :limit.sync="searchForm.limit" 
      @pagination="fetchData" />
    <!-- 弹窗 -->
    <el-dialog title="详情" :visible.sync="dialog" center width="540px">
      <div class="box font-16 lh-24">{{viewsContent}}</div>
    </el-dialog>
  </div>
</template>

<script>
import { listAdvice } from '@/api/system/index'

export default {
  data() {
    return {
      firmList: [],  // 列表
      total: 0,  // 总页数
      listLoading: true,
      // 搜索相关数据
      searchForm: {
        page: 1,
        page_len: 10
      },
      dialog: false, // 弹窗
      viewsContent: '', // 意见内容
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    // 获取列表
    fetchData(obj={}) {
      if(obj.page) {
        this.searchForm.page = obj.page
        this.searchForm.page_len = obj.page_len
      }
      this.listLoading = true
      this.$http(listAdvice(this.searchForm), (res) => {
        this.firmList = res.data.result
        this.total = res.data.data_sum
        this.listLoading = false
      })
    },
    // 内容详情
    handleDetail(viewsContent) {
      if(viewsContent) {
        this.viewsContent = viewsContent
        this.dialog = true
      }
    },
  }
}
</script>

<style lang='scss' scoped>
  .box {
    width: 496px;
    padding: 20px;
    text-indent:2em;
    border: 1px solid #ccc;
  }
</style>
