fix(internal/controllers/getController): 优化获取所有道路的逻辑

- 在获取所有道路的函数中,添加了对 roadName 的非空判断,确保只有在 roadName 不为空时才将其添加到查询参数中,提升了代码的健壮性。
- 更新了前端请求的 URL,从 "/get/product" 修改为 "get/all/road",确保正确获取道路信息。
This commit is contained in:
danial
2025-06-11 16:45:24 +08:00
parent a67f50d36e
commit c47c8bd611
2 changed files with 7 additions and 5 deletions

View File

@@ -426,7 +426,9 @@ func (c *GetController) GetRoad() {
func (c *GetController) GetAllRoad() {
roadName := strings.TrimSpace(c.GetString("roadName"))
params := make(map[string]string)
params["road_name__icontains"] = roadName
if roadName != "" {
params["road_name__icontains"] = roadName
}
roadDataJSON := new(datas.RoadDataJSON)
roadInfoList := road.GetAllRoad(params)

View File

@@ -394,7 +394,7 @@
//将上游通道供应商写入
function setSupplier() {
$.ajax({
url: "/get/product",
url: "get/all/road",
success: function (res) {
if (res.Code === 404) {
window.parent.location = "/login.html";
@@ -402,9 +402,9 @@
alert("没有获取到上游供应商数据");
} else {
let str = '<option value="' + "" + '">' + "请选择" + '</option>';
for (let key in res.ProductMap) {
let v = res.ProductMap[key];
str = str + '<option value="' + key + '">' + v + '</option>'
for (let i = 0; i < res.RoadInfoList.length; i++) {
let v = res.RoadInfoList[i];
str = str + '<option value="' + v.RoadUid + '">' + v.RoadName + '</option>'
}
$("#search-order-supplier-name").html(str);
}