DetailDialog.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <uni-popup ref="popup" background-color="#fff" :is-mask-click="false">
  3. <view class="container">
  4. <view class="tools-box">
  5. <uni-easyinput prefixIcon="search" v-model="searchVal" placeholder="编码、名称"></uni-easyinput>
  6. <view class="all" v-if="!type || type == 'input'">
  7. <view>已选 {{ selectionList.length }}/{{ tableData.length }} 项</view>
  8. <text @click="checkAll = !checkAll" class="text-primary">全选</text>
  9. </view>
  10. </view>
  11. <view class="list-container">
  12. <checkbox-group @change="checkboxChange">
  13. <view class="assets-cell" v-for="(item, index) in showList" :key="index">
  14. <label>
  15. <view class="title">
  16. {{ item.assetName }}
  17. <text>{{ item.onlyCode }}</text>
  18. </view>
  19. <view class="col">
  20. <text>
  21. <text class="label">批次号</text>
  22. {{ item.batchNo }}
  23. </text>
  24. <text>
  25. <text class="label">包装编码</text>
  26. {{ item.num }}
  27. </text>
  28. </view>
  29. <view class="col" v-if="!row.isUnpack">
  30. <text>
  31. <text class="label">最小包装单元</text>
  32. {{ `${item.measurementUnit || ''}${item.unit}/${item.minPackUnit}` }}
  33. </text>
  34. <text>
  35. <text class="label">入库天数</text>
  36. {{ item.day }}
  37. </text>
  38. </view>
  39. <view class="col">
  40. <text>
  41. <text class="label">{{ item.manufactureTime ? '生产日期' : '采购日期' }}</text>
  42. {{ item.manufactureTime || item.procurementTime }}
  43. </text>
  44. </view>
  45. <view class="col">
  46. <text>
  47. <text class="label">过期日期</text>
  48. {{ item.expirationTime }}
  49. </text>
  50. </view>
  51. <checkbox :key="forceUpdate" :value="item.id + ''" :checked="item.checked || !!item.disabled" :disabled="!!item.disabled" v-if="type != 'detail'"></checkbox>
  52. </label>
  53. </view>
  54. </checkbox-group>
  55. </view>
  56. </view>
  57. <view class="footer">
  58. <u-button size="large" type="success" @click="confirm" v-if="type != 'detail'">确认添加</u-button>
  59. <u-button size="large" @click="cancel">返回</u-button>
  60. </view>
  61. </uni-popup>
  62. </template>
  63. <script>
  64. import { tableHeader } from '../../common'
  65. import { get } from '@/utils/api.js'
  66. export default {
  67. props: {
  68. // 新增 or 反显
  69. type: {
  70. type: String,
  71. default: '' //新增
  72. },
  73. assetsList: {
  74. type: Array,
  75. default: () => []
  76. },
  77. preAssetsList: {
  78. type: Array,
  79. default: () => []
  80. }
  81. },
  82. data() {
  83. return {
  84. tableHeader,
  85. searchVal: '',
  86. tableData: [],
  87. selectionList: [],
  88. cargoSpace: '',
  89. row: {},
  90. callback: null,
  91. forceUpdate: true
  92. }
  93. },
  94. computed: {
  95. checkAll: {
  96. get() {
  97. return this.selectionList.length && this.selectionList.length == this.showList.length
  98. },
  99. set(val) {
  100. if (val) {
  101. this.selectionList = this.showList.map(item => item.id + '')
  102. this.showList.map(item => (item.checked = true))
  103. } else {
  104. this.selectionList = []
  105. this.showList.map(item => (item.checked = false))
  106. }
  107. this.forceUpdate = !this.forceUpdate
  108. }
  109. },
  110. showList() {
  111. if (this.searchVal) {
  112. return this.tableData.filter(({ assetName, onlyCode, assetCode, batchNo }) => {
  113. return String(assetName).indexOf(this.searchVal) != -1 || String(onlyCode).indexOf(this.searchVal) != -1
  114. })
  115. }
  116. return this.tableData
  117. }
  118. },
  119. methods: {
  120. async open(row, cargoSpaceId, callback) {
  121. this.row = row
  122. this.callback = callback
  123. this.$refs.popup.open('right')
  124. const disabledDetailReqList = [...(this.preAssetsList.find(i => i.curId == row.curId)?.detailReqList || []), ...(this.assetsList.find(i => i.curId == row.curId)?.detailReqList || [])]
  125. if (!this.type) {
  126. // const res = await get(
  127. // this.apiUrl + '/conventionalStockTransfer/warehouse/getGoodsSingle',
  128. // {
  129. // assetCode: row.assetCode,
  130. // assetType: row.assetType,
  131. // cargoSpaceId: cargoSpaceId
  132. // }
  133. // )
  134. if (res?.success) {
  135. this.tableData = res.data
  136. .map(i => {
  137. i.checked = false
  138. i.batchNo = i.batchNum
  139. const obj = (this.row.detailReqList || []).find(itm => itm.id == i.id)
  140. if (obj) {
  141. i.checked = true
  142. this.selectionList.push(i.id + '')
  143. }
  144. if (disabledDetailReqList.find(p => p.onlyCode == i.onlyCode)) {
  145. i.checked = false
  146. i.disabled = true
  147. }
  148. return i
  149. })
  150. .filter(item => !item.disabled)
  151. }
  152. } else {
  153. // 反显
  154. const reList = this.type == 'output' ? 'curDetailReqList' : 'detailReqList' //反显列表
  155. console.log(this.row[reList], 'this.row')
  156. this.tableData = uni.$u.deepClone(this.row[reList])
  157. this.tableData.forEach(itm => {
  158. if (itm.checked) {
  159. this.selectionList.push(itm.id + '')
  160. }
  161. })
  162. }
  163. },
  164. checkboxChange(val) {
  165. this.selectionList = val.detail.value
  166. },
  167. confirm() {
  168. let selection = this.tableData.map(item => {
  169. item.checked = this.selectionList.includes(item.id + '')
  170. return item
  171. })
  172. if (this.type !== 'output') {
  173. selection = this.tableData.filter(item => item.checked)
  174. }
  175. this.callback && this.callback(selection)
  176. this.cancel()
  177. },
  178. cancel() {
  179. this.tableData = []
  180. this.selectionList = []
  181. this.$refs.popup.close()
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .container {
  188. width: 100vw;
  189. padding: 88rpx + $tab-height 10rpx 0; //安全高度
  190. box-sizing: border-box;
  191. background-color: $page-bg;
  192. height: 100vh;
  193. display: flex;
  194. flex-direction: column;
  195. overflow: hidden;
  196. }
  197. .tools-box {
  198. margin-bottom: 20rpx;
  199. }
  200. .all {
  201. display: flex;
  202. justify-content: flex-end;
  203. padding: 10rpx;
  204. padding-right: 30rpx;
  205. text {
  206. margin-left: 40rpx;
  207. }
  208. }
  209. .footer {
  210. position: fixed;
  211. bottom: 0;
  212. left: 0;
  213. right: 0;
  214. }
  215. .list-container {
  216. flex: 1;
  217. box-sizing: border-box;
  218. padding-bottom: 220rpx;
  219. overflow: auto;
  220. }
  221. .assets-cell {
  222. padding: 10rpx;
  223. font-size: 28rpx;
  224. position: relative;
  225. background-color: #fff;
  226. margin-bottom: 30rpx;
  227. color: #7f7f7f;
  228. .title {
  229. display: flex;
  230. justify-content: space-between;
  231. font-weight: bold;
  232. font-size: 32rpx;
  233. color: #555;
  234. margin-bottom: 10rpx;
  235. }
  236. .col {
  237. display: flex;
  238. justify-content: space-between;
  239. margin-bottom: 8rpx;
  240. text {
  241. flex: 1;
  242. }
  243. .label {
  244. margin-right: 40rpx;
  245. }
  246. }
  247. uni-checkbox {
  248. position: absolute;
  249. right: 0;
  250. bottom: 10rpx;
  251. }
  252. }
  253. </style>