<template>

  <el-dialog  :close-on-click-modal="false" :title="$t('一机一档')" :visible.sync="visible" width="1200px" append-to-body>
    <el-card>
      <div slot="header" class="clearfix">
        <span>基本资料</span>
      </div>
      <div class="el-descriptions">
        <div class="el-descriptions__body">
          <table class="el-descriptions__table is-bordered el-descriptions--big" style="table-layout: fixed;border: 1px solid #e6ebf5;">
            <tr class="el-descriptions-row">
              <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label "> 装置</th>
              <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content"> {{}}</td>
              <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label "> 单元</th>
              <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content" > {{}}</td>
              <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label "> 位号</th>
              <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content">{{}}</td>
            </tr>
            <tr class="el-descriptions-row">
              <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label "> 设备名称</th>
              <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content">{{}}</td>
              <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label "> 设备类型</th>
              <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content">{{}}</td>
              <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label "> 使用证编号</th>
              <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content">{{}}</td>
            </tr>
          </table>
        </div>
      </div>
    </el-card>

    <el-card>
      <div slot="header" class="clearfix">
        <span>原始资料（厂家，产品编号等）</span>

      </div>
      <el-table v-loading="loading" :data="yuanshilist" border>
        <el-table-column label="设备id" align="center" prop="id"  v-if="false" :show-overflow-tooltip="true"/>
        <el-table-column label="设备位号" align="center" prop="devno" :show-overflow-tooltip="true"/>
        <el-table-column label="设备名称" align="center" prop="devname" :show-overflow-tooltip="true"/>
        <el-table-column label="状态" align="center" prop="intactStatus" :formatter="intactStatusFormat" />
        <el-table-column label="原始资料档案查看" align="center" prop="archives" :show-overflow-tooltip="true" >
          <template slot-scope="scope">

            <el-button icon="el-icon-folder" style="color:#6e96fa;"  @click="handleDoc(scope.row)"  ></el-button>
            <el-dialog  :close-on-click-modal="false" v-dialogDrag :title="doc.title" :visible.sync="doc.open" width="700px" append-to-body>
              <el-upload
                ref="doc"
                :limit="50"
                :headers="doc.headers"
                :action="doc.url + '?pType=' + doc.pType + '&pId=' + doc.pId"
                :disabled="doc.isUploading"
                :on-progress="handleFileDocProgress"
                :on-success="handleFileDocSuccess"
                :auto-upload="true"
                drag
              >
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">
                  {{ $t('将文件拖到此处，或') }}
                  <em>{{ $t('点击上传') }}</em>
                </div>
              </el-upload>
              <el-table :data="doc.commonfileList" border>
                <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
                  <template slot-scope="scope">
                    <a  class="link-type"  @click="handleDownload(scope.row)">
                      <span>{{ scope.row.fileName }}</span>
                    </a>
                  </template>
                </el-table-column>
                <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize" :show-overflow-tooltip="true" width="80" />
                <el-table-column :label="$t('上传人')" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
                <el-table-column :label="$t('操作')" align="center" width="150" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button
                      v-if="scope.row.fileName.endsWith('pdf')"
                      size="mini"
                      type="text"
                      icon="el-icon-view"
                      @click="handleSee(scope.row)"
                    >{{ $t('预览') }}</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-download"
                      @click="handleDownload(scope.row)"
                    >{{ $t('下载') }}</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-delete"
                      @click="handleDeleteDoc(scope.row)"
                    >{{ $t('删除') }}</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <div slot="footer" class="dialog-footer">
                <!--        <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>-->
                <el-button @click="doc.open = false">{{ $t('返 回') }}</el-button>
              </div>
            </el-dialog>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-card>
      <div slot="header" class="clearfix">
        <span>安装资料、使用说明</span>
      </div>
      <el-table v-loading="loading" :data="anzhuanglist" border>
       <el-table-column label="设备id" align="center" prop="id"  v-if="false" :show-overflow-tooltip="true"/>
        <el-table-column label="设备位号" align="center" prop="devno" :show-overflow-tooltip="true"/>
        <el-table-column label="设备名称" align="center" prop="devname" :show-overflow-tooltip="true"/>
        <el-table-column label="状态" align="center" prop="intactStatus" :formatter="intactStatusFormat" />
  <el-table-column label="安装资料档案查看" align="center" prop="archives" :show-overflow-tooltip="true" >
          <template slot-scope="scope">

            <el-button icon="el-icon-folder" style="color:#6e96fa;"  @click="handleDoc11(scope.row)"  ></el-button>
                <el-dialog  :close-on-click-modal="false" v-dialogDrag :title="doc11.title" :visible.sync="doc11.open" width="700px" append-to-body>
              <el-upload
                ref="doc11"
                :limit="50"
                :headers="doc11.headers"
                :action="doc11.url + '?pType=' + doc11.pType + '&pId=' + doc11.pId"
                :disabled="doc11.isUploading"
                :on-progress="handleFileDocProgress11"
                :on-success="handleFileDocSuccess11"
                :auto-upload="true"
                drag
              >
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">
                  {{ $t('将文件拖到此处，或') }}
                  <em>{{ $t('点击上传') }}</em>
                </div>
              </el-upload>
              <el-table :data="doc11.commonfileList" border>
                <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
                  <template slot-scope="scope">
                    <a  class="link-type"  @click="handleDownload(scope.row)">
                      <span>{{ scope.row.fileName }}</span>
                    </a>
                  </template>
                </el-table-column>
                <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize" :show-overflow-tooltip="true" width="80" />
                <el-table-column :label="$t('上传人')" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
                <el-table-column :label="$t('操作')" align="center" width="150" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button
                      v-if="scope.row.fileName.endsWith('pdf')"
                      size="mini"
                      type="text"
                      icon="el-icon-view"
                      @click="handleSee(scope.row)"
                    >{{ $t('预览') }}</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-download"
                      @click="handleDownload(scope.row)"
                    >{{ $t('下载') }}</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-delete"
                      @click="handleDeleteDoc(scope.row)"
                    >{{ $t('删除') }}</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <div slot="footer" class="dialog-footer">
                <!--        <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>-->
                <el-button @click="doc11.open = false">{{ $t('返 回') }}</el-button>
              </div>
            </el-dialog>
                 </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-card>
      <div slot="header" class="clearfix">
        <span> 巡检记录</span><div style="float: right;margin-bottom: -14px">
        <el-form :model="queryDeviceParams" ref="queryRegularForm" label-width="68px" :inline="true">
          <el-form-item :label="$t('年份')" prop="year">
            <el-date-picker clearable size="small" style="width: 200px"
                            v-model="queryDeviceParams.year"
                            type="year"
                            value-format="yyyy"
                            :placeholder="$t('请选择') + $t('年份')">
            </el-date-picker>
          </el-form-item>
          <el-button type="cyan" icon="el-icon-search" size="mini" @click="getRecordList(row,queryDeviceParams.year)" style="margin-left: 20px;">
            {{ $t('搜索') }}</el-button>
        </el-form>
      </div>
      </div>
      <el-table v-loading="loading" :data="recordList" :max-height="300" border>
        <el-table-column label="设备名称" align="center" prop="devname" :show-overflow-tooltip="true"/>
        <el-table-column label="设备位号" align="center" prop="devno" :show-overflow-tooltip="true"/>
        <el-table-column label="区域" align="center" prop="region" :show-overflow-tooltip="true"/>
        <el-table-column label="原因" align="center" prop="reason" :show-overflow-tooltip="true"/>
        <el-table-column label="巡检时间" align="center" prop="inspectionTime" width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.inspectionTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="消故时间" align="center" prop="pastTime" width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.pastTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="消故人" align="center" prop="pasterCode" :show-overflow-tooltip="true"/>
        <el-table-column label="处理情况" align="center" prop="treatment" :show-overflow-tooltip="true"/>
        <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
      </el-table>
      <!--      <el-table :data="list" v-loading="planLoading"  border>-->

      <!--      </el-table>-->
    </el-card>
    <el-card>
      <div slot="header" class="clearfix">
        <span> 维修记录</span><div style="float: right;margin-bottom: -14px">
        <el-form :model="queryDeviceParams2" ref="queryRegularForm" label-width="68px" :inline="true">
          <el-form-item :label="$t('年份')" prop="year">
            <el-date-picker clearable size="small" style="width: 200px"
                            v-model="queryDeviceParams2.year"
                            type="year"
                            value-format="yyyy"
                            :placeholder="$t('请选择') + $t('年份')">
            </el-date-picker>
          </el-form-item>
          <el-button type="cyan" icon="el-icon-search" size="mini" @click="staffPlanQuery1(row,queryDeviceParams2.year)" style="margin-left: 20px;">
            {{ $t('搜索') }}</el-button>
        </el-form>
      </div>
      </div>
      <el-table v-loading="loading" :data="approveList" border>
        <el-table-column :label="$t('申请人')" align="center" prop="userName" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('设备类型')+':'" align="center" prop="devType" :formatter="devTypeFormat" />
        <el-table-column :label="$t('审批类型')" align="center" prop="approveType"  :formatter="approveTypeFormat"/>
        <el-table-column :label="$t('内容')" align="center" prop="content" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('申请状态')" align="center" prop="status"  :formatter="statusFormat"/>
        <el-table-column :label="$t('开始时间')" align="center" prop="creattime" width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.creattime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('结束时间')" align="center" prop="enddate" width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.enddate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('操作')" align="center"  width="120" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="detailHandle(scope.row)"
            >{{ $t('查看') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <spec-maintenance v-if="specMaintenanceVisible" ref="specMaintenance"></spec-maintenance>
      <!--      <el-table :data="list" v-loading="planLoading"  border>-->

      <!--      </el-table>-->
    </el-card>
    <el-card>
      <div slot="header" class="clearfix">
        <span> 变更记录</span><div style="float: right;margin-bottom: -14px">
        <el-form :model="queryDeviceParams3" ref="queryRegularForm" label-width="68px" :inline="true">
          <el-form-item :label="$t('年份')" prop="year">
            <el-date-picker clearable size="small" style="width: 200px"
                            v-model="queryDeviceParams3.year"
                            type="year"
                            value-format="yyyy"
                            :placeholder="$t('请选择') + $t('年份')">
            </el-date-picker>
          </el-form-item>
          <el-button type="cyan" icon="el-icon-search" size="mini" @click="staffPlanQuery" style="margin-left: 20px;">
            {{ $t('搜索') }}</el-button>
        </el-form>
      </div>
      </div>
      <el-table :data="changelist" v-loading="planLoading"  border>
           <el-table-column :label="$t('申请人')" align="center" prop="userName" :show-overflow-tooltip="true"/>
      <el-table-column :label="$t('设备类型')+':'" align="center" prop="devType" :formatter="devTypeFormat" />
      <el-table-column :label="$t('审批类型')" align="center" prop="approveType" :formatter="approveTypeFormat" />
      <el-table-column :label="$t('内容')" align="center" prop="content" :show-overflow-tooltip="true"/>
      <el-table-column :label="$t('申请状态')" align="center" prop="status"  :formatter="statusFormat"/>
      <el-table-column :label="$t('开始时间')" align="center" prop="creattime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.creattime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('结束时间')" align="center" prop="endtime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      </el-table>
    </el-card>
  </el-dialog>
</template>

<script>
import { listGyl, getGyl, delGyl, addGyl, updateGyl, exportGyl, importTemplate} from "@/api/intact/gyl";
import {  getApproveInfo,listHisApprove } from "@/api/intact/approve_dev";
import Treeselect from "@riophae/vue-treeselect";
import {allFileList, delCommonfile} from "@/api/common/commonfile";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {listPlan} from "@/api/training/spec/plan";
import {listParticipants} from "@/api/training/participants";
import {listDevice} from "@/api/training/device";
import {getToken} from "@/utils/auth";
import {listRecord} from "@/api/inspection/record";
import {hisApprovelist} from "@/api/intact/maintenance";
import SpecMaintenance from "@/views/approve/approveDetail/specMaintenance-detail";

export default {
  name: "Resume",
  components: {Treeselect,SpecMaintenance},
  data() {
    return {
      row:{},
      recordList:[],
      approveList:[],
      specMaintenanceVisible: false,
      devType:1,
      devTypeOptions: [{dictValue:1,dictLabel:'工业炉'},{dictValue:2,dictLabel:'压缩机'},{},{}],
      // 审批类型字典
      approveTypeOptions: [{dictValue:1,dictLabel:'维修'}],
      statusOptions: [],
      intactStatusOptions:[],
      list: [],
      yuanshilist:[],
      anzhuanglist:[],
      changelist:[],
      // 遮罩层
      loading: false,
      planLoading: false,
      visible: false,
      // 选中数组
      ids: [],
      photo: '',
      dataListSelections: [],
      // 装置名称字典
      plantCodeOptions: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 弹出层标题
      title: "",
      // 操作
      operation: "",
      // 部门树选项
      deptOptions: undefined,
      clientHeight: 300,
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        staffId: null,
        plantName: null,
        startDate: null,
        endDate: null,
        classHour: null,
        studyState: null
      },
      queryDeviceParams: {
        staffId: null,
        regularId: null,
        year: this.getNowTime(),
        trainingType: null
      },
      queryDeviceParams2: {
        staffId: null,
        regularId: null,
        year: this.getNowTime(),
        trainingType: null
      },
      queryDeviceParams3: {
        staffId: null,
        regularId: null,
        year: this.getNowTime(),
        trainingType: null
      },
      doc: {
        file: "123",
        // 是否显示弹出层（报告附件）
        open: false,
        // 弹出层标题（报告附件）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 报告附件上传位置编号
        ids: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/common/commonfile/uploadFile",
        commonfileList: null,
        queryParams: {
          pId: null,
          pType: 'intactRecord'
        },
        pType: 'intactRecord',
        pId: null
      },
        doc11: {
        file: "123",
        // 是否显示弹出层（报告附件）
        open: false,
        // 弹出层标题（报告附件）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 报告附件上传位置编号
        ids: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/common/commonfile/uploadFile",
        commonfileList: null,
        queryParams: {
          pId: null,
          pType: 'intactRecord'
        },
        pType: 'intactRecord',
        pId: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };

  },
  watch: {},
  created() {
    this.getDicts("PLANT_DIVIDE").then(response => {
      this.plantCodeOptions = response.data;
    });
    this.getDicts("spec_approve_res").then(response => {
      this.statusOptions = response.data;
    });
    this.getDicts("INTACT_STATUS").then(response => {
      this.intactStatusOptions = response.data;
    });
  },
  methods: {
    init(row) {
      this.row=row
      this.visible = true

      //给原始、安装资料的list数据赋值

      getGyl(row.id).then(response => {
        const didi=[]
        didi.push(response.data)
       this.yuanshilist=didi
       this.anzhuanglist=didi
        this.total = response.total;
        this.loading = false;

      });

      var data = {
        devno:row.devno,
        region:row.position
      }
      listRecord(data).then(response => {
        this.recordList = response.rows;
        this.total = response.total;
        this.loading = false;

      });

      var data2={
        devId : row.id,
        devType : this.devType
      }
      hisApprovelist(data2).then(response => {
        this.approveList = response.data;
        this.total = response.total;
        this.loading = false;

      });

      //设备变更信息
        var data3={
        devId : row.id,
        devType : this.devType
      }
      //变更的申请记录
      listHisApprove(data3).then(response => {
        this.changelist = response.data;
        this.total = response.total;
        this.loading = false;
      });


    },
    staffPlanQuery1(row,year){
      var data2={
        devId : row.id,
        devType : this.devType,
        createyear: year
      }
      hisApprovelist(data2).then(response => {
        this.approveList = response.data;
        this.total = response.total;
        this.loading = false;
      });
    },
    handleSee(row){

    },
    staffPlanQuery(){
      alert("123123qqss")
    },
    // 设备类型：字典翻译
    devTypeFormat(row) {
      return this.selectDictLabel(this.devTypeOptions, row.devType);
    },
    // 审批类型字典翻译
    approveTypeFormat(row) {
      return this.selectDictLabel(this.approveTypeOptions, row.approveType);
    },
    // 审批类型字典翻译
    statusFormat(row) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    intactStatusFormat(row){
      return this.selectDictLabel(this.intactStatusOptions, row.status);
    },
    /** 获取当前年份 */
    getNowTime() {
      var now = new Date();
      var year = now.getFullYear(); //得到年份
      var defaultDate = `${year}`;
      defaultDate = `${year}`
      return defaultDate;
    },
    // 装置名称字典翻译
    plantCodeFormat(row, column) {
      return this.selectDictLabel(this.plantCodeOptions, row.plantCode);
    },
    //操作审批流程
    detailHandle (row) {
      this.specMaintenanceVisible = true
      this.$nextTick(() => {
        console.log(row)
        this.$refs.specMaintenance.init(row.id, row.taskId, row.processId,row.taskName)
      })
    },
    getRecordList(row,year){
      const data = {
        devno: row.devno,
        region: row.position,
        createyear: year
      };
      listRecord(data).then(response => {
        console.log(data)
        this.recordList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    /** 原始资料档案附件按钮操作 */
    handleDoc(row) {
      console.log(row)

      this.doc.id = row.id;
      this.doc.title = row.filename;
      this.doc.open = true;
      this.doc.queryParams.pId = row.id
      this.doc.pId = row.id
      this.getFileList()
      this.$nextTick(() => {
        this.$refs.doc.clearFiles()
      })

    },
    //安装资料档案操作
    handleDoc11(row) {


      this.doc11.id = row.id;
      this.doc11.title = row.filename;
      this.doc11.open = true;
      this.doc11.queryParams.pId =parseFloat( row.id.toString()+row.id.toString())
      this.doc11.pId = parseFloat( row.id.toString()+row.id.toString())
      this.getFileList11()
      this.$nextTick(() => {
        this.$refs.doc11.clearFiles()
      })

    },
    //原始资料得到文件列表
    getFileList (){
      allFileList(this.doc.queryParams).then(response => {
        this.doc.commonfileList = response;
      });
    },
    //安装资料得到文件列表
    getFileList11 (){
      allFileList(this.doc11.queryParams).then(response => {
        this.doc11.commonfileList = response;
      });
    },
    //原始附件上传中处理
    handleFileDocProgress(event, file, fileList) {
      this.doc.file = file;
      this.doc.isUploading = true;
    },
    //原始附件上传成功处理
    handleFileDocSuccess(response, file, fileList) {
      this.doc.isUploading = false;
      this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
      this.getFileList()
    },
     //安装附件上传中处理
    handleFileDocProgress11(event, file, fileList) {
      this.doc11.file = file;
      this.doc11.isUploading = true;
    },
    //安装附件上传成功处理11
    handleFileDocSuccess11(response, file, fileList) {
      this.doc11.isUploading = false;
      this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
      this.getFileList11()
    },
    /** 删除按钮操作 */
    handleDeleteDoc(row) {
      const ids = row.id || this.ids;
      this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: "warning"
      }).then(function() {
        return delCommonfile(ids);
      }).then(() => {
        this.getFileList()
        this.getFileList11()
        this.msgSuccess(this.$t('删除成功'));
      })
    },
    // 文件下载处理
    handleDownload(row) {
      var name = row.fileName;
      var url = row.fileUrl;
      var suffix = url.substring(url.lastIndexOf("."), url.length);
      console.log(url)
      const a = document.createElement('a')
      a.setAttribute('download', name)
      a.setAttribute('target', '_blank')
      a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
      a.click()
    },

  }
};
</script>
