FileManagementTab.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view>
  3. <view class="content-title" v-if="current != 3">
  4. <view v-t="'PersonalManagement.Title.FileManagement'"></view>
  5. <view class="content-title-btns">
  6. <view v-if="!isSHowBtn.isSHowIdentity" class="btn-primary" @click="openAddFileDialog(1)">
  7. <cwg-icon icon="crm-plus" :size="16" color="#fff" />
  8. <text v-t="'PersonalManagement.Title.ProofOfIdentity'" />
  9. </view>
  10. <view v-if="!isSHowBtn.isSHowAddress" class="btn-primary" @click="openAddFileDialog(2)">
  11. <cwg-icon icon="crm-plus" :size="16" color="#fff" />
  12. <text v-t="'PersonalManagement.Title.ProofOfAddress'" />
  13. </view>
  14. <view class="btn-primary" @click="openAddFileDialog(3)">
  15. <cwg-icon icon="crm-plus" :size="16" color="#fff" />
  16. <text v-t="'PersonalManagement.Title.AttachedFile'" />
  17. </view>
  18. </view>
  19. </view>
  20. <cwg-tabel ref="tableRef" :columns="columns" :api="customFileApi" :show-operation="false"
  21. :showPagination="false">
  22. <template #type="{ row }">
  23. <view :class="['status-badge', row.status]">{{ typeMap[row.type] }}</view>
  24. </template>
  25. <template #status="{ row }">
  26. <view :class="['status-badge', row.status]">{{ stateMap[row.status] }}</view>
  27. </template>
  28. <template #btn="{ row }">
  29. <text :class="['operation-btn', row.status !== 4 ? 'disabled' : '']" @click.stop="openAddFile(row)">
  30. <cwg-icon name="crm-image" :size="16" color="#1d293d" />
  31. <text v-t="'State.Again'" />
  32. </text>
  33. </template>
  34. </cwg-tabel>
  35. <add-file-dialog ref="addFileDialog" @file-added="customFileList" @success="addSuccess" />
  36. </view>
  37. </template>
  38. <script setup lang="ts">
  39. import { computed, ref, onMounted } from 'vue';
  40. import { useI18n } from 'vue-i18n';
  41. import AddFileDialog from './AddFileDialog.vue';
  42. const { t } = useI18n();
  43. import { personalApi } from '@/service/personal';
  44. const stateMap = computed(() => ({
  45. 1: t('State.ToBeProcessed'),
  46. 2: t('State.Completed'),
  47. 3: t('State.Refused'),
  48. 4: t('State.Again')
  49. }));
  50. const typeMap = computed(() => ({
  51. 1: t('PersonalManagement.Title.ProofOfIdentity'),
  52. 2: t('PersonalManagement.Title.ProofOfIdentity'),
  53. 3: t('PersonalManagement.Title.ProofOfAddress'),
  54. 4: t('PersonalManagement.Title.ProofOfAddress'),
  55. 10: t('PersonalManagement.Title.AttachedFile')
  56. }));
  57. const btnMap = computed(() => ({
  58. 1: t('PersonalManagement.Title.ProofOfIdentity'),
  59. 2: t('PersonalManagement.Title.ProofOfAddress'),
  60. 3: t('PersonalManagement.Title.AttachedFile')
  61. }));
  62. interface Props {
  63. icon: string;
  64. label: string;
  65. value: string;
  66. isLast?: boolean;
  67. }
  68. const tableRef = ref<any>(null);
  69. const tableData = computed(() => {
  70. return tableRef.value ? tableRef.value.tableData : [];
  71. });
  72. const isSHowBtn = computed(() => {
  73. const a = tableData.value
  74. let tableIdentity = [];
  75. const tableAddress = [];
  76. const tableAdditional = [];
  77. a.forEach((item) => {
  78. if (item.type == 1 || item.type == 2) {
  79. tableIdentity.push(item);
  80. } else if (item.type == 3) {
  81. tableAddress.push(item);
  82. } else {
  83. tableAdditional.push(item);
  84. }
  85. });
  86. const isSHowIdentity = tableIdentity.length > 1;
  87. const isSHowAddress = tableAddress.length > 0;
  88. return { isSHowIdentity, isSHowAddress };
  89. });
  90. // 表格列配置
  91. const columns = computed(() => [
  92. {
  93. prop: 'path',
  94. label: t('PersonalManagement.Label.Document'),
  95. type: 'file',
  96. align: 'center'
  97. },
  98. {
  99. prop: 'type',
  100. label: t('PersonalManagement.Label.FileName'),
  101. align: 'left',
  102. slot: 'type'
  103. },
  104. {
  105. prop: 'uploadTime',
  106. label: t('PersonalManagement.Label.UploadDate'),
  107. type: 'date',
  108. dateFormat: 'YYYY-MM-DD HH:mm',
  109. align: 'left'
  110. },
  111. {
  112. prop: 'status',
  113. label: t('PersonalManagement.Label.State'),
  114. type: 'tag',
  115. tagMap: { 1: '启用', 10: '禁用' },
  116. tagTypeMap: { 1: 'success', 0: 'danger' },
  117. slot: 'status',
  118. align: 'left'
  119. },
  120. {
  121. prop: 'btn',
  122. label: '操作',
  123. slot: 'btn',
  124. align: 'left'
  125. }
  126. ])
  127. const addFileDialog = ref(null);
  128. const customFileApi = ref(null)
  129. customFileApi.value = personalApi.customFileList
  130. const openAddFileDialog = (type) => {
  131. addFileDialog.value.open({ type, title: btnMap.value[type], tableData: tableData.value });
  132. }
  133. const openAddFile = (row) => {
  134. if (row.status != 4) {
  135. return
  136. }
  137. let type
  138. switch (row.type) {
  139. case 1:
  140. type = 1
  141. break;
  142. case 2:
  143. type = 1
  144. break;
  145. case 3:
  146. type = 2
  147. break;
  148. case 10:
  149. type = 3
  150. break;
  151. }
  152. addFileDialog.value.open({ type, title: btnMap.value[type], tableData: tableData.value, currentFile: row });
  153. }
  154. const addSuccess = () => {
  155. tableRef.value.refreshTable()
  156. }
  157. defineProps<Props>();
  158. </script>
  159. <style scoped lang="scss">
  160. @import "@/uni.scss";
  161. .avatar {
  162. width: px2rpx(60);
  163. height: px2rpx(60);
  164. border-radius: 4px;
  165. }
  166. .content-title {
  167. display: flex;
  168. justify-content: space-between;
  169. align-items: center;
  170. font-size: px2rpx(20);
  171. font-weight: 500;
  172. .content-title-btns {
  173. margin: px2rpx(8) 0;
  174. display: flex;
  175. align-items: center;
  176. justify-content: center;
  177. gap: px2rpx(12);
  178. .btn-primary {
  179. min-width: px2rpx(120);
  180. background-color: var(--color-error);
  181. color: white;
  182. padding: 0 px2rpx(12);
  183. border: none;
  184. font-size: px2rpx(14);
  185. text-align: center;
  186. cursor: pointer;
  187. display: flex;
  188. align-items: center;
  189. justify-content: center;
  190. gap: px2rpx(8);
  191. }
  192. .btn-primary:active {
  193. background-color: #cf1322;
  194. ;
  195. }
  196. }
  197. }
  198. .operation-btn {
  199. :deep(span) {
  200. display: flex;
  201. align-items: center;
  202. justify-content: center;
  203. gap: px2rpx(4);
  204. cursor: pointer;
  205. background-color: var(--color-slate-150);
  206. padding: px2rpx(8) 0;
  207. }
  208. }
  209. .operation-btn.disabled {
  210. cursor: not-allowed;
  211. opacity: 0.5;
  212. }
  213. </style>