<template>
  <section class="app-container">
    <el-row>
      <el-col :span="4">
        <region @selectdRegionCode="selectdRegionCode" :currentNodeKey.sync="queryParams.provinceCode"></region>
      </el-col>
      <el-col :span="20">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="名称">
            <el-input v-model="queryParams.deviceName" placeholder="请输入名称" clearable size="small" style="width: 240px"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="设备类型">
            <el-select v-model="queryParams.deviceType" clearable placeholder="请选择">
              <el-option v-for="item in deviceTypeList" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="cyan" 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 size="mini" type="primary" icon="el-icon-plus" @click="handleAdd" v-hasPermi="['system:device:save']">增加</el-button>
          </el-col>
          <el-col :span="1.5">
            <!-- <el-button type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
              v-hasPermi="['monitor:job:remove']">批量删除</el-button> -->
              <el-button type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
              v-hasPermi="['system:device:remove']">批量删除</el-button>
          </el-col>
          <!-- <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleClean" v-hasPermi="['monitor:job:remove']">清空
            </el-button>
          </el-col> -->
          <el-col :span="1.5">
            <el-button type="info" icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['system:device:import']">导入
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:device:export']">导出
            </el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center">
          </el-table-column>
          <el-table-column prop="deviceId" align="center" label="设备SN" min-width="200">
          </el-table-column>
          <el-table-column prop="deviceName" align="center" label="设备名称" min-width="150">
            <template slot-scope="scope">
              <el-link type="primary" :href="'./detail?id=' + scope.row.id "  target="_blank">{{scope.row.deviceName}}</el-link>
            </template>
          </el-table-column>
          <el-table-column prop="deviceType" align="center" label="类型">
            <template slot-scope="scope">{{getDeviceTypeLabel(scope.row.deviceType)}}</template>
            <!-- <template slot-scope="scope">{{scope.row.deviceType}}</template> -->
            <!-- <template slot-scope="scope">{{deviceTypeList.find(v=> v.value == scope.row.deviceType).label}}</template> -->
          </el-table-column>
          <el-table-column prop="productId" align="center" label="产品SN" min-width="200">
          </el-table-column>
          <!-- <el-table-column prop="deviceCode" align="center" label="设备编码">
          </el-table-column>
          <el-table-column prop="deviceType" align="center" label="类型">
          </el-table-column>
          <el-table-column prop="deviceModel" align="center" label="装置模型">
          </el-table-column> -->
          <el-table-column prop="proName" align="center" label="省份" min-width="80">
          </el-table-column>
          <el-table-column prop="cityName" align="center" label="市" min-width="80">
          </el-table-column>
          <el-table-column prop="disName" align="center" label="区" min-width="80">
          </el-table-column>
          <!-- <el-table-column prop="status" align="center" label="在线状态">
          </el-table-column> -->
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width"  min-width="250">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-plus" @click="handleAddnode(scope.row)" v-hasPermi="['system:product:add']">新增节点
              </el-button>
              <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:device:edit']">修改
              </el-button>
              <el-button size="mini" type="text" icon="el-icon-view" @click="handleview(scope.row)" v-hasPermi="['system:device:node:list']">查看节点
              </el-button>
              <el-button class="text-danger" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                v-hasPermi="['system:device: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-col>
    </el-row>
    <!-- 添加或修改参数配置对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item label="设备SN" prop="deviceId">
          <el-input :disabled="!!form.id" v-model="form.deviceId" placeholder="请输入设备SN" />
        </el-form-item>
        <el-form-item label="设备名称" prop="deviceName">
          <el-input v-model="form.deviceName" placeholder="请输入设备名称" />
        </el-form-item>
        <el-form-item label="设备类型" prop="deviceType">
          <el-select :disabled="!!form.id" v-model="form.deviceType" clearable placeholder="请选择">
            <el-option v-for="item in deviceTypeList" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="设备编码" prop="deviceCode">
          <el-input v-model="form.deviceCode" placeholder="请输入设备编码" />
        </el-form-item>
        <el-form-item label="设备类型" prop="deviceType">
          <el-input v-model="form.deviceType" placeholder="请输入设备类型" />
        </el-form-item>
        <el-form-item label="设备型号" prop="deviceModel">
          <el-input v-model="form.deviceModel" placeholder="请输入设备型号" />
        </el-form-item> -->
        <el-form-item label="产品" prop="productId">
          <el-select :disabled="!!form.id" v-model="form.productId" clearable placeholder="请选择">
            <el-option v-for="item in productSelectList" :key="item.id" :label="item.productName" :value="item.productId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="客户" prop="userId">
          <el-select :disabled="!!form.id" v-model="form.userId" clearable placeholder="请选择" @change="userIdChange">
            <el-option v-for="item in userSelectList" :key="item.id" :label="item.nickName" :value="item.userId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="项目" prop="projectId">
          <el-select :disabled="!!form.id" v-model="form.projectId" clearable placeholder="请选择">
            <el-option v-for="item in projectSelectList" :key="item.id" :label="item.projectName" :value="item.projectId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="国家行政区 省" prop="proCode">
          <el-select v-model="form.proCode" clearable placeholder="请选择" @change="provinceCodeChange">
            <el-option v-for="item in provinceSelectList" :key="item.code" :label="item.cityName" :value="item.code">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="国家行政区 市" prop="cityCode">
          <el-select v-model="form.cityCode" clearable placeholder="请选择" @change="cityCodeChange">
            <el-option v-for="item in citySelectList" :key="item.code" :label="item.cityName" :value="item.code">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="国家行政区 区" prop="disCode">
          <el-select v-model="form.disCode" clearable placeholder="请选择">
            <el-option v-for="item in districtSelectList" :key="item.code" :label="item.cityName" :value="item.code">
            </el-option>
          </el-select>
        </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>

    <!-- 节点列表弹框 -->
    <el-dialog title="节点列表" :visible.sync="nodeDialog">
      <!-- <el-row class="mb8">
        <el-button type="danger" icon="el-icon-delete" size="mini" :disabled="nodeMultiple" @click="batchHandleDeletenode">批量删除</el-button>
      </el-row> -->
      <!-- <el-button type="danger" icon="el-icon-delete" size="mini" :disabled="nodeMultiple" @click="batchHandleDeletenode">批量删除</el-button> -->
      <el-table :data="nodeData" @selection-change="nodeHandleSelectionChange">
        <!-- <el-table-column type="selection" width="55" align="center">
        </el-table-column> -->
        <el-table-column align="center" prop="deviceId" label="设备SN"></el-table-column>
        <el-table-column align="center" prop="nodeId" label="节点SN"></el-table-column>
        <el-table-column align="center" prop="nowVersion" label="节点版本"></el-table-column>
        <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdatenode(scope.row)">修改</el-button>
            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleInitNode(scope.row)">初始化</el-button>
            <el-button class="text-danger" size="mini" type="text" icon="el-icon-delete" @click="handleDeletenode(scope.row)">删除</el-button>
          </template>
        </el-table-column> -->
      </el-table>
    </el-dialog>

    <!-- 添加节点参数配置对话框 -->
    <el-dialog :title="title" :visible.sync="nodeOpen" width="500px" append-to-body>
      <el-form ref="nodeForm" :model="nodeForm" :rules="nodeRules" label-width="100px">
        <el-form-item label="设备SN" prop="deviceId">
          <el-input v-model="nodeForm.deviceId" disabled placeholder="请输入设备SN" />
        </el-form-item>
        <el-form-item label="产品节点" prop="nodeId">
          <el-select style="width:100%" v-model="nodeForm.nodeId" :disabled="!!nodeForm.id" clearable placeholder="请选择">
            <el-option  v-for="item in productNodeSelectList" :key="item.id" :label="item.nodeName + '('+ item.nodeSn +')'" :value="item.nodeSn">
            </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="节点SN" prop="nodeId">
          <el-input v-model="nodeForm.nodeId" placeholder="请输入节点SN" />
        </el-form-item> -->
        <el-form-item label="初始版本" prop="nowVersion">
          <el-input v-model="nodeForm.nowVersion" placeholder="请输入节点初始版本" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="saveNode">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </section>
</template>

<script>
import Region from "@/components/Region";
import {
  list,
  info,
  add,
  update,
  del,
  saveDeviceFirmware,
  exportEquipment,
  importTemplate
} from "@/api/hardware/device";
// import { nodeList, addNode, nodeInfo, delNode, nodeSelect } from "@/api/system/device/node";
import { select as productSelect } from "@/api/hardware/product";
import { select as projectSelect } from "@/api/hardware/project";
import { userSelect } from "@/api/system/user";
import { list as provinceList, getProvinceByParent } from "@/api/hardware/province";
import { productNodeList, productNodeSelect } from "@/api/hardware/productNode";
import { deviceNodeList, deviceNodeSave, deviceNodeInfo, deviceNodeDel, deviceNodeSelect } from "@/api/hardware/deviceNode";
import { getToken } from "@/utils/auth";
export default {
  name: "DeviceList",
  components: {
    Region,
  },
  // watch: {
  //   'form.proCode': function(code) {
  //     this.provinceCodeChange(code)
  //   },
  //   'form.cityCode': function(code) {
  //     this.cityCodeChange(code)
  //   },
  // },
  data () {
    return {
      snapDeviceInfo: {},
      // 产品下拉列表
      productSelectList: [],
      userSelectList: [],
      projectSelectList: [],
      provinceSelectList: [],
      citySelectList: [],
      districtSelectList: [],
      productNodeSelectList: [],
      deviceTypeList: [
        { 'label': '锐能设备', 'value': 'rn', },
        { 'label': '铁塔设备', 'value': 'tt', },
      ],
      // 选中数组
      ids: [],
      nodeIds: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      nodeMultiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      nodeDialog: false,
      nodeOpen: false,
      // 表单参数
      form: {},
      nodeForm: {},
      // 表格数据
      tableData: [],
      nodeData: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/system/device/importData"
      },
      rules: {
        deviceId: [
          { required: true, message: "设备SN不能为空", trigger: "blur" },
        ],
        deviceName: [
          { required: true, message: "设备名称不能为空", trigger: "blur" },
        ],
        deviceType: [
          { required: true, message: "设备编码不能为空", trigger: "blur" },
        ],
        productId: [
          { required: true, message: "产品不能为空", trigger: "blur" },
        ],
        userId: [
          { required: true, message: "客户不能为空", trigger: "blur" },
        ],
        projectId: [
          { required: true, message: "项目不能为空", trigger: "blur" },
        ],
        proCode: [
          { required: true, message: "省不能为空", trigger: "blur" },
        ],
        cityCode: [
          { required: true, message: "市不能为空", trigger: "blur" },
        ],
        disCode: [
          { required: true, message: "区不能为空", trigger: "blur" },
        ],
      },
      nodeRules: {
        nodeId: [
          { required: true, message: "节点不能为空", trigger: "blur" },
        ],
        deviceId: [
          { required: true, message: "设备SN不能为空", trigger: "blur" },
        ],
        nowVersion: [
          { required: true, message: "节点初始版本不能为空", trigger: "blur" },
        ],
      }
    };
  },
  created () {
    productSelect().then(({ code, msg, select }) => {
      if (code == 200) {
        this.productSelectList = select;
      } else {
        this.$message.error(msg);
      }
    })
    userSelect().then(({ code, msg, select }) => {
      if (code == 200) {
        this.queryUserSelectList = select;
        this.userSelectList = select;
      } else {
        this.$message.error(msg);
      }
    })
    provinceList().then(({ code, msg, rows }) => {
      if (code == 200) {
        this.provinceSelectList = rows;
      } else {
        this.$message.error(msg);
      }
    })
    this.getList();
  },
  methods: {
    /** 导出按钮操作 */
    handleExport () {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有用户数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return exportEquipment(queryParams);
      }).then(response => {
        this.download(response.msg);
      })
    },
    /** 导入按钮操作 */
    handleImport () {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate () {
      importTemplate().then(response => {
        this.download(response.msg);
      });
    },
    // 文件上传中处理
    handleFileUploadProgress (event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess (response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm () {
      this.$refs.upload.submit();
    },

    getDeviceTypeLabel (deviceType) {
      let snap = '';
      this.deviceTypeList.map(v => {
        if (v.value == deviceType) {
          snap = v.label;
        }
      })
      return snap;
    },
    selectdRegionCode ({ code }) {
      this.queryParams.provinceCode = code;
      this.handleQuery();
    },
    userIdChange (userId) {
      delete this.form.projectId;
      this.projectSelectList = [];
      if (!userId) return;
      projectSelect({ userId }).then(({ code, msg, select }) => {
        if (code == 200) {
          this.projectSelectList = select;
        } else {
          this.$message.error(msg);
        }
      })
    },
    getProvinceByParent (id) {
      return new Promise((resolve, reject) => {
        getProvinceByParent(id).then(({ code, msg, data }) => {
          if (code == 200) {
            resolve(data);
          } else {
            this.$message.error(msg);
            reject({ msg, code })
          }
        }).catch(error => {
          reject(error)
        })
      })
    },
    async provinceCodeChange (id) {
      delete this.form.cityCode;
      delete this.form.disCode;
      this.citySelectList = await this.getProvinceByParent(id);
    },
    async cityCodeChange (id) {
      delete this.form.disCode;
      this.districtSelectList = await this.getProvinceByParent(id);
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.queryParams = {};
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 获取设备数据列表
    getList () {
      list(this.queryParams).then((response) => {
        this.tableData = response.rows;
        this.total = response.total;
      });
    },

    // 获取节点数据列表
    getListnode ({ deviceId }) {
      deviceNodeList({ deviceId }).then((response) => {
        this.nodeData = response.rows;
      });
    },

    // 取消按钮
    cancel () {
      this.open = false;
      this.nodeOpen = false;
      this.reset();
    },

    // 表单重置
    reset () {
      this.form = {
        deviceId: "",
        deviceType: "",
        deviceName: "",
        status: "0",
      };
      this.nodeForm = {
        nodeId: "",
        deviceId: "",
      };
      this.resetForm("form");
      this.resetForm("nodeForm");
    },

    // 多选框选中数据
    handleSelectionChange (selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },

    // 节点多选框选中数据
    nodeHandleSelectionChange (selection) {
      this.nodeIds = selection.map((item) => item.id);
      this.nodeMultiple = !selection.length;
    },

    /** 新增按钮操作 */
    handleAdd () {
      this.reset();
      this.open = true;
      this.title = "添加设备";
    },

    // 新增节点
    handleAddnode (row) {
      productNodeSelect({ productId: row.productId }).then(({ code, msg, select }) => {
        if (code == 200) {
          this.productNodeSelectList = select;
        } else {
          this.$message.error(msg);
        }
      })
      this.reset();
      this.nodeOpen = true;
      this.title = "添加设备节点";
      this.nodeForm.deviceId = row.deviceId;
    },

    // 查看节点
    handleview (row) {
      this.nodeDialog = true;
      this.snapDeviceInfo = row;
      this.getListnode(row)
    },

    /** 修改按钮操作 */
    handleUpdate (row) {
      this.reset();
      info(row.id).then(({ code, info, msg }) => {
        if (200 == code) {
          this.provinceCodeChange(info.proCode);
          this.cityCodeChange(info.cityCode);
          this.form = info;
          this.open = true;
          this.title = "修改设备";
        } else {
          this.msgError(msg);
        }
      })
    },

    /** 修改节点 */
    handleUpdatenode (row) {
      this.reset();
      productNodeSelect({ productId: this.snapDeviceInfo.productId }).then(({ code, msg, select }) => {
        if (code == 200) {
          this.productNodeSelectList = select;
        } else {
          this.$message.error(msg);
        }
      })
      this.nodeOpen = true;
      this.title = "修改设备节点";
      this.nodeForm = Object.assign({}, row);
    },

    handleInitNode ({ deviceId, nodeId }) {
      this.$prompt('请输入初始化版本号', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        // inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
        // inputErrorMessage: '邮箱格式不正确'
      }).then(({ value }) => {
        saveDeviceFirmware({ deviceId, nodeId, nowVersion: value }).then(({ code, msg }) => {
          if (200 == code) {
            this.msgSuccess(msg);
            this.getListnode({ deviceId });
          } else {
            this.msgError(msg);
          }
        })
      }).catch(() => {
      });
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          // debugger
          if (this.form.id != undefined) {
            update(this.form).then(res => {
              if (200 == res.code) {
                this.msgSuccess(this.title + "成功");
                this.open = false;
                this.getList();
              } else {
                this.msgError(res.msg);
              }

            });
          } else {
            add(this.form).then(res => {
              if (200 == res.code) {
                this.msgSuccess(this.title + "成功");
                this.open = false;
                this.getList();
              } else {
                this.msgError(res.msg);
              }
            });
          }
        }
      });
    },

    // 节点提交
    saveNode: function () {
      deviceNodeSave(this.nodeForm).then((res) => {
        if (200 == res.code) {
          let msgDict = {
            '-1': '存在节点，无法添加',
            '0': '添加失败',
            '1': '添加成功',
          }
          this.msgSuccess(msgDict[res.result]);
          this.nodeOpen = false;
          this.getList();
        } else {
          this.msgError(res.msg);
        }
      });
    },

    /** 删除按钮操作 */
    handleDelete (row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        return del(ids);
      }).catch(() => { }).then(res => {
        if (200 == res.code) {
          this.getList();
          this.msgSuccess("删除成功");
        } else {
          this.msgError(res.msg);
        }
      }).catch(res => { })
    },

    handleDeletenode (row) {
      const ids = row.id || this.ids;
      this.$confirm("是否确认删除?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return deviceNodeDel(ids);
        })
        .then((res) => {
          if (200 == res.code) {
            this.getListnode(row);
            this.msgSuccess("删除成功");
          } else {
            this.msgError(res.msg);
          }
        })
        .catch((res) => { });
    },
    // 批量删除节点
    batchHandleDeletenode () {
      this.$confirm("是否确认删除?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return deviceNodeDel(this.nodeIds);
        })
        .then((res) => {
          if (200 == res.code) {
            this.getListnode(...this.nodeData);
            this.msgSuccess("删除成功");
          } else {
            this.msgError(res.msg);
          }
        })
        .catch((res) => { });
    },

    // 页码尺寸改变
    handleSizeChange (val) {
      this.queryForm.pagesize = val;
      this.getList();
    },
    // 页码改变
    handleCurrentChange (val) {
      this.queryForm.page = val;
      this.getList();
    },
    // handleSelectionChange(val) {
    //   this.multipleSelection = val;
    // },
    handleSizeChange (val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange (val) {
      console.log(`当前页: ${val}`);
    },
    // 对话框的关闭
    handleClose (done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => { });
    },
  },
};
</script>


<style></style>
