CargoSpaceInfoDialog.vue 8.5 KB

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