mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-16 06:16:47 +08:00
连选
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
<image class="img" src="../../static/images/learnpath/thispath.png" mode=""></image>
|
||||
<text class="text">当前路径</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="item" style="margin-left: 80rpx;">
|
||||
<image class="img" src="../../static/images/learnpath/otherpath.png" mode=""></image>
|
||||
<text class="text">其他路径</text>
|
||||
</view>
|
||||
@@ -23,7 +23,7 @@
|
||||
</view>
|
||||
<view class="table">
|
||||
<view class="table-container">
|
||||
<table width="100%">
|
||||
<table>
|
||||
<thead>
|
||||
<tr style="background: #F0F6FC;display: flex;align-items: center;">
|
||||
<th class="first" align="center"><view class="text">
|
||||
@@ -34,7 +34,7 @@
|
||||
<tbody>
|
||||
<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 :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
|
||||
v-if="(t && t.isMajorPosition) "
|
||||
src="@/static/images/learnpath/thispath.png"
|
||||
@@ -205,7 +205,7 @@
|
||||
height: 100vh;
|
||||
.table {
|
||||
.table-container {
|
||||
width: 100%;
|
||||
/* width: 100%; */
|
||||
overflow-x: auto;
|
||||
}
|
||||
table {
|
||||
@@ -243,7 +243,7 @@
|
||||
}
|
||||
.item1{
|
||||
/* padding: 12px 20px; */
|
||||
width: 220rpx;
|
||||
width: 156rpx;
|
||||
min-height: 100rpx;
|
||||
text-align: center;
|
||||
border: 2rpx solid #F0F6FC;
|
||||
@@ -257,7 +257,7 @@
|
||||
align-items: center;
|
||||
}
|
||||
.item{
|
||||
width: 220rpx;
|
||||
width: 156rpx;
|
||||
min-height: 120rpx;
|
||||
text-align: center;
|
||||
border: 2rpx solid #F0F6FC;
|
||||
@@ -318,7 +318,7 @@
|
||||
}
|
||||
.path{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
/* justify-content: space-between; */
|
||||
align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
.item{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="item" style='margin-bottom: 180rpx;'>
|
||||
<view class="title">
|
||||
职级
|
||||
</view>
|
||||
@@ -35,7 +35,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<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}}
|
||||
</view>
|
||||
</view>
|
||||
@@ -137,17 +137,69 @@
|
||||
downList(){
|
||||
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){
|
||||
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) {
|
||||
this.bandIndexs.splice(indexToRemove, 1);
|
||||
this.bandIndexs.splice(indexToRemove, 1);
|
||||
} else {
|
||||
this.bandIndexs.push(index);
|
||||
this.bandIndexs.push(currentIndex);
|
||||
}
|
||||
if(this.bandIndexs.length == 0){
|
||||
this.bandFirst = ''
|
||||
this.bandItem = []
|
||||
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.bandItem.sort((a, b) => parseInt(a.bandId, 10) - parseInt(b.bandId, 10));
|
||||
this.bandFirst = this.bandItem[0].bandCode
|
||||
@@ -162,9 +214,11 @@
|
||||
<style>
|
||||
.searchs{
|
||||
background: #fff;
|
||||
height: 100vh;
|
||||
padding: 56rpx 56rpx 180rpx 38rpx;
|
||||
min-height: 100vh;
|
||||
overflow: auto;
|
||||
padding: 56rpx 56rpx 0 38rpx;
|
||||
.item{
|
||||
|
||||
.downlist{
|
||||
margin: 0 auto;
|
||||
.body{
|
||||
@@ -190,6 +244,9 @@
|
||||
font-size: 28rpx;
|
||||
color: #387DF7;
|
||||
}
|
||||
.disabled-item {
|
||||
background-color: #ccc;
|
||||
}
|
||||
}
|
||||
.title{
|
||||
display: flex;
|
||||
@@ -289,12 +346,16 @@
|
||||
|
||||
}
|
||||
.footers{
|
||||
width: 100%;
|
||||
height: 120rpx;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, 0%);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
/* align-items: center; */
|
||||
background: #fff;
|
||||
.btn{
|
||||
width: 284rpx;
|
||||
height: 96rpx;
|
||||
|
||||
Reference in New Issue
Block a user