<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" @submit.native.prevent>
      <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="结算批次" prop="batchName">
        <el-input v-model="queryParams.batchName" placeholder="请输入结算批次" @keyup.enter.native="handleQuery" clearable />
      </el-form-item>
      <el-form-item label="发放状态" prop="give">
        <el-select v-model="queryParams.give" placeholder="充值状态" class="se" clearable>
          <el-option value="0" label="待发放"></el-option>
          <el-option value="1" label="待核实"></el-option>
          <el-option value="2" label="发放成功"></el-option>
        </el-select>
      </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="selection" width="55" align="center" />
      <el-table-column type="index" label="序号" align="center" width="80" />
      <el-table-column label="结算单号" align="center" prop="num" width="160" />
      <el-table-column label="结算批次" align="center" prop="batchName" width="150"/>
      <el-table-column label="服务公司" align="center" width="160">
        <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="160"/>
      <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" fixed="right">
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.give == 0">待发放</el-tag>
          <el-tag type="danger" 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="auditTime" width="160" />
      <el-table-column label="操作" align="center" width="200" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="op('detail', scope.row)">详情</el-button>
          <el-button size="mini" type="text" icon="el-icon-s-promotion" @click="op('send', scope.row)" v-if="scope.row.give == 0">发放</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';
import send from './send';
export default {
  data() {
    return {
      response: {},
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        batchName: null,
        num: null,
        projectId: null,
        give: null,
        orderByColumn: 's.id',
        isAsc: 'desc'
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.ajax({ url: '/work/statement/give', data: this.queryParams }).then((response) => {
        this.response = response;
      });
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    resetQuery() {
      this.resetForm('queryForm');
      this.handleQuery();
    },
    op(tag, row) {
      const id = row.id || this.ids[0];
      if (tag == 'detail') {
        this.iframe({ obj: record, param: { form: row, detail: true }, title: '查看结算单详情', width: '75%', height: '65%' });
      }
      if (tag == 'send') {
        this.iframe({ obj: send, param: { id: id, row: row }, title: '薪资发放', width: '50%', height: '70%' });
      }
    }
  }
};
</script>
