matterPop.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view>
  3. <u-popup :show="show" duration='300' :mode='mode' :closeOnClickOverlay='false'>
  4. <view class="content-box">
  5. <view class="list_box">
  6. <u-list @scrolltolower="scrolltolower">
  7. <checkbox-group v-for="(item, index) in list" :key="index"
  8. @change="e => selectVal(e, item, index)">
  9. <label class="listBox rx-bs">
  10. <view class="listBox-sel">
  11. <checkbox :value="item.code" color="#fff" :disabled="item.disabled"
  12. :checked="item.checked" />
  13. </view>
  14. <view class="listBox-con">
  15. <view class="listBox-top rx-bc">
  16. <view> {{ item.name }}</view>
  17. <view class="code">{{ item.code}}</view>
  18. </view>
  19. <view class="listBox-bottom rx">
  20. <view v-for="(itm, index) in tableH(1)" :key="index" class="item100">
  21. {{ itm.label }}:{{ item[itm.prop] }}
  22. </view>
  23. </view>
  24. </view>
  25. </label>
  26. </checkbox-group>
  27. <view style='margin-top: 20vh;' v-if='list.length == 0'>
  28. <u-empty iconSize='150' textSize='32' text='暂无数据'>
  29. </u-empty>
  30. </view>
  31. </u-list>
  32. </view>
  33. <view class="operate_box rx-sc">
  34. <u-button size="small" class="u-reset-button" @click="handleClose">取消</u-button>
  35. <u-button size="small" class="u-reset-button" type="success" @click="save">确认 </u-button>
  36. </view>
  37. </view>
  38. </u-popup>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. tableHeader
  44. } from '../../common.js'
  45. import { getInventoryDetails } from '@/api/pda/feeding.js'
  46. export default {
  47. props: {
  48. matterId: [String, Number],
  49. categoryId: [String, Number],
  50. mattList: {
  51. type: Array,
  52. default: () => {}
  53. }
  54. },
  55. data() {
  56. return {
  57. show: true,
  58. mode: 'right',
  59. memoList: [],
  60. list: []
  61. }
  62. },
  63. created() {
  64. this.getList()
  65. },
  66. methods: {
  67. getList() {
  68. let param = {
  69. pageNum: 1,
  70. size: -1,
  71. categoryId: this.categoryId
  72. }
  73. getInventoryDetails(param).then(res => {
  74. let list = []
  75. list.push(
  76. ...res.list.map(i => {
  77. const checked =
  78. this.mattList.findIndex(itm => itm.id == i.id) > -1
  79. return {
  80. checked,
  81. ...i
  82. }
  83. })
  84. )
  85. this.list = list
  86. })
  87. },
  88. scrolltolower() {},
  89. save() {
  90. let _arr = []
  91. _arr = this.list.filter(f => f.checked)
  92. this.$emit('mattSave', _arr, this.matterId)
  93. },
  94. //勾选
  95. selectVal(e, val, index) {
  96. this.list[index].checked = !this.list[index].checked
  97. const idx = this.memoList.findIndex(
  98. item => item.code === this.list[index].code
  99. )
  100. if (this.list[index].checked) {
  101. if (idx === -1) {
  102. this.memoList.push(this.list[index])
  103. }
  104. } else {
  105. if (idx > -1) {
  106. this.memoList.splice(idx, 1)
  107. }
  108. }
  109. },
  110. tableH(type) {
  111. return tableHeader(type)
  112. },
  113. handleClose() {
  114. this.$emit('close')
  115. },
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .content-box {
  121. width: 80vw;
  122. height: 100vh;
  123. overflow: hidden;
  124. display: flex;
  125. flex-direction: column;
  126. background-color: $page-bg;
  127. }
  128. .list_box {
  129. flex: 1;
  130. overflow: hidden;
  131. padding: 4rpx 0;
  132. .u-list {
  133. height: 100% !important;
  134. }
  135. }
  136. .listBox {
  137. margin-top: 8rpx;
  138. padding: 8rpx 24rpx;
  139. background: #fff;
  140. /deep/ .uni-checkbox-input-checked {
  141. background-color: $theme-color !important;
  142. border-color: $theme-color !important;
  143. }
  144. .listBox-con {
  145. width: 650rpx;
  146. font-weight: 400;
  147. }
  148. .listBox-top {
  149. margin-top: 6rpx;
  150. color: #090A0A;
  151. font-size: 28rpx;
  152. font-style: normal;
  153. }
  154. .listBox-bottom {
  155. color: #090A0A;
  156. font-size: 24rpx;
  157. font-style: normal;
  158. flex-wrap: wrap;
  159. .item100 {
  160. width: 100%;
  161. margin-top: 8rpx;
  162. }
  163. .items {
  164. width: 50%;
  165. margin-top: 8rpx;
  166. }
  167. }
  168. }
  169. .operate_box {
  170. background-color: #fff;
  171. padding: 10rpx 100rpx;
  172. /deep/ .u-button {
  173. width: 160rpx;
  174. }
  175. }
  176. </style>