he wei
2022-11-13 b4816f6294646157b50bb49f1d19eaf306e0ac8c
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
<template>
  <div class="btn-list">
    <div :class="['btn-item', item.icon, {disabled: item.disabled}]" v-for="(item, idx) in list" :key="'btn_' + idx" :title="item.title" @click="itemClick(item)">
    </div>
  </div>
</template>
 
<script>
export default {
  name: "",
 
  data() {
    const list = [
      {
        title: '打开文件',
        icon: 'open',
        method: 'openFile'
      },
      {
        title: '生成报告',
        icon: 'export',
        method: 'exportReport',
        disabled: true
      },
      {
        title: '查看属性',
        icon: 'view',
        method: 'viewProp',
        disabled: true
      },
      {
        title: '分级评价',
        icon: 'report',
        method: 'setAlarmValue'
      },
      {
        title: '窗口配置',
        icon: 'window-confirm',
        method: 'windowConfirm'
      }
    ];
    return {
      list
    };
  },
  watch: {
    $route(n) {
      this.list[1].disabled = !["compare", "result"].includes(
        n.name
      );
      this.list[2].disabled = !["result"].includes(
        n.name
      );
    },
  },
  components: {},
  methods: {
    itemClick(obj) {
      // console.log(obj)
      if (
        obj.method &&
        "function" == typeof this[obj.method] &&
        !obj.disabled
      ) {
        this[obj.method]();
      }
    },
    openFile() {
      window.api.send("open-file-dialog", "MenuList");
    },
    exportReport() {
      this.$bus.$emit("export");
    },
    viewProp() {
      this.$bus.$emit('viewProp');
    },
    setAlarmValue() {
      this.$bus.$emit('setAlarmValue');
    },
    windowConfirm() {
      this.$bus.$emit('windowConfirm');
    }
  },
 
  mounted() {},
};
</script>
 
<style scoped lang="less">
.btn-list {
  padding: 4px 2px;
  display: flex;
  flex-direction: row;
  .btn-item {
    flex: 1;
    height: 26px;
    cursor: pointer;
    & + .btn-item {
      margin-left: 4px;
    }
    &.open {
      background: url('~@/assets/open.png') center / contain no-repeat;
    }
    &.export {
      background: url('~@/assets/export.png') center / contain no-repeat;
    }
    &.view {
      background: url('~@/assets/view.png') center / contain no-repeat;
    }
    &.report {
      background: url('~@/assets/report.png') center / contain no-repeat;
    }
    &.window-confirm {
      background: url('~@/assets/window-confirm.png') center / contain no-repeat;
    }
    &:hover {
      background-color: rgba(200, 200, 200, .4);
    }
    &.disabled.disabled {
      background-color: #999;
      background-blend-mode: luminosity;
      cursor: not-allowed;
    }
  }
}
</style>