detail.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="detail-container">
  3. <view class="header-card">
  4. <view class="title">{{ form.projectName || '未知名称' }}</view>
  5. <view class="meta-row">
  6. <view class="leader" v-if="form.projectLeaderName">
  7. 项目负责人:{{ form.projectLeaderName }}
  8. </view>
  9. <view class="tags">
  10. <text class="tag bg-blue">{{ formatterProjctType(form.projectType) }}</text>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="tabs-container">
  15. <uv-tabs :list="tabList" :current="currentTab" @click="handleTabClick"
  16. :activeStyle="{ color: '#1c9bfd', fontWeight: 'bold' }" :inactiveStyle="{ color: '#666' }" lineColor="#1c9bfd"
  17. :scrollable="false"></uv-tabs>
  18. </view>
  19. <view class="scroll-wrapper">
  20. <scroll-view scroll-y class="content-area" :show-scrollbar="false">
  21. <view class="component-wrapper">
  22. <!-- 1. 单据信息 -->
  23. <view v-if="currentTab === 0">
  24. <CommonSection title="到款信息" :isFirst="true">
  25. <CommonInfoRow label="到账金额(元)" :value="amountUnitFormatter(paymentForm.amount)" isAmount />
  26. <CommonInfoRow label="管理费(元)" :value="amountUnitFormatter(paymentForm.manageAmount)" isAmount />
  27. <CommonInfoRow label="税费(元)" :value="amountUnitFormatter(paymentForm.taxAmount)" isAmount />
  28. <CommonInfoRow label="待认领金额(元)" :value="amountUnitFormatter(Number(paymentForm.allotAmount || 0))"
  29. isAmount />
  30. <CommonInfoRow label="到款日期"
  31. :value="paymentForm.date ? formatDate(new Date(paymentForm.date), 'YYYY-MM-DD') : '-'" />
  32. <CommonInfoRow label="经费类型" :value="getDictLabel(paymentReceivedTypeOptions, paymentForm.type)" />
  33. <CommonInfoRow label="打款单位" :value="paymentForm.unit || '-'" />
  34. </CommonSection>
  35. <CommonSection title="项目信息">
  36. <CommonInfoRow label="项目负责人" :value="form.projectLeaderName" />
  37. <CommonInfoRow label="科室" :value="form.deptName" />
  38. </CommonSection>
  39. <CommonSection title="认领经费" v-if="form.detail && form.detail.length > 0">
  40. <CommonInfoRow v-for="(item, index) in form.detail" :key="item.id || index" :label="item.subjName"
  41. :value="amountUnitFormatter(item.amount) + '元'" :isAmount="true" />
  42. </CommonSection>
  43. </view>
  44. <!-- 2. 审批记录 -->
  45. <view v-else-if="currentTab === 1">
  46. <CommonSection title="审批记录" :isFirst="true" v-if="form.id">
  47. <FlowTable :id="form.id" :businessCode="form.id ? form.id.toString() : ''" defCode="sci_fund_allot_apply" />
  48. </CommonSection>
  49. </view>
  50. <view class="bottom-spacer"></view>
  51. </view>
  52. </scroll-view>
  53. </view>
  54. </view>
  55. </template>
  56. <script lang="ts" setup>
  57. import { ref } from 'vue';
  58. import { onLoad } from '@dcloudio/uni-app';
  59. import { useFundApi, useClaimApi } from '@/api/fund/index';
  60. import { useSystemApi } from '@/api/system/index';
  61. import { formatDate } from '@/utils/date';
  62. import CommonSection from '@/components/ui/CommonSection.vue';
  63. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  64. import FlowTable from '@/pages/project/components/detail/FlowTable.vue';
  65. const claimApi = useClaimApi();
  66. const fundApi = useFundApi();
  67. const systemApi = useSystemApi();
  68. const tabList = ref([
  69. { name: '单据信息', index: 0 },
  70. { name: '审批记录', index: 1 }
  71. ]);
  72. const currentTab = ref(0);
  73. const handleTabClick = (item: any) => {
  74. currentTab.value = item.index;
  75. };
  76. const paymentReceivedTypeOptions = ref<any[]>([]);
  77. const paymentForm = ref<any>({
  78. detail: [],
  79. id: 0,
  80. amount: 0,
  81. manageAmount: 0,
  82. taxAmount: 0,
  83. proportion: 0,
  84. date: '',
  85. type: '',
  86. serialNo: '',
  87. unit: '',
  88. remark: ''
  89. });
  90. const form = ref<any>({
  91. id: 0,
  92. amount: '',
  93. externalAmount: '',
  94. fundId: null,
  95. internalAmount: '',
  96. projectId: null,
  97. remark: '',
  98. schemeId: null,
  99. projectName: '',
  100. projectType: '',
  101. detail: []
  102. });
  103. const amountUnitFormatter = (val: any) => {
  104. if (val === null || val === undefined || val === '') return '0.00';
  105. const num = Number(val);
  106. return isNaN(num) ? '0.00' : num.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  107. };
  108. const getDictLabel = (options: any[], value: string) => {
  109. const find = options.find((item) => item.dictValue === value);
  110. return find ? find.dictLabel : value || '-';
  111. };
  112. const getDict = async () => {
  113. try {
  114. const res: any = await systemApi.getDictDataByType('PaymentReceivedType');
  115. if (res.code == 200 && res.data) {
  116. paymentReceivedTypeOptions.value = res.data.values || [];
  117. }
  118. } catch (err) {
  119. console.error(err);
  120. }
  121. };
  122. const formatterProjctType = (val: string) => {
  123. switch (val) {
  124. case '10': return '纵向项目';
  125. case '20': return '横向项目';
  126. case '30': return '内部项目';
  127. case '40': return '重点学科';
  128. default: return '-';
  129. }
  130. };
  131. const getFundDetail = async (id: number) => {
  132. try {
  133. const res: any = await claimApi.getEntityByFundId({ fundId: id });
  134. if (res.code == 200 && res.data) {
  135. form.value = { ...form.value, ...res.data };
  136. }
  137. const pRes: any = await fundApi.getDetails({ id });
  138. if (pRes.code == 200 && pRes.data) {
  139. paymentForm.value = pRes.data;
  140. }
  141. } catch (err) {
  142. console.error('获取详情失败', err);
  143. }
  144. };
  145. onLoad((options: any) => {
  146. const id = options.id ? Number(options.id) : 0;
  147. getDict();
  148. if (id) {
  149. getFundDetail(id);
  150. }
  151. });
  152. </script>
  153. <style lang="scss" scoped>
  154. .detail-container {
  155. height: 100vh;
  156. display: flex;
  157. flex-direction: column;
  158. background-color: #f5f7fa;
  159. box-sizing: border-box;
  160. overflow: hidden;
  161. }
  162. .header-card {
  163. flex-shrink: 0;
  164. background: linear-gradient(135deg, #1c9bfd 0%, #15a982 100%);
  165. padding: 40rpx 30rpx 80rpx;
  166. color: #fff;
  167. border-bottom-left-radius: 40rpx;
  168. border-bottom-right-radius: 40rpx;
  169. box-shadow: 0 10rpx 20rpx rgba(28, 155, 253, 0.2);
  170. .title {
  171. font-size: 40rpx;
  172. font-weight: bold;
  173. margin-bottom: 20rpx;
  174. line-height: 1.4;
  175. }
  176. .meta-row {
  177. display: flex;
  178. align-items: center;
  179. justify-content: space-between;
  180. gap: 20rpx;
  181. }
  182. .leader {
  183. font-size: 28rpx;
  184. opacity: 0.9;
  185. }
  186. .tags {
  187. display: flex;
  188. flex-wrap: wrap;
  189. gap: 16rpx;
  190. .tag {
  191. font-size: 24rpx;
  192. padding: 6rpx 20rpx;
  193. border-radius: 30rpx;
  194. border: 2rpx solid rgba(255, 255, 255, 0.4);
  195. background: rgba(255, 255, 255, 0.1);
  196. backdrop-filter: blur(4px);
  197. }
  198. }
  199. }
  200. .tabs-container {
  201. flex-shrink: 0;
  202. margin: -40rpx 30rpx 20rpx;
  203. background-color: #fff;
  204. border-radius: 16rpx;
  205. padding: 10rpx 0;
  206. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
  207. position: relative;
  208. z-index: 10;
  209. }
  210. .scroll-wrapper {
  211. flex: 1;
  212. overflow: hidden;
  213. }
  214. .content-area {
  215. height: 100%;
  216. }
  217. .component-wrapper {
  218. padding: 30rpx;
  219. box-sizing: border-box;
  220. }
  221. .bottom-spacer {
  222. height: calc(10rpx + env(safe-area-inset-bottom));
  223. width: 100%;
  224. }
  225. </style>