<!--
  @description: CA管理-CA确认缴费
  @Modifier:肖文龙
  @routerPath:/caManage/confirmPayment
  @date:2019-12-6 15:33:47
-->
<template>
  <div style="height: 100%">
    <section class="title p0-16">
      确认CA缴费
    </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.title" placeholder="申请人" style="width:240px" />
          </el-form-item>
          <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="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="CA类型" label-width="80px" prop="caType">
            <el-select v-model="searchForm.caType" placeholder="请选择" style="width:240px">
              <el-option v-for="item in caTypeOptions" :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>
      </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="main">
      <el-table :data="tableData" :fit="true" style="width: 100%" size="small">
        <el-table-column type="index" label="序号" width="60" align="center" />
        <el-table-column prop="title" min-width="70%" align="center" label="申请人" />
        <el-table-column prop="applicantUnit" min-width="100%" label="申请单位" />
        <el-table-column prop="applicationData" min-width="100%" label="申请时间" />
        <el-table-column prop="caType" min-width="100%" label="CA类型">
          <template slot-scope="scope">
            <span v-if="scope.row.caType==='00'">单位身份证书</span>
            <span v-if="scope.row.caType==='01'">个人数字证书</span>
          </template>
        </el-table-column>
        <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>
          </template>
        </el-table-column>
        <el-table-column prop="paymenAamount" min-width="100%" label="缴费金额（元）" />
        <el-table-column prop="purchaseType" fixed="right" label="操作" align="center" width="90px">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="info"
              plain
              @click="auditBtn(scope.row.id)"
            >
              确认缴费
            </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: 'ConfirmPaymentList',
  components: {
    pagination
  },
  mixins: [ListMixin],
  data() {
    return {
      is_hide: false,
      searchForm: {
        applyEndDate: '', // 发布结束日期
        applyStartDate: '', // 发布开始日期
        purchaseNo: '', // 采购项目编号
        purchaseType: '', // 采购方式
        stage: '', // 项目所处阶段
        title: '', // 采购项目名称
        auditStatus: '' // 审核状态
      },
      applyDate: '', // 时间
      tableData: [{
        serialNumber: '', // 流水号
        applicantUnit: '', // 申请单位
        applicationData: '', // 申请时间
        AuditData: '', // 审核时间
        caType: '', // CA类型
        serviceType: '', // 服务类型
        paymentMode: '', // 支付方式
        PayData: '', // 缴费时间
        billingStatus: '', // 开票状态
        specialTicket: '', // 是否专票
        mobilePhone: '', // 移动电话
        refund: '', // 退款
        invoice: '', // 发票号码
        invoiceCode: '', // 发票代码
        invoiceVerificationCode: '', // 发票验证码
        electronicsMail: '', // 电子邮箱
        region: '', // 地区
        invoiceMethod: '', // 开票方式
        operation: '', // 操作
        id: '', //
        paymenAamount: '', // 缴费金额
        unitMin: '', // 单位名称
        paymentVoucher: '', // 支付凭证
        auditStatus: '00' // 审核状态
      }],
      // 制作状态
      productionStatusOptions: [{
        value: '00',
        label: '未制作'
      }, {
        value: '01',
        label: '已制作'
      }],
      // 是否开取专票
      specialTicketOptions: [{
        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: '其他'
      }]

    }
  },
  computed: {
  },
  mounted() {
    // 分页初始化
    this.getData()
  },
  methods: {
    // 路径跳转
    auditBtn(id) { // 项目id//
      this.$router.push({
        path: '/caManage/paymentAuditDetail',
        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] // 开始日期
      }
    },
    // 初始化分页
    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()
    },
    // 搜索重置
    resetForm(formName) {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.applyDate = ''
      this.$refs[formName].resetFields()
      this.getData()
    }
  }
}
</script>

<style lang="less">

</style>
