Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
supervisor-miniprogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 392349c6
authored
Jun 04, 2026
by
Jaxon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 还原被覆盖的selectPopup组件
1 parent
dc72338c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
173 additions
and
340 deletions
components/selectPopup/selectPopup.js
components/selectPopup/selectPopup.js
View file @
392349c
// pa
ges/tab/learningCenter/learningCenter
.js
// pa
ckageWorkspace/pages/performanceRating/components/selectPopup/selectPopup
.js
const
IMG_URL
=
'https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/'
const
IMG_URL
=
'https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/'
import
api
from
"~/api/learningCenter/index"
Component
({
import
constantData
from
"./constantData"
options
:
{
Page
({
addGlobalClass
:
true
/**
* 页面的初始数据
*/
data
:
{
IMG_URL
,
navBarHeight
:
84
,
statisticsData
:
{},
showSearchIcon
:
true
,
pageNum
:
1
,
pageSize
:
10
,
total
:
0
,
navBarHeight
:
0
,
sortObj
:
{
id
:
'0'
,
label
:
'最多人学'
},
searchTitle
:
''
,
myCourseList
:
[],
formItems
:
[{
key
:
'title'
,
type
:
'title'
},
{
label
:
'课程时长'
,
key
:
'totalDuration'
,
unit
:
'min'
},
{
label
:
'学习进度'
,
type
:
'progress'
,
statusKey
:
'completeStatus'
,
statusEvent
:
'0'
,
key
:
'_process'
}],
allFormItems
:
[{
key
:
'title'
,
type
:
'title'
},
{
label
:
'课程时长'
,
key
:
'totalDuration'
,
unit
:
'min'
},
{
type
:
'score'
,
key
:
'_totalStar'
,
textKey
:
'totalStar'
},
{
type
:
'studied'
,
key
:
'learnTotal'
}],
allList
:
[],
pageScrollFlag
:
false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
(
options
)
{
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
()
{
},
/**
* 生命周期函数--监听页面显示
*/
onShow
()
{
this
.
setData
({
allList
:
[],
pageNum
:
1
,
nothing
:
false
,
scrollTop
:
0
},
()
=>
{
this
.
getList
()
})
},
},
properties
:
{
onScroll
(
e
)
{
show
:
{
this
.
setData
({
type
:
Boolean
,
pageScrollFlag
:
e
.
detail
.
scrollTop
>
0
value
:
false
})
},
title
:
{
type
:
String
,
value
:
''
},
// 原始选项列表,支持任意字段名,通过 labelKey/valueKey 映射
options
:
{
type
:
Array
,
value
:
[]
},
// 是否多选
multiple
:
{
type
:
Boolean
,
value
:
false
},
// 单选初始值
value
:
{
type
:
null
,
value
:
null
},
// 多选初始值
values
:
{
type
:
Array
,
value
:
[]
},
// 字段映射
labelKey
:
{
type
:
String
,
value
:
'name'
},
valueKey
:
{
type
:
String
,
value
:
'value'
},
// 多选最大数量(不限制则设为 0 或不传)
max
:
{
type
:
Number
,
value
:
0
},
// 单选时点击即确认
confirmOnSelect
:
{
type
:
Boolean
,
value
:
false
},
height
:
{
type
:
String
},
allowSearch
:
{
type
:
Boolean
}
},
},
data
:
{
scrollonReachBottom
()
{
IMG_URL
,
const
{
pageNum
,
total
,
pageSize
}
=
this
.
data
;
displayOptions
:
[],
// 带 checked 的渲染选项
if
(
Math
.
ceil
(
total
/
pageSize
)
>
pageNum
)
{
selectedValues
:
[]
// 选中的值列表(单选也统一用数组)
this
.
setData
({
pageNum
:
pageNum
+
1
},
()
=>
{
this
.
getList
()
})
}
else
{
this
.
setData
({
nothing
:
true
})
}
},
back
()
{
wx
.
navigateBack
()
},
},
onTabItemTap
(
e
)
{
// 点击埋点
wx
.
$track
.
setTrackData
(
0
,
'supervisor_learning_page'
,
{},
''
)
},
navbarReady
(
e
)
{
let
navBarHeight
=
e
.
detail
.
height
;
console
.
log
(
navBarHeight
)
this
.
setData
({
navBarHeight
,
});
},
// 跳转北森课程详情
goBeisenDetail
(
e
)
{
let
{
target
}
=
e
.
currentTarget
.
dataset
wx
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
wx
.
$track
.
setTrackData
(
0
,
'supervisor_course_detail'
,
{},
''
)
api
.
findBeiSenSSOToken
({}).
then
(
res
=>
{
wx
.
hideLoading
()
const
beisenToken
=
res
.
data
;
if
(
beisenToken
)
{
const
COURSE_ID
=
target
?.
courseId
;
const
baseUrl
=
'https://cloud.italent.cn/PageHome/Index'
;
const
params
=
{
product
:
'Learning'
,
keyName
:
'Nusion'
,
pageCode
:
'LearningCourseTraineeDetailPage'
,
appCode
:
'Learning'
,
id
:
COURSE_ID
};
this
.
jumpUrl
=
''
const
queryString
=
Object
.
entries
(
params
)
.
map
(([
key
,
value
])
=>
`
${
key
}
=
${
value
}
`
)
.
join
(
'&'
);
const
url
=
encodeURIComponent
(
`
${
baseUrl
}
?
${
queryString
}
#/viewDynamic?1=1`
);
const
tokenUrl
=
beisenToken
wx
.
$router
.
jumpH5
(
`
${
tokenUrl
}
&return_url=
${
url
}
`
)
}
else
{
wx
.
showToast
({
title
:
'培训账号未创建'
,
icon
:
'none'
})
}
})
},
// 全部课程搜素
searchInput
(
e
)
{
let
{
value
}
=
e
.
detail
this
.
setData
({
searchTitle
:
value
})
},
search
()
{
this
.
setData
({
pageNum
:
1
},
()
=>
{
this
.
getList
(
true
)
})
},
clear
()
{
this
.
setData
({
searchTitle
:
''
},
()
=>
{
this
.
search
()
})
},
handleSort
()
{
this
.
setData
({
showSortPopup
:
true
})
},
sortConfirm
(
e
)
{
let
data
=
e
.
detail
const
obj
=
data
?.
find
(
val
=>
val
.
active
==
true
)
this
.
setData
({
sortObj
:
obj
,
pageNum
:
1
},
()
=>
{
this
.
getList
(
true
)
})
this
.
sortCancel
()
},
sortCancel
()
{
this
.
setData
({
showSortPopup
:
false
})
},
handleCategory
()
{
this
.
setData
({
showCategory
:
true
})
},
// 课程分类筛选返回
containerCategoryBack
()
{
this
.
setData
({
showCategory
:
false
})
},
// 课程分类筛选
searchCategoryScreen
(
e
)
{
let
obj
=
{}
let
data
=
e
.
detail
data
?.
forEach
(
item
=>
{
item
?.
children
?.
forEach
(
val
=>
{
if
(
val
.
active
)
obj
=
val
})
})
if
(
Object
.
keys
(
obj
).
length
)
obj
.
label
=
obj
.
parentCategoryName
&&
obj
.
categoryName
&&
obj
.
categoryName
!=
'全部'
?
`
${
obj
.
parentCategoryName
}
-
${
obj
.
categoryName
}
`
:
`
${
obj
.
parentCategoryName
}
`
this
.
setData
({
categoryObj
:
obj
,
pageNum
:
1
},
()
=>
{
this
.
getList
(
true
)
})
this
.
containerCategoryBack
()
},
// 筛选
handleScreen
()
{
this
.
setData
({
showScreen
:
true
})
},
searchScreen
(
e
)
{
this
.
setData
({
screenObj
:
e
.
detail
,
pageNum
:
1
},
()
=>
{
this
.
containerBack
()
this
.
getList
(
true
)
})
},
// 筛选返回
containerBack
()
{
this
.
setData
({
showScreen
:
false
})
},
getList
()
{
let
{
pageNum
,
pageSize
,
searchTitle
,
sortObj
,
categoryObj
,
screenObj
}
=
this
.
data
let
userInfo
=
wx
.
$util
.
getUserInfo
()
let
params
=
{
pageNum
,
pageSize
,
staffPhone
:
userInfo
?.
phone
,
title
:
searchTitle
,
sortType
:
sortObj
?.
id
,
sortOrder
:
'desc'
,
courseCategoryId
:
categoryObj
?.
id
,
planCourseType
:
screenObj
?.
planCourseType
,
courseFileType
:
screenObj
?.
courseFileType
,
totalStar
:
screenObj
?.
totalStar
}
wx
.
showLoading
()
if
(
pageNum
>
1
)
{
this
.
setData
({
loadingList
:
true
})
}
api
.
getRecommendedCourseList
(
params
).
then
(
res
=>
{
this
.
setData
({
loadingList
:
false
})
let
{
code
,
data
,
message
}
=
res
if
(
code
==
0
)
{
data
?.
list
?.
forEach
(
val
=>
{
val
.
_totalStar
=
val
.
totalStar
/
2
val
.
_imageUrl
=
constantData
.
TYPEIMG
[
val
.
courseFileType
]
val
.
_tagText
=
constantData
.
TAGTEXT
[
val
.
courseFileType
]
})
let
newList
=
data
?.
list
||
[]
if
(
pageNum
==
1
)
{
this
.
setData
({
allList
:
newList
});
}
else
{
this
.
setData
({
allList
:
this
.
data
.
allList
.
concat
(
newList
)
})
}
wx
.
hideLoading
()
this
.
setData
({
total
:
res
.
data
?.
total
,
nothing
:
newList
.
length
>
0
});
}
else
{
wx
.
$util
.
showToast
(
message
)
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide
()
{
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
()
{
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
()
{
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
()
{
},
/**
* 用户点击右上角分享
*/
onShareAppMessage
()
{
}
})
\ No newline at end of file
\ No newline at end of file
observers
:
{
'options, multiple, value, values'
:
function
(
options
,
multiple
,
value
,
values
)
{
this
.
initDisplay
(
options
||
[],
multiple
,
value
,
values
)
},
show
(
n
)
{
// 进出场时保持数据一致
if
(
n
)
{
this
.
setData
({
searchValue
:
''
})
this
.
initDisplay
(
this
.
properties
.
options
||
[],
this
.
properties
.
multiple
,
this
.
properties
.
value
,
this
.
properties
.
values
)
}
}
},
methods
:
{
initDisplay
(
options
=
[],
multiple
=
false
,
value
=
null
,
values
=
[])
{
const
vKey
=
this
.
properties
.
valueKey
// 初始选中值统一转为数组
const
initSelected
=
multiple
?
(
Array
.
isArray
(
values
)
?
values
.
slice
()
:
[])
:
(
value
!==
null
&&
value
!==
undefined
?
value
:
[])
const
display
=
(
options
||
[]).
map
(
item
=>
{
const
val
=
item
[
vKey
]
const
checked
=
initSelected
?.
some
(
v
=>
v
===
val
)
return
{
...
item
,
checked
}
})
this
.
setData
({
displayOptions
:
display
,
copyDisplayOptions
:
wx
.
$util
.
deepClone
(
display
),
selectedValues
:
initSelected
})
},
toggle
(
e
)
{
const
{
index
,
item
}
=
e
.
currentTarget
.
dataset
const
{
multiple
,
max
,
valueKey
}
=
this
.
properties
let
{
displayOptions
,
copyDisplayOptions
}
=
this
.
data
if
(
!
item
||
item
.
disabled
)
return
if
(
multiple
)
{
let
nextChecked
=
!
item
.
checked
// 限制最大数量
if
(
nextChecked
&&
max
>
0
)
{
const
selectedCount
=
this
.
data
.
selectedValues
.
length
if
(
selectedCount
>=
max
)
{
// 可根据项目规范提示用户,这里不做 UI 弹窗,保持组件纯净
this
.
triggerEvent
(
'maxtips'
)
return
}
}
const
selectIndex
=
displayOptions
?.
findIndex
(
v
=>
v
[
valueKey
]
==
item
[
valueKey
])
this
.
setData
({
[
`displayOptions[
${
selectIndex
}
].checked`
]:
nextChecked
})
const
copySelectIndex
=
copyDisplayOptions
?.
findIndex
(
v
=>
v
[
valueKey
]
==
item
[
valueKey
])
this
.
setData
({
[
`copyDisplayOptions[
${
copySelectIndex
}
].checked`
]:
nextChecked
})
const
val
=
item
[
valueKey
]
let
selected
=
this
.
data
.
selectedValues
.
slice
()
const
pos
=
selected
.
findIndex
(
v
=>
v
===
val
)
if
(
nextChecked
&&
pos
===
-
1
)
selected
.
push
(
val
)
if
(
!
nextChecked
&&
pos
>
-
1
)
selected
.
splice
(
pos
,
1
)
this
.
setData
({
selectedValues
:
selected
})
this
.
triggerEvent
(
'change'
,
{
values
:
selected
,
items
:
this
.
getSelectedItems
()
})
}
else
{
// 单选:取消其他,选中当前
const
currentVal
=
item
[
valueKey
]
const
display
=
this
.
data
.
displayOptions
.
map
((
it
,
idx
)
=>
({
...
it
,
checked
:
idx
===
index
?
!
it
.
checked
:
false
}))
const
selected
=
display
[
index
].
checked
?
[
currentVal
]
:
[]
this
.
setData
({
displayOptions
:
display
,
selectedValues
:
selected
})
const
copyDisplay
=
this
.
data
.
copyDisplayOptions
.
map
((
it
,
idx
)
=>
({
...
it
,
checked
:
idx
===
index
?
!
it
.
checked
:
false
}))
this
.
setData
({
copyDisplayOptions
:
copyDisplay
})
this
.
triggerEvent
(
'change'
,
{
values
:
selected
,
items
:
this
.
getSelectedItems
()
})
if
(
this
.
properties
.
confirmOnSelect
)
{
this
.
onConfirm
()
}
}
},
search
(
e
)
{
let
{
labelKey
,
copyDisplayOptions
,
displayOptions
,
selectedValues
,
valueKey
}
=
this
.
data
let
{
value
}
=
e
.
detail
if
(
!
value
)
{
copyDisplayOptions
.
map
(
i
=>
{
i
.
checked
=
false
if
(
selectedValues
.
includes
(
i
[
valueKey
]))
i
.
checked
=
true
return
i
})
this
.
setData
({
displayOptions
:
copyDisplayOptions
})
}
else
{
let
arr
=
[]
copyDisplayOptions
.
map
(
i
=>
{
i
.
checked
=
false
if
(
selectedValues
.
includes
(
i
[
valueKey
]))
i
.
checked
=
true
if
(
i
[
labelKey
].
indexOf
(
value
)
!=
-
1
)
{
arr
.
push
(
i
)
}
})
this
.
setData
({
displayOptions
:
arr
})
}
},
onCancel
()
{
this
.
triggerEvent
(
'cancel'
)
},
onConfirm
()
{
const
values
=
this
.
data
.
selectedValues
const
items
=
this
.
getSelectedItems
()
this
.
triggerEvent
(
'confirm'
,
{
values
,
items
})
},
getSelectedItems
()
{
return
(
this
.
data
.
copyDisplayOptions
||
[]).
filter
(
it
=>
it
.
checked
)
}
}
})
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment