ines-num-old"> 575
      this.userConectChanged()
576
      this.relevance = true
577
      this.relevanceValidate.number = row.deviceNo
578
      this.relevanceValidate.id = row.deviceId
579
      if (row.bindName == '--') {
580
        this.relevanceValidate.msgisShow = false
581
        this.relevanceValidate.msg = ''
582
      } else {
583
        this.relevanceValidate.msgisShow = true
584
        this.relevanceValidate.msg = '当前终端已关联 ' + row.bindName + ' ,点击保存更改关联关系'
585
      }
586
    },
587
    removeD(row) {
588
      let that = this
589
      let confirm = {
590
        title: '请确认',
591
        content: '删除后不可恢复,确认删除吗?',
592
        ok: function () {
593
          var params = new FormData()
594
          params.append('data', JSON.stringify({
595
            deviceId: row.deviceId
596
          }))
597
          this.$test.post(services.device.DEL_DEVICE, params
598
          ).then(res => {
599
            // 请求成功处理...
600
            if (res.data.result) {
601
              that.$Message.success('操作成功')
602
              that.getList(that.table.pager.currentPage, that.table.pager.size, that.queryCondition.isBindDevice, that.queryCondition.deviceNo)
603
            } else {
604
              that.$Message.danger(res.data.errMsg)
605
            }
606
          }).catch(res => {
607
            // 请求失败处理...
608
          })
609
        }
610
      }
611
      this.$Confirm.confirm(confirm)
373 612
    }
374 613
  }
375 614
}

common-ui - Nuosi Git Service

AIoT前端公共UI

Tree.vue 4.4KB

    <!-- eslint-disable vue/no-mutating-props --> <!-- eslint-disable vue/no-template-shadow --> <!-- * @Author: Devin * @Date: 2022-12-12 16:52:01 * @LastEditors: Devin * @LastEditTime: 2023-02-22 14:50:08 * @Description: 公共树组件 --> <template> <div class="aiot-common-tree"> <div class="common-btn"> <el-button link @click.stop="addRootLevel"> <span class="btn-icon"> <!-- <common-icon name="common-plus" :size="12"></common-icon> --> + </span> {{ btnText }} </el-button> </div> <!-- filter --> <el-input v-if="hasFilter" v-model="filterText" size="small" :suffix-icon="Search" :placeholder="searchText || '请输入'" class="int" @keydown="filterTree" ></el-input> <!-- tree module --> <el-tree ref="treeRef" :data="treeData" v-bind="attrs" empty-text="暂无数据" :highlight-current="true" :filter-node-method="filterNode" @node-click="nodeClick" > <template #default="{ node, data }"> <span class="custom-tree-node" @mouseenter="() => (hIndex = node.label)" @mouseleave="() => (hIndex = '')" > <span>{{ node.label }}</span> {{ node.$index }} <template v-if="hIndex === node.label"> <span v-if="actions"> <span v-for="action in actions" :key="action?.['name']" :class="action?.['type'] || 'primary'" class="m-l-4 text-btn" @click.stop="action.onClick(node, data)" > <common-icon v-if="isIcon" :name="action?.['name']" :size="action?.['size'] || 18" :content="action?.['label']" ></common-icon> <span v-else> {{ action?.['label'] }} </span> </span> </span> </template> </span> </template> </el-tree> </div> </template> <script setup lang="ts"> import { Search } from '@element-plus/icons-vue'; import { watch, ref } from 'vue'; const emits = defineEmits(['nodeClick', 'addRootLevel']); const hIndex = ref<any>(''); const props = defineProps({ attrs: { type: Object, default: () => {} }, hasFilter: { type: Boolean, default: () => true }, searchText: { type: String, default: () => '' }, treeData: { type: Array, default: () => [] }, searchWord: { type: String, default: () => '' }, actions: { type: Array<any>, default: () => [] }, isIcon: { type: Boolean, default: () => true }, btnText: { type: String, default: () => '新增根目录' } }); // 树过滤 function filterTree(val: any) { console.log(val); } function filterNode(value: string, data: any) { if (!value) return true; return data?.[props?.attrs?.props?.label || 'label'].includes(value); } const filterText = ref(''); const treeRef = ref<any>(null); watch(filterText, (val) => { treeRef.value!.filter(val); }); defineExpose({ treeRef }); // 节点被点击时 function nodeClick(data: any) { emits('nodeClick', data); } // 添加一级目录 function addRootLevel() { emits('addRootLevel'); } </script> <script lang="ts"> export default { name: 'CommonTree' }; </script> <style lang="scss"> .aiot-common-tree { .icon { margin-left: 5px; } .custom-tree-node { width: 100%; display: flex; align-items: center; justify-content: space-between; font-size: 14px; padding-right: 8px; line-height: 32px; } .int { margin-bottom: 10px; } .common-btn { width: 100%; // text-align: center; border-bottom: 1px solid #ebebeb; margin-bottom: 10px; padding-bottom: 10px; font-size: 14px; color: #455a74; .btn-icon { background-color: #2d98ff; color: #fff; padding: 2px; margin-right: 10px; border-radius: 2px; } } } :deep(.el-tree-node) { line-height: 32px; } :deep(.el-tree-node__label) { width: 100%; } :deep(.el-tree-node__content) { height: 32px; } .text-btn { cursor: pointer; min-width: 12px; } // type color .primary { color: #169bfa; } .warning { color: #ffb95b; } .error { color: #ff5f5f; } .danger { color: #ff5f5f; } .info { color: #2d3e53; } </style>