| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <template>
- <view>
- <view class="content-title" v-t="'PersonalManagement.Title.FileManagement'"></view>
- <view class="content-title" v-if="current != 3">
- <view/>
- <view class="content-title-btns">
- <view v-if="!isSHowBtn.isSHowIdentity" class="btn-primary" @click="openAddFileDialog(1)">
- <cwg-icon icon="crm-plus" :size="16" color="#fff" />
- <text v-t="'PersonalManagement.Title.ProofOfIdentity'" />
- </view>
- <view v-if="!isSHowBtn.isSHowAddress" class="btn-primary" @click="openAddFileDialog(2)">
- <cwg-icon icon="crm-plus" :size="16" color="#fff" />
- <text v-t="'PersonalManagement.Title.ProofOfAddress'" />
- </view>
- <view class="btn-primary" @click="openAddFileDialog(3)">
- <cwg-icon icon="crm-plus" :size="16" color="#fff" />
- <text v-t="'PersonalManagement.Title.AttachedFile'" />
- </view>
- </view>
- </view>
- <cwg-tabel ref="tableRef" :columns="columns" :api="customFileApi" :show-operation="false"
- :showPagination="false">
- <template #type="{ row }">
- <view :class="['status-badge', row.status]">{{ typeMap[row.type] }}</view>
- </template>
- <template #status="{ row }">
- <view :class="['status-badge', row.status]">{{ stateMap[row.status] }}</view>
- </template>
- <template #btn="{ row }">
- <text class="btn-submit" :class="['operation-btn', row.status !== 4 ? 'disabled' : '']" @click.stop="openAddFile(row)">
- <cwg-icon name="crm-image" :size="16" color="#1d293d" />
- <text v-t="'State.Again'" />
- </text>
- </template>
- </cwg-tabel>
- <add-file-dialog ref="addFileDialog" @file-added="customFileList" @success="addSuccess" />
- </view>
- </template>
- <script setup lang="ts">
- import { computed, ref, onMounted } from 'vue';
- import { useI18n } from 'vue-i18n';
- import AddFileDialog from './AddFileDialog.vue';
- const { t } = useI18n();
- import { personalApi } from '@/service/personal';
- const stateMap = computed(() => ({
- 1: t('State.ToBeProcessed'),
- 2: t('State.Completed'),
- 3: t('State.Refused'),
- 4: t('State.Again')
- }));
- const typeMap = computed(() => ({
- 1: t('PersonalManagement.Title.ProofOfIdentity'),
- 2: t('PersonalManagement.Title.ProofOfIdentity'),
- 3: t('PersonalManagement.Title.ProofOfAddress'),
- 4: t('PersonalManagement.Title.ProofOfAddress'),
- 10: t('PersonalManagement.Title.AttachedFile')
- }));
- const btnMap = computed(() => ({
- 1: t('PersonalManagement.Title.ProofOfIdentity'),
- 2: t('PersonalManagement.Title.ProofOfAddress'),
- 3: t('PersonalManagement.Title.AttachedFile')
- }));
- interface Props {
- icon: string;
- label: string;
- value: string;
- isLast?: boolean;
- }
- const tableRef = ref<any>(null);
- const tableData = computed(() => {
- return tableRef.value ? tableRef.value.tableData : [];
- });
- const isSHowBtn = computed(() => {
- const a = tableData.value
- let tableIdentity = [];
- const tableAddress = [];
- const tableAdditional = [];
- a.forEach((item) => {
- if (item.type == 1 || item.type == 2) {
- tableIdentity.push(item);
- } else if (item.type == 3) {
- tableAddress.push(item);
- } else {
- tableAdditional.push(item);
- }
- });
- const isSHowIdentity = tableIdentity.length > 1;
- const isSHowAddress = tableAddress.length > 0;
- return { isSHowIdentity, isSHowAddress };
- });
- // 表格列配置
- const columns = computed(() => [
- {
- prop: 'path',
- label: t('PersonalManagement.Label.Document'),
- type: 'file',
- align: 'center'
- },
- {
- prop: 'type',
- label: t('PersonalManagement.Label.FileName'),
- align: 'left',
- slot: 'type'
- },
- {
- prop: 'uploadTime',
- label: t('PersonalManagement.Label.UploadDate'),
- type: 'date',
- dateFormat: 'YYYY-MM-DD HH:mm',
- align: 'left'
- },
- {
- prop: 'status',
- label: t('PersonalManagement.Label.State'),
- type: 'tag',
- tagMap: { 1: '启用', 10: '禁用' },
- tagTypeMap: { 1: 'success', 0: 'danger' },
- slot: 'status',
- align: 'left'
- },
- {
- prop: 'btn',
- label: '操作',
- slot: 'btn',
- align: 'left'
- }
- ])
- const addFileDialog = ref(null);
- const customFileApi = ref(null)
- customFileApi.value = personalApi.customFileList
- const openAddFileDialog = (type) => {
- addFileDialog.value.open({ type, title: btnMap.value[type], tableData: tableData.value });
- }
- const openAddFile = (row) => {
- if (row.status != 4) {
- return
- }
- let type
- switch (row.type) {
- case 1:
- type = 1
- break;
- case 2:
- type = 1
- break;
- case 3:
- type = 2
- break;
- case 10:
- type = 3
- break;
- }
- addFileDialog.value.open({ type, title: btnMap.value[type], tableData: tableData.value, currentFile: row });
- }
- const addSuccess = () => {
- tableRef.value.refreshTable()
- }
- defineProps<Props>();
- </script>
- <style scoped lang="scss">
- @import "@/uni.scss";
- .avatar {
- width: px2rpx(60);
- height: px2rpx(60);
- border-radius: 4px;
- }
- .content-title {
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: px2rpx(20);
- font-weight: 500;
- .content-title-btns {
- margin: px2rpx(8) 0;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- //flex-wrap: wrap;
- gap: px2rpx(10);
- .btn-primary {
- min-width: px2rpx(80);
- background-color: var(--color-error);
- color: white;
- padding: 0 px2rpx(10);
- border: none;
- font-size: px2rpx(14);
- text-align: center;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: px2rpx(5);
- }
- .btn-primary:active {
- background-color: #cf1322;
- ;
- }
- }
- }
- .operation-btn {
- :deep(span) {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: px2rpx(4);
- cursor: pointer;
- background-color: var(--bs-danger);
- color: #fff;
- padding: px2rpx(8) 0;
- }
- }
- .operation-btn.disabled {
- cursor: not-allowed;
- opacity: 0.8;
- }
- </style>
|