<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="任务名称" prop="taskName">
        <el-input v-model="queryParams.taskName" placeholder="请输入任务名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="任务类型" prop="typeName">
        <el-select v-model="queryParams.typeName" placeholder="请选择任务类型" clearable>
          <el-option v-for="dict in dict.type.task_type" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>

      <el-form-item label="所属地块" prop="fieldIdList">
        <el-select v-model="queryParams.fieldIdList" placeholder="请选择地块" multiple collapse-tags filterable clearable>
          <el-option v-for="dict in fieldIdList" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="所属农场" prop="deptIdList">
        <treeselect v-model="queryParams.deptIdList" :options="deptOptions" multiple :flat="true" :limit="1"
          :limitText="count => `+${count}`" style="width:200px" :show-count="true" placeholder="请选所属农场" />
      </el-form-item>

      <el-form-item label="执行人" prop="assigneeName">
        <el-input v-model="queryParams.assigneeName" placeholder="请输入执行人" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="任务状态" prop="taskStatus">
        <el-select v-model="queryParams.taskStatus" placeholder="请选择任务状态" clearable>
          <el-option v-for="dict in dict.type.task_status" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>

      <el-form-item label="执行时间" prop="executeTimeRange">
        <el-date-picker v-model="executeTimeRange" type="datetimerange" range-separator="至" start-placeholder="开始时间"
          end-placeholder="结束时间" value-format="yyyy-MM-dd HH:mm:ss" clearable style="width: 350px">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="完成时间" prop="completionTimeRange">
        <el-date-picker v-model="completionTimeRange" type="datetimerange" range-separator="至" start-placeholder="开始时间"
          end-placeholder="结束时间" value-format="yyyy-MM-dd HH:mm:ss" clearable style="width: 350px">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['base:tasks:add']">新增</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['base:tasks:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['base:tasks:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="tasksList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="任务名称" align="center" prop="taskName" />
      <el-table-column label="任务类型" align="center" prop="typeName">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.task_type" :value="scope.row.typeName" />
        </template>
      </el-table-column>

      <el-table-column label="作物名称" align="center" prop="growCrops" />
      <el-table-column label="所属地块" align="center" prop="fieldName" />
      <el-table-column label="所属农场" align="center" prop="deptName" />
      <el-table-column label="执行人" align="center" prop="assigneeName" />
      <el-table-column label="计划执行时间" align="center" prop="executeTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.executeTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划完成时间" align="center" prop="plannedCompletetime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.plannedCompletetime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>

      <!-- <el-table-column label="任务状态" align="center" prop="taskStatus" width="100">
        <template slot-scope="scope">
          <el-tag :type="scope.row.taskStatus === 1 ? 'success' : 'warning'" size="small">
            {{ scope.row.taskStatus === 1 ? '已完成' : '待完成' }}
          </el-tag>
        </template>
      </el-table-column> -->

      <el-table-column label="任务状态" align="center" prop="taskStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.task_status" :value="scope.row.taskStatus" />
        </template>
      </el-table-column>

      <el-table-column label="任务说明" align="center" prop="remark" width="150" show-overflow-tooltip />
      <el-table-column label="实际开始时间" align="center" prop="practicalBegintime" width="180">
        <template slot-scope="scope">
          <span>{{ scope.row.practicalBegintime ? parseTime(scope.row.practicalBegintime, '{y}-{m}-{d} {h}:{i}:{s}') :
            '-'
            }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际完成时间" align="center" prop="completionTime" width="180">
        <template slot-scope="scope">
          <span>{{ scope.row.completionTime ? parseTime(scope.row.completionTime, '{y}-{m}-{d} {h}:{i}:{s}') : '-'
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="完成说明" align="center" prop="completionDesc" width="150" show-overflow-tooltip />
      <el-table-column label="附件" align="center" prop="imageCount" width="80">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.imageCount && scope.row.imageCount > 0" type="success" size="mini">
            {{ scope.row.imageCount }}张
          </el-tag>
          <span v-else style="color: #999;">-</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['base:tasks:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['base:tasks:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改农事任务对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="650px" append-to-body @opened="queryMachineNameFieldUserTe()">
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="任务名称" prop="taskName">
              <el-input v-model="form.taskName" placeholder="请输入任务名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="任务类型" prop="typeName">
              <el-select v-model="form.typeName" placeholder="请选择任务类型">
                <el-option v-for="dict in dict.type.task_type" :key="dict.value" :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="所属农场" prop="farmId">
              <treeselect v-model="form.farmId" :options="enabledDeptOptions" :show-count="true"
                @input="queryMachineNameFieldUser(form.farmId)" placeholder="请先选择所属农场" />
            </el-form-item>
          </el-col>
          <el-col :span="12">

            <el-form-item label="所属地块" prop="plotIds">
              <!-- <el-select v-model="form.fieldName" placeholder="请选择作业地块" style="width: 100%" :disabled="!form.farmName">
                <el-option v-for="field in filteredFieldOptions" :key="field.value" :label="field.label"
                  :value="field.value" />
              </el-select> -->

              <el-select v-model="form.plotId" placeholder="请选择作业地块" :disabled="!form.farmId">
                <el-option v-for="item in fields" :key="item.id" :label="item.fieldName" :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="执行人" prop="assigneeId">
              <el-select v-model="form.assigneeId" placeholder="请选择操作员" :disabled="!form.farmId">
                <el-option v-for="item in userName" :key="item.userId" :label="item.nickName" :value="item.userId">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="执行时间" prop="executeTime">
              <el-date-picker clearable v-model="form.executeTime" type="datetime" placeholder="请选择执行时间"
                style="width: 100%">
              </el-date-picker>
            </el-form-item>
          </el-col> -->

          <el-col :span="12">
            <el-form-item label="任务状态" prop="taskStatus">
              <el-select v-model="form.taskStatus" placeholder="请选择任务状态" style="width: 100%">
                <el-option v-for="dict in dict.type.task_status" :key="dict.value" :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>

          </el-col>
        </el-row>
        <el-row :gutter="20">
          <!-- <el-col :span="12">
            <el-form-item label="任务状态" prop="taskStatus">
              <el-select v-model="form.taskStatus" placeholder="请选择任务状态" style="width: 100%">
                <el-option v-for="dict in dict.type.task_status" :key="dict.value" :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>

          </el-col> -->
          <el-col :span="12">
            <el-form-item label="作物名称" prop="growCrops">
              <el-input v-model="form.growCrops" placeholder="请输入作物名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划开始时间" prop="executeTime">
              <el-date-picker clearable v-model="form.executeTime" type="datetime" placeholder="请选择计划开始时间"
                style="width: 100%">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">

          <el-col :span="12">
            <el-form-item label="计划完成时间" prop="plannedCompletetime">
              <el-date-picker clearable v-model="form.plannedCompletetime" type="datetime" placeholder="请选择计划完成时间"
                style="width: 100%">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="任务说明" prop="remark">
          <el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入任务说明" />
        </el-form-item>
        <el-row :gutter="20" v-if="form.taskStatus == 1">

          <el-col :span="12">
            <el-form-item label="实际开始时间" prop="practicalBegintime">
              <el-date-picker clearable v-model="form.practicalBegintime" type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择实际开始时间" style="width: 100%">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际完成时间" prop="completionTime">
              <el-date-picker clearable v-model="form.completionTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择实际完成时间" style="width: 100%">
              </el-date-picker>
            </el-form-item>
          </el-col>

        </el-row>
        <el-form-item label="完成说明" prop="completionDesc" v-if="form.taskStatus == 1">
          <el-input v-model="form.completionDesc" type="textarea" :rows="3" placeholder="请输入完成说明" />
        </el-form-item>
        <el-form-item label="上传附件" prop="taskImages" v-if="form.taskStatus == 1">
          <image-upload v-model="form.taskImages" :limit="5" :fileSize="10" :fileType="['jpg', 'jpeg', 'png', 'gif']" />
          <div style="color: #999; font-size: 12px; margin-top: 5px;">
            支持jpg、jpeg、png、gif格式，单张图片不超过10MB，最多上传5张
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>



  </div>
</template>

<script>
import { getMachineNameFieldUser, MachineNameFieldUserText } from "@/api/base/machineWorkRecords"
import { listTasks, getTasks, delTasks, addTasks, updateTasks } from "@/api/base/tasks"
import { deptTreeSelect } from "@/api/system/user";
import { listFieldName } from "@/api/base/field"
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import ImageUpload from "@/components/ImageUpload"

export default {
  name: "Tasks",
  components: {
    ImageUpload,
    Treeselect
  },
  dicts: ['task_type', 'task_status', 'field_soil_type', 'sys_field_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 农事任务表格数据
      tasksList: [],
      // 弹出层标题
      title: "",
      titleSet: "",
      // 是否显示弹出层
      open: false,
      openSet: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        taskName: null,
        taskType: null,
        plotNames: [],
        farmNames: [],
        executor: null,
        taskStatus: null,

      },
      // 地块选项
      plotOptions: [],
      // 农场选项
      farmOptions: [],
      // 执行人选项
      executorOptions: [],
      // 表单参数
      form: {},
      formSet: {},
      // 部门树选项
      deptOptions: undefined,
      // 过滤掉已禁用部门树选项
      enabledDeptOptions: undefined,
      // 所属地块
      fieldIdList: [],

      fields: [],
      userName: [],
      executeTimeRange: [],
      completionTimeRange: [],


      // 表单校验
      rules: {
        taskName: [
          { required: true, message: "任务名称不能为空", trigger: "blur" }
        ],
        typeName: [
          { required: true, message: "任务类型不能为空", trigger: "change" }
        ],
        plotId: [
          { required: true, message: "所属地块不能为空", trigger: "change" }
        ],
        farmId: [
          { required: true, message: "所属农场不能为空", trigger: "change" }
        ],
        assigneeId: [
          { required: true, message: "执行人不能为空", trigger: "change" }
        ],
        executeTime: [
          { required: true, message: "计划开始时间不能为空", trigger: "blur" }
        ],
        plannedCompletetime: [
          { required: true, message: "计划完成时间不能为空", trigger: "blur" }
        ],
        taskStatus: [
          { required: true, message: "任务状态不能为空", trigger: "change" }
        ]
      }
    }
  },
  created() {
    this.getList();
    this.getDeptTree();
    this.getFieldNameList();
    // this.initOptions()
  },
  methods: {

    formatDateTime(dateString) {
      const date = new Date(dateString);
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, '0');
      const day = String(date.getDate()).padStart(2, '0');
      const hours = String(date.getHours()).padStart(2, '0');
      const minutes = String(date.getMinutes()).padStart(2, '0');
      return `${year}-${month}-${day} ${hours}:${minutes}`;
    },

    queryMachineNameFieldUser(farmId) {
      console.log("queryMachineNameFieldUser")
      this.form.plotId = null;
      this.form.assigneeId = null;
      if (farmId != undefined) {
        const data = {
          deptId: farmId
        }
        getMachineNameFieldUser(data).then(response => {
          this.fields = response.data.fields
          this.userName = response.data.users
        })
      }
    },
    queryMachineNameFieldUserTe() {
      console.log("queryMachineNameFieldUserTe")
      const id = this.form.id;
      if (id != undefined) {
        getTasks(id).then(response => {
          this.form.plotId = response.data.plotId
          this.form.assigneeId = response.data.assigneeId
        })
      }
    },

    /** 查询部门下拉树结构 */
    getDeptTree() {
      deptTreeSelect().then(response => {
        this.deptOptions = response.data;
        this.enabledDeptOptions = this.filterDisabledDept(JSON.parse(JSON.stringify(response.data)))
      });
    },
    filterDisabledDept(deptList) {
      return deptList.filter(dept => {
        if (dept.disabled) {
          return false
        }
        if (dept.children && dept.children.length) {
          dept.children = this.filterDisabledDept(dept.children)
        }
        return true
      })
    },

    /** 查询地块名称 **/
    getFieldNameList() {
      listFieldName().then(res => {
        this.fieldIdList = res;
        this.fieldIdList.forEach(x => {
          x.value = x.id;
          x.label = x.fieldName;
        })
      });
    },
    /** 初始化下拉选项 */
    initOptions() {
      // 为了支持修改表单回填，这里提供一些模拟数据
      // 实际开发中应该调用API获取真实数据
      this.plotOptions = [
        { label: "东区1号田", value: "东区1号田" },
        { label: "西区2号田", value: "西区2号田" },
        { label: "南区果园", value: "南区果园" },
        { label: "北区菜地", value: "北区菜地" },
        { label: "温室大棚A区", value: "温室大棚A区" },
        { label: "智能温室B区", value: "智能温室B区" },
        { label: "智能温室C区", value: "智能温室C区" },
        { label: "有机种植区", value: "有机种植区" },
        { label: "葡萄园A区", value: "葡萄园A区" },
        { label: "机械库房", value: "机械库房" }
      ]

      this.farmOptions = [
        { label: "阳光农场", value: "阳光农场" },
        { label: "绿野农场", value: "绿野农场" },
        { label: "丰收农场", value: "丰收农场" },
        { label: "田园农场", value: "田园农场" },
        { label: "科技农场", value: "科技农场" },
        { label: "有机农场", value: "有机农场" },
        { label: "现代农场", value: "现代农场" },
        { label: "生态农场", value: "生态农场" },
        { label: "智慧农场", value: "智慧农场" },
        { label: "酒庄农场", value: "酒庄农场" }
      ]

      this.executorOptions = [
        { label: "张三", value: "张三" },
        { label: "李四", value: "李四" },
        { label: "王五", value: "王五" },
        { label: "赵六", value: "赵六" },
        { label: "钱七", value: "钱七" },
        { label: "孙八", value: "孙八" },
        { label: "周九", value: "周九" },
        { label: "吴十", value: "吴十" },
        { label: "郑十一", value: "郑十一" },
        { label: "冯十二", value: "冯十二" }
      ]
    },
    /** 获取任务类型名称 */
    getTaskTypeName(type) {
      const typeMap = {
        '0': '施肥',
        '1': '灌溉',
        '2': '打药',
        '3': '采摘',
        '4': '巡检',
        '5': '除草',
        '6': '其他'
      }
      return typeMap[type] || '未知'
    },
    /** 获取任务类型标签类型 */
    getTaskTypeTagType(type) {
      const tagTypeMap = {
        '0': 'success',  // 施肥
        '1': 'primary',  // 灌溉
        '2': 'warning',  // 打药
        '3': 'danger',   // 采摘
        '4': 'info',     // 巡检
        '5': '',         // 除草
        '6': 'default'   // 其他
      }
      return tagTypeMap[type] || ''
    },
    /** 查询农事任务列表 */
    getList() {
      this.loading = true
      this.queryParams.params = {}
      if (null != this.executeTimeRange && '' != this.executeTimeRange) {
        this.queryParams.params["beginExecuteTime"] = this.executeTimeRange[0];
        this.queryParams.params["endExecuteTime"] = this.executeTimeRange[1];
      }
      if (null != this.completionTimeRange && '' != this.completionTimeRange) {
        this.queryParams.params["beginCompletionTime"] = this.completionTimeRange[0];
        this.queryParams.params["endCompletionTime"] = this.completionTimeRange[1];
      }
      listTasks(this.queryParams).then(response => {
        this.tasksList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        taskName: null,
        typeName: null,
        plotName: null,
        farmId: null,
        plotId: null,
        assigneeId: null,
        executeTime: null,
        plannedCompletetime: null,
        growCrops: null,
        remark: null,
        taskStatus: "0",
        taskDescription: null,
        practicalBegintime: null,
        completionTime: null,
        completionDesc: null,
        field: null,
        fieldName: null,
        assigneeId: null,
        assigneeName: null,
        imageCount: null
      }

      this.resetForm("form")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.executeTimeRange = []
      this.completionTimeRange = []
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = "添加农事任务"
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      if (row.farmId != undefined) {
        const data = {
          deptId: row.farmId
        }
        MachineNameFieldUserText(data).then(response => {
          this.fields = response.data.fields
          this.userName = response.data.users
        })
      }
      this.reset()
      console.log(row)
      const id = row.id || this.ids
      // 如果是批量修改或者需要从服务器获取数据
      getTasks(id).then(response => {
        this.form = response.data
        this.open = true
        this.title = "修改农事任务"
      })

    },
    formatDateTime(dateString) {
      const date = new Date(dateString);
      return date.toISOString().replace('T', ' ').substring(0, 16);
    },
    /** 提交按钮 */
    submitForm() {
      console.log("提交按钮");
      this.$refs["form"].validate(valid => {
        if (valid) {
          // 格式化时间字段
          this.form.executeTime = this.formatDateTime(this.form.executeTime);
          this.form.plannedCompletetime = this.formatDateTime(this.form.plannedCompletetime);

          if (this.form.id != null) {
            // 修改任务
            this.form.field = this.form.plotId;
            const selectedUser = this.userName.find(user => user.userId === this.form.assigneeId);
            if (selectedUser) {
              this.form.assigneeName = selectedUser.nickName;
            }

            const selectedfieldName = this.fields.find(field => field.id === this.form.plotId);
            if (selectedfieldName) {
              this.form.fieldName = selectedfieldName.fieldName;
            }

            updateTasks(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            // 新增任务
            this.form.field = this.form.plotId;
            const selectedUser = this.userName.find(user => user.userId === this.form.assigneeId);
            if (selectedUser) {
              this.form.assigneeName = selectedUser.nickName;
            }

            const selectedfieldName = this.fields.find(field => field.id === this.form.plotId);
            if (selectedfieldName) {
              this.form.fieldName = selectedfieldName.fieldName;
            }

            addTasks(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除农事任务编号为"' + ids + '"的数据项？').then(function () {
        return delTasks(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("删除成功")
      }).catch(() => { })
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('base/tasks/export', {
        ...this.queryParams
      }, `tasks_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
