WareHouseHistoryPanel.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view>
  3. <view class="panel-mask" :class="{ show: visible }" @tap="close"></view>
  4. <view class="history-panel" :class="{ show: visible }">
  5. <view class="panel-header">
  6. <view class="panel-action" @tap="close">关闭</view>
  7. <view class="panel-title">{{ tradeName || '库存记录' }}</view>
  8. <view class="panel-action panel-action-placeholder">关闭</view>
  9. </view>
  10. <view class="history-tabs">
  11. <view class="history-tab" :class="{ active: activeTab === 'wareHouse' }" @tap="activeTab = 'wareHouse'">
  12. 入库
  13. </view>
  14. <view class="history-tab" :class="{ active: activeTab === 'collect' }" @tap="activeTab = 'collect'">
  15. 领用
  16. </view>
  17. <view class="history-tab" :class="{ active: activeTab === 'loss' }" @tap="activeTab = 'loss'">
  18. 报损
  19. </view>
  20. </view>
  21. <scroll-view scroll-y class="history-list">
  22. <view v-if="loading" class="panel-state">加载中...</view>
  23. <view v-else-if="activeHistoryList.length === 0" class="panel-state">暂无记录</view>
  24. <view v-else class="history-list-inner">
  25. <view v-for="(record, index) in activeHistoryList" :key="record.id || index" class="history-card">
  26. <template v-if="activeTab === 'wareHouse'">
  27. <view class="history-title">{{ record.wareHouseName || record.wareHouseNumber || '-' }}</view>
  28. <view class="history-grid">
  29. <text>入库编号:{{ record.wareHouseNumber || '-' }}</text>
  30. <text>入库数量:{{ record.tradeNumber || '-' }}</text>
  31. <text>当前库存:{{ record.currentInventory || '-' }}</text>
  32. <text>生产日期:{{ record.produceDate || '-' }}</text>
  33. <text>保质期:{{ formatShelfLife(record) }}</text>
  34. <text>经办人:{{ record.wareHouseHandledBy || '-' }}</text>
  35. <text>入库时间:{{ record.wareHouseDate || '-' }}</text>
  36. </view>
  37. </template>
  38. <template v-else-if="activeTab === 'collect'">
  39. <view class="history-title">{{ record.collectNo || record.goodsName || '-' }}</view>
  40. <view class="history-grid">
  41. <text>领用数量:{{ calcCollectRecordNumber(record) }}</text>
  42. <text>当前库存:{{ record.currentInventory || '-' }}</text>
  43. <text>经办人:{{ record.collectHandleBy || '-' }}</text>
  44. <text>领用时间:{{ record.collectDate || '-' }}</text>
  45. </view>
  46. </template>
  47. <template v-else>
  48. <view class="history-title">{{ record.lossNo || record.goodsName || '-' }}</view>
  49. <view class="history-grid">
  50. <text>报损数量:{{ record.lossNumber || '-' }}</text>
  51. <text>经办人:{{ record.handledByName || '-' }}</text>
  52. <text>经办部门:{{ record.handledByOfficeName || '-' }}</text>
  53. <text>报损时间:{{ record.createTime || '-' }}</text>
  54. </view>
  55. </template>
  56. </view>
  57. </view>
  58. </scroll-view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import WareHouseService from '@/api/psi/WareHouseService'
  64. import LossService from '@/api/psi/LossService'
  65. export default {
  66. name: 'WareHouseHistoryPanel',
  67. data() {
  68. return {
  69. visible: false,
  70. loading: false,
  71. activeTab: 'wareHouse',
  72. tradeName: '',
  73. wareHouseHistoryList: [],
  74. collectHistoryList: [],
  75. lossHistoryList: []
  76. }
  77. },
  78. wareHouseService: null,
  79. lossService: null,
  80. computed: {
  81. activeHistoryList() {
  82. if (this.activeTab === 'wareHouse') {
  83. return this.wareHouseHistoryList
  84. }
  85. if (this.activeTab === 'collect') {
  86. return this.collectHistoryList
  87. }
  88. return this.lossHistoryList
  89. }
  90. },
  91. created() {
  92. this.wareHouseService = new WareHouseService()
  93. this.lossService = new LossService()
  94. },
  95. methods: {
  96. async open(row, supplierId) {
  97. this.tradeName = (row && row.tradeName) || ''
  98. this.activeTab = 'wareHouse'
  99. this.visible = true
  100. this.loading = true
  101. try {
  102. const params = {
  103. current: 1,
  104. size: 20,
  105. tradeName: this.tradeName
  106. }
  107. const [wareData, collectData, lossData] = await Promise.all([
  108. this.wareHouseService.wareHouseHistoryList({
  109. ...params,
  110. detailId: supplierId ? row.id || '' : ''
  111. }),
  112. this.wareHouseService.collectHistoryList(params),
  113. this.lossService.getLossByTradeName({
  114. current: 1,
  115. size: 20,
  116. goodsName: this.tradeName
  117. })
  118. ])
  119. this.wareHouseHistoryList = (wareData && wareData.records) || []
  120. this.collectHistoryList = (collectData && collectData.records) || []
  121. this.lossHistoryList = (lossData && lossData.records) || []
  122. } finally {
  123. this.loading = false
  124. }
  125. },
  126. close() {
  127. this.visible = false
  128. },
  129. formatShelfLife(row) {
  130. if (row.shelfLife && row.shelfLifeUnit) {
  131. return `${row.shelfLife}${row.shelfLifeUnit}`
  132. }
  133. return '-'
  134. },
  135. calcCollectRecordNumber(row) {
  136. if (row.notSurplusStock && row.spec) {
  137. const value = parseFloat(row.notSurplusStock) / parseFloat(row.spec)
  138. if (Number.isNaN(value)) {
  139. return '-'
  140. }
  141. return Number.isInteger(value) ? String(value) : value.toFixed(2)
  142. }
  143. return '-'
  144. }
  145. }
  146. }
  147. </script>
  148. <style scoped>
  149. .panel-mask {
  150. position: fixed;
  151. inset: 0;
  152. background: rgba(0, 0, 0, 0.35);
  153. opacity: 0;
  154. visibility: hidden;
  155. transition: all 0.25s ease;
  156. z-index: 1000;
  157. }
  158. .panel-mask.show {
  159. opacity: 1;
  160. visibility: visible;
  161. }
  162. .history-panel {
  163. position: fixed;
  164. left: 0;
  165. right: 0;
  166. bottom: 0;
  167. height: 78vh;
  168. background: #f7f9fc;
  169. border-radius: 28rpx 28rpx 0 0;
  170. transform: translateY(100%);
  171. transition: transform 0.25s ease;
  172. z-index: 1001;
  173. display: flex;
  174. flex-direction: column;
  175. }
  176. .history-panel.show {
  177. transform: translateY(0);
  178. }
  179. .panel-header {
  180. display: flex;
  181. align-items: center;
  182. justify-content: space-between;
  183. padding: 28rpx 32rpx 16rpx;
  184. background: #fff;
  185. border-bottom: 1rpx solid #eef2f7;
  186. }
  187. .panel-title {
  188. max-width: 460rpx;
  189. font-size: 32rpx;
  190. font-weight: 600;
  191. color: #1f2937;
  192. overflow: hidden;
  193. text-overflow: ellipsis;
  194. white-space: nowrap;
  195. }
  196. .panel-action {
  197. min-width: 80rpx;
  198. font-size: 28rpx;
  199. color: #2979ff;
  200. }
  201. .panel-action-placeholder {
  202. opacity: 0;
  203. }
  204. .history-tabs {
  205. display: grid;
  206. grid-template-columns: repeat(3, minmax(0, 1fr));
  207. gap: 12rpx;
  208. padding: 18rpx 24rpx;
  209. background: #fff;
  210. }
  211. .history-tab {
  212. padding: 16rpx 0;
  213. text-align: center;
  214. border-radius: 999rpx;
  215. font-size: 26rpx;
  216. color: #475569;
  217. background: #f1f5f9;
  218. }
  219. .history-tab.active {
  220. color: #fff;
  221. background: #2979ff;
  222. }
  223. .history-list {
  224. flex: 1;
  225. padding: 18rpx 24rpx 32rpx;
  226. }
  227. .history-list-inner {
  228. display: flex;
  229. flex-direction: column;
  230. gap: 16rpx;
  231. }
  232. .panel-state {
  233. padding-top: 120rpx;
  234. text-align: center;
  235. font-size: 28rpx;
  236. color: #94a3b8;
  237. }
  238. .history-card {
  239. padding: 22rpx;
  240. background: #fff;
  241. border-radius: 18rpx;
  242. box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.05);
  243. }
  244. .history-title {
  245. margin-bottom: 12rpx;
  246. font-size: 28rpx;
  247. font-weight: 700;
  248. color: #0f172a;
  249. word-break: break-all;
  250. }
  251. .history-grid {
  252. display: flex;
  253. flex-direction: column;
  254. gap: 8rpx;
  255. font-size: 24rpx;
  256. line-height: 1.5;
  257. color: #475569;
  258. }
  259. </style>