<!--
  @description: 标书费管理
  @Modifier: sunxinman/haofengxian
  @routerPath: /fee/tenderFeeManage
  @date: 2020/03/19-17:20
-->
<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>
      <section :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-width="110px"
            label-position="left"
          >
            <!-- 招标项目编号 -->
            <el-form-item ref="tenderNo" label="招标项目编号" prop="tenderNo">
              <el-input v-model.trim="searchForm.tenderNo" placeholder="招标项目编号" style="width: 228px" />
            </el-form-item>
            <!-- 标段（包）名称 -->
            <el-form-item ref="packName" label="标段（包）名称" prop="packName">
              <el-input v-model.trim="searchForm.packName" placeholder="标段（包）名称" style="width: 228px" />
            </el-form-item>
            <!-- 项目经理 -->
            <el-form-item label="项目经理" prop="managerName">
              <el-input v-model.trim="searchForm.managerName" placeholder="项目经理" style="width: 228px" />
            </el-form-item>
            <!-- 业务部门 -->
            <el-form-item ref="department" label="业务部门" prop="department">
              <el-input v-model.trim="searchForm.department" placeholder="业务部门" style="width: 228px" />
            </el-form-item>
            <!-- 资格审查方式 -->
            <el-form-item label="资格审查方式" prop="qualificationMethod">
              <el-select
                v-model="searchForm.qualificationMethod"
                placeholder="请选择"
                style="width:228px"
              >
                <el-option
                  v-for="item in phaseTypeList"
                  :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>
      </section>
      <!--查询结果-->
      <div class="crud_menu_title">
        <span class="icon-line">查询结果</span>
      </div>
      <section>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <!-- 招标项目编号 -->
          <el-table-column
            prop="tenderNo"
            align="center"
            label="招标项目编号"
            width="160"
          />
          <!-- 标段（包）名称 -->
          <el-table-column

            header-align="center"
            label="标段（包）名称"
            prop="packName"
            align="left"
            min-width="260"
          />
          <!-- 项目经理 -->
          <el-table-column
            header-align="center"
            prop="managerName"
            label="项目经理"
            min-width="75"
          />
          <!-- 业务部门 -->
          <el-table-column
            header-align="center"
            prop="department"
            label="业务部门"
            min-width="200"
          />
          <!-- 资格审查方式 -->
          <el-table-column
            header-align="center"
            label="资格审查方式"
            prop="qualificationMethod"
            align="center"
            width="140"
          >
            <template slot-scope="scope">
              <span
                v-for="(item,index) in phaseTypeList"
                v-if="scope.row.qualificationMethod===item.typecode"
                :key="index"
              >{{ item.typename }}</span>
            </template>
          </el-table-column>
          <!-- 招标文件购买家数 -->
          <el-table-column
            header-align="center"
            label="招标文件购买家数"
            prop="buyDocumentNumber"
            align="right"
            width="140"
          />
          <el-table-column
            header-align="center"
            label="操作"
            align="center"
            width="140"
          >
            <template slot-scope="scope">
              <el-link
                type="primary"
                @click.stop="preview(scope.row)"
              >
                [查看文件购买记录]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </section>
    </section>
  </div>
</template>
<script>
/* 接口*/
import { queryAllChargingFileList } from '@api/fee/docfee'
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { TenderFeeGroupMixin } from '../mixins/tenderFeeGroupMixin'
import { ListMixin } from '@/mixins/ListMixin'
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页

export default {
  name: 'TenderFeeManageList',
  components: {
    pagination// 分页
  },
  mixins: [ListMixin, TenderFeeGroupMixin],
  data() {
    return {
      /* 字典信息-start */
      phaseTypeList: [], // 资格审查方式
      /* 字典信息-end */
      loading: true,
      // 搜索
      searchForm: {
        department: '', // 业务部门
        packName: '', // 标段名称
        managerName: '', // 项目经理
        qualificationMethod: '', // 资格审查方式 00资格预审,01 资格后审
        tenderName: '', // 项目名称
        tenderNo: '' // 项目编号
      },
      tableData: []
    }
  },
  created() {
    // 获取列表信息
    this.loadData()
    this.initGroup()// 获取字典方法
  },
  methods: {
    // 获取字典方法
    initGroup() {
      const data = [
        'phaseType' // 资格审查方式
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      queryAllChargingFileList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {

      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 查看文件购买记录
    preview(row) {
      this.$router.push({
        path: '/fee/docPurchaseRecord',
        name: 'DocPurchaseRecordList',
        params: {
          packId: row.packId
        }
      })
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.$refs[formName].resetFields()
      // 获取列表信息
      this.loadData()
    }
  }
}
</script>
<style lang="less" scoped>

</style>
