<!--
  @description:招标-邀请函列表
  @Modifier: haoFx
  @routerPath: /bidding/tenderInvitation
  @date: 2020/1/5-15:08
-->
<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
            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="200"
          >
            <template slot-scope="scope">
              <el-link
                v-if="scope.row.useStatus !=='00'"
                type="primary"
                @click="examineInvitation(scope.row)"
              >
                [查看]
              </el-link>
              <el-link
                type="primary"
                @click="addSupplier(scope.row)"
              >
                [追加邀请人]
              </el-link>
              <template v-if="tenderInvitationAuditConfigType">
                <el-link
                  v-if="scope.row.auditStatus"
                  type="primary"
                  @click="handleDetail(scope.row.invitationId)"
                >
                  [流程追踪]
                </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 { listTenderInvitationPages } from '@/api/bidding/bidInvitation'// 邀请函列表
/* api*/
import { queryTenderProjectIsPack } from '@/api/bidding/biddingProject'
/* 公用方法*/
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 {
      tenderInvitationAuditConfigType: false, // true启动工作流 false普通审核
      loading: true,
      // 搜索
      searchForm: {
        tenderName: '', // 项目名称
        title: '' // 公告标题
      },
      tableData: []
    }
  },
  created() {
    // 根据键获取正式配置
    this.$store.dispatch('getSystemConfigValue', 'tenderInvitation-audit-config').then(() => {
      this.tenderInvitationAuditConfigType = this.$store.getters.systemConfigVo.configType // true启动工作流 false普通审核
    }).catch(() => {
    })
    // 获取列表信息
    this.loadData()
  },
  methods: {
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      listTenderInvitationPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
        this.$forceUpdate()
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 查看邀请函详情
    examineInvitation(row) {
      this.$router.push({
        path: '/bidding/tenderInvitationDetail',
        query: {
          id: row.tenderId, // 项目id
          invitationId: row.invitationId // 邀请函id
        }
      })
    },
    // 追加邀请人
    addSupplier(row) {
      this.getPack(row)
    },
    // 获取分标段不分标段状态
    getPack(row) {
      queryTenderProjectIsPack(row.tenderId).then(res => {
        const { isPack } = res.data // isPack 00 不分包 01 分包
        // 分包不分包邀请名单跳转不同页面
        if (isPack === '01') {
          this.$router.push({
            path: '/bidding/packageAppendSupplierInvitation',
            query: {
              invitationId: row.invitationId, // 邀请函id
              tenderId: row.id // 项目id
            }
          })
        } else {
          this.$router.push({
            path: '/bidding/noPackageAppendSupplierInvitation',
            query: {
              invitationId: row.invitationId // 邀请函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>
