<template>
  <div class="app-container">
    <!--顶栏结构-->
    <el-card>
      <!--<el-radio v-model="radio" label="1">未收回</el-radio>-->
      <!--<el-radio v-model="radio" label="2">已收回</el-radio>-->
      <span style="margin-left: 10px">招标企业：</span>
      <el-input v-model="TenderingEnterprise" clearable size="small" style="width:140px" placeholder="请输入招标企业"/>
      <span style="margin-left: 20px">保金类型：</span>
      <el-select v-model="TypeOfGoldDepositValue" clearable filterable placeholder="请选择" size="small" style="margin-left: 10px;width: 100px">
        <el-option
          v-for="item in TypeOfGoldDeposit"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <span style="margin-left: 10px">投标人：</span>
      <el-input v-model="Bidder" clearable size="small" style="width:100px" placeholder="请选择" readonly @dblclick.native="dialogFormVisiblePeople = true;flag2 = 1" @clear="clear()"/>
      <span style="margin-left: 10px">开始日期：</span>
      <el-date-picker
        v-model="startTime"
        style="width: 200px;"
        value-format="yyyy-MM-dd"
        size="small"
        type="date"
        placeholder="请选择开始日期"/>
      <span style="margin-left: 10px">结束日期：</span>
      <el-date-picker
        v-model="endTime"
        style="width: 200px;"
        value-format="yyyy-MM-dd"
        size="small"
        type="date"
        placeholder="请选择结束日期"/>
      <el-button type="success" icon="el-icon-search" size="small" style="margin-left: 10px" @click="PageSize = 10;PageCurrent = 1;fetchTableData1()">查询</el-button>
      <el-button type="primary" icon="el-icon-circle-plus-outline" size="small" style="margin-left: 10px;margin-right: 15px" @click="addBidBond();flag1 = 2">增加</el-button>
    </el-card>

    <!--投标保证金表格-->
    <el-card>
      <el-table
        v-loading="tableData1Loading"
        :data="tableData1"
        style="width: 100%"
        height="600"
        border
        size="mini">
        <el-table-column align="center" label="投标结果" width="190">
          <template slot-scope="scope">
            <el-radio-group v-model="scope.row.投标结果" @change="changeTenderResult(scope.row)">
              <el-radio :disabled="scope.row.是否禁用已中标" label="1">已中标</el-radio>
              <el-radio :disabled="scope.row.是否禁用未中标" label="2">未中标</el-radio>
            </el-radio-group>
          </template>
        </el-table-column>
        <el-table-column align="center" label="公布日期" width="100">
          <template slot-scope="scope">
            {{ !scope.row.公布日期 ? '未公布' : scope.row.公布日期.substring(0 , scope.row.公布日期.length - 8) }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="招标企业" width="180">
          <template slot-scope="scope">
            {{ scope.row.招标企业 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="联系人" width="100">
          <template slot-scope="scope">
            {{ scope.row.联系人 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="联系电话" width="120">
          <template slot-scope="scope">
            {{ scope.row.联系电话 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="保证金金额" width="100">
          <template slot-scope="scope">
            <el-tag style="width: 80px" size="small">{{ scope.row.保证金金额 }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="中标服务费" width="100">
          <template slot-scope="scope">
            {{ scope.row.中标服务费 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="转履约保证金金额" width="150">
          <template slot-scope="scope">
            {{ scope.row.转履约保证金金额 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="应收回金额" width="100">
          <template slot-scope="scope">
            {{ scope.row.应收回金额 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="实收回金额" width="100">
          <template slot-scope="scope">
            <el-tag v-if="parseInt(scope.row.是否收回) === 2" size="small" type="success" style="width: 66px">{{ scope.row.应收回金额 }}</el-tag>
            <el-tag v-else slot="reference" type="danger" size="small" style="width: 66px">未收回</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="投标人" width="100">
          <template slot-scope="scope">
            {{ scope.row.投标人 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="保金类型" width="150">
          <template slot-scope="scope">
            {{ scope.row.保证金类型 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="投标日期" width="150">
          <template slot-scope="scope">
            {{ scope.row.投标日期.substring(0, scope.row.投标日期.length - 8) }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="计划收回日期" width="150">
          <template slot-scope="scope">
            {{ !scope.row.预计收回日期 ? '结果未公布' : scope.row.预计收回日期.substring(0, scope.row.预计收回日期.length - 8) }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="实际收回日期" width="150">
          <template slot-scope="scope">
            {{ !scope.row.实际收回日期 ? '未收回' : scope.row.实际收回日期.substring(0, scope.row.实际收回日期.length - 8) }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="状态" width="120">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.预计收回日期===''||scope.row.预计收回日期===null" slot="reference" size="small" style="width: 66px">未公布</el-tag>
            <el-tag v-else-if="scope.row.预计收回日期!==''&&scope.row.预计收回日期!==null&&parseInt(scope.row.是否收回)===2" slot="reference" type="success" size="small" style="width: 66px">已收回</el-tag>
            <el-tag v-else-if="scope.row.预计收回日期!==''&&scope.row.预计收回日期!==null&&parseInt(scope.row.状态) ===0" slot="reference" type="primary" size="small" style="width: 66px">未开始</el-tag>
            <el-tag v-else-if="scope.row.预计收回日期!==''&&scope.row.预计收回日期!==null&&parseInt(scope.row.状态) ===1" slot="reference" type="warning" size="small" style="width: 66px">即将拖期</el-tag>
            <el-tag v-else-if="scope.row.预计收回日期!==''&&scope.row.预计收回日期!==null&&parseInt(scope.row.状态) ===2" slot="reference" type="danger" size="small" style="width: 66px">已拖期</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="备注">
          <template slot-scope="scope">
            {{ scope.row.备注 }}
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" align="center" width="400">
          <template slot-scope="scope">
            <el-button
              :disabled="scope.row.是否禁用"
              size="mini"
              type="success"
              icon="el-icon-edit"
              @click.stop="TakeBack(scope.row);flag1 = 1">收回</el-button>
            <el-button
              :disabled="scope.row.是否禁用履约"
              size="mini"
              type="info"
              icon="el-icon-edit"
              @click.stop="ComplianceGold(scope.row)">履约</el-button>
            <el-button
              :disabled="scope.row.是否禁用编辑"
              size="mini"
              type="primary"
              icon="el-icon-edit"
              @click.stop="editBidBond(scope.row);flag1 = 3">编辑</el-button>
            <el-button
              :disabled="scope.row.是否禁用删除"
              size="mini"
              type="danger"
              icon="el-icon-delete"
              @click.stop="delBidBond(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="PageCurrent"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="PageSize"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
    </el-card>

    <el-dialog :visible.sync="dialogFormVisiblePeople" title="人员信息" center width="750px">
      <div style="height: 420px">
        <div style="float: left;margin-top: 10px;margin-left: 20px;overflow-y: scroll;height: 400px">
          <el-tree
            :data="dataPeople"
            node-key="id"
            style="width: 150px;float: left"
            height="400"
            accordion
            @node-click="handleNodeClick"
          />
        </div>
        <el-table :data="ListPeople" highlight-current-row height="400" style="width: 400px;float: left;margin-left: 30px" @row-click="handleChange">
          <el-table-column label="考勤编号" align="center" >
            <template slot-scope="scope">
              {{ scope.row.考勤编号 }}
            </template>
          </el-table-column>
          <el-table-column label="姓名" align="center" >
            <template slot-scope="scope">
              {{ scope.row.姓名 }}
            </template>
          </el-table-column>
          <el-table-column label="性别" align="center">
            <template slot-scope="scope">
              {{ scope.row.性别 }}
            </template>
          </el-table-column>
          <el-table-column label="工作岗位" align="center">
            <template slot-scope="scope">
              {{ scope.row.岗位名称 }}
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-button style="margin-left: 260px" @click="offName">取消</el-button>
      <el-button type="primary" style="margin-top: 20px" @click="getName">确认</el-button>
    </el-dialog>

    <!--收回投标保证金-->
    <el-dialog :visible.sync="dialogFormVisible1" title="收回" center style="min-height: 300px" width="20%">
      <el-form ref="form1" :model="form1" :rules="rules1" label-position="left" label-width="110px" class="demo-ruleForm">
        <el-form-item label="实际收回日期" prop="收回日期">
          <el-date-picker
            v-model="form1.收回日期"
            style="width: 200px;"
            value-format="yyyy-MM-dd"
            size="small"
            type="date"
            placeholder="收回日期"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="callOff('form1')">取消</el-button>
        <el-button type="primary" @click="submit('form1')">确 定</el-button>
      </div>
    </el-dialog>

    <!--投标保证金对话框-->
    <el-dialog :title="title" :visible.sync="dialogFormVisible2" center style="min-height: 300px" width="40%">
      <el-form ref="form2" :model="form2" :rules="rules2" label-position="left" label-width="120px" class="demo-ruleForm">
        <el-row>
          <el-col :span="12">
            <el-form-item label="招标企业" prop="招标企业">
              <el-input v-model="form2.招标企业" size="small" placeholder="请输入招标企业" style="width: 200px;"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系人" prop="联系人">
              <el-input v-model="form2.联系人" size="small" placeholder="请输入联系人" style="width: 200px;"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="联系电话">
              <el-input v-model="form2.联系电话" size="small" placeholder="请输入联系电话" style="width: 200px;"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="保证金金额" prop="保证金金额">
              <el-input-number v-model="form2.保证金金额" :precision="2" :step="0.1" style="width: 200px" size="small"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="保证金类型" prop="保证金类型">
              <el-select v-model="form2.保证金类型" clearable filterable placeholder="请选择保证金类型" size="small" style="width: 200px;">
                <el-option
                  v-for="item in TypeOfGoldDeposit1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="投标人" prop="投标人">
              <el-input v-model="form2.投标人" size="small" placeholder="请输入投标人" style="width: 200px;" clearable readonly @dblclick.native="dialogFormVisiblePeople = true;flag2 = 2" @clear="clear()"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="投标日期" prop="投标日期">
              <el-date-picker
                v-model="form2.投标日期"
                style="width: 200px;"
                value-format="yyyy-MM-dd"
                size="small"
                type="date"
                placeholder="投标日期"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公布后X天收回" prop="提前X天提醒我">
              <el-input-number v-model="form2.提前X天提醒我" :step="1" style="width: 200px" size="small"/>
            </el-form-item>
          </el-col>
          <!--<el-col :span="12">-->
          <!--<el-form-item label="计划收回日期" prop="计划收回日期">-->
          <!--<el-date-picker-->
          <!--v-model="form2.计划收回日期"-->
          <!--style="width: 200px;"-->
          <!--value-format="yyyy-MM-dd"-->
          <!--size="small"-->
          <!--type="date"-->
          <!--placeholder="收回日期"/>-->
          <!--</el-form-item>-->
          <!--</el-col>-->
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="备注" prop="备注">
              <el-input v-model="form2.备注" size="small" placeholder="请输入备注" style="width: 560px;"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="callOff('form2')">取消</el-button>
        <el-button type="primary" @click="submit('form2')">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogTimeVisible" :show-close="false" :close-on-click-modal="false" title="请输入" center style="min-height: 300px" width="23%">
      <el-form ref="Timeform" :model="Timeform" :rules="TimeRules" label-width="150px">
        <el-form-item label="投标结果公布日期" prop="投标结果公布日期">
          <el-date-picker
            v-model="Timeform.投标结果公布日期"
            style="width: 200px;"
            value-format="yyyy-MM-dd"
            size="small"
            type="date"
            placeholder="请选择结果公布日期"/>
        </el-form-item>
        <el-form-item label="中标服务费" prop="中标服务费">
          <el-input-number :disabled="tenderResultDisabled" v-model="Timeform.中标服务费" :precision="2" :step="0.1" :max="tenderResultMax" style="width: 200px" size="small"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="callOffTime('Timeform')">取消</el-button>
        <el-button type="primary" @click="submitTime('Timeform')">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogPerformanceBondVisible" title="转履约保证金" center style="min-height: 300px" width="40%">
      <el-form ref="PerformanceBondform" :model="PerformanceBondform" :rules="PerformanceBondrules" label-position="left" label-width="120px" class="demo-ruleForm">
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目名称" prop="项目名称">
              <el-select v-model="PerformanceBondform.项目名称" filterable clearable placeholder="请选择项目名称" style="width: 560px" size="small">
                <el-option
                  v-for="item in entryName"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="保证金金额" prop="保证金金额">
              <el-input-number v-model="PerformanceBondform.保证金金额" :precision="2" :step="0.1" style="width: 200px" size="small"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="保证金类型" prop="保证金类型">
              <el-select v-model="PerformanceBondform.保证金类型" filterable placeholder="请选择保证金类型" style="width: 200px" size="small">
                <el-option
                  v-for="item in TypeOfGoldDeposit1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="收回条件" prop="收回条件">
              <el-select v-model="PerformanceBondform.收回条件" filterable placeholder="请选择收回条件" style="width: 200px" size="small">
                <el-option
                  v-for="item in plannedTime"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="截止时间(天)" prop="截止时间">
              <el-input-number v-model="PerformanceBondform.截止时间" placeholder="请输入截止时间" style="width: 200px" size="small"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="callOffPerformanceBondform('PerformanceBondform')">取消</el-button>
        <el-button type="primary" @click="submitPerformanceBondform('PerformanceBondform')">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import elInput from 'element-ui/packages/input'
import { initType, selectBidBond, getTree, tree, getTablePeople, TakeBack, addBidBond, editBidBond, delBidBond, winningBid, executionProgressID, intProject, submitPerformanceBond } from '@/api/MarketingCenter/BidBond'
export default {
  components: {
    elInput
  },
  data() {
    return {
      entryName: [],
      plannedTime: [],
      disabled: false,
      tenderResultDisabled: false,
      dialogPerformanceBondVisible: false, // 转履约保证金对话框
      BidBondCode: '',
      MoneyTypeCode: '',
      TypeOfGoldDeposit1: [],
      flag2: '',
      title: '',
      dialogFormVisible2: false,
      code: '',
      flag1: '',
      startTime: '',
      startTime_check: '',
      endTime: '',
      endTime_check: '',
      tableData1Loading: false,
      TypeOfGoldDepositValue: '', // 保证金类型
      TypeOfGoldDepositValue_check: '',
      TypeOfGoldDeposit: [], // 保证金类型数组
      Bidder: '', // 投标人,
      Bidder_check: '',
      TenderingEnterprise: '', // 招标企业
      TenderingEnterprise_check: '',
      time: [], // 时间区间
      radio: '',
      tableData1: [],
      tenderResultMax: null,
      PageSize: 10,
      PageCurrent: 1,
      total: null,
      dataPeople: [],
      dialogFormVisiblePeople: false,
      ListPeople: [],
      peopleid: '',
      peoplename: '',
      dialogFormVisible1: false,
      dialogTimeVisible: false,
      form1: {
        收回日期: ''
      },
      Timeform: {
        投标结果公布日期: '',
        中标服务费: ''
      },
      PerformanceBondform: {
        项目名称: '',
        保证金类型: 1,
        收回条件: 1,
        截止时间: 15,
        保证金金额: ''
      },
      form2: {
        招标企业: '',
        联系人: '',
        联系电话: '',
        保证金金额: '',
        保证金类型: 1,
        投标人: '',
        投标日期: '',
        计划收回日期: '',
        提前X天提醒我: 15,
        备注: ''
      },
      rules1: { // 表单验证规则
        收回日期: [{ required: true, message: '请输入收回日期', trigger: 'change' }]
      },
      PerformanceBondrules: { // 表单验证规则
        项目名称: [{ required: true, message: '请选择项目', trigger: 'change' }],
        保证金类型: [{ required: true, message: '请选择保证金类型', trigger: 'change' }],
        收回条件: [{ required: true, message: '请选择收回条件', trigger: 'change' }],
        截止时间: [{ required: true, message: '请选择截止日期', trigger: 'change' }],
        保证金金额: [{ required: true, message: '请输入保证金金额', trigger: 'change' }]
      },
      TimeRules: { // 表单验证规则
        投标结果公布日期: [{ required: true, message: '请选择投标结果公布日期', trigger: 'change' }],
        中标服务费: [{ required: true, message: '请输入中标服务费', trigger: 'change' }]
      },
      rules2: { // 表单验证规则
        招标企业: [{ required: true, message: '请输入招标企业', trigger: 'blur' }],
        联系人: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
        联系电话: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
        保证金金额: [{ required: true, message: '请输入保证金金额', trigger: 'blur' }],
        保证金类型: [{ required: true, message: '请输入保证金类型', trigger: 'change' }],
        投标人: [{ required: true, message: '请输入投标人', trigger: 'change' }],
        投标日期: [{ required: true, message: '请选择收回日期', trigger: 'change' }],
        计划收回日期: [{ required: true, message: '请选择计划收回日期', trigger: 'change' }],
        提前X天提醒我: [{ required: true, message: '提前X天提醒我', trigger: 'blur' }]
      }
    }
  },
  created() {
    this.init()
    this.fetchTableData1()
  },
  methods: {
    init() {
      this.getSelect(initType, ['保证金类型', '保证金类型流水号'], 'TypeOfGoldDeposit')
      this.getSelect(initType, ['保证金类型', '保证金类型流水号'], 'TypeOfGoldDeposit1')
      this.getSelect(executionProgressID, ['执行进度名', '执行进度ID'], 'plannedTime')
      this.getSelect(intProject, ['项目名称', '项目流水号'], 'entryName')
      getTree().then(response => { // 获取人员信息树
        const data = response.data
        this.dataPeople = tree(data, 0)
      })
    },
    fetchTableData1() {
      if (this.TypeOfGoldDepositValue === '' || this.TypeOfGoldDepositValue == null) {
        this.TypeOfGoldDepositValue_check = 0
      } else {
        this.TypeOfGoldDepositValue_check = 1
      }
      if (this.Bidder === '' || this.Bidder == null) {
        this.Bidder_check = 0
      } else {
        this.Bidder_check = 1
      }
      if (this.TenderingEnterprise === '' || this.TenderingEnterprise == null) {
        this.TenderingEnterprise_check = 0
      } else {
        this.TenderingEnterprise_check = 1
      }
      if (this.startTime === '' || this.startTime == null) {
        this.startTime_check = 0
      } else {
        this.startTime_check = 1
      }
      if (this.endTime === '' || this.endTime == null) {
        this.endTime_check = 0
      } else {
        this.endTime_check = 1
      }
      this.tableData1Loading = true
      selectBidBond(this.TypeOfGoldDepositValue_check, this.TypeOfGoldDepositValue, this.Bidder_check, this.peopleid, this.TenderingEnterprise_check, this.TenderingEnterprise, this.startTime_check, this.startTime, this.endTime_check, this.endTime, this.PageCurrent, this.PageSize).then(response => {
        this.tableData1Loading = false
        const data = response.data.rows
        for (let i = 0; i < data.length; i++) {
          data[i].公布日期 === '' || data[i].公布日期 === null || parseInt(data[i].履约金) === 1 || parseInt(data[i].投标结果) === 2 || parseInt(data[i].是否收回) === 2 ? data[i].是否禁用履约 = true : data[i].是否禁用履约 = false
          parseInt(data[i].是否收回) === 2 ? data[i].是否禁用编辑 = true : data[i].是否禁用编辑 = false
          parseInt(data[i].是否收回) === 2 ? data[i].是否禁用删除 = true : data[i].是否禁用删除 = false
          data[i].公布日期 === '' || data[i].公布日期 === null || parseInt(data[i].是否收回) === 2 ? data[i].是否禁用 = true : data[i].是否禁用 = false
          if (data[i].投标结果 === '1') {
            data[i].是否禁用已中标 = false
            data[i].是否禁用未中标 = true
          } else if (data[i].投标结果 === '2') {
            data[i].是否禁用已中标 = true
            data[i].是否禁用未中标 = false
          } else {
            data[i].是否禁用已中标 = false
            data[i].是否禁用未中标 = false
          }
        }
        this.tableData1 = data
        this.total = response.data.total
      })
    },
    handleSizeChange(val) {
      this.PageCurrent = 1
      this.PageSize = val
      this.fetchTableData1()
    },
    handleCurrentChange(val) {
      this.PageCurrent = val
      this.fetchTableData1()
    },
    handleNodeClick(data) { // 树节点点击
      this.getData(getTablePeople, 'ListPeople', data.id)
    },
    handleChange(row) {
      this.peopleid = row.人员编号
      this.peoplename = row.姓名
    },
    getName() {
      this.dialogFormVisiblePeople = false
      if (this.flag2 === 1) {
        this.Bidder = this.peoplename
      } else {
        this.form2.投标人 = this.peoplename
      }
    },
    offName() {
      this.dialogFormVisiblePeople = false
      this.peopleid = ''
      this.peoplename = ''
    },
    TakeBack(row) {
      this.addForm('form1')
      this.dialogFormVisible1 = true
      this.code = row.招标保证金流水号
    },
    submitTakeBack() {
      TakeBack(this.code, this.form1.收回日期).then(response => {
        this.dialogFormVisible1 = false
        if (response.data[0].result === '1') {
          this.$message.success('信息更新成功')
          this.fetchTableData1()
        } else {
          this.$message.error('信息更新失败')
        }
      })
    },
    submit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.flag1 === 1) {
            this.submitTakeBack()
            this.flag1 = null
          } else if (this.flag1 === 2) {
            this.addTableData1()
            this.flag1 = null
          } else if (this.flag1 === 3) {
            this.editTableData1()
            this.flag1 = null
          }
        }
      })
    },
    callOff() {
      this.dialogFormVisible1 = false
      this.dialogFormVisible2 = false
    },
    ComplianceGold(row) {
      this.addForm('PerformanceBondform')
      this.code = row.招标保证金流水号
      this.dialogPerformanceBondVisible = true
      this.PerformanceBondform.保证金金额 = row.应收回金额
    },
    addBidBond() {
      this.addForm('form2')
      this.title = '增加'
      this.dialogFormVisible2 = true
    },
    addTableData1() {
      addBidBond(this.form2.招标企业, this.form2.联系人, this.form2.联系电话, this.form2.保证金金额, this.peopleid, this.form2.保证金类型, this.form2.投标日期, this.form2.备注, this.form2.提前X天提醒我).then(response => {
        if (response.data[0].result === '1') {
          this.$message.success('添加成功')
          this.title = ''
          this.dialogFormVisible2 = false
          this.fetchTableData1()
        } else {
          this.$message.error('添加失败,请检查金额于提醒天数是否为数字')
        }
      })
    },
    editBidBond(row) {
      this.editForm(row, 'form2')
      this.title = '编辑'
      this.dialogFormVisible2 = true
      this.form2.招标企业 = row.招标企业
      this.form2.联系人 = row.联系人
      this.form2.联系电话 = row.联系电话
      this.form2.保证金金额 = row.保证金金额
      this.form2.投标人 = row.投标人
      this.peopleid = row.人员流水号
      this.form2.保证金类型 = parseInt(row.保证金类型流水号)
      // this.MoneyTypeCode = row.保证金类型流水号
      this.form2.投标日期 = row.投标日期
      // this.form2.计划收回日期 = row.预计收回日期
      this.form2.备注 = row.备注
      this.form2.提前X天提醒我 = row.提前x天提醒
      this.BidBondCode = row.招标保证金流水号
    },
    editTableData1() {
      editBidBond(this.form2.招标企业, this.form2.联系人, this.form2.联系电话, this.form2.保证金金额, this.peopleid, this.form2.保证金类型, this.form2.投标日期, this.form2.备注, this.form2.提前X天提醒我, this.BidBondCode).then(response => {
        if (response.data[0].result === '1') {
          this.$message.success('编辑成功')
          this.title = ''
          this.dialogFormVisible2 = false
          this.fetchTableData1()
        } else {
          this.$message.error('编辑失败')
        }
      })
    },
    delBidBond(row) {
      function a() {
        this.fetchTableData1()
        this.dialogFormVisible2 = false
      }
      this.deleteRow(delBidBond, row.招标保证金流水号, a)
    },
    changeTenderResult(row) {
      this.code = row.招标保证金流水号
      this.tenderResultMax = row.应收回金额
      if (row.投标结果 === '1') {
        this.radio = '1'
        this.dialogTimeVisible = true
        this.tenderResultDisabled = false
      } else if (row.投标结果 === '2') {
        this.radio = '2'
        this.dialogTimeVisible = true
        this.tenderResultDisabled = true
      }
    },
    callOffTime() {
      this.dialogTimeVisible = false
      this.fetchTableData1()
    },
    submitTime() {
      winningBid(this.code, this.radio, this.Timeform.投标结果公布日期, this.Timeform.中标服务费).then(response => {
        if (response.data[0].result === '1') {
          this.fetchTableData1()
          this.dialogTimeVisible = false
          this.$message.success('操作成功')
        } else {
          this.$message.error('操作失败')
        }
      })
    },
    callOffPerformanceBondform() {
      this.dialogPerformanceBondVisible = false
    },
    submitPerformanceBondform(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          submitPerformanceBond(this.code, this.PerformanceBondform.项目名称, this.PerformanceBondform.保证金金额, this.PerformanceBondform.保证金类型, this.PerformanceBondform.收回条件, this.PerformanceBondform.截止时间).then(response => {
            if (response.data[0].result === '1') {
              this.fetchTableData1()
              this.dialogPerformanceBondVisible = false
              this.$message.success('操作成功')
            } else {
              this.$message.error('操作失败')
            }
          })
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
