refactor(shopExpressTemplate): 优化运费模板及明细功能界面和数据结构

- 规范和补充ShopExpressTemplate及ShopExpressTemplateDetail接口字段注释
- 调整列表列配置,增加字段宽度和排序支持,优化表格显示
- 添加计费方式和状态的标签显示,替换原有文字提示
- 删除批量移动功能相关代码和UI,简化操作流程
- 搜索组件添加清除按钮,支持批量删除操作提升用户体验
- 编辑弹窗宽度调整,表单控件换为数字输入或单选框提升输入准确性
- 编辑弹窗中新增运费模板下拉选择和表单验证,确保数据完整性
- 移除无用变量和注释,清理代码结构,提高维护性
- 优化时间显示为日期格式,界面更友好
This commit is contained in:
2026-07-07 14:24:45 +08:00
parent d87d542e2e
commit b0193cf4c8
8 changed files with 439 additions and 351 deletions

View File

@@ -4,33 +4,35 @@ import type { PageParam } from '@/api';
* 运费模板 * 运费模板
*/ */
export interface ShopExpressTemplate { export interface ShopExpressTemplate {
// /** 主键ID */
shopExpressTemplateId?: number;
/** 旧字段ID兼容 */
id?: number; id?: number;
// /** 计费方式: 0=按件, 1=按重量 */
type?: string; type?: string;
// /** 模板名称 */
title?: string; title?: string;
// 收件价格 /** 首件价格 */
firstAmount?: string; firstAmount?: string;
// 续件价格 /** 续件价格 */
extraAmount?: string; extraAmount?: string;
// 状态, 0已发布, 1待审核 2已驳回 3违规内容 /** 状态: 0=启用, 1=禁用 */
status?: number; status?: number;
// 是否删除, 0否, 1 /** 是否删除: 0=否, 1=是 */
deleted?: number; deleted?: number;
// 租户id /** 租户ID */
tenantId?: number; tenantId?: number;
// 创建时间 /** 创建时间 */
createTime?: string; createTime?: string;
// 修改时间 /** 修改时间 */
updateTime?: string; updateTime?: string;
// 排序 /** 排序号 */
sortNumber?: number; sortNumber?: number;
// 备注 /** 备注 */
comments?: string; comments?: string;
// 首件数量/重量 /** 首件数量/重量 */
firstNum?: string; firstNum?: string;
// 续件数量/重量 /** 续件数量/重量 */
extraNum?: string; extraNum?: string;
} }
@@ -39,5 +41,11 @@ export interface ShopExpressTemplate {
*/ */
export interface ShopExpressTemplateParam extends PageParam { export interface ShopExpressTemplateParam extends PageParam {
id?: number; id?: number;
/** 模板名称 */
title?: string;
/** 计费方式 */
type?: string;
/** 状态 */
status?: number;
keywords?: string; keywords?: string;
} }

View File

@@ -1,45 +1,53 @@
import type { PageParam } from '@/api'; import type { PageParam } from '@/api';
/** /**
* 运费模板 * 运费模板明细(区域运费设置)
*/ */
export interface ShopExpressTemplateDetail { export interface ShopExpressTemplateDetail {
// /** 主键ID */
shopExpressTemplateDetailId?: number;
/** 旧字段ID兼容 */
id?: number; id?: number;
// /** 所属运费模板ID */
templateId?: number; templateId?: number;
// 0按件 /** 计费方式: 0=按件, 1=按重量 */
type?: string; type?: string;
// /** 省份ID */
provinceId?: number; provinceId?: number;
// /** 城市ID */
cityId?: number; cityId?: number;
// 首件数量/重量 /** 首件数量/重量 */
firstNum?: string; firstNum?: string;
// 收件价格 /** 首件价格 */
firstAmount?: string; firstAmount?: string;
// 续件价格 /** 续件价格 */
extraAmount?: string; extraAmount?: string;
// 续件数量/重量 /** 续件数量/重量 */
extraNum?: string; extraNum?: string;
// 状态, 0已发布, 1待审核 2已驳回 3违规内容 /** 状态: 0=启用, 1=禁用 */
status?: number; status?: number;
// 是否删除, 0否, 1 /** 是否删除: 0=否, 1=是 */
deleted?: number; deleted?: number;
// 租户id /** 租户ID */
tenantId?: number; tenantId?: number;
// 创建时间 /** 创建时间 */
createTime?: string; createTime?: string;
// 修改时间 /** 修改时间 */
updateTime?: string; updateTime?: string;
// /** 排序号 */
sortNumber?: number; sortNumber?: number;
} }
/** /**
* 运费模板搜索条件 * 运费模板明细搜索条件
*/ */
export interface ShopExpressTemplateDetailParam extends PageParam { export interface ShopExpressTemplateDetailParam extends PageParam {
id?: number; id?: number;
/** 所属运费模板ID */
templateId?: number;
/** 计费方式 */
type?: string;
/** 状态 */
status?: number;
keywords?: string; keywords?: string;
} }

View File

@@ -1,42 +1,68 @@
<!-- 搜索表单 --> <!-- 搜索表单 -->
<template> <template>
<a-space :size="10" style="flex-wrap: wrap"> <a-space :size="10" style="flex-wrap: wrap">
<a-input-search
allow-clear
placeholder="请输入模板名称"
v-model:value="keywords"
style="width: 220px"
@search="onSearch"
/>
<a-button type="primary" class="ele-btn-icon" @click="add"> <a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon> <template #icon>
<PlusOutlined /> <PlusOutlined />
</template> </template>
<span>添加</span> <span>添加</span>
</a-button> </a-button>
<a-button
danger
type="primary"
class="ele-btn-icon"
:disabled="!selection?.length"
@click="remove"
>
<template #icon>
<DeleteOutlined />
</template>
<span>批量删除</span>
</a-button>
</a-space> </a-space>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue'; import { ref } from 'vue';
import type { GradeParam } from '@/api/user/grade/model'; import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
import { watch } from 'vue'; import type { ShopExpressTemplateParam } from '@/api/shop/shopExpressTemplate/model';
import type { ShopExpressTemplate } from '@/api/shop/shopExpressTemplate/model';
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
// 选中的角色 // 选中的表格数据
selection?: []; selection?: ShopExpressTemplate[];
}>(), }>(),
{} {}
); );
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'search', where?: GradeParam): void; (e: 'search', where?: ShopExpressTemplateParam): void;
(e: 'add'): void; (e: 'add'): void;
(e: 'remove'): void; (e: 'remove'): void;
(e: 'batchMove'): void;
}>(); }>();
const keywords = ref('');
// 搜索
const onSearch = () => {
emit('search', { title: keywords.value });
};
// 新增 // 新增
const add = () => { const add = () => {
emit('add'); emit('add');
}; };
watch( // 批量删除
() => props.selection, const remove = () => {
() => {} emit('remove');
); };
</script> </script>

View File

@@ -1,10 +1,11 @@
<!-- 编辑弹窗 --> <!-- 编辑弹窗 -->
<template> <template>
<ele-modal <ele-modal
:width="800" :width="680"
:visible="visible" :visible="visible"
:maskClosable="false" :maskClosable="false"
:maxable="maxable" :maxable="maxable"
:confirm-loading="loading"
:title="isUpdate ? '编辑运费模板' : '添加运费模板'" :title="isUpdate ? '编辑运费模板' : '添加运费模板'"
:body-style="{ paddingBottom: '28px' }" :body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible" @update:visible="updateVisible"
@@ -19,50 +20,63 @@
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' } styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
" "
> >
<a-form-item label="" name="type"> <a-form-item label="模板名称" name="title">
<a-input allow-clear placeholder="请输入" v-model:value="form.type" />
</a-form-item>
<a-form-item label="" name="title">
<a-input allow-clear placeholder="请输入" v-model:value="form.title" />
</a-form-item>
<a-form-item label="收件价格" name="firstAmount">
<a-input <a-input
allow-clear allow-clear
placeholder="请输入收件价格" placeholder="请输入模板名称"
v-model:value="form.title"
:maxlength="50"
/>
</a-form-item>
<a-form-item label="计费方式" name="type">
<a-radio-group v-model:value="form.type">
<a-radio value="0">按件</a-radio>
<a-radio value="1">按重量</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="首件数量/重量" name="firstNum">
<a-input-number
:min="0"
:precision="2"
class="ele-fluid"
placeholder="请输入首件数量/重量"
v-model:value="form.firstNum"
/>
</a-form-item>
<a-form-item label="首件价格" name="firstAmount">
<a-input-number
:min="0"
:precision="2"
class="ele-fluid"
placeholder="请输入首件价格"
v-model:value="form.firstAmount" v-model:value="form.firstAmount"
/> />
</a-form-item> </a-form-item>
<a-form-item label="续件数量/重量" name="extraNum">
<a-input-number
:min="0"
:precision="2"
class="ele-fluid"
placeholder="请输入续件数量/重量"
v-model:value="form.extraNum"
/>
</a-form-item>
<a-form-item label="续件价格" name="extraAmount"> <a-form-item label="续件价格" name="extraAmount">
<a-input <a-input-number
allow-clear :min="0"
:precision="2"
class="ele-fluid"
placeholder="请输入续件价格" placeholder="请输入续件价格"
v-model:value="form.extraAmount" v-model:value="form.extraAmount"
/> />
</a-form-item> </a-form-item>
<a-form-item <a-form-item label="状态" name="status">
label="状态, 0已发布, 1待审核 2已驳回 3违规内容"
name="status"
>
<a-radio-group v-model:value="form.status"> <a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio> <a-radio :value="0">启用</a-radio>
<a-radio :value="1">隐藏</a-radio> <a-radio :value="1">禁用</a-radio>
</a-radio-group> </a-radio-group>
</a-form-item> </a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted"> <a-form-item label="排序号" name="sortNumber">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
<a-form-item label="" name="sortNumber">
<a-input-number <a-input-number
:min="0" :min="0"
:max="9999" :max="9999"
@@ -71,18 +85,13 @@
v-model:value="form.sortNumber" v-model:value="form.sortNumber"
/> />
</a-form-item> </a-form-item>
<a-form-item label="首件数量/重量" name="firstNum"> <a-form-item label="备注" name="comments">
<a-input <a-textarea
allow-clear allow-clear
placeholder="请输入首件数量/重量" placeholder="请输入备注"
v-model:value="form.firstNum" v-model:value="form.comments"
/> :rows="2"
</a-form-item> :maxlength="200"
<a-form-item label="续件数量/重量" name="extraNum">
<a-input
allow-clear
placeholder="请输入续件数量/重量"
v-model:value="form.extraNum"
/> />
</a-form-item> </a-form-item>
</a-form> </a-form>
@@ -92,7 +101,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive, watch } from 'vue'; import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue'; import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro'; import { assignObject } from 'ele-admin-pro';
import { import {
addShopExpressTemplate, addShopExpressTemplate,
updateShopExpressTemplate updateShopExpressTemplate
@@ -100,9 +109,7 @@
import { ShopExpressTemplate } from '@/api/shop/shopExpressTemplate/model'; import { ShopExpressTemplate } from '@/api/shop/shopExpressTemplate/model';
import { useThemeStore } from '@/store/modules/theme'; import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form'; import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改 // 是否是修改
const isUpdate = ref(false); const isUpdate = ref(false);
@@ -127,18 +134,18 @@
const loading = ref(false); const loading = ref(false);
// 是否显示最大化切换按钮 // 是否显示最大化切换按钮
const maxable = ref(true); const maxable = ref(true);
// 表格选中数据 // 表单实例
const formRef = ref<FormInstance | null>(null); const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息 // 表单数据
const form = reactive<ShopExpressTemplate>({ const form = reactive<ShopExpressTemplate>({
shopExpressTemplateId: undefined,
id: undefined, id: undefined,
type: undefined, type: '0',
title: undefined, title: undefined,
firstAmount: undefined, firstAmount: undefined,
extraAmount: undefined, extraAmount: undefined,
deleted: undefined, deleted: 0,
tenantId: undefined, tenantId: undefined,
createTime: undefined, createTime: undefined,
updateTime: undefined, updateTime: undefined,
@@ -156,30 +163,51 @@
// 表单验证规则 // 表单验证规则
const rules = reactive({ const rules = reactive({
shopExpressTemplateName: [ title: [
{ {
required: true, required: true,
type: 'string', type: 'string',
message: '请填写运费模板名称', message: '请填写模板名称',
trigger: 'blur'
}
],
type: [
{
required: true,
message: '请选择计费方式',
trigger: 'change'
}
],
firstNum: [
{
required: true,
message: '请输入首件数量/重量',
trigger: 'blur'
}
],
firstAmount: [
{
required: true,
message: '请输入首件价格',
trigger: 'blur'
}
],
extraNum: [
{
required: true,
message: '请输入续件数量/重量',
trigger: 'blur'
}
],
extraAmount: [
{
required: true,
message: '请输入续件价格',
trigger: 'blur' trigger: 'blur'
} }
] ]
}); });
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules); const { resetFields } = useForm(form, rules);
/* 保存编辑 */ /* 保存编辑 */
@@ -191,9 +219,7 @@
.validate() .validate()
.then(() => { .then(() => {
loading.value = true; loading.value = true;
const formData = { const formData = { ...form };
...form
};
const saveOrUpdate = isUpdate.value const saveOrUpdate = isUpdate.value
? updateShopExpressTemplate ? updateShopExpressTemplate
: addShopExpressTemplate; : addShopExpressTemplate;
@@ -216,16 +242,8 @@
() => props.visible, () => props.visible,
(visible) => { (visible) => {
if (visible) { if (visible) {
images.value = [];
if (props.data) { if (props.data) {
assignObject(form, props.data); assignObject(form, props.data);
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
});
}
isUpdate.value = true; isUpdate.value = true;
} else { } else {
isUpdate.value = false; isUpdate.value = false;

View File

@@ -7,6 +7,7 @@
:columns="columns" :columns="columns"
:datasource="datasource" :datasource="datasource"
:customRow="customRow" :customRow="customRow"
:selection="selection"
tool-class="ele-toolbar-form" tool-class="ele-toolbar-form"
class="sys-org-table" class="sys-org-table"
> >
@@ -16,16 +17,17 @@
:selection="selection" :selection="selection"
@add="openEdit" @add="openEdit"
@remove="removeBatch" @remove="removeBatch"
@batchMove="openMove"
/> />
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'"> <template v-if="column.key === 'type'">
<a-image :src="record.image" :width="50" /> <a-tag v-if="record.type === '0'" color="blue">按件</a-tag>
<a-tag v-else-if="record.type === '1'" color="cyan">按重量</a-tag>
<span v-else>{{ record.type }}</span>
</template> </template>
<template v-if="column.key === 'status'"> <template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag> <a-tag v-if="record.status === 0" color="green">启用</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag> <a-tag v-else color="red">禁用</a-tag>
</template> </template>
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<a-space> <a-space>
@@ -84,10 +86,6 @@
const current = ref<ShopExpressTemplate | null>(null); const current = ref<ShopExpressTemplate | null>(null);
// 是否显示编辑弹窗 // 是否显示编辑弹窗
const showEdit = ref(false); const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源 // 表格数据源
const datasource: DatasourceFunction = ({ const datasource: DatasourceFunction = ({
@@ -111,85 +109,76 @@
// 表格列配置 // 表格列配置
const columns = ref<ColumnItem[]>([ const columns = ref<ColumnItem[]>([
{ {
title: '', title: '模板名称',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90
},
{
title: '',
dataIndex: 'type',
key: 'type',
align: 'center'
},
{
title: '',
dataIndex: 'title', dataIndex: 'title',
key: 'title', key: 'title',
align: 'center' align: 'center',
ellipsis: true
}, },
{ {
title: '收件价格', title: '计费方式',
dataIndex: 'type',
key: 'type',
align: 'center',
width: 100
},
{
title: '首件数量/重量',
dataIndex: 'firstNum',
key: 'firstNum',
align: 'center',
width: 120
},
{
title: '首件价格',
dataIndex: 'firstAmount', dataIndex: 'firstAmount',
key: 'firstAmount', key: 'firstAmount',
align: 'center' align: 'center',
width: 100
},
{
title: '续件数量/重量',
dataIndex: 'extraNum',
key: 'extraNum',
align: 'center',
width: 120
}, },
{ {
title: '续件价格', title: '续件价格',
dataIndex: 'extraAmount', dataIndex: 'extraAmount',
key: 'extraAmount', key: 'extraAmount',
align: 'center' align: 'center',
width: 100
}, },
{ {
title: '状态, 0已发布, 1待审核 2已驳回 3违规内容', title: '状态',
dataIndex: 'status', dataIndex: 'status',
key: 'status', key: 'status',
align: 'center' align: 'center',
width: 80
}, },
{ {
title: '是否删除, 0否, 1是', title: '排序',
dataIndex: 'deleted', dataIndex: 'sortNumber',
key: 'deleted', key: 'sortNumber',
align: 'center' align: 'center',
width: 80,
sorter: true
}, },
{ {
title: '创建时间', title: '创建时间',
dataIndex: 'createTime', dataIndex: 'createTime',
key: 'createTime', key: 'createTime',
align: 'center', align: 'center',
width: 120,
sorter: true, sorter: true,
ellipsis: true, ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd') customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
}, },
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center'
},
{
title: '',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center'
},
{
title: '首件数量/重量',
dataIndex: 'firstNum',
key: 'firstNum',
align: 'center'
},
{
title: '续件数量/重量',
dataIndex: 'extraNum',
key: 'extraNum',
align: 'center'
},
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 180, width: 140,
fixed: 'right', fixed: 'right',
align: 'center', align: 'center',
hideInSetting: true hideInSetting: true
@@ -208,11 +197,6 @@
showEdit.value = true; showEdit.value = true;
}; };
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */ /* 删除单个 */
const remove = (row: ShopExpressTemplate) => { const remove = (row: ShopExpressTemplate) => {
const hide = message.loading('请求中..', 0); const hide = message.loading('请求中..', 0);
@@ -257,25 +241,14 @@
}); });
}; };
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */ /* 自定义行属性 */
const customRow = (record: ShopExpressTemplate) => { const customRow = (record: ShopExpressTemplate) => {
return { return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => { onDblclick: () => {
openEdit(record); openEdit(record);
} }
}; };
}; };
query();
</script> </script>
<script lang="ts"> <script lang="ts">

View File

@@ -1,42 +1,72 @@
<!-- 搜索表单 --> <!-- 搜索表单 -->
<template> <template>
<a-space :size="10" style="flex-wrap: wrap"> <a-space :size="10" style="flex-wrap: wrap">
<a-input-search
allow-clear
placeholder="请输入模板ID"
v-model:value="keywords"
style="width: 220px"
@search="onSearch"
/>
<a-button type="primary" class="ele-btn-icon" @click="add"> <a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon> <template #icon>
<PlusOutlined /> <PlusOutlined />
</template> </template>
<span>添加</span> <span>添加</span>
</a-button> </a-button>
<a-button
danger
type="primary"
class="ele-btn-icon"
:disabled="!selection?.length"
@click="remove"
>
<template #icon>
<DeleteOutlined />
</template>
<span>批量删除</span>
</a-button>
</a-space> </a-space>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue'; import { ref } from 'vue';
import type { GradeParam } from '@/api/user/grade/model'; import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
import { watch } from 'vue'; import type { ShopExpressTemplateDetailParam } from '@/api/shop/shopExpressTemplateDetail/model';
import type { ShopExpressTemplateDetail } from '@/api/shop/shopExpressTemplateDetail/model';
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
// 选中的角色 // 选中的表格数据
selection?: []; selection?: ShopExpressTemplateDetail[];
}>(), }>(),
{} {}
); );
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'search', where?: GradeParam): void; (e: 'search', where?: ShopExpressTemplateDetailParam): void;
(e: 'add'): void; (e: 'add'): void;
(e: 'remove'): void; (e: 'remove'): void;
(e: 'batchMove'): void;
}>(); }>();
const keywords = ref('');
// 搜索
const onSearch = () => {
const where: ShopExpressTemplateDetailParam = {};
if (keywords.value) {
where.templateId = Number(keywords.value);
}
emit('search', where);
};
// 新增 // 新增
const add = () => { const add = () => {
emit('add'); emit('add');
}; };
watch( // 批量删除
() => props.selection, const remove = () => {
() => {} emit('remove');
); };
</script> </script>

View File

@@ -1,11 +1,12 @@
<!-- 编辑弹窗 --> <!-- 编辑弹窗 -->
<template> <template>
<ele-modal <ele-modal
:width="800" :width="680"
:visible="visible" :visible="visible"
:maskClosable="false" :maskClosable="false"
:maxable="maxable" :maxable="maxable"
:title="isUpdate ? '编辑运费模板' : '添加运费模板'" :confirm-loading="loading"
:title="isUpdate ? '编辑运费模板明细' : '添加运费模板明细'"
:body-style="{ paddingBottom: '28px' }" :body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible" @update:visible="updateVisible"
@ok="save" @ok="save"
@@ -19,82 +20,80 @@
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' } styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
" "
> >
<a-form-item label="" name="templateId"> <a-form-item label="所属模板" name="templateId">
<a-input <a-select
allow-clear allow-clear
placeholder="请输入" placeholder="请选择所属运费模板"
v-model:value="form.templateId" v-model:value="form.templateId"
:options="templateOptions"
:field-names="{ label: 'title', value: 'shopExpressTemplateId' }"
/> />
</a-form-item> </a-form-item>
<a-form-item label="0按件" name="type"> <a-form-item label="计费方式" name="type">
<a-input <a-radio-group v-model:value="form.type">
allow-clear <a-radio value="0">按件</a-radio>
placeholder="请输入0按件" <a-radio value="1">按重量</a-radio>
v-model:value="form.type" </a-radio-group>
/>
</a-form-item> </a-form-item>
<a-form-item label="" name="provinceId"> <a-form-item label="省份ID" name="provinceId">
<a-input <a-input-number
allow-clear :min="0"
placeholder="请输入" class="ele-fluid"
placeholder="请输入省份ID"
v-model:value="form.provinceId" v-model:value="form.provinceId"
/> />
</a-form-item> </a-form-item>
<a-form-item label="" name="cityId"> <a-form-item label="城市ID" name="cityId">
<a-input allow-clear placeholder="请输入" v-model:value="form.cityId" /> <a-input-number
:min="0"
class="ele-fluid"
placeholder="请输入城市ID"
v-model:value="form.cityId"
/>
</a-form-item> </a-form-item>
<a-form-item label="首件数量/重量" name="firstNum"> <a-form-item label="首件数量/重量" name="firstNum">
<a-input <a-input-number
allow-clear :min="0"
:precision="2"
class="ele-fluid"
placeholder="请输入首件数量/重量" placeholder="请输入首件数量/重量"
v-model:value="form.firstNum" v-model:value="form.firstNum"
/> />
</a-form-item> </a-form-item>
<a-form-item label="件价格" name="firstAmount"> <a-form-item label="件价格" name="firstAmount">
<a-input <a-input-number
allow-clear :min="0"
placeholder="请输入收件价格" :precision="2"
class="ele-fluid"
placeholder="请输入首件价格"
v-model:value="form.firstAmount" v-model:value="form.firstAmount"
/> />
</a-form-item> </a-form-item>
<a-form-item label="续件价格" name="extraAmount">
<a-input
allow-clear
placeholder="请输入续件价格"
v-model:value="form.extraAmount"
/>
</a-form-item>
<a-form-item label="续件数量/重量" name="extraNum"> <a-form-item label="续件数量/重量" name="extraNum">
<a-input <a-input-number
allow-clear :min="0"
:precision="2"
class="ele-fluid"
placeholder="请输入续件数量/重量" placeholder="请输入续件数量/重量"
v-model:value="form.extraNum" v-model:value="form.extraNum"
/> />
</a-form-item> </a-form-item>
<a-form-item <a-form-item label="续件价格" name="extraAmount">
label="状态, 0已发布, 1待审核 2已驳回 3违规内容" <a-input-number
name="status" :min="0"
> :precision="2"
class="ele-fluid"
placeholder="请输入续件价格"
v-model:value="form.extraAmount"
/>
</a-form-item>
<a-form-item label="状态" name="status">
<a-radio-group v-model:value="form.status"> <a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio> <a-radio :value="0">启用</a-radio>
<a-radio :value="1">隐藏</a-radio> <a-radio :value="1">禁用</a-radio>
</a-radio-group> </a-radio-group>
</a-form-item> </a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted"> <a-form-item label="排序号" name="sortNumber">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
<a-form-item label="" name="sortNumber">
<a-input-number <a-input-number
:min="0" :min="0"
:max="9999" :max="9999"
@@ -108,17 +107,20 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive, watch } from 'vue'; import { ref, reactive, watch, onMounted } from 'vue';
import { Form, message } from 'ant-design-vue'; import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro'; import { assignObject } from 'ele-admin-pro';
import { import {
addShopExpressTemplateDetail, addShopExpressTemplateDetail,
updateShopExpressTemplateDetail updateShopExpressTemplateDetail
} from '@/api/shop/shopExpressTemplateDetail'; } from '@/api/shop/shopExpressTemplateDetail';
import { ShopExpressTemplateDetail } from '@/api/shop/shopExpressTemplateDetail/model'; import { listShopExpressTemplate } from '@/api/shop/shopExpressTemplate';
import {
ShopExpressTemplateDetail
} from '@/api/shop/shopExpressTemplateDetail/model';
import type { ShopExpressTemplate } from '@/api/shop/shopExpressTemplate/model';
import { useThemeStore } from '@/store/modules/theme'; import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form'; import { FormInstance } from 'ant-design-vue/es/form';
// 是否是修改 // 是否是修改
@@ -144,22 +146,24 @@
const loading = ref(false); const loading = ref(false);
// 是否显示最大化切换按钮 // 是否显示最大化切换按钮
const maxable = ref(true); const maxable = ref(true);
// 表格选中数据 // 表单实例
const formRef = ref<FormInstance | null>(null); const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]); // 运费模板下拉选项
const templateOptions = ref<ShopExpressTemplate[]>([]);
// 用户信息 // 表单数据
const form = reactive<ShopExpressTemplateDetail>({ const form = reactive<ShopExpressTemplateDetail>({
shopExpressTemplateDetailId: undefined,
id: undefined, id: undefined,
templateId: undefined, templateId: undefined,
type: undefined, type: '0',
provinceId: undefined, provinceId: undefined,
cityId: undefined, cityId: undefined,
firstNum: undefined, firstNum: undefined,
firstAmount: undefined, firstAmount: undefined,
extraAmount: undefined, extraAmount: undefined,
extraNum: undefined, extraNum: undefined,
deleted: undefined, deleted: 0,
tenantId: undefined, tenantId: undefined,
createTime: undefined, createTime: undefined,
updateTime: undefined, updateTime: undefined,
@@ -174,11 +178,45 @@
// 表单验证规则 // 表单验证规则
const rules = reactive({ const rules = reactive({
shopExpressTemplateDetailName: [ templateId: [
{ {
required: true, required: true,
type: 'string', message: '请选择所属运费模板',
message: '请填写运费模板名称', trigger: 'change'
}
],
type: [
{
required: true,
message: '请选择计费方式',
trigger: 'change'
}
],
firstNum: [
{
required: true,
message: '请输入首件数量/重量',
trigger: 'blur'
}
],
firstAmount: [
{
required: true,
message: '请输入首件价格',
trigger: 'blur'
}
],
extraNum: [
{
required: true,
message: '请输入续件数量/重量',
trigger: 'blur'
}
],
extraAmount: [
{
required: true,
message: '请输入续件价格',
trigger: 'blur' trigger: 'blur'
} }
] ]
@@ -186,6 +224,17 @@
const { resetFields } = useForm(form, rules); const { resetFields } = useForm(form, rules);
/* 加载运费模板列表 */
const loadTemplates = () => {
listShopExpressTemplate()
.then((data) => {
templateOptions.value = data || [];
})
.catch(() => {
templateOptions.value = [];
});
};
/* 保存编辑 */ /* 保存编辑 */
const save = () => { const save = () => {
if (!formRef.value) { if (!formRef.value) {
@@ -195,9 +244,7 @@
.validate() .validate()
.then(() => { .then(() => {
loading.value = true; loading.value = true;
const formData = { const formData = { ...form };
...form
};
const saveOrUpdate = isUpdate.value const saveOrUpdate = isUpdate.value
? updateShopExpressTemplateDetail ? updateShopExpressTemplateDetail
: addShopExpressTemplateDetail; : addShopExpressTemplateDetail;
@@ -216,11 +263,14 @@
.catch(() => {}); .catch(() => {});
}; };
onMounted(() => {
loadTemplates();
});
watch( watch(
() => props.visible, () => props.visible,
(visible) => { (visible) => {
if (visible) { if (visible) {
images.value = [];
if (props.data) { if (props.data) {
assignObject(form, props.data); assignObject(form, props.data);
isUpdate.value = true; isUpdate.value = true;

View File

@@ -7,6 +7,7 @@
:columns="columns" :columns="columns"
:datasource="datasource" :datasource="datasource"
:customRow="customRow" :customRow="customRow"
:selection="selection"
tool-class="ele-toolbar-form" tool-class="ele-toolbar-form"
class="sys-org-table" class="sys-org-table"
> >
@@ -16,16 +17,17 @@
:selection="selection" :selection="selection"
@add="openEdit" @add="openEdit"
@remove="removeBatch" @remove="removeBatch"
@batchMove="openMove"
/> />
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'"> <template v-if="column.key === 'type'">
<a-image :src="record.image" :width="50" /> <a-tag v-if="record.type === '0'" color="blue">按件</a-tag>
<a-tag v-else-if="record.type === '1'" color="cyan">按重量</a-tag>
<span v-else>{{ record.type }}</span>
</template> </template>
<template v-if="column.key === 'status'"> <template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag> <a-tag v-if="record.status === 0" color="green">启用</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag> <a-tag v-else color="red">禁用</a-tag>
</template> </template>
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<a-space> <a-space>
@@ -84,10 +86,6 @@
const current = ref<ShopExpressTemplateDetail | null>(null); const current = ref<ShopExpressTemplateDetail | null>(null);
// 是否显示编辑弹窗 // 是否显示编辑弹窗
const showEdit = ref(false); const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源 // 表格数据源
const datasource: DatasourceFunction = ({ const datasource: DatasourceFunction = ({
@@ -111,97 +109,90 @@
// 表格列配置 // 表格列配置
const columns = ref<ColumnItem[]>([ const columns = ref<ColumnItem[]>([
{ {
title: '', title: '所属模板ID',
dataIndex: 'id', dataIndex: 'templateId',
key: 'id', key: 'templateId',
align: 'center',
width: 110
},
{
title: '计费方式',
dataIndex: 'type',
key: 'type',
align: 'center',
width: 100
},
{
title: '省份ID',
dataIndex: 'provinceId',
key: 'provinceId',
align: 'center', align: 'center',
width: 90 width: 90
}, },
{ {
title: '', title: '城市ID',
dataIndex: 'templateId',
key: 'templateId',
align: 'center'
},
{
title: '0按件',
dataIndex: 'type',
key: 'type',
align: 'center'
},
{
title: '',
dataIndex: 'provinceId',
key: 'provinceId',
align: 'center'
},
{
title: '',
dataIndex: 'cityId', dataIndex: 'cityId',
key: 'cityId', key: 'cityId',
align: 'center' align: 'center',
width: 90
}, },
{ {
title: '首件数量/重量', title: '首件数量/重量',
dataIndex: 'firstNum', dataIndex: 'firstNum',
key: 'firstNum', key: 'firstNum',
align: 'center' align: 'center',
width: 120
}, },
{ {
title: '件价格', title: '件价格',
dataIndex: 'firstAmount', dataIndex: 'firstAmount',
key: 'firstAmount', key: 'firstAmount',
align: 'center' align: 'center',
}, width: 100
{
title: '续件价格',
dataIndex: 'extraAmount',
key: 'extraAmount',
align: 'center'
}, },
{ {
title: '续件数量/重量', title: '续件数量/重量',
dataIndex: 'extraNum', dataIndex: 'extraNum',
key: 'extraNum', key: 'extraNum',
align: 'center' align: 'center',
width: 120
}, },
{ {
title: '状态, 0已发布, 1待审核 2已驳回 3违规内容', title: '续件价格',
dataIndex: 'extraAmount',
key: 'extraAmount',
align: 'center',
width: 100
},
{
title: '状态',
dataIndex: 'status', dataIndex: 'status',
key: 'status', key: 'status',
align: 'center' align: 'center',
width: 80
}, },
{ {
title: '是否删除, 0否, 1是', title: '排序',
dataIndex: 'deleted', dataIndex: 'sortNumber',
key: 'deleted', key: 'sortNumber',
align: 'center' align: 'center',
width: 80,
sorter: true
}, },
{ {
title: '创建时间', title: '创建时间',
dataIndex: 'createTime', dataIndex: 'createTime',
key: 'createTime', key: 'createTime',
align: 'center', align: 'center',
width: 120,
sorter: true, sorter: true,
ellipsis: true, ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd') customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
}, },
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center'
},
{
title: '',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center'
},
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 180, width: 140,
fixed: 'right', fixed: 'right',
align: 'center', align: 'center',
hideInSetting: true hideInSetting: true
@@ -220,11 +211,6 @@
showEdit.value = true; showEdit.value = true;
}; };
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */ /* 删除单个 */
const remove = (row: ShopExpressTemplateDetail) => { const remove = (row: ShopExpressTemplateDetail) => {
const hide = message.loading('请求中..', 0); const hide = message.loading('请求中..', 0);
@@ -269,25 +255,14 @@
}); });
}; };
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */ /* 自定义行属性 */
const customRow = (record: ShopExpressTemplateDetail) => { const customRow = (record: ShopExpressTemplateDetail) => {
return { return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => { onDblclick: () => {
openEdit(record); openEdit(record);
} }
}; };
}; };
query();
</script> </script>
<script lang="ts"> <script lang="ts">