平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 kuukautta sitten
3 kuukautta sitten
3 kuukautta sitten
3 kuukautta sitten
3 kuukautta sitten
3 kuukautta sitten
3 kuukautta sitten
3 kuukautta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view @touchmove.stop @touch.stop>
  3. <myCell v-show="cellVisible" :title="title" isLink :hasValue="value&&value.length?true:false" :border="false" @click="show = true"></myCell>
  4. <u-popup :show="show" mode="bottom" :closeable="true" :round="10" @close="close" @open="open">
  5. <view class="title">
  6. {{popupTitle}}
  7. </view>
  8. <view>
  9. <u-tabs :list="tabsList" :current="tabIndex" @change="tabsChange" :activeStyle="{
  10. color: '#000000',
  11. }" itemStyle="height:84rpx;width:33.33%;box-sizing:border-box;background:#fff;border-top:1rpx solid rgba(0,0,0,0.03)"></u-tabs>
  12. <view v-for="(item) in tabsList" :key="item.value">
  13. <template v-if="tabIndex == item.value">
  14. <u-radio-group v-model="selectValue" iconPlacement="right" placement="column" @change="change"
  15. borderBottom>
  16. <u-radio v-for="(item,index) in selectOptions" :key="index" :label="item.label"
  17. :name="item.value"></u-radio>
  18. </u-radio-group>
  19. </template>
  20. </view>
  21. <view style="padding: 36rpx 50rpx">
  22. <u-button @click="cofirm" type="primary" style="border-radius: 36rpx;height: 72rpx;"
  23. text="确定"></u-button>
  24. </view>
  25. </view>
  26. </u-popup>
  27. </view>
  28. </template>
  29. <script>
  30. import myCell from "@/components/cell.vue"
  31. export default {
  32. name: "selectRadio",
  33. components: {
  34. myCell
  35. },
  36. props: {
  37. value: {
  38. default: () => [],
  39. type: Array
  40. },
  41. labels: {
  42. default: () => [],
  43. type: Array
  44. },
  45. placeholder: {
  46. default: '请选择'
  47. },
  48. popupTitle: {
  49. default: "请选择",
  50. type: String
  51. },
  52. cellVisible: {
  53. default: true,
  54. },
  55. },
  56. data() {
  57. return {
  58. show: false,
  59. title: this.labels.join('/') || this.placeholder,
  60. tabsList: [{
  61. name: "系部",
  62. cate:"系部",
  63. value: 0,
  64. disabled: false,
  65. list: [{
  66. value: 222,
  67. label: '信息系'
  68. }, {
  69. value: 333,
  70. label: '金融系'
  71. }]
  72. },
  73. {
  74. name: "专业",
  75. cate:"专业",
  76. value: 1,
  77. disabled: true,
  78. list: [{
  79. value: 222,
  80. label: '计算机应用'
  81. }, {
  82. value: 333,
  83. label: '土木工程'
  84. }]
  85. },
  86. {
  87. name: "班级",
  88. cate:"班级",
  89. value: 2,
  90. disabled: true,
  91. list: [{
  92. value: 222,
  93. label: '1班'
  94. }, {
  95. value: 333,
  96. label: '2班'
  97. }]
  98. },
  99. ],
  100. tabIndex: 0,
  101. selectValue: null,
  102. selectOptions: [],
  103. selectValues: this.value,
  104. selectLabels: [],
  105. };
  106. },
  107. mounted() {
  108. // 获取第一个tab的selectOptions
  109. },
  110. methods: {
  111. close() {
  112. this.show = false
  113. },
  114. // 打开选择弹框
  115. open() {
  116. this.selectValues = this.value || []
  117. this.title = this.labels.join('/') || this.placeholder
  118. if(!this.selectValues.length){
  119. // 展示tabs第一个数据
  120. this.tabIndex = 0
  121. }else{
  122. // 展示tabs最后一个数据
  123. this.tabIndex = 2
  124. }
  125. this.setSelectOptions()
  126. this.show = true
  127. },
  128. // 设置单选列表数据
  129. setSelectOptions(){
  130. switch(this.tabIndex){
  131. case 0:
  132. this.selectOptions = this.tabsList[0].list
  133. break
  134. case 1:
  135. this.selectOptions = this.tabsList[1].list
  136. break
  137. case 2:
  138. this.selectOptions = this.tabsList[2].list
  139. break
  140. }
  141. },
  142. // 单选改变
  143. change(e) {
  144. // 赋值
  145. this.selectValues[this.tabIndex] = e
  146. let obj = this.selectOptions.find(e1 => e1.value == e)
  147. this.selectLabels[this.tabIndex] = obj.label
  148. // 切换tab
  149. if (this.tabIndex < this.tabsList.length - 1) {
  150. let nextItem = this.tabsList[this.tabIndex + 1]
  151. this.tabsChange(nextItem)
  152. }
  153. if(this.tabIndex == this.tabsList.length - 1){
  154. this.tabsList[this.tabIndex].name = obj.label
  155. }
  156. },
  157. // 切换tab
  158. tabsChange(item) {
  159. if (this.tabIndex == item.value) return
  160. this.tabIndex = item.value
  161. setTimeout(() => {
  162. this.setSelectOptions()
  163. this.selectValue = null
  164. this.initTabs()
  165. }, 150)
  166. },
  167. // 初始化tab数据
  168. initTabs() {
  169. for (let item of this.tabsList) {
  170. if (item.value > this.tabIndex) {
  171. item.disabled = true
  172. this.selectValues[item.value] = ''
  173. this.selectLabels[item.value] = ''
  174. } else if (item.value < this.tabIndex) {
  175. item.disabled = false
  176. } else {
  177. item.disabled = false
  178. this.selectValues[item.value] = ''
  179. this.selectLabels[item.value] = ''
  180. }
  181. item.name = this.selectLabels[item.value]||item.cate
  182. }
  183. },
  184. // 确定
  185. cofirm() {
  186. if (this.selectValues[2]) {
  187. this.$emit("input", this.selectValues)
  188. this.$emit("update:labels", this.selectLabels)
  189. this.$emit("change", this.selectValues)
  190. this.title = this.selectLabels.join('/')
  191. this.close()
  192. }else{
  193. this.$emit("input", [])
  194. this.$emit("update:labels", [])
  195. this.$emit("change", [])
  196. this.title = this.placeholder
  197. this.close()
  198. }
  199. },
  200. }
  201. }
  202. </script>
  203. <style scoped lang="scss">
  204. .title {
  205. color: #333;
  206. font-size: 32rpx;
  207. text-align: center;
  208. line-height: 100rpx;
  209. }
  210. .u-radio-group {
  211. width: 92%;
  212. height: 780rpx;
  213. overflow-y: auto;
  214. padding: 0 30rpx;
  215. .u-cell {
  216. background-color: #fff;
  217. border-radius: 20rpx 20rpx 0 0;
  218. padding: 24rpx 0;
  219. }
  220. }
  221. .u-border-bottom {
  222. border-color: #F6F6F6 !important;
  223. }
  224. .u-radio {
  225. margin-top: 18rpx;
  226. }
  227. .u-checkbox {
  228. margin-top: 18rpx;
  229. }
  230. </style>