FileManagementTab.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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 isSHowBtn = computed(() => {
  86. const a = tableData.value
  87. let tableIdentity = [];
  88. const tableAddress = [];
  89. const tableAdditional = [];
  90. a.forEach((item) => {
  91. if (item.type == 1 || item.type == 2) {
  92. tableIdentity.push(item);
  93. } else if (item.type == 3) {
  94. tableAddress.push(item);
  95. } else {
  96. tableAdditional.push(item);
  97. }
  98. });
  99. const isSHowIdentity = tableIdentity.length > 1;
  100. const isSHowAddress = tableAddress.length > 0;
  101. return { isSHowIdentity, isSHowAddress };
  102. });
  103. // 表格列配置
  104. const columns = computed(() => [
  105. {
  106. prop: 'path',
  107. label: t('PersonalManagement.Label.Document'),
  108. type: 'file',
  109. align: 'center'
  110. },
  111. {
  112. prop: 'type',
  113. label: t('PersonalManagement.Label.FileName'),
  114. align: 'left',
  115. slot: 'type'
  116. },
  117. {
  118. prop: 'uploadTime',
  119. label: t('PersonalManagement.Label.UploadDate'),
  120. type: 'date',
  121. dateFormat: 'YYYY-MM-DD HH:mm',
  122. align: 'left'
  123. },
  124. {
  125. prop: 'status',
  126. label: t('PersonalManagement.Label.State'),
  127. type: 'tag',
  128. tagMap: { 1: '启用', 10: '禁用' },
  129. tagTypeMap: { 1: 'success', 0: 'danger' },
  130. slot: 'status',
  131. align: 'center'
  132. },
  133. {
  134. prop: 'btn',
  135. label: '操作',
  136. slot: 'btn',
  137. align: 'center'
  138. }
  139. ])
  140. const addFileDialog = ref(null);
  141. const customFileApi = ref(null)
  142. customFileApi.value = personalApi.customFileList
  143. const openAddFileDialog = (type) => {
  144. addFileDialog.value.open({ type, title: btnMap.value[type], tableData: tableData.value });
  145. }
  146. const openAddFile = (row) => {
  147. if (row.status != 4) {
  148. return
  149. }
  150. let type
  151. switch (row.type) {
  152. case 1:
  153. type = 1
  154. break;
  155. case 2:
  156. type = 1
  157. break;
  158. case 3:
  159. type = 2
  160. break;
  161. case 10:
  162. type = 3
  163. break;
  164. }
  165. addFileDialog.value.open({ type, title: btnMap.value[type], tableData: tableData.value, currentFile: row });
  166. }
  167. const addSuccess = () => {
  168. tableRef.value.refreshTable()
  169. }
  170. defineProps<Props>();
  171. </script>
  172. <style scoped lang="scss">
  173. @import "@/uni.scss";
  174. .btn{
  175. margin: 0;
  176. }
  177. .avatar {
  178. width: px2rpx(60);
  179. height: px2rpx(60);
  180. border-radius: 4px;
  181. }
  182. .content-title {
  183. display: flex;
  184. justify-content: space-between;
  185. align-items: center;
  186. font-size: px2rpx(20);
  187. font-weight: 500;
  188. .content-title-btns {
  189. margin: px2rpx(8) 0;
  190. display: flex;
  191. align-items: center;
  192. justify-content: flex-end;
  193. //flex-wrap: wrap;
  194. gap: px2rpx(5);
  195. .btn-primary {
  196. min-width: px2rpx(80);
  197. background-color: var(--color-error);
  198. color: white;
  199. padding: 0 px2rpx(10);
  200. border: none;
  201. border-radius: px2rpx(8);
  202. font-size: px2rpx(16);
  203. text-align: center;
  204. cursor: pointer;
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. box-sizing: border-box;
  209. //gap: px2rpx(5);
  210. }
  211. .btn-primary:active {
  212. background-color: #cf1322;
  213. ;
  214. }
  215. }
  216. }
  217. .operation-btn {
  218. display: flex;
  219. width: px2rpx(120);
  220. align-items: center;
  221. justify-content: center;
  222. padding: 0 px2rpx(10);
  223. box-sizing: border-box;
  224. height: px2rpx(36);
  225. line-height: px2rpx(36);
  226. :deep(span) {
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. gap: px2rpx(4);
  231. cursor: pointer;
  232. background-color: var(--btn-color);
  233. color: #000;
  234. padding: px2rpx(8) 0;
  235. }
  236. }
  237. .table-cell-center {
  238. display: flex;
  239. justify-content: center;
  240. align-items: center;
  241. width: 100%;
  242. }
  243. .operation-btn.disabled {
  244. cursor: not-allowed;
  245. opacity: 0.5;
  246. :deep(span) {
  247. cursor: not-allowed;
  248. }
  249. }
  250. </style>