<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" @submit.native.prevent v-show="showSearch">
      <el-form-item label="结算单号" prop="num">
        <el-input v-model="queryParams.num" placeholder="请输入结算单号" @keyup.enter.native="handleQuery" clearable />
      </el-form-item>
      <el-form-item label="创建日期">
        <el-date-picker v-model="dateRange" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="response.rows" border height="calc(100vh - 235px)">
      <el-table-column type="index" label="序号" align="center" width="70" />
      <el-table-column label="结算单号" align="center" prop="num" width="160" />
      <el-table-column label="结算批次" align="center" prop="batchName" width="160" />
      <el-table-column label="服务公司" align="center" width="200">
        <template slot-scope="scope">
          <div class="omit" :title="scope.row.serviceCompany">{{ scope.row.serviceCompany }}</div>
        </template>
      </el-table-column>
      <el-table-column label="关联项目" align="center" prop="projectName" width="150" />
      <el-table-column label="结算人数" align="center" prop="peoples" width="110" />
      <el-table-column label="结算金额(元)" align="center" prop="money" width="125" />
      <el-table-column label="发放业务费(元)" align="center" prop="realMoney" width="125" />
      <el-table-column label="综合服务费(元)" align="center" prop="serviceMoney" width="125" />
      <el-table-column label="发放状态" align="center" width="110">
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.give == 1">待发放</el-tag>
          <el-tag type="success" v-if="scope.row.give == 2">已发放</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="创建日期" align="center" prop="giveTime" width="160" />
      <el-table-column label="操作" align="center" width="160">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="op('detail', scope.row)">详情</el-button>
        </template>
      </el-table-column>
      <template slot="empty">
        <el-empty></el-empty>
      </template>
    </el-table>
    <pagination v-if="response.total > 0" :total="response.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>

<script>
import record from '@/views/work/statement/manage/record';
export default {
  data() {
    return {
      showSearch: true,
      response: {},
      dateRange: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        num: null,
        give: null,
        orderByColumn: 's.id',
        isAsc: 'desc'
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      if (this.dateRange) {
        this.queryParams.dateBegin = this.dateRange[0];
        this.queryParams.dateEnd = this.dateRange[1];
      }
      this.ajax({ url: '/work/statement/bill', data: this.queryParams }).then((response) => {
        this.response = response;
      });
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    resetQuery() {
      this.resetForm('queryForm');
      this.dateRange = [];
      this.handleQuery();
    },
    op(tag, row) {
      if (tag == 'detail') {
        this.iframe({ obj: record, param: { form: row, detail: true }, title: '查看结算单详情', width: '75%', height: '65%' });
      }
    }
  }
};
</script>
