ChangeDetailPopup.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <uv-popup ref="popupRef" mode="bottom" round="20" :safeAreaInsetBottom="true">
  3. <view class="popup-container">
  4. <view class="popup-header">
  5. <text class="title">变更详情</text>
  6. <uv-icon name="close" size="36rpx" color="#999" @click="close"></uv-icon>
  7. </view>
  8. <scroll-view class="popup-content" scroll-y v-if="!projectStore.fetchChangeDetailLoading">
  9. <uv-tabs :list="tabList" :current="currentTab" @click="handleTabClick" lineColor="#1c9bfd" activeColor="#1c9bfd" inactiveColor="#666"></uv-tabs>
  10. <view class="tab-pane" v-show="tabList[currentTab]?.name === '基本信息'">
  11. <!-- 基本信息 -->
  12. <CommonSection title="基本信息">
  13. <CommonInfoRow label="变更类型" :value="getDictLabel(changeTypeOptions, projectStore.changeDetailData.changeType)" />
  14. <template v-if="projectStore.changeDetailData.projectType == '10' || projectStore.changeDetailData.projectType == '30'">
  15. <CommonInfoRow
  16. label="项目分类"
  17. :value="projectStore.projectBaseData.projectClazzName"
  18. />
  19. </template>
  20. <template v-if="projectStore.changeDetailData.projectType == '20'">
  21. <CommonInfoRow
  22. label="研究类型"
  23. :value="sysDict.getDictLabel('sci_pjt_type', projectStore.projectBaseData.isClinicalTrial)"
  24. />
  25. </template>
  26. <CommonInfoRow
  27. v-if="projectStore.changeDetailData.changeType == '50'"
  28. label="中止时间"
  29. :value="projectStore.changeDetailData.abortDate ? dayjs(projectStore.changeDetailData.abortDate).format('YYYY-MM-DD') : '--'"
  30. noBorder
  31. />
  32. <CommonInfoRow
  33. v-if="projectStore.changeDetailData.changeType == '60'"
  34. label="经费卡余额"
  35. :value="projectStore.projectBaseData.cardBalanceAmount !== undefined && projectStore.projectBaseData.cardBalanceAmount !== null ? String(projectStore.projectBaseData.cardBalanceAmount) : '--'"
  36. noBorder
  37. />
  38. <view
  39. class="ui-info-row no-border"
  40. v-if="projectStore.changeDetailData.evidence"
  41. style="padding: 24rpx 0; font-size: 28rpx; display: flex; justify-content: space-between;"
  42. >
  43. <view class="item-label" style="color: #343a3f; width: 200rpx; flex-shrink: 0; margin-right: 20rpx;">证明材料</view>
  44. <view class="item-value" style="flex: 1; text-align: right;">
  45. <text style="color: #1c9bfd;" @click="previewFile(projectStore.changeDetailData.evidence)">查看附件</text>
  46. </view>
  47. </view>
  48. </CommonSection>
  49. </view>
  50. <view class="tab-pane" v-show="tabList[currentTab]?.name === '变更前信息'">
  51. <!-- 变更前信息 -->
  52. <CommonSection title="变更前信息" v-if="projectStore.changeDetailData.changeType != '50'">
  53. <!-- 10: 成员变更 -->
  54. <template v-if="projectStore.changeDetailData.changeType == '10'">
  55. <view class="member-list">
  56. <view class="member-card" v-for="(row, idx) in projectStore.changePreData" :key="idx">
  57. <view class="m-header">
  58. <text class="m-name">{{ row.memberName }}</text>
  59. <text class="m-role">{{ getProjectRoleName(row.projectRole) }}</text>
  60. </view>
  61. <view class="m-body">
  62. <CommonInfoRow label="学位" :value="getDegreeName(row.degree)" />
  63. <CommonInfoRow label="成员类型" :value="getMemberTypeName(row.memberType)" />
  64. <CommonInfoRow label="科室" :value="row.deptName" />
  65. <CommonInfoRow label="负责内容" :value="row.responsibleContent" noBorder />
  66. </view>
  67. </view>
  68. <uv-empty v-if="!projectStore.changePreData || projectStore.changePreData.length === 0" mode="data" text="暂无数据"></uv-empty>
  69. </view>
  70. </template>
  71. <!-- 30: 延期变更 -->
  72. <template v-if="projectStore.changeDetailData.changeType == '30'">
  73. <CommonInfoRow label="开始日期" :value="projectStore.changePreData && projectStore.changePreData[0] ? dayjs(projectStore.changePreData[0]).format('YYYY-MM-DD') : '--'" />
  74. <CommonInfoRow label="结束日期" :value="projectStore.changePreData && projectStore.changePreData[1] ? dayjs(projectStore.changePreData[1]).format('YYYY-MM-DD') : '--'" noBorder />
  75. </template>
  76. <!-- 40: 经费变更 -->
  77. <template v-if="projectStore.changeDetailData.changeType == '40'">
  78. <CommonInfoRow
  79. :label="projectStore.projectBaseData.isClinicalTrial === '10' ? '科研经费(万元)' : '合同经费(万元)'"
  80. :value="amountUnitTransfer(projectStore.changePreData)"
  81. isAmount
  82. noBorder
  83. />
  84. </template>
  85. <!-- 60: 经费调剂 -->
  86. <template v-if="projectStore.changeDetailData.changeType == '60'">
  87. <view class="member-list">
  88. <view class="member-card" v-for="(row, idx) in projectStore.changePreData" :key="idx">
  89. <view class="m-header">
  90. <text class="m-name">{{ row.subjName }}</text>
  91. </view>
  92. <view class="m-body">
  93. <CommonInfoRow label="科目编号" :value="row.subjCode" />
  94. <CommonInfoRow label="剩余金额(元)" :value="row.balanceAmount !== undefined && row.balanceAmount !== null ? String(row.balanceAmount) : '0'" noBorder />
  95. </view>
  96. </view>
  97. <uv-empty v-if="!projectStore.changePreData || projectStore.changePreData.length === 0" mode="data" text="暂无数据"></uv-empty>
  98. </view>
  99. </template>
  100. </CommonSection>
  101. <uv-empty v-else mode="data" text="此变更类型无变更前信息"></uv-empty>
  102. </view>
  103. <view class="tab-pane" v-show="tabList[currentTab]?.name === '变更后信息'">
  104. <!-- 变更后信息 -->
  105. <CommonSection title="变更后信息" v-if="projectStore.changeDetailData.changeType != '50'">
  106. <!-- 10: 成员变更 -->
  107. <template v-if="projectStore.changeDetailData.changeType == '10'">
  108. <view class="member-list">
  109. <view class="member-card is-new" v-for="(row, idx) in projectStore.changeAfterData" :key="idx">
  110. <view class="m-header">
  111. <text class="m-name">{{ row.memberName }}</text>
  112. <text class="m-role">{{ getProjectRoleName(row.projectRole) }}</text>
  113. </view>
  114. <view class="m-body">
  115. <CommonInfoRow label="学位" :value="getDegreeName(row.degree)" />
  116. <CommonInfoRow label="成员类型" :value="getMemberTypeName(row.memberType)" />
  117. <CommonInfoRow label="科室" :value="row.deptName" />
  118. <CommonInfoRow label="负责内容" :value="row.responsibleContent" noBorder />
  119. </view>
  120. </view>
  121. <uv-empty v-if="!projectStore.changeAfterData || projectStore.changeAfterData.length === 0" mode="data" text="暂无数据"></uv-empty>
  122. </view>
  123. </template>
  124. <!-- 30: 延期变更 -->
  125. <template v-if="projectStore.changeDetailData.changeType == '30'">
  126. <CommonInfoRow label="开始日期" :value="projectStore.changeAfterData && projectStore.changeAfterData[0] ? dayjs(projectStore.changeAfterData[0]).format('YYYY-MM-DD') : '--'" />
  127. <CommonInfoRow label="结束日期" :value="projectStore.changeAfterData && projectStore.changeAfterData[1] ? dayjs(projectStore.changeAfterData[1]).format('YYYY-MM-DD') : '--'" noBorder />
  128. </template>
  129. <!-- 40: 经费变更 -->
  130. <template v-if="projectStore.changeDetailData.changeType == '40'">
  131. <CommonInfoRow
  132. :label="projectStore.projectBaseData.isClinicalTrial === '10' ? '科研经费(万元)' : '合同经费(万元)'"
  133. :value="amountUnitTransfer(projectStore.changeAfterData)"
  134. isAmount
  135. noBorder
  136. />
  137. </template>
  138. <!-- 60: 经费调剂 -->
  139. <template v-if="projectStore.changeDetailData.changeType == '60'">
  140. <view class="member-list">
  141. <view class="member-card is-new" v-for="(row, idx) in projectStore.changeAfterData" :key="idx">
  142. <view class="m-header">
  143. <text class="m-name">{{ row.subjName }}</text>
  144. </view>
  145. <view class="m-body">
  146. <CommonInfoRow label="科目编号" :value="row.subjCode" />
  147. <CommonInfoRow label="剩余金额(元)" :value="row.balanceAmount !== undefined && row.balanceAmount !== null ? String(row.balanceAmount) : '0'" noBorder />
  148. </view>
  149. </view>
  150. <uv-empty v-if="!projectStore.changeAfterData || projectStore.changeAfterData.length === 0" mode="data" text="暂无数据"></uv-empty>
  151. </view>
  152. </template>
  153. </CommonSection>
  154. <uv-empty v-else mode="data" text="此变更类型无变更后信息"></uv-empty>
  155. </view>
  156. <view class="tab-pane" v-show="tabList[currentTab]?.name === '审批信息'">
  157. <!-- 审批信息 -->
  158. <CommonSection title="审批信息">
  159. <FlowTable :id="projectStore.changeDetailData.id" :businessCode="String(projectStore.changeDetailData.id)"
  160. defCode="sci_project_change" />
  161. </CommonSection>
  162. </view>
  163. </scroll-view>
  164. <view class="loading-wrap" v-else>
  165. <uv-loading-icon text="数据加载中..." :vertical="true"></uv-loading-icon>
  166. </view>
  167. </view>
  168. </uv-popup>
  169. </template>
  170. <script setup lang="ts">
  171. import { ref, computed } from 'vue';
  172. import { useProjectStore } from '@/store/modules/project';
  173. import { useDict } from '@/hooks/useDict';
  174. import { changeTypeOptions } from '@/constants';
  175. import FlowTable from './FlowTable.vue';
  176. import dayjs from 'dayjs';
  177. import CommonSection from '@/components/ui/CommonSection.vue';
  178. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  179. import { previewFile } from '@/utils/file';
  180. const projectStore = useProjectStore();
  181. const popupRef = ref<any>(null);
  182. const sysDict = useDict('sci_pjt_level', 'sci_pjt_type', 'sci_academic_degree');
  183. /** Tab 页标题配置 */
  184. const tabList = computed(() => {
  185. const tabs = [{ name: '基本信息' }];
  186. if (projectStore.changeDetailData.changeType != '50') {
  187. tabs.push({ name: '变更前信息' });
  188. tabs.push({ name: '变更后信息' });
  189. }
  190. if (projectStore.changeDetailData.approvalStatus > 10) {
  191. tabs.push({ name: '审批信息' });
  192. }
  193. return tabs;
  194. });
  195. // 当前激活的 tab index
  196. const currentTab = ref(0);
  197. /**
  198. * 切换 Tab 页
  199. */
  200. const handleTabClick = (item: any) => {
  201. currentTab.value = item.index;
  202. };
  203. /**
  204. * 外部调用开启详情弹窗
  205. * @param row 原始数据
  206. * @param projectType 项目类型
  207. * @param projectId 项目对应的原记录ID
  208. */
  209. const open = (row: any, projectType: string, projectId: number) => {
  210. popupRef.value?.open();
  211. // Call mapped store action, keeping all logic decoupled
  212. projectStore.fetchProjectChangeDetail(row.id || row.changeId, projectType, projectId);
  213. };
  214. const close = () => {
  215. popupRef.value?.close();
  216. // 关闭时重置 tab 索引
  217. setTimeout(() => {
  218. currentTab.value = 0;
  219. }, 300);
  220. };
  221. // Utils strictly mapped locally for UI
  222. const getDictLabel = (options: any[], value: string | number) => {
  223. const opt = options.find((item: any) => item.dictValue == value);
  224. return opt ? opt.dictLabel : value;
  225. };
  226. const getDegreeName = (val: string) => {
  227. return sysDict.getDictLabel('sci_academic_degree', val) || '--';
  228. };
  229. const getMemberTypeName = (val: string) => {
  230. const map: Record<string, string> = { '10': '本院人员', '20': '非本院人员', '30': '研究生' };
  231. return map[val] || val || '--';
  232. };
  233. const getProjectRoleName = (val: string) => {
  234. const map: Record<string, string> = { '10': '负责人', '20': '主要参与人', '30': '一般参与人' };
  235. return map[val] || val || '--';
  236. };
  237. const amountUnitTransfer = (val: any) => {
  238. if (val === null || val === undefined) return '0.00';
  239. const num = Number(val);
  240. if (isNaN(num)) return '0.00';
  241. const formatted = (num / 10000).toFixed(2);
  242. const parts = formatted.split('.');
  243. parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  244. return parts.join('.');
  245. };
  246. defineExpose({ open, close });
  247. </script>
  248. <style lang="scss" scoped>
  249. .popup-container {
  250. height: 85vh;
  251. display: flex;
  252. flex-direction: column;
  253. background-color: #f7f8fa;
  254. }
  255. .popup-header {
  256. flex-shrink: 0;
  257. display: flex;
  258. justify-content: space-between;
  259. align-items: center;
  260. padding: 30rpx 40rpx;
  261. background-color: #fff;
  262. border-bottom: 2rpx solid #eee;
  263. .title {
  264. font-size: 34rpx;
  265. font-weight: bold;
  266. color: #343A3F;
  267. }
  268. }
  269. .loading-wrap {
  270. flex: 1;
  271. display: flex;
  272. align-items: center;
  273. justify-content: center;
  274. }
  275. .popup-content {
  276. flex: 1;
  277. overflow: hidden;
  278. background-color: #f7f8fa;
  279. }
  280. .tab-pane {
  281. padding: 24rpx;
  282. display: flex;
  283. flex-direction: column;
  284. gap: 24rpx;
  285. }
  286. .section {
  287. background-color: #fff;
  288. border-radius: 16rpx;
  289. padding: 30rpx;
  290. margin-bottom: 20rpx;
  291. .section-title {
  292. font-size: 30rpx;
  293. font-weight: bold;
  294. color: #343A3F;
  295. display: flex;
  296. align-items: center;
  297. margin-bottom: 24rpx;
  298. .icon {
  299. width: 8rpx;
  300. height: 30rpx;
  301. background-color: #1c9bfd;
  302. border-radius: 4rpx;
  303. margin-right: 16rpx;
  304. }
  305. }
  306. }
  307. .info-list {
  308. display: flex;
  309. flex-direction: column;
  310. .info-item {
  311. display: flex;
  312. padding: 16rpx 0;
  313. border-bottom: 2rpx dashed #f5f5f5;
  314. font-size: 28rpx;
  315. line-height: 1.5;
  316. &:last-child {
  317. border-bottom: none;
  318. }
  319. .label {
  320. color: #343A3F;
  321. width: 180rpx;
  322. flex-shrink: 0;
  323. }
  324. .value {
  325. flex: 1;
  326. color: #585858;
  327. word-break: break-all;
  328. text-align: right;
  329. }
  330. }
  331. }
  332. .member-list {
  333. display: flex;
  334. flex-direction: column;
  335. gap: 20rpx;
  336. .member-card {
  337. background-color: #f8f9fb;
  338. border-radius: 12rpx;
  339. padding: 24rpx;
  340. border-left: 6rpx solid #b3d8ff;
  341. &.is-new {
  342. border-left-color: #67c23a;
  343. }
  344. .m-header {
  345. display: flex;
  346. justify-content: space-between;
  347. margin-bottom: 20rpx;
  348. .m-name {
  349. font-size: 30rpx;
  350. font-weight: bold;
  351. color: #343A3F;
  352. }
  353. .m-role {
  354. font-size: 24rpx;
  355. background-color: #e6f1fc;
  356. color: #1c9bfd;
  357. padding: 4rpx 12rpx;
  358. border-radius: 8rpx;
  359. }
  360. }
  361. .m-body {
  362. background-color: #fff;
  363. padding: 10rpx 20rpx;
  364. border-radius: 8rpx;
  365. }
  366. }
  367. }
  368. .text-red {
  369. color: #ff4d4f;
  370. }
  371. .font-num {
  372. font-family: din;
  373. font-weight: bold;
  374. }
  375. </style>