checkBoxPicker.vue 3.2 KB

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