FileManagementTab.vue 6.6 KB

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