<template>
<div class="bidingInfoDetailMenu">
  <h1>招投标公告详情</h1>
  <el-descriptions class="margin-top" title="公告基本信息" :column="2"  border>
    <el-descriptions-item label="标题" :span="2">{{this.dataList.infoTitle}}</el-descriptions-item>
    <el-descriptions-item label="一级公告类型" >
      {{getChangeType(this.dataList.infoType)}}<!--调用getChangeType方法-->
    </el-descriptions-item>
    <el-descriptions-item label="二级公告类型" >
      {{getChangeType1(this.dataList.infoTypeSegment)}}
    </el-descriptions-item>
    <el-descriptions-item label="项目所属地区" >
      {{this.dataList.areaProvince+this.dataList.areaCity+this.dataList.areaCountry}}
    </el-descriptions-item>
    <el-descriptions-item label="项目名称" >{{this.dataList.infoTitle}}</el-descriptions-item>
    <el-descriptions-item label="招标方式" >{{getChangeType2(this.dataList.biddingType)}}</el-descriptions-item>
    <el-descriptions-item label="招标预算" >{{this.dataList.bidWinnerAmount}}</el-descriptions-item>
    <el-descriptions-item label="发布时间" >{{this.dataList.infoPublishTime}}</el-descriptions-item>
    <el-descriptions-item label="投标开始至截止日期" >{{this.dataList.tenderBeginTime}}至{{this.dataList.tenderEndTime}}</el-descriptions-item>
    <el-descriptions-item label="标书开始至截止日期" >{{this.dataList.bidingAcquireTime}}至{{this.dataList.bidingEndTime}}</el-descriptions-item>
    <el-descriptions-item label="招标公司类型" ></el-descriptions-item>
<!--    <el-descriptions-item label="招标状态" >{{YMDHMS_daxiao(this.areaObj.tenderEndTime) > 0 ? "未截止":"已截止"}}</el-descriptions-item>-->
    <el-descriptions-item label="招标状态" ></el-descriptions-item>
  </el-descriptions>
    <el-descriptions class="margin-top" title="公告主题信息" :column="2"  border >
      <el-descriptions-item label="招标单位" >{{(this.dataList.zhaoBiaoUnitTempDtos!=null&&this.dataList.zhaoBiaoUnitTempDtos.length == 0) ? null:this.dataList.zhaoBiaoUnitTempDtos[0].zhaoBiaoUnit}}</el-descriptions-item>
      <el-descriptions-item label="招标单位联系人">{{(this.dataList.zhaoBiaoUnitTempDtos!=null&&this.dataList.zhaoBiaoUnitTempDtos.length == 0) ? null : this.dataList.zhaoBiaoUnitTempDtos[0].zhaoRelationName}}</el-descriptions-item>
      <el-descriptions-item label="招标单位联系电话">{{(this.dataList.zhaoBiaoUnitTempDtos!=null&&this.dataList.zhaoBiaoUnitTempDtos.length == 0) ? null : this.dataList.zhaoBiaoUnitTempDtos[0].zhaoRelationWay}}</el-descriptions-item>
      <el-descriptions-item label="代理单位" >{{(this.dataList.agentUnitTempDtos!=null&&this.dataList.agentUnitTempDtos.length == 0) ?  null: this.dataList.agentUnitTempDtos[0].agentUnit}}</el-descriptions-item>
      <el-descriptions-item label="代理单位联系人" >{{(this.dataList.agentUnitTempDtos!=null&&this.dataList.agentUnitTempDtos.length == 0) ?  null: this.dataList.agentUnitTempDtos[0].agentRelationName}}</el-descriptions-item>
      <el-descriptions-item label="代理单位联系方式" >{{(this.dataList.agentUnitTempDtos!=null&&this.dataList.agentUnitTempDtos.length == 0) ?  null: this.dataList.agentUnitTempDtos[0].agentRelationWay}}</el-descriptions-item>
      <el-descriptions-item label="联系地址" ></el-descriptions-item>
      <el-descriptions-item label="中标单位" >{{(this.dataList.zhongBiaoUnitTempDtos!=null&&this.dataList.zhongBiaoUnitTempDtos.length == 0) ?  null: this.dataList.zhongBiaoUnitTempDtos[0].zhongBiaoUnit}}</el-descriptions-item>
      <el-descriptions-item label="中标单位联系人" >{{(this.dataList.zhongBiaoUnitTempDtos!=null&&this.dataList.zhongBiaoUnitTempDtos.length == 0) ?  null: this.dataList.zhongBiaoUnitTempDtos[0].zhongRelationName}}</el-descriptions-item>
      <el-descriptions-item label="中标单位联系人电话" >{{(this.dataList.zhongBiaoUnitTempDtos!=null&&this.dataList.zhongBiaoUnitTempDtos.length == 0) ?  null: this.dataList.zhongBiaoUnitTempDtos[0].zhongRelationWay}}</el-descriptions-item>
      <el-descriptions-item label="中标合同开始时间" >
            <el-date-picker
              :disabled="contractInputVisible"
              v-model="form.contractStartTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="请输入合同开始时间">
            </el-date-picker>
      </el-descriptions-item>
      <el-descriptions-item label="中标合同结束时间" >
          <el-date-picker
            :disabled="contractInputVisible"
            v-model="form.contractEndTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请输入合同结束时间">
          </el-date-picker>
      </el-descriptions-item>
    </el-descriptions>

  <el-button type="primary" @click="contractEditHandle">编辑中标合同时间</el-button>
  <el-button type="primary" @click="contractSaveHandle">保存中标合同时间</el-button>
  <el-descriptions class="margin-top" title="产品信息" :column="5"  border>
    <el-descriptions-item label="产品" :span="5">
      <el-table
        :data="this.dataList.targetList"
        style="width: 100%" :header-cell-style="{'text-align':'center'}">
        <el-table-column
          prop="packetId"
          label="包号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="packetName"
          label="包名"
          width="180">
        </el-table-column>
        <el-table-column
          prop="name"
          label="标的物名称"
          width="180">
        </el-table-column>
        <el-table-column
          prop="brand"
          label="品牌"
          width="180">
        </el-table-column>
        <el-table-column
          prop="model"
          label="型号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="number"
          label="数量"
          width="180">
        </el-table-column>
        <el-table-column
          prop="price"
          label="单价"
          width="180">
        </el-table-column>
        <el-table-column
          prop="totalPrice"
          label="总价"
          width="180">
        </el-table-column>
      </el-table>
    </el-descriptions-item>
    <el-descriptions-item label="附件">
      <div v-for="(item,index) in this.dataList.infoNewFile">
        <a :href="item.infoFileUrl" target="_blank" class="buttonText" style="color: #00afff">
          {{ item.infoFileName}}</a>
      </div>

    </el-descriptions-item>
  </el-descriptions>
  <el-descriptions class="margin-top" title="公告详情信息"  border>
    <el-descriptions-item label="公告原文" >
      <el-button type="info" @click="openInfoDetail">原文</el-button>
    </el-descriptions-item>
  </el-descriptions>
  <el-row type="flex" justify="end">
    <el-col :span="2">
      <el-button type="primary" @click="returnPage">返回</el-button>
    </el-col>
  </el-row>

  <el-dialog
    :visible.sync="dialogVisible"
    v-if="dialogVisible"
    width="100%"
    :before-close="handleClose"
    :modal="false"
    fullscreen
  >
    <Detail :detailId="this.detailId" @change="costPlannedAmountChange($event)"></Detail>
  </el-dialog>

</div>
</template>
<script>

import {QueryById, updateContractTime} from "@/api/business/bid/biding";

export default {
  name: "bidingInfoDetailMenu",
  components:{
    Detail : () => import("@/views/business/bid/detail/detail.vue"),
  },
  props:{
    lastData:{
      type: [String,Number]
    },
  },
  created() {
    this.getDetail(this.lastData)
  },
  data() {
    return {
      detailId:'',
      returnPageQueryParam:'',
      contractStartTime:'',
      contractEndTime:'',
      contractInputVisible:true,
      dialogVisible:false,
      dataList:{},
      areaObj:'',
      form:{
        id:'',
        contractStartTime:'',
        contractEndTime:'',
      },
      bidType: [
        {
          value: '0',
          label: '公开招标'
        },
        {
          value: '4',
          label: '询比价'
        },
        {
          value: '2',
          label: '竞价'
        },
        {
          value: '1',
          label: '邀请招标'
        },
        {
          value: '3',
          label: '定点采购'
        },
        {
          value: '5',
          label: '公开寻源'
        },
        {
          value: '6',
          label: '电子反拍'
        }
      ],
      noticeTwoType: [
        {
          value: '1',
          label: '采购意向'
        },
        {
          value: '2',
          label: '招投标'
        },
        {
          value: '3',
          label: '招标'
        },
        {
          value: '5',
          label: '变更公告'
        },
        {
          value: '10',
          label: '中标候选人'
        },
        {
          value: '11',
          label: '中标结果'
        },
        {
          value: '12',
          label: '合同'
        },
        {
          value: '13',
          label: '验收公告'
        },
      ],
      noticeOneType:[
        {
          value: '0',
          label: '公告'
        },
        {
          value: '1',
          label: '预告'
        },
        {
          value: '2',
          label: '变更'
        },
        {
          value: '3',
          label: '结果'
        },
        {
          value: '5',
          label: '其他'
        }
      ],
    };
  },

  methods:{
    async costPlannedAmountChange(value){
      this.dialogVisible=value
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },
    contractEditHandle(){
      this.contractInputVisible=false
    },
    contractSaveHandle(){
      updateContractTime(this.form).then(res =>{
        if(200==res.code){
          this.contractInputVisible=true
          this.$modal.msgSuccess("修改成功");
        }else {
          this.$modal.alertError("修改失败");
        }
      })
    },
    goToBasic(){
      this.$router.push({path:'/business/bid/detail',query:{id:this.dataList.infoId}});
    },

    openInfoDetail(){
      this.detailId=this.dataList.infoId
      this.dialogVisible=true
    },
    getDetail(val){
      QueryById(val).then(res =>{
        if(res.code == 200){
          this.dataList=res.data
          this.form.contractStartTime=this.dataList.zhongBiaoUnitTempDtos[0].contractStartTime
          this.form.contractEndTime=this.dataList.zhongBiaoUnitTempDtos[0].contractEndTime
          this.form.id= this.dataList.zhongBiaoUnitTempDtos[0].id
        }
      })
    },
    // YMDHMS_daxiao(str1) {
    //   str1 = new Date(str1).getTime();
    //   // 小于0则str1时间小，大于0则str1时间大
    //   return str1 - new Date().getTime();
    // },
    returnPage(){
      this.$emit('change', false);
    },
    getChangeType(e) {
      for (var i = 0; i < this.noticeOneType.length; i++) {
        if (this.noticeOneType[i].value === e) {
          return this.noticeOneType[i].label;
        }
      }
    },
    getChangeType1(e) {
      for (var i = 0; i < this.noticeTwoType.length; i++) {
        if (this.noticeTwoType[i].value === e) {
          return this.noticeTwoType[i].label;
        }
      }
    },
    getChangeType2(e) {
      for (var i = 0; i < this.bidType.length; i++) {
        if (this.bidType[i].value === e) {
          return this.bidType[i].label;
        }
      }
    },
  }
}
</script>
<style lang="scss" scoped>
.bidingInfoDetailMenu{
  margin: 10px;
}
</style>
