This commit is contained in:
zhangsir
2024-06-26 16:34:17 +08:00
parent 1e28aa139f
commit 1fe94a9f21
2 changed files with 77 additions and 16 deletions

View File

@@ -12,7 +12,7 @@
<image class="img" src="../../static/images/learnpath/thispath.png" mode=""></image> <image class="img" src="../../static/images/learnpath/thispath.png" mode=""></image>
<text class="text">当前路径</text> <text class="text">当前路径</text>
</view> </view>
<view class="item"> <view class="item" style="margin-left: 80rpx;">
<image class="img" src="../../static/images/learnpath/otherpath.png" mode=""></image> <image class="img" src="../../static/images/learnpath/otherpath.png" mode=""></image>
<text class="text">其他路径</text> <text class="text">其他路径</text>
</view> </view>
@@ -23,7 +23,7 @@
</view> </view>
<view class="table"> <view class="table">
<view class="table-container"> <view class="table-container">
<table width="100%"> <table>
<thead> <thead>
<tr style="background: #F0F6FC;display: flex;align-items: center;"> <tr style="background: #F0F6FC;display: flex;align-items: center;">
<th class="first" align="center"><view class="text"> <th class="first" align="center"><view class="text">
@@ -34,7 +34,7 @@
<tbody> <tbody>
<tr style="display: flex;align-items: center;" v-for="item,index in preparedData" :key="index"> <tr style="display: flex;align-items: center;" v-for="item,index in preparedData" :key="index">
<td class="first" align="center"><view class="text">{{ item.isOtherPosition == 1 ? item.positionName + '(' + item.organizationName + ')' : item.positionName }}</view></td> <td class="first" align="center"><view class="text">{{ item.isOtherPosition == 1 ? item.positionName + '(' + item.organizationName + ')' : item.positionName }}</view></td>
<td :style="{width: 222 * t.number + 'rpx'}" class="item" align="center" v-for="t,i in item.bandCodes"> <td :style="{width: 158 * t.number + 'rpx'}" class="item" align="center" v-for="t,i in item.bandCodes">
<image <image
v-if="(t && t.isMajorPosition) " v-if="(t && t.isMajorPosition) "
src="@/static/images/learnpath/thispath.png" src="@/static/images/learnpath/thispath.png"
@@ -205,7 +205,7 @@
height: 100vh; height: 100vh;
.table { .table {
.table-container { .table-container {
width: 100%; /* width: 100%; */
overflow-x: auto; overflow-x: auto;
} }
table { table {
@@ -243,7 +243,7 @@
} }
.item1{ .item1{
/* padding: 12px 20px; */ /* padding: 12px 20px; */
width: 220rpx; width: 156rpx;
min-height: 100rpx; min-height: 100rpx;
text-align: center; text-align: center;
border: 2rpx solid #F0F6FC; border: 2rpx solid #F0F6FC;
@@ -257,7 +257,7 @@
align-items: center; align-items: center;
} }
.item{ .item{
width: 220rpx; width: 156rpx;
min-height: 120rpx; min-height: 120rpx;
text-align: center; text-align: center;
border: 2rpx solid #F0F6FC; border: 2rpx solid #F0F6FC;
@@ -318,7 +318,7 @@
} }
.path{ .path{
display: flex; display: flex;
justify-content: space-between; /* justify-content: space-between; */
align-items: center; align-items: center;
margin-bottom: 30rpx; margin-bottom: 30rpx;
.item{ .item{

View File

@@ -18,7 +18,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="item"> <view class="item" style='margin-bottom: 180rpx;'>
<view class="title"> <view class="title">
职级 职级
</view> </view>
@@ -35,7 +35,7 @@
</view> </view>
</view> </view>
<view v-if="bandShow" class="body"> <view v-if="bandShow" class="body">
<view @click="isBand(item,index)" :class="bandIndexs.includes(index)?'item2':''" v-for="(item,index) in bandLists" :key="index" class="item"> <view @click="isBand(item,index)" :class=" {'item2': bandIndexs.includes(index),'disabled-item': isDisabled(index)}" v-for="(item,index) in bandLists" :key="index" class="item">
{{item.bandCode}} {{item.bandCode}}
</view> </view>
</view> </view>
@@ -137,17 +137,69 @@
downList(){ downList(){
this.bandShow = !this.bandShow this.bandShow = !this.bandShow
}, },
isDisabled(index) {
if (this.bandIndexs.length >= 1) {
const firstClickIndex = Math.min(...this.bandIndexs);
const allowedRangeEnd = firstClickIndex + 2;
return index < firstClickIndex || index > allowedRangeEnd;
}
return false;
},
isBand(item,index){ isBand(item,index){
const indexToRemove = this.bandIndexs.indexOf(index); if (this.bandIndexs.length >= 1) {
const firstClickIndex = Math.min(...this.bandIndexs);
const allowedRangeEnd = firstClickIndex + 2;
if (index < firstClickIndex || index > allowedRangeEnd) {
return;
}
}
if (this.bandIndexs.length === 3 && this.bandIndexs.includes(index) && this.bandIndexs.indexOf(index) === 1) {
// 删除最后一个元素
this.bandIndexs.pop();
this.bandItem = this.bandIndexs.map(index => this.bandLists[index])
this.bandItem = this.bandItem.sort((a, b) => parseInt(a.bandId, 10) - parseInt(b.bandId, 10));
this.bandFirst = this.bandItem[0].bandCode
if(this.bandItem && this.bandItem.length > 1){
this.bandEnd = this.bandItem[this.bandItem.length - 1].bandCode
}
return;
}
let currentIndex = index;
let firstClickIndex = this.bandIndexs[0];
if (this.bandIndexs.length === 0) {
this.bandIndexs.push(currentIndex);
return;
}
// 确保currentIndex和firstClickIndex按顺序排列
if (currentIndex < firstClickIndex) {
[currentIndex, firstClickIndex] = [firstClickIndex, currentIndex];
}
// 检查是否有连续的未选择项,并自动填充
for (let i = firstClickIndex + 1; i < currentIndex; i++) {
if (!this.bandIndexs.includes(i)) {
this.bandIndexs.splice(this.bandIndexs.indexOf(i - 1) + 1, 0, i);
}
}
// 添加或移除当前点击的index
const indexToRemove = this.bandIndexs.indexOf(currentIndex);
if (indexToRemove !== -1) { if (indexToRemove !== -1) {
this.bandIndexs.splice(indexToRemove, 1); this.bandIndexs.splice(indexToRemove, 1);
} else { } else {
this.bandIndexs.push(index); this.bandIndexs.push(currentIndex);
} }
if(this.bandIndexs.length == 0){ if(this.bandIndexs.length == 0){
this.bandFirst = ''
this.bandItem = []
return return
} }
console.log(this.bandIndexs,'this.bandIndexs') if(this.bandIndexs.length == 1){
this.bandEnd = ''
}
this.bandItem = this.bandIndexs.map(index => this.bandLists[index]) this.bandItem = this.bandIndexs.map(index => this.bandLists[index])
this.bandItem = this.bandItem.sort((a, b) => parseInt(a.bandId, 10) - parseInt(b.bandId, 10)); this.bandItem = this.bandItem.sort((a, b) => parseInt(a.bandId, 10) - parseInt(b.bandId, 10));
this.bandFirst = this.bandItem[0].bandCode this.bandFirst = this.bandItem[0].bandCode
@@ -162,9 +214,11 @@
<style> <style>
.searchs{ .searchs{
background: #fff; background: #fff;
height: 100vh; min-height: 100vh;
padding: 56rpx 56rpx 180rpx 38rpx; overflow: auto;
padding: 56rpx 56rpx 0 38rpx;
.item{ .item{
.downlist{ .downlist{
margin: 0 auto; margin: 0 auto;
.body{ .body{
@@ -190,6 +244,9 @@
font-size: 28rpx; font-size: 28rpx;
color: #387DF7; color: #387DF7;
} }
.disabled-item {
background-color: #ccc;
}
} }
.title{ .title{
display: flex; display: flex;
@@ -289,12 +346,16 @@
} }
.footers{ .footers{
width: 100%;
height: 120rpx;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, 0%);
display: flex; display: flex;
justify-content: center; justify-content: center;
/* align-items: center; */
background: #fff;
.btn{ .btn{
width: 284rpx; width: 284rpx;
height: 96rpx; height: 96rpx;