applyInfo.uvue 13 KB

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