<!--
  @description: 服务费管理
  @Modifier: sunxinman/haofengxian
  @routerPath: /fee/serviceManage
  @date: 2020/04/06-12:18
-->
<template>
  <div>
    <table-crud
      ref="tableCrud"
      :search-form="searchForm"
      search-label-width="110px"
      @on-load="loadData"
    >
      <template v-slot:header>
        服务费管理
      </template>
      <template v-slot:search="search">
        <!-- 招标项目编号 -->
        <el-form-item ref="tenderNo" label="招标项目编号" prop="tenderNo">
          <el-input
            v-model.trim="searchForm.tenderNo"
            placeholder="招标项目编号"
            style="width:220px"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
        <!-- 标段（包）名称 -->
        <el-form-item ref="packName" label="标段（包）名称" prop="packName">
          <el-input
            v-model.trim="searchForm.packName"
            placeholder="标段（包）名称"
            style="width:220px"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
        <!-- 服务费收取对象 -->
        <el-form-item label="服务费收取对象" prop="paymentParty">
          <el-select v-model="searchForm.paymentParty" placeholder="请选择" style="width:220px">
            <el-option
              v-for="(item,index) in collectionObjList"
              :key="index"
              :label="item.typename"
              :value="item.typecode"
            />
          </el-select>
        </el-form-item>
        <!--服务费收取方式-->
        <el-form-item ref="paymentMethod" label="服务费收取方式" prop="paymentMethod">
          <el-select v-model="searchForm.paymentMethod" placeholder="请选择" style="width:220px">
            <el-option
              v-for="(item,index) in collectionWayList"
              :key="index"
              :label="item.typename"
              :value="item.typecode"
            />
          </el-select>
        </el-form-item>
      </template>
      <template v-slot:GXTable>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
        >
          <el-table-column
            type="index"
            label="序号"
            fixed="left"
            width="60px"
            align="center"
          />
          <!-- 招标项目编号-->
          <el-table-column
            prop="tenderNo"
            align="center"
            fixed="left"
            label="招标项目编号"
            width="160"
          />
          <!-- 标段（包）名称 -->
          <el-table-column
            header-align="center"
            label="标段（包）名称"
            prop="packName"
            align="left"
            min-width="200"
          />
          <!-- 招标代理服务费收取对象 -->
          <el-table-column
            :formatter="formatPaymentParty"
            header-align="center"
            prop="paymentParty"
            label="招标代理服务费收取对象"
            align="center"
            width="220"
          />
          <!-- 招标代理服务费收取方式-->
          <el-table-column
            :formatter="formatPaymentMethod"
            header-align="center"
            label="招标代理服务费收取方式"
            prop="paymentMethod"
            min-width="200"
          />
          <!-- 项目经理 -->
          <el-table-column
            header-align="center"
            label="项目经理"
            prop="tenderManager"
            width="100"
          />
          <!-- 业务部门 -->
          <el-table-column
            header-align="center"
            align="center"
            label="业务部门"
            prop="tenderDepart"
            min-width="100"
          />
          <!-- 开票金额（元） -->
          <el-table-column
            header-align="center"
            label="开票金额（元）"
            prop="totalInvoiceAmount"
            align="right"
            min-width="150"
          />
          <!-- 操作 -->
          <el-table-column
            header-align="center"
            align="center"
            label="操作"
            width="130"
          >
            <template slot-scope="scope">
              <el-link type="primary" @click.stop="invoice(scope.row)">
                [服务费开票记录]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </table-crud>
  </div>
</template>
<script>
/* 接口*/
import { queryWinServicePackinfoList } from '@/api/fee/servicefee'
/* 混合开发方法-参数字段*/
import { ServiceGroupMixin } from '../../mixins/serviceFeeGroupMixin'

export default {
  name: 'ServiceManageList',
  mixins: [ServiceGroupMixin],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        packId: '', // 标段id
        packName: '', // 标段名称
        packNo: '', // 标段编号
        paymentMethod: '', // 服务费支付方式00差额定率累进制 01固定金额 02固定比例
        paymentParty: '', // 服务费支付方00中标人 01招标人
        tenderDepart: '', // 业务部门
        tenderDepartId: '', // 业务部门ID
        tenderId: '', // 项目id
        tenderManager: '', // 项目经理
        tenderManagerId: '', // 项目经理ID
        tenderName: '', // 项目名称
        tenderNo: '', // 项目编号
        winServicePackinfoid: '' // 服务费包组信息id
      },
      tableData: []
    }
  },
  methods: {
    // 获取数据
    loadData(params, callback) {
      queryWinServicePackinfoList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 服务费开票记录
    invoice(row) {
      this.$router.push({
        path: '/fee/serviceInvoiceRecords',
        query: {
          winServicePackinfoid: row.winServicePackinfoid,
          packId: row.packId, // 标段id
          stageId: row.stageId, // 阶段id
          tenderId: row.tenderId // 项目id
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
