fuliqi
2024-10-24 f8331485341314c3d0613079d4981887a111568c
src/views/system/work-order/threshold/index.vue
@@ -284,6 +284,7 @@
      >
    </el-row>
    <el-row class="content-warp">
      <div class="header—text" style="margin-bottom: 5px">工单白名单</div>
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
        <el-form-item label="设备编码" prop="serialNumber">
          <el-input
@@ -309,8 +310,32 @@
      </el-form>
    </el-row>
    <el-row class="content-warp">
      <el-button size="small" type="success" @click="addOpen">新增</el-button>
      <el-button size="small" type="danger" @click="bathDelete">删除</el-button>
      <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">
@@ -362,6 +387,7 @@
  listThreshold,
  getThreshold,
  updateThreshold,
  importData,
} from "@/api/platform/threshold";
import {
  editCar,
@@ -500,6 +526,11 @@
          {required: true, message: "设备编码不能为空", trigger: "blur"},
        ],
      },
      // 导入文件路径
      importUrl: '',
      fileList: [],
      importFile: null,
      upload: false,
    };
  },
  created() {
@@ -894,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()
      })
    }
  }
};