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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
151 additions
and
318 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
},
/**
properties
:
{
* 页面的初始数据
show
:
{
*/
type
:
Boolean
,
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
:
{
data
:
{
IMG_URL
,
IMG_URL
,
navBarHeight
:
84
,
displayOptions
:
[],
// 带 checked 的渲染选项
statisticsData
:
{},
selectedValues
:
[]
// 选中的值列表(单选也统一用数组)
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
},
},
observers
:
{
/**
'options, multiple, value, values'
:
function
(
options
,
multiple
,
value
,
values
)
{
* 生命周期函数--监听页面加载
this
.
initDisplay
(
options
||
[],
multiple
,
value
,
values
)
*/
onLoad
(
options
)
{
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
()
{
},
},
show
(
n
)
{
/**
// 进出场时保持数据一致
* 生命周期函数--监听页面显示
if
(
n
)
{
*/
onShow
()
{
this
.
setData
({
allList
:
[],
pageNum
:
1
,
nothing
:
false
,
scrollTop
:
0
},
()
=>
{
this
.
getList
()
})
},
onScroll
(
e
)
{
this
.
setData
({
this
.
setData
({
pageScrollFlag
:
e
.
detail
.
scrollTop
>
0
searchValue
:
''
})
})
},
this
.
initDisplay
(
this
.
properties
.
options
||
[],
this
.
properties
.
multiple
,
this
.
properties
.
value
,
this
.
properties
.
values
)
}
scrollonReachBottom
()
{
const
{
pageNum
,
total
,
pageSize
}
=
this
.
data
;
if
(
Math
.
ceil
(
total
/
pageSize
)
>
pageNum
)
{
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
,
});
},
},
methods
:
{
// 跳转北森课程详情
initDisplay
(
options
=
[],
multiple
=
false
,
value
=
null
,
values
=
[])
{
goBeisenDetail
(
e
)
{
const
vKey
=
this
.
properties
.
valueKey
let
{
target
}
=
e
.
currentTarget
.
dataset
// 初始选中值统一转为数组
wx
.
showLoading
({
const
initSelected
=
multiple
?
(
Array
.
isArray
(
values
)
?
values
.
slice
()
:
[])
:
(
value
!==
null
&&
value
!==
undefined
?
value
:
[])
title
:
'加载中'
,
const
display
=
(
options
||
[]).
map
(
item
=>
{
mask
:
true
const
val
=
item
[
vKey
]
})
const
checked
=
initSelected
?.
some
(
v
=>
v
===
val
)
wx
.
$track
.
setTrackData
(
0
,
'supervisor_course_detail'
,
{},
''
)
return
{
...
item
,
checked
}
api
.
findBeiSenSSOToken
({}).
then
(
res
=>
{
})
wx
.
hideLoading
()
this
.
setData
({
const
beisenToken
=
res
.
data
;
displayOptions
:
display
,
if
(
beisenToken
)
{
copyDisplayOptions
:
wx
.
$util
.
deepClone
(
display
),
const
COURSE_ID
=
target
?.
courseId
;
selectedValues
:
initSelected
const
baseUrl
=
'https://cloud.italent.cn/PageHome/Index'
;
})
const
params
=
{
},
product
:
'Learning'
,
toggle
(
e
)
{
keyName
:
'Nusion'
,
const
{
index
,
item
}
=
e
.
currentTarget
.
dataset
pageCode
:
'LearningCourseTraineeDetailPage'
,
const
{
multiple
,
max
,
valueKey
}
=
this
.
properties
appCode
:
'Learning'
,
let
{
displayOptions
,
copyDisplayOptions
}
=
this
.
data
id
:
COURSE_ID
if
(
!
item
||
item
.
disabled
)
return
};
this
.
jumpUrl
=
''
if
(
multiple
)
{
const
queryString
=
Object
.
entries
(
params
)
let
nextChecked
=
!
item
.
checked
.
map
(([
key
,
value
])
=>
`
${
key
}
=
${
value
}
`
)
// 限制最大数量
.
join
(
'&'
);
if
(
nextChecked
&&
max
>
0
)
{
const
url
=
encodeURIComponent
(
`
${
baseUrl
}
?
${
queryString
}
#/viewDynamic?1=1`
);
const
selectedCount
=
this
.
data
.
selectedValues
.
length
const
tokenUrl
=
beisenToken
if
(
selectedCount
>=
max
)
{
wx
.
$router
.
jumpH5
(
`
${
tokenUrl
}
&return_url=
${
url
}
`
)
// 可根据项目规范提示用户,这里不做 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
{
}
else
{
wx
.
showToast
({
// 单选:取消其他,选中当前
title
:
'培训账号未创建'
,
const
currentVal
=
item
[
valueKey
]
icon
:
'none'
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
searchInput
(
e
)
{
let
{
value
}
=
e
.
detail
let
{
value
}
=
e
.
detail
this
.
setData
({
if
(
!
value
)
{
searchTitle
:
value
copyDisplayOptions
.
map
(
i
=>
{
})
i
.
checked
=
false
},
if
(
selectedValues
.
includes
(
i
[
valueKey
]))
i
.
checked
=
true
return
i
search
()
{
this
.
setData
({
pageNum
:
1
},
()
=>
{
this
.
getList
(
true
)
})
})
},
clear
()
{
this
.
setData
({
this
.
setData
({
searchTitle
:
''
displayOptions
:
copyDisplayOptions
},
()
=>
{
this
.
search
()
})
})
},
}
else
{
let
arr
=
[]
handleSort
()
{
copyDisplayOptions
.
map
(
i
=>
{
this
.
setData
({
i
.
checked
=
false
showSortPopup
:
true
if
(
selectedValues
.
includes
(
i
[
valueKey
]))
i
.
checked
=
true
})
if
(
i
[
labelKey
].
indexOf
(
value
)
!=
-
1
)
{
},
arr
.
push
(
i
)
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
({
this
.
setData
({
loadingList
:
false
displayOptions
:
arr
})
})
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
)
}
}
})
},
},
onCancel
()
{
/**
this
.
triggerEvent
(
'cancel'
)
* 生命周期函数--监听页面隐藏
*/
onHide
()
{
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
()
{
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
()
{
},
},
onConfirm
()
{
/**
const
values
=
this
.
data
.
selectedValues
* 页面上拉触底事件的处理函数
const
items
=
this
.
getSelectedItems
()
*/
this
.
triggerEvent
(
'confirm'
,
{
values
,
items
})
onReachBottom
()
{
},
},
getSelectedItems
()
{
/**
return
(
this
.
data
.
copyDisplayOptions
||
[]).
filter
(
it
=>
it
.
checked
)
* 用户点击右上角分享
}
*/
onShareAppMessage
()
{
}
}
})
})
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