<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 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="invoiceNumber" align="center"></el-table-column>
      <el-table-column label="开票日期" prop="invoiceDate" align="center"></el-table-column>
      <el-table-column label="发票类型" prop="invoiceType" align="center"></el-table-column>
      <el-table-column label="供应商代码" prop="supplierCode" align="center"></el-table-column>
      <el-table-column label="供应商名称" prop="supplierName" align="center"></el-table-column>
      <el-table-column label="物料编码" prop="materialCode" align="center"></el-table-column>
      <el-table-column label="物料名称" prop="materialName" align="center"></el-table-column>
      <el-table-column label="规格型号" prop="specification" align="center"></el-table-column>
      <el-table-column label="单位" prop="unit" align="center"></el-table-column>
      <el-table-column label="数量" prop="quantity" align="center"></el-table-column>
      <el-table-column label="含税单价" prop="taxPrice" align="center"></el-table-column>
      <el-table-column label="税率" prop="taxRate" align="center"></el-table-column>
      <el-table-column label="不含税金额" prop="untaxedAmount" align="center"></el-table-column>
      <el-table-column label="税额" prop="taxAmount" align="center"></el-table-column>
      <el-table-column label="价税合计" prop="totalPrice" align="center"></el-table-column>
      <el-table-column label="备注" prop="remark" 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>
