血透系统pad前端

TwoMenu.vue 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <div class="Dialog" v-show="show">
  3. <div class="DialogTit">
  4. <div class="back" @click="hide()">
  5. <span class="iconfont">&#xe720;</span>返回
  6. </div>
  7. <h1 class="name">{{ title }}</h1>
  8. <!-- <span class="success" @click="handle_selected()">完成</span> -->
  9. <span v-if="type == 1" class="success"></span>
  10. <span v-if="type == 2" @click="handle_selected" class="success"
  11. >确定</span
  12. >
  13. </div>
  14. <div class="optionsBox" v-show="type == 1">
  15. <div class="list">
  16. <ul>
  17. <li
  18. v-for="(item, i) in single.options"
  19. :key="i"
  20. :value="single.id_key.lenght == 0 ? item : item[single.id_key]"
  21. :class="
  22. single.cur_id ==
  23. (single.id_key.lenght == 0 ? item : item[single.id_key])
  24. ? 'tick'
  25. : ''
  26. "
  27. @click="
  28. single_click(
  29. single.id_key.lenght == 0 ? item : item[single.id_key]
  30. )
  31. "
  32. >
  33. {{ single.show_key.lenght == 0 ? item : item[single.show_key] }}
  34. </li>
  35. </ul>
  36. </div>
  37. </div>
  38. <div class="CheckBox" v-show="type == 2">
  39. <ul>
  40. <li>
  41. <van-checkbox-group v-model="mutable.selected_values">
  42. <van-checkbox
  43. style="border-bottom: 1px #e5e5e5 solid;padding: 0 0.38rem;width:100%;"
  44. v-for="(item, index) in mutable.options"
  45. :key="index"
  46. :name="mutable.id_key.lenght == 0 ? item : item[mutable.id_key]"
  47. >
  48. {{ mutable.show_key.lenght == 0 ? item : item[mutable.show_key] }}
  49. </van-checkbox>
  50. </van-checkbox-group>
  51. </li>
  52. </ul>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. export default {
  58. name: "TwoMenu",
  59. data() {
  60. return {
  61. // list: ["复选框1", "复选框2"],
  62. // result: ["复选框1"],
  63. show: false,
  64. type: 1, // 1.单选 2.复选
  65. handle_select: null, // function
  66. handle_hide: null, // function
  67. title: "",
  68. single: {
  69. options: [],
  70. cur_id: 0,
  71. show_key: "",
  72. id_key: ""
  73. },
  74. mutable: {
  75. options: [],
  76. selected_values: [],
  77. show_key: "",
  78. id_key: ""
  79. }
  80. };
  81. },
  82. methods: {
  83. showSingleSelect(
  84. list_options,
  85. current_select_id,
  86. title,
  87. show_key,
  88. id_key,
  89. handle_select,
  90. handle_hide
  91. ) {
  92. this.show = true;
  93. this.type = 1;
  94. this.title = title;
  95. this.single.options = list_options;
  96. this.single.cur_id = current_select_id;
  97. this.single.show_key = show_key;
  98. this.single.id_key = id_key;
  99. this.handle_select = handle_select;
  100. this.handle_hide = handle_hide;
  101. console.log(this.single.cur_id);
  102. },
  103. // showMutableSelect(list_options, selected_values, title, show_key, id_key, handle_select) {
  104. // this.show = true
  105. // this.type = 2
  106. // this.title = title
  107. // this.mutable.options = list_options
  108. // this.mutable.selected_values = selected_values
  109. // this.mutable.show_key = show_key
  110. // this.mutable.id_key = id_key
  111. // this.handle_select = handle_select
  112. // },
  113. hide() {
  114. if (this.handle_hide != null && this.handle_hide != undefined) {
  115. this.handle_hide();
  116. }
  117. this.show = false;
  118. },
  119. single_click: function(id) {
  120. this.single.cur_id = id;
  121. this.finish_selected();
  122. this.hide();
  123. },
  124. finish_selected: function() {
  125. if (this.handle_select != null && this.handle_select != undefined) {
  126. this.handle_select(this.single.cur_id);
  127. }
  128. }
  129. }
  130. };
  131. </script>
  132. <style style="stylesheet/scss" lang="scss" scoped>
  133. .van-checkbox__icon--checked .van-icon {
  134. color: #fff;
  135. border-color: $main-color !important;
  136. background-color: $main-color !important;
  137. }
  138. .optionsBox {
  139. background: #fff;
  140. max-height: 10.6rem;
  141. min-height: 5rem;
  142. overflow-y: scroll;
  143. @media only screen and (max-width: 812px) {
  144. min-height: 8rem !important;
  145. }
  146. @media only screen and (min-width: 415px) and (max-width: 737px) {
  147. max-height: 12.6rem !important;
  148. }
  149. ul {
  150. li {
  151. height: 1.2rem;
  152. line-height: 1.2rem;
  153. border-bottom: 1px #e5e5e5 solid;
  154. padding: 0 0.38rem;
  155. font-size: 0.45rem;
  156. }
  157. .tick {
  158. position: relative;
  159. &::before {
  160. content: "";
  161. display: inline-block;
  162. border: 2px solid $main-color;
  163. border-top-width: 0;
  164. border-right-width: 0;
  165. width: 0.3rem;
  166. height: 0.15rem;
  167. -webkit-transform: rotate(-50deg);
  168. position: absolute;
  169. top: 0.38rem;
  170. right: 0.44rem;
  171. }
  172. }
  173. }
  174. }
  175. .CheckBox {
  176. background: #fff;
  177. max-height: 10.6rem;
  178. min-height: 5rem;
  179. overflow-y: scroll;
  180. ul {
  181. li {
  182. line-height: 1rem;
  183. }
  184. }
  185. }
  186. </style>