2
schangxiang@126.com
2025-05-12 6177ed5cb88df34f2a67d9d0610e3e0dc7030e70
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
139
140
141
142
143
<template>
  <div class="collapse" :class="{ collapsed: isCollapsed }">
    <div class="header">
      <div class="header-left" @click="toggleCollapse">
        <transition name="icon">
          <div :class="['icon', themeClass]" :key="'isCollapsed'">
            <span v-if="isCollapsed" class="triangle right"></span>
            <span v-else class="triangle"></span>
          </div>
        </transition>
        <div :class="['text', themeClass]">{{ $props.title }}</div>
        <div>
          <slot name="header-left"></slot>
        </div>
      </div>
      <div class="header-right">
        <slot name="header-right"></slot>
      </div>
    </div>
    <transition name="collapse">
      <div class="content" v-if="!isCollapsed">
        <slot name="content"></slot>
      </div>
    </transition>
    <div class="slot">
      <slot></slot>
    </div>
  </div>
</template>
 
<script lang="ts" setup>
import { ref, computed } from 'vue'
// import { ORDER_STATUS } from '../../enum'
import { getEnum } from '../../enum'
const { ORDER_STATUS } = getEnum()
const $props = defineProps<{
  title: string
  status: number
}>()
 
const THEME_MAP = {
  [ORDER_STATUS.PRODUCTION]: 'PRODUCTION',
  [ORDER_STATUS.PRODUCED]: 'PRODUCED',
  [ORDER_STATUS.PAUSED]: 'PAUSED',
  [ORDER_STATUS.NOT_ACTIVE]: 'NOT_ACTIVE',
}
 
const isCollapsed = ref(false)
 
const themeClass = computed(() => THEME_MAP[$props.status])
 
const toggleCollapse = () => {
  isCollapsed.value = !isCollapsed.value
}
</script>
 
<style lang="scss" scoped>
.collapse {
  overflow: hidden;
}
 
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 10px;
  background-color: #f1f1f1;
  font-size: 16px;
  font-weight: bold;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}
.header-left {
  display: flex;
  align-items: center;
  padding: 10px;
  background-color: #f1f1f1;
  cursor: pointer;
  font-weight: bold;
}
 
.icon {
  width: 20px;
  height: 20px;
  line-height: 1;
  border-radius: 50%;
  text-align: center;
  margin-right: 5px;
  font-weight: bold;
}
 
.content {
  background-color: #ffffff;
}
.triangle {
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 5px 0 5px;
  border-color: #fff transparent transparent transparent;
}
 
.right {
  transform: rotate(270deg);
  position: relative;
  top: -1px;
  right: -1px;
}
 
.PRODUCTION {
  &.icon {
    background-color: #426aeb;
  }
  &.text {
    color: #426aeb;
  }
}
.PRODUCED {
  &.icon {
    background-color: #f3b666;
  }
  &.text {
    color: #f3b666;
  }
}
.PAUSED {
  &.icon {
    background-color: #ea7a76;
  }
  &.text {
    color: #ea7a76;
  }
}
.NOT_ACTIVE {
  &.icon {
    background-color: #737373;
  }
  &.text {
    color: #737373;
  }
}
</style>