dropdown-item.wxml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <wxs module="_" src="./util.wxs" />
  2. <view wx:if="{{wrapperVisible}}" class="{{classPrefix}}" style="top:{{top}}px; z-index: {{zIndex + 1}}">
  3. <t-popup
  4. visible="{{show}}"
  5. z-index="{{zIndex + 1}}"
  6. duration="{{duration}}"
  7. show-overlay="{{showOverlay}}"
  8. custom-style="position: absolute;"
  9. overlayProps="{{ { customStyle: 'position: absolute' } }}"
  10. bind:leaved="onLeaved"
  11. bind:visible-change="handleMaskClick"
  12. class="{{classPrefix}}__popup-host"
  13. t-class-content="{{contentClasses}} {{classPrefix}}__content"
  14. >
  15. <view class="{{classPrefix}}__body">
  16. <block wx:if="{{optionsLayout === 'columns'}}">
  17. <!-- 单选列表 -->
  18. <t-cell-group wx:if="{{!multiple}}">
  19. <t-radio-group class="{{classPrefix}}__radio" value="{{value}}" bind:change="handleRadioChange">
  20. <t-radio
  21. wx:for="{{options}}"
  22. wx:key="index"
  23. class="{{classPrefix}}__radio-item"
  24. icon="stroke-line"
  25. align="right"
  26. t-class="radio"
  27. t-class-label="radio__label radio__label--{{value == item[valueAlias] ? 'active' : ''}}"
  28. value="{{item[valueAlias]}}"
  29. label="{{item[labelAlias]}}"
  30. disabled="{{item.disabled}}"
  31. ></t-radio>
  32. </t-radio-group>
  33. </t-cell-group>
  34. <!-- 多选列表 -->
  35. <block wx:else>
  36. <t-checkbox-group
  37. class="{{classPrefix}}__checkbox"
  38. t-class="{{classPrefix}}__checkbox-group"
  39. custom-style="grid-template-columns: repeat({{optionsColumns}}, 1fr)"
  40. value="{{value}}"
  41. bind:change="handleRadioChange"
  42. >
  43. <block wx:for="{{options}}" wx:key="index">
  44. <t-checkbox
  45. class="{{classPrefix}}__checkbox-item"
  46. theme="tag"
  47. value="{{item[valueAlias]}}"
  48. label="{{item[labelAlias]}}"
  49. disabled="{{item.disabled}}"
  50. ></t-checkbox>
  51. </block>
  52. </t-checkbox-group>
  53. </block>
  54. </block>
  55. <block wx:elif="{{optionsLayout === 'tree'}}">
  56. <scroll-view
  57. scroll-y
  58. class="{{classPrefix}}__column {{classPrefix}}__column--{{_.getTreeClass(leafLevel - level)}}"
  59. wx:for="{{treeOptions}}"
  60. wx:key="level"
  61. wx:for-index="level"
  62. >
  63. <block wx:if="{{level < leafLevel}}">
  64. <view
  65. wx:for="{{treeOptions[level]}}"
  66. wx:key="index"
  67. bind:tap="handleTreeClick"
  68. data-level="{{level}}"
  69. data-value="{{item[valueAlias]}}"
  70. class="{{classPrefix}}__tree-item {{item[valueAlias] === value[level] ? classPrefix + '__tree-item--active' : '' }}"
  71. >
  72. {{item[labelAlias]}}
  73. </view>
  74. </block>
  75. <block wx:else>
  76. <block wx:if="{{!multiple}}">
  77. <t-radio-group
  78. class="{{classPrefix}}__radio"
  79. data-level="{{level}}"
  80. value="{{value[level]}}"
  81. bind:change="handleRadioChange"
  82. >
  83. <t-radio
  84. wx:for="{{treeOptions[level]}}"
  85. wx:key="value"
  86. class="{{classPrefix}}__radio-item"
  87. t-class="radio"
  88. t-class-label="radio__label radio__label--{{value[level] === item[valueAlias] ? 'active' : ''}}"
  89. value="{{item[valueAlias]}}"
  90. borderless
  91. align="right"
  92. >{{item[labelAlias]}}</t-radio
  93. >
  94. </t-radio-group>
  95. </block>
  96. <block wx:elif="{{multiple}}">
  97. <t-checkbox-group
  98. class="{{classPrefix}}__checkbox"
  99. value="{{value[level]}}"
  100. bind:change="handleRadioChange"
  101. data-level="{{level}}"
  102. >
  103. <t-checkbox
  104. wx:for="{{treeOptions[level]}}"
  105. wx:key="value"
  106. align="right"
  107. t-class="radio"
  108. t-class-label="radio__label radio__label--{{value[level] === item[valueAlias] ? 'active' : ''}}"
  109. borderless
  110. value="{{item[valueAlias]}}"
  111. >{{item[labelAlias]}}</t-checkbox
  112. >
  113. </t-checkbox-group>
  114. </block>
  115. </block>
  116. </scroll-view>
  117. </block>
  118. <slot />
  119. </view>
  120. <view class="{{classPrefix}}__foot" wx:if="{{multiple || optionsLayout === 'tree'}}">
  121. <t-button-group>
  122. <t-button
  123. block
  124. size="large"
  125. class="{{classPrefix}}__reset-btn"
  126. t-class="button button--reset"
  127. theme="default"
  128. disabled="{{!hasChanged}}"
  129. bindtap="handleReset"
  130. >重置</t-button
  131. >
  132. <t-button
  133. block
  134. size="large"
  135. class="{{classPrefix}}__confirm-btn"
  136. t-class="button button--confirm"
  137. theme="primary"
  138. disabled="{{!hasChanged}}"
  139. bindtap="handleConfirm"
  140. >确定</t-button
  141. >
  142. </t-button-group>
  143. </view>
  144. </t-popup>
  145. </view>