detail.uvue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <uni-navbar-lite :showRight=false :title="title"></uni-navbar-lite>
  3. <view class="page-container">
  4. <scroll-view class="page-content" :scroll-y="true" :style="pageContentStyle">
  5. <view class="section">
  6. <view class="section-header">
  7. <view class="section-indicator"></view>
  8. <text class="section-title">产品信息</text>
  9. </view>
  10. <view class="info-card">
  11. <view class="info-row">
  12. <text class="info-label">产品编码</text>
  13. <text class="info-value">{{ productCode }}</text>
  14. </view>
  15. <view class="info-row">
  16. <text class="info-label">产品名称</text>
  17. <text class="info-value">{{ productName }}</text>
  18. </view>
  19. <view class="info-row">
  20. <text class="info-label">规格型号</text>
  21. <text class="info-value">{{ specification }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="section">
  26. <view class="section-header">
  27. <view class="section-indicator"></view>
  28. <text class="section-title">汇报信息</text>
  29. </view>
  30. <view class="info-card">
  31. <view class="info-row">
  32. <text class="info-label">汇报数量</text>
  33. <text class="info-value warning">{{ quantity }} {{ unitName }}</text>
  34. </view>
  35. <view class="info-row">
  36. <text class="info-label">换算吨数</text>
  37. <text class="info-value primary">{{ quantityTon }} {{ baseUnitName }}</text>
  38. </view>
  39. <view class="info-row">
  40. <text class="info-label">换算比例</text>
  41. <text class="info-value">{{ conversionRate }}</text>
  42. </view>
  43. <view class="info-row">
  44. <text class="info-label">报工日期</text>
  45. <text class="info-value">{{ reportDate }}</text>
  46. </view>
  47. <view class="info-row">
  48. <text class="info-label">开始时间</text>
  49. <text class="info-value">{{ startTime }}</text>
  50. </view>
  51. <view class="info-row">
  52. <text class="info-label">结束时间</text>
  53. <text class="info-value">{{ endTime }}</text>
  54. </view>
  55. <view class="info-row">
  56. <text class="info-label">汇报人</text>
  57. <text class="info-value">{{ reporter }}</text>
  58. </view>
  59. <view class="info-row">
  60. <text class="info-label">状态</text>
  61. <view class="status-badge" :class="'status-' + status">
  62. <text>{{ statusText }}</text>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="section" v-if="remark && remark.length > 0">
  68. <view class="section-header">
  69. <view class="section-indicator"></view>
  70. <text class="section-title">备注</text>
  71. </view>
  72. <view class="info-card">
  73. <text class="remark-text">{{ remark }}</text>
  74. </view>
  75. </view>
  76. </scroll-view>
  77. <view class="bottom-buttons" v-if="showBottomButtons">
  78. <button class="undo-btn" @click="handleUndoConfirm" v-if="hasUndoPermission">退回</button>
  79. <button class="finish-btn" @click="handleFinish" v-if="hasFinishPermission">完成</button>
  80. </view>
  81. </view>
  82. </template>
  83. <script setup lang="uts">
  84. import { ref, computed, onMounted } from 'vue'
  85. import { getProReportById, undoConfirmProReport, finishProReport } from '../../api/pro/index'
  86. import { checkPermission } from '../../utils/permission'
  87. const reportId = ref<string>('')
  88. const productCode = ref<string>('')
  89. const productName = ref<string>('')
  90. const specification = ref<string>('')
  91. const quantity = ref<string>('')
  92. const unitName = ref<string>('')
  93. const quantityTon = ref<string>('')
  94. const baseUnitName = ref<string>('')
  95. const conversionRate = ref<string>('')
  96. const reportDate = ref<string>('')
  97. const startTime = ref<string>('')
  98. const endTime = ref<string>('')
  99. const reporter = ref<string>('')
  100. const status = ref<string>('')
  101. const remark = ref<string>('')
  102. const hasFinishPermission = ref<boolean>(false)
  103. const hasUndoPermission = ref<boolean>(false)
  104. const title = computed(() => {
  105. return '生产汇报详情'
  106. })
  107. const showBottomButtons = computed(() => {
  108. if (!status.value || status.value.length === 0) return false
  109. return status.value === 'CONFIRMED' && (hasFinishPermission.value || hasUndoPermission.value)
  110. })
  111. const pageContentStyle = computed(() => {
  112. return {
  113. paddingBottom: showBottomButtons.value ? '130rpx' : '20rpx'
  114. }
  115. })
  116. const statusText = computed(() => {
  117. switch (status.value) {
  118. case 'PREPARE': return '草稿'
  119. case 'CONFIRMED': return '已确认'
  120. case 'FINISHED': return '已完成'
  121. case 'CANCEL': return '已取消'
  122. default: return status.value
  123. }
  124. })
  125. const loadDetail = (): void => {
  126. if (reportId.value.length === 0) return
  127. getProReportById(reportId.value).then((response: any) => {
  128. const res = response as UTSJSONObject
  129. const data = res["data"] as UTSJSONObject
  130. productCode.value = data['productCode'] != null ? data['productCode'].toString() : ''
  131. productName.value = data['productName'] != null ? data['productName'].toString() : ''
  132. specification.value = data['specification'] != null ? data['specification'].toString() : ''
  133. quantity.value = data['quantity'] != null ? data['quantity'].toString() : ''
  134. unitName.value = data['unitName'] != null ? data['unitName'].toString() : ''
  135. quantityTon.value = data['quantityTon'] != null ? data['quantityTon'].toString() : ''
  136. baseUnitName.value = data['baseUnitName'] != null ? data['baseUnitName'].toString() : ''
  137. conversionRate.value = data['conversionRate'] != null ? data['conversionRate'].toString() : ''
  138. reportDate.value = data['reportDate'] != null ? data['reportDate'].toString() : ''
  139. const st = data['startTime'] != null ? data['startTime'].toString() : ''
  140. startTime.value = st.length > 10 ? st.substring(11, 16) : ''
  141. const et = data['endTime'] != null ? data['endTime'].toString() : ''
  142. endTime.value = et.length > 10 ? et.substring(11, 16) : ''
  143. reporter.value = data['reporter'] != null ? data['reporter'].toString() : ''
  144. status.value = data['status'] != null ? data['status'].toString() : ''
  145. remark.value = data['remark'] != null ? data['remark'].toString() : ''
  146. }).catch((e) => {
  147. const error = e as UTSError
  148. uni.showToast({ title: error?.message.toString() || '加载失败', icon: 'none' })
  149. })
  150. }
  151. const handleBack = (): void => {
  152. uni.navigateBack()
  153. }
  154. const handleUndoConfirm = (): void => {
  155. uni.showModal({
  156. title: '提示',
  157. content: '确认退回报工记录?',
  158. success: (res) => {
  159. if (res.confirm) {
  160. const data = new UTSJSONObject()
  161. data['reportId'] = parseInt(reportId.value)
  162. undoConfirmProReport(data).then((r: any) => {
  163. uni.showToast({ title: '退回成功', icon: 'success' })
  164. status.value = 'PREPARE'
  165. uni.setStorageSync('needRefresh', 'true')
  166. setTimeout(() => {
  167. uni.navigateBack({ delta: 1 })
  168. }, 1500)
  169. }).catch((e) => {
  170. const error = e as UTSError
  171. uni.showToast({ title: error?.message.toString() || '退回失败', icon: 'none' })
  172. })
  173. }
  174. }
  175. })
  176. }
  177. const handleFinish = (): void => {
  178. uni.showModal({
  179. title: '提示',
  180. content: '确认完成报工记录?',
  181. success: (res) => {
  182. if (res.confirm) {
  183. const data = new UTSJSONObject()
  184. data['reportId'] = parseInt(reportId.value)
  185. finishProReport(data).then((r: any) => {
  186. uni.showToast({ title: '完成成功', icon: 'success' })
  187. status.value = 'FINISHED'
  188. uni.setStorageSync('needRefresh', 'true')
  189. setTimeout(() => {
  190. uni.navigateBack({ delta: 1 })
  191. }, 1500)
  192. }).catch((e) => {
  193. const error = e as UTSError
  194. uni.showToast({ title: error?.message.toString() || '完成失败', icon: 'none' })
  195. })
  196. }
  197. }
  198. })
  199. }
  200. onMounted(() => {
  201. const pages = getCurrentPages()
  202. const currentPage = pages[pages.length - 1]
  203. const options = currentPage.options
  204. hasFinishPermission.value = checkPermission('mes:pro:proreport:finish')
  205. hasUndoPermission.value = checkPermission('mes:pro:proreport:undoconfirm')
  206. if (options != null && options.id != null) {
  207. reportId.value = options.id.toString()
  208. loadDetail()
  209. }
  210. })
  211. </script>
  212. <style lang="scss">
  213. .page-container {
  214. flex: 1;
  215. background-color: #e8f0f9;
  216. }
  217. .page-content {
  218. flex: 1;
  219. padding: 20rpx;
  220. padding-bottom: 130rpx;
  221. }
  222. .section {
  223. margin-bottom: 20rpx;
  224. background: #ffffff;
  225. border-radius: 16rpx;
  226. padding: 20rpx;
  227. }
  228. .section-header {
  229. flex-direction: row;
  230. align-items: center;
  231. margin-bottom: 20rpx;
  232. }
  233. .section-indicator {
  234. width: 6rpx;
  235. height: 32rpx;
  236. background-color: #007aff;
  237. border-radius: 3rpx;
  238. margin-right: 12rpx;
  239. }
  240. .section-title {
  241. font-size: 32rpx;
  242. font-weight: bold;
  243. color: #333333;
  244. }
  245. .info-card {
  246. background-color: #f8f9fa;
  247. border-radius: 12rpx;
  248. padding: 20rpx;
  249. }
  250. .info-row {
  251. flex-direction: row;
  252. align-items: center;
  253. padding: 16rpx 0;
  254. border-bottom: 1rpx solid #e9ecef;
  255. &:last-child {
  256. border-bottom: none;
  257. }
  258. }
  259. .info-label {
  260. font-size: 28rpx;
  261. color: #666666;
  262. width: 180rpx;
  263. flex-shrink: 0;
  264. }
  265. .info-value {
  266. font-size: 28rpx;
  267. color: #333333;
  268. flex: 1;
  269. &.warning {
  270. color: #faad14;
  271. }
  272. &.primary {
  273. color: #007aff;
  274. }
  275. }
  276. .status-badge {
  277. font-size: 24rpx;
  278. padding: 6rpx 16rpx;
  279. border-radius: 6rpx;
  280. &.status-PREPARE {
  281. background-color: #f0f0f0;
  282. color: #666666;
  283. }
  284. &.status-CONFIRMED {
  285. background-color: #e6f7ff;
  286. color: #1890ff;
  287. }
  288. &.status-FINISHED {
  289. background-color: #f6ffed;
  290. color: #52c41a;
  291. }
  292. &.status-CANCEL {
  293. background-color: #fff1f0;
  294. color: #ff4d4f;
  295. }
  296. }
  297. .remark-text {
  298. font-size: 28rpx;
  299. color: #333333;
  300. line-height: 1.6;
  301. }
  302. .bottom-buttons {
  303. position: fixed;
  304. bottom: 0;
  305. left: 0;
  306. right: 0;
  307. padding: 20rpx 30rpx;
  308. background-color: #ffffff;
  309. border-top: 1rpx solid #e5e5e5;
  310. display: flex;
  311. flex-direction: row;
  312. gap: 20rpx;
  313. }
  314. .undo-btn {
  315. flex: 1;
  316. height: 80rpx;
  317. line-height: 80rpx;
  318. background-color: #faad14;
  319. color: #ffffff;
  320. font-size: 28rpx;
  321. font-weight: 600;
  322. border-radius: 20rpx;
  323. border: none;
  324. }
  325. .finish-btn {
  326. flex: 1;
  327. height: 80rpx;
  328. line-height: 80rpx;
  329. background-color: #52c41a;
  330. color: #ffffff;
  331. font-size: 28rpx;
  332. font-weight: 600;
  333. border-radius: 20rpx;
  334. border: none;
  335. }
  336. .back-btn {
  337. flex: 1;
  338. height: 80rpx;
  339. line-height: 80rpx;
  340. background-color: #007aff;
  341. color: #ffffff;
  342. font-size: 28rpx;
  343. font-weight: 600;
  344. border-radius: 20rpx;
  345. border: none;
  346. }
  347. </style>