detail.uvue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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. if (salseId.value.length === 0) return
  147. getProductSalseById(salseId.value).then((res: any) => {
  148. const resData = res as UTSJSONObject
  149. const data = resData["data"] as UTSJSONObject
  150. salseCode.value = data['salseCode'] != null ? data['salseCode'].toString() : ''
  151. status.value = data['status'] != null ? data['status'].toString() : ''
  152. createBy.value = data['createNickName'] != null ? data['createNickName'].toString() : ''
  153. receiverUser.value = data['receiverUser'] != null ? data['receiverUser'].toString() : ''
  154. createTime.value = data['createTime'] != null ? data['createTime'].toString() : ''
  155. const lines = data['wmProductSalseLineList']
  156. if (lines != null) {
  157. const allLines = lines as UTSJSONObject[]
  158. // 只显示当前用户的明细
  159. lineList.value = allLines.filter((line: UTSJSONObject) => {
  160. const receiverUserId = line['receiverUserId']
  161. return receiverUserId != null && receiverUserId.toString() === currentUserId
  162. })
  163. } else {
  164. lineList.value = []
  165. }
  166. }).catch((e) => {
  167. const error = e as UTSError
  168. const errMsg = error?.message
  169. uni.showToast({ title: errMsg.toString(), icon: 'none' })
  170. })
  171. }
  172. const handleSignReceive = (item: UTSJSONObject): void => {
  173. const lineId = item['lineId']
  174. if (lineId == null) {
  175. uni.showToast({ title: '明细ID不存在', icon: 'none' })
  176. return
  177. }
  178. uni.showModal({
  179. title: '提示',
  180. content: '确认签收该物料?',
  181. success: (res) => {
  182. if (res.confirm) {
  183. signReceiveLine(lineId.toString()).then((res: any) => {
  184. uni.showToast({ title: '签收成功', icon: 'success' })
  185. loadDetail()
  186. }).catch((e) => {
  187. const error = e as UTSError
  188. const errMsg = error?.message
  189. uni.showToast({ title: errMsg.toString(), icon: 'none' })
  190. })
  191. }
  192. }
  193. })
  194. }
  195. const handleBack = (): void => {
  196. uni.navigateBack()
  197. }
  198. onLoad((options: any) => {
  199. const params = options as UTSJSONObject
  200. if (params != null && params['id'] != null) {
  201. salseId.value = params['id'].toString()
  202. const userInfo = getUserInfo()
  203. if (userInfo != null) {
  204. const userId = userInfo['userId']
  205. currentUserId = userId != null ? userId.toString() : ''
  206. }
  207. loadDetail()
  208. }
  209. })
  210. </script>
  211. <style lang="scss">
  212. .page-container {
  213. flex: 1;
  214. background-color: #e8f0f9;
  215. }
  216. .page-content {
  217. flex: 1;
  218. padding: 20rpx;
  219. }
  220. .section {
  221. margin-bottom: 20rpx;
  222. background: #ffffff;
  223. border-radius: 16rpx;
  224. padding: 20rpx;
  225. }
  226. .section-header {
  227. flex-direction: row;
  228. align-items: center;
  229. margin-bottom: 20rpx;
  230. }
  231. .section-indicator {
  232. width: 6rpx;
  233. height: 32rpx;
  234. background-color: #007aff;
  235. border-radius: 3rpx;
  236. margin-right: 12rpx;
  237. }
  238. .section-title {
  239. font-size: 32rpx;
  240. color: #333333;
  241. font-weight: bold;
  242. }
  243. .info-card {
  244. background-color: #f8f9fa;
  245. border-radius: 8rpx;
  246. padding: 20rpx;
  247. }
  248. .info-row {
  249. flex-direction: row;
  250. justify-content: space-between;
  251. margin-bottom: 16rpx;
  252. &:last-child {
  253. margin-bottom: 0;
  254. }
  255. }
  256. .info-label {
  257. font-size: 28rpx;
  258. color: #666666;
  259. }
  260. .info-value {
  261. font-size: 28rpx;
  262. color: #333333;
  263. }
  264. .status-text {
  265. &.status-PREPARE {
  266. color: #faad14;
  267. }
  268. &.status-CONFIRMED {
  269. color: #1890ff;
  270. }
  271. &.status-EXECUTING {
  272. color: #722ed1;
  273. }
  274. &.status-FINISHED {
  275. color: #52c41a;
  276. }
  277. &.status-CANCEL {
  278. color: #ff4d4f;
  279. }
  280. &.status-received {
  281. color: #52c41a;
  282. }
  283. &.status-pending {
  284. color: #faad14;
  285. }
  286. }
  287. .material-list {
  288. background-color: #f8f9fa;
  289. border-radius: 8rpx;
  290. padding: 20rpx;
  291. }
  292. .empty-tip {
  293. align-items: center;
  294. padding: 40rpx;
  295. }
  296. .empty-tip-text {
  297. color: #999999;
  298. font-size: 28rpx;
  299. }
  300. .material-item {
  301. background-color: #ffffff;
  302. border-radius: 12rpx;
  303. padding: 28rpx;
  304. margin-bottom: 20rpx;
  305. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  306. &:last-child {
  307. margin-bottom: 0;
  308. }
  309. }
  310. .material-header {
  311. flex-direction: row;
  312. justify-content: space-between;
  313. align-items: flex-start;
  314. margin-bottom: 16rpx;
  315. }
  316. .material-name {
  317. font-size: 32rpx;
  318. color: #333333;
  319. font-weight: bold;
  320. flex: 1;
  321. margin-right: 16rpx;
  322. line-height: 44rpx;
  323. }
  324. .material-status {
  325. font-size: 24rpx;
  326. padding: 8rpx 20rpx;
  327. border-radius: 12rpx;
  328. &.status-received {
  329. background-color: #f6ffed;
  330. color: #52c41a;
  331. }
  332. &.status-pending {
  333. background-color: #fff7e6;
  334. color: #fa8c16;
  335. }
  336. }
  337. .material-spec {
  338. flex-direction: row;
  339. margin-bottom: 16rpx;
  340. }
  341. .spec-label {
  342. font-size: 26rpx;
  343. color: #999999;
  344. margin-right: 8rpx;
  345. }
  346. .spec-value {
  347. font-size: 26rpx;
  348. color: #666666;
  349. flex: 1;
  350. }
  351. .material-divider {
  352. height: 2rpx;
  353. background-color: #f0f0f0;
  354. margin: 16rpx 0;
  355. }
  356. .material-footer {
  357. flex-direction: row;
  358. justify-content: space-between;
  359. align-items: center;
  360. }
  361. .quantity-info {
  362. flex-direction: column;
  363. flex: 1;
  364. }
  365. .right-info {
  366. justify-content: center;
  367. margin-right: 24rpx;
  368. }
  369. .quantity-num {
  370. font-size: 32rpx;
  371. color: #007aff;
  372. font-weight: bold;
  373. }
  374. .detail-row {
  375. flex-direction: row;
  376. margin-bottom: 8rpx;
  377. &:last-child {
  378. margin-bottom: 0;
  379. }
  380. }
  381. .quantity-label {
  382. font-size: 26rpx;
  383. color: #999999;
  384. width: 120rpx;
  385. }
  386. .quantity-value {
  387. font-size: 26rpx;
  388. color: #007aff;
  389. font-weight: bold;
  390. flex: 1;
  391. }
  392. .receive-btn-wrap {
  393. margin-left: 24rpx;
  394. }
  395. .receive-btn {
  396. padding: 14rpx 36rpx;
  397. background-color: #007aff;
  398. color: #ffffff;
  399. font-size: 26rpx;
  400. border-radius: 8rpx;
  401. border: none;
  402. font-weight: bold;
  403. &:active {
  404. background-color: #0056b3;
  405. }
  406. }
  407. .material-detail {
  408. flex-direction: row;
  409. justify-content: space-between;
  410. }
  411. .detail-row {
  412. flex-direction: row;
  413. }
  414. </style>