haoxuan
2023-11-03 26ffbb096df8f0dc7f851b1af23fea7136fcfaea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<template>
  <div class="device-check-list">
    <CommonModal v-model="modelData" @close="closeModal">
      <template #title>设备选择</template>
      <div class="device-box">
        <el-scrollbar always class="scroller">
          <template v-if="devices?.length">
            <div
              v-for="(item, index) in devices"
              :key="index"
              :class="item.checked ? 'device-item check-item' : 'device-item'"
              @click="deviceClick(index)"
            >
              <div class="item-l">
                <span>{{ item.number }}</span>
                {{ item.name }}
              </div>
              <div v-if="item.checked" class="item-r">
                <el-icon class="item-icon" size="22" color="#00ff00"><CircleCheckFilled /></el-icon>
              </div>
            </div>
          </template>
        </el-scrollbar>
      </div>
      <template #footer>
        <div class="device-b dialog-footer">
          <BigButton class="btn1" bg-color="#213e9e" @click="closeModal">取消</BigButton>
          <BigButton class="btn" bg-color="#0dfde6" @click="saveModal">保存</BigButton>
        </div>
      </template>
    </CommonModal>
  </div>
</template>
<script setup lang="ts">
import { useVModel } from '@vueuse/core'
import { CircleCheckFilled } from '@element-plus/icons-vue'
import BigButton from '@/views/dashboard/components/BigButton.vue'
import { ref } from 'vue'
export interface DeviceCheckListProps {
  modelValue: boolean
}
const props = withDefaults(defineProps<DeviceCheckListProps>(), {
  modelValue: false
})
 
const emit = defineEmits<{
  'update:modelValue': [show: boolean]
}>()
const modelData = useVModel(props, 'modelValue', emit)
 
const devices = ref([
  {
    number: '111',
    name: '设备A',
    checked: true
  },
  {
    number: '222',
    name: '设备b'
  }
])
function closeModal() {
  modelData.value = false
}
function saveModal() {}
const deviceClick = (index) => {
  devices.value.find((ele) => (ele.checked = false))
 
  devices.value[index].checked = true
}
</script>
<style scoped lang="scss">
$status-done: #0dfde6;
$status-d: #213e9e;
:deep(.el-dialog__body) {
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}
.device-box {
  height: 200px;
  overflow-y: auto;
  .check-item {
    border: 1px solid $status-done;
  }
  .device-item {
    box-sizing: border-box;
    width: 100%;
    height: 45px;
    line-height: 45px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 14px;
    color: #fff;
    cursor: pointer;
    .item-l {
      width: calc(100% - 80px);
      float: left;
      span {
        margin-right: 10px;
      }
    }
    .item-icon {
      height: 100%;
      display: flex;
      align-items: center;
    }
    .item-r {
      height: 100%;
      float: right;
    }
  }
}
.device-b {
  width: 210px;
  margin: 10px auto 10px;
  display: flex;
  align-items: center;
  .btn,
  .btn1 {
    width: 100px;
    height: 40px;
    line-height: 40px;
    border-radius: 4px;
    float: left;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
  }
  .btn1 {
    color: #fff;
    margin-right: 10px;
  }
}
.scroller {
  padding: 4px 16px;
}
</style>