mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 05:09:21 +08:00
feat: 订单状态表新增颜色字段
- 新增 sql/ec_design.sql 表设计文档
- ec_order_status 表新增 color 字段
- 后端 PO/DTO/VO 同步新增 color 字段
- 前端表单支持颜色选择(预设12色+自定义输入)
- 前端列表页状态名称显示颜色标签
⚠️ 数据库需执行 ALTER TABLE 语句
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
-- =============================================
|
||||
-- 电商模块表结构设计
|
||||
-- =============================================
|
||||
|
||||
-- --------------------------------------------
|
||||
-- 订单状态表 ec_order_status
|
||||
-- --------------------------------------------
|
||||
DROP TABLE IF EXISTS `ec_order_status`;
|
||||
CREATE TABLE `ec_order_status` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单状态ID',
|
||||
`company_id` bigint NOT NULL COMMENT '公司ID',
|
||||
`status_name` varchar(50) NOT NULL COMMENT '状态名称(中文)',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '状态描述',
|
||||
`color` varchar(20) DEFAULT NULL COMMENT '状态颜色(十六进制,如 #1890ff)',
|
||||
`sort_order` int DEFAULT 0 COMMENT '排序',
|
||||
`auto_statistics` tinyint(1) DEFAULT 1 COMMENT '是否自动参与统计:0-不参与 1-参与',
|
||||
`is_refund` tinyint(1) DEFAULT 0 COMMENT '是否为退款状态:0-否 1-是',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_by` bigint DEFAULT NULL COMMENT '创建人ID',
|
||||
`update_by` bigint DEFAULT NULL COMMENT '更新人ID',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_company_id` (`company_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='电商-订单状态表';
|
||||
|
||||
-- 颜色字段变更 SQL(如已存在表则单独执行此语句)
|
||||
ALTER TABLE `ec_order_status` ADD COLUMN `color` varchar(20) DEFAULT NULL COMMENT '状态颜色(十六进制,如 #1890ff)' AFTER `description`;
|
||||
+6
@@ -25,6 +25,12 @@ public class CreateOrderStatusDTO {
|
||||
@Schema(description = "状态描述", example = "订单已创建,等待商家发货")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态颜色(十六进制,如 #1890ff)
|
||||
*/
|
||||
@Schema(description = "状态颜色", example = "#1890ff")
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
|
||||
+6
@@ -25,6 +25,12 @@ public class UpdateOrderStatusDTO {
|
||||
@Schema(description = "状态描述", example = "订单已创建,等待商家发货")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态颜色(十六进制,如 #1890ff)
|
||||
*/
|
||||
@Schema(description = "状态颜色", example = "#1890ff")
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
|
||||
+6
@@ -38,6 +38,12 @@ public class OrderStatusPO {
|
||||
@TableField("description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态颜色(十六进制,如 #1890ff)
|
||||
*/
|
||||
@TableField("color")
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
|
||||
+6
@@ -36,6 +36,12 @@ public class OrderStatusVO {
|
||||
@Schema(description = "状态描述", example = "订单已创建,等待商家发货")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态颜色(十六进制,如 #1890ff)
|
||||
*/
|
||||
@Schema(description = "状态颜色", example = "#1890ff")
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,8 @@ export namespace OrderStatusDTO {
|
||||
statusName: string;
|
||||
/** 状态描述 */
|
||||
description?: string;
|
||||
/** 状态颜色(十六进制,如 #1890ff) */
|
||||
color?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 自动统计 0不参与 1参与 */
|
||||
@@ -23,6 +25,8 @@ export namespace OrderStatusDTO {
|
||||
statusName: string;
|
||||
/** 状态描述 */
|
||||
description?: string;
|
||||
/** 状态颜色(十六进制,如 #1890ff) */
|
||||
color?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 自动统计 0不参与 1参与 */
|
||||
|
||||
@@ -13,6 +13,8 @@ export namespace OrderStatusVO {
|
||||
statusName: string;
|
||||
/** 状态描述 */
|
||||
description?: string;
|
||||
/** 状态颜色(十六进制,如 #1890ff) */
|
||||
color?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 自动统计 0不参与 1参与 */
|
||||
|
||||
+36
@@ -37,10 +37,18 @@ const loading = ref(false);
|
||||
const isEdit = ref(false);
|
||||
const currentRecord = ref<null | OrderStatusVO.Info>(null);
|
||||
|
||||
// 预设颜色列表
|
||||
const colorPresets = [
|
||||
'#1890ff', '#52c41a', '#faad14', '#f5222d',
|
||||
'#722ed1', '#13c2c2', '#eb2f96', '#fa8c16',
|
||||
'#a0d911', '#2f54eb', '#531dab', '#d9d9d9',
|
||||
];
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<Partial<OrderStatusDTO.Create>>({
|
||||
statusName: '',
|
||||
description: '',
|
||||
color: '',
|
||||
autoStatistics: 1,
|
||||
sortOrder: 0,
|
||||
isRefund: 0,
|
||||
@@ -67,6 +75,7 @@ function open(edit: boolean, record?: OrderStatusVO.Info) {
|
||||
? {
|
||||
statusName: record.statusName,
|
||||
description: record.description || '',
|
||||
color: record.color || '',
|
||||
autoStatistics: record.autoStatistics,
|
||||
sortOrder: record.sortOrder || 0,
|
||||
isRefund: record.isRefund || 0,
|
||||
@@ -74,6 +83,7 @@ function open(edit: boolean, record?: OrderStatusVO.Info) {
|
||||
: {
|
||||
statusName: '',
|
||||
description: '',
|
||||
color: '',
|
||||
autoStatistics: 1,
|
||||
sortOrder: 0,
|
||||
isRefund: 0,
|
||||
@@ -87,6 +97,11 @@ function close() {
|
||||
emit('cancel');
|
||||
}
|
||||
|
||||
// 选择颜色
|
||||
function selectColor(color: string) {
|
||||
formData.value.color = color;
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
@@ -98,6 +113,7 @@ async function handleSubmit() {
|
||||
const updateData: OrderStatusDTO.Update = {
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
color: formData.value.color,
|
||||
autoStatistics: formData.value.autoStatistics!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
isRefund: formData.value.isRefund,
|
||||
@@ -109,6 +125,7 @@ async function handleSubmit() {
|
||||
const createData: OrderStatusDTO.Create = {
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
color: formData.value.color,
|
||||
autoStatistics: formData.value.autoStatistics!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
isRefund: formData.value.isRefund,
|
||||
@@ -161,6 +178,25 @@ defineExpose({
|
||||
placeholder="请输入状态名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="状态颜色" name="color">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex gap-1 flex-wrap">
|
||||
<div
|
||||
v-for="c in colorPresets"
|
||||
:key="c"
|
||||
class="h-6 w-6 cursor-pointer rounded border-2 transition-transform hover:scale-110"
|
||||
:style="{ backgroundColor: c, borderColor: formData.color === c ? '#000' : 'transparent' }"
|
||||
@click="selectColor(c)"
|
||||
></div>
|
||||
</div>
|
||||
<Input
|
||||
v-model:value="formData.color"
|
||||
placeholder="#1890ff"
|
||||
class="!w-24"
|
||||
/>
|
||||
</div>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<Form.Item label="状态描述" name="description">
|
||||
|
||||
+13
-2
@@ -35,10 +35,9 @@ const gridOptions: VxeGridProps<any> = {
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
field: 'statusName',
|
||||
title: '状态名称',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
slots: { default: 'statusName' },
|
||||
},
|
||||
{
|
||||
field: 'description',
|
||||
@@ -207,6 +206,18 @@ function handleModalSuccess() {
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 状态名称列(带颜色) -->
|
||||
<template #statusName="{ row }: { row: OrderStatusVO.Info }">
|
||||
<Tag
|
||||
v-if="row.color"
|
||||
:color="row.color"
|
||||
class="font-bold"
|
||||
>
|
||||
{{ row.statusName }}
|
||||
</Tag>
|
||||
<span v-else>{{ row.statusName }}</span>
|
||||
</template>
|
||||
|
||||
<!-- 自动统计列 -->
|
||||
<template #autoStatistics="{ row }: { row: OrderStatusVO.Info }">
|
||||
<Tag :color="row.autoStatistics === 1 ? 'green' : 'default'">
|
||||
|
||||
Reference in New Issue
Block a user