<!--
  @description: 供应商信息
  @author: sunxinman
  @routerPath: /redisManagement/supplierRedisList
  @date: 2020-1-16 13:35
-->
<template>
  <div>
    <section class="title p0-16">
      <i class="iconfont icon-fanhui pointer" @click="back()" />
      供应商信息
    </section>
    <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-position="left"
          >
            <!--供应商名称-->
            <el-form-item ref="supplierName" label="供应商名称" prop="supplierName">
              <el-input v-model="searchForm.supplierName" placeholder="供应商名称" style="width: 220px" @keyup.enter.native="onSearch" />
            </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>
      <section>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <el-table-column
            prop="supplierName"
            label="供应商名称"
            min-width="260"
          />
          <el-table-column
            header-align="center"
            prop="linker"
            label="联系人"
            min-width="100"
          />
          <el-table-column
            header-align="center"
            prop="linkerTel"
            label="联系电话"
            min-width="75"
          />
          <el-table-column
            header-align="center"
            prop="bidTime"
            label="投标时间"
            width="130"
            align="center"
          >
            <template slot-scope="scope">
              {{ scope.row.bidTime && $Moment(scope.row.bidTime).format(momentDateTime) }}
            </template>
          </el-table-column>
          <el-table-column
            header-align="center"
            prop="bidStatus"
            label="投标状态"
            min-width="120"
            align="center"
          />
          <el-table-column
            header-align="center"
            label="投标方式"
            prop="submitBidWay"
            align="center"
            width="100"
          >
            <template slot-scope="scope">
              {{ scope.row.submitBidWay | filterSubmitBidWay }}
            </template>
          </el-table-column>
          <el-table-column
            header-align="center"
            label="操作"
            align="center"
            width="100"
          >
            <template slot-scope="scope">
              <el-link type="primary" @click="delRed(scope.row.detailId)">
                [清除redis]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="getBidSupplierRedisList" />
      </section>
    </section>
  </div>
</template>

<script>
import { listBidSupplierRedisResetByStageIdPages, delRedisBySupplierId } from '@/api/bidding/bid'
import { ListMixin } from '@/mixins/ListMixin'
import pagination from '@comp/common/pagination/pagination'
export default {
  name: 'SupplierRedisList',
  components: {
    pagination
  },
  filters: {
    filterSubmitBidWay(claimType) {
      const statusMap = {
        '00': '自主投标',
        '01': '补录投标'
      }
      return statusMap[claimType]
    }
  },
  mixins: [ListMixin],
  data() {
    return {
      loading: false,
      searchForm: {
        stageId: this.$route.params.stageId, // 阶段id
        supplierName: '' // 供应商名称
      },
      tableData: [{}]
    }
  },
  created() {
    this.getBidSupplierRedisList()
  },
  methods: {
    // 清除redis模块-根据阶段id获取供应商信息列表
    getBidSupplierRedisList() {
      listBidSupplierRedisResetByStageIdPages(this.searchForm).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
      })
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.getBidSupplierRedisList()
    },
    // 重置
    resetForm(formName) {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.$refs[formName].resetFields()
      // 获取列表信息
      this.getBidSupplierRedisList()
    },
    // 清除供应商redis
    delRed(bidId) {
      this.$confirm('是否清除该供应商redis？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        delRedisBySupplierId(bidId).then(res => {
          this.$message.success(res.header.msg)
        }).catch(() => {
        })
      }).catch(() => {
      })
    },
    // 返回
    back() {
      this.$router.push({
        name: 'packageRedis',
        params: {
          ...this.$route.params
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
  .margin{
    margin:8px 0;
  }
</style>
