AchCommitteeForm.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="document-form">
  3. <uv-loading-icon v-if="loading" mode="circle" text="正在加载详情..."></uv-loading-icon>
  4. <template v-else-if="form">
  5. <!-- 变更单据基本信息 -->
  6. <CommonSection title="基本信息" :isFirst="true">
  7. <CommonInfoRow label="所属委员会" :value="committeeLabel" />
  8. <CommonInfoRow label="变更类型" :value="getChangeTypeLabel(form.changeType)" />
  9. <CommonInfoRow label="变更时间" :value="formatDate(form.changeDate)" />
  10. <CommonInfoRow label="备注说明" :value="form.remark" isColumn />
  11. </CommonSection>
  12. <!-- 变更材料 -->
  13. <AttachmentList :file="mergedChangeFile" title="变更材料" />
  14. <!-- 如果是主任变更 (10) -->
  15. <template v-if="form.changeType === '10'">
  16. <CommonSection title="现委员会主任">
  17. <view class="info-box" v-if="acadeCommittee">
  18. <CommonInfoRow label="主任委员" :value="acadeCommittee.directorName" />
  19. <CommonInfoRow label="所属科室" :value="acadeCommittee.directorDeptName" />
  20. <CommonInfoRow label="职称" :value="acadeCommittee.directorTechnicalTitle" />
  21. <CommonInfoRow label="邮箱" :value="acadeCommittee.directorEmail" />
  22. </view>
  23. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  24. </CommonSection>
  25. <CommonSection title="变更委员会主任">
  26. <view class="info-box highlight-box" v-if="acadeCommitteeChange">
  27. <CommonInfoRow label="主任委员" :value="acadeCommitteeChange.userName" />
  28. <CommonInfoRow label="所属科室" :value="acadeCommitteeChange.deptName" />
  29. <CommonInfoRow label="职称" :value="acadeCommitteeChange.technicalTitle" />
  30. <CommonInfoRow label="邮箱" :value="acadeCommitteeChange.userEmail" />
  31. </view>
  32. </CommonSection>
  33. </template>
  34. <!-- 如果是副主任/委员变更 (20/30) -->
  35. <template v-else>
  36. <!-- 现人员信息 -->
  37. <CommonSection title="现人员信息">
  38. <view class="staff-list" v-if="acadeMemberList?.length">
  39. <view class="staff-item" v-for="(item, index) in acadeMemberList" :key="index">
  40. <view class="staff-header">
  41. <text class="s-name">{{ item.userName }}</text>
  42. <text class="s-tag blue">{{ getUserTypeLabel(item.userType) }}</text>
  43. </view>
  44. <view class="s-body">
  45. <text class="s-text">{{ item.deptName }} | {{ item.technicalTitle }}</text>
  46. <text class="s-text mt5">{{ item.userEmail }}</text>
  47. </view>
  48. </view>
  49. </view>
  50. <uv-empty v-else mode="data" text="暂无人员信息"></uv-empty>
  51. </CommonSection>
  52. <!-- 变更人员信息 -->
  53. <CommonSection title="变更人员信息">
  54. <view class="staff-list" v-if="acadeCommitteeChangeList?.length">
  55. <view class="staff-item highlight-border" v-for="(item, index) in acadeCommitteeChangeList" :key="index">
  56. <view class="staff-header">
  57. <text class="s-name">{{ item.userName }}</text>
  58. <text class="s-tag primary">{{ getUserTypeLabel(item.userType) }}</text>
  59. </view>
  60. <view class="s-body">
  61. <text class="s-text">{{ item.deptName }} | {{ item.technicalTitle }}</text>
  62. <text class="s-text mt5">{{ item.userEmail }}</text>
  63. </view>
  64. </view>
  65. </view>
  66. <uv-empty v-else mode="data" text="暂无变更信息"></uv-empty>
  67. </CommonSection>
  68. </template>
  69. </template>
  70. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  71. </view>
  72. </template>
  73. <script setup lang="ts">
  74. import { ref, onMounted, watch, computed } from 'vue';
  75. import { useDocumentApi } from '@/api/document';
  76. import { formatDate } from '@/utils/date';
  77. import to from 'await-to-js';
  78. import CommonSection from '@/components/ui/CommonSection.vue';
  79. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  80. import AttachmentList from './AttachmentList.vue';
  81. const props = defineProps<{
  82. code: string;
  83. }>();
  84. const documentApi = useDocumentApi();
  85. const form = ref<any>(null); // 变更单据
  86. const acadeCommittee = ref<any>(null); // 变更前的委员会详情
  87. const acadeCommitteeChange = ref<any>(null); // 变更后的主任信息
  88. const acadeMemberList = ref<any[]>([]); // 变更前的人员列表
  89. const acadeCommitteeChangeList = ref<any[]>([]); // 变更后的人员列表
  90. const committees = ref<any[]>([]); // 所有委员会列表,用于翻译名称
  91. const loading = ref(false);
  92. const committeeLabel = computed(() => {
  93. if (!form.value?.committeeId) return '';
  94. const item = committees.value.find(c => c.id === form.value.committeeId);
  95. return item ? item.committeeName : '-';
  96. });
  97. const mergedChangeFile = computed(() => {
  98. if (!form.value?.changeFile) return null;
  99. return {
  100. url: form.value.changeFile,
  101. name: '变更材料',
  102. type: '变更材料'
  103. };
  104. });
  105. const getChangeTypeLabel = (val: string) => {
  106. const map: any = { '10': '主任变更', '20': '副主任变更', '30': '委员变更' };
  107. return map[val] || val || '-';
  108. };
  109. const getUserTypeLabel = (val: string) => {
  110. const map: any = { '10': '主任委员', '20': '副主任委员', '30': '委员' };
  111. return map[val] || val || '-';
  112. };
  113. const fetchData = async () => {
  114. if (!props.code) return;
  115. loading.value = true;
  116. // 1. 获取委员会列表(用于翻译ID)
  117. const [cErr, cRes] = await to(documentApi.getCommitteeList());
  118. if (!cErr && cRes?.data?.list) {
  119. committees.value = cRes.data.list;
  120. }
  121. // 2. 获取变更单据详情
  122. const [err, res] = await to(documentApi.getCommitteeByCode(props.code));
  123. if (!err && res?.data) {
  124. form.value = res.data;
  125. acadeCommitteeChange.value = res.data.acadeCommitteeMember;
  126. acadeCommitteeChangeList.value = res.data.acadeCommitteeList || [];
  127. // 3. 根据委员会ID获取原始详情(現人员信息)
  128. const [e, r] = await to(documentApi.getCommitteeById(res.data.committeeId, res.data.changeType));
  129. if (!e && r?.data) {
  130. acadeCommittee.value = r.data;
  131. acadeMemberList.value = r.data.acadeCommitteeList || [];
  132. }
  133. }
  134. loading.value = false;
  135. };
  136. onMounted(() => {
  137. fetchData();
  138. });
  139. watch(() => props.code, () => {
  140. fetchData();
  141. });
  142. </script>
  143. <style lang="scss" scoped>
  144. @import "./common.scss";
  145. .info-box {
  146. background-color: #f8fafc;
  147. border-radius: 12rpx;
  148. padding: 8rpx 0;
  149. &.highlight-box {
  150. background-color: #f0f9ff;
  151. border: 1rpx solid #e0f2fe;
  152. }
  153. }
  154. .staff-list {
  155. .staff-item {
  156. padding: 24rpx;
  157. background-color: #f8fafc;
  158. border-radius: 16rpx;
  159. margin-bottom: 20rpx;
  160. border: 1rpx solid #f1f5f9;
  161. &.highlight-border {
  162. border: 2rpx dashed #3b82f6;
  163. background-color: #f0f9ff;
  164. }
  165. .staff-header {
  166. display: flex;
  167. justify-content: space-between;
  168. align-items: center;
  169. margin-bottom: 16rpx;
  170. .s-name {
  171. font-size: 30rpx;
  172. font-weight: 700;
  173. color: #1e293b;
  174. }
  175. }
  176. .s-body {
  177. display: flex;
  178. flex-direction: column;
  179. .s-text {
  180. font-size: 26rpx;
  181. color: #64748b;
  182. }
  183. .mt5 { margin-top: 8rpx; }
  184. }
  185. }
  186. }
  187. </style>