applyInfo.uvue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <uni-navbar-lite :showRight=false title="申请详情"></uni-navbar-lite>
  3. <view class="page-container">
  4. <scroll-view class="page-content" :class="{ 'has-bottom-buttons': applyStatus != null && applyStatus.trim() == 'PREPARE' }" :scroll-y="true">
  5. <!-- 申请单信息 -->
  6. <view class="section">
  7. <view class="section-header">
  8. <view class="section-indicator"></view>
  9. <text class="section-title">申请单信息</text>
  10. </view>
  11. <view class="info-card">
  12. <view class="info-row">
  13. <text class="info-label">申请单号</text>
  14. <text class="info-value">{{ applyCode }}</text>
  15. </view>
  16. <view class="info-row">
  17. <text class="info-label">状态</text>
  18. <text class="info-value status-text" :class="'status-' + applyStatus">{{ applyStatusText }}</text>
  19. </view>
  20. <view class="info-row">
  21. <text class="info-label">申购状态</text>
  22. <text class="info-value status-text" :class="'purchase-status-' + purchaseStatus">{{getPurchaseStatusText(purchaseStatus)}}</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 class="info-row">
  29. <text class="info-label">申请人</text>
  30. <text class="info-value">{{ nickName }}</text>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 物料清单 -->
  35. <view class="section">
  36. <view class="section-header">
  37. <view class="section-indicator"></view>
  38. <text class="section-title">物料清单</text>
  39. </view>
  40. <view class="material-list">
  41. <view v-if="lineList.length === 0" class="empty-tip">
  42. <text class="empty-tip-text">暂无物料</text>
  43. </view>
  44. <view
  45. v-else
  46. v-for="(item, index) in lineList"
  47. :key="index"
  48. class="material-item"
  49. >
  50. <view class="material-info">
  51. <text class="material-name">{{ getItemName(item) }}</text>
  52. <!-- <text class="material-spec">{{ getSpecification(item) }}</text> -->
  53. </view>
  54. <view class="material-detail">
  55. <view class="detail-row detail-row-left">
  56. <text class="detail-label">数量</text>
  57. <text class="detail-value quantity-value">{{ getQuantity(item) }}</text>
  58. <text class="detail-value">{{ getMeasureName(item) }}</text>
  59. </view>
  60. <view class="detail-row detail-row-right">
  61. <text class="detail-label">已出库</text>
  62. <text class="detail-value">{{ getQuantityOutTotal(item) }}</text>
  63. <text class="detail-value">{{ getMeasureName(item) }}</text>
  64. </view>
  65. <view class="detail-row detail-row-left">
  66. <text class="detail-label">库存</text>
  67. <text class="detail-value">{{ getCurrentStock(item) }}</text>
  68. <text class="detail-value">{{ getMeasureName(item) }}</text>
  69. </view>
  70. <view class="detail-row detail-row-right">
  71. <text class="detail-label">状态</text>
  72. <text class="detail-value status-text" :class="'line-status-' + getLineStatus(item)">{{ getLineStatusText(item) }}</text>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </scroll-view>
  79. <!-- 底部按钮 -->
  80. <view v-if="applyStatus != null && applyStatus.trim() == 'PREPARE'" class="bottom-buttons">
  81. <button class="delete-btn" @click="handleDelete">删除</button>
  82. <button class="confirm-btn" @click="handleConfirm">确认申请</button>
  83. </view>
  84. </view>
  85. </template>
  86. <script setup lang="uts">
  87. import { ref, computed } from 'vue'
  88. import { getPurchaseApplyById, confirmPurchaseApply, deletePurchaseApply } from '../../api/apply/index'
  89. const applyId = ref<string>("")
  90. const applyCode = ref<string>("")
  91. const applyStatus = ref<string>("")
  92. const purchaseStatus = ref<string>("")
  93. const createTime = ref<string>("")
  94. const nickName = ref<string>("")
  95. const lineList = ref<UTSJSONObject[]>([])
  96. const applyStatusText = computed((): string => {
  97. const status = applyStatus.value
  98. switch (status) {
  99. case 'PREPARE': return '待确认'
  100. case 'CONFIRMED': return '已确认'
  101. case 'APPROVING': return '审批中'
  102. case 'APPROVED': return '已审批'
  103. case 'FINISHED': return '已完成'
  104. case 'WAITOUT': return '待出库'
  105. case 'CANCEL': return '已取消'
  106. default: return status
  107. }
  108. })
  109. const getPurchaseStatusText = (status: string): string => {
  110. switch (status) {
  111. case '0': return '未申购'
  112. case '1': return '已申购'
  113. default: return ''
  114. }
  115. }
  116. const getItemName = (item: UTSJSONObject): string => {
  117. if (item == null) return ''
  118. const val = item['itemName']
  119. return val != null ? val.toString() : ''
  120. }
  121. const getSpecification = (item: UTSJSONObject): string => {
  122. if (item == null) return ''
  123. const val = item['specification']
  124. return val != null ? val.toString() : ''
  125. }
  126. const getQuantity = (item: UTSJSONObject): string => {
  127. if (item == null) return '0'
  128. const val = item['quantityApply']
  129. return val != null ? val.toString() : '0'
  130. }
  131. const getMeasureName = (item: UTSJSONObject): string => {
  132. if (item == null) return ''
  133. const val = item['measureName']
  134. return val != null ? val.toString() : ''
  135. }
  136. const getLineStatus = (item: UTSJSONObject): string => {
  137. if (item == null) return ''
  138. const val = item['status']
  139. return val != null ? val.toString() : ''
  140. }
  141. const getLineStatusText = (item: UTSJSONObject): string => {
  142. if (item == null) return ''
  143. const val = item['status']
  144. const status = val != null ? val.toString() : ''
  145. switch (status) {
  146. case '1': return '草稿'
  147. case '2': return '生成出库单'
  148. case '3': return '已申请采购'
  149. case '4': return '已申请采购/出库'
  150. case '5': return '已完成'
  151. case '6': return '已取消'
  152. case '7': return '部分出库'
  153. default: return status
  154. }
  155. }
  156. const getQuantityOutTotal = (item: UTSJSONObject): string => {
  157. if (item == null) return '0'
  158. const val = item['quantityOutTotal']
  159. return val != null ? val.toString() : '0'
  160. }
  161. const getCurrentStock = (item: UTSJSONObject): string => {
  162. if (item == null) return '0'
  163. const val = item['quantityStock']
  164. return val != null ? val.toString() : '0'
  165. }
  166. const loadDetail = (): void => {
  167. if (applyId.value.length === 0) return
  168. getPurchaseApplyById(applyId.value).then((response: any) => {
  169. const res = response as UTSJSONObject
  170. const data = res["data"] as UTSJSONObject
  171. applyCode.value = data['applyCode'] != null ? data['applyCode'].toString() : ''
  172. applyStatus.value = data['status'] != null ? data['status'].toString() : ''
  173. purchaseStatus.value = data['applyStatus'] != null ? data['applyStatus'].toString() : ''
  174. createTime.value = data['createTime'] != null ? data['createTime'].toString() : ''
  175. nickName.value = data['nickName'] != null ? data['nickName'].toString() : ''
  176. const lines = data['wmPurchaseApplyLineList']
  177. if (lines != null) {
  178. lineList.value = (lines as UTSJSONObject[])
  179. }
  180. }).catch((e) => {
  181. const error = e as UTSError
  182. const errMsg = error?.message
  183. uni.showToast({ title: errMsg.toString(), icon: 'none' })
  184. })
  185. }
  186. const handleConfirm = (): void => {
  187. uni.showModal({
  188. title: '提示',
  189. content: '确认提交该申请单?',
  190. success: (res) => {
  191. if (res.confirm) {
  192. const data = new UTSJSONObject()
  193. data['applyId'] = parseInt(applyId.value)
  194. data['status'] = 'CONFIRMED'
  195. confirmPurchaseApply(data).then((res: any) => {
  196. uni.showToast({ title: '确认成功', icon: 'success' })
  197. applyStatus.value = 'CONFIRMED'
  198. loadDetail()
  199. }).catch((e) => {
  200. const error = e as UTSError
  201. const errMsg = error?.message
  202. uni.showToast({ title: errMsg.toString(), icon: 'none' })
  203. })
  204. }
  205. }
  206. })
  207. }
  208. const handleDelete = (): void => {
  209. uni.showModal({
  210. title: '提示',
  211. content: '确定要删除该申请单吗?',
  212. success: (res) => {
  213. if (res.confirm) {
  214. deletePurchaseApply(applyId.value).then((res: any) => {
  215. uni.showToast({ title: '删除成功', icon: 'success' })
  216. setTimeout(() => {
  217. uni.navigateBack()
  218. }, 1500)
  219. }).catch((e) => {
  220. const error = e as UTSError
  221. const errMsg = error?.message
  222. uni.showToast({ title: errMsg.toString(), icon: 'none' })
  223. })
  224. }
  225. }
  226. })
  227. }
  228. onLoad((options: any) => {
  229. const params = options as UTSJSONObject
  230. if (params != null && params['id'] != null) {
  231. applyId.value = params['id'].toString()
  232. loadDetail()
  233. }
  234. })
  235. </script>
  236. <style lang="scss">
  237. .page-container {
  238. flex: 1;
  239. background-color: #e8f0f9;
  240. }
  241. .debug-info {
  242. padding: 20rpx;
  243. background-color: #ff0000;
  244. color: #ffffff;
  245. }
  246. .page-content {
  247. flex: 1;
  248. padding: 20rpx;
  249. }
  250. .page-content.has-bottom-buttons {
  251. padding-bottom: 130rpx;
  252. }
  253. .section {
  254. margin-bottom: 20rpx;
  255. background: #ffffff;
  256. border-radius: 16rpx;
  257. padding: 20rpx;
  258. }
  259. .section-header {
  260. flex-direction: row;
  261. align-items: center;
  262. margin-bottom: 20rpx;
  263. }
  264. .section-indicator {
  265. width: 6rpx;
  266. height: 32rpx;
  267. background-color: #007aff;
  268. border-radius: 3rpx;
  269. margin-right: 12rpx;
  270. }
  271. .section-title {
  272. font-size: 32rpx;
  273. color: #333333;
  274. font-weight: bold;
  275. }
  276. .info-card {
  277. background-color: #f8f9fa;
  278. border-radius: 8rpx;
  279. padding: 20rpx;
  280. }
  281. .info-row {
  282. flex-direction: row;
  283. justify-content: space-between;
  284. margin-bottom: 16rpx;
  285. &:last-child {
  286. margin-bottom: 0;
  287. }
  288. }
  289. .info-label {
  290. font-size: 28rpx;
  291. color: #666666;
  292. }
  293. .info-value {
  294. font-size: 28rpx;
  295. color: #333333;
  296. }
  297. .status-text {
  298. &.status-PREPARE {
  299. color: #faad14;
  300. }
  301. &.status-CONFIRMED {
  302. color: #1890ff;
  303. }
  304. &.status-WAITOUT {
  305. color: #fa8c16;
  306. }
  307. &.status-APPROVED {
  308. color: #52c41a;
  309. }
  310. &.status-FINISHED {
  311. color: #52c41a;
  312. }
  313. &.status-CANCEL {
  314. color: #ff4d4f;
  315. }
  316. &.line-status-1 {
  317. color: #faad14;
  318. }
  319. &.line-status-2 {
  320. color: #1890ff;
  321. }
  322. &.line-status-3 {
  323. color: #722ed1;
  324. }
  325. &.line-status-7 {
  326. color: #fa8c16;
  327. }
  328. &.line-status-5 {
  329. color: #52c41a;
  330. }
  331. &.line-status-6 {
  332. color: #ff4d4f;
  333. }
  334. &.purchase-status-0 {
  335. color: #faad14;
  336. }
  337. &.purchase-status-1 {
  338. color: #52c41a;
  339. }
  340. }
  341. .material-list {
  342. background-color: #f8f9fa;
  343. border-radius: 8rpx;
  344. padding: 20rpx;
  345. }
  346. .empty-tip {
  347. align-items: center;
  348. padding: 40rpx;
  349. }
  350. .empty-tip-text {
  351. color: #999999;
  352. font-size: 28rpx;
  353. }
  354. .material-item {
  355. background-color: #ffffff;
  356. border-radius: 8rpx;
  357. padding: 20rpx;
  358. margin-bottom: 16rpx;
  359. &:last-child {
  360. margin-bottom: 0;
  361. }
  362. }
  363. .material-info {
  364. margin-bottom: 16rpx;
  365. }
  366. .material-name {
  367. font-size: 28rpx;
  368. color: #333333;
  369. font-weight: bold;
  370. }
  371. .material-spec {
  372. font-size: 24rpx;
  373. color: #999999;
  374. margin-top: 8rpx;
  375. }
  376. .material-detail {
  377. flex-direction: row;
  378. flex-wrap: wrap;
  379. margin: -8rpx;
  380. }
  381. .detail-row {
  382. flex-direction: row;
  383. width: 50%;
  384. padding: 8rpx;
  385. box-sizing: border-box;
  386. }
  387. .detail-row-left {
  388. justify-content: flex-start;
  389. }
  390. .detail-row-right {
  391. justify-content: flex-end;
  392. }
  393. .detail-label {
  394. font-size: 26rpx;
  395. color: #666666;
  396. margin-right: 8rpx;
  397. }
  398. .detail-value {
  399. font-size: 26rpx;
  400. color: #333333;
  401. &.quantity-value {
  402. color: #007aff;
  403. font-weight: bold;
  404. }
  405. }
  406. .bottom-buttons {
  407. position: fixed;
  408. bottom: 0;
  409. left: 0;
  410. right: 0;
  411. padding: 20rpx 30rpx;
  412. background-color: #ffffff;
  413. border-top: 1rpx solid #e5e5e5;
  414. flex-direction: row;
  415. justify-content: space-between;
  416. }
  417. .delete-btn {
  418. flex: 1;
  419. height: 80rpx;
  420. background-color: #ff4d4f;
  421. color: #ffffff;
  422. font-size: 28rpx;
  423. font-weight: 600;
  424. border-radius: 20rpx;
  425. border: none;
  426. margin-right: 20rpx;
  427. }
  428. .confirm-btn {
  429. flex: 1;
  430. height: 80rpx;
  431. background-color: #007aff;
  432. color: #ffffff;
  433. font-size: 28rpx;
  434. font-weight: 600;
  435. border-radius: 20rpx;
  436. border: none;
  437. }
  438. </style>