<!--
  @description:招标公告列表/资审公告列表
  @Modifier: haoFx
  @routerPath: /bidding/tenderBulletin
              /bidding/tenderInformationBulletin
  @date: 2020/1/5-15:08
-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />
      {{ bulletinTitle }}列表
    </div>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
      </div>
      <div class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-position="right"
          >
            <el-form-item ref="tenderNo" :label="bulletinTitle" prop="title">
              <el-input v-model.trim="searchForm.title" 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>
        </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
            :label="bulletinTitle"
            header-align="center"
            prop="title"
            min-width="230"
          />
          <el-table-column
            prop="bulletinPublishTime"
            align="center"
            label="发布时间"
            width="140"
          />
          <el-table-column
            header-align="center"
            prop="tenderName"
            label="招标项目名称"
            min-width="230"
          />
          <el-table-column
            header-align="center"
            label="包编号"
            prop="packNos"
            align="left"
            min-width="200"
          />
          <el-table-column
            header-align="center"
            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="操作"
            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="tenderBulletinAuditConfigType">
                <el-link
                  v-if="scope.row.auditStatus"
                  type="primary"
                  @click="handleDetail(scope.row.bulletinId)"
                >
                  [流程追踪]
                </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 { listTenderBulletinPages } from '@/api/bidding/bidBulletin'// 公告列表
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { tenderBulletinInitGroupMixin } from './../mixins/tenderBulletinInitGroupMixin'// 字典信息
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import flowDetailDialog from '@views/work/process/flowDetail-dialog' //  流程追踪组件
export default {
  name: 'BulletinAllList',
  components: {
    pagination, // 分页
    flowDetailDialog
  },
  mixins: [ListMixin, tenderBulletinInitGroupMixin],
  data() {
    return {
      tenderBulletinAuditConfigType: false, // true启动工作流 false普通审核
      loading: true,
      // 搜索
      searchForm: {
        bulletinType: '', // 公告类型 招标公告 01, 资审公告 21
        tenderName: '', // 项目名称
        title: '' // 公告标题
      },
      tableData: []
    }
  },
  watch: {
    $route() {
      this.initBulletinType()// 字典信息区分-招标公告/资审公告方法
      this.resetForm('searchForm')
    }
  },
  created() {
    // 根据键获取正式配置
    this.$store.dispatch('getSystemConfigValue', 'tenderBulletin-audit-config').then(() => {
      this.tenderBulletinAuditConfigType = this.$store.getters.systemConfigVo.configType // true启动工作流 false普通审核
    }).catch(() => {
    })
    this.initBulletinType()// 字典信息区分-招标公告/资审公告方法
    // 获取列表信息
    this.loadData()
  },
  methods: {
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      listTenderBulletinPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
        this.$forceUpdate()
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      this.searchForm.bulletinType = this.bulletinType
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 查看公告
    examineBulletin(row) {
      // 同一个页面不同路由
      let path = ''
      if (this.bulletinType === '01') { // 招标公告
        path = '/bidding/tenderBulletinPdfDetail'
      } else if (this.bulletinType === '21') {
        path = '/bidding/tenderInformationBulletinDetail'// 资审公告
      }
      this.$router.push({
        path: path,
        query: {
          bulletinId: row.bulletinId
        }
      })
    },
    // 搜索
    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()
    },
    // 流程追踪详情
    handleDetail(id) {
      this.$refs.tracingFlow.openDialogInitData(id)
    }
  }
}
</script>

<style lang="less" scoped>

</style>
