123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- <template>
- <div class="main">
- <div class="search">
- <el-input placeholder="设备名称或编号" class="search-input" clearable v-model="mixins_query.deviceNo"></el-input>
- <el-select slot="status" v-model="mixins_query.deviceStatus" clearable>
- <el-option v-for="(item, index) in deviceStatus" :key="index" :label="item.label" :value="item.status">{{
- item.label
- }}</el-option>
- </el-select>
- <el-button type="primary" class="search-btn" @click="mixins_search" icon="el-icon-search">查询 </el-button>
- <div class="search-icon">
- <i class="iconfont" @click="deluserbyidFn()" v-txt-tip data-txt="删除"></i>
- <i class="iconfont" @click="addOrEdit('add')" v-left-txt-tip data-txt="新增"></i>
- </div>
- </div>
- <div class="roles-wrap">
- <zz-table
- :cols="cols"
- :settings="{ showCheckbox: true, showIndex: true, stripe: true }"
- :loading="mixins_onQuery"
- :data="mixins_list"
- :pageset="mixins_pageset"
- @page-change="pageChange"
- @selection-change="selectionChange"
- >
- <template slot-scope="scope" slot="opt">
- <div class="opt">
- <el-tooltip class="item" effect="light" placement="bottom" content="编辑">
- <img class="optImg" @click="addOrEdit('edit', scope.row)" src="@/assets/img/btn_bianji.png" />
- </el-tooltip>
- <el-tooltip class="item" effect="light" placement="bottom" content="删除">
- <img class="optImg" @click="deluserbyidFn(scope.row.id)" src="@/assets/img/btn_shanchu.png" />
- </el-tooltip>
- </div>
- </template>
- </zz-table>
- </div>
- </div>
- </template>
- <script>
- import list from '@utils/list.js';
- export default {
- mixins: [list],
- data() {
- let _this = this;
- return {
- selectRow: [],
- // 数据列表
- deviceStatus: [
- {
- status: 1,
- label: '正常'
- },
- {
- status: 2,
- label: '告警'
- },
- {
- status: 3,
- label: '离线'
- },
- {
- status: 4,
- label: '未启用'
- },
- {
- status: 5,
- label: '报废'
- }
- ],
- cols: [
- {
- label: '所属小区',
- prop: 'communityId',
- format(val) {
- let va = '';
- _this.$store.getters['getAreaSelect'].forEach((element) => {
- if (element.id === val) {
- va = element.communityName;
- }
- });
- return va;
- }
- },
- {
- label: '设备类型',
- prop: 'deviceTypeName'
- },
- {
- label: '设备编号',
- prop: 'deviceNo'
- },
- {
- label: '设备名称',
- prop: 'deviceName'
- },
- {
- label: '设备地址',
- prop: 'address'
- },
- {
- label: '添加日期',
- prop: 'createDate'
- },
- {
- label: '设备状态',
- prop: 'deviceStatus',
- format(val) {
- if (val == '1') {
- return '正常';
- } else if (val == '2') {
- return '告警';
- } else if (val == '3') {
- return '离线';
- } else if (val == '4') {
- return '未启用';
- } else if (val == '5') {
- return '报废';
- }
- }
- },
- {
- label: '二维码',
- prop: 'deviceQrcode'
- },
- {
- label: '操作',
- prop: 'id',
- slot: 'opt'
- }
- ],
- mixins_post: 'post',
- productOptions: []
- };
- },
- created() {
- if (this.$store.getters['getAreaSelect'].length === 0) {
- this.getorgTree();
- }
- this.mixins_dataUrl = '/device/page';
- this.mixins_query = {};
- this.mixins_search();
- },
- mounted() {
- this.getProductOptions();
- },
- methods: {
- getorgTree() {
- this.$http
- .get('/sc-community/assets/community/list')
- .then((data) => {
- this.$store.commit('setAreaSelect', data.data);
- })
- .catch(function () {});
- },
- deluserbyidFn(id) {
- let ids = [];
- if (!!id) {
- ids = [id];
- } else {
- if (!this.selectRow.length) {
- this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
- return;
- }
- this.selectRow.forEach((v) => {
- ids.push(v.id);
- });
- }
- this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
- .then(() => {
- this.$http.post('/facility/delete', ids).then(({ status, data, msg }) => {
- if (0 === status) {
- this.$message({
- type: 'success',
- message: '删除成功!'
- });
- this.mixins_search();
- }
- });
- })
- .catch(() => {});
- },
- addOrEdit(todo, data = {}) {
- new Promise((resolve) => {
- let title = '添加设备管理';
- if (todo == 'add') {
- // title = this.mixins_query.alarmCategory == '2' ? '添加离线规则' : '添加告警';
- } else {
- title = '修改设备管理';
- }
- this.$store.dispatch('addPopup', {
- url: '/deviceManagement/popups/addDeviceManagement.vue',
- width: '500px',
- height: '700px',
- props: {
- data,
- todo,
- productOptions: this.productOptions,
- callback: resolve
- },
- title: title
- });
- }).then(() => {
- this.mixins_search();
- });
- },
- selectionChange(val) {
- this.selectRow = val;
- },
- getProductOptions() {
- this.$http.postForm('/devicetype/selectList', { name: '' }).then((data) => {
- this.productOptions = data;
- });
- }
- }
- };
- </script>
- <style lang='scss' scoped>
- .new-select-tree {
- vertical-align: top;
- display: inline-block;
- margin-right: 25px;
- }
- table i {
- cursor: pointer;
- }
- </style>
|