<!--
 * @description: 老平台发票
 * @author: tangQing
 * @date: 2023-01-06
!-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />老平台发票
    </div>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
        <span class="fr pointer" @click="handleToggleSearch">
          <el-link
            :underline="false"
            :class="toggleSearchStatus?'arrow-is-active':''"
            type="primary"
            class="toggleSearchStatus icon el-icon-arrow-down"
          />
          {{ toggleSearchStatus?'收起高级查询' :'展开高级查询' }}
        </span>
      </div>
      <div :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-width="100px"
            label-position="left"
          >
            <!-- 项目名称 -->
            <el-form-item ref="projectName" label="项目名称" prop="projectName">
              <el-input
                v-model.trim="searchForm.projectName"
                placeholder="项目名称"
                style="width:220px"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!-- 机构名称 -->
            <el-form-item ref="departInfoName" label="机构名称" prop="departInfoName">
              <el-input
                v-model.trim="searchForm.departInfoName"
                placeholder="机构名称"
                style="width:220px"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!-- <el-form-item label="开票状态" prop="invoiceStatus">
              <el-select v-model="searchForm.invoiceStatus" placeholder="请选择" style="width: 220px">
                <el-option
                  v-for="item in invoiceStatusList"
                  :key="item.typecode"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item> -->
          </el-form>
        </div>
        <div class="fr">
          <el-button type="primary" @click="onSearch">
            搜 索
          </el-button>
          <el-button plain type="info" @click="resetForm('searchForm')">
            重 置
          </el-button>
        </div>
      </div>
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询结果</span>
      </div>
      <div>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
          class="tableLimit"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <el-table-column
            prop="projectName"
            align="center"
            label="项目名称"
            min-width="100"
          />
          <el-table-column
            prop="departInfoName"
            align="center"
            label="机构名称"
            min-width="100"
          />
          <!-- <el-table-column
            prop="invoiceStatus"
            align="center"
            label="开票状态"
            min-width="100"
          >
            <template slot-scope="scope">
              {{ filterDictText(invoiceStatusList, scope.row.invoiceStatus) }}
            </template>
          </el-table-column> -->
          <el-table-column
            label="文件"
            align="center"
            prop="attachmenttitle"
          >
            <template slot-scope="score">
              <div style="color:#007CCC; cursor: pointer;" @click.stop="getFile( score.row.departInfoName,score.row.invoiceAttachment)">
                <span> <i class="iconfont icon-downloadRecord archived" />   {{ score.row.departInfoName }}</span>
              </div>
            </template>
          </el-table-column>
        </el-table>

        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </div>
    </section>
  </div>
</template>
<script>
/* 接口*/
import { getOldBidServiceFeeInvoiceList } from '@/api/bidService/bidServiceStatistics.js'// 项目列表
/* 公用方法*/
import { filterObj, filterDictText, restoreInitialValue } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* api */
import { downLoadFileByPath } from '@/api/common/uploadCenter'
import { download } from '@/assets/js/utils'// 常用方法
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
export default {
  name: 'TenderProjectList',
  components: {
    pagination // 分页

  },
  mixins: [ListMixin],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        projectName: '', // 项目名称
        departInfoName: '' // 机构名称
        // invoiceStatus: '' // 开票状态
      },
      invoiceStatusList: [
        { typename: '未开票', typecode: '00' },
        { typename: '已开票', typecode: '01' }
      ], // 支付方式数据字典
      tableData: []
    }
  },
  created() {
    sessionStorage.clear()
    // 获取列表信息
    this.loadData()
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      getOldBidServiceFeeInvoiceList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.tableData.forEach(element => {

        })
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 下载文件
    getFile(attachmenttitle, realpath) {
      var params = {
        realpath: realpath,
        attachmenttitle: attachmenttitle,
        extend: 'pdf'
      }
      downLoadFileByPath(params).then(res => {
        download(res, attachmenttitle + '.pdf')
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      restoreInitialValue(this.searchForm)
      // 获取列表信息
      this.onSearch()
    }

  }
}
</script>
<style lang="less" scoped>

</style>
