FileManagementTab.vue 7.2 KB

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