FileManagementTab.vue 7.6 KB

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