<template>
  <div class="edit-add-detail">
    <div class="crumbs">
      <Breadcrumb
        :breadcrumbOpt="breadcrumbOpt"
        svg-name="#icon-audit"
        @breadcrumb-click="handleClose"
      />
    </div>
    <div class="common-page-shadow">
      <el-row class="common-table-container flex searchPanel">
        <el-col :span="24" class="common-table-wrapper">
          <div class="common-btn-group">
            <el-button
              :disabled="handleAddActive"
              size="small"
              icon="el-icon-circle-check"
              type="primary"
              :loading="adding"
              class="btn btn-plus"
              @click="handleAdd"
            >
              确认中标人
            </el-button>
          </div>
          <!-- LJ：表格高度自适应需配合样式  btn-pagenation 有按钮有分页  btngroup只有按钮  pagenation只有分页 -->
          <div class="common-table-content btn-pagenation">
            <el-table
              :border="true"
              stripe
              fit
              size="mini"
              v-loading="tableLoading"
              ref="multipleSelection"
              :data="tableData"
              @selection-change="handleSelectionChange"
            >
              <el-table-column type="selection" width="55" align="center">
              </el-table-column>
              <el-table-column
                type="index"
                width="55"
                align="center"
                label="序号"
              >
              </el-table-column>
              <el-table-column
                prop="quotationCompanyName"
                min-width="20%"
                label="企业名称"
                align="center"
                resizable
              >
              </el-table-column>
              <el-table-column
                prop="totalPrice"
                show-overflow-tooltip
                min-width="20%"
                align="center"
                label="报价"
                resizable
              >
              </el-table-column>
              <el-table-column
                prop="totalScore"
                show-overflow-tooltip
                min-width="15%"
                align="center"
                label="得分"
                resizable
              >
              </el-table-column>
              <el-table-column
                prop="rank"
                show-overflow-tooltip
                min-width="15%"
                align="center"
                label="排名"
                resizable
              >
              </el-table-column>
               <el-table-column
                prop="isSel"
                show-overflow-tooltip
                min-width="15%"
                align="center"
                label="中标状态"
                resizable
              >
              <template slot-scope="scope">
                 <span v-if="scope.row.isSel==0">未中标</span>
                 <span v-if="scope.row.isSel==1">已中标</span>
              </template>
              </el-table-column>
              <el-table-column min-width="10%" align="center" label="操作">
                <template v-slot="{row}">
                  <template>
                    <el-button
                      type="primary"
                      plain
                      size="small"
                      @click="quoteBtn(row)"
                      >评标详情</el-button
                    >
                  </template>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <div class="common-pagenation">
            <el-pagination
              ref="paginationPanel"
              background
              :current-page="queryParam.pageBean.page"
              :page-sizes="[20, 30, 40, 50]"
              :page-size="queryParam.pageBean.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="queryParam.pageBean.total"
            >
            </el-pagination>
          </div>
        </el-col>
      </el-row>
    </div>
    <!-- 中标弹层 -->
    <!-- <el-dialog
      :close-on-click-modal="false"
      title="中标原因"
      :close-on-press-escape="false"
      :visible.sync="showTroubleshooting"
      width="50%"
      :before-close="winningBidder"
      top="10vh"
    >
      <el-form
        justify="left"
        label-width="auto"
        label-position="right"
        :model="markerFlowValue"
        class="demo-form-inline"
      >
        <el-form-item label="中标原因">
          <el-input
            type="textarea"
            size="small"
            v-model="markerFlowValue.name"
            placeholder="请输入中标原因"
            clearable
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="winningBidder">取消</el-button>
        <el-button size="small" type="primary" @click="handleSave"
          >保 存</el-button
        >
      </span>
    </el-dialog> -->
  </div>
</template>

<script>
import Breadcrumb from '@/components/Breadcrumb/index.vue'
export default {
  name: 'domesticDialog',
  components: {Breadcrumb},
  props: {
    editData: Object
  },
  data() {
    return {
      showTroubleshooting: false,
      markerFlowValue: {},
      handleAddActive: true,
      breadcrumbOpt: [
        {breadcrumbName: '物资采购'},
        {breadcrumbName: '评标确认'}
      ],
      tableData: [],
      selectList:[],
      form:{},
      adding:false,
      tableLoading: false,
      queryParam: {
        pageBean: {
          page: 1,
          pageSize: 20,
          total: 0
        }
      },
    }
  },
  created() {
    let noticeId =  this.$route.params.id
    this.loadData(noticeId)
  },
  mounted() {
    
  },
  methods: {
    //中标保存
    handleSave() {
      this.showTroubleshooting = false
      this.markerFlowValue = ''
    },
    //取消确认中标
    winningBidder() {
      this.showTroubleshooting = false
      this.markerFlowValue = ''
    },
    //确认中标人
    handleAdd() {
      let form = {}
      this.adding = true
      this.selectList.forEach(item=>{
        form = item
      })
      this.$http.post('${portal}/calibration/v1/saveByCalibra',form).then(res=>{
        if(res.data.state){
          this.$message.success(res.data.message)
        }
        this.adding = false
      })
      // this.showTroubleshooting = true
    },
    //表格多选
    handleSelectionChange(val) {
      this.selectList = val
      if (val.length === 0) {
        this.handleAddActive = true
      } else {
        this.handleAddActive = false
      }
    },
    //查看报价
    quoteBtn(rows) {
      rows.evaluationTemplateId   = this.$route.query.editRows.evaluationTemplateId
      this.$router.push({
        name: 'materialProcurementBid',
        query: {editRows: rows}
      })
    },
    //
    loadData(id) {
      this.$http.post('${portal}/bizBiddingQuotation/v1/evaOrgRankData?noticeId='+id).then(res=>{
        if(res.data.state){
          this.tableData = res.data.value
        }
      })
    },
    // 关闭//面包屑点击
    handleClose() {
      this.$router.push({
        name: 'calibration',
        params: {
          tabsActiveName: 'materialProcurement',
          pageBean: this.$route.query.pageBean
        }
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.common-page-shadow {
  width: 100%;
  height: calc(100% - 40px);
  box-sizing: border-box;
  margin-top: 10px;
  .common-search-container {
    height: 80px;
    div {
      display: flex;
      align-items: center;
    }
  }
  .common-table-container{
    height: calc(100% - 10px);
  }
}

.rows {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ebebeb;
  margin-bottom: 16px;
  padding: 10px 0;
  .rows-left {
    margin-right: 10px;
    .rows-hr {
      width: 3px;
      height: 18px;
      background-color: #0e6eff;
      border-radius: 2px;
    }
  }
  .rows-title {
    .text-overflow {
      width: 100%;
      font-size: 16px;
    }
  }
}
</style>
