| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- <template>
- <cwg-popup :title="form.title" :visible="visible" @close="onPopupClose" @confirm="submit" >
- <!-- <view class="dialog-container">-->
- <!-- <view class="dialog-header">-->
- <!-- <text class="dialog-title">{{ form.title }}</text>-->
- <!-- <view class="dialog-close" @click="close">-->
- <!-- <text>×</text>-->
- <!-- </view>-->
- <!-- </view>-->
- <uni-forms ref="formRef" :rules="rules" :model="form" labelWidth="200" label-position="top"
- class="crm-form">
- <uni-row class="form-row uni-row1">
- <template v-if="form.type === 1">
- <uni-col :xs="24" :offset="2">
- <uni-forms-item :label="t('PersonalManagement.Title.ProofOfIdentity') + 1">
- <cwg-file-picker-wrapper v-model="form.file1" :editable="editingId === form.id" :limit="1"
- uploadUrl="/custom/file/upload/1" :baseUrl="updateUrl" :imageWidth="150"
- :imageHeight="150" uploadText="点击上传" replaceText="点击替换" noImageText="暂无图片"
- :showPreviewDelete="editingId === form.id"
- @update:modelValue="(val) => handleFileUpdate(val, form, 'file1')" />
- </uni-forms-item>
- </uni-col>
- <uni-col :xs="24" :offset="2">
- <uni-forms-item :label="t('PersonalManagement.Title.ProofOfIdentity') + 2">
- <cwg-file-picker-wrapper v-model="form.file2" :editable="editingId === form.id" :limit="1"
- uploadUrl="/custom/file/upload/2" :baseUrl="updateUrl" :imageWidth="150"
- :imageHeight="150" uploadText="点击上传" replaceText="点击替换" noImageText="暂无图片"
- :showPreviewDelete="editingId === form.id"
- @update:modelValue="(val) => handleFileUpdate(val, form, 'file2')" />
- </uni-forms-item>
- </uni-col>
- </template>
- <template v-if="form.type === 2">
- <uni-col :xs="24" :offset="2">
- <uni-forms-item :label="t('PersonalManagement.Title.ProofOfAddress')">
- <cwg-file-picker-wrapper v-model="form.file3" :editable="editingId === form.id" :limit="1"
- uploadUrl="/custom/file/upload/3" :baseUrl="updateUrl" :imageWidth="150"
- :imageHeight="150" uploadText="点击上传" replaceText="点击替换" noImageText="暂无图片"
- :showPreviewDelete="editingId === form.id"
- @update:modelValue="(val) => handleFileUpdate(val, form, 'file3')" />
- </uni-forms-item>
- </uni-col>
- </template>
- <template v-if="form.type === 3">
- <uni-col :xs="24" :offset="2">
- <uni-forms-item :label="t('PersonalManagement.Title.AttachedFile')">
- <cwg-file-picker-wrapper v-model="form.file4" :editable="editingId === form.id" :limit="9"
- uploadUrl="/custom/file/upload/10" :baseUrl="updateUrl" :imageWidth="150"
- :imageHeight="150" uploadText="点击上传" replaceText="点击替换" noImageText="暂无图片"
- :showPreviewDelete="editingId === form.id"
- @update:modelValue="(val) => handleFileUpdate(val, form, 'file4')" />
- </uni-forms-item>
- </uni-col>
- </template>
- </uni-row>
- </uni-forms>
- <!-- <view class="dialog-footer">-->
- <!-- <view class="btn btn-cancel" @click="close">{{ t('Btn.Cancel') }}</view>-->
- <!-- <view class="btn btn-confirm" @click="submit">{{ t('Btn.Confirm') }}</view>-->
- <!-- </view>-->
- <!-- </view>-->
- </cwg-popup>
- </template>
- <script setup lang="ts">
- import { ref, nextTick, computed, onMounted } from 'vue';
- import { useI18n } from 'vue-i18n';
- import { Validators } from '@/utils/validators';
- import { personalApi } from '@/service/personal';
- const { t, locale } = useI18n();
- interface AddBankForm {
- addressName: string;
- address: string;
- checkboxGroup: string[];
- }
- const hobbys = computed(() => [
- { value: 1, text: t('blockchain.item8') }
- ]);
- const emit = defineEmits(["success"]);
- const fileRef = ref<any>(null);
- const formRef = ref<any>(null);
- const visible = ref(false);
- const form = ref<AddBankForm>({});
- const rules = {
- addressName: [Validators.required(t('blockchain.item3') + t('common.cannotbeempty'))],
- address: [Validators.required(t('blockchain.item4') + t('common.cannotbeempty'))]
- };
- // 打开弹窗
- const open = async (item) => {
- form.value = {}
- await nextTick();
- console.log(item, 23123);
- form.value = item;
- let files = []
- item?.tableData.forEach(file => {
- if (file.type === 1) {
- form.value.file1 = file.path
- } else if (file.type === 2) {
- form.value.file2 = file.path
- } else if (file.type === 3) {
- form.value.file3 = file.path
- } else if (file.type === 10) {
- files.push(file.path)
- }
- })
- getBankList()
- visible.value = true
- // fileRef.value?.open();
- };
- // 关闭弹窗
- const close = () => {
- visible.value = false
- };
- // 弹窗真正关闭后清空表单
- const onPopupClose = () => {
- resetForm();
- };
- // 重置表单
- const resetForm = () => {
- form.value = {};
- formRef.value?.clearValidate();
- };
- // 提交表单
- const submit = async () => {
- close();
- emit('success');
- };
- const bankList = ref([])
- const isZh = computed(() => ['cn', 'zh', 'zhHant'].includes(locale.value));
- const getLangName = (item: any) => (isZh.value ? item.name : item.enName);
- const createOptions = (list: any[], valueKey = 'code') => {
- return list.map((item) => ({
- text: getLangName(item),
- value: getLangName(item)
- }));
- };
- const bankOptions = computed(() => createOptions(bankList.value, 'name'));
- // 获取银行列表
- const getBankList = async () => {
- const res = await personalApi.BankList({})
- if (res.code === 200) {
- bankList.value = res.data
- }
- }
- // 文件更新处理
- const handleFileUpdate = (newValue, item, field) => {
- item[field] = newValue
- }
- // 暴露方法
- defineExpose({
- open,
- close
- });
- </script>
- <style scoped lang="scss">
- @import "@/uni.scss";
- .dialog-container {
- width: 80vw;
- max-width: px2rpx(800);
- max-height: 85vh;
- padding: px2rpx(24);
- overflow: hidden;
- border-radius: px2rpx(12);
- .dialog-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: px2rpx(24);
- padding-bottom: px2rpx(16);
- border-bottom: 1px solid #f3f4f6;
- .dialog-title {
- font-size: px2rpx(18);
- font-weight: 600;
- color: #1f2937;
- }
- .dialog-close {
- width: px2rpx(32);
- height: px2rpx(32);
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: px2rpx(28);
- color: #9ca3af;
- cursor: pointer;
- transition: all 0.3s;
- &:hover {
- color: #1f2937;
- }
- }
- }
- .dialog-footer {
- display: flex;
- gap: px2rpx(12);
- justify-content: space-around;
- padding: px2rpx(16) 0 0;
- border-top: 1px solid #f3f4f6;
- .btn {
- min-width: px2rpx(120);
- padding: px2rpx(12) px2rpx(24);
- border-radius: px2rpx(6);
- font-size: px2rpx(14);
- font-weight: 600;
- box-sizing: border-box;
- border: none;
- cursor: pointer;
- text-align: center;
- transition: all 0.3s;
- display: flex;
- align-items: center;
- justify-content: space-around;
- &.btn-cancel {
- background: #f3f4f6;
- color: #6b7280;
- &:hover {
- background: #e5e7eb;
- }
- &:active {
- background: #d1d5db;
- }
- }
- &.btn-confirm {
- background: #ea2027;
- color: var(--bs-emphasis-color);
- &:hover {
- background: #d11920;
- }
- &:active {
- background: #c01819;
- }
- }
- }
- }
- .crm-form {
- overflow-y: auto;
- max-height: 70vh;
- }
- }
- </style>
|