detail.vue 7.1 KB

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