FileManagementTab.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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: 'id',
  94. label: 'ID',
  95. align: 'left'
  96. },
  97. {
  98. prop: 'path',
  99. label: t('PersonalManagement.Label.Document'),
  100. type: 'file',
  101. align: 'left'
  102. },
  103. {
  104. prop: 'type',
  105. label: t('PersonalManagement.Label.FileName'),
  106. align: 'left',
  107. slot: 'type'
  108. },
  109. {
  110. prop: 'uploadTime',
  111. label: t('PersonalManagement.Label.UploadDate'),
  112. type: 'date',
  113. dateFormat: 'YYYY-MM-DD HH:mm',
  114. align: 'left'
  115. },
  116. {
  117. prop: 'status',
  118. label: t('PersonalManagement.Label.State'),
  119. type: 'tag',
  120. tagMap: { 1: '启用', 10: '禁用' },
  121. tagTypeMap: { 1: 'success', 0: 'danger' },
  122. slot: 'status',
  123. align: 'left'
  124. },
  125. {
  126. prop: 'btn',
  127. label: '操作',
  128. slot: 'btn',
  129. align: 'left'
  130. }
  131. ])
  132. const addFileDialog = ref(null);
  133. const customFileApi = ref(null)
  134. customFileApi.value = personalApi.customFileList
  135. const openAddFileDialog = (type) => {
  136. addFileDialog.value.open({ type, title: btnMap.value[type], tableData: tableData.value });
  137. }
  138. const openAddFile = (row) => {
  139. if (row.status != 4) {
  140. return
  141. }
  142. let type
  143. switch (row.type) {
  144. case 1:
  145. type = 1
  146. break;
  147. case 2:
  148. type = 1
  149. break;
  150. case 3:
  151. type = 2
  152. break;
  153. case 10:
  154. type = 3
  155. break;
  156. }
  157. addFileDialog.value.open({ type, title: btnMap.value[type], tableData: tableData.value, currentFile: row });
  158. }
  159. const addSuccess = () => {
  160. tableRef.value.refreshTable()
  161. }
  162. defineProps<Props>();
  163. </script>
  164. <style scoped lang="scss">
  165. @import "@/uni.scss";
  166. .avatar {
  167. width: px2rpx(60);
  168. height: px2rpx(60);
  169. border-radius: 4px;
  170. }
  171. .content-title {
  172. display: flex;
  173. justify-content: space-between;
  174. align-items: center;
  175. font-size: px2rpx(20);
  176. font-weight: 500;
  177. .content-title-btns {
  178. margin: px2rpx(8) 0;
  179. display: flex;
  180. align-items: center;
  181. justify-content: center;
  182. gap: px2rpx(12);
  183. .btn-primary {
  184. min-width: px2rpx(120);
  185. background-color: var(--color-error);
  186. color: white;
  187. padding: 0 px2rpx(12);
  188. border: none;
  189. font-size: px2rpx(14);
  190. text-align: center;
  191. cursor: pointer;
  192. display: flex;
  193. align-items: center;
  194. justify-content: center;
  195. gap: px2rpx(8);
  196. }
  197. .btn-primary:active {
  198. background-color: #cf1322;
  199. ;
  200. }
  201. }
  202. }
  203. .operation-btn {
  204. :deep(span) {
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. gap: px2rpx(4);
  209. cursor: pointer;
  210. background-color: var(--color-slate-150);
  211. padding: px2rpx(8) 0;
  212. }
  213. }
  214. .operation-btn.disabled {
  215. cursor: not-allowed;
  216. opacity: 0.5;
  217. }
  218. </style>