CargoSpaceInfoDialog copy.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <uni-popup ref="popup" background-color="#fff" :is-mask-click="false">
  3. <view class="pop-container">
  4. <!-- <uni-nav-bar fixed="true" statusBar="true" :title="cargoSpace">
  5. </uni-nav-bar> -->
  6. <view class="tools-box">
  7. <uni-easyinput prefixIcon="search" v-model="searchVal" placeholder="编码、名称"></uni-easyinput>
  8. </view>
  9. <view class="dialog-title">
  10. <text class="text-success">货位{{ cargoSpace }}</text>
  11. <view class="all">
  12. <div>选中调拨 {{ selected }}/{{ tableData.length }} 项</div>
  13. </view>
  14. </view>
  15. <view class="scroll-wrapper">
  16. <!-- <AssetsCard
  17. v-for="item in showTable"
  18. :key="item.produceId"
  19. :item="item"
  20. /> -->
  21. <view class="card-list" v-for="(item, index) in tableData" :key="index">
  22. <view class="title">{{ item.assetName }}({{ item.assetCode }})</view>
  23. <view class="card-row">
  24. <view class="card-col" v-for="(itm, index) in tableHeader(item.assetType)" :key="index">
  25. <text class="label">{{ itm.label }}</text>
  26. <template v-if="itm.formatter">{{ itm.formatter(item) }}</template>
  27. <template v-else>{{ item[itm.prop] }}</template>
  28. </view>
  29. <view class="card-col">
  30. <text class="label">类型</text>
  31. <!-- {{ getDictValue('物品类型', item.assetType) }} -->
  32. </view>
  33. <view class="card-col">
  34. <text class="label">库存数量</text>
  35. {{ item.stocker }}{{ item.isUnpack ? item.unit : item.minPackUnit }}
  36. </view>
  37. <view class="card-col">
  38. <text class="label">可调拨数量</text>
  39. {{ item.max }}{{ item.isUnpack ? item.unit : item.minPackUnit }}
  40. </view>
  41. </view>
  42. <view class="card-footer">
  43. <view style="margin-top: -40rpx">调拨数量</view>
  44. <u-number-box v-if="item.takeStockPattern" v-model="item.amount" :min="0" :max="+item.max"></u-number-box>
  45. <text class="text-primary num" @click="handleDetail(item)" v-else>{{ (item.detailReqList && item.detailReqList.length) || 0 || '选择' }}</text>
  46. </view>
  47. </view>
  48. <u-empty text="暂无数据" v-if="!tableData.length"></u-empty>
  49. </view>
  50. <view class="footer">
  51. <u-button size="large" @click="cancel">返回</u-button>
  52. <u-button size="large" type="success" @click="confirm">提交</u-button>
  53. </view>
  54. </view>
  55. <DetailDialog ref="detailRef" :assetsList="assetsList" :preAssetsList="preAssetsList" />
  56. </uni-popup>
  57. </template>
  58. <script>
  59. import { getPackingList } from '@/api/warehouseManagement'
  60. import DetailDialog from './DetailDialog'
  61. import AssetsCard from './AssetsCard'
  62. import { tableHeader } from '../../common'
  63. import { get } from '@/utils/api.js'
  64. // import dictMixins from '@/mixins/dictMixins'
  65. export default {
  66. components: { AssetsCard, DetailDialog },
  67. // mixins: [dictMixins],
  68. props: {
  69. assetsList: {
  70. type: Array,
  71. default: () => []
  72. },
  73. preAssetsList: {
  74. type: Array,
  75. default: () => []
  76. }
  77. },
  78. data() {
  79. return {
  80. page: 1,
  81. size: 10,
  82. total: 0,
  83. tableData: [],
  84. cargoSpace: '',
  85. searchVal: '',
  86. selectAll: false
  87. }
  88. },
  89. created() {
  90. this.requestDict('物品类型')
  91. },
  92. computed: {
  93. // showTable() {
  94. // return this.tableData.filter(item => {
  95. // if (this.searchVal) {
  96. // if (String(assetName).indexOf(this.searchVal) != -1 || String(assetCode).indexOf(this.searchVal) != -1) {
  97. // return true
  98. // }
  99. // return false
  100. // }
  101. // return true
  102. // })
  103. // },
  104. selected() {
  105. // let sum = 0
  106. // this.tableData.forEach(item => {
  107. // if (item.takeStockPattern) {
  108. // sum += +item.amount
  109. // } else {
  110. // sum += item.detailReqList?.length || 0
  111. // }
  112. // })
  113. return this.tableData.filter(item => {
  114. if (item.takeStockPattern) {
  115. return !!+item.amount
  116. } else {
  117. return !!item.detailReqList?.length
  118. }
  119. }).length
  120. }
  121. },
  122. methods: {
  123. tableHeader,
  124. async open(warehouse) {
  125. this.cargoSpace = warehouse.warehouseName + '-' + warehouse.areaName + '-' + warehouse.shelfCode + '-' + warehouse.cargoSpaceCode
  126. this.warehouse = warehouse
  127. this.$refs.popup.open('right')
  128. let params = {
  129. warehouseId: warehouse.warehouseId,
  130. warehouseAreaId: warehouse.areaId,
  131. warehouseAreaGoodsId: warehouse.shelfId,
  132. warehouseAreaGoodsShelvesId: warehouse.cargoSpaceId
  133. }
  134. const data = await getPackingList({
  135. ...params,
  136. pageNum: this.page,
  137. size: this.size
  138. })
  139. console.log(data)
  140. this.total = data.count
  141. this.tableData = data.list
  142. // const res = await get(
  143. // this.apiUrl +
  144. // `/conventionalStockTransfer/warehouse/getGoodsDetail/${warehouse.cargoSpaceId}`
  145. // )
  146. // if (res?.success) {
  147. // this.tableData = res.data.map(i => {
  148. // // 唯一id 添加相同判断
  149. // i.curId = warehouse.cargoSpaceId + i.assetCode
  150. // let preAmount = 0
  151. // let tempAmount = 0
  152. // // 预调入数量需展示,但不可修改,展示剩余可调拨
  153. // const index1 = this.preAssetsList.findIndex(
  154. // item => item.curId === i.curId
  155. // )
  156. // if (index1 > -1) {
  157. // preAmount = this.preAssetsList[index1].amount
  158. // }
  159. // i.stocker = +i.amount
  160. // i.amount = 0
  161. // const index = this.assetsList.findIndex(
  162. // item => item.curId === i.curId
  163. // )
  164. // if (index > -1) {
  165. // tempAmount = this.assetsList[index].amount
  166. // }
  167. // i.max = i.stocker - preAmount - tempAmount
  168. // delete i.id
  169. // return i
  170. // })
  171. // }
  172. },
  173. handleAllChange(e) {
  174. this.tableData.map(item => {
  175. item.checked = !!e.detail.value.length
  176. })
  177. },
  178. handleDetail(item) {
  179. this.$refs.detailRef.open(item, this.warehouse.cargoSpaceId, res => {
  180. this.$set(
  181. item,
  182. 'detailReqList',
  183. res.filter(i => i.checked)
  184. )
  185. })
  186. },
  187. confirm() {
  188. const selection = this.tableData.filter(item => {
  189. Object.assign(item, this.warehouse)
  190. if (!item.takeStockPattern) {
  191. item.amount = item.detailReqList?.length
  192. }
  193. return item.amount > 0
  194. })
  195. if (!selection.length) {
  196. uni.showToast({
  197. title: '请至少选择一条数据',
  198. icon: 'none'
  199. })
  200. return
  201. }
  202. this.$emit('success', selection)
  203. this.cancel()
  204. },
  205. cancel() {
  206. this.$refs.popup.close()
  207. this.$emit('cancel')
  208. this.tableData = []
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss" scoped>
  214. view {
  215. box-sizing: border-box;
  216. }
  217. .pop-container {
  218. padding-top: $tab-height;
  219. height: 100vh;
  220. width: 100vw;
  221. display: flex;
  222. flex-direction: column;
  223. .scroll-wrapper {
  224. flex: 1;
  225. overflow: auto;
  226. padding-bottom: 220rpx;
  227. }
  228. }
  229. .card-list {
  230. font-size: 28rpx;
  231. padding: 10rpx 20rpx;
  232. .title {
  233. margin-bottom: 20rpx;
  234. font-size: 32rpx;
  235. font-weight: bold;
  236. }
  237. .card-row {
  238. display: flex;
  239. justify-content: space-between;
  240. flex-wrap: wrap;
  241. padding: 0rpx 20rpx;
  242. .card-col {
  243. width: 50%;
  244. margin-bottom: 20rpx;
  245. .label {
  246. margin-right: 20rpx;
  247. }
  248. }
  249. }
  250. .card-footer {
  251. display: flex;
  252. // justify-content: flex-end;
  253. flex-direction: column;
  254. align-items: flex-end;
  255. .num {
  256. margin-bottom: 5rpx;
  257. display: inline-block;
  258. border: 1rpx solid $j-primary-green;
  259. padding: 8rpx 20rpx;
  260. border-radius: 10rpx;
  261. }
  262. /deep/.u-number-box {
  263. align-items: stretch;
  264. height: 60rpx;
  265. .u-number-box__input {
  266. width: 80rpx !important;
  267. height: auto !important;
  268. }
  269. .u-number-box__minus,
  270. .u-number-box__plus {
  271. height: auto !important;
  272. }
  273. }
  274. }
  275. }
  276. ::v-deep.scroll-wrapper {
  277. // height: 50vh;
  278. overflow: auto;
  279. .assets-cell {
  280. & + .assets-cell {
  281. margin-top: 10px;
  282. }
  283. }
  284. }
  285. .tools-box {
  286. padding: 12rpx;
  287. .all {
  288. display: flex;
  289. justify-content: space-between;
  290. align-items: center;
  291. padding: 12rpx 0 0;
  292. }
  293. }
  294. .dialog-title {
  295. width: 100vw;
  296. text-align: left;
  297. display: flex;
  298. justify-content: space-between;
  299. position: relative;
  300. text-align: center;
  301. font-size: 28rpx;
  302. padding: 20rpx;
  303. // background-color: $j-primary-border-green;
  304. span {
  305. position: absolute;
  306. top: 50%;
  307. left: 50%;
  308. transform: translate(-50%, -50%);
  309. }
  310. }
  311. .footer {
  312. position: fixed;
  313. bottom: 0;
  314. left: 0;
  315. right: 0;
  316. display: flex;
  317. justify-content: space-between;
  318. }
  319. </style>