1 files added
2 files modified
New file |
| | |
| | | /** |
| | | * CSwitchRadio |
| | | * @author Tevin |
| | | */ |
| | | |
| | | <template> |
| | | <view |
| | | class="c-switch c-switch-radio" |
| | | :class="className" |
| | | > |
| | | <AtSwitch :title="itemRes.label" /> |
| | | <radio-group @change="evt => handleChange(evt.detail.value)"> |
| | | <label> |
| | | <radio |
| | | value="true" |
| | | :checked="itemRes.formData[itemRes.name]" |
| | | >{{checkedLabel}}</radio> |
| | | </label> |
| | | <label> |
| | | <radio |
| | | value="false" |
| | | :checked="!itemRes.formData[itemRes.name]" |
| | | >{{uncheckedLabel}}</radio> |
| | | </label> |
| | | </radio-group> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import { AtSwitch } from 'taro-ui-vue'; |
| | | import './cSwitch.scss'; |
| | | |
| | | export default { |
| | | name: 'CSwitchRadio', |
| | | components: { AtSwitch }, |
| | | props: { |
| | | // 表单数据资源(表单组件内部机制专用) |
| | | itemRes: Object, |
| | | checkedLabel: { |
| | | type: String, |
| | | default: '是', |
| | | }, |
| | | uncheckedLabel: { |
| | | type: String, |
| | | default: '否', |
| | | }, |
| | | }, |
| | | data() { |
| | | return {}; |
| | | }, |
| | | computed: { |
| | | className() { |
| | | let className = ''; |
| | | if (this.itemRes.required) { |
| | | className += 'c-switch-required '; |
| | | } |
| | | if (this.itemRes.error) { |
| | | className += 'c-switch-error '; |
| | | } |
| | | return className; |
| | | }, |
| | | }, |
| | | methods: { |
| | | handleChange(value) { |
| | | this.itemRes.onChange(JSON.parse(value)); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | |
| | | color: #FF4949; |
| | | } |
| | | } |
| | | &.c-switch-radio { |
| | | position: relative; |
| | | .at-switch__title { |
| | | flex: 4; |
| | | } |
| | | .at-switch__container { |
| | | visibility: hidden; |
| | | } |
| | | .weui-cells_radiogroup { |
| | | @include position(absolute, 50% n n 0); |
| | | padding: 24px 32px 24px 0; |
| | | transform: translateY(-50%); |
| | | } |
| | | .weui-check:checked+.weui-icon-checked:before { |
| | | color: #2093df; |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | |
| | | import CSwitch from '@components/forms/switch/CSwitch.vue'; |
| | | import CSwitchRadio from '@components/forms/switch/CSwitchRadio.vue'; |
| | | |
| | | export { |
| | | CSwitch, |
| | | CSwitchRadio, |
| | | } |