ChangeDetailPopup.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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, isClinicalTrialOptions } 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. // Pull globally dynamic dictionaries
  183. const sysDict = useDict('sci_pjt_level', 'sci_pjt_type', 'sci_academic_degree');
  184. /** Tab 页标题配置 */
  185. const tabList = computed(() => {
  186. const tabs = [{ name: '基本信息' }];
  187. if (projectStore.changeDetailData.changeType != '50') {
  188. tabs.push({ name: '变更前信息' });
  189. tabs.push({ name: '变更后信息' });
  190. }
  191. if (projectStore.changeDetailData.approvalStatus > 10) {
  192. tabs.push({ name: '审批信息' });
  193. }
  194. return tabs;
  195. });
  196. // 当前激活的 tab index
  197. const currentTab = ref(0);
  198. /**
  199. * 切换 Tab 页
  200. */
  201. const handleTabClick = (item: any) => {
  202. currentTab.value = item.index;
  203. };
  204. /**
  205. * 外部调用开启详情弹窗
  206. * @param row 原始数据
  207. * @param projectType 项目类型
  208. * @param projectId 项目对应的原记录ID
  209. */
  210. const open = (row: any, projectType: string, projectId: number) => {
  211. popupRef.value?.open();
  212. // Call mapped store action, keeping all logic decoupled
  213. projectStore.fetchProjectChangeDetail(row.id || row.changeId, projectType, projectId);
  214. };
  215. const close = () => {
  216. popupRef.value?.close();
  217. // 关闭时重置 tab 索引
  218. setTimeout(() => {
  219. currentTab.value = 0;
  220. }, 300);
  221. };
  222. // Utils strictly mapped locally for UI
  223. const getDictLabel = (options: any[], value: string | number) => {
  224. const opt = options.find((item: any) => item.dictValue == value);
  225. return opt ? opt.dictLabel : value;
  226. };
  227. const getDegreeName = (val: string) => {
  228. return sysDict.getDictLabel('sci_academic_degree', val) || '--';
  229. };
  230. const getMemberTypeName = (val: string) => {
  231. const map: Record<string, string> = { '10': '本院人员', '20': '非本院人员', '30': '研究生' };
  232. return map[val] || val || '--';
  233. };
  234. const getProjectRoleName = (val: string) => {
  235. const map: Record<string, string> = { '10': '负责人', '20': '主要参与人', '30': '一般参与人' };
  236. return map[val] || val || '--';
  237. };
  238. const amountUnitTransfer = (val: any) => {
  239. if (val === null || val === undefined) return '0.00';
  240. const num = Number(val);
  241. if (isNaN(num)) return '0.00';
  242. const formatted = (num / 10000).toFixed(2);
  243. const parts = formatted.split('.');
  244. parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  245. return parts.join('.');
  246. };
  247. defineExpose({ open, close });
  248. </script>
  249. <style lang="scss" scoped>
  250. .popup-container {
  251. height: 85vh;
  252. display: flex;
  253. flex-direction: column;
  254. background-color: #f7f8fa;
  255. }
  256. .popup-header {
  257. flex-shrink: 0;
  258. display: flex;
  259. justify-content: space-between;
  260. align-items: center;
  261. padding: 30rpx 40rpx;
  262. background-color: #fff;
  263. border-bottom: 2rpx solid #eee;
  264. .title {
  265. font-size: 34rpx;
  266. font-weight: bold;
  267. color: #343A3F;
  268. }
  269. }
  270. .loading-wrap {
  271. flex: 1;
  272. display: flex;
  273. align-items: center;
  274. justify-content: center;
  275. }
  276. .popup-content {
  277. flex: 1;
  278. overflow: hidden;
  279. background-color: #f7f8fa;
  280. }
  281. .tab-pane {
  282. padding: 24rpx;
  283. display: flex;
  284. flex-direction: column;
  285. gap: 24rpx;
  286. }
  287. .section {
  288. background-color: #fff;
  289. border-radius: 16rpx;
  290. padding: 30rpx;
  291. margin-bottom: 20rpx;
  292. .section-title {
  293. font-size: 30rpx;
  294. font-weight: bold;
  295. color: #343A3F;
  296. display: flex;
  297. align-items: center;
  298. margin-bottom: 24rpx;
  299. .icon {
  300. width: 8rpx;
  301. height: 30rpx;
  302. background-color: #1c9bfd;
  303. border-radius: 4rpx;
  304. margin-right: 16rpx;
  305. }
  306. }
  307. }
  308. .info-list {
  309. display: flex;
  310. flex-direction: column;
  311. .info-item {
  312. display: flex;
  313. padding: 16rpx 0;
  314. border-bottom: 2rpx dashed #f5f5f5;
  315. font-size: 28rpx;
  316. line-height: 1.5;
  317. &:last-child {
  318. border-bottom: none;
  319. }
  320. .label {
  321. color: #343A3F;
  322. width: 180rpx;
  323. flex-shrink: 0;
  324. }
  325. .value {
  326. flex: 1;
  327. color: #585858;
  328. word-break: break-all;
  329. text-align: right;
  330. }
  331. }
  332. }
  333. .member-list {
  334. display: flex;
  335. flex-direction: column;
  336. gap: 20rpx;
  337. .member-card {
  338. background-color: #f8f9fb;
  339. border-radius: 12rpx;
  340. padding: 24rpx;
  341. border-left: 6rpx solid #b3d8ff;
  342. &.is-new {
  343. border-left-color: #67c23a;
  344. }
  345. .m-header {
  346. display: flex;
  347. justify-content: space-between;
  348. margin-bottom: 20rpx;
  349. .m-name {
  350. font-size: 30rpx;
  351. font-weight: bold;
  352. color: #343A3F;
  353. }
  354. .m-role {
  355. font-size: 24rpx;
  356. background-color: #e6f1fc;
  357. color: #1c9bfd;
  358. padding: 4rpx 12rpx;
  359. border-radius: 8rpx;
  360. }
  361. }
  362. .m-body {
  363. background-color: #fff;
  364. padding: 10rpx 20rpx;
  365. border-radius: 8rpx;
  366. }
  367. }
  368. }
  369. .text-red {
  370. color: #ff4d4f;
  371. }
  372. .font-num {
  373. font-family: din;
  374. font-weight: bold;
  375. }
  376. </style>