FileManagementTab.vue 7.0 KB

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