redioPicker.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. val:{
  32. type: String,
  33. default: ''
  34. }
  35. },
  36. data(){
  37. return{
  38. isShow:this.showModal,
  39. chooseObj:null,
  40. chooseFlag:-1,
  41. dataList:[]
  42. }
  43. },
  44. methods:{
  45. getList(){
  46. getLookUpDatas({
  47. lookupCode: this.code,pageNo:1,pageSize:1000
  48. }).then(result => {
  49. if (result && result.status + '' === '200') {
  50. this.dataList = result.data.list
  51. //勾选上次选中值
  52. if(this.val){
  53. let pos=result.data.list.findIndex(item=>{
  54. return item.code == this.val
  55. })
  56. if(pos != -1){
  57. this.chooseFlag = pos
  58. }
  59. }
  60. }
  61. })
  62. },
  63. submit(index){
  64. if(this.chooseFlag == -1){
  65. this.chooseObj = null
  66. }
  67. this.$emit('chooseItem',this.chooseObj)
  68. this.isShow = false
  69. },
  70. getChooseItem(index){
  71. if(this.chooseFlag == index){
  72. this.chooseFlag = -1
  73. }else{
  74. this.chooseFlag = index
  75. }
  76. this.chooseObj=this.dataList[index]
  77. }
  78. },
  79. watch:{
  80. // 父页面传过来的弹框状态
  81. showModal (newValue, oldValue) {
  82. this.isShow = newValue
  83. },
  84. // 重定义的弹框状态
  85. isShow (newValue, oldValue) {
  86. if (!newValue) {
  87. this.$emit('close')
  88. }else{
  89. this.getList();
  90. }
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. .content{
  97. width: 100%;
  98. height: 100%;
  99. .con{
  100. flex-grow: 1;
  101. overflow: auto;
  102. padding:0 40rpx;
  103. .choose-list{
  104. border-bottom: 1rpx solid #efefef;
  105. padding:20rpx 0;
  106. &:last-child{
  107. border-bottom: 0rpx solid #efefef;
  108. }
  109. }
  110. }
  111. .btn{
  112. border-top: 1rpx solid #efefef;
  113. .cancleStyle,.confimStyle{
  114. width: 50%;
  115. text-align: center;
  116. height: 89rpx;
  117. line-height: 89rpx;
  118. text-align: center;
  119. }
  120. }
  121. }
  122. </style>