detail.uvue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <uni-navbar-lite @leftClick="handleBack" :show-right=false title="出库单详情"></uni-navbar-lite>
  3. <view class="page-container">
  4. <scroll-view class="page-content" :scroll-y="true">
  5. <!-- 出库单信息 -->
  6. <view class="section">
  7. <view class="info-card">
  8. <view class="info-row">
  9. <text class="info-label">出库单号</text>
  10. <text class="info-value">{{ salseCode }}</text>
  11. </view>
  12. <view class="info-row">
  13. <text class="info-label">状态</text>
  14. <text class="info-value status-text" :class="'status-' + status">{{ statusText }}</text>
  15. </view>
  16. <view class="info-row">
  17. <text class="info-label">创建人</text>
  18. <text class="info-value">{{ createBy }}</text>
  19. </view>
  20. <view class="info-row">
  21. <text class="info-label">领用人</text>
  22. <text class="info-value">{{ receiverUser }}</text>
  23. </view>
  24. <view class="info-row">
  25. <text class="info-label">创建时间</text>
  26. <text class="info-value">{{ createTime }}</text>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 物料明细 -->
  31. <view class="section">
  32. <view class="section-header">
  33. <view class="section-indicator"></view>
  34. <text class="section-title">物料明细</text>
  35. </view>
  36. <view class="material-list">
  37. <view v-if="lineList.length === 0" class="empty-tip">
  38. <text class="empty-tip-text">暂无物料</text>
  39. </view>
  40. <view
  41. v-else
  42. v-for="(item, index) in lineList"
  43. :key="index"
  44. class="material-item"
  45. >
  46. <view class="material-header">
  47. <text class="material-name">{{ getItemName(item) }}</text>
  48. <text class="material-status" :class="getLineStatus(item) == 'Y' ? 'status-received' : 'status-pending'">
  49. {{ getLineStatusText(item) }}
  50. </text>
  51. </view>
  52. <view class="material-spec" v-if="getSpecification(item)">
  53. <text class="spec-label">规格:</text>
  54. <text class="spec-value">{{ getSpecification(item) }}</text>
  55. </view>
  56. <view class="material-divider"></view>
  57. <view class="material-footer">
  58. <view class="quantity-info">
  59. <view class="detail-row">
  60. <text class="quantity-label">领料人:</text>
  61. <text class="quantity-value">{{ getReceiverUser(item) }}</text>
  62. </view>
  63. <view class="detail-row">
  64. <text class="quantity-label">签收人:</text>
  65. <text class="quantity-value">{{ getReceiverSigner(item) }}</text>
  66. </view>
  67. </view>
  68. <view class="right-info">
  69. <text class="quantity-num">{{ getQuantity(item) }} {{ getMeasureName(item) }}</text>
  70. </view>
  71. <view v-if="status == 'FINISHED' && getLineStatus(item) != 'Y'" class="receive-btn-wrap">
  72. <button class="receive-btn" @click="handleSignReceive(item)">签收</button>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </scroll-view>
  79. </view>
  80. </template>
  81. <script setup lang="uts">
  82. import { ref, computed } from 'vue'
  83. import { getProductSalseById, signReceiveLine } from '../../api/out/index'
  84. import { getUserInfo } from '../../utils/storage'
  85. const salseId = ref<string>("")
  86. const salseCode = ref<string>("")
  87. const status = ref<string>("")
  88. const createBy = ref<string>("")
  89. const receiverUser = ref<string>("")
  90. const createTime = ref<string>("")
  91. const lineList = ref<UTSJSONObject[]>([])
  92. let currentUserId: string = ''
  93. const statusText = computed((): string => {
  94. const s = status.value
  95. switch (s) {
  96. case 'PREPARE': return '待确认'
  97. case 'CONFIRMED': return '已确认'
  98. case 'EXECUTING': return '执行中'
  99. case 'FINISHED': return '已完成'
  100. case 'CANCEL': return '已取消'
  101. default: return s
  102. }
  103. })
  104. const getItemName = (item: UTSJSONObject): string => {
  105. if (item == null) return ''
  106. const val = item['itemName']
  107. return val != null ? val.toString() : ''
  108. }
  109. const getSpecification = (item: UTSJSONObject): string => {
  110. if (item == null) return ''
  111. const val = item['specification']
  112. return val != null ? val.toString() : ''
  113. }
  114. const getQuantity = (item: UTSJSONObject): string => {
  115. if (item == null) return '0'
  116. const val = item['quantitySalse']
  117. return val != null ? val.toString() : '0'
  118. }
  119. const getMeasureName = (item: UTSJSONObject): string => {
  120. if (item == null) return ''
  121. const val = item['measureName']
  122. return val != null ? val.toString() : ''
  123. }
  124. const getLineStatus = (item: UTSJSONObject): string => {
  125. if (item == null) return ''
  126. const val = item['receiverStatus']
  127. return val != null ? val.toString() : ''
  128. }
  129. const getReceiverUser = (item: UTSJSONObject): string => {
  130. if (item == null) return ''
  131. const val = item['receiverUser']
  132. return val != null ? val.toString() : ''
  133. }
  134. const getReceiverSigner = (item: UTSJSONObject): string => {
  135. if (item == null) return ''
  136. const val = item['receiverSigner']
  137. return val != null ? val.toString() : ''
  138. }
  139. const getLineStatusText = (item: UTSJSONObject): string => {
  140. const s = getLineStatus(item)
  141. if (s == 'Y') return '已签收'
  142. if (s == 'N') return '待签收'
  143. return s
  144. }
  145. const loadDetail = (): void => {
  146. const len = salseId.value.length as number
  147. if (len === 0) return
  148. getProductSalseById(salseId.value).then((res: any) => {
  149. const resData = res as UTSJSONObject
  150. const data = resData["data"] as UTSJSONObject
  151. salseCode.value = data['salseCode'] != null ? data['salseCode'].toString() : ''
  152. status.value = data['status'] != null ? data['status'].toString() : ''
  153. createBy.value = data['createNickName'] != null ? data['createNickName'].toString() : ''
  154. receiverUser.value = data['receiverUser'] != null ? data['receiverUser'].toString() : ''
  155. createTime.value = data['createTime'] != null ? data['createTime'].toString() : ''
  156. const lines = data['wmProductSalseLineList']
  157. if (lines != null) {
  158. const allLines = lines as UTSJSONObject[]
  159. // 只显示当前用户的明细
  160. lineList.value = allLines.filter((line: UTSJSONObject) => {
  161. const receiverUserId = line['receiverUserId']
  162. return receiverUserId != null && receiverUserId.toString() === currentUserId
  163. })
  164. } else {
  165. lineList.value = []
  166. }
  167. }).catch((e) => {
  168. const error = e as UTSError
  169. const errMsg = error?.message
  170. uni.showToast({ title: errMsg.toString(), icon: 'none' })
  171. })
  172. }
  173. const handleSignReceive = (item: UTSJSONObject): void => {
  174. const lineId = item['lineId']
  175. if (lineId == null) {
  176. uni.showToast({ title: '明细ID不存在', icon: 'none' })
  177. return
  178. }
  179. uni.showModal({
  180. title: '提示',
  181. content: '确认签收该物料?',
  182. success: (res) => {
  183. if (res.confirm) {
  184. signReceiveLine(lineId.toString()).then((res: any) => {
  185. uni.showToast({ title: '签收成功', icon: 'success' })
  186. loadDetail()
  187. }).catch((e) => {
  188. const error = e as UTSError
  189. const errMsg = error?.message
  190. uni.showToast({ title: errMsg.toString(), icon: 'none' })
  191. })
  192. }
  193. }
  194. })
  195. }
  196. const handleBack = (): void => {
  197. uni.navigateBack()
  198. }
  199. onLoad((options: any) => {
  200. const params = options as UTSJSONObject
  201. if (params != null && params['id'] != null) {
  202. salseId.value = params['id'].toString()
  203. const userInfo = getUserInfo()
  204. if (userInfo != null) {
  205. const userId = userInfo['userId']
  206. currentUserId = userId != null ? userId.toString() : ''
  207. }
  208. loadDetail()
  209. }
  210. })
  211. </script>
  212. <style lang="scss">
  213. .page-container {
  214. flex: 1;
  215. background-color: #e8f0f9;
  216. }
  217. .page-content {
  218. flex: 1;
  219. padding: 20rpx;
  220. }
  221. .section {
  222. margin-bottom: 20rpx;
  223. background: #ffffff;
  224. border-radius: 16rpx;
  225. padding: 20rpx;
  226. }
  227. .section-header {
  228. flex-direction: row;
  229. align-items: center;
  230. margin-bottom: 20rpx;
  231. }
  232. .section-indicator {
  233. width: 6rpx;
  234. height: 32rpx;
  235. background-color: #007aff;
  236. border-radius: 3rpx;
  237. margin-right: 12rpx;
  238. }
  239. .section-title {
  240. font-size: 32rpx;
  241. color: #333333;
  242. font-weight: bold;
  243. }
  244. .info-card {
  245. background-color: #f8f9fa;
  246. border-radius: 8rpx;
  247. padding: 20rpx;
  248. }
  249. .info-row {
  250. flex-direction: row;
  251. justify-content: space-between;
  252. margin-bottom: 16rpx;
  253. &:last-child {
  254. margin-bottom: 0;
  255. }
  256. }
  257. .info-label {
  258. font-size: 28rpx;
  259. color: #666666;
  260. }
  261. .info-value {
  262. font-size: 28rpx;
  263. color: #333333;
  264. }
  265. .status-text {
  266. &.status-PREPARE {
  267. color: #faad14;
  268. }
  269. &.status-CONFIRMED {
  270. color: #1890ff;
  271. }
  272. &.status-EXECUTING {
  273. color: #722ed1;
  274. }
  275. &.status-FINISHED {
  276. color: #52c41a;
  277. }
  278. &.status-CANCEL {
  279. color: #ff4d4f;
  280. }
  281. &.status-received {
  282. color: #52c41a;
  283. }
  284. &.status-pending {
  285. color: #faad14;
  286. }
  287. }
  288. .material-list {
  289. background-color: #f8f9fa;
  290. border-radius: 8rpx;
  291. padding: 20rpx;
  292. }
  293. .empty-tip {
  294. align-items: center;
  295. padding: 40rpx;
  296. }
  297. .empty-tip-text {
  298. color: #999999;
  299. font-size: 28rpx;
  300. }
  301. .material-item {
  302. background-color: #ffffff;
  303. border-radius: 12rpx;
  304. padding: 28rpx;
  305. margin-bottom: 20rpx;
  306. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  307. &:last-child {
  308. margin-bottom: 0;
  309. }
  310. }
  311. .material-header {
  312. flex-direction: row;
  313. justify-content: space-between;
  314. align-items: flex-start;
  315. margin-bottom: 16rpx;
  316. }
  317. .material-name {
  318. font-size: 32rpx;
  319. color: #333333;
  320. font-weight: bold;
  321. flex: 1;
  322. margin-right: 16rpx;
  323. line-height: 44rpx;
  324. }
  325. .material-status {
  326. font-size: 24rpx;
  327. padding: 8rpx 20rpx;
  328. border-radius: 12rpx;
  329. &.status-received {
  330. background-color: #f6ffed;
  331. color: #52c41a;
  332. }
  333. &.status-pending {
  334. background-color: #fff7e6;
  335. color: #fa8c16;
  336. }
  337. }
  338. .material-spec {
  339. flex-direction: row;
  340. margin-bottom: 16rpx;
  341. }
  342. .spec-label {
  343. font-size: 26rpx;
  344. color: #999999;
  345. margin-right: 8rpx;
  346. }
  347. .spec-value {
  348. font-size: 26rpx;
  349. color: #666666;
  350. flex: 1;
  351. }
  352. .material-divider {
  353. height: 2rpx;
  354. background-color: #f0f0f0;
  355. margin: 16rpx 0;
  356. }
  357. .material-footer {
  358. flex-direction: row;
  359. justify-content: space-between;
  360. align-items: center;
  361. }
  362. .quantity-info {
  363. flex-direction: column;
  364. flex: 1;
  365. }
  366. .right-info {
  367. justify-content: center;
  368. margin-right: 24rpx;
  369. }
  370. .quantity-num {
  371. font-size: 32rpx;
  372. color: #007aff;
  373. font-weight: bold;
  374. }
  375. .detail-row {
  376. flex-direction: row;
  377. margin-bottom: 8rpx;
  378. &:last-child {
  379. margin-bottom: 0;
  380. }
  381. }
  382. .quantity-label {
  383. font-size: 26rpx;
  384. color: #999999;
  385. width: 120rpx;
  386. }
  387. .quantity-value {
  388. font-size: 26rpx;
  389. color: #007aff;
  390. font-weight: bold;
  391. flex: 1;
  392. }
  393. .receive-btn-wrap {
  394. margin-left: 24rpx;
  395. }
  396. .receive-btn {
  397. padding: 14rpx 36rpx;
  398. background-color: #007aff;
  399. color: #ffffff;
  400. font-size: 26rpx;
  401. border-radius: 8rpx;
  402. border: none;
  403. font-weight: bold;
  404. &:active {
  405. background-color: #0056b3;
  406. }
  407. }
  408. .material-detail {
  409. flex-direction: row;
  410. justify-content: space-between;
  411. }
  412. .detail-row {
  413. flex-direction: row;
  414. }
  415. </style>