WareHouseHistoryPanel.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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) {
  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(params),
  109. this.wareHouseService.collectHistoryList(params),
  110. this.lossService.getLossByTradeName({
  111. current: 1,
  112. size: 20,
  113. goodsName: this.tradeName
  114. })
  115. ])
  116. this.wareHouseHistoryList = (wareData && wareData.records) || []
  117. this.collectHistoryList = (collectData && collectData.records) || []
  118. this.lossHistoryList = (lossData && lossData.records) || []
  119. } finally {
  120. this.loading = false
  121. }
  122. },
  123. close() {
  124. this.visible = false
  125. },
  126. formatShelfLife(row) {
  127. if (row.shelfLife && row.shelfLifeUnit) {
  128. return `${row.shelfLife}${row.shelfLifeUnit}`
  129. }
  130. return '-'
  131. },
  132. calcCollectRecordNumber(row) {
  133. if (row.notSurplusStock && row.spec) {
  134. const value = parseFloat(row.notSurplusStock) / parseFloat(row.spec)
  135. if (Number.isNaN(value)) {
  136. return '-'
  137. }
  138. return Number.isInteger(value) ? String(value) : value.toFixed(2)
  139. }
  140. return '-'
  141. }
  142. }
  143. }
  144. </script>
  145. <style scoped>
  146. .panel-mask {
  147. position: fixed;
  148. inset: 0;
  149. background: rgba(0, 0, 0, 0.35);
  150. opacity: 0;
  151. visibility: hidden;
  152. transition: all 0.25s ease;
  153. z-index: 1000;
  154. }
  155. .panel-mask.show {
  156. opacity: 1;
  157. visibility: visible;
  158. }
  159. .history-panel {
  160. position: fixed;
  161. left: 0;
  162. right: 0;
  163. bottom: 0;
  164. height: 78vh;
  165. background: #f7f9fc;
  166. border-radius: 28rpx 28rpx 0 0;
  167. transform: translateY(100%);
  168. transition: transform 0.25s ease;
  169. z-index: 1001;
  170. display: flex;
  171. flex-direction: column;
  172. }
  173. .history-panel.show {
  174. transform: translateY(0);
  175. }
  176. .panel-header {
  177. display: flex;
  178. align-items: center;
  179. justify-content: space-between;
  180. padding: 28rpx 32rpx 16rpx;
  181. background: #fff;
  182. border-bottom: 1rpx solid #eef2f7;
  183. }
  184. .panel-title {
  185. max-width: 460rpx;
  186. font-size: 32rpx;
  187. font-weight: 600;
  188. color: #1f2937;
  189. overflow: hidden;
  190. text-overflow: ellipsis;
  191. white-space: nowrap;
  192. }
  193. .panel-action {
  194. min-width: 80rpx;
  195. font-size: 28rpx;
  196. color: #2979ff;
  197. }
  198. .panel-action-placeholder {
  199. opacity: 0;
  200. }
  201. .history-tabs {
  202. display: grid;
  203. grid-template-columns: repeat(3, minmax(0, 1fr));
  204. gap: 12rpx;
  205. padding: 18rpx 24rpx;
  206. background: #fff;
  207. }
  208. .history-tab {
  209. padding: 16rpx 0;
  210. text-align: center;
  211. border-radius: 999rpx;
  212. font-size: 26rpx;
  213. color: #475569;
  214. background: #f1f5f9;
  215. }
  216. .history-tab.active {
  217. color: #fff;
  218. background: #2979ff;
  219. }
  220. .history-list {
  221. flex: 1;
  222. padding: 18rpx 24rpx 32rpx;
  223. }
  224. .history-list-inner {
  225. display: flex;
  226. flex-direction: column;
  227. gap: 16rpx;
  228. }
  229. .panel-state {
  230. padding-top: 120rpx;
  231. text-align: center;
  232. font-size: 28rpx;
  233. color: #94a3b8;
  234. }
  235. .history-card {
  236. padding: 22rpx;
  237. background: #fff;
  238. border-radius: 18rpx;
  239. box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.05);
  240. }
  241. .history-title {
  242. margin-bottom: 12rpx;
  243. font-size: 28rpx;
  244. font-weight: 700;
  245. color: #0f172a;
  246. word-break: break-all;
  247. }
  248. .history-grid {
  249. display: flex;
  250. flex-direction: column;
  251. gap: 8rpx;
  252. font-size: 24rpx;
  253. line-height: 1.5;
  254. color: #475569;
  255. }
  256. </style>