mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 01:09:19 +08:00
feat: 新增导入功能
This commit is contained in:
+293
-12
@@ -1,5 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { ImportFieldDefVO } from '#/api/ecommerce/import-field-def';
|
||||
import type {
|
||||
ImportMappingDTO,
|
||||
ImportMappingVO,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import type { ImportTaskDTO } from '#/api/ecommerce/import-task';
|
||||
import type { ShopVO } from '#/api/shop/shop/types';
|
||||
|
||||
@@ -7,12 +11,37 @@ import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, Form, message, Select, Spin, Steps } from 'ant-design-vue';
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
Input,
|
||||
message,
|
||||
Select,
|
||||
Spin,
|
||||
Steps,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { getFieldDefsByTypeApi } from '#/api/ecommerce/import-field-def';
|
||||
import {
|
||||
createImportMappingApi,
|
||||
getImportMappingPageApi,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import { createImportTaskApi } from '#/api/ecommerce/import-task';
|
||||
import { uploadFileApi } from '#/api/media/file';
|
||||
import { getShopPageApi } from '#/api/shop/shop';
|
||||
import { useImportTaskStore } from '#/store';
|
||||
|
||||
// 定义映射项数据结构
|
||||
interface FieldMappingItem {
|
||||
/** 数据库字段名 */
|
||||
fieldName: string;
|
||||
/** 中文字段名 */
|
||||
fieldLabel: string;
|
||||
/** 文件字段名(CSV列名) */
|
||||
fileFieldName?: string;
|
||||
/** 是否必填 */
|
||||
required: boolean;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'CreateImportTaskModal' });
|
||||
|
||||
@@ -54,9 +83,35 @@ const fieldMappings = ref<
|
||||
>
|
||||
>({});
|
||||
|
||||
// 映射模板相关
|
||||
const mappingTemplates = ref<ImportMappingVO.ImportMappingInfoVO[]>([]);
|
||||
const selectedTemplateId = ref<number | undefined>();
|
||||
const templateLoading = ref(false);
|
||||
const savingTemplate = ref(false);
|
||||
const templateName = ref('');
|
||||
|
||||
// 创建保存模板的 vben modal
|
||||
const [SaveTemplateModal, saveTemplateModalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[500px]',
|
||||
title: '保存映射模板',
|
||||
showCancelButton: true,
|
||||
showConfirmButton: true,
|
||||
confirmText: '保存',
|
||||
cancelText: '取消',
|
||||
onConfirm: handleConfirmSaveTemplate,
|
||||
onCancel() {
|
||||
templateName.value = '';
|
||||
saveTemplateModalApi.close();
|
||||
},
|
||||
});
|
||||
|
||||
// 表单引用
|
||||
const formRef = ref();
|
||||
|
||||
// 导入任务store
|
||||
const importTaskStore = useImportTaskStore();
|
||||
|
||||
// 计算属性:必填字段是否都已绑定
|
||||
const canGoToNextStep = computed(() => {
|
||||
if (currentStep.value === 0) {
|
||||
@@ -167,6 +222,153 @@ const fetchFieldDefs = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 获取映射模板列表
|
||||
const fetchMappingTemplates = async () => {
|
||||
try {
|
||||
templateLoading.value = true;
|
||||
const result = await getImportMappingPageApi({
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
filters: {
|
||||
type: 'order',
|
||||
},
|
||||
});
|
||||
mappingTemplates.value = result.records || [];
|
||||
} catch (error) {
|
||||
console.error('获取映射模板列表失败:', error);
|
||||
message.error('获取映射模板列表失败');
|
||||
} finally {
|
||||
templateLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 选择映射模板
|
||||
const handleSelectTemplate = async (value: any) => {
|
||||
const templateId = typeof value === 'number' ? value : undefined;
|
||||
if (!templateId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const template = mappingTemplates.value.find((t) => t.id === templateId);
|
||||
if (!template) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 解析模板的 mapping JSON
|
||||
const mappingItems: FieldMappingItem[] = JSON.parse(template.mapping);
|
||||
|
||||
// 根据模板填充字段映射
|
||||
const mappings: typeof fieldMappings.value = {};
|
||||
fieldDefs.value.forEach((fieldDef) => {
|
||||
const templateItem = mappingItems.find(
|
||||
(item) => item.fieldName === fieldDef.fieldName,
|
||||
);
|
||||
let mappedHeader: string | undefined;
|
||||
|
||||
if (templateItem?.fileFieldName) {
|
||||
// 检查 CSV 表头中是否存在该字段名
|
||||
const matched = csvHeaders.value.find(
|
||||
(header) => header === templateItem.fileFieldName,
|
||||
);
|
||||
if (matched) {
|
||||
mappedHeader = matched;
|
||||
}
|
||||
}
|
||||
|
||||
mappings[fieldDef.id] = {
|
||||
fieldDef,
|
||||
mappedHeader,
|
||||
};
|
||||
});
|
||||
|
||||
fieldMappings.value = mappings;
|
||||
message.success('已应用映射模板');
|
||||
} catch (error) {
|
||||
console.error('应用映射模板失败:', error);
|
||||
message.error('应用映射模板失败,模板格式可能不正确');
|
||||
}
|
||||
};
|
||||
|
||||
// 打开保存模板模态框
|
||||
const handleSaveTemplate = () => {
|
||||
// 验证是否有映射数据
|
||||
const mappingItems: FieldMappingItem[] = Object.values(fieldMappings.value)
|
||||
.filter((m) => m.mappedHeader)
|
||||
.map((m) => ({
|
||||
fieldName: m.fieldDef.fieldName,
|
||||
fieldLabel: m.fieldDef.fieldLabel,
|
||||
fileFieldName: m.mappedHeader,
|
||||
required: m.fieldDef.required,
|
||||
}));
|
||||
|
||||
if (mappingItems.length === 0) {
|
||||
message.warning('请先完成字段映射');
|
||||
return;
|
||||
}
|
||||
|
||||
templateName.value = '';
|
||||
saveTemplateModalApi.open();
|
||||
};
|
||||
|
||||
// 确认保存映射模板
|
||||
async function handleConfirmSaveTemplate() {
|
||||
if (!templateName.value.trim()) {
|
||||
message.warning('请输入模板名称');
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证必填字段是否都已绑定
|
||||
const requiredFields = fieldDefs.value.filter((f) => f.required);
|
||||
const unMappedFields = requiredFields.filter((field) => {
|
||||
const mapping = fieldMappings.value[field.id];
|
||||
return !mapping || !mapping.mappedHeader;
|
||||
});
|
||||
|
||||
if (unMappedFields.length > 0) {
|
||||
message.warning(
|
||||
`请先绑定所有必填字段:${unMappedFields.map((f) => f.fieldLabel).join('、')}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
savingTemplate.value = true;
|
||||
saveTemplateModalApi.lock();
|
||||
|
||||
// 构建映射数据
|
||||
const mappingItems: FieldMappingItem[] = Object.values(fieldMappings.value)
|
||||
.filter((m) => m.mappedHeader)
|
||||
.map((m) => ({
|
||||
fieldName: m.fieldDef.fieldName,
|
||||
fieldLabel: m.fieldDef.fieldLabel,
|
||||
fileFieldName: m.mappedHeader,
|
||||
required: m.fieldDef.required,
|
||||
}));
|
||||
|
||||
const createData: ImportMappingDTO.CreateImportMappingDTO = {
|
||||
type: 'order',
|
||||
name: templateName.value.trim(),
|
||||
mapping: JSON.stringify(mappingItems),
|
||||
};
|
||||
|
||||
await createImportMappingApi(createData);
|
||||
message.success('保存映射模板成功');
|
||||
templateName.value = '';
|
||||
saveTemplateModalApi.close();
|
||||
// 刷新模板列表
|
||||
await fetchMappingTemplates();
|
||||
// 清空选中的模板
|
||||
selectedTemplateId.value = undefined;
|
||||
} catch (error: any) {
|
||||
console.error('保存映射模板失败:', error);
|
||||
message.error(error?.message || '保存映射模板失败');
|
||||
} finally {
|
||||
savingTemplate.value = false;
|
||||
saveTemplateModalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// 下一步
|
||||
const handleNext = () => {
|
||||
if (currentStep.value === 0) {
|
||||
@@ -178,6 +380,10 @@ const handleNext = () => {
|
||||
if (fieldDefs.value.length === 0) {
|
||||
fetchFieldDefs();
|
||||
}
|
||||
// 加载映射模板列表
|
||||
if (mappingTemplates.value.length === 0) {
|
||||
fetchMappingTemplates();
|
||||
}
|
||||
} else if (currentStep.value === 1) {
|
||||
// 验证必填字段
|
||||
const requiredFields = fieldDefs.value.filter((f) => f.required);
|
||||
@@ -218,29 +424,56 @@ const handleCreateTask = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
|
||||
// 确保SSE连接已建立(如果还没有连接,先建立连接)
|
||||
if (!importTaskStore.sseConnection || !importTaskStore.sseConnected) {
|
||||
message.loading('正在建立连接...', 0);
|
||||
try {
|
||||
await importTaskStore.connectSse();
|
||||
message.destroy();
|
||||
} catch (error: any) {
|
||||
message.destroy();
|
||||
message.error(
|
||||
error?.message || '建立SSE连接失败,无法实时接收任务进度',
|
||||
);
|
||||
// 即使连接失败,也允许继续创建任务
|
||||
}
|
||||
}
|
||||
|
||||
// 先上传文件
|
||||
message.loading('正在上传文件...', 0);
|
||||
const fileInfo = await uploadFileApi(selectedFile.value);
|
||||
message.destroy();
|
||||
|
||||
// 构建字段映射 JSON
|
||||
const mapping: Record<string, string> = {};
|
||||
Object.values(fieldMappings.value).forEach((m) => {
|
||||
if (m.mappedHeader) {
|
||||
mapping[m.fieldDef.fieldName] = m.mappedHeader;
|
||||
}
|
||||
});
|
||||
// 构建字段映射 JSON(基于 ImportFieldDefInfoVO 结构)
|
||||
const mappingItems: FieldMappingItem[] = Object.values(fieldMappings.value)
|
||||
.filter((m) => m.mappedHeader)
|
||||
.map((m) => ({
|
||||
fieldName: m.fieldDef.fieldName,
|
||||
fieldLabel: m.fieldDef.fieldLabel,
|
||||
fileFieldName: m.mappedHeader,
|
||||
required: m.fieldDef.required,
|
||||
}));
|
||||
|
||||
const createData: ImportTaskDTO.CreateImportTaskDTO = {
|
||||
shopId: selectedShopId.value!,
|
||||
type: 'order',
|
||||
fileName: selectedFile.value.name,
|
||||
filePath: fileInfo.url,
|
||||
mapping: JSON.stringify(mapping),
|
||||
mapping: JSON.stringify(mappingItems),
|
||||
};
|
||||
|
||||
await createImportTaskApi(createData);
|
||||
const task = await createImportTaskApi(createData);
|
||||
message.success('创建导入任务成功');
|
||||
|
||||
// 更新store中的任务列表
|
||||
importTaskStore.updateTask(task);
|
||||
|
||||
// 刷新任务列表
|
||||
await importTaskStore.fetchTasks(true);
|
||||
|
||||
// 创建成功后,自动展开任务下拉菜单
|
||||
importTaskStore.openDropdown();
|
||||
|
||||
// 创建成功后,重置状态并关闭
|
||||
currentStep.value = 0;
|
||||
selectedShopId.value = undefined;
|
||||
@@ -354,8 +587,41 @@ const shopOptions = computed(() => {
|
||||
|
||||
<!-- 第二步:字段映射 -->
|
||||
<div v-if="currentStep === 1" class="py-4">
|
||||
<div class="mb-4 text-sm text-gray-600">
|
||||
请为每个订单字段选择对应的CSV列,必填字段必须绑定
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<div class="text-sm text-gray-600">
|
||||
请为每个订单字段选择对应的CSV列,必填字段必须绑定
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Select
|
||||
v-model:value="selectedTemplateId"
|
||||
placeholder="选择已有模板"
|
||||
class="w-[200px]"
|
||||
:loading="templateLoading"
|
||||
allow-clear
|
||||
@change="handleSelectTemplate"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="templateLoading" class="py-4 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-2">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-4 text-center text-gray-400">
|
||||
暂无模板
|
||||
</div>
|
||||
</template>
|
||||
<Select.Option
|
||||
v-for="template in mappingTemplates"
|
||||
:key="template.id"
|
||||
:value="template.id"
|
||||
>
|
||||
{{ template.name }}
|
||||
<span class="ml-2 text-xs text-gray-400">
|
||||
({{ new Date(template.createTime).toLocaleDateString() }})
|
||||
</span>
|
||||
</Select.Option>
|
||||
</Select>
|
||||
<Button @click="handleSaveTemplate">保存为模板</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="max-h-[400px] space-y-4 overflow-y-auto">
|
||||
<div
|
||||
@@ -452,6 +718,21 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 保存模板模态框 -->
|
||||
<SaveTemplateModal :confirm-loading="savingTemplate">
|
||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
||||
<Form.Item label="模板名称" required>
|
||||
<Input
|
||||
v-model:value="templateName"
|
||||
placeholder="请输入模板名称"
|
||||
:maxlength="50"
|
||||
show-count
|
||||
@press-enter="handleConfirmSaveTemplate"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</SaveTemplateModal>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -89,6 +89,14 @@ const handleManageSpecs = (product: ProductVO.Info) => {
|
||||
{{ product.name }}
|
||||
</div>
|
||||
|
||||
<!-- 商品编码 -->
|
||||
<div
|
||||
v-if="product.productCode"
|
||||
class="mb-2 text-xs text-gray-500 dark:text-gray-400"
|
||||
>
|
||||
编码: {{ product.productCode }}
|
||||
</div>
|
||||
|
||||
<!-- 规格信息预览 -->
|
||||
<div
|
||||
v-if="product.specs && product.specs.length > 0"
|
||||
|
||||
+22
-6
@@ -66,6 +66,7 @@ const imageLoadError = ref(false); // 图片加载错误状态
|
||||
// 表单数据
|
||||
const formData = ref({
|
||||
name: '',
|
||||
productCode: '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
mainImageId: undefined as number | undefined,
|
||||
@@ -93,6 +94,7 @@ function initFormData() {
|
||||
const productData = currentProductData.value as any;
|
||||
formData.value = {
|
||||
name: currentProductData.value.name || '',
|
||||
productCode: currentProductData.value.productCode || '',
|
||||
specCode: productData.specCode || '',
|
||||
skuCode: productData.skuCode || '',
|
||||
mainImageId: undefined,
|
||||
@@ -105,6 +107,7 @@ function initFormData() {
|
||||
// 创建模式 - 如果有传入的productData,则使用它来初始化表单
|
||||
formData.value = {
|
||||
name: currentProductData.value?.name || '',
|
||||
productCode: currentProductData.value?.productCode || '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
mainImageId: undefined,
|
||||
@@ -174,15 +177,21 @@ async function handleSubmit() {
|
||||
'id' in currentProductData.value &&
|
||||
currentProductData.value.id
|
||||
) {
|
||||
await updateProductApi(
|
||||
currentProductData.value.id,
|
||||
submitData as ProductDTO.Update,
|
||||
);
|
||||
const updateData: ProductDTO.Update = {
|
||||
name: submitData.name,
|
||||
productCode: submitData.productCode || undefined,
|
||||
specCode: submitData.specCode || undefined,
|
||||
skuCode: submitData.skuCode || undefined,
|
||||
mainImageId: submitData.mainImageId,
|
||||
costPrice: submitData.costPrice,
|
||||
};
|
||||
await updateProductApi(currentProductData.value.id, updateData);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
// 创建模式:统一使用创建接口,规格信息作为可选字段
|
||||
const createData: ProductDTO.Create = {
|
||||
name: submitData.name,
|
||||
productCode: submitData.productCode || undefined,
|
||||
mainImageId: submitData.mainImageId,
|
||||
...(specs.value.length > 0 && { specs: specs.value }),
|
||||
};
|
||||
@@ -512,8 +521,15 @@ onUnmounted(() => {
|
||||
<Input v-model:value="formData.name" placeholder="请输入商品名称" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item v-if="isEdit" label="商品编码" name="specCode">
|
||||
<Input v-model:value="formData.specCode" placeholder="请输入商品编码" />
|
||||
<Form.Item label="商品编码" name="productCode">
|
||||
<Input
|
||||
v-model:value="formData.productCode"
|
||||
placeholder="请输入商品编码"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item v-if="isEdit" label="规格编码" name="specCode">
|
||||
<Input v-model:value="formData.specCode" placeholder="请输入规格编码" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item v-if="isEdit" label="商品SKU" name="skuCode">
|
||||
|
||||
@@ -31,6 +31,7 @@ const productGridViewRef = ref<null | { refreshTable: () => void }>(null);
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
name: '',
|
||||
productCode: '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
minCostPrice: undefined as number | undefined,
|
||||
|
||||
+17
-1
@@ -30,6 +30,7 @@ const props = defineProps<{
|
||||
maxCostPrice?: number;
|
||||
minCostPrice?: number;
|
||||
name: string;
|
||||
productCode: string;
|
||||
skuCode: string;
|
||||
specCode: string;
|
||||
};
|
||||
@@ -54,6 +55,7 @@ const scrollContainerRef = ref<HTMLElement | null>(null);
|
||||
// 本地搜索表单副本(用于 v-model)
|
||||
const localSearchForm = ref({
|
||||
name: props.searchForm.name,
|
||||
productCode: props.searchForm.productCode,
|
||||
specCode: props.searchForm.specCode,
|
||||
skuCode: props.searchForm.skuCode,
|
||||
minCostPrice: props.searchForm.minCostPrice,
|
||||
@@ -66,12 +68,14 @@ watch(
|
||||
(newForm) => {
|
||||
if (
|
||||
localSearchForm.value.name !== newForm.name ||
|
||||
localSearchForm.value.productCode !== newForm.productCode ||
|
||||
localSearchForm.value.specCode !== newForm.specCode ||
|
||||
localSearchForm.value.skuCode !== newForm.skuCode ||
|
||||
localSearchForm.value.minCostPrice !== newForm.minCostPrice ||
|
||||
localSearchForm.value.maxCostPrice !== newForm.maxCostPrice
|
||||
) {
|
||||
localSearchForm.value.name = newForm.name;
|
||||
localSearchForm.value.productCode = newForm.productCode;
|
||||
localSearchForm.value.specCode = newForm.specCode;
|
||||
localSearchForm.value.skuCode = newForm.skuCode;
|
||||
localSearchForm.value.minCostPrice = newForm.minCostPrice;
|
||||
@@ -92,6 +96,7 @@ watch(
|
||||
(newForm) => {
|
||||
if (
|
||||
props.searchForm.name !== newForm.name ||
|
||||
props.searchForm.productCode !== newForm.productCode ||
|
||||
props.searchForm.specCode !== newForm.specCode ||
|
||||
props.searchForm.skuCode !== newForm.skuCode ||
|
||||
props.searchForm.minCostPrice !== newForm.minCostPrice ||
|
||||
@@ -114,6 +119,7 @@ const loadProductList = async (reset = false) => {
|
||||
pageSize: pageSize.value,
|
||||
filters: {
|
||||
name: localSearchForm.value.name || undefined,
|
||||
productCode: localSearchForm.value.productCode || undefined,
|
||||
specCode: localSearchForm.value.specCode || undefined,
|
||||
skuCode: localSearchForm.value.skuCode || undefined,
|
||||
minCostPrice: localSearchForm.value.minCostPrice,
|
||||
@@ -157,6 +163,7 @@ const handleSearch = () => {
|
||||
const handleReset = () => {
|
||||
localSearchForm.value = {
|
||||
name: '',
|
||||
productCode: '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
minCostPrice: undefined,
|
||||
@@ -235,13 +242,22 @@ onUnmounted(() => {
|
||||
</Form.Item>
|
||||
<Form.Item label="商品编码" class="mb-0">
|
||||
<Input
|
||||
v-model:value="localSearchForm.specCode"
|
||||
v-model:value="localSearchForm.productCode"
|
||||
placeholder="请输入商品编码"
|
||||
style="width: 150px"
|
||||
allow-clear
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="规格编码" class="mb-0">
|
||||
<Input
|
||||
v-model:value="localSearchForm.specCode"
|
||||
placeholder="请输入规格编码"
|
||||
style="width: 150px"
|
||||
allow-clear
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="商品SKU" class="mb-0">
|
||||
<Input
|
||||
v-model:value="localSearchForm.skuCode"
|
||||
|
||||
+21
-1
@@ -17,6 +17,7 @@ const props = defineProps<{
|
||||
maxCostPrice?: number;
|
||||
minCostPrice?: number;
|
||||
name: string;
|
||||
productCode: string;
|
||||
skuCode: string;
|
||||
specCode: string;
|
||||
};
|
||||
@@ -35,6 +36,7 @@ const loading = ref(false);
|
||||
// 本地搜索表单副本(用于 v-model)
|
||||
const localSearchForm = ref({
|
||||
name: props.searchForm.name,
|
||||
productCode: props.searchForm.productCode,
|
||||
specCode: props.searchForm.specCode,
|
||||
skuCode: props.searchForm.skuCode,
|
||||
minCostPrice: props.searchForm.minCostPrice,
|
||||
@@ -47,12 +49,14 @@ watch(
|
||||
(newForm) => {
|
||||
if (
|
||||
localSearchForm.value.name !== newForm.name ||
|
||||
localSearchForm.value.productCode !== newForm.productCode ||
|
||||
localSearchForm.value.specCode !== newForm.specCode ||
|
||||
localSearchForm.value.skuCode !== newForm.skuCode ||
|
||||
localSearchForm.value.minCostPrice !== newForm.minCostPrice ||
|
||||
localSearchForm.value.maxCostPrice !== newForm.maxCostPrice
|
||||
) {
|
||||
localSearchForm.value.name = newForm.name;
|
||||
localSearchForm.value.productCode = newForm.productCode;
|
||||
localSearchForm.value.specCode = newForm.specCode;
|
||||
localSearchForm.value.skuCode = newForm.skuCode;
|
||||
localSearchForm.value.minCostPrice = newForm.minCostPrice;
|
||||
@@ -69,6 +73,7 @@ watch(
|
||||
(newForm) => {
|
||||
if (
|
||||
props.searchForm.name !== newForm.name ||
|
||||
props.searchForm.productCode !== newForm.productCode ||
|
||||
props.searchForm.specCode !== newForm.specCode ||
|
||||
props.searchForm.skuCode !== newForm.skuCode ||
|
||||
props.searchForm.minCostPrice !== newForm.minCostPrice ||
|
||||
@@ -99,6 +104,12 @@ const gridOptions: VxeGridProps<any> = {
|
||||
minWidth: 200,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'productCode',
|
||||
title: '商品编码',
|
||||
minWidth: 150,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
title: '规格数量',
|
||||
minWidth: 100,
|
||||
@@ -166,6 +177,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
name: localSearchForm.value.name || undefined,
|
||||
productCode: localSearchForm.value.productCode || undefined,
|
||||
specCode: localSearchForm.value.specCode || undefined,
|
||||
skuCode: localSearchForm.value.skuCode || undefined,
|
||||
minCostPrice: localSearchForm.value.minCostPrice,
|
||||
@@ -208,9 +220,17 @@ const formOptions = computed(() => ({
|
||||
componentProps: {
|
||||
placeholder: '请输入商品编码',
|
||||
},
|
||||
fieldName: 'specCode',
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入规格编码',
|
||||
},
|
||||
fieldName: 'specCode',
|
||||
label: '规格编码',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
|
||||
Reference in New Issue
Block a user