<!--
  @description:投标服务费财务管理-增值服务费财务管理
  @Modifier:肖文龙
  @routerPath:/addService/addServiceManagementList
  @date:2019-12-9 17:06:04
-->
<template>
  <div style="height: 100%">
    <section class="title p0-16">
      增值服务费财务管理
    </section>
    <!--搜索-->
    <section :class="{'SearchContent_show':toggleSearchStatus}" class="p0-16 clearfix SearchContent">
      <div class="SearchContent_leftInput fl">
        <el-form ref="searchForm" :model="searchForm" inline>
          <el-form-item label="订单号" label-width="80px" prop="paymentInstitution">
            <el-input v-model="searchForm.paymentInstitution" placeholder="订单号" style="width:240px" />
          </el-form-item>
          <el-form-item label="项目名称" label-width="80px" prop="paymentInstitution">
            <el-input v-model="searchForm.title" placeholder="项目名称" style="width:240px" />
          </el-form-item>
          <el-form-item label="支付方式" label-width="80px" prop="paymentMode">
            <el-select v-model="searchForm.paymentMode" placeholder="请选择" style="width:240px">
              <el-option v-for="item in paymentModeOptions" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="服务类型" label-width="80px" prop="serviceType">
            <el-select v-model="searchForm.serviceType" placeholder="请选择" style="width:240px">
              <el-option v-for="item in serviceTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="缴费时间" label-width="80px" prop="effectEndDate">
            <el-date-picker
              v-model="applyDate"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              style="width:240px"
              @change="chooseTimeRange"
            />
          </el-form-item>
          <el-form-item label="开票状态" label-width="80px" prop="specialTicket">
            <el-select v-model="searchForm.billingStatus" placeholder="请选择" style="width:240px">
              <el-option v-for="item in billingStatusOptions" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-form>
      </div>
      <div class="fr">
        <el-button
          v-if="toggleSearchStatus"
          icon="el-icon-arrow-up"
          class="toggleSearchStatus"
          type="gray"
          @click="handleToggleSearch"
        />
        <el-button
          v-else
          icon="el-icon-arrow-down"
          class="toggleSearchStatus"
          type="gray"
          @click="handleToggleSearch"
        />
        <el-button type="primary" icon="iconfont icon-search" @click="onSearch('searchForm')">
          搜索
        </el-button>
        <el-button plain type="info" @click="resetForm('searchForm')">
          重置
        </el-button>
      </div>
    </section>
    <!--金额-->
    <section class="derivedScore">
      <div class="derivedScore_div">
        <el-button type="primary" size="small" plain icon="iconfont icon-export" @click="exportExcel">
          导出列表数据
        </el-button>
        <el-button type="primary" size="small" plain icon="iconfont icon-export" @click="exportExcel">
          导出发票信息
        </el-button>
      </div>
      <div class="derivedScore_div derivedScore_orange">
        费用统计：<span>123456</span>
      </div>
      <div class="derivedScore_div" />
    </section>
    <!--列表-->
    <section class="main">
      <el-table id="tableData" :data="tableData" :fit="true" style="width:100%" size="small">
        <el-table-column prop="orderNumber" min-width="70%" align="center" label="订单号" />
        <!-- 	<el-table-column prop="applicantUnit" :=true min-width="100%" label="申请单位">
						</el-table-column> -->
        <el-table-column prop="title" min-width="100%" label="项目名称" />
        <el-table-column prop="serviceType" min-width="100%" label="服务类型">
          <template slot-scope="scope">
            <span v-if="scope.row.serviceType==='00'">加急服务</span>
            <span v-if="scope.row.serviceType==='01'">远程投标服务</span>
            <span v-if="scope.row.serviceType==='02'">在线全程指导</span>
          </template>
        </el-table-column>
        <el-table-column prop="paymenAamount" min-width="100%" label="缴费金额（元）" />
        <el-table-column prop="paymentMode" min-width="100%" label="支付方式">
          <template slot-scope="scope">
            <span v-if="scope.row.paymentMode==='00'">易支付</span>
            <span v-if="scope.row.paymentMode==='01'">支付宝</span>
            <span v-if="scope.row.paymentMode==='02'">微信</span>
          </template>
        </el-table-column>
        <el-table-column prop="PayData" min-width="100%" label="缴费时间" />
        <el-table-column prop="billingData" min-width="100%" label="开票时间" />
        <el-table-column prop="refund" min-width="200px" label="退款">
          <template slot-scope="scope">
            <span v-if="scope.row.refund==='00'">否</span>
            <span v-if="scope.row.refund==='01'">是</span>
          </template>
        </el-table-column>
        <el-table-column prop="contacts" min-width="200px" label="联系人" />
        <el-table-column prop="mobilePhone" min-width="200px" label="联系电话" />
        <el-table-column prop="electronicsMail" min-width="200px" label="电子邮箱" />
        <el-table-column prop="invoice" min-width="200px" label="发票号" />
        <el-table-column prop="invoiceVerificationCode" min-width="200px" label="发票效验码" />
        <el-table-column prop="invoiceMethod" min-width="200px" label="开票方式">
          <template slot-scope="scope">
            <span v-if="scope.row.invoiceMethod==='00'">电子发票</span>
            <span v-if="scope.row.invoiceMethod==='01'">录入发票</span>
          </template>
        </el-table-column>
        <el-table-column prop="orderType" align="center" width="90px" fixed="right" style="z-index: 1" label="操作">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="info"
              plain
              @click="auditBtn(scope.row.id,scope.row.purchaseType)"
            >
              发票信息
            </el-button>
            <el-button
              size="mini"
              type="primary"
              plain
              @click="auditBtn(scope.row.id,scope.row.purchaseType)"
            >
              录入发票
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="getData" />
    </section>
  </div>
</template>

<script>
import { getList } from '@/api/purchase/purchaseMain'
import { ListMixin } from '@/mixins/ListMixin'
import pagination from '@comp/common/pagination/pagination'
export default {
  name: 'ManagementList',
  components: {
    pagination
  },
  mixins: [ListMixin],
  data() {
    return {
      searchForm: {
        applyEndDate: '', // 发布结束日期
        applyStartDate: '', // 发布开始日期
        purchaseNo: '', // 采购项目编号
        purchaseType: '', // 采购方式
        stage: '', // 项目所处阶段
        title: '', // 采购项目名称
        auditStatus: '' // 审核状态
      },
      applyDate: '', // 时间
      // 制作状态
      productionStatusOptions: [{
        value: '00',
        label: '未制作'
      }, {
        value: '01',
        label: '已制作'
      }],
      // 是否开取专票
      specialTicketOptions: [{
        value: '00',
        label: '否'
      }, {
        value: '01',
        label: '是'
      }],
      // 开票状态
      billingStatusOptions: [{
        value: '00',
        label: '未开票'
      }, {
        value: '01',
        label: '已开票'
      }],
      // 服务类型
      serviceTypeOptions: [{
        value: '00',
        label: '证书办理'
      }, {
        value: '01',
        label: '证书延期'
      }, {
        value: '02',
        label: '损坏/遗失补办'
      }, {
        value: '03',
        label: '证书更新'
      }],
      // CA类型
      caTypeOptions: [{
        value: '00',
        label: '单位身份证书'
      }, {
        value: '01',
        label: '个人数字证书'
      }],
      // 支付方式
      paymentModeOptions: [{
        value: '00',
        label: '易宝支付'
      }, {
        value: '01',
        label: '支付宝'
      }, {
        value: '02',
        label: '微信'
      }, {
        value: '03',
        label: '其他'
      }],
      // 数据列表
      tableData: [{}]

    }
  },
  methods: {
    // 路径跳转
    auditBtn(id, operation) { // 项目id
      if (operation === '00') {
        // 发票信息
        this.$router.push({
          path: '/addService/addServiceManagementList/informationDetail',
          query: {
            id: id
          }
        })
      } else if (operation === '01') {
        // 录入发票
        this.$router.push({
          path: '/addService/addServiceManagementList/entryAdd',
          query: {
            id: id
          }
        })
      }
    },
    // 时间转换
    chooseTimeRange(t) {
      const timeArr = t
      if (timeArr) {
        const moment = require('moment')
        for (const i in timeArr) {
          timeArr[i] = moment(timeArr[i]).format('YYYY-MM-DD')
        }
        this.searchForm.applyEndDate = timeArr[1] // 结束日期
        this.searchForm.applyStartDate = timeArr[0] // 开始日期
      }
    },
    // Excel导出
    exportExcel() {
    },
    // 初始化分页
    initData(tableData) {
      if (tableData === false) {
        this.tableData = []
      } else {
        const moment = require('moment')
        this.tableData = tableData.data.results
        this.paginationData.total = tableData.data.total
        for (let i = 0; i < this.tableData.length; i++) {
          this.tableData[i].createDate = moment(this.tableData[i].createDate).format('YYYY-MM-DD')
          // 审核状态
          if (this.tableData[i].auditStatus === '00') {
            this.tableData[i].auditStatus = '待审核'
          } else if (this.tableData[i].auditStatus === '01') {
            this.tableData[i].auditStatus = '审核通过'
          } else {
            this.tableData[i].auditStatus = '审核不通过'
          }
        }
      }
    },
    // 获取列表
    getData() {
      const data = {
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize,
        orgMethod: '00', // 自主采购
        ...this.searchForm
      }
      getList(data).then(response => {
        this.initData(response)
      }).catch(res => {})
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.getData(this.searchForm)
    },
    // 搜索重置
    resetForm(formName) {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.$refs[formName].resetFields()
      this.getData(this.searchForm)
    }
  }
}
</script>

<style lang="less">

</style>
