mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 01:49:19 +08:00
refactor: 全部改用vben模态框
This commit is contained in:
+35
-15
@@ -1,7 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { Button, message, Modal } from 'ant-design-vue';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import ProductFormModal from '#/views/shop/product/components/ProductFormModal.vue';
|
||||
import ProductSpecModal from '#/views/shop/product/components/ProductSpecModal.vue';
|
||||
@@ -25,6 +27,31 @@ interface Emits {
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[800px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
onConfirm() {
|
||||
handleSubmit();
|
||||
},
|
||||
});
|
||||
|
||||
// 监听 visible 变化
|
||||
watch(
|
||||
() => props.visible,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
modalApi.open();
|
||||
} else {
|
||||
modalApi.close();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const shopFormModalRef = ref();
|
||||
@@ -42,23 +69,23 @@ const currentCreatingSpec = ref<null | {
|
||||
// 处理提交
|
||||
function handleSubmit() {
|
||||
// 检查是否还有未创建的实体
|
||||
const { entitiesToCreate } = defineProps<Props>();
|
||||
|
||||
if (
|
||||
entitiesToCreate.shops.length > 0 ||
|
||||
entitiesToCreate.products.length > 0 ||
|
||||
entitiesToCreate.specs.length > 0
|
||||
props.entitiesToCreate.shops.length > 0 ||
|
||||
props.entitiesToCreate.products.length > 0 ||
|
||||
props.entitiesToCreate.specs.length > 0
|
||||
) {
|
||||
message.warning('请先创建所有缺失的实体');
|
||||
return;
|
||||
}
|
||||
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
}
|
||||
|
||||
// 处理取消
|
||||
function handleCancel() {
|
||||
emit('cancel');
|
||||
modalApi.close();
|
||||
}
|
||||
|
||||
// 打开店铺创建模态框
|
||||
@@ -149,14 +176,7 @@ function handleProductSpecCreated() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
:open="visible"
|
||||
title="创建缺失的实体"
|
||||
width="800px"
|
||||
:confirm-loading="loading"
|
||||
@ok="handleSubmit"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<Modal title="创建缺失的实体" :confirm-loading="loading">
|
||||
<div class="space-y-6">
|
||||
<!-- 店铺创建 -->
|
||||
<div
|
||||
|
||||
+21
-17
@@ -1,12 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Modal, Select } from 'ant-design-vue';
|
||||
import { Button, Select } from 'ant-design-vue';
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[1200px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
});
|
||||
|
||||
// 创建图标组件
|
||||
const InfoIcon = createIconifyIcon('lucide:info');
|
||||
const CheckIcon = createIconifyIcon('lucide:check');
|
||||
@@ -32,8 +43,6 @@ interface Emits {
|
||||
(e: 'cancel'): void;
|
||||
}
|
||||
|
||||
const visible = ref(false);
|
||||
|
||||
// 系统字段定义
|
||||
const systemFields: SystemField[] = [
|
||||
{
|
||||
@@ -147,18 +156,17 @@ const unmappedFieldsCount = computed(() => {
|
||||
watch(
|
||||
() => props.visible,
|
||||
(newVal) => {
|
||||
visible.value = newVal;
|
||||
if (newVal) {
|
||||
modalApi.open();
|
||||
// 初始化字段映射
|
||||
initializeFieldMappings();
|
||||
} else {
|
||||
modalApi.close();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(visible, (newVal) => {
|
||||
emit('update:visible', newVal);
|
||||
});
|
||||
|
||||
// 初始化字段映射
|
||||
const initializeFieldMappings = () => {
|
||||
const mappings: Record<string, string> = {};
|
||||
@@ -258,12 +266,14 @@ const handleConfirm = () => {
|
||||
}
|
||||
|
||||
emit('confirm', { ...fieldMappings.value });
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
// 处理取消
|
||||
const handleCancel = () => {
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
emit('update:visible', false);
|
||||
emit('cancel');
|
||||
};
|
||||
|
||||
@@ -274,13 +284,7 @@ const handleReset = () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
v-model:open="visible"
|
||||
title="字段匹配配置"
|
||||
width="1200px"
|
||||
:footer="null"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<Modal title="字段匹配配置" :footer="false">
|
||||
<div class="field-mapping-container">
|
||||
<!-- 说明信息 -->
|
||||
<div class="mb-4 rounded-lg border border-blue-200 bg-blue-50 p-3">
|
||||
|
||||
+22
-18
@@ -1,14 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, message, Modal } from 'ant-design-vue';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
defineOptions({ name: 'FileUploadModal' });
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[800px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
});
|
||||
|
||||
// 创建图标组件
|
||||
const UploadIcon = createIconifyIcon('lucide:upload');
|
||||
const CheckCircleIcon = createIconifyIcon('lucide:check-circle');
|
||||
@@ -26,7 +37,6 @@ interface Emits {
|
||||
}
|
||||
|
||||
// 响应式数据
|
||||
const visible = ref(false);
|
||||
const uploadedFile = ref<File | null>(null);
|
||||
const isDragOver = ref(false);
|
||||
const fileInputRef = ref<HTMLInputElement>();
|
||||
@@ -35,20 +45,18 @@ const fileInputRef = ref<HTMLInputElement>();
|
||||
watch(
|
||||
() => props.open,
|
||||
(newVal) => {
|
||||
visible.value = newVal;
|
||||
if (!newVal) {
|
||||
if (newVal) {
|
||||
modalApi.open();
|
||||
} else {
|
||||
modalApi.close();
|
||||
// 关闭时重置状态
|
||||
uploadedFile.value = null;
|
||||
isDragOver.value = false;
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// 监听visible变化,同步到父组件
|
||||
watch(visible, (newVal) => {
|
||||
emit('update:open', newVal);
|
||||
});
|
||||
|
||||
// 文件验证
|
||||
const validateFile = (file: File): boolean => {
|
||||
const isCSV = file.type === 'text/csv' || file.name.endsWith('.csv');
|
||||
@@ -125,14 +133,16 @@ const clearFile = () => {
|
||||
const handleConfirm = () => {
|
||||
if (uploadedFile.value) {
|
||||
emit('confirm', uploadedFile.value);
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
}
|
||||
};
|
||||
|
||||
// 取消
|
||||
const handleCancel = () => {
|
||||
emit('cancel');
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
};
|
||||
|
||||
// 格式化文件大小
|
||||
@@ -146,13 +156,7 @@ const formatFileSize = (bytes: number) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
v-model:open="visible"
|
||||
title="继续导入CSV文件"
|
||||
width="800px"
|
||||
:footer="null"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<Modal title="继续导入CSV文件" :footer="false">
|
||||
<div class="space-y-6">
|
||||
<!-- 文件拖拽上传区域 -->
|
||||
<div
|
||||
|
||||
+29
-23
@@ -1,14 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import type { MatchDetail } from '../services/EntityMatchingService';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Modal, Select } from 'ant-design-vue';
|
||||
import { Button, Select } from 'ant-design-vue';
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[600px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
});
|
||||
|
||||
// 创建图标组件
|
||||
const CheckIcon = createIconifyIcon('lucide:check');
|
||||
const XIcon = createIconifyIcon('lucide:x');
|
||||
@@ -30,22 +41,20 @@ interface Emits {
|
||||
|
||||
const selectedMatchId = ref<string>('');
|
||||
|
||||
// 计算属性用于双向绑定
|
||||
const visible = computed({
|
||||
get: () => props.visible,
|
||||
set: (value) => {
|
||||
emit('update:visible', value);
|
||||
},
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(newVal) => {
|
||||
if (newVal && props.matchDetail) {
|
||||
// 初始化选中的匹配项
|
||||
selectedMatchId.value = getCurrentMatchId() || '';
|
||||
if (newVal) {
|
||||
modalApi.open();
|
||||
if (props.matchDetail) {
|
||||
// 初始化选中的匹配项
|
||||
selectedMatchId.value = getCurrentMatchId() || '';
|
||||
}
|
||||
} else {
|
||||
modalApi.close();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const getStatusText = (status: string) => {
|
||||
@@ -228,7 +237,8 @@ const handleApplyMatch = () => {
|
||||
selectedMatchId.value,
|
||||
);
|
||||
}
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
// 处理应用到所有相同数据
|
||||
@@ -241,22 +251,18 @@ const handleApplyToAll = () => {
|
||||
selectedMatchId.value,
|
||||
);
|
||||
}
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
emit('update:visible', false);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
v-model:open="visible"
|
||||
:title="getModalTitle()"
|
||||
width="600px"
|
||||
:footer="null"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<Modal :title="getModalTitle()">
|
||||
<div v-if="matchDetail" class="space-y-4">
|
||||
<!-- 当前匹配状态 -->
|
||||
<div class="mb-4 flex items-center space-x-2">
|
||||
|
||||
@@ -14,7 +14,7 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
import { Button, message, Progress, Space } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { batchImportOrdersApi } from '#/api/ecommerce';
|
||||
import { batchImportOrdersApi } from '#/api/ecommerce/order';
|
||||
import FieldMappingModal from '#/views/ecommerce/data-import/components/FieldMappingModal.vue';
|
||||
|
||||
import EntityCreationModal from './components/EntityCreationModal.vue';
|
||||
|
||||
Reference in New Issue
Block a user