FileManagementTab.vue 6.8 KB

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