redioPicker.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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" v-if="dataList.length>0">
  6. <view class="choose-list u-flex u-row-between" v-for="(item,i) in dataList" :key="item.id" @click="getChooseItem(i)">
  7. <view>{{item.dispName}}</view>
  8. <u-icon v-show="chooseFlag==i" 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. import { getLookUpDatas } from '@/api/data';
  21. export default{
  22. props:{
  23. showModal:{
  24. type: Boolean,
  25. default: false
  26. },
  27. code:{
  28. type: String,
  29. default: ''
  30. }
  31. },
  32. data(){
  33. return{
  34. isShow:this.showModal,
  35. chooseObj:null,
  36. chooseFlag:-1,
  37. dataList:[]
  38. }
  39. },
  40. created() {
  41. this.getList();
  42. },
  43. methods:{
  44. getList(){
  45. getLookUpDatas({
  46. lookupCode: this.code,pageNo:1,pageSize:1000
  47. }).then(result => {
  48. if (result && result.status + '' === '200') {
  49. this.dataList = result.data.list
  50. }
  51. })
  52. },
  53. submit(index){
  54. if(this.chooseFlag == -1){
  55. this.chooseObj = null
  56. }
  57. this.$emit('chooseItem',this.chooseObj)
  58. this.isShow = false
  59. },
  60. getChooseItem(index){
  61. if(this.chooseFlag == index){
  62. this.chooseFlag = -1
  63. }else{
  64. this.chooseFlag = index
  65. }
  66. this.chooseObj=this.dataList[index]
  67. }
  68. },
  69. watch:{
  70. // 父页面传过来的弹框状态
  71. showModal (newValue, oldValue) {
  72. this.isShow = newValue
  73. },
  74. // 重定义的弹框状态
  75. isShow (newValue, oldValue) {
  76. if (!newValue) {
  77. this.$emit('close')
  78. }
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .content{
  85. width: 100%;
  86. height: 100%;
  87. .con{
  88. flex-grow: 1;
  89. overflow: auto;
  90. padding:0 40rpx;
  91. .choose-list{
  92. border-bottom: 1rpx solid #efefef;
  93. padding:20rpx 0;
  94. &:last-child{
  95. border-bottom: 0rpx solid #efefef;
  96. }
  97. }
  98. }
  99. .btn{
  100. border-top: 1rpx solid #efefef;
  101. .cancleStyle,.confimStyle{
  102. width: 50%;
  103. text-align: center;
  104. height: 89rpx;
  105. line-height: 89rpx;
  106. text-align: center;
  107. }
  108. }
  109. }
  110. </style>