detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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.projectIncharge">
  7. 项目负责人:{{ form.projectIncharge }}
  8. </view>
  9. <view class="tags">
  10. <text class="tag bg-blue">{{ getProjectTypeLabel(form.projectType) }}</text>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="tabs-container">
  15. <uv-tabs :list="tabList" :current="currentTab" @change="onTabChange"
  16. :activeStyle="{ color: '#1c9bfd', fontWeight: 'bold' }"
  17. :inactiveStyle="{ color: '#666' }" lineColor="#1c9bfd"
  18. :scrollable="true"></uv-tabs>
  19. </view>
  20. <scroll-view scroll-y class="content-area" :show-scrollbar="false">
  21. <view class="component-wrapper" v-if="currentTab === 0">
  22. <CommonSection title="项目信息">
  23. <CommonInfoRow label="项目编号" :value="form.projectNo" />
  24. <CommonInfoRow label="项目来源" :value="form.projectSource" />
  25. <CommonInfoRow label="项目负责人" :value="form.projectIncharge" />
  26. <CommonInfoRow label="所属科室" :value="form.projectDeptName" />
  27. <CommonInfoRow label="经费卡">
  28. <template v-if="form.type == '10'">{{ form.cardNo }}_上级拨款</template>
  29. <template v-else-if="form.type == '20'">{{ form.cardNo }}_匹配经费</template>
  30. <template v-else-if="form.type == '30'">{{ form.cardNo }}_横向经费</template>
  31. <template v-else>-</template>
  32. </CommonInfoRow>
  33. <CommonInfoRow label="费用科目" :value="form.subjName" />
  34. <CommonInfoRow label="入账金额" :value="showAmount ? amountUnitFormatter(showAmount) + '元' : '-'" :isAmount="true" />
  35. <CommonInfoRow label="可用金额" :value="showBalanceAmount ? amountUnitFormatter(showBalanceAmount) + '元' : '-'" :isAmount="true" />
  36. <CommonInfoRow label="费用类型" :value="form.subSubjName" />
  37. <CommonInfoRow label="事项" :value="form.purpose" />
  38. </CommonSection>
  39. <CommonSection title="报销经费">
  40. <CommonInfoRow label="经办人" :value="form.handle" />
  41. <CommonInfoRow label="支出金额" :value="amountUnitFormatter(form.amount) + '元'" :isAmount="true" />
  42. <CommonInfoRow label="结算金额" :value="form.settleAmount !== null && form.settleAmount !== undefined ? amountUnitFormatter(form.settleAmount) + '元' : '-'" :isAmount="true" />
  43. </CommonSection>
  44. </view>
  45. <!-- 发票信息 -->
  46. <view class="component-wrapper" v-else-if="currentTab === 1">
  47. <template v-if="form.invoice && form.invoice.length > 0">
  48. <CommonSection
  49. v-for="(item, index) in form.invoice"
  50. :key="'invoice-' + index"
  51. :title="'发票信息 ' + (Number(index) + 1)"
  52. >
  53. <CommonInfoRow label="发票号码" :value="item.invoiceNo" />
  54. <CommonInfoRow label="金额" :value="amountUnitFormatter(item.amount) + '元'" :isAmount="true" />
  55. <CommonInfoRow label="开票日期" :value="item.invoiceBy ? formatDate(new Date(item.invoiceBy), 'YYYY-MM-DD') : '-'" />
  56. <view class="mt10" v-if="item.fileList && item.fileList.length > 0">
  57. <view class="file-label">发票附件:</view>
  58. <view class="file-card">
  59. <template v-for="(file, idx) in item.fileList" :key="idx">
  60. <uv-image
  61. v-if="/\.(jpeg|jpg|gif|png|webp|bmp)$/i.test(file.name || '')"
  62. class="file-img mt10"
  63. :src="file.url"
  64. @click="onPreview(file.url)"
  65. width="120rpx"
  66. height="120rpx"
  67. ></uv-image>
  68. <view class="file-doc mt10" v-else @click="onPreview(file.url)">
  69. <uv-icon name="file-text" size="40"></uv-icon>
  70. <text class="file-name">{{ file.name }}</text>
  71. </view>
  72. </template>
  73. </view>
  74. </view>
  75. </CommonSection>
  76. </template>
  77. <uv-empty v-else mode="data" text="暂无发票信息" margin-top="100"></uv-empty>
  78. </view>
  79. <!-- 支付信息 -->
  80. <view class="component-wrapper" v-else-if="currentTab === 2">
  81. <template v-if="form.payment && form.payment.length > 0">
  82. <CommonSection
  83. v-for="(item, index) in form.payment"
  84. :key="'payment-' + index"
  85. :title="'支付信息 ' + (Number(index) + 1)"
  86. >
  87. <CommonInfoRow label="支付方式">
  88. <template v-if="item.payType == '10'">银行转账</template>
  89. <template v-else-if="item.payType == '20'">现金</template>
  90. <template v-else-if="item.payType == '30'">国库集中支付</template>
  91. <template v-else>-</template>
  92. </CommonInfoRow>
  93. <CommonInfoRow label="收款人/单位" :value="item.receiver" />
  94. <CommonInfoRow label="个人/单位类型" :value="getDictLabel(receiverTypeOptions, item.receiverType)" />
  95. <CommonInfoRow label="金额" :value="amountUnitFormatter(item.amount) + '元'" :isAmount="true" />
  96. </CommonSection>
  97. </template>
  98. <uv-empty v-else mode="data" text="暂无支付信息" margin-top="100"></uv-empty>
  99. </view>
  100. <!-- 附件信息 -->
  101. <view class="component-wrapper" v-else-if="currentTab === 3">
  102. <template v-if="form.fileList && form.fileList.length > 0">
  103. <CommonSection title="附件信息">
  104. <view v-for="(file, idx) in form.fileList" :key="'file-' + idx" style="margin-bottom: 24rpx; padding-bottom: 24rpx; border-bottom: 1px dashed #eee;">
  105. <view style="font-size: 28rpx; color: #333; margin-bottom: 10rpx;">文件类型:{{ file.fileType || '-' }} <text v-if="file.required" style="color: #f5222d;">*</text></view>
  106. <view class="file-card">
  107. <uv-image
  108. v-if="/\.(jpeg|jpg|gif|png|webp|bmp)$/i.test(file.name || '')"
  109. class="file-img mt10"
  110. :src="file.url"
  111. @click="onPreview(file.url)"
  112. width="120rpx"
  113. height="120rpx"
  114. ></uv-image>
  115. <view class="file-doc mt10" v-else @click="onPreview(file.url)">
  116. <uv-icon name="file-text" size="40"></uv-icon>
  117. <text class="file-name">{{ file.name }}</text>
  118. </view>
  119. </view>
  120. </view>
  121. </CommonSection>
  122. </template>
  123. <uv-empty v-else mode="data" text="暂无附件信息" margin-top="100"></uv-empty>
  124. </view>
  125. <view class="component-wrapper" v-else-if="currentTab === 4">
  126. <FlowTable :id="form.id || 0" :businessCode="'' + (form.id || '')" defCode="sci_fund_expense" />
  127. </view>
  128. </scroll-view>
  129. </view>
  130. </template>
  131. <script lang="ts" setup>
  132. import { ref } from 'vue';
  133. import { onLoad } from '@dcloudio/uni-app';
  134. import CommonSection from '@/components/ui/CommonSection.vue';
  135. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  136. import FlowTable from '@/pages/project/components/detail/FlowTable.vue';
  137. import { formatDate } from '@/utils/date';
  138. import { useSystemApi } from '@/api/system/index';
  139. import { useFundApi, useExpenseRemindApi, useRebateApi, useExpenseApi, useFundCardApi } from '@/api/fund/index';
  140. const systemApi = useSystemApi();
  141. const expenseRemindApi = useExpenseRemindApi();
  142. const fundApi = useFundApi();
  143. const expenseApi = useExpenseApi();
  144. const fundCardApi = useFundCardApi();
  145. const rebateApi = useRebateApi();
  146. const receiverTypeOptions = ref<any[]>([]);
  147. const showAmount = ref(0);
  148. const showBalanceAmount = ref(0);
  149. const tabList = ref([{ name: '项目信息' }, { name: '发票信息' }, { name: '支付信息' }, { name: '附件信息' }, { name: '审批详情' }]);
  150. const currentTab = ref(0);
  151. const onTabChange = (e: any) => {
  152. currentTab.value = e.index;
  153. };
  154. const form = ref<any>({
  155. id: 0,
  156. orderNo: '',
  157. price: 0,
  158. buyerName: '',
  159. createdTime: '',
  160. status: '',
  161. fileList: [],
  162. amount: 0,
  163. noticeId: null,
  164. projectType: '',
  165. allotId: null,
  166. handle: '',
  167. projectId: 0,
  168. projectIncharge: '',
  169. projectCode: '',
  170. projectName: '',
  171. projectSource: '',
  172. deptName: '',
  173. startDate: '',
  174. endDate: '',
  175. purpose: '',
  176. invoice: [],
  177. payment: [],
  178. type: '',
  179. cardNo: '',
  180. settleAmount: 0,
  181. projectDeptName: '',
  182. deptId: null,
  183. subjCode: '',
  184. subjName: '',
  185. subSubjCode: '',
  186. subSubjName: '',
  187. expendTime: '',
  188. expend: ''
  189. });
  190. const getProjectTypeLabel = (type: string) => {
  191. const map: Record<string, string> = {
  192. '10': '纵向项目',
  193. '20': '横向项目',
  194. '30': '内部项目',
  195. '40': '重点学科',
  196. '50': '人才类项目',
  197. '60': '科研平台'
  198. };
  199. return map[type] || '-';
  200. };
  201. const amountUnitFormatter = (val: any) => {
  202. if (val === null || val === undefined || val === '') return '0.00';
  203. const num = Number(val);
  204. return isNaN(num) ? '0.00' : num.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  205. };
  206. const getDictLabel = (options: any[], value: string) => {
  207. const find = options.find((item) => item.dictValue === value);
  208. return find ? find.dictLabel : '-';
  209. };
  210. const formatFileUrl = (url: string) => {
  211. if (!url) return '';
  212. if (url.startsWith('http')) return url;
  213. return import.meta.env.VITE_SCIENTIFIC + url;
  214. };
  215. const getDict = async () => {
  216. try {
  217. const res: any = await systemApi.getDictDataByType('sci_receiver_type');
  218. if (res.code == 200 && res.data) {
  219. receiverTypeOptions.value = res.data.values || [];
  220. }
  221. } catch (err) {
  222. console.error(err);
  223. }
  224. };
  225. const getAmountInfo = async () => {
  226. if (!form.value.projectId || !form.value.subjCode) return;
  227. const params = {
  228. projectId: form.value.projectId,
  229. projectType: form.value.projectType,
  230. type: form.value.type,
  231. subjCode: form.value.subjCode
  232. };
  233. showAmount.value = 0;
  234. showBalanceAmount.value = 0;
  235. try {
  236. const res: any = await fundCardApi.getSubjAmount(params);
  237. if (res.code == 200 && res.data) {
  238. showAmount.value = res.data.amount;
  239. showBalanceAmount.value = res.data.balanceAmount;
  240. }
  241. } catch (err) {
  242. console.error(err);
  243. }
  244. };
  245. const getFundDetail = async (id: number, remindId: number) => {
  246. try {
  247. const post = id ? rebateApi.getDetails : rebateApi.getExpenseByNoticeId;
  248. const res: any = await post({ id: id || remindId });
  249. if (res.code == 200 && res.data) {
  250. const data = res.data;
  251. const fileList = data.fileUrl ? JSON.parse(data.fileUrl) : [];
  252. data.fileList = fileList.map((item: any) => ({
  253. url: formatFileUrl(item.fileUrl),
  254. name: item.fileName,
  255. invoiceType: item.invoiceType || item.fileType,
  256. fileType: item.fileType,
  257. required: item.required
  258. }));
  259. const invoice = data.invoice ? data.invoice : [];
  260. data.invoice = invoice.map((item: any) => ({
  261. ...item,
  262. fileList: [
  263. {
  264. url: formatFileUrl(item.fileUrl),
  265. name: item.fileName,
  266. invoiceType: item.invoiceType || ''
  267. }
  268. ]
  269. }));
  270. form.value = data;
  271. getAmountInfo();
  272. }
  273. } catch (err) {
  274. console.error(err);
  275. }
  276. };
  277. const onPreview = (url: string) => {
  278. uni.previewImage({
  279. urls: [url]
  280. });
  281. };
  282. onLoad((options: any) => {
  283. const id = options.id ? Number(options.id) : 0;
  284. const remindId = options.remindId ? Number(options.remindId) : 0;
  285. getDict();
  286. getFundDetail(id, remindId);
  287. });
  288. </script>
  289. <style lang="scss" scoped>
  290. .detail-container {
  291. height: calc(100vh - var(--window-top));
  292. display: flex;
  293. flex-direction: column;
  294. background-color: #f5f7fa;
  295. box-sizing: border-box;
  296. }
  297. .header-card {
  298. flex-shrink: 0;
  299. background: linear-gradient(135deg, #1c9bfd 0%, #15a982 100%);
  300. padding: 40rpx 30rpx 80rpx;
  301. color: #fff;
  302. border-bottom-left-radius: 40rpx;
  303. border-bottom-right-radius: 40rpx;
  304. box-shadow: 0 10rpx 20rpx rgba(28, 155, 253, 0.2);
  305. .title {
  306. font-size: 40rpx;
  307. font-weight: bold;
  308. margin-bottom: 20rpx;
  309. line-height: 1.4;
  310. }
  311. .meta-row {
  312. display: flex;
  313. align-items: center;
  314. justify-content: space-between;
  315. gap: 20rpx;
  316. }
  317. .leader {
  318. font-size: 28rpx;
  319. opacity: 0.9;
  320. }
  321. .tags {
  322. display: flex;
  323. flex-wrap: wrap;
  324. gap: 16rpx;
  325. .tag {
  326. font-size: 24rpx;
  327. padding: 6rpx 20rpx;
  328. border-radius: 30rpx;
  329. border: 2rpx solid rgba(255, 255, 255, 0.4);
  330. background: rgba(255, 255, 255, 0.1);
  331. backdrop-filter: blur(4px);
  332. }
  333. }
  334. }
  335. .tabs-container {
  336. flex-shrink: 0;
  337. margin: -40rpx 30rpx 20rpx;
  338. background-color: #fff;
  339. border-radius: 16rpx;
  340. padding: 10rpx 0;
  341. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
  342. position: relative;
  343. z-index: 10;
  344. }
  345. .content-area {
  346. flex: 1;
  347. height: 0;
  348. }
  349. .component-wrapper {
  350. margin: 0 30rpx;
  351. padding-top: 20rpx;
  352. padding-bottom: calc(40rpx + env(safe-area-inset-bottom));
  353. }
  354. .mt10 {
  355. margin-top: 20rpx;
  356. }
  357. .file-label {
  358. font-size: 28rpx;
  359. color: #666;
  360. margin-bottom: 10rpx;
  361. }
  362. .file-card {
  363. display: flex;
  364. flex-wrap: wrap;
  365. gap: 20rpx;
  366. .file-img {
  367. border-radius: 8rpx;
  368. overflow: hidden;
  369. border: 1px solid #eee;
  370. }
  371. .file-doc {
  372. display: flex;
  373. flex-direction: column;
  374. align-items: center;
  375. justify-content: center;
  376. width: 120rpx;
  377. height: 120rpx;
  378. background-color: #f7f8fa;
  379. border-radius: 8rpx;
  380. overflow: hidden;
  381. .file-name {
  382. font-size: 22rpx;
  383. color: #999;
  384. margin-top: 10rpx;
  385. width: 100%;
  386. text-align: center;
  387. overflow: hidden;
  388. white-space: nowrap;
  389. text-overflow: ellipsis;
  390. padding: 0 4rpx;
  391. }
  392. }
  393. }
  394. </style>