日期校验有问题
This commit is contained in:
@@ -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)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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`。
|
||||
- 同步修正对应表单控件绑定,避免物件名称、样式备注、更新时间、快递单号提交到错误字段。
|
||||
|
||||
|
||||
@@ -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() {
|
||||
<div>
|
||||
<label class="mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300">{{ t('purchase_addorder.part_name') }}</label>
|
||||
<input
|
||||
v-model="form.style_remarks"
|
||||
v-model="form.partname"
|
||||
type="text"
|
||||
class="w-full rounded-lg border border-gray-300 bg-white px-3.5 py-2 text-sm outline-none transition-colors focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 dark:border-dk-muted dark:bg-dk-base dark:text-white"
|
||||
:placeholder="t('purchase_addorder.part_name')"
|
||||
@@ -180,7 +180,7 @@ async function handleSubmit() {
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300">{{ t('purchase_addorder.style_remarks') }}</label>
|
||||
<tagadder :placeholder="t('purchase_addorder.add_style')" v-model="form.notes" />
|
||||
<tagadder :placeholder="t('purchase_addorder.add_style')" v-model="form.styles" />
|
||||
</div>
|
||||
|
||||
<!-- costs table -->
|
||||
@@ -201,9 +201,9 @@ async function handleSubmit() {
|
||||
<tbody>
|
||||
<tr v-for="(item, idx) in costEntries" :key="idx" class="border-b border-gray-100 dark:border-dk-muted">
|
||||
<td class="px-3 py-2 font-medium text-gray-900 dark:text-white">{{ costType[item.type] }}</td>
|
||||
<td class="px-3 py-2 text-gray-500">{{ item.qty }}</td>
|
||||
<td class="px-3 py-2 text-gray-500">{{ item.int }}</td>
|
||||
<td class="px-3 py-2 text-gray-500">{{ item.cost }}</td>
|
||||
<td class="px-3 py-2 text-gray-500">{{ item.cost_t }}</td>
|
||||
<td class="px-3 py-2 text-gray-500">{{ item.costt }}</td>
|
||||
<td class="px-3 py-2 text-gray-500">{{ currencyOptions[item.currency_type] }}</td>
|
||||
<td class="px-3 py-2">
|
||||
<button class="rounded px-2 py-1 text-xs font-medium text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20" @click="removeCostEntry(idx)">{{ t('purchase_addorder.remove') }}</button>
|
||||
@@ -224,7 +224,7 @@ async function handleSubmit() {
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-medium text-gray-500">{{ t('purchase_addorder.input_quantity') }}</label>
|
||||
<input v-model.number="newCost.qty" type="number" class="w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm dark:border-dk-muted dark:bg-dk-base dark:text-white" min="1" />
|
||||
<input v-model.number="newCost.int" type="number" class="w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm dark:border-dk-muted dark:bg-dk-base dark:text-white" min="1" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-medium text-gray-500">{{ t('purchase_addorder.input_fee') }}</label>
|
||||
@@ -255,12 +255,12 @@ async function handleSubmit() {
|
||||
<label class="mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||
{{ t('purchase_addorder.update_time') }} <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<datePicker v-model="form.tracking_number" />
|
||||
<datePicker v-model="form.updatetime" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300">{{ t('purchase_addorder.tracking_number') }}</label>
|
||||
<input
|
||||
v-model="form.express_number"
|
||||
v-model="form.tracking_number"
|
||||
type="text"
|
||||
class="w-full rounded-lg border border-gray-300 bg-white px-3.5 py-2 text-sm outline-none transition-colors focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 dark:border-dk-muted dark:bg-dk-base dark:text-white"
|
||||
:placeholder="t('purchase_addorder.input_tracking_number')"
|
||||
|
||||
Reference in New Issue
Block a user