applyInfo.uvue 16 KB

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