index.vue
9.25 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<template>
<div @wheel="handleWheel" ref="fleetContentBox" :class="{ scrolling: isScrolling }" class="fleet-content-box">
<!-- 线路信息 -->
<div v-for="(childItem, childIndex) in item.fleetInfos" :key="childItem.lineName" ref="fleetLineInfoContainer"
class="fleet-line-info-container">
<div :id="childItem.lineName" class="fleet-line-title">
{{ childItem.lineName != "青蒸线(区间)" ? childItem.lineName : childItem.lineName + "— 引用青蒸线" }}
</div>
<div class="line-box" style="height: 2px; margin: 10px 0; background: #d9e0e2;"></div>
<div ref="fleetNbbmInfoContainer" class="fleet-nbbm-info-container">
<div v-for="(sunItem, sunIndex) in childItem.lineInfos" :key="sunItem.nbbm" class="fleet-nbbm-info-item">
<div v-if="sunItem.saleInfoVo != null" class="fleet-nbbm-info-have-sale">
<el-popover popper-class="fleet-popover-style" placement="top-start" :title="childItem.lineName" :width="320"
:open-delay="500" :popper-options="{ boundariesElement: 'viewport', removeOnDestroy: true }"
:show-after="200" @after-enter="alterEnterHandler(sunItem.driverInfoVo.jobCode)">
<ConstForm :showFlag="personSignInfo.jobCode == sunItem.driverInfoVo.jobCode"
:currentDateKey="currentDateKey" :jobCode="sunItem.driverInfoVo.jobCode" />
<template #reference>
<div class="fleet-nbbm-have-sale-driver" :style="signStyleColor[sunItem.driverInfoVo.signStatus]">
</div>
</template>
</el-popover>
<div class="fleet-nbbm-have-sale-txt-box">
<span class="fleet-nbbm-have-sale-txt">
<span :style="{ color: sunItem.driverInfoVo.signStatus != 1 ? 'white' : 'black' }">
{{ sunItem.nbbm.substring(0, Math.floor(sunItem.nbbm.length / 2)) }}</span>
<span :style="{ color: sunItem.saleInfoVo.signStatus != 1 ? 'white' : 'black' }">
{{ sunItem.nbbm.substring(Math.floor(sunItem.nbbm.length / 2), sunItem.nbbm.length) }}
</span>
</span>
</div>
<el-popover popper-class="fleet-popover-style" placement="top-start" :title="childItem.lineName" :width="320"
:open-delay="500" :popper-options="{ boundariesElement: 'viewport', removeOnDestroy: true }"
:show-after="200" @after-enter="alterEnterHandler(sunItem.saleInfoVo.jobCode)">
<ConstForm :showFlag="personSignInfo.jobCode == sunItem.saleInfoVo.jobCode" :currentDateKey="currentDateKey"
:jobCode="sunItem.saleInfoVo.jobCode" />
<template #reference>
<div class="fleet-nbbm-have-sale-sale" :style="signStyleColor[sunItem.saleInfoVo.signStatus]">
</div>
</template>
</el-popover>
</div>
<el-popover v-else :show-after="200" @after-enter="alterEnterHandler(sunItem.driverInfoVo.jobCode)"
:open-delay="500" :popper-options="{ boundariesElement: 'viewport', removeOnDestroy: true }"
placement="top-start" :title="childItem.lineName" popper-class="fleet-popover-style" :width="320">
<ConstForm :showFlag="personSignInfo.jobCode == sunItem.driverInfoVo.jobCode" :currentDateKey="currentDateKey"
:jobCode="sunItem.driverInfoVo.jobCode" />
<template #reference>
<div class="fleet-nbbm-info-no-sale" :style="signStyleColor[sunItem.driverInfoVo.signStatus]">
<span class="fleet-nbbm-info-no-sale-text">
{{ sunItem.nbbm }}
</span>
</div>
</template>
</el-popover>
</div>
</div>
</div>
</div>
</template>
<script setup>
import ConstForm from '@/components/ConstForm/index.vue';
import { nextTick, onMounted, reactive, ref } from 'vue';
const props = defineProps({
item: {
type: Object,
required: true
},
currentDateKey: {
type: String,
required: true
},
handleLoadSuccess: {
type: Function,
required: true
},
signStyleColor: {
type: Object,
required: true
}
})
/** 签到信息 */
const personSignInfo = reactive(
{
jobCode: null,
date: null
}
);
// 控制滚动
const isScrolling = ref(false);
// 元素信息
const fleetNbbmInfoContainer = ref();
const fleetContentBox = ref();
const fleetLineInfoContainer = ref();
/**
* 显示弹窗
* @param {*} val 工号
*/
const alterEnterHandler = (val) => {
personSignInfo.jobCode = val;
}
/**
* 处理容器滚动回调函数
* @param container HTML parent element
* @param boxContainerElement HTML parent element
*/
const handleContainerScrollCallBack = (container, boxContainerElement) => {
let element = container[0];
let parentLength = element.offsetWidth - 1;
let styles = window.getComputedStyle(element.firstElementChild);
let margin = Number(styles.marginRight.substring(0, styles.marginRight.length - 2));
let childLength = element.firstElementChild.offsetWidth - 1 + margin;
let elementCount = Math.floor(parentLength / childLength);
let containerLength = elementCount * childLength;
let surplus = Math.floor((parentLength - containerLength) / 2) - 1;
boxContainerElement.forEach(boxElement => {
boxElement.style.paddingLeft = surplus + "px";
boxElement.style.paddingRight = surplus + "px";
});
}
/**
* 鼠标滚轮触发了
* @param {*} el
*/
const handleWheel = (el) => {
const containerElement = fleetContentBox.value;
// 内容溢出
if (containerElement.scrollHeight > containerElement.clientHeight) {
// el.preventDefault();
// 根据滚轮滚动的距离来计算滚动量
const scrollAmount = el.deltaY * 0.5;
// 修改盒子的滚动位置
containerElement.scrollTop += scrollAmount;
}
}
onMounted(() => {
nextTick(() => {
const containerElement = fleetNbbmInfoContainer.value;
const boxContainerElement = fleetLineInfoContainer.value;
try {
handleContainerScrollCallBack(containerElement, boxContainerElement);
} catch (error) {
console.log("元素为空");
}
props.handleLoadSuccess(false);
})
})
</script>
<style lang="scss" scoped>
.fleet-content-box {
height: 85%;
width: auto;
overflow: hidden;
scroll-behavior: smooth;
.scrolling {
animation: scroll 5s linear infinite;
}
@keyframes scroll {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-100%);
}
}
// 线路信息
.fleet-line-info-container {
width: 100%;
height: auto;
.fleet-line-title {
margin-top: clamp(0.8rem, -0.549rem + 4.09vw, 1.2rem);
margin-bottom: calc(clamp(0.8rem, -0.549rem + 4.09vw, 1.2rem) - 0.4vw);
box-sizing: border-box;
font-weight: bold;
}
.fleet-nbbm-info-container {
width: 100%;
height: auto;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
font-size: 0.8vw;
.fleet-nbbm-info-item {
width: 6vw;
height: 2.4vh;
box-sizing: border-box;
margin-top: 0.4vw;
margin-right: 0.4vw;
color: black;
.fleet-nbbm-info-have-sale {
width: 100%;
height: 100%;
display: flex;
.fleet-nbbm-have-sale-driver {
border-radius: 1 solid #0761ba;
border-radius: 5px 0 0 5px;
height: 100%;
width: 100%;
margin-right: 0.2vw;
position: relative;
display: flex;
align-items: center;
}
.fleet-nbbm-have-sale-sale {
width: 100%;
height: 100%;
border-radius: 0 5px 5px 0;
display: flex;
justify-content: center;
align-items: center;
}
.fleet-nbbm-have-sale-txt-box {
position: relative;
display: flex;
justify-content: center;
align-items: center;
.fleet-nbbm-have-sale-txt {
position: absolute;
width: auto;
/* 防止文字换行 */
white-space: nowrap;
padding-left: 0.5vw;
padding-right: 0.5vw;
/** 防止元素遮挡 */
pointer-events: none;
}
}
}
.fleet-nbbm-info-no-sale {
width: 100%;
height: 100%;
position: relative;
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
border-radius: 5px;
/* 防止文字换行 */
.fleet-nbbm-info-no-sale-text {
position: absolute;
width: auto;
white-space: nowrap;
padding-left: 0.5vw;
padding-right: 0.5vw;
/* 防止文字换行 */
}
}
}
}
}
}
</style>
<style>
.fleet-popover-style {
color: black !important;
margin: 10px 0 10px 0;
min-width: 100px;
}
.el-popover.fleet-popover-style {
border-color: #f4f4f5;
}
.fleet-popover-style .el-popover__title {
color: black;
font-weight: bold;
}
.el-popper[data-popper-placement^=top]>.el-popper__arrow::before {
border-top-color: rgba(244, 244, 245, 0.735) !important;
background-color: rgba(244, 244, 245, 0.735) !important;
}
</style>