| | |
| | | v-hasPermi="['point:remove']">删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="warning" plain icon="el-icon-top" size="mini" @click="handleImportPoint" |
| | | v-hasPermi="['point:import']">导入点位</el-button> |
| | | <el-button type="primary" plain icon="el-icon-bottom" v-loading="download" size="mini" @click="handleExport" |
| | | v-hasPermi="['point:export']">导出点位</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-popover> |
| | | <div> |
| | | <el-select v-model="importUnitId" size="small" placeholder="负责单位"> |
| | | <el-option v-for="unit in unitList" :key="unit.id" :label="unit.value" :value="unit.id"></el-option> |
| | | </el-select> |
| | | </div> |
| | | <div> |
| | | <el-upload |
| | | ref="upload" |
| | | class="upload-demo" |
| | | drag |
| | | :action="importUrl" |
| | | :file-list="fileList" |
| | | :before-upload="beforeUpload" |
| | | > |
| | | <i class="el-icon-upload"></i> |
| | | <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
| | | <div class="el-upload__tip" slot="tip">只能上传xls/xlsx文件</div> |
| | | </el-upload> |
| | | </div> |
| | | <div> |
| | | <el-button type="primary" size="small" v-model="upload" :disabled="! importUnitId || ! importFile" @click="handleImport" style="width: 100%; margin-top: 5px" |
| | | v-hasPermi="['point:import']">导入</el-button> |
| | | </div> |
| | | <el-button type="primary" size="mini" plain icon="el-icon-top" slot="reference">导入点位</el-button> |
| | | </el-popover> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="danger" plain icon="el-icon-receiving" size="mini" @click="handleEditBatch" |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listPoint, getPoint, delPoint, addPoint, batchEdit, updatePoint } from "@/api/platform/point"; |
| | | import { listPoint, getPoint, delPoint, addPoint, batchEdit, updatePoint, exportData, importData } from "@/api/platform/point"; |
| | | import { unitSelect } from "@/api/platform/unit"; |
| | | import { getCascader } from '@/api/platform/region' |
| | | import { cascader } from '@/api/system/dept' |
| | |
| | | dicts: ['point_tag'], |
| | | data() { |
| | | return { |
| | | fileList: [], |
| | | importFile: null, |
| | | importUrl: '', |
| | | importUnitId: null, |
| | | download: false, |
| | | upload: false, |
| | | deptOptions: [], |
| | | // 批量修改表单 |
| | | batchEditForm: { |
| | |
| | | this.getDeptCascader(); |
| | | }, |
| | | methods: { |
| | | beforeUpload(file) { |
| | | this.importFile = file |
| | | this.fileList = [file] |
| | | return false |
| | | }, |
| | | // 点位导入 |
| | | handleImportPoint() { |
| | | handleImport() { |
| | | this.upload =true; |
| | | let formData = new FormData() |
| | | formData.append("file", this.importFile) |
| | | importData(formData, this.importUnitId).then(res => { |
| | | this.$message.success("导入成功") |
| | | this.upload = false |
| | | }) |
| | | }, |
| | | // 点位导出 |
| | | handleExport() { |
| | | this.download = true |
| | | exportData(this.queryParams).then(res => { |
| | | // 将二进制数据转换为 Blob 对象 |
| | | let blob = new Blob([res], { type: 'application/octet-stream' }); |
| | | |
| | | // 创建下载链接 |
| | | let downloadLink = document.createElement('a'); |
| | | downloadLink.href = URL.createObjectURL(blob); |
| | | downloadLink.setAttribute('download', "点位更换运维单位.xlsx"); // 设置下载文件的文件名 |
| | | downloadLink.style.display = 'none'; |
| | | // 添加到页面并触发下载 |
| | | document.body.appendChild(downloadLink); |
| | | downloadLink.click(); |
| | | document.body.removeChild(downloadLink); |
| | | this.download = false |
| | | }) |
| | | }, |
| | | cos(value) { |
| | | console.log(value) |
| | |
| | | }).catch(() => { |
| | | }); |
| | | }, |
| | | /** 导出按钮操作 */ |
| | | handleExport() { |
| | | this.download('x/point/export', { |
| | | ...this.queryParams |
| | | }, `point_${new Date().getTime()}.xlsx`) |
| | | } |
| | | } |
| | | }; |
| | | </script> |