Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mocp-uniapp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pangchong
mocp-uniapp
Commits
f8eefbd7
Commit
f8eefbd7
authored
Jun 05, 2024
by
pangchong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 复选框
parent
94a179cf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
src/mocp/components/global-checkbox/global-checkbox.vue
+20
-17
No files found.
src/mocp/components/global-checkbox/global-checkbox.vue
View file @
f8eefbd7
<
template
>
<
template
>
<!-- 全局复选框 -->
<view
class=
"checkbox"
:style=
"getStyle"
>
<view
class=
"checkbox"
:style=
"getStyle"
>
<up-checkbox-group
<up-checkbox-group
v-model=
"checkboxValue"
:placement=
"placement"
:placement=
"placement"
@
change=
"checkboxChange"
@
change=
"checkboxChange"
:disabled=
"disabled"
:disabled=
"disabled"
...
@@ -21,7 +23,7 @@
...
@@ -21,7 +23,7 @@
</
template
>
</
template
>
<
script
setup
>
<
script
setup
>
import
{
computed
,
ref
}
from
'vue'
import
{
computed
,
ref
,
watch
}
from
'vue'
import
*
as
dictData
from
'mocp/hooks/use-dict/dict-data'
import
*
as
dictData
from
'mocp/hooks/use-dict/dict-data'
import
{
cloneDeep
}
from
'lodash'
import
{
cloneDeep
}
from
'lodash'
...
@@ -34,7 +36,7 @@ const ps = defineProps({
...
@@ -34,7 +36,7 @@ const ps = defineProps({
},
},
dictkey
:
{
dictkey
:
{
type
:
String
,
type
:
String
,
default
:
''
default
:
'
leaderState
'
},
},
modelValue
:
{
modelValue
:
{
type
:
String
,
type
:
String
,
...
@@ -43,20 +45,7 @@ const ps = defineProps({
...
@@ -43,20 +45,7 @@ const ps = defineProps({
options
:
{
options
:
{
type
:
Array
,
type
:
Array
,
default
:
()
=>
{
default
:
()
=>
{
return
[
return
[]
{
label
:
'苹果'
,
value
:
1
},
{
label
:
'香蕉'
,
value
:
2
},
{
label
:
'橙子'
,
value
:
3
}
]
}
}
},
},
labelField
:
{
labelField
:
{
...
@@ -107,6 +96,7 @@ const ps = defineProps({
...
@@ -107,6 +96,7 @@ const ps = defineProps({
default
:
false
default
:
false
}
}
})
})
const
checkboxValue
=
ref
([])
//获取复选框样式
//获取复选框样式
const
getStyle
=
computed
(()
=>
{
const
getStyle
=
computed
(()
=>
{
let
checkboxAlign
=
'flex-start'
let
checkboxAlign
=
'flex-start'
...
@@ -124,7 +114,7 @@ const getCustomStyle = computed(() => {
...
@@ -124,7 +114,7 @@ const getCustomStyle = computed(() => {
...
ps
.
customStyle
...
ps
.
customStyle
}
}
if
(
ps
.
placement
==
'row'
)
{
if
(
ps
.
placement
==
'row'
)
{
_style
.
marginLeft
=
'
32
rpx'
_style
.
marginLeft
=
'
16
rpx'
}
}
return
_style
return
_style
})
})
...
@@ -145,6 +135,19 @@ const getColumns = computed(() => {
...
@@ -145,6 +135,19 @@ const getColumns = computed(() => {
}
}
}
}
})
})
//监听设置默认值
watch
(
[()
=>
ps
.
modelValue
,
()
=>
ps
.
options
],
()
=>
{
ps
.
modelValue
.
split
(
ps
.
valueSplit
).
forEach
((
item
)
=>
{
let
option
=
getColumns
.
value
.
find
((
option
)
=>
String
(
option
[
ps
.
valueField
])
===
String
(
item
))
if
(
option
)
{
checkboxValue
.
value
.
push
(
option
[
ps
.
valueField
])
}
})
},
{
immediate
:
true
}
)
const
checkboxChange
=
(
value
)
=>
{
const
checkboxChange
=
(
value
)
=>
{
es
(
'update:modelValue'
,
value
.
join
(
ps
.
valueSplit
))
es
(
'update:modelValue'
,
value
.
join
(
ps
.
valueSplit
))
es
(
'change'
,
value
.
join
(
ps
.
valueSplit
))
es
(
'change'
,
value
.
join
(
ps
.
valueSplit
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment