checkBoxPicker.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. };
  48. },
  49. methods: {
  50. getList() {
  51. getLookUpDatas({
  52. lookupCode: this.code,
  53. pageNo: 1,
  54. pageSize: 1000
  55. }).then(result => {
  56. if (result && result.status == 200) {
  57. if(this.filtrate){//筛选业务状态
  58. var selfArr=['WAIT_SUBMIT','WAIT_AUDIT','WAIT_OUT_WAREHOUSE','FINISH']
  59. result.data.list=result.data.list.filter((item,i)=>{
  60. if(selfArr.includes(item.code)){
  61. return item
  62. }
  63. })
  64. result.data.list.splice()
  65. }
  66. if (this.val) {//勾选上次选中值
  67. var valArr = this.val.split(',');
  68. result.data.list.forEach(value => {
  69. valArr.includes(value.code) ? value.checked=true:value.checked=false
  70. });
  71. }
  72. this.list = result.data.list;
  73. }
  74. });
  75. },
  76. submit(index) {
  77. let arr = [];
  78. this.list.forEach(con => {
  79. if (con.checked) {
  80. arr.push(con);
  81. }
  82. });
  83. if(arr.length == 0){
  84. uni.showToast({
  85. title:'参数值不能为空',
  86. icon:'none'
  87. })
  88. }else{
  89. this.$emit('chooseCon', arr);
  90. this.isShow = false;
  91. }
  92. },
  93. getChooseItem(e) {
  94. const row = this.list.find(item => item.code == e.name)
  95. if(row){
  96. row.checked = !row.checked
  97. this.list.splice()
  98. }
  99. }
  100. },
  101. watch: {
  102. // 父页面传过来的弹框状态
  103. showModal(newValue, oldValue) {
  104. this.isShow = newValue;
  105. },
  106. // 重定义的弹框状态
  107. isShow(newValue, oldValue) {
  108. if (!newValue) {
  109. this.$emit('close');
  110. } else {
  111. this.getList();
  112. }
  113. }
  114. }
  115. };
  116. </script>
  117. <style lang="scss" scoped>
  118. .content {
  119. width: 100%;
  120. height: 100%;
  121. .con {
  122. flex-grow: 1;
  123. overflow: auto;
  124. padding: 0 40rpx;
  125. .choose-list {
  126. border-bottom: 1rpx solid #efefef;
  127. padding: 20rpx 0;
  128. &:last-child {
  129. border-bottom: 0rpx solid #efefef;
  130. }
  131. .u-checkbox{
  132. display: inline-block !important;
  133. }
  134. }
  135. }
  136. .btn {
  137. border-top: 1rpx solid #efefef;
  138. .cancleStyle,
  139. .confimStyle {
  140. width: 50%;
  141. text-align: center;
  142. height: 89rpx;
  143. line-height: 89rpx;
  144. text-align: center;
  145. }
  146. }
  147. }
  148. </style>