| | |
| | | <!-- 设备总览 --> |
| | | <template> |
| | | <div class="role_manage"> |
| | | <div> |
| | | <el-form :model="entity" inline label-position="right"> |
| | | <el-form-item label="状态:"> |
| | | <el-select v-model="entity.deviceStatus" placeholder="全部" size="small" clearable> |
| | | <div style="display: flex;justify-content: space-between;margin-top: 10px;"> |
| | | <div style="display: flex;"> |
| | | <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;"> |
| | | <span style="width: 48px;font-size: 14px;font-weight: 700;color: #606266;">状态</span> |
| | | <el-select v-model="entity.deviceStatus" placeholder="全部" |
| | | @change="currentPage = 1, keyMap = {}, list = [], finishLoding = false, refreshTable()" |
| | | size="small" clearable> |
| | | <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="设备名称:"> |
| | | <el-input size="small" placeholder="请输入" clearable v-model="entity.deviceName"></el-input> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | </div> |
| | | <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;"> |
| | | <span style="width: 88px;font-size: 14px;font-weight: 700;color: #606266;">设备名称</span> |
| | | <el-input size="small" placeholder="请输入" clearable v-model="entity.deviceName" |
| | | @keyup.enter.native="currentPage = 1, keyMap = {}, list = [], finishLoding = false, refreshTable()"></el-input> |
| | | </div> |
| | | <div style="line-height: 30px;"> |
| | | <el-button size="mini" type="primary" @click="currentPage = 1, keyMap = {}, list = [], finishLoding = false, refreshTable()">查询</el-button> |
| | | <el-button size="mini" @click="refresh()">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-button size="mini" type="primary" @click="importVisible = true">导入</el-button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="table" v-loading="loading"> |
| | | <scroll-pagination @load="refreshTable()" :finishLoding="finishLoding" :list="list" |
| | |
| | | 暂无数据 |
| | | </div> |
| | | </div> |
| | | <el-dialog title="设备导入" :visible.sync="importVisible" width="500px" @closed="resetImport"> |
| | | <div style="margin-bottom: 12px;"> |
| | | 请使用设备导入模板填写数据,单个文件不超过10MB。 |
| | | <el-button type="text" @click="downloadTemplate">下载导入模板</el-button> |
| | | </div> |
| | | <el-upload ref="deviceUpload" drag name="file" accept=".xlsx" :action="importAction" |
| | | :headers="uploadHeader" :auto-upload="false" :limit="1" :file-list="importFiles" |
| | | :before-upload="beforeImport" :on-success="importSuccess" :on-error="importError"> |
| | | <i class="el-icon-upload"></i> |
| | | <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
| | | </el-upload> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="importVisible = false">取消</el-button> |
| | | <el-button type="primary" :loading="importing" @click="submitImport">导入</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | import ScrollPagination from '@/components/index/scroll-paging.vue' |
| | | import { |
| | | selectDeviceParameter, |
| | | downloadDeviceImportTemplate, |
| | | } from '@/api/cnas/resourceDemand/device.js' |
| | | export default { |
| | | props: { |
| | |
| | | finishLoding: false, // 加载完成,显示已经没有更多了 |
| | | keyMap: {}, |
| | | laboratoryNameIsNull: false, |
| | | importVisible: false, |
| | | importing: false, |
| | | importFiles: [], |
| | | } |
| | | }, |
| | | computed: { |
| | | importAction() { |
| | | return this.javaApi + '/deviceScope/importDevice' |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | this.clickSidebar(this.clickNodeVal) |
| | | }, |
| | | methods: { |
| | | downloadTemplate() { |
| | | downloadDeviceImportTemplate().then(res => { |
| | | this.$download.saveAs(new Blob([res]), '设备导入模板.xlsx') |
| | | }) |
| | | }, |
| | | submitImport() { |
| | | if (!this.$refs.deviceUpload.uploadFiles.length) { |
| | | this.$message.warning('请选择需要导入的Excel文件') |
| | | return |
| | | } |
| | | this.$refs.deviceUpload.submit() |
| | | }, |
| | | beforeImport(file) { |
| | | if (!file.name.toLowerCase().endsWith('.xlsx')) { |
| | | this.$message.error('仅支持.xlsx格式文件') |
| | | return false |
| | | } |
| | | if (file.size > 10 * 1024 * 1024) { |
| | | this.$message.error('导入文件不能超过10MB') |
| | | return false |
| | | } |
| | | this.importing = true |
| | | return true |
| | | }, |
| | | importSuccess(response) { |
| | | this.importing = false |
| | | if (response.code !== 200) { |
| | | this.$message.error(response.message || response.msg || '导入失败') |
| | | return |
| | | } |
| | | this.$message.success(`成功导入${response.data}条设备`) |
| | | this.importVisible = false |
| | | this.refresh() |
| | | this.$emit('refresh-tree') |
| | | }, |
| | | importError() { |
| | | this.importing = false |
| | | this.$message.error('导入失败') |
| | | }, |
| | | resetImport() { |
| | | this.importing = false |
| | | this.importFiles = [] |
| | | if (this.$refs.deviceUpload) { |
| | | this.$refs.deviceUpload.clearFiles() |
| | | } |
| | | }, |
| | | refreshTable() { |
| | | const key = `_${this.currentPage}` |
| | | const value = this.keyMap[key] |