index.vue 20.9 KB
Newer Older
冯超鹏's avatar
冯超鹏 committed
1
<template>
冯超鹏's avatar
冯超鹏 committed
2 3 4
  <div class="app-container">
    <div class="filter-container">
      <el-form ref="query" :model="deviceSearch" style="display: inline-block;">
冯超鹏's avatar
冯超鹏 committed
5
        <el-input v-model="deviceSearch.deviceName" placeholder="设备编号" style="width: 200px;" class="filter-item" name="userskk" />
冯超鹏's avatar
冯超鹏 committed
6 7 8
        <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleSubmit">
          {{ $t('table.search') }}
        </el-button>
冯超鹏's avatar
冯超鹏 committed
9 10 11
        <el-button v-waves class="filter-item" type="primary" icon="el-icon-plus" @click="addDevice">
          {{ $t('table.add') }}
        </el-button>
冯超鹏's avatar
冯超鹏 committed
12 13 14 15
      </el-form>
      <el-button v-if="device != '' " v-waves :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">
        {{ $t('table.export') }}
      </el-button>
冯超鹏's avatar
冯超鹏 committed
16
      <el-badge v-if="paper > 0" :value="paper" class="item" style="margin-bottom: 8px;">
冯超鹏's avatar
冯超鹏 committed
17
        <el-button size="small" @click="pucharray">
冯超鹏's avatar
冯超鹏 committed
18 19 20
          <svg-icon class-name="custom-class" icon-class="feizhilou" />废纸篓
        </el-button>
      </el-badge>
冯超鹏's avatar
冯超鹏 committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
    </div>
    <el-tabs v-model="activeName" stretch @tab-click="handleClick">
      <el-tab-pane v-for="item in list" :key="item.tid" :label="item.tname" :tid="item.tid" :name="item.tid==1 ? 'second' : list.tid"></el-tab-pane>
    </el-tabs>
    <el-table :key="tableKey" v-loading="loading" :data="device" border fit highlight-current-rows>
      <el-table-column align="center" label="id" width="80">
        <template slot-scope="scope">
          <span style="color: #409EFF;" @click="deviceinfo(scope.row.id)">{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="设备编号" width="150">
        <template slot-scope="scope">
          <span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="设备类型" width="150">
        <template slot-scope="scope">
          <span>{{ scope.row.tname }}</span>
        </template>
      </el-table-column>
冯超鹏's avatar
冯超鹏 committed
41 42 43 44 45
      <el-table-column align="center" label="用户名称" width="150">
        <template slot-scope="scope">
          <span>{{ scope.row.usernickname }}</span>
        </template>
      </el-table-column>
冯超鹏's avatar
冯超鹏 committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
      <el-table-column align="center" label="介质状态" width="170">
        <template slot-scope="scope">
          <span>{{ scope.row.gas }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="设备名称" width="170">
        <template slot-scope="scope">
          <span>{{ scope.row.username }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="浓度" width="170">
        <template slot-scope="scope">
          <span>{{ scope.row.nd }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="是否已删除设备" width="170">
        <template slot-scope="scope">
冯超鹏's avatar
冯超鹏 committed
63
          <span :style="{color:( scope.row.delete==1 ? '#F56C6C' : '#67C23A' )}">{{ scope.row.delete ==1 ? '设备已被丢弃废纸篓' : '设备正常' }}</span>
冯超鹏's avatar
冯超鹏 committed
64 65 66 67 68 69 70 71 72 73 74 75
        </template>
      </el-table-column>
      <el-table-column align="center" label="设备备注" width="170">
        <template slot-scope="scope">
          <span>{{ scope.row.deviceremark }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="设备详情" width="170">
        <template slot-scope="scope">
          <span>{{ scope.row.deviceinfo }}</span>
        </template>
      </el-table-column>
Administrator's avatar
Administrator committed
76
      <el-table-column align="center" label="IP地址" width="170">
冯超鹏's avatar
冯超鹏 committed
77 78 79 80
        <template slot-scope="scope">
          <span @click="handleCopy(scope.row.ipaddr,$event)">{{ scope.row.ipaddr }}</span>
        </template>
      </el-table-column>
冯超鹏's avatar
冯超鹏 committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94
      <el-table-column align="center" label="创建时间" width="170">
        <template slot-scope="scope">
          <span>{{ scope.row.deviceaddtime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="设备实时状态" width="170">
        <template slot-scope="scope">
          <span>
            <el-tag :type=" scope.row.status_name=='正常' ? 'success' : 'warning' " effect="dark">{{ scope.row.status_name }}</el-tag>
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="状态" width="170">
        <template slot-scope="scope">
冯超鹏's avatar
冯超鹏 committed
95 96
          <span v-if="scope.row.status_name=='正常' " :style="{color:( scope.row.devicestatus==1 ? '#67C23A' : '#F56C6C' )}">{{ scope.row.devicestatus==1 ? '正常' : '设备错误' }}</span>
          <span v-if="scope.row.status_name!='正常' " :style="{color:( scope.row.status_name=='正常' ? '#67C23A' : '#F56C6C' )}">{{ scope.row.status_name=='正常' ? '正常' : '设备异常' }}</span>
冯超鹏's avatar
冯超鹏 committed
97 98
        </template>
      </el-table-column>
冯超鹏's avatar
冯超鹏 committed
99
      <el-table-column align="center" label="操作" width="300px">
冯超鹏's avatar
冯超鹏 committed
100 101
        <template slot-scope="scope">
          <el-popover width="160" trigger="click" placement="top">
冯超鹏's avatar
冯超鹏 committed
102
            <p>此操作,分丢弃废纸篓,和删除设备</p>
冯超鹏's avatar
冯超鹏 committed
103 104
            <div style="text-align: right; margin: 0">
              <el-button v-if="scope.row.delete==2" size="mini" type="text" @click="deviceDelete(scope.row.id, 1)">丢弃废纸篓</el-button>
冯超鹏's avatar
冯超鹏 committed
105
              <el-button type="text" size="mini" @click="deviceDelete(scope.row.id, 2)">删除设备</el-button>
冯超鹏's avatar
冯超鹏 committed
106 107 108
            </div>
            <el-button slot="reference" size="mini" type="danger" :disabled="scope.row.delete == 1 ? true : (scope.row.devicestatus > 1 ? true : false) ">操作</el-button>
          </el-popover>
1431670879@qq.com's avatar
1431670879@qq.com committed
109 110
          <el-button slot="reference" size="mini" type="primary" :disabled="scope.row.delete == 1 ? true : (scope.row.devicestatus > 1 ? true : false)" @click="contactsuser(scope.row.id)">添加联系人</el-button>
          <el-button slot="reference" size="mini" type="primary" :disabled="scope.row.delete == 1 ? true : (scope.row.devicestatus > 1 ? true : false)" @click="updatedevice(scope.row.id)">编辑设备</el-button>
冯超鹏's avatar
冯超鹏 committed
111 112
        </template>
      </el-table-column>
冯超鹏's avatar
冯超鹏 committed
113
    </el-table>
冯超鹏's avatar
冯超鹏 committed
114
    <pagination v-show="total>0" :total="total" :page.sync="page" :limit.sync="limit" @pagination="devicelist" />
冯超鹏's avatar
冯超鹏 committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135

    <el-dialog :visible.sync="dialogPvVisible" title="设备详情信息" width="50%">
      <el-table :data="devicefistr">
        <el-table-column type="expand">
          <template>
            <el-form v-for="item in deviceDataInfo" :key="item.id" label-position="left" inline class="demo-table-expand">
              <el-form-item label="姓名">
                <span>{{ item.contacts_name }}</span>
              </el-form-item>
              <el-form-item label="手机号">
                <span @click="handleCopyphone(item.contacts_phone,$event)">{{ item.contacts_phone }}</span>
              </el-form-item>
              <el-form-item label="添加用户">
                <span>{{ item.isadmin==1 ? '管理员' : '用户' }}</span>
              </el-form-item>
              <el-form-item label="状态">
                <span :style="{color:( item.isstatus==1 ? '#67C23A' : '#F56C6C' )}">{{ item.isstatus==1 ? '开启' : '禁用' }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
Administrator's avatar
Administrator committed
136
        <el-table-column label="设备UUID" prop="deviceuuid" width="380px"></el-table-column>
冯超鹏's avatar
冯超鹏 committed
137 138 139 140
        <el-table-column label="设备联系人" prop="devicelinkman"></el-table-column>
        <el-table-column label="设备手机号" prop="devicephone"></el-table-column>
      </el-table>
    </el-dialog>
冯超鹏's avatar
冯超鹏 committed
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
    <el-drawer title="添加联系人" :visible.sync="drawer" :direction="direction" :before-close="handleClose">
      <el-card class="box-card">
        <el-form ref="contactsdata" :model="contactsdata" label-width="80px">
          <el-form-item label="联系人名称" label-width="92px">
            <el-input v-model="contactsdata.contacts_name" style="width: 80%;"></el-input>
          </el-form-item>
          <el-form-item label="联系人手机号" label-width="100px">
            <el-input v-model="contactsdata.contacts_phone" style="width: 80%;"></el-input>
          </el-form-item>
          <el-form-item label="人员状态">
            <el-radio-group v-model="contactsdata.isstatus">
              <el-radio label="开启"></el-radio>
              <el-radio label="禁用"></el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="oncontacts">立即创建</el-button>
            <el-button @click="handleClose">取消</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </el-drawer>
Administrator's avatar
Administrator committed
163 164 165 166 167 168 169
    <el-drawer
      title="编辑设备"
      :visible.sync="drawerup"
      :direction="directionup"
      :before-close="handleCloseup"
      custom-class="zl-drawer"
    >
冯超鹏's avatar
冯超鹏 committed
170 171
      <el-card class="box-card">
        <el-form ref="updevicedata" :model="updevicedata" label-width="80px">
Administrator's avatar
Administrator committed
172
          <el-form-item label="设备编号" label-width="100px">
冯超鹏's avatar
冯超鹏 committed
173 174
            <el-input v-model="updevicedata.devicenum" :disabled="disabled" style="width: 80%;"></el-input>
          </el-form-item>
Administrator's avatar
Administrator committed
175
          <el-form-item label="用户名称" label-width="100px">
冯超鹏's avatar
冯超鹏 committed
176 177
            <el-input v-model="updevicedata.name" :disabled="disabled" style="width: 80%;"></el-input>
          </el-form-item>
Administrator's avatar
Administrator committed
178
          <el-form-item label="设备名称" label-width="100px">
冯超鹏's avatar
冯超鹏 committed
179 180 181
            <el-input v-model="updevicedata.username" style="width: 80%;"></el-input>
          </el-form-item>
          <el-form-item label="设备坐标" label-width="100px">
Administrator's avatar
Administrator committed
182
            <el-input v-model="updevicedata.devicecoord" style="width:50%"></el-input>
Administrator's avatar
Administrator committed
183
            <el-button type="primary" @click="drawerMap = true">
Administrator's avatar
Administrator committed
184 185
              拾取坐标
            </el-button>
冯超鹏's avatar
冯超鹏 committed
186 187 188 189 190 191 192 193 194 195 196 197 198
          </el-form-item>
          <el-form-item label="设备联系人" label-width="100px">
            <el-input v-model="updevicedata.devicelinkman" style="width: 80%;"></el-input>
          </el-form-item>
          <el-form-item label="设备手机号" label-width="100px">
            <el-input v-model="updevicedata.devicephone" style="width: 80%;"></el-input>
          </el-form-item>
          <el-form-item label="设备备注" label-width="100px">
            <el-input v-model="updevicedata.deviceremark" style="width: 80%;"></el-input>
          </el-form-item>
          <el-form-item label="设备安装位置" label-width="100px">
            <el-input v-model="updevicedata.deviceinfo" style="width: 80%;"></el-input>
          </el-form-item>
Administrator's avatar
Administrator committed
199
          <el-form-item v-if="checkPermission(['manage isadmin'])" label="选择用户" label-width="100px">
冯超鹏's avatar
冯超鹏 committed
200 201 202 203
            <el-select v-model="updevicedata.uid" placeholder="请选择用户">
              <el-option v-for="item in addUserDevice" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
Administrator's avatar
Administrator committed
204
          <el-form-item label="选择分类" label-width="100px">
冯超鹏's avatar
冯超鹏 committed
205 206 207 208
            <el-select v-model="updevicedata.tid" placeholder="请选择分类">
              <el-option v-for="item in list" :key="item.id" :label="item.tname" :value="item.tid"></el-option>
            </el-select>
          </el-form-item>
Administrator's avatar
Administrator committed
209
          <el-form-item label="介质/单位" label-width="100px">
冯超鹏's avatar
冯超鹏 committed
210 211 212
            <el-select v-model="updevicedata.status" placeholder="请选择介质">
              <el-option v-for="item in gas" :key="item.id" :label="item.gas" :value="item.id"></el-option>
            </el-select>
Administrator's avatar
Administrator committed
213 214 215
            <el-select v-model="updevicedata.devicemonad" placeholder="请选择单位">
              <el-option v-for="item in danwei" :key="item.id" :label="item.danwei" :value="item.id"></el-option>
            </el-select>
冯超鹏's avatar
冯超鹏 committed
216
          </el-form-item>
冯超鹏's avatar
冯超鹏 committed
217 218 219 220 221 222
          <el-form-item>
            <el-button type="primary" @click="updedata">立即更新</el-button>
            <el-button @click="handleCloseup">取消</el-button>
          </el-form-item>
        </el-form>
      </el-card>
Administrator's avatar
Administrator committed
223 224 225
      <el-drawer title="拾取坐标" :visible.sync="drawerMap" :modal="false" :direction="directionMap" :before-close="handleClose" size="70%" :with-header="false">
        <div><CoordinateMap @map-confirm="mapConfirmData" @giveLnglat="getLnglat"></CoordinateMap></div>
      </el-drawer>
冯超鹏's avatar
冯超鹏 committed
226
    </el-drawer>
冯超鹏's avatar
冯超鹏 committed
227
  </div>
冯超鹏's avatar
冯超鹏 committed
228 229 230
</template>

<script>
冯超鹏's avatar
冯超鹏 committed
231
import { deviceTypeList, deviceList, deviceDataInfo, deviceDataSearch, addUserDevice, deviceBasket, deviceDelete, addcontactsuser, postupdatedevice, updedata } from '@/api/device';
冯超鹏's avatar
冯超鹏 committed
232 233 234 235
import Pagination from '@/components/Pagination'; // 分页
import waves from '@/directive/waves'; // 水波纹效果
import clip from '@/utils/clipboard';
import { parseTime } from '@/utils';
冯超鹏's avatar
冯超鹏 committed
236
import checkPermission from '@/utils/permission';
Administrator's avatar
Administrator committed
237
import CoordinateMap from '@/components/coordinateMap';
冯超鹏's avatar
冯超鹏 committed
238 239
export default {
  name: 'Devicetype',
Administrator's avatar
Administrator committed
240
  components: { Pagination, CoordinateMap },
冯超鹏's avatar
冯超鹏 committed
241 242 243
  directives: { waves },
  data() {
    return {
Administrator's avatar
Administrator committed
244 245
      drawerMap: false,
      directionMap: 'rtl',
冯超鹏's avatar
冯超鹏 committed
246 247 248 249 250 251
      tableKey: 0,
      downloadLoading: false,
      pvData: [],
      dialogPvVisible: false,
      activeName: 'second',
      list: [],
冯超鹏's avatar
冯超鹏 committed
252 253
      danwei: [],
      gas: [],
冯超鹏's avatar
冯超鹏 committed
254 255 256 257
      loading: true,
      device: [],
      deviceDataInfo: [],
      devicefistr: [],
冯超鹏's avatar
冯超鹏 committed
258
      addUserDevice: [],
冯超鹏's avatar
冯超鹏 committed
259 260 261 262 263 264 265 266 267
      page: 1,
      deviceSearch: {
        deviceName: '',
        limit: 10,
        page: 1,
      },
      limit: 10,
      type: '',
      total: 0,
冯超鹏's avatar
冯超鹏 committed
268
      paper: undefined,
冯超鹏's avatar
冯超鹏 committed
269
      drawer: false,
冯超鹏's avatar
冯超鹏 committed
270
      disabled: true,
冯超鹏's avatar
冯超鹏 committed
271
      direction: 'rtl',
冯超鹏's avatar
冯超鹏 committed
272 273
      drawerup: false,
      directionup: 'ltr',
冯超鹏's avatar
冯超鹏 committed
274 275 276 277 278 279
      contactsdata: {
        contactsid: undefined,
        contacts_name: undefined,
        contacts_phone: undefined,
        isstatus: undefined,
      },
冯超鹏's avatar
冯超鹏 committed
280 281
      updevicedata: {},
      deid: undefined,
冯超鹏's avatar
冯超鹏 committed
282 283 284 285 286
    };
  },
  created() {
    this.getList(); // 设备状态
    this.devicelist();
冯超鹏's avatar
冯超鹏 committed
287
    this.deviceBasket();
冯超鹏's avatar
冯超鹏 committed
288 289 290
  },

  methods: {
Administrator's avatar
Administrator committed
291 292 293 294 295 296 297 298 299 300 301 302
    mapConfirmData(text) {
      if (text.state === true) {
        this.updevicedata.devicecoord = text.location;
        this.drawerMap = false;
      }
      if (text.state === false) {
        this.drawerMap = false;
      }
    },
    getLnglat(lnglnt) {
      console.log(lnglnt);
    },
冯超鹏's avatar
冯超鹏 committed
303
    checkPermission,
冯超鹏's avatar
冯超鹏 committed
304 305 306 307 308
    getList() {
      deviceTypeList()
        .then(response => {
          var devicetype = response.data;
          this.list = devicetype['devicetype'];
冯超鹏's avatar
冯超鹏 committed
309 310
          this.danwei = devicetype['danwei'];
          this.gas = devicetype['gas'];
冯超鹏's avatar
冯超鹏 committed
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
        })
        .catch(err => {
          console.log(err);
        });
    },
    devicelist() {
      const limit = this.limit;
      const page = this.page;
      this.loading = true;
      deviceList(page, limit, this.type)
        .then(response => {
          var devicetype = response.data['devicelist'];
          this.device = devicetype;
          this.device.forEach((element, index) => {
            element['index'] = (page - 1) * limit + index + 1;
          });
          this.total = response.data.count;
          this.loading = false;
        })
        .catch(err => {
          console.log(err);
        });
    },
    handleClick(tab) {
      this.type = tab.$attrs.tid;
      this.devicelist();
    },
    handleCopy(text, event) {
      clip(text, event);
    },
冯超鹏's avatar
冯超鹏 committed
341 342 343 344
    // 跳转废纸废纸篓
    pucharray() {
      this.$router.push({ path: '/device/DeviceStutus' });
    },
冯超鹏's avatar
冯超鹏 committed
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
    deviceinfo(row) {
      this.dialogPvVisible = true;
      this.deviceData(row);
    },
    deviceData(id){
      deviceDataInfo(id)
        .then(response => {
          var deviceData = response.data['devicedata'];
          this.deviceDataInfo = deviceData;
          this.devicefistr = response.data['devicedatainfo'];
        })
        .catch(err => {
          console.log(err);
        });
    },
    handleCopyphone(text, event){
      clip(text, event);
    },
冯超鹏's avatar
冯超鹏 committed
363 364 365 366
    // 添加设备
    addDevice() {
      this.$router.push({ path: '/device/addDevice' });
    },
冯超鹏's avatar
冯超鹏 committed
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
    handleDownload() {
      this.downloadLoading = true;
      import('@/vendor/Export2Excel').then(excel => {
        const tHeader = ['id', '设备编号', '设备名称', '设备类型', '介质状态', '设备备注', '添加时间', '设备实时状态', '是否已删除设备'];
        const filterVal = ['id', 'devicenum', 'username', 'tname', 'gas', 'deviceremark', 'deviceaddtime', 'status_name', 'delete'];
        const data = this.formatJson(filterVal, this.device);
        excel.export_json_to_excel({
          header: tHeader,
          data,
          filename: '设备列表',
        });
        this.downloadLoading = false;
      });
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map(v => filterVal.map(j => {
        if (j === 'deviceaddtime') {
          return parseTime(v[j]);
        } else if (j === 'delete') {
          return v[j] === 1 ? '已删除' : '正常';
        } else {
          return v[j];
        }
      }));
    },
    handleSubmit() {
      deviceDataSearch(this.deviceSearch)
        .then(response => {
          if (response.code === 105) {
            this.$message({
              message: response.msg,
              type: 'warning',
            });
            this.devicelist();
          }
          var deviceData = response.data['devicelist'];
          this.device.forEach((element, index) => {
            element['index'] = (this.deviceSearch.page - 1) * this.deviceSearch.limit + index + 1;
          });
          this.device = deviceData;
          this.total = response.data.count;
        })
        .catch(err => {
          console.log(err);
        });
    },
冯超鹏's avatar
冯超鹏 committed
413 414 415 416 417 418 419 420 421 422
    // 获取废纸篓数量
    deviceBasket() {
      deviceBasket()
        .then(response => {
          this.paper = response.data;
        })
        .catch(err => {
          console.log(err);
        });
    },
冯超鹏's avatar
冯超鹏 committed
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
    contactsuser(id) {
      const deviceid = id;
      this.drawer = true; // 打开抽屉
      this.contactsdata.contactsid = deviceid;
    },
    handleClose(done) {
      this.drawer = false; // 关闭抽屉
      this.contactsdata.contacts_name = undefined;
      this.contactsdata.contacts_phone = undefined;
      this.contactsdata.contactsid = undefined;
      this.contactsdata.isstatus = undefined;
    },
    oncontacts() {
      if (this.contactsdata.contacts_name === undefined) {
        this.$message({
          message: '联系人名称不能为空',
          type: 'warning',
        });
      } else if (this.contactsdata.contacts_phone === undefined) {
        this.$message({
          message: '联系人手机号不能为空',
          type: 'warning',
        });
      } else if (this.contactsdata.isstatus === undefined) {
        this.$message({
          message: '请选择用户状态',
          type: 'warning',
        });
      } else {
        this.contactsdata.isstatus === '开启' ? this.contactsdata.isstatus = 1 : this.contactsdata.isstatus = 2;
        addcontactsuser(this.contactsdata)
          .then(response => {
            this.$message({
              message: '添加成功',
              type: 'success',
            });
            this.handleClose();
          })
          .catch(err => {
            console.log(err);
          });
      }
    },
冯超鹏's avatar
冯超鹏 committed
466
    deviceDelete(id, type) {
冯超鹏's avatar
冯超鹏 committed
467
      this.$confirm('是否将设备丢弃', '提示', {
冯超鹏's avatar
冯超鹏 committed
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        deviceDelete(id, type)
          .then(response => {
            this.getList();
            this.devicelist();
            this.deviceBasket();
          })
          .catch(err => {
            console.log(err);
          });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消',
        });
      });
    },
冯超鹏's avatar
冯超鹏 committed
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
    // 编辑设备
    updatedevice(id) {
      const deviceid = id;
      this.drawerup = true; // 打开抽屉
      this.postupdatedevice(deviceid);
      this.addUserDevices();
      this.deid = deviceid;
    },
    // 关闭
    handleCloseup(done) {
      this.drawerup = false; // 关闭抽屉
      this.deid = undefined;
    },
    // 请求数据
    postupdatedevice(id) {
      postupdatedevice(id)
        .then(response => {
          this.updevicedata = response.data;
        })
        .catch(err => {
          console.log(err);
        });
    },
    updedata() {
      this.updevicedata.deid = this.deid;
      updedata(this.updevicedata)
        .then(response => {
          this.handleCloseup();
          this.devicelist();
        })
        .catch(err => {
          console.log(err);
        });
    },
    addUserDevices() {
      addUserDevice()
        .then(response => {
          this.addUserDevice = response.data;
        })
        .catch(err => {
          console.log(err);
        });
    },
    accuracy() {
      window.open('latlge.html');
    },
冯超鹏's avatar
冯超鹏 committed
534 535
  },
};
冯超鹏's avatar
冯超鹏 committed
536 537 538
</script>

<style>
冯超鹏's avatar
冯超鹏 committed
539 540 541 542 543 544 545 546 547 548 549 550
  .demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
  }
Administrator's avatar
Administrator committed
551 552
  .zl-drawer .el-drawer__body {
    overflow-y: auto !important;
冯超鹏's avatar
冯超鹏 committed
553
  }
冯超鹏's avatar
冯超鹏 committed
554
</style>