From dd7bc95f533df161bdf9558987c09aaf5ebed3c5 Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 4 Apr 2026 23:41:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=A0=A1=E9=AA=8C=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/my_work/routers/apiPurchase.go | 45 ++++++++++--------- .../ops_vue_js/.workbuddy/expert-history.json | 13 +++++- .../.workbuddy/memory/2026-04-04.md | 6 +++ .../src/views/purchase/addorder.vue | 34 +++++++------- 4 files changed, 60 insertions(+), 38 deletions(-) diff --git a/backend/my_work/routers/apiPurchase.go b/backend/my_work/routers/apiPurchase.go index 9d3f3f7..d485edf 100644 --- a/backend/my_work/routers/apiPurchase.go +++ b/backend/my_work/routers/apiPurchase.go @@ -11,25 +11,23 @@ import ( ) type CostItem struct { - Cost int `json:"cost"` // 必须,非负 - CostT int `json:"costt"` // 必须,非负 - CurrencyType string `json:"currencytype"` // 必须 - Int int `json:"int"` // 必须 - Type string `json:"type"` // 必须 + Cost int `json:"cost"` // 费用 + CostT int `json:"costt"` // 总价 + CurrencyType string `json:"currencytype"` // 货币类型 + Int int `json:"int"` // 数量 + Type string `json:"type"` // 费用类型 } type From_purchase_addorder struct { - Costs []CostItem `json:"costs"` // 价格 - ExpressNumber string //快递单号 - Link string `json:"link"` // 可选 - Notes string //样式 - OrderStatus string `json:"order_status"` // - PartName string `json:"partname"` // 可选 - Photos []string `json:"photos"` // 可选 - Remark string `json:"remark"` // 可选 - Styles string `json:"styles"` // 可选 - Title string `json:"title"` // 必须 - TrackingNumber string `json:"tracking_number"` // 可选 - UpdateTime string `json:"update_time"` // 可选 + Costs []CostItem `json:"costs"` // 成本 + Link string `json:"link"` // 链接 + OrderStatus string `json:"order_status"` // 订单状态 + PartName string `json:"partname"` // 物件名称 + Photos []string `json:"photos"` // 图片备注 + Remark string `json:"remark"` // 备注 + Styles string `json:"styles"` // 样式备注 + Title string `json:"title"` // 标题 + TrackingNumber string `json:"tracking_number"` // 快递单号 + UpdateTime string `json:"update_time"` // 更新时间 } func ApiPurchase(r *gin.RouterGroup) { @@ -99,7 +97,8 @@ func ApiPurchase(r *gin.RouterGroup) { var jsondata From_purchase_addorder if err := mapstructure.Decode(data, &jsondata); err == nil { - //fmt.Println("转换后数据:\n", jsondata) + jsonStr, _ := json.MarshalIndent(jsondata, "", " ") + fmt.Println("转换后数据:\n", string(jsonStr)) //数据比较混乱 在这里校验 @@ -107,15 +106,19 @@ func ApiPurchase(r *gin.RouterGroup) { is_data_ok := true if jsondata.Title == "" { is_data_ok = false + + fmt.Println("err1") } //判断数量与价格是否为负数 for i := 0; i < len(jsondata.Costs); i++ { if jsondata.Costs[i].Cost <= 0 { is_data_ok = false + fmt.Println("err2") } if jsondata.Costs[i].Int <= 0 { is_data_ok = false + fmt.Println("err3") } } @@ -124,6 +127,7 @@ func ApiPurchase(r *gin.RouterGroup) { //判断字符串是否包含标点符号 if models.IsContainsSpecialChar(jsondata.Photos[i]) { is_data_ok = false + fmt.Println("err4") } } @@ -132,6 +136,7 @@ func ApiPurchase(r *gin.RouterGroup) { uptime, e := models.StringToTimePtr(jsondata.UpdateTime) if e != nil { is_data_ok = false + fmt.Println("err5") } if is_data_ok { @@ -164,7 +169,7 @@ func ApiPurchase(r *gin.RouterGroup) { } } else { - ReturnJson(ctx, "jsonErr", nil) + ReturnJson(ctx, "jsonErr_1", nil) } } else { @@ -175,7 +180,7 @@ func ApiPurchase(r *gin.RouterGroup) { ReturnJson(ctx, "userCookieError", nil) } - ReturnJson(ctx, "apiErr", nil) + //ReturnJson(ctx, "apiErr", nil) }) } diff --git a/frontend/ops_vue_js/.workbuddy/expert-history.json b/frontend/ops_vue_js/.workbuddy/expert-history.json index 0c24893..953c5e1 100644 --- a/frontend/ops_vue_js/.workbuddy/expert-history.json +++ b/frontend/ops_vue_js/.workbuddy/expert-history.json @@ -22,7 +22,18 @@ "usedAt": 1775242179615, "industryId": "all" } + ], + "8e3dae3f55ad43b4b3b604818204bc8c": [ + { + "expertId": "FrontendDeveloper", + "name": "Paul", + "profession": "前端开发工程师", + "avatarUrl": "https://acc-1258344699.cos.accelerate.myqcloud.com/workbuddy/experts/avatars/02-Engineering/FrontendDeveloper/FrontendDeveloper.png", + "promptUrl": "https://acc-1258344699.cos.accelerate.myqcloud.com/workbuddy/experts/experts/02-Engineering/FrontendDeveloper/FrontendDeveloper_zh.md", + "usedAt": 1775314940465, + "industryId": "all" + } ] }, - "lastUpdated": 1775242274077 + "lastUpdated": 1775314975133 } \ No newline at end of file diff --git a/frontend/ops_vue_js/.workbuddy/memory/2026-04-04.md b/frontend/ops_vue_js/.workbuddy/memory/2026-04-04.md index ff227fa..5338ac3 100644 --- a/frontend/ops_vue_js/.workbuddy/memory/2026-04-04.md +++ b/frontend/ops_vue_js/.workbuddy/memory/2026-04-04.md @@ -14,3 +14,9 @@ - 删除按钮、修改日程提交按钮 - `copyEvent` 和 `pastEvent` 的 toast 提示 - `"xxx的日程"` 占位文本暂保留(后续待动态注入用户名时再处理) + +## purchase/addorder 表单字段对齐后端 + +- 修正 `src/views/purchase/addorder.vue` 提交 payload 字段名,使其与后端 `From_purchase_addorder` 一致:`partname`、`styles`、`tracking_number`、`update_time`。 +- 同步修正对应表单控件绑定,避免物件名称、样式备注、更新时间、快递单号提交到错误字段。 + diff --git a/frontend/ops_vue_js/src/views/purchase/addorder.vue b/frontend/ops_vue_js/src/views/purchase/addorder.vue index ad46591..de97d51 100644 --- a/frontend/ops_vue_js/src/views/purchase/addorder.vue +++ b/frontend/ops_vue_js/src/views/purchase/addorder.vue @@ -37,24 +37,24 @@ const orderStatus = computed(() => ({ const costEntries = reactive([]) const newCost = reactive({ - type: '1', qty: 1, cost: 0, currencyType: '1', + type: '1', int: 1, cost: 0, currencyType: '1', }) const newCostTotal = computed(() => - parseFloat((newCost.qty * newCost.cost).toFixed(2)) + parseFloat((newCost.int * newCost.cost).toFixed(2)) ) function addCostEntry() { if (newCost.cost <= 0) return costEntries.push({ type: newCost.type, - qty: newCost.qty, + int: newCost.int, cost: newCost.cost, - cost_t: newCostTotal.value, - currency_type: newCost.currencyType, + costt: newCostTotal.value, + currencytype: newCost.currencyType, }) newCost.type = '1' - newCost.qty = 1 + newCost.int = 1 newCost.cost = 0 newCost.currencyType = '1' } @@ -73,11 +73,11 @@ const form = reactive({ remark: '', photos: [], link: '', - style_remarks: '', - notes: '', + partname: '', + styles: '', costs: [], tracking_number: '', - express_number: '', + updatetime: '', order_status: '1', }) @@ -97,7 +97,7 @@ async function handleSubmit() { form.costs = costEntries.map(h => ({ ...h, cost: Math.round(h.cost * 100), - cost_t: Math.round(h.cost_t * 100), + costt: Math.round(h.costt * 100), })) loading.value = true @@ -172,7 +172,7 @@ async function handleSubmit() {
- +
@@ -201,9 +201,9 @@ async function handleSubmit() { {{ costType[item.type] }} - {{ item.qty }} + {{ item.int }} {{ item.cost }} - {{ item.cost_t }} + {{ item.costt }} {{ currencyOptions[item.currency_type] }} @@ -224,7 +224,7 @@ async function handleSubmit() {
- +
@@ -255,12 +255,12 @@ async function handleSubmit() { - +