fix:修改参数管理对接

This commit is contained in:
2026-01-08 10:49:10 +08:00
parent 1655d86f6b
commit 60f141a0a9
2 changed files with 630 additions and 79 deletions
+114 -30
View File
@@ -216,15 +216,23 @@
style="width: 100%" style="width: 100%"
:header-cell-style="{ background: '#fafafa', color: '#333', fontWeight: 600 }" :header-cell-style="{ background: '#fafafa', color: '#333', fontWeight: 600 }"
> >
<el-table-column prop="id" label="参数ID" width="100" /> <el-table-column prop="id" label="参数ID" width="80" />
<el-table-column prop="name" label="参数名称" min-width="150" /> <el-table-column prop="name" label="参数名称" min-width="120" />
<el-table-column prop="type" label="参数类型" width="120"> <el-table-column prop="type" label="参数类型" width="100">
<template #default="{ row }"> <template #default="{ row }">
<el-tag :type="getArgTypeTag(row.type)"> <el-tag :type="getArgTypeTag(row.type)">
{{ getArgTypeText(row.type) }} {{ getArgTypeText(row.type) }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="数值配置" min-width="180">
<template #default="{ row }">
<template v-if="row.type === 'number'">
<span class="number-config">步进: {{ row.step || '-' }} | 范围: {{ row.min ?? '-' }} ~ {{ row.max ?? '-' }}</span>
</template>
<span v-else class="text-muted">-</span>
</template>
</el-table-column>
<el-table-column label="操作" width="250" fixed="right"> <el-table-column label="操作" width="250" fixed="right">
<template #default="{ row }"> <template #default="{ row }">
<div class="action-buttons"> <div class="action-buttons">
@@ -248,7 +256,7 @@
ref="paramFormRef" ref="paramFormRef"
:model="paramForm" :model="paramForm"
:rules="paramRules" :rules="paramRules"
label-width="100px" label-width="120px"
> >
<el-form-item label="参数名称" prop="arg_name"> <el-form-item label="参数名称" prop="arg_name">
<el-input v-model="paramForm.arg_name" placeholder="请输入参数名称" /> <el-input v-model="paramForm.arg_name" placeholder="请输入参数名称" />
@@ -260,6 +268,19 @@
<el-radio label="select">选择</el-radio> <el-radio label="select">选择</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- number 类型参数的额外配置 -->
<template v-if="paramForm.arg_type === 'number'">
<el-divider content-position="left">数值参数配置</el-divider>
<el-form-item label="步进值" prop="arg_step">
<el-input-number v-model="paramForm.arg_step" :min="1" placeholder="步进值" style="width: 100%" />
</el-form-item>
<el-form-item label="最小值" prop="arg_min">
<el-input-number v-model="paramForm.arg_min" placeholder="最小值" style="width: 100%" />
</el-form-item>
<el-form-item label="最大值" prop="arg_max">
<el-input-number v-model="paramForm.arg_max" placeholder="最大值" style="width: 100%" />
</el-form-item>
</template>
</el-form> </el-form>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
@@ -289,15 +310,26 @@
style="width: 100%; margin-top: 20px" style="width: 100%; margin-top: 20px"
:header-cell-style="{ background: '#fafafa', color: '#333', fontWeight: 600 }" :header-cell-style="{ background: '#fafafa', color: '#333', fontWeight: 600 }"
> >
<el-table-column prop="id" label="值ID" width="100" /> <el-table-column prop="id" label="值ID" width="80" />
<el-table-column prop="name" label="值名称" min-width="150" /> <el-table-column prop="name" label="值名称" min-width="120" />
<el-table-column prop="value" label="值" min-width="150" /> <el-table-column label="值/范围" min-width="150">
<el-table-column label="价格" width="120">
<template #default="{ row }"> <template #default="{ row }">
¥{{ (row.price / 100).toFixed(2) }} <template v-if="currentParam?.type === 'select'">
{{ row.value || '-' }}
</template>
<template v-else-if="currentParam?.type === 'number'">
<el-tag size="small" type="info">{{ getRangeTypeText(row.rangeType) }} {{ row.range }}</el-tag>
</template>
<template v-else>{{ row.value || '-' }}</template>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="200" fixed="right"> <el-table-column prop="index" label="排序" width="80" />
<el-table-column label="价格" width="100">
<template #default="{ row }">
¥{{ row.price }}
</template>
</el-table-column>
<el-table-column label="操作" width="150" fixed="right">
<template #default="{ row }"> <template #default="{ row }">
<div class="action-buttons"> <div class="action-buttons">
<el-button type="primary" link @click="handleEditParamValue(row)">编辑</el-button> <el-button type="primary" link @click="handleEditParamValue(row)">编辑</el-button>
@@ -312,23 +344,41 @@
<el-dialog <el-dialog
v-model="paramValueFormDialogVisible" v-model="paramValueFormDialogVisible"
:title="paramValueFormType === 'add' ? '添加参数值' : '编辑参数值'" :title="paramValueFormType === 'add' ? '添加参数值' : '编辑参数值'"
width="500px" width="550px"
append-to-body append-to-body
> >
<el-form <el-form
ref="paramValueFormRef" ref="paramValueFormRef"
:model="paramValueForm" :model="paramValueForm"
:rules="paramValueRules" :rules="paramValueRules"
label-width="100px" label-width="120px"
> >
<el-form-item label="值名称" prop="attr_name"> <el-form-item label="值名称" prop="attr_name">
<el-input v-model="paramValueForm.attr_name" placeholder="请输入值名称" /> <el-input v-model="paramValueForm.attr_name" placeholder="请输入值名称" />
</el-form-item> </el-form-item>
<el-form-item label="值" prop="attr_value"> <!-- select 类型显示参数值 -->
<el-input v-model="paramValueForm.attr_value" placeholder="请输入值" /> <el-form-item v-if="currentParam?.type === 'select'" label="参数值" prop="attr_value">
<el-input v-model="paramValueForm.attr_value" placeholder="请输入参数值" />
</el-form-item> </el-form-item>
<el-form-item label="价格(元)" prop="attr_price"> <!-- number 类型显示范围配置 -->
<el-input-number v-model="paramValueForm.attr_price" :min="0" :precision="2" :step="0.01" placeholder="请输入价格" style="width: 100%" /> <template v-if="currentParam?.type === 'number'">
<el-divider content-position="left">数值范围配置</el-divider>
<el-form-item label="范围类型" prop="range_type">
<el-select v-model="paramValueForm.range_type" placeholder="请选择范围类型" style="width: 100%">
<el-option label="大于 (after)" value="after" />
<el-option label="小于 (before)" value="before" />
<el-option label="等于 (equal)" value="equal" />
</el-select>
</el-form-item>
<el-form-item label="范围值" prop="attr_range">
<el-input-number v-model="paramValueForm.attr_range" placeholder="范围值" style="width: 100%" />
</el-form-item>
</template>
<el-form-item label="排序索引" prop="index">
<el-input-number v-model="paramValueForm.index" :min="0" placeholder="排序索引" style="width: 100%" />
</el-form-item>
<el-form-item label="价格" prop="attr_price">
<el-input-number v-model="paramValueForm.attr_price" :min="0" placeholder="请输入价格" style="width: 100%" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
@@ -686,7 +736,10 @@ const paramFormRef = ref(null)
const paramForm = reactive({ const paramForm = reactive({
arg_id: undefined, arg_id: undefined,
arg_name: '', arg_name: '',
arg_type: 'string' arg_type: 'string',
arg_step: 1,
arg_min: 0,
arg_max: 100
}) })
const paramRules = { const paramRules = {
@@ -713,9 +766,7 @@ const paramValueForm = reactive({
}) })
const paramValueRules = { const paramValueRules = {
attr_name: [{ required: true, message: '请输入值名称', trigger: 'blur' }], attr_name: [{ required: true, message: '请输入值名称', trigger: 'blur' }]
attr_value: [{ required: true, message: '请输入值', trigger: 'blur' }],
attr_price: [{ required: true, message: '请输入价格', trigger: 'blur' }]
} }
// 打开参数管理 // 打开参数管理
@@ -752,6 +803,12 @@ const getArgTypeTag = (type) => {
return tagMap[type] || 'info' return tagMap[type] || 'info'
} }
// 范围类型显示
const getRangeTypeText = (type) => {
const typeMap = { 'after': '大于 >', 'before': '小于 <', 'equal': '等于 =' }
return typeMap[type] || type || '-'
}
// 新增参数 // 新增参数
const handleAddParameter = () => { const handleAddParameter = () => {
paramFormType.value = 'add' paramFormType.value = 'add'
@@ -759,7 +816,10 @@ const handleAddParameter = () => {
Object.assign(paramForm, { Object.assign(paramForm, {
arg_id: undefined, arg_id: undefined,
arg_name: '', arg_name: '',
arg_type: 'string' arg_type: 'string',
arg_step: 1,
arg_min: 0,
arg_max: 100
}) })
paramFormRef.value?.resetFields() paramFormRef.value?.resetFields()
} }
@@ -771,7 +831,10 @@ const handleEditParameter = (row) => {
Object.assign(paramForm, { Object.assign(paramForm, {
arg_id: row.id, arg_id: row.id,
arg_name: row.name, arg_name: row.name,
arg_type: row.type arg_type: row.type,
arg_step: row.step || 1,
arg_min: row.min || 0,
arg_max: row.max || 100
}) })
} }
@@ -802,6 +865,12 @@ const submitParamForm = () => {
arg_name: paramForm.arg_name, arg_name: paramForm.arg_name,
arg_type: paramForm.arg_type arg_type: paramForm.arg_type
} }
// number 类型添加额外参数
if (paramForm.arg_type === 'number') {
submitData.arg_step = Number(paramForm.arg_step)
submitData.arg_min = Number(paramForm.arg_min)
submitData.arg_max = Number(paramForm.arg_max)
}
if (paramFormType.value === 'edit') { if (paramFormType.value === 'edit') {
submitData.arg_id = paramForm.arg_id submitData.arg_id = paramForm.arg_id
} }
@@ -871,11 +940,11 @@ const handleEditParamValue = (row) => {
Object.assign(paramValueForm, { Object.assign(paramValueForm, {
attr_id: row.id, attr_id: row.id,
attr_name: row.name, attr_name: row.name,
attr_value: row.value, attr_value: row.value || '',
attr_price: row.price / 100, attr_price: row.price || 0,
index: row.index || 0, index: row.index || 0,
attr_range: row.attr_range || 0, attr_range: row.range || 0,
range_type: row.range_type || 'equal' range_type: row.rangeType || 'equal'
}) })
} }
@@ -908,11 +977,17 @@ const submitParamValueForm = () => {
good_id: Number(currentProductId.value), good_id: Number(currentProductId.value),
arg_id: Number(currentParam.value.id), arg_id: Number(currentParam.value.id),
attr_name: paramValueForm.attr_name, attr_name: paramValueForm.attr_name,
attr_value: paramValueForm.attr_value,
attr_price: paramValueForm.attr_price,
index: Number(paramValueForm.index), index: Number(paramValueForm.index),
attr_range: Number(paramValueForm.attr_range), attr_price: Number(paramValueForm.attr_price)
range_type: paramValueForm.range_type }
// select 类型添加 attr_value
if (currentParam.value.type === 'select') {
submitData.attr_value = paramValueForm.attr_value
}
// number 类型添加范围参数
if (currentParam.value.type === 'number') {
submitData.attr_range = Number(paramValueForm.attr_range)
submitData.range_type = paramValueForm.range_type
} }
if (paramValueFormType.value === 'edit') { if (paramValueFormType.value === 'edit') {
submitData.attr_id = paramValueForm.attr_id submitData.attr_id = paramValueForm.attr_id
@@ -1080,5 +1155,14 @@ const submitParamValueForm = () => {
justify-content: flex-end; justify-content: flex-end;
gap: 12px; gap: 12px;
} }
.number-config {
color: #909399;
font-size: 13px;
}
.text-muted {
color: #c0c4cc;
}
</style> </style>
+516 -49
View File
@@ -7,62 +7,17 @@
}, },
"tags": [], "tags": [],
"paths": { "paths": {
"/api/v1/admin/order/list": { "/api/v1/admin/good/spec/list": {
"get": { "get": {
"summary": "获取订单列表", "summary": "获取商品参数列表",
"deprecated": false, "deprecated": false,
"description": "", "description": "",
"tags": [], "tags": [],
"parameters": [ "parameters": [
{ {
"name": "count", "name": "good_id",
"in": "query", "in": "query",
"description": "获取条数 默认 10", "description": "商品id",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "page",
"in": "query",
"description": "获取页码 默认 1",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "key",
"in": "query",
"description": "关键词筛选",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "state",
"in": "query",
"description": "状态筛选",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "user_id",
"in": "query",
"description": "用户id筛选",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "user_key",
"in": "query",
"description": "用户关键词筛选(用户名 手机号 邮箱)",
"required": false, "required": false,
"schema": { "schema": {
"type": "string" "type": "string"
@@ -95,6 +50,518 @@
}, },
"security": [] "security": []
} }
},
"/api/v1/admin/good/spec/create": {
"post": {
"summary": "创建商品参数",
"deprecated": false,
"description": "",
"tags": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"description": "",
"example": "Bearer {{token}}",
"schema": {
"type": "string",
"default": "Bearer {{token}}"
}
}
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"good_id": {
"description": "商品id",
"example": 0,
"type": "integer"
},
"arg_name": {
"description": "参数名称",
"example": "",
"type": "string"
},
"arg_type": {
"description": "参数类型 string | number | select",
"example": "",
"type": "string"
},
"arg_step": {
"description": "参数值步进值(number 类型参数)",
"example": 0,
"type": "integer"
},
"arg_max": {
"description": "参数值最大值(number 类型参数)",
"example": 0,
"type": "integer"
},
"arg_min": {
"description": "参数值最小值(number 类型参数)",
"example": 0,
"type": "integer"
}
}
}
}
}
},
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
},
"headers": {}
}
},
"security": []
}
},
"/api/v1/admin/good/spec/detail": {
"get": {
"summary": "获取商品参数详情",
"deprecated": false,
"description": "",
"tags": [],
"parameters": [
{
"name": "good_id",
"in": "query",
"description": "商品id",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "arg_id",
"in": "query",
"description": "参数id",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "Authorization",
"in": "header",
"description": "",
"example": "Bearer {{token}}",
"schema": {
"type": "string",
"default": "Bearer {{token}}"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
},
"headers": {}
}
},
"security": []
}
},
"/api/v1/admin/good/spec/update": {
"post": {
"summary": "更新商品参数",
"deprecated": false,
"description": "",
"tags": [],
"parameters": [
{
"name": "good_id",
"in": "query",
"description": "商品id",
"required": false,
"example": "",
"schema": {
"type": "string"
}
},
{
"name": "arg_id",
"in": "query",
"description": "参数id",
"required": false,
"example": "",
"schema": {
"type": "string"
}
},
{
"name": "arg_name",
"in": "query",
"description": "参数名称",
"required": false,
"example": "",
"schema": {
"type": "string"
}
},
{
"name": "arg_type",
"in": "query",
"description": "参数类型 string | number | select",
"required": false,
"example": "",
"schema": {
"type": "string"
}
},
{
"name": "arg_step",
"in": "query",
"description": "参数值步进值(number 类型参数)",
"required": false,
"example": 0,
"schema": {
"type": "integer"
}
},
{
"name": "arg_max",
"in": "query",
"description": "参数值最大值(number 类型参数)",
"required": false,
"example": 0,
"schema": {
"type": "integer"
}
},
{
"name": "arg_min",
"in": "query",
"description": "参数值最小值(number 类型参数)",
"required": false,
"example": 0,
"schema": {
"type": "integer"
}
},
{
"name": "Authorization",
"in": "header",
"description": "",
"example": "Bearer {{token}}",
"schema": {
"type": "string",
"default": "Bearer {{token}}"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
},
"headers": {}
}
},
"security": []
}
},
"/api/v1/admin/good/spec/delete": {
"delete": {
"summary": "删除商品参数",
"deprecated": false,
"description": "",
"tags": [],
"parameters": [
{
"name": "good_id",
"in": "query",
"description": "商品id",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "arg_id",
"in": "query",
"description": "参数id",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "Authorization",
"in": "header",
"description": "",
"example": "Bearer {{token}}",
"schema": {
"type": "string",
"default": "Bearer {{token}}"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
},
"headers": {}
}
},
"security": []
}
},
"/api/v1/admin/good/spec/add_value": {
"post": {
"summary": "增加商品参数值",
"deprecated": false,
"description": "",
"tags": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"description": "",
"example": "Bearer {{token}}",
"schema": {
"type": "string",
"default": "Bearer {{token}}"
}
}
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"good_id": {
"description": "商品id",
"example": 0,
"type": "integer"
},
"arg_id": {
"description": "参数id",
"example": 0,
"type": "integer"
},
"attr_name": {
"description": "值名称",
"example": "",
"type": "string"
},
"attr_value": {
"description": "参数值 (select 类型使用)",
"example": "",
"type": "string"
},
"index": {
"description": "商品参数排序索引",
"example": 0,
"type": "integer"
},
"attr_range": {
"description": "参数值范围 (number类型使用)",
"example": 0,
"type": "integer"
},
"range_type": {
"description": "参数值范围类型 after \\ before \\ equal (number类型使用)",
"example": "",
"type": "string"
},
"attr_price": {
"description": "价格",
"example": 0,
"type": "integer"
}
}
}
}
}
},
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
},
"headers": {}
}
},
"security": []
}
},
"/api/v1/admin/good/spec/delete_value": {
"delete": {
"summary": "删除商品参数值",
"deprecated": false,
"description": "",
"tags": [],
"parameters": [
{
"name": "good_id",
"in": "query",
"description": "商品id",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "attr_id",
"in": "query",
"description": "参数值id",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "Authorization",
"in": "header",
"description": "",
"example": "Bearer {{token}}",
"schema": {
"type": "string",
"default": "Bearer {{token}}"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
},
"headers": {}
}
},
"security": []
}
},
"/api/v1/admin/good/spec/update_value": {
"post": {
"summary": "更新商品参数值",
"deprecated": false,
"description": "",
"tags": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"description": "",
"example": "Bearer {{token}}",
"schema": {
"type": "string",
"default": "Bearer {{token}}"
}
}
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"good_id": {
"description": "商品id",
"example": 0,
"type": "integer"
},
"attr_id": {
"description": "参数值id",
"example": "",
"type": "string"
},
"attr_name": {
"description": "值名称",
"example": "",
"type": "string"
},
"attr_value": {
"description": "参数值 (select 类型使用)",
"example": "",
"type": "string"
},
"attr_range": {
"description": "参数值范围 (number类型使用)",
"example": 0,
"type": "integer"
},
"index": {
"description": "商品参数排序索引",
"example": 0,
"type": "integer"
},
"range_type": {
"description": "参数值范围类型 after \\ before \\ equal (number类型使用)",
"example": "",
"type": "string"
},
"attr_price": {
"description": "价格",
"example": 0,
"type": "integer"
}
}
}
}
}
},
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
},
"headers": {}
}
},
"security": []
}
} }
}, },
"components": { "components": {