redioPicker.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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">
  7. <view>{{ item.dispName }}</view>
  8. <!-- <u-icon v-show="chooseFlag==i" name="checkbox-mark" color="#2979ff" size="28"></u-icon> -->
  9. <u-radio-group v-model="chooseVal">
  10. <u-radio :name="item.code" @change="getChooseItem"></u-radio>
  11. </u-radio-group>
  12. </view>
  13. </view>
  14. <view class="btn u-flex">
  15. <view class="cancleStyle" @click="isShow = false">取消</view>
  16. <view class="confimStyle" :style="{ background: $config('primaryColor'), color: '#fff' }" @click="submit">确定</view>
  17. </view>
  18. </view>
  19. </u-popup>
  20. </view>
  21. </template>
  22. <script>
  23. import { getLookUpDatas } from '@/api/data';
  24. export default {
  25. props: {
  26. showModal: {
  27. type: Boolean,
  28. default: false
  29. },
  30. code: {
  31. type: String,
  32. default: ''
  33. },
  34. val: {
  35. type: String,
  36. default: ''
  37. }
  38. },
  39. data() {
  40. return {
  41. isShow: this.showModal,
  42. chooseObj: null,
  43. chooseVal: null,
  44. dataList: []
  45. };
  46. },
  47. methods: {
  48. getList() {
  49. getLookUpDatas({
  50. lookupCode: this.code,
  51. pageNo: 1,
  52. pageSize: 1000
  53. }).then(result => {
  54. if (result && result.status + '' === '200') {
  55. this.dataList = result.data.list;
  56. //勾选上次选中值
  57. if (this.val) {
  58. this.chooseVal = this.val;
  59. }
  60. }
  61. });
  62. },
  63. submit(index) {
  64. if (!this.chooseVal) {
  65. this.chooseObj = null;
  66. }
  67. this.$emit('chooseItem', this.chooseObj);
  68. this.isShow = false;
  69. },
  70. getChooseItem(e) {
  71. if (this.chooseVal == e) {
  72. this.chooseVal ='';
  73. } else {
  74. this.chooseVal = e;
  75. }
  76. const index = this.dataList.findIndex(item => {
  77. return item.code == e;
  78. });
  79. this.chooseObj = this.dataList[index];
  80. }
  81. },
  82. watch: {
  83. // 父页面传过来的弹框状态
  84. showModal(newValue, oldValue) {
  85. this.isShow = newValue;
  86. },
  87. // 重定义的弹框状态
  88. isShow(newValue, oldValue) {
  89. if (!newValue) {
  90. this.$emit('close');
  91. } else {
  92. this.getList();
  93. }
  94. }
  95. }
  96. };
  97. </script>
  98. <style lang="scss" scoped>
  99. .content {
  100. width: 100%;
  101. height: 100%;
  102. .con {
  103. flex-grow: 1;
  104. overflow: auto;
  105. padding: 0 40rpx;
  106. .choose-list {
  107. border-bottom: 1rpx solid #efefef;
  108. padding: 20rpx 0;
  109. &:last-child {
  110. border-bottom: 0rpx solid #efefef;
  111. }
  112. .u-radio{
  113. display: inline-block !important;
  114. }
  115. }
  116. }
  117. .btn {
  118. border-top: 1rpx solid #efefef;
  119. .cancleStyle,
  120. .confimStyle {
  121. width: 50%;
  122. text-align: center;
  123. height: 89rpx;
  124. line-height: 89rpx;
  125. text-align: center;
  126. }
  127. }
  128. }
  129. </style>