checkBoxPicker.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view>
  3. <u-popup v-model="isShow" @close="isShow = false" mode="bottom" safe-area-inset-bottom border-radius="20" >
  4. <view class="content flex flex_column">
  5. <view class="con">
  6. <view class="choose-list u-flex u-row-between" v-for="(item,i) in list" :key="item.id" @click="getChooseItem(i)">
  7. <view>{{item.name}}</view>
  8. <u-icon v-show="item.isChecked" name="checkbox-mark" color="#2979ff" size="28"></u-icon>
  9. </view>
  10. </view>
  11. <view class="btn u-flex">
  12. <view class="cancleStyle" @click="isShow = false">取消</view>
  13. <view class="confimStyle" :style="{background:$config('primaryColor'),color:'#fff'}" @click="submit">确定</view>
  14. </view>
  15. </view>
  16. </u-popup>
  17. </view>
  18. </template>
  19. <script>
  20. export default{
  21. props:{
  22. showModal:{
  23. type: Boolean,
  24. default: false
  25. },
  26. dataList:{
  27. type: Array,
  28. default: ()=>[]
  29. }
  30. },
  31. data(){
  32. return{
  33. isShow:this.showModal,
  34. chooseObj:null,
  35. chooseFlag:-1,
  36. list:[]
  37. }
  38. },
  39. methods:{
  40. submit(index){
  41. let arr = [];
  42. this.list.forEach(con=>{
  43. if(con.isChecked){
  44. arr.push(con)
  45. }
  46. })
  47. this.$emit('chooseCon',arr)
  48. this.isShow = false
  49. },
  50. getChooseItem(index){
  51. this.list[index].isChecked=!this.list[index].isChecked;
  52. }
  53. },
  54. watch:{
  55. // 父页面传过来的弹框状态
  56. showModal (newValue, oldValue) {
  57. this.isShow = newValue
  58. },
  59. // 重定义的弹框状态
  60. isShow (newValue, oldValue) {
  61. if (!newValue) {
  62. this.$emit('close')
  63. }else{
  64. this.list=this.dataList;
  65. }
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .content{
  72. width: 100%;
  73. height: 100%;
  74. .con{
  75. flex-grow: 1;
  76. overflow: auto;
  77. padding:0 40rpx;
  78. .choose-list{
  79. border-bottom: 1rpx solid #efefef;
  80. padding:20rpx 0;
  81. &:last-child{
  82. border-bottom: 0rpx solid #efefef;
  83. }
  84. }
  85. }
  86. .btn{
  87. border-top: 1rpx solid #efefef;
  88. .cancleStyle,.confimStyle{
  89. width: 50%;
  90. text-align: center;
  91. height: 89rpx;
  92. line-height: 89rpx;
  93. text-align: center;
  94. }
  95. }
  96. }
  97. </style>