<!--
  @description: 招标-招标文件列表/资审文件列表
  @Modifier: 肖文龙/haofengxian
  @routerPath:/bidding/bidDocFile-list
  @date: 2020/1/13-10:04
-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />{{ fileQualificationTitle }}列表
    </div>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
      </div>
      <div :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-width="98px"
            label-position="right"
          >
            <el-form-item ref="tenderNo" label="招标项目编号" prop="tenderNo">
              <el-input v-model.trim="searchForm.tenderNo" placeholder="招标项目编号" width="228px" />
            </el-form-item>
            <el-form-item ref="tenderName" label="招标项目名称" prop="tenderName">
              <el-input v-model.trim="searchForm.tenderName" placeholder="招标项目名称" width="228px" />
            </el-form-item>
            <el-form-item ref="title" label="文件名称" prop="title">
              <el-input v-model.trim="searchForm.title" placeholder="文件名称" width="228px" />
            </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">
        <span class="icon-line">查询结果</span>
      </div>
      <div>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <el-table-column
            header-align="center"
            prop="tenderNo"
            label="招标项目编号"
            width="160px"
          />
          <el-table-column

            header-align="center"
            prop="tenderName"
            label="招标项目名称"
          />
          <el-table-column

            header-align="center"
            prop="packNos"
            label="标段（包）编号"
          />
          <el-table-column
            :label="fileQualificationTitle"
            filter-placement="top-end"
            enterable

            header-align="center"
            prop="title"
          />
          <el-table-column
            header-align="center"
            label="创建时间"
            prop="createTime"
            align="center"
            width="140"
          />
          <el-table-column
            header-align="center"
            label="文件价格（元）"
            prop="documentPrice"
            align="right"
            width="120"
          />
          <el-table-column
            label="状态"
            prop="auditStatus"
            align="center"
            width="100"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.auditStatus!=='02' && scope.row.useStatus==='00'" class="status4">草稿</span>
              <span v-if="scope.row.auditStatus==='00'" class="status2">待审核</span>
              <span v-if="scope.row.auditStatus==='01'" class="status1">审核通过</span>
              <span v-if="scope.row.auditStatus==='02'" class="status3">审核不通过</span>
            </template>
          </el-table-column>
          <el-table-column
            header-align="center"
            label="操作"
            align="center"
            width="120"
          >
            <template slot-scope="scope">
              <el-link
                v-if="scope.row.useStatus!=='00'"
                type="primary"
                @click="examineBulletin(scope.row)"
              >
                [查看]
              </el-link>
              <template v-if="tenderDocAuditConfigType">
                <el-link
                  v-if="scope.row.auditStatus"
                  type="primary"
                  @click="handleDetail(scope.row.procfileId)"
                >
                  [流程追踪]
                </el-link>
              </template>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </div>
    </section>
    <!--流程追踪查看弹框-->
    <flow-detail-dialog ref="tracingFlow" />
  </div>
</template>

<script>
/* 接口*/
import { listTenderDocPages } from '@api/bidding/tenderDoc'
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { tenderDoc } from './../mixins/tenderDoc'// 文件类型字典信息
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import flowDetailDialog from '@views/work/process/flowDetail-dialog' //  流程追踪组件
export default {
  name: 'BidDocFileList',
  components: {
    pagination, // 分页
    flowDetailDialog
  },
  mixins: [ListMixin, tenderDoc],
  data() {
    return {
      tenderDocAuditConfigType: false, // true启动工作流 false普通审核
      loading: true,
      tableData: [],
      // 搜索
      searchForm: {
        fileQualificationType: '', // 00:资审文件 01:后审文件
        tenderName: '', // 项目名称
        tenderNo: '', // 项目编号
        title: '' // 文件名称
      }
    }
  },
  watch: {
    $route() {
      this.initBulletinType(this.$route.meta) // 字典信息区分-招标文件/资审文件方法
      this.loadData()
    }
  },
  created() {
    // 根据键获取正式配置
    this.$store.dispatch('getSystemConfigValue', 'tenderDoc-audit-config').then(() => {
      this.tenderDocAuditConfigType = this.$store.getters.systemConfigVo.configType // true启动工作流 false普通审核
    }).catch(() => {
    })
    this.initBulletinType(this.$route.meta) // 字典信息区分-招标文件/资审文件方法
    this.loadData()
  },
  methods: {
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      listTenderDocPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      this.searchForm.fileQualificationType = this.routerFileQualificationType
      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) {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.$refs[formName].resetFields()
      // 获取列表信息
      this.loadData()
    },
    // 查看文件--招标文件资审问了列表为公用页面-根据routerFileQualificationType判断查看跳转不同页面
    examineBulletin(row) {
      // 00 资审文件
      if (this.routerFileQualificationType === '00') {
        this.$router.push({
          path: '/bidding/tenderZswjDocInfoDetail',
          query: {
            backType: this.routerFileQualificationType, // 00 资审文件 01 招标文件
            procfileId: row.procfileId
          }
        })
      }
      // 01 招标文件
      if (this.routerFileQualificationType === '01') {
        this.$router.push({
          path: '/bidding/tenderDocInfoDetail',
          query: {
            backType: this.routerFileQualificationType, // 00 资审文件 01 招标文件
            procfileId: row.procfileId
          }
        })
      }
    },
    // 流程追踪详情
    handleDetail(id) {
      this.$refs.tracingFlow.openDialogInitData(id)
    }
  }
}
</script>

<style lang="less" scoped>

</style>
