FileManagementTab.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view>
  3. <!-- <view class="content-title" v-t="'PersonalManagement.Title.FileManagement'"></view>-->
  4. <view v-show="!loading" class="content-title">
  5. <view/>
  6. <view v-if="isShowBtn" class="content-title-btns">
  7. <button v-if="!isShowBtn.isSHowIdentity" type="button" class="btn btn-danger btn-shadow waves-effect" @click="openAddFileDialog(1)" >
  8. <view class="d-flex align-items-center">
  9. <cwg-icon name="crm-plus" :size="14" color="#fff" />
  10. <text v-t="'PersonalManagement.Title.ProofOfIdentity'" />
  11. </view>
  12. </button>
  13. <button v-if="!isShowBtn.isSHowAddress" type="button" class="btn btn-danger btn-shadow waves-effect" @click="openAddFileDialog(2)" >
  14. <view class="d-flex align-items-center">
  15. <cwg-icon name="crm-plus" :size="14" color="#fff" />
  16. <text v-t="'PersonalManagement.Title.ProofOfAddress'" />
  17. </view>
  18. </button>
  19. <button type="button" class="btn btn-danger btn-shadow waves-effect" @click="openAddFileDialog(3)" >
  20. <view class="d-flex align-items-center">
  21. <cwg-icon name="crm-plus" :size="14" color="#fff" />
  22. <text v-t="'PersonalManagement.Title.AttachedFile'" />
  23. </view>
  24. </button>
  25. </view>
  26. </view>
  27. <cwg-tabel ref="tableRef" :columns="columns" :api="customFileApi" :show-operation="false"
  28. :showPagination="false">
  29. <template #type="{ row }">
  30. <view :class="['status-badge', row.status]">{{ typeMap[row.type] }}</view>
  31. </template>
  32. <template #status="{ row }">
  33. <view class="table-cell-center">
  34. <view :class="['status-badge', row.status]">{{ stateMap[row.status] }}</view>
  35. </view>
  36. </template>
  37. <template #btn="{ row }">
  38. <view class="table-cell-center">
  39. <button class="btn-submit" :class="['operation-btn', row.status !== 4 ? 'disabled' : '']" :disabled="row.status !== 4" @click.stop="openAddFile(row)">
  40. <cwg-icon name="crm-image" :size="16" color="#1d293d" />
  41. <text v-t="'State.Again'" />
  42. </button>
  43. </view>
  44. </template>
  45. </cwg-tabel>
  46. <add-file-dialog ref="addFileDialog" @file-added="customFileList" @success="addSuccess" />
  47. </view>
  48. </template>
  49. <script setup lang="ts">
  50. import { computed, ref, onMounted, watch } from 'vue';
  51. import { useI18n } from 'vue-i18n';
  52. import AddFileDialog from './AddFileDialog.vue';
  53. const { t } = useI18n();
  54. import { personalApi } from '@/service/personal';
  55. const stateMap = computed(() => ({
  56. 1: t('State.ToBeProcessed'),
  57. 2: t('State.Completed'),
  58. 3: t('State.Refused'),
  59. 4: t('State.Again')
  60. }));
  61. const typeMap = computed(() => ({
  62. 1: t('PersonalManagement.Title.ProofOfIdentity'),
  63. 2: t('PersonalManagement.Title.ProofOfIdentity'),
  64. 3: t('PersonalManagement.Title.ProofOfAddress'),
  65. 4: t('PersonalManagement.Title.ProofOfAddress'),
  66. 10: t('PersonalManagement.Title.AttachedFile')
  67. }));
  68. const btnMap = computed(() => ({
  69. 1: t('PersonalManagement.Title.ProofOfIdentity'),
  70. 2: t('PersonalManagement.Title.ProofOfAddress'),
  71. 3: t('PersonalManagement.Title.AttachedFile')
  72. }));
  73. interface Props {
  74. icon: string;
  75. label: string;
  76. value: string;
  77. isLast?: boolean;
  78. }
  79. const tableRef = ref<any>(null);
  80. const tableData = computed(() => {
  81. return tableRef.value ? tableRef.value.tableData : [];
  82. });
  83. const loading = ref(false)
  84. const isShowBtn = ref()
  85. const setShowBtn = () => {
  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. isShowBtn.value = { isSHowIdentity, isSHowAddress };
  102. }
  103. // 表格列配置
  104. const columns = computed(() => [
  105. {
  106. prop: 'path',
  107. label: t('vu.item20'),
  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: t('Label.Action'),
  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. watch(tableData, (newVal) => {
  171. if (newVal && newVal.length > 0) {
  172. loading.value = true
  173. setShowBtn()
  174. setTimeout(()=>{
  175. loading.value = false
  176. },300)
  177. }
  178. }, { immediate: true })
  179. defineProps<Props>();
  180. </script>
  181. <style scoped lang="scss">
  182. @import "@/uni.scss";
  183. .btn{
  184. margin: 0;
  185. }
  186. .avatar {
  187. width: px2rpx(60);
  188. height: px2rpx(60);
  189. border-radius: 4px;
  190. }
  191. .content-title {
  192. display: flex;
  193. justify-content: space-between;
  194. align-items: center;
  195. font-size: px2rpx(20);
  196. font-weight: 500;
  197. .content-title-btns {
  198. margin: px2rpx(8) 0;
  199. display: flex;
  200. align-items: center;
  201. justify-content: flex-end;
  202. //flex-wrap: wrap;
  203. gap: px2rpx(5);
  204. .btn-primary {
  205. min-width: px2rpx(80);
  206. background-color: var(--color-error);
  207. color: white;
  208. padding: 0 px2rpx(10);
  209. border: none;
  210. border-radius: px2rpx(8);
  211. font-size: px2rpx(16);
  212. text-align: center;
  213. cursor: pointer;
  214. display: flex;
  215. align-items: center;
  216. justify-content: center;
  217. box-sizing: border-box;
  218. //gap: px2rpx(5);
  219. }
  220. .btn-primary:active {
  221. background-color: #cf1322;
  222. ;
  223. }
  224. }
  225. }
  226. .operation-btn {
  227. display: flex;
  228. width: px2rpx(120);
  229. align-items: center;
  230. justify-content: center;
  231. padding: 0 px2rpx(10);
  232. box-sizing: border-box;
  233. height: px2rpx(36);
  234. line-height: px2rpx(36);
  235. :deep(span) {
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. gap: px2rpx(4);
  240. cursor: pointer;
  241. background-color: var(--btn-color);
  242. color: #000;
  243. padding: px2rpx(8) 0;
  244. }
  245. }
  246. .table-cell-center {
  247. display: flex;
  248. justify-content: center;
  249. align-items: center;
  250. width: 100%;
  251. }
  252. .operation-btn.disabled {
  253. cursor: not-allowed;
  254. opacity: 0.5;
  255. :deep(span) {
  256. cursor: not-allowed;
  257. }
  258. }
  259. </style>