<template>
  <div>
    <el-table
      :border="true"
      stripe
      fit
      size="mini"
      height="100%"
      ref="multipleSelection"
      :data="tableData"
    >
      <el-table-column type="index" width="55" align="center" label="序号">
      </el-table-column>
      <el-table-column
        prop="projectNumber"
        min-width="100px"
        label="项目编号"
        align="center"
        resizable
      >
        <template slot-scope="scope">
          <div v-if="scope.row.noticeType==1">
            {{ scope.row.projectNumber }}
          </div>
          <div v-else>
            {{ scope.row.noticeCode }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        prop="noticeTitle"
        show-overflow-tooltip
        min-width="130px"
        align="center"
        label="项目名称"
        resizable
      >
      </el-table-column>
      <el-table-column
        prop="procureOrgName"
        show-overflow-tooltip
        min-width="130px"
        align="center"
        label="采购单位"
        resizable
      >
      </el-table-column>
      <el-table-column
        prop="procureType"
        show-overflow-tooltip
        min-width="100px"
        align="center"
        label="采购类型"
        resizable
      >
        <template v-slot="{row}">
          <div v-if="row.procureType != 6">
            {{ getDictName('cglx-cglx', row.procureType) }}
          </div>
          <div v-else>谈判采购（多轮）</div>
        </template>
      </el-table-column>
      <el-table-column
        prop="biddingStartTime"
        show-overflow-tooltip
        min-width="130px"
        align="center"
        label="投标开始时间"
        resizable
      >
      </el-table-column>
      <el-table-column
        prop="biddingEndTime"
        show-overflow-tooltip
        min-width="130px"
        align="center"
        label="投标结束时间"
        resizable
      >
      </el-table-column>
      <el-table-column min-width="120px" align="center" label="操作">
        <template v-slot="{row}">
          <template>
            <el-button
              type="primary"
              plain
              icon="el-icon-view"
              size="small"
              @click="quoteConfirm(row)"
              >明细查看</el-button
            >
          </template>
        </template>
      </el-table-column>
    </el-table>
    <!-- 最低评标法 -->
    <materialEvaluationDialog ref="lowest"></materialEvaluationDialog>
    <!-- 综合评标法 -->
    <materialProcurementBid ref="composite"></materialProcurementBid>
    
  </div>
</template>
    
    <script>
import {helper} from '../../../public/hotent.helper.js'
import req from '@/request.js'
import basicData from '@/api/basicData'
import utils from '@/hotent-ui-util.js'
import utilData from '@/utils.js'
import materialEvaluationDialog from './components/materialEvaluationDialog.vue'
import materialProcurementBid from './components/materialProcurementBid.vue'
export default {
  components: {
    materialEvaluationDialog, //最低评标法
    materialProcurementBid  //综合评标法
  },
  data() {
    return {
      parameter: {},
      loading: false,
      tableData: [],
      saveFlag: true,
      currentNode: 1,
      activeName: 1,
      scoreData: [],
    }
  },
  mounted() {
    this.currentNode = this.$route.query.node
    window.saveData = this.saveData
    window.relationData = this.relationData
    this.id = utils.getUrlKey('id')
    this.node = utils.getUrlKey('node')
    if (this.id) {
      let params = {
        querys: [],
      }
      params.querys.push({
        group: 'main',
        operation: 'EQUAL',
        parentGroup: '',
        property: 'id',
        relation: 'AND',
        value: this.id,
      })
      req
        .post(window.context.portal + '/matApproval/v1/page', params)
        .then((res) => {
          if (res.data.state) {
            this.tableData = res.data.value.rows
          }
        })
    }
  },
  methods: {
    quoteConfirm(rows) {
      if (
        (rows.evaluationMethod == 1 || rows.evaluationMethod == 2) &&
        rows.evaluationMode == 1
      ) {
        this.$refs.lowest.open(rows)
      }
      if (rows.evaluationMethod == 2 && rows.evaluationMode == 2) {
        this.$refs.composite.open(rows)
      }
    },
    getDictName(code, value) {
      return utilData.getDictName(code, value)
    },
    /* 保存 */
    saveData() {
      if (this.saveFlag) {
        //如果是第一个节点他可以保存数据，否则不需要进行数据操作
        if (this.node == 1) {
          this.$http
            .post(
              '${portal}/matApproval/v1/modifyCalibraStatus?ids=' +
                this.tableData[0].id +
                '&status=1'
            )
            .then((res) => {
              console.log(res, '调用结果')
              if (res.data.state) {
                this.id = res.data.value
                let params = {
                  type: 'saveData',
                  state: true,
                  businessKey: this.id, // todo 确认id字段是否正确 用接口返回值做businessKey
                  sysCode: '',
                }
                params.vars = {
                  // props1: this.forms.props1,
                  //   noticeReleaseUserAccount: this.form.noticeReleaseUserAccount,
                }
                hotent.sendMessage(params)
                this.saveFlag = false
              }
            })
        } else {
          let params = {
            type: 'saveData',
            state: true,
            businessKey: this.id, // 流程地址参数id
            sysCode: '',
          }
          hotent.sendMessage(params)
          this.isFirst = false
        }
      } else {
        let params = {
          type: 'saveData',
          state: true,
          businessKey: this.id, // 流程地址参数id
          sysCode: '',
        }
        params.vars = {
          //   noticeReleaseUserAccount: this.form.noticeReleaseUserAccount,
        }
        hotent.sendMessage(params)
        this.isFirst = false
      }
      // }
    },
    relationData(data) {
      this.tableData = data
    },
  },
}
</script>
    
    <style lang="scss" scoped>
.form-content {
  overflow-x: hidden;
}
.rows:first-of-type {
  cursor: pointer;
}
.auto {
  display: none;
}
.classNone {
  display: block;
}
.form-flex {
  /deep/.el-form-item__content {
    display: flex;
    align-items: center;
  }
}
.append {
  width: 10%;
  background-color: #f5f7fa;
  color: #909399;
  vertical-align: middle;
  display: table-cell;
  position: relative;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  padding: 0 10px;
  white-space: nowrap;
  text-align: center;
}
</style>