index.wxml 1.3 KB

1234567891011121314151617181920212223242526
  1. <wux-cell-group id="wux-cell-group" wux-class="{{ prefixCls }}" prefixCls="{{ cellGroupPrefixCls }}" title="{{ title }}" label="{{ label }}">
  2. <block wx:for="{{ common.getOptions(options) }}" wx:for-item="option" wx:key="" wx:if="{{ options.length > 0 }}">
  3. <wux-checkbox
  4. prefixCls="{{ option.prefixCls || 'wux-checkbox' }}"
  5. cellPrefixCls="{{ option.cellPrefixCls || 'wux-cell' }}"
  6. selectablePrefixCls="{{ option.selectablePrefixCls || 'wux-selectable' }}"
  7. title="{{ option.title }}"
  8. label="{{ option.label }}"
  9. extra="{{ option.extra }}"
  10. value="{{ option.value }}"
  11. checked="{{ common.getChecked(inputValue, option) }}"
  12. disabled="{{ option.disabled }}"
  13. color="{{ option.color || 'balanced' }}"
  14. data-index="{{ index }}"
  15. bind:change="onCheckboxChange"
  16. />
  17. </block>
  18. <block wx:if="{{ options.length === 0 }}">
  19. <slot></slot>
  20. </block>
  21. </wux-cell-group>
  22. <wxs module="common">
  23. module.exports.getOptions = function(options) { return options.map(function(option) { if (option.constructor === 'String') { return { title: option, value: option } } return option }) }
  24. module.exports.getChecked = function(values, option) { return values.indexOf(option.value) !== -1 }
  25. </wxs>