applyInfo.uvue 16 KB

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