checkBoxPicker.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.dispName }}</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. 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. list: []
  38. };
  39. },
  40. created() {
  41. this.getList();
  42. },
  43. methods: {
  44. getList() {
  45. if(this.code =='SALES_BILL_STATUS'){
  46. this.list= [
  47. { id: 1099, isChecked: false,code:'WAIT_SUBMIT', dispName: '待提交' },
  48. { id: 1100, isChecked: false,code:'SALES_BILL_STATUS', dispName: '待审核' },
  49. { id: 1102, isChecked: false,code:'SALES_BILL_STATUS', dispName: '待出库' },
  50. { id: 1103, isChecked: false, code:'FINISH',dispName: '已完结' }
  51. ]
  52. }else{
  53. getLookUpDatas({
  54. lookupCode: this.code,
  55. pageNo: 1,
  56. pageSize: 1000
  57. }).then(result => {
  58. if (result && result.status + '' === '200') {
  59. result.data.list.forEach(con => {
  60. con.isChecked = false
  61. });
  62. this.list = result.data.list;
  63. }
  64. });
  65. }
  66. },
  67. submit(index) {
  68. let arr = [];
  69. this.list.forEach(con => {
  70. if (con.isChecked) {
  71. arr.push(con);
  72. }
  73. });
  74. this.$emit('chooseCon', arr);
  75. this.isShow = false;
  76. },
  77. getChooseItem(index) {
  78. this.list[index].isChecked = !this.list[index].isChecked;
  79. }
  80. },
  81. watch: {
  82. // 父页面传过来的弹框状态
  83. showModal(newValue, oldValue) {
  84. this.isShow = newValue;
  85. },
  86. // 重定义的弹框状态
  87. isShow(newValue, oldValue) {
  88. if (!newValue) {
  89. this.$emit('close');
  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,
  114. .confimStyle {
  115. width: 50%;
  116. text-align: center;
  117. height: 89rpx;
  118. line-height: 89rpx;
  119. text-align: center;
  120. }
  121. }
  122. }
  123. </style>