|
@@ -1,5 +1,5 @@
|
|
|
import { defineComponent } from 'vue'
|
|
|
-import { Tag, CheckboxGroup, Checkbox } from 'vant'
|
|
|
+import { Tag, CheckboxGroup, Checkbox, RadioGroup, Radio } from 'vant'
|
|
|
import styles from './select.module.less'
|
|
|
import classNames from 'classnames'
|
|
|
|
|
@@ -13,9 +13,17 @@ export default defineComponent({
|
|
|
onSelect: {
|
|
|
type: Function,
|
|
|
default: () => {}
|
|
|
+ },
|
|
|
+ rowSingle: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ needAllButton: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
}
|
|
|
},
|
|
|
- setup({ child, onSelect }, { attrs }) {
|
|
|
+ setup({ child, onSelect, needAllButton, rowSingle }, { attrs }) {
|
|
|
return () => {
|
|
|
const selected = attrs.selected as number[]
|
|
|
return (
|
|
@@ -26,19 +34,32 @@ export default defineComponent({
|
|
|
onSelect(val)
|
|
|
}}
|
|
|
>
|
|
|
- <Checkbox name={0} class={styles.radio} onClick={() => onSelect([])}>
|
|
|
- <Tag
|
|
|
- class={classNames(styles.item, 'van-ellipsis')}
|
|
|
- type="primary"
|
|
|
- plain={selected.length !== 0}
|
|
|
- round
|
|
|
- size="large"
|
|
|
+ {needAllButton && (
|
|
|
+ <Checkbox
|
|
|
+ name={0}
|
|
|
+ class={styles.radio}
|
|
|
+ onClick={() => onSelect([])}
|
|
|
>
|
|
|
- 全部
|
|
|
- </Tag>
|
|
|
- </Checkbox>
|
|
|
+ <Tag
|
|
|
+ class={classNames(styles.item, 'van-ellipsis')}
|
|
|
+ type="primary"
|
|
|
+ plain={selected.length !== 0}
|
|
|
+ round
|
|
|
+ size="large"
|
|
|
+ >
|
|
|
+ 全部
|
|
|
+ </Tag>
|
|
|
+ </Checkbox>
|
|
|
+ )}
|
|
|
{child.map((item: any) => (
|
|
|
- <Checkbox key={item.id} name={item.id} class={styles.radio}>
|
|
|
+ <Checkbox
|
|
|
+ key={item.id}
|
|
|
+ name={item.id}
|
|
|
+ class={styles.radio}
|
|
|
+ onClick={() => {
|
|
|
+ rowSingle && onSelect([item.id])
|
|
|
+ }}
|
|
|
+ >
|
|
|
<Tag
|
|
|
class={classNames(styles.item, 'van-ellipsis')}
|
|
|
plain={!selected.includes(item.id)}
|