mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 05:49:20 +08:00
fix: 修复前端若干类型报错
This commit is contained in:
+17
-8
@@ -14,9 +14,7 @@ import {
|
||||
deleteImportMappingApi,
|
||||
getImportMappingPageApi,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import {
|
||||
ImportMappingType,
|
||||
} from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
import { ImportMappingType } from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
|
||||
import ImportMappingFormModal from '../import-mapping/components/ImportMappingFormModal.vue';
|
||||
|
||||
@@ -30,7 +28,12 @@ const formModalRef = ref();
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', width: 80, title: '序号' },
|
||||
{ field: 'name', title: '模板名称', minWidth: 'auto', showOverflow: 'tooltip' },
|
||||
{
|
||||
field: 'name',
|
||||
title: '模板名称',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip',
|
||||
},
|
||||
{ field: 'type', title: '类型', width: 120, slots: { default: 'type' } },
|
||||
{
|
||||
title: '映射字段数',
|
||||
@@ -65,7 +68,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
filters: { type: ImportMappingType.ORDER },
|
||||
});
|
||||
return { items: result.records || [], total: result.total || 0 };
|
||||
} catch (error) {
|
||||
} catch {
|
||||
message.error('获取字段映射模板列表失败');
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
@@ -76,7 +79,11 @@ const gridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({ gridOptions, showSearchForm: false, tableTitle: '字段映射模板' });
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
tableTitle: '字段映射模板',
|
||||
});
|
||||
|
||||
function refresh() {
|
||||
gridApi?.reload();
|
||||
@@ -95,7 +102,7 @@ async function handleDelete(row: ImportMappingVO.ImportMappingInfoVO) {
|
||||
await deleteImportMappingApi(row.id);
|
||||
message.success('删除成功');
|
||||
refresh();
|
||||
} catch (error) {
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
}
|
||||
@@ -141,7 +148,9 @@ function getTypeName(type: ImportMappingType): string {
|
||||
<Tag color="blue">{{ getTypeName(row.type) }}</Tag>
|
||||
</template>
|
||||
|
||||
<template #mappingCount="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }">
|
||||
<template
|
||||
#mappingCount="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }"
|
||||
>
|
||||
<Tag color="green">{{ getMappingCount(row.mapping) }} 个字段</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
+44
-29
@@ -1,32 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import type { ImportFieldDefVO } from '#/api/ecommerce/import-field-def';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type { ImportMappingVO } from '#/api/ecommerce/import-mapping';
|
||||
import type { ImportMappingType } from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
Form,
|
||||
Input,
|
||||
message,
|
||||
Select,
|
||||
} from 'ant-design-vue';
|
||||
import { Form, Input, message, Select } from 'ant-design-vue';
|
||||
|
||||
import { getFieldDefsByTypeApi } from '#/api/ecommerce/import-field-def';
|
||||
import {
|
||||
createImportMappingApi,
|
||||
updateImportMappingApi,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import {
|
||||
getFieldDefsByTypeApi,
|
||||
} from '#/api/ecommerce/import-field-def';
|
||||
import { ImportMappingType as MappingTypeEnum } from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
|
||||
import {
|
||||
ImportMappingType as MappingTypeEnum,
|
||||
} from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
|
||||
defineOptions({ name: 'ImportMappingFormModal' });
|
||||
|
||||
// Props: 传入模板类型
|
||||
@@ -97,16 +88,17 @@ async function fetchOrderStatuses() {
|
||||
}
|
||||
|
||||
// 打开弹窗
|
||||
async function open(isNew: boolean, record?: ImportMappingVO.ImportMappingInfoVO) {
|
||||
async function open(
|
||||
isNew: boolean,
|
||||
record?: ImportMappingVO.ImportMappingInfoVO,
|
||||
) {
|
||||
isEdit.value = !isNew;
|
||||
editId.value = record?.id;
|
||||
modalApi.open();
|
||||
|
||||
if (props.type === MappingTypeEnum.ORDER_STATUS) {
|
||||
await fetchOrderStatuses();
|
||||
} else {
|
||||
await fetchFieldDefs();
|
||||
}
|
||||
await (props.type === MappingTypeEnum.ORDER_STATUS
|
||||
? fetchOrderStatuses()
|
||||
: fetchFieldDefs());
|
||||
|
||||
if (isNew) {
|
||||
// 新建:初始化空映射
|
||||
@@ -161,7 +153,9 @@ async function handleConfirm() {
|
||||
let mappingJson = '[]';
|
||||
if (props.type === MappingTypeEnum.ORDER_STATUS) {
|
||||
// 过滤掉未映射的
|
||||
const validMappings = statusMappings.value.filter((m) => m.mappedStatusId);
|
||||
const validMappings = statusMappings.value.filter(
|
||||
(m) => m.mappedStatusId,
|
||||
);
|
||||
mappingJson = JSON.stringify(validMappings);
|
||||
} else {
|
||||
const items: FieldMappingItem[] = fieldDefs.value
|
||||
@@ -205,7 +199,11 @@ defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :loading="loading" :title="isEdit ? '编辑映射模板' : '新建映射模板'" :confirm-text="isEdit ? '保存' : '创建'">
|
||||
<Modal
|
||||
:loading="loading"
|
||||
:title="isEdit ? '编辑映射模板' : '新建映射模板'"
|
||||
:confirm-text="isEdit ? '保存' : '创建'"
|
||||
>
|
||||
<Form :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
|
||||
<Form.Item label="模板名称" required>
|
||||
<Input
|
||||
@@ -217,14 +215,20 @@ defineExpose({ open });
|
||||
</Form.Item>
|
||||
|
||||
<!-- 订单状态映射编辑 -->
|
||||
<Form.Item v-if="type === MappingTypeEnum.ORDER_STATUS" label="状态映射" :wrapper-col="{ span: 20 }">
|
||||
<div class="max-h-[400px] overflow-y-auto space-y-2">
|
||||
<Form.Item
|
||||
v-if="type === MappingTypeEnum.ORDER_STATUS"
|
||||
label="状态映射"
|
||||
:wrapper-col="{ span: 20 }"
|
||||
>
|
||||
<div class="max-h-[400px] space-y-2 overflow-y-auto">
|
||||
<div
|
||||
v-for="(item, idx) in statusMappings"
|
||||
:key="idx"
|
||||
class="flex items-center space-x-2 rounded border p-2"
|
||||
>
|
||||
<span class="w-[200px] truncate text-gray-600">{{ item.csvStatus }}</span>
|
||||
<span class="w-[200px] truncate text-gray-600">{{
|
||||
item.csvStatus
|
||||
}}</span>
|
||||
<span class="text-gray-400">→</span>
|
||||
<Select
|
||||
v-model:value="item.mappedStatusId"
|
||||
@@ -232,10 +236,18 @@ defineExpose({ open });
|
||||
class="flex-1"
|
||||
show-search
|
||||
allow-clear
|
||||
:options="orderStatusList.map((s) => ({ label: s.statusName, value: s.id }))"
|
||||
:options="
|
||||
orderStatusList.map((s) => ({
|
||||
label: s.statusName,
|
||||
value: s.id,
|
||||
}))
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="statusMappings.length === 0" class="py-4 text-center text-gray-400">
|
||||
<div
|
||||
v-if="statusMappings.length === 0"
|
||||
class="py-4 text-center text-gray-400"
|
||||
>
|
||||
暂无映射数据
|
||||
</div>
|
||||
</div>
|
||||
@@ -243,12 +255,15 @@ defineExpose({ open });
|
||||
|
||||
<!-- 字段映射编辑(只读展示) -->
|
||||
<Form.Item v-else label="字段映射" :wrapper-col="{ span: 20 }">
|
||||
<div class="max-h-[400px] overflow-y-auto space-y-2">
|
||||
<div class="max-h-[400px] space-y-2 overflow-y-auto">
|
||||
<div
|
||||
v-for="field in fieldDefs"
|
||||
:key="field.id"
|
||||
class="flex items-center space-x-2 rounded border p-2"
|
||||
:class="{ 'border-red-200 bg-red-50': field.required && !fieldMappings[field.fieldName] }"
|
||||
:class="{
|
||||
'border-red-200 bg-red-50':
|
||||
field.required && !fieldMappings[field.fieldName],
|
||||
}"
|
||||
>
|
||||
<span class="w-[140px]">
|
||||
{{ field.fieldLabel }}
|
||||
|
||||
+17
-8
@@ -14,9 +14,7 @@ import {
|
||||
deleteImportMappingApi,
|
||||
getImportMappingPageApi,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import {
|
||||
ImportMappingType,
|
||||
} from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
import { ImportMappingType } from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
|
||||
import ImportMappingFormModal from '../import-mapping/components/ImportMappingFormModal.vue';
|
||||
|
||||
@@ -30,7 +28,12 @@ const formModalRef = ref();
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', width: 80, title: '序号' },
|
||||
{ field: 'name', title: '模板名称', minWidth: 'auto', showOverflow: 'tooltip' },
|
||||
{
|
||||
field: 'name',
|
||||
title: '模板名称',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip',
|
||||
},
|
||||
{ field: 'type', title: '类型', width: 120, slots: { default: 'type' } },
|
||||
{
|
||||
title: '映射状态数',
|
||||
@@ -65,7 +68,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
filters: { type: ImportMappingType.ORDER_STATUS },
|
||||
});
|
||||
return { items: result.records || [], total: result.total || 0 };
|
||||
} catch (error) {
|
||||
} catch {
|
||||
message.error('获取订单状态映射模板列表失败');
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
@@ -76,7 +79,11 @@ const gridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({ gridOptions, showSearchForm: false, tableTitle: '订单状态映射模板' });
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
tableTitle: '订单状态映射模板',
|
||||
});
|
||||
|
||||
function refresh() {
|
||||
gridApi?.reload();
|
||||
@@ -95,7 +102,7 @@ async function handleDelete(row: ImportMappingVO.ImportMappingInfoVO) {
|
||||
await deleteImportMappingApi(row.id);
|
||||
message.success('删除成功');
|
||||
refresh();
|
||||
} catch (error) {
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
}
|
||||
@@ -141,7 +148,9 @@ function getTypeName(type: ImportMappingType): string {
|
||||
<Tag color="orange">{{ getTypeName(row.type) }}</Tag>
|
||||
</template>
|
||||
|
||||
<template #mappingCount="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }">
|
||||
<template
|
||||
#mappingCount="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }"
|
||||
>
|
||||
<Tag color="green">{{ getMappingCount(row.mapping) }} 个状态</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user