<!--
  @description:CA费用统计
  @Modifier:肖文龙
  @routerPath:/caManage/calculateExpenseList
  @date:2019-12-6 14:32:45
-->
<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="100px" prop="stage">
            <el-select v-model="searchForm.productionStatus" placeholder="请选择" style="width:240px">
              <el-option
                v-for="item in productionStatusOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="制作时间" label-width="100px" prop="applyStartDate">
            <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="100px" prop="paymentInstitution">
            <el-input v-model="searchForm.title" placeholder="项目名称" style="width:240px" />
          </el-form-item>
          <el-form-item label="是否开取专票" label-width="100px" prop="specialTicket">
            <el-select v-model="searchForm.specialTicket" placeholder="请选择" style="width:240px">
              <el-option v-for="item in specialTicketOptions" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="缴费时间" label-width="100px" 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="100px" 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-item label="开票时间" label-width="100px" 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="100px" prop="title">
            <el-input v-model="searchForm.agentMechanism" placeholder="代理机构" style="width:240px" />
          </el-form-item>
          <el-form-item label="项目编号" label-width="100px" prop="title">
            <el-input v-model="searchForm.itemNumber" placeholder="项目编号" style="width:240px" />
          </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>
      </div>
      <div class="derivedScore_div derivedScore_orange">
        合计CA办理费用：<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 type="index" label="序号" width="60" align="center" />
        <el-table-column prop="projectCode" min-width="100px" label="项目编号" />
        <el-table-column prop="serialNumber" min-width="70%" align="center" label="流水号" />
        <el-table-column prop="productionStatus" min-width="100%" label="制作状态">
          <template slot-scope="scope">
            <span v-if="scope.row.productionStatus==='00'">未制作</span>
            <span v-if="scope.row.productionStatus==='01'">已制作</span>
          </template>
        </el-table-column>
        <el-table-column prop="createDate" min-width="100%" label="制作时间" />
        <el-table-column prop="paymentInstitution" 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="invoiceRise" min-width="100%" label="发票抬头" />
        <el-table-column prop="specialTicket" min-width="200px" label="是否开取专票">
          <template slot-scope="scope">
            <span v-if="scope.row.specialTicket==='00'">否</span>
            <span v-if="scope.row.specialTicket==='01'">是</span>
          </template>
        </el-table-column>
        <el-table-column prop="paymenAamount" min-width="200px" label="缴费金额" />
        <el-table-column prop="purchaseQuantity" min-width="200px" label="购买数量" />
        <el-table-column prop="paymentMode" min-width="200px" label="支付方式">
          <template slot-scope="scope">
            <span v-if="scope.row.paymentMode==='00'">易支付</span>
            <span v-if="scope.row.paymentMode==='01'">支付宝</span>
          </template>
        </el-table-column>
        <el-table-column prop="PayData" min-width="200px" label="缴费时间" />
        <el-table-column prop="billingStatus" min-width="200px" label="开票状态">
          <template slot-scope="scope">
            <span v-if="scope.row.billingStatus==='00'">未开票</span>
            <span v-if="scope.row.billingStatus==='01'">已开票</span>
          </template>
        </el-table-column>
        <el-table-column prop="isrefund" min-width="200px" label="是否可以退款">
          <template slot-scope="scope">
            <span v-if="scope.row.isrefund==='00'">否</span>
            <span v-if="scope.row.isrefund==='01'">是</span>
          </template>
        </el-table-column>
        <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="invoice" min-width="200px" label="发票号码" />
        <el-table-column prop="invoiceCode" min-width="200px" label="发票代码" />
        <el-table-column prop="billingData" min-width="200px" label="开票时间" />
        <el-table-column prop="agency" min-width="200px" label="代理机构" />
        <el-table-column align="center" prop="title" min-width="100px" fixed="left" label="项目名称" />
      </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: 'CalculateExpenseList',
  components: {
    pagination
  },
  mixins: [ListMixin],
  data() {
    return {
      searchForm: {
        applyEndDate: '', // 发布结束日期
        applyStartDate: '', // 发布开始日期
        purchaseNo: '', // 采购项目编号
        purchaseType: '', // 采购方式
        stage: '', // 项目所处阶段
        title: '', // 采购项目名称
        auditStatus: '' // 审核状态
      },
      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: '' // 审核状态
        }
      ],
      applyDate: '', // 时间
      // 制作状态
      productionStatusOptions: [
        {
          value: '00',
          label: '未制作'
        },
        {
          value: '01',
          label: '已制作'
        }
      ],
      // 是否开取专票
      specialTicketOptions: [
        {
          value: '00',
          label: '否'
        },
        {
          value: '01',
          label: '是'
        }
      ],
      // 开票状态
      billingStatusOptions: [
        {
          value: '00',
          label: '未开票'
        },
        {
          value: '01',
          label: '已开票'
        }
      ]
    }
  },
  mounted() {
  //  获取列表
    this.getData()
  },
  methods: {
    // 时间转换
    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()
    },
    // 搜索重置
    resetForm(formName) {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.applyDate = ''
      this.$refs[formName].resetFields()
      this.getData(this.searchForm)
    }
  }
}
</script>

<style lang="less">

</style>
