<!--
  @description:中标结果公示列表
  @Modifier: 肖文龙
  @Modifier: hfx联调 2020/2/19-09:54
  @routerPath: /bidding/resultBulletin
  @date: 2020/2/7 9:43
-->
<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>
      </div>
      <div class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-position="right"
          >
            <el-form-item ref="title" label="中标结果公示" 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
            header-align="center"
            prop="title"
            label="中标结果公示"
            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
            label="状态"
            prop="auditStatus"
            align="center"
            width="100"
          >
            <template slot-scope="scope">
              <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
                type="primary"
                @click="examineBulletin(scope.row)"
              >
                [查看]
              </el-link>
              <template v-if="resultBulletinAuditConfigType">
                <el-link
                  v-if="scope.row.auditStatus"
                  type="primary"
                  @click="handleDetail(scope.row.id)"
                >
                  [流程追踪]
                </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 { getResultBulletinMadeListPages } from '@/api/bidding/bidCalibration'// 结果公示列表
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import flowDetailDialog from '@views/work/process/flowDetail-dialog' //  流程追踪组件
export default {
  name: 'BulletinAllList',
  components: {
    pagination, // 分页
    flowDetailDialog
  },
  mixins: [ListMixin],
  data() {
    return {
      resultBulletinAuditConfigType: false, // true启动工作流 false普通审核
      loading: true,
      // 搜索
      searchForm: {
        tenderName: '', // 项目名称
        title: '' // 公告标题
      },
      tableData: []
    }
  },
  created() {
    // 根据键获取正式配置
    this.$store.dispatch('getSystemConfigValue', 'resultBulletin-audit-config').then(() => {
      this.resultBulletinAuditConfigType = this.$store.getters.systemConfigVo.configType // true启动工作流 false普通审核
    }).catch(() => {
    })
    // 获取列表信息
    this.loadData()
  },
  methods: {
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      getResultBulletinMadeListPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 查看结果公示
    examineBulletin(row) {
      this.$router.push({
        path: '/bidding/resultBulletinDetail',
        query: {
          winBidResultBulletinId: row.id // 结果公示id
        }
      })
    },
    // 搜索
    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>
