<template>
  <div>
    <el-form :model="forminfo" :rules="rulesmb" ref="ruleForm1" label-width="130px" class="demo-ruleForm">
      <el-row :gutter="20">
        <el-col :span="12" >
          <el-form-item label="模版名称" prop="templateName">
            <el-input v-model="forminfo.templateName" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="word模板" prop="templateAttachment" :style="forminfo.templateAttachment?'width: 100%;':''">
            <upfile :accept="'.docx,.doc'" filePath="mb" inputtype="templateAttachment" :value="forminfo.templateAttachment"
              @changimg="e=>changimg(e,'templateAttachment')"></upfile>
             
          </el-form-item>
          <div v-if="!forminfo.templateAttachment" class="greens tableBtn iterem" @click.stop="openfile($baseURL+'/zsfwzxt/mb/fa0cc984-e1ac-474e-a579-89ea79cc9b8e-ces合同.docx')">模版文件</div>
        </el-col>
      </el-row>
    </el-form>
    <el-form :model="formInline" :rules="rulesHetong" ref="ruleForm" label-width="130px" class="demo-ruleForm">
      <TitleWithCircle title="合同信息" style="margin-left: 65px;margin-bottom: 30px;" />
      <el-row :gutter="20">
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="合同类型" prop="contractType" style="width: calc(100% - 35px)">
            <el-select v-model="formInline.contractType" placeholder="请选择" style="width: 100%;">
              <el-option label="商铺合同" value="商铺合同"></el-option>
              <el-option label="广告位合同" value="广告位合同"></el-option>
              <el-option label="场地合同" value="场地合同"></el-option>
            </el-select>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('合同类型')"></i>
        </el-col>
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="合同编号" prop="contractNumber" style="width: calc(100% - 35px)">
            <el-input v-model="formInline.contractNumber" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('合同编号')"></i>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="标段号" prop="sectionNumber" style="width: calc(100% - 35px)">
            <el-input v-model="formInline.sectionNumber" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('标段号')"></i>
        </el-col>
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="合同名称" prop="contractName" style="width: calc(100% - 35px)">
            <el-input v-model="formInline.contractName" placeholder="请输入" maxlength="50"></el-input>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('合同名称')"></i>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="合同签订日期" prop="contractSigningDate" style="width: calc(100% - 35px)">
            <el-date-picker v-model="formInline.contractSigningDate" type="date" value-format="yyyy-MM-dd"
              placeholder="选择日期" style="width: 100%;">
            </el-date-picker>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('合同签订日期')"></i>
        </el-col>
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="押金" prop="earnestMoney" style="width: calc(100% - 35px)">
            <el-input v-model="formInline.earnestMoney" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('押金')"></i>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="起租日期" prop="leaseStartDate" style="width: calc(100% - 35px)">
            <el-date-picker v-model="formInline.leaseStartDate" type="date" value-format="yyyy-MM-dd" placeholder="选择日期"
              style="width: 100%;">
            </el-date-picker>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('起租日期')"></i>
        </el-col>
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="终止日期" prop="contractTerminationDate" style="width: calc(100% - 35px)">
            <el-date-picker v-model="formInline.contractTerminationDate" type="date" value-format="yyyy-MM-dd"
              placeholder="选择日期" style="width: 100%;">
            </el-date-picker>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('终止日期')"></i>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="付款周期" prop="paymentCycle" style="width: calc(100% - 35px)">
            <el-select v-model="formInline.paymentCycle" placeholder="请选择" style="width: 100%;">
              <el-option label="按年" value="按年"></el-option>
              <el-option label="按月" value="按月"></el-option>
              <el-option label="按日" value="按日"></el-option>
              <el-option label="季度" value="季度"></el-option>
            </el-select>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('付款周期')"></i>
        </el-col>
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="租金" prop="contractAmount" style="width: calc(100% - 35px)">
            <el-input v-model="formInline.contractAmount" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('租金')"></i>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="付款日" prop="paymentDay" style="width: calc(100% - 35px)">
            <el-select v-model="formInline.paymentDay" placeholder="请选择" style="width: 100%;">
              <el-option :label="val+'号'" :value="val+'号'" v-for="val in 31"></el-option>
            </el-select>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('付款日')"></i>
        </el-col>
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="承租人银行账号" prop="tenantBankAccount" style="width: calc(100% - 35px)">
            <el-input v-model="formInline.tenantBankAccount" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('承租人银行账号')"></i>
        </el-col>
      </el-row>
      <!-- <el-form-item label="绑定商家" prop="relatedMerchants" >
        <el-select style="width: 100%;" v-model="formInline.relatedMerchants" placeholder="请输入关键词搜索" filterable
          @change="changeRelatedMerchants ">
          <el-option v-for="(item,index) in shopList" :key="index" :label="item.name+ ' ' + item.phone"
            :value="item.id+''" />
        </el-select>
      </el-form-item> -->
      <el-row :gutter="20">
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="承租人名称" prop="tenantName" style="width: calc(100% - 35px)">
            <el-input v-model="formInline.tenantName" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('承租人名称')"></i>
        </el-col>
        <el-col :span="12" style="display: flex;align-items: center;">
          <el-form-item label="联系电话" prop="tenantTelephone" style="width: calc(100% - 35px)">
            <el-input v-model="formInline.tenantTelephone" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
          <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit('联系电话')"></i>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="绑定资源" prop="shopNumber">
            <div style="border: 1px solid #E5E5E5;padding: 1px" id="huodong">
              <div
                style="font-size: 14px;border-bottom: 1px solid #E5E5E5;display: flex;justify-content: space-between;line-height:20px;background:#F2F3F5;">
                <div></div>
                <!-- @click="mingShow" -->
                <div v-if="AddData.length != 1" style="color: #3F9B6A;padding:10px;" >
                  添加
                </div>
              </div>
              <div style="padding: 15px;">
                <div style="padding: 0px 20px 0px 0px">
                  <el-table :data="[{}]"
                    :header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}">
                    <el-table-column label="序号">
                      <template slot-scope="scope">
                        {{scope.$index + 1}}

                      </template>
                    </el-table-column>
                    <el-table-column label="资源名称">
                      <template slot-scope="scope">
                        <div style="display: flex;">
                          <div>资源名称</div>
                          <i class="el-icon-copy-document greens tableBtn iterem" style="height: 0;" @click.stop="copytit('资源名称')"></i>
                        </div>
                      </template>
                    </el-table-column>
                    <el-table-column label="资源类型">
                      <template slot-scope="scope">
                        <div style="display: flex;">
                          <div>资源类型</div>
                          <i class="el-icon-copy-document greens tableBtn iterem" style="height: 0;" @click.stop="copytit('资源类型')"></i>
                        </div>
                      </template>
                    </el-table-column>

                    <el-table-column label="详细地址">
                      <template slot-scope="scope">
                        <div style="display: flex;">
                          <div>详细地址</div>
                          <i class="el-icon-copy-document greens tableBtn iterem" style="height: 0;" @click.stop="copytit('详细地址')"></i>
                        </div>
                      </template>
                    </el-table-column>

                    <el-table-column prop="notes" label="实际使用面积">
                      <template slot-scope="scope">
                        <div style="display: flex;">
                          <div>实际使用面积</div>
                          <i class="el-icon-copy-document greens tableBtn iterem" style="height: 0;" @click.stop="copytit('实际使用面积')"></i>
                        </div>
                      </template>

                    </el-table-column>
                    <!-- <el-table-column label="操作" min-width="15%">
                      <template slot-scope="scope">
                        <div @click="MingDelete(scope.$index)" class="tableBtn greens">删除</div>
                      </template>
                    </el-table-column> -->
                  </el-table>
                </div>
              </div>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <TitleWithCircle title="其他信息管理" style="margin-left: 65px;" />
    <div >
      <el-form style="margin-top: 20px;" ref="ruleForm" :rules="ruleAddData" label-width="130px" class="demo-ruleForm">
        <el-row :gutter="20">
          <el-col :span="item.width == '50%（半行）'?12:item.width == '100%（一行）'?24:12" v-for="(item,index) in AddData" style="display: flex;align-items: center;">
            <el-form-item :label="item.name" :prop="item.key" v-if="item.type == '单行文本'" style="width: calc(100% - 35px)">
              <el-input v-model="item.value" placeholder="请输入" :maxlength="item.length"></el-input>
            </el-form-item>
            <el-form-item :label="item.name" :prop="item.key" v-if="item.type == '多行文本'" style="width: calc(100% - 35px)">
              <el-input show-word-limit rows="4" v-model="item.value" placeholder="请输入" type="textarea" :maxlength="item.length"/>
            </el-form-item>
            <el-form-item :label="item.name" :prop="item.key" v-if="item.type == '日期'" style="width: calc(100% - 35px)">
              <el-date-picker v-model="item.value" type="date" value-format="yyyy-MM-dd" placeholder="选择日期" style="width: 100%;"></el-date-picker>
            </el-form-item>
            <i class="el-icon-copy-document greens tableBtn iterem" @click.stop="copytit(item.name)"></i>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div style="margin-left: 65px;">
      <el-button @click="mingShow()" style="background-color: #3F9B6A;color: #fff;">添加</el-button>
    </div>
    <div style="margin-top: 20px;margin-left: 65px;">
      <div style="padding: 0px 20px 0px 0px">
        <el-table :data="AddData"
          :header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}">
          <el-table-column label="字段排序">
            <template slot-scope="scope">
              {{scope.$index + 1}}
            </template>
          </el-table-column>
          <el-table-column prop="notes" label="字段名称">
            <template slot-scope="scope">
              {{scope.row.name?scope.row.name : '-'}}
            </template>
          </el-table-column>
          <el-table-column prop="notes" label="字段key">
            <template slot-scope="scope">
              {{scope.row.key?scope.row.key : '-'}}
            </template>
          </el-table-column>
          <el-table-column prop="notes" label="字段类型">
            <template slot-scope="scope">
              {{scope.row.type?scope.row.type : '-'}}
            </template>
          </el-table-column>
          <el-table-column prop="notes" label="是否必填">
            <template slot-scope="scope">
              {{scope.row.isrequired?scope.row.isrequired : '-'}}
            </template>
          </el-table-column>
          <el-table-column prop="notes" label="字段宽度">
            <template slot-scope="scope">
              {{scope.row.width?scope.row.width : '-'}}
            </template>
          </el-table-column>
          <el-table-column prop="notes" label="限制规则">
            <template slot-scope="scope">
              {{scope.row.length?scope.row.length : '-'}}
            </template>
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <div @click="MingDelete(scope.$index)" class="tableBtn greens">删除</div>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div v-if="info.id" style="margin-top: 20px;margin-left: 65px;">
      <el-button @click="close()" class="buttonHover"
        style="color: #606266;border: 1px solid #DBDBDB;background-color: #fff;">返回</el-button>
    </div>
    <div v-else style="margin-top: 20px;margin-left: 65px;">
      <el-button @click="add()" style="background-color: #3F9B6A;color: #fff;">确定</el-button>
      <el-button @click="close()" class="buttonHover"
        style="color: #606266;border: 1px solid #DBDBDB;background-color: #fff;">取消</el-button>
    </div>
    <el-dialog :visible.sync="addMing" title="添加" style="padding: 0;z-index: 9999999;" width="50%" append-to-body center
      :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false">
      <div v-if="addMing">
        <el-form :model="addmbitem" :rules="ruleaddmbitem" ref="addmbitem" label-width="130px" class="demo-ruleForm">
          <el-form-item label="字段名称" prop="name">
            <el-input v-model="addmbitem.name" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
          <el-form-item label="字段key" prop="key">
            <el-input v-model="addmbitem.key" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
          <el-form-item label="字段类型" prop="type">
            <el-select v-model="addmbitem.type" placeholder="请选择" style="width: 100%;">
              <el-option label="单行文本" value="单行文本"></el-option>
              <el-option label="多行文本" value="多行文本"></el-option>
              <el-option label="日期" value="日期"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="是否必填" prop="isrequired">
            <el-select v-model="addmbitem.isrequired" placeholder="请选择" style="width: 100%;">
              <el-option label="是" value="是"></el-option>
              <el-option label="否" value="否"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="字段宽度" prop="width">
            <el-select v-model="addmbitem.width" placeholder="请选择" style="width: 100%;">
              <el-option label="50%（半行）" value="50%（半行）"></el-option>
              <el-option label="100%（一行）" value="100%（一行）"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="限制规则" prop="length">
            <el-input v-model.number="addmbitem.length" placeholder="请输入" maxlength="20"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <template #footer>
        <div style="display: flex; justify-content: flex-end; align-items: center;">
          <el-button @click="minSev" style="background-color: #3F9B6A;color: #fff;">确定</el-button>
          <el-button @click="mingClose" class="buttonHover"
            style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;">取消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script>
  import {
    businessListGetAll,
  } from '@/api/business'
  import upimg from "@/components/ImageUpload/index"
  import TitleWithCircle from '@/components/top/index';
  import {
    uploadUrl
  } from '@/utils/request'
  import {
    getAlls,
    changAlls
  } from '@/api/information.js'
  import {
    getAlls as map1
  } from '@/api/map1.js'
  import {
    miniioupload
  } from '@/api/commodityLease.js'
  import {

    contractinsertAdd
  } from '@/api/manage.js'
  import {
    cerePlatformMerchant,
    cereContractTemplateadd
  } from '@/api/newly.js'
  import {
    msgedit
  } from '@/api/cereBusinessInfo'
  import {
    AdvertiserInfoEdit
  } from '@/api/advertisement.js'
  import upfile from "@/components/fujianUpload/fujianList"
import { copy } from '@/api/activityBz';
  export default {
    components: {
      upfile,
      upimg,
      TitleWithCircle
    },
    data() {
      return {
        rulesmb:{
          templateName: [{
            required: true,
            message: '请填写模版名称',
            trigger: 'change'
          }],
          templateAttachment: [{
            required: true,
            message: '请上传word模板',
            trigger: 'change'
          }],
        },
        forminfo:{
          templateName: '',       // 模板名称
          templateAttachment: '', // 模板附件路径或名称
          otherInfo: '',          // 其他信息
          templateType: '',       // 模板类型
          creator: '',            // 创建人
          createTime: '',         // 创建时间
          remark1: '',            // 备注1
          remark2: ''             // 备注2
        },
        ruleAddData:{},
        ruleaddmbitem:{
          name: [{
            required: true,
            message: '请填写字段名称',
            trigger: 'change'
          }],
          key: [{
            required: true,
            message: '请填写字段key',
            trigger: 'change'
          }],
          type: [{
            required: true,
            message: '请选择字段类型',
            trigger: 'change'
          }],
          isrequired: [{
            required: true,
            message: '请选择是否必填',
            trigger: 'change'
          }],
          width: [{
            required: true,
            message: '请选择字段宽度',
            trigger: 'change'
          }],
          length: [{
            required: true,
            message: '请填写限制规则',
            trigger: 'change'
          }],
        },
        addmbitem: {
          name: '',
          key: '',
          type: '',
          isrequired: '',
          width: '',
          length: '',
          value: '',
        },
        AddData: [], //最后资源
        multipleSelection: [], //资源
        addMing: false,
        ziyuanData: [],
        shopId: null,
        hefuData: [], //合同附件
        uploadFileUrl: uploadUrl, // 请求地址
        shopList: [],
        formInline: {
          // 合同类型
          contractType: '',
          // 合同编号
          contractNumber: '',
          // 标段号
          sectionNumber: '',
          // 合同名称
          contractName: '',
          // 押金
          earnestMoney: '',
          // 合同签订日期
          contractSigningDate: '',
          // 合同终止日期
          contractTerminationDate: '',
          // 起租日期
          leaseStartDate: '',
          // 付款周期
          paymentCycle: '',
          // 合同金额（租金）
          contractAmount: '',
          // 付款日
          paymentDay: '',
          // 承租人名称
          tenantName: '',
          // 承租人联系电话
          tenantTelephone: '',
          // 承租人银行账号
          tenantBankAccount: '',
          // 关联商家
          relatedMerchants: '',
          // 商铺编号(绑定资源)
          shopNumber: '',
          // 合同附件
          appendicesContract: '',
          //合同状态
          dataStatus: '1'
        },
        rulesHetong: {
          contractType: [{
            required: true,
            message: '请选择合同类型',
            trigger: 'change'
          }],
          contractNumber: [{
            required: true,
            message: '请输入合同编号',
            trigger: 'change'
          }],
          sectionNumber: [{
            required: true,
            message: '请输入标段号',
            trigger: 'change'
          }],
          contractName: [{
            required: true,
            message: '请输入合同名称',
            trigger: 'change'
          }],
          earnestMoney: [{
            required: true,
            message: '请输入押金',
            trigger: 'change'
          }],
          contractSigningDate: [{
            required: true,
            message: '请选择签订日期',
            trigger: 'change'
          }],
          contractTerminationDate: [{
            required: true,
            message: '请选择终止日期',
            trigger: 'change'
          }],
          leaseStartDate: [{
            required: true,
            message: '请选择起租日期',
            trigger: 'change'
          }],
          paymentCycle: [{
            required: true,
            message: '请选择付款周期',
            trigger: 'change'
          }],
          contractAmount: [{
            required: true,
            message: '请输入租金',
            trigger: 'change'
          }],
          paymentDay: [{
            required: true,
            message: '请选择付款日',
            trigger: 'change'
          }],
          tenantName: [{
            required: true,
            message: '请输入承租人名称',
            trigger: 'change'
          }],
          tenantTelephone: [{
            required: true,
            message: '请输入联系电话',
            trigger: 'change'
          }],
          tenantBankAccount: [{
            required: true,
            message: '请输入承租人银行账号',
            trigger: 'change'
          }],
          relatedMerchants: [{
            required: true,
            message: '请选择绑定商家',
            trigger: 'change'
          }],
          shopNumber: [{
            required: true,
            message: '请选择绑定资源',
            trigger: 'change'
          }],
          appendicesContract: [{
            required: true,
            message: '请上传合同附件',
            trigger: 'change'
          }],
        },
        shopfrom: {
          checkState: '2',
          pageNumber: 0,
          pageSize: 1000,
        },
        pageindex: {
          pageNumber: 0,
          pageSize: 20,
        },
        baseURL: 'http://192.168.2.38:9003',
        uploadFiles: [],
        filesLength: 1
      };
    },
    props: {
      info: {
        type: Object,
        default: {}
      }
    },
    async created() {
      console.error({
        ...this.info
      })
      // await cerePlatformMerchant(this.shopfrom).then(res => {
      //   this.shopList = res.data.content
      //   console.error(this.shopList)
      // })
      if (this.info.id) {
        this.info.otherInfo = JSON.parse(this.info.otherInfo)
        this.AddData =  this.info.otherInfo
        this.forminfo = this.info
      }
    },
    methods: {
      async copytit(content){
          // 复制结果
          let copyResult = true
          // 设置想要复制的文本内容
          const text = content || '复制内容为空哦~';
          // 判断是否支持clipboard方式
          if (!!window.navigator.clipboard) {
            // 利用clipboard将文本写入剪贴板（这是一个异步promise）
            await window.navigator.clipboard.writeText(text).then((res) => {
              console.log('复制成功');
            }).catch((err) => {
              console.log('复制失败--采取第二种复制方案', err);
              // clipboard方式复制失败 则采用document.execCommand()方式进行尝试
              copyResult =  copyContent2(text)
            })
          } else {
            // 不支持clipboard方式 则采用document.execCommand()方式
            copyResult =  copyContent2(text)
          }
        // 返回复制操作的最终结果
          return copyResult;
      },
      changimg(e, type) {
        this.forminfo[type] = e
      },
      openfile(e) {
        if (e) {
          const fullUrl = e;
          try {
            window.open(fullUrl, '_blank'); // 在新标签页中打开文件
          } catch (error) {
            console.error('打开文件失败:', error);
          }
        } else {
          console.error('无文件可查看');
        }
      },
      //获取当前时间
      updateCurrentTime() {
        const now = new Date();
        const year = now.getFullYear();
        const month = (now.getMonth() + 1).toString().padStart(2, '0');
        const day = now.getDate().toString().padStart(2, '0');
        const hours = now.getHours().toString().padStart(2, '0');
        const minutes = now.getMinutes().toString().padStart(2, '0');
        const seconds = now.getSeconds().toString().padStart(2, '0');

        return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
      },
      add() {
       console.error(this.AddData)
        this.$refs.ruleForm1.validate((valid) => {
            console.log(valid)
            if (valid) {
              this.forminfo.otherInfo = JSON.stringify(this.AddData)
              console.log(
                {...this.forminfo}
              )
              // return
              cereContractTemplateadd({
                ...this.forminfo,
                creator: localStorage.getItem('roleName'),
                createTime: this.updateCurrentTime(),
              }).then(res => {
                console.error(res)
                if (res.code == 200) {
                  this.$message({
                    message: '添加成功',
                    type: 'success'
                  })
                  this.$emit('removeonaction', '1')
                } else {
                  this.$message({
                    message: res.msg,
                    type: 'error'
                  })
                }

              })
            } else {
              this.$message({
                message: '请填写完整信息',
                type: 'error'
              })
              return false;
            }
          })
      },
      close() {
        this.$emit('removeonaction', '1')
      },
      MingDelete(item) {
        this.AddData.splice(item, 1);
      },
      async mingShow() {
        const ziyuan = await getAlls(this.pageindex)
        const ggw = await map1(this.pageindex)
        const changdi = await changAlls(this.pageindex)
        this.ziyuanData = [...ziyuan.data.content, ...ggw.data.content, ...changdi.data.content]
        console.error(this.ziyuanData)
        this.addMing = true
      },
      handleSelectionChange(selection) {
        // 处理选择变化的逻辑
        console.error(selection)
        this.multipleSelection = []
        this.multipleSelection.push(selection)
      },
      minSev() {
        // return
        this.$refs.addmbitem.validate((valid) => {
            console.log(valid)
            if (valid) {
              this.AddData.push(this.addmbitem)
              this.addmbitem = {
                name: '',
                key: '',
                type: '',
                isrequired: '',
                width: '',
                length: '',
                value: '',
              }
              this.addMing = false
              this.multipleSelection = []
              this.ruleAddData = {}
              for (let index = 0; index < this.AddData.length; index++) {
                const element = this.AddData[index];
                if(element.isrequired == '是') {
                  this.ruleAddData[element.key] = [{
                    required: true,
                    message: '请填写' + element.name,
                    trigger: 'change'
                  }]
    
                }
                
              }
            } else {
              this.$message({
                message: '请填写完整信息',
                type: 'error'
              })
              return false;
            }
          })
      },
      mingClose() {
        this.multipleSelection = []
        this.ziyuanData = []
        this.addMing = false
      },
      changeRelatedMerchants(e) {
        console.error(e)
        this.shopId = this.shopList[e].id
        this.formInline.tenantName = this.shopList[e].name
        this.formInline.tenantTelephone = this.shopList[e].phone
      },
      hefuRemove() {
        this.hefuData = []
      },
      hefuSuccess(response, file, fileList) {
        this.hefuData = []
        console.error(response)
        let fd = new FormData()
        fd.append('file', response.raw)
        fd.append('filePath', 'hetong')
        miniioupload(fd).then(res => {
          console.error(res)
          const fileMsg = {
            name: response.name,
            url: res.data,
          }
          this.hefuData.push(fileMsg)
        })
      },


    },
  };
</script>
<style lang="css">
  .el-upload {
    display: block;
    text-align: left;
  }

  .el-dialog__header {
    background-color: #F2F3F5;
    text-align: left;
  }

  .el-dialog__title {
    line-height: 30px;
    font-size: 15px;
    color: #303133;
  }
  .iterem{
    z-index: 99;
    margin-left: 10px
    ;height: 40px;
    line-height: 25px;
  }
</style>
