checkBoxPicker.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. this.$emit('chooseCon', arr);
  84. this.isShow = false;
  85. },
  86. getChooseItem(e) {
  87. const row = this.list.find(item => item.code == e.name)
  88. if(row){
  89. row.checked = !row.checked
  90. this.list.splice()
  91. }
  92. }
  93. },
  94. watch: {
  95. // 父页面传过来的弹框状态
  96. showModal(newValue, oldValue) {
  97. this.isShow = newValue;
  98. },
  99. // 重定义的弹框状态
  100. isShow(newValue, oldValue) {
  101. if (!newValue) {
  102. this.$emit('close');
  103. } else {
  104. this.getList();
  105. }
  106. }
  107. }
  108. };
  109. </script>
  110. <style lang="scss" scoped>
  111. .content {
  112. width: 100%;
  113. height: 100%;
  114. .con {
  115. flex-grow: 1;
  116. overflow: auto;
  117. padding: 0 40rpx;
  118. .choose-list {
  119. border-bottom: 1rpx solid #efefef;
  120. padding: 20rpx 0;
  121. &:last-child {
  122. border-bottom: 0rpx solid #efefef;
  123. }
  124. .u-checkbox{
  125. display: inline-block !important;
  126. }
  127. }
  128. }
  129. .btn {
  130. border-top: 1rpx solid #efefef;
  131. .cancleStyle,
  132. .confimStyle {
  133. width: 50%;
  134. text-align: center;
  135. height: 89rpx;
  136. line-height: 89rpx;
  137. text-align: center;
  138. }
  139. }
  140. }
  141. </style>