123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <template>
- <div class="robotbar" @click="changeRobot">
- <div class="name">{{ deviceInfo.name }}</div>
- <div class="online-state">
- <div class="light" :style="{ backgroundColor: getOnlineColor }"></div>
- <div class="text">{{ getOnlineState }}</div>
- </div>
- <div class="alarm-state">
- <div class="light" :style="{ backgroundColor: getAlarmColor }"></div>
- <div class="text">{{ getAlarmState }}</div>
- </div>
- <div></div>
- </div>
- </template>
- <script>
- import lodash from 'lodash'
- export default {
- props: {
- deviceInfo: {
- type: Object,
- default: {
- id: '1',
- name: '机器人1#',
- onlineState: '1',
- alarmState: '0',
- },
- },
- },
- data() {
- return {
- onlineStateOptions: [
- { code: '0', text: '离线', color: '#526891' },
- { code: '1', text: '运行', color: '#28b973' },
- { code: '2', text: '急停', color: '#f32727' },
- ],
- alarmStateOptions: [
- { code: '0', text: '正常', color: '#28b973' },
- { code: '1', text: '故障', color: '#f32727' },
- ],
- }
- },
- computed: {
- getOnlineState() {
- return lodash.find(this.onlineStateOptions, (o) => {
- return o.code == this.deviceInfo.onlineState
- }).text
- },
- getAlarmState() {
- return lodash.find(this.alarmStateOptions, (o) => {
- return o.code == this.deviceInfo.alarmState
- }).text
- },
- getOnlineColor() {
- return lodash.find(this.onlineStateOptions, (o) => {
- return o.code == this.deviceInfo.onlineState
- }).color
- },
- getAlarmColor() {
- return lodash.find(this.alarmStateOptions, (o) => {
- return o.code == this.deviceInfo.alarmState
- }).color
- },
- },
- methods: {
- //回传选中设备
- changeRobot() {
- this.$emit('changeRobot', this.deviceInfo)
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .robotbar {
- background-color: #1278e1;
- color: white;
- height: 47px;
- display: flex;
- gap: 10px;
- width: 100%;
- border-radius: 5px !important;
- .name {
- margin-top: 10px;
- width: 150px;
- height: 27px;
- min-width: 80px;
- line-height: 27px;
- font-size: 16px;
- display: inline-block;
- vertical-align: middle;
- text-align: center;
- }
- .online-state {
- margin-top: 10px;
- width: 82px;
- min-width: 82px;
- height: 27px;
- display: inline-block;
- border-radius: 15px;
- background-color: #063e92;
- .light {
- width: 12px;
- height: 12px;
- display: inline-block;
- margin-left: 12px;
- margin-top: 8px;
- border-radius: 5px;
- }
- .text {
- display: inline-block;
- margin-left: 12px;
- font-size: 14px;
- height: 10px;
- }
- }
- .alarm-state {
- margin-top: 10px;
- width: 82px;
- min-width: 82px;
- height: 27px;
- display: inline-block;
- border-radius: 15px;
- background-color: #063e92;
- .light {
- width: 12px;
- height: 12px;
- display: inline-block;
- margin-left: 12px;
- margin-top: 8px;
- border-radius: 5px;
- }
- .text {
- display: inline-block;
- margin-left: 12px;
- font-size: 14px;
- height: 10px;
- }
- }
- }
- </style>
|