lohir
2024-10-24 7d068e81ea1d88f708f096ea62c769452385612e
白名单导入
2个文件已修改
60 ■■■■■ 已修改文件
src/api/platform/threshold.js 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/work-order/threshold/index.vue 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/platform/threshold.js
@@ -85,3 +85,16 @@
    data: data
  })
}
// 导入
export function importData(data) {
  return request({
    url: '/threshold/import',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    timeout: 150000
  })
}
src/views/system/work-order/threshold/index.vue
@@ -312,6 +312,30 @@
    <el-row class="content-warp">
      <el-button size="small" type="success" @click="addOpen" plain>新增</el-button>
      <el-button size="small" type="danger" @click="bathDelete" plain>删除</el-button>
      <el-popover style="margin-left: 10px" placement="bottom" trigger="hover" content="导入点位">
        <div class="bottom_">
          <p>导入点位只做新增操作</p>
        </div>
        <div class="bottom_">
          <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 class="bottom_" type="primary" size="small" v-loading="upload" @click="handleImport"
                     v-hasPermi="['point:import']">导入</el-button>
        </div>
        <el-button type="primary" size="small" plain icon="el-icon-bottom" slot="reference" v-hasPermi="['point:import']">导入白名单</el-button>
      </el-popover>
    </el-row>
    <el-row class="content-warp">
      <el-col :span="24">
@@ -363,6 +387,7 @@
  listThreshold,
  getThreshold,
  updateThreshold,
  importData,
} from "@/api/platform/threshold";
import {
  editCar,
@@ -501,6 +526,11 @@
          {required: true, message: "设备编码不能为空", trigger: "blur"},
        ],
      },
      // 导入文件路径
      importUrl: '',
      fileList: [],
      importFile: null,
      upload: false,
    };
  },
  created() {
@@ -895,6 +925,23 @@
        this.$modal.msgSuccess("批量删除成功");
        this.ids = [];
      })
    },
    beforeUpload(file) {
      this.importFile = file
      this.fileList = [file]
      return false
    },
    // 导入白名单
    handleImport() {
      this.upload = true;
      let formData = new FormData()
      formData.append("file", this.importFile)
      importData(formData).then(res => {
        this.$message.success("导入成功")
        this.upload = false
        this.fileList = []
        this.getWhiteList()
      })
    }
  }
};