xuhy
2025-08-21 4bd9e1b8ac5fbc790be40bd033dcc0ac95051e15
经停站点
4个文件已修改
216 ■■■■■ 已修改文件
ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TLineController.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementOKTravel/guns-admin/src/main/webapp/WEB-INF/view/system/tLine/tLine_add.html 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementOKTravel/guns-admin/src/main/webapp/WEB-INF/view/system/tLine/tLine_edit.html 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementOKTravel/guns-admin/src/main/webapp/static/modular/system/tLine/tLine_info.js 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TLineController.java
@@ -115,6 +115,8 @@
        model.addAttribute("start",start);
        TLineSite end = itLineSiteService.selectOne(new EntityWrapper<TLineSite>().eq("lineId", tLineId).eq("type", 2));
        model.addAttribute("end",end);
        List<TLineSite> stopoverList = itLineSiteService.selectList(new EntityWrapper<TLineSite>().eq("lineId", tLineId).eq("type", 3));
        model.addAttribute("stopoverList",stopoverList);
        //站点
        List<TSite> siteList = itSiteService.selectList(new EntityWrapper<TSite>().eq("state", 1));
        model.addAttribute("siteList",siteList);
@@ -157,7 +159,10 @@
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public ResultUtil add(TLine tLine,Integer startSiteId,Integer endSiteId,@RequestParam String subArr,@RequestParam String shuArr) {
    public ResultUtil add(TLine tLine,Integer startSiteId,Integer endSiteId,
                          @RequestParam String subArr,
                          @RequestParam String shuArr,
                          @RequestParam String stopoverValues) {
        String name = tLine.getName();
        name = name.replaceAll("& lt;", "<");
        name = name.replaceAll("& gt;", ">");
@@ -180,6 +185,18 @@
        end.setSiteId(endSiteId);
        end.setType(2);
        itLineSiteService.insert(end);
        // 添加经停站
        List<TLineSite> stopoverList = new ArrayList<>();
        JSONArray jsonArray = JSON.parseArray(stopoverValues);
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            TLineSite stopover = new TLineSite();
            stopover.setLineId(tLine.getId());
            stopover.setSiteId(jsonObject.getInteger("id"));
            stopover.setType(3);
            stopoverList.add(stopover);
        }
        itLineSiteService.insertBatch(stopoverList);
        //添加价格设置
        addPrice(tLine.getId(), subArr);
@@ -326,7 +343,10 @@
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public ResultUtil update(TLine tLine,Integer startSiteId,Integer endSiteId,@RequestParam String subArr,@RequestParam String shuArr) {
    public ResultUtil update(TLine tLine,Integer startSiteId,Integer endSiteId,
                             @RequestParam String subArr,
                             @RequestParam String shuArr,
                             @RequestParam String stopoverValues) {
        String name = tLine.getName();
        name = name.replaceAll("& lt;", "<");
        name = name.replaceAll("& gt;", ">");
@@ -364,6 +384,21 @@
            itLineSiteService.insert(end);
        }
        // 删除经停站
        itLineSiteService.delete(new EntityWrapper<TLineSite>().eq("lineId",tLine.getId()).eq("type",3));
        // 添加经停站
        List<TLineSite> stopoverList = new ArrayList<>();
        JSONArray jsonArray = JSON.parseArray(stopoverValues);
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            TLineSite stopover = new TLineSite();
            stopover.setLineId(tLine.getId());
            stopover.setSiteId(jsonObject.getInteger("id"));
            stopover.setType(3);
            stopoverList.add(stopover);
        }
        itLineSiteService.insertBatch(stopoverList);
        //删除线路价格
        itLinePriceService.delete(new EntityWrapper<TLinePrice>().eq("lineId",tLine.getId()));
        //添加价格设置
ManagementOKTravel/guns-admin/src/main/webapp/WEB-INF/view/system/tLine/tLine_add.html
@@ -16,6 +16,7 @@
                </div>
            </div>
            <div class="row">
                <input type="hidden" id="siteList" value="${siteList}">
                <div class="col-sm-11">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">线路名称:</label>
@@ -33,6 +34,15 @@
                                @}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">经停站:</label>
                        <div class="col-sm-10">
                            <#button btnCss="info" name="添加" id="stopoverSite" icon="fa-check" clickFun="addBtn()"/>
                        </div>
                    </div>
                    <div class="form-group" id="stopoverSiteDiv">
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">终点:</label>
@@ -238,6 +248,59 @@
            layer.msg("【分钟】输入框不能超过3位数");
        }
    }
    function addBtn(){
        console.log("addBtn");
        // 给stopoverSiteDiv的里面添加经停站
        var stopoverSiteDiv = $("#stopoverSiteDiv");
        var siteListStr = $("#siteList").val();
        var siteList = extractSites(siteListStr);
        // 转成json
        console.log("1111122222111"+siteList);
        var options = '<option value="">选择站点</option>';
        for (var i = 0; i < siteList.length; i++) {
            console.log(siteList[i]);
            options += '<option value="' + siteList[i].id + '">' + siteList[i].name + '</option>';
        }
        // 添加唯一ID和删除按钮
        var uniqueId = Date.now(); // 生成唯一ID
        var stopoverSite = '<div class="form-group" id="stopoverItem_' + uniqueId + '">' +
            '<label class="col-sm-2 control-label"></label>' +
            '<div class="col-sm-2">' +
            '<select class="form-control">' + options + '</select>' +
            '</div>' +
            '<div class="col-sm-1">' +
            '<button type="button" class="btn btn-danger btn-sm" onclick="removeStopover(' + uniqueId + ')">' +
            '<i class="fa fa-trash"></i> 删除' +
            '</button>' +
            '</div>' +
            '</div>';
        stopoverSiteDiv.append(stopoverSite);
    }
    // 删除经停站函数
    function removeStopover(id) {
        $("#stopoverItem_" + id).remove();
    }
    function extractSites(siteListStr) {
        try {
            var sites = [];
            // 匹配每个站点的id和name
            var regex = /TSite\{id=(\d+), name=([^,}]+)/g;
            var match;
            while ((match = regex.exec(siteListStr)) !== null) {
                sites.push({
                    id: parseInt(match[1]),
                    name: match[2]
                });
            }
            return sites;
        } catch (e) {
            console.error("提取站点信息失败:", e);
            return [];
        }
    }
</script>
@}
ManagementOKTravel/guns-admin/src/main/webapp/WEB-INF/view/system/tLine/tLine_edit.html
@@ -16,6 +16,7 @@
                </div>
            </div>
            <input type="hidden" id="id" name="id" value="${item.id}">
            <input type="hidden" id="siteList" value="${siteList}">
            <div class="row">
                <div class="col-sm-11">
                    <div class="form-group">
@@ -35,6 +36,34 @@
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">经停站:</label>
                        <div class="col-sm-10">
                            <#button btnCss="info" name="添加" id="stopoverSite" icon="fa-check" clickFun="addBtn()"/>
                        </div>
                    </div>
                    <div class="form-group" id="stopoverSiteDiv">
                        @for(stopover in stopoverList){
                        <div class="form-group" id="stopoverItem_${stopover.id}">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-2">
                                    <select class="form-control" id="endSiteId1" >
                                        <option value="">选择站点</option>
                                        @for(obj in siteList){
                                        <option value="${obj.id}" ${obj.id == stopover.siteId ? 'selected=selected' : ''}>${obj.name}</option>
                                        @}
                                    </select>
                            </div>
                            <div class="col-sm-1">
                                <button type="button" class="btn btn-danger btn-sm" onclick="removeStopover(${stopover.id})">
                                    <i class="fa fa-trash"></i> 删除
                                </button>
                            </div>
                        </div>
                        @}
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">终点:</label>
                        <div class="col-sm-2">
@@ -252,6 +281,60 @@
            layer.msg("【分钟】输入框不能超过3位数");
        }
    }
    function addBtn(){
        console.log("addBtn");
        // 给stopoverSiteDiv的里面添加经停站
        var stopoverSiteDiv = $("#stopoverSiteDiv");
        var siteListStr = $("#siteList").val();
        var siteList = extractSites(siteListStr);
        // 转成json
        console.log("1111122222111"+siteList);
        var options = '<option value="">选择站点</option>';
        for (var i = 0; i < siteList.length; i++) {
            console.log(siteList[i]);
            options += '<option value="' + siteList[i].id + '">' + siteList[i].name + '</option>';
        }
        // 添加唯一ID和删除按钮
        var uniqueId = Date.now(); // 生成唯一ID
        var stopoverSite = '<div class="form-group" id="stopoverItem_' + uniqueId + '">' +
            '<label class="col-sm-2 control-label"></label>' +
            '<div class="col-sm-2">' +
            '<select class="form-control">' + options + '</select>' +
            '</div>' +
            '<div class="col-sm-1">' +
            '<button type="button" class="btn btn-danger btn-sm" onclick="removeStopover(' + uniqueId + ')">' +
            '<i class="fa fa-trash"></i> 删除' +
            '</button>' +
            '</div>' +
            '</div>';
        stopoverSiteDiv.append(stopoverSite);
    }
    // 删除经停站函数
    function removeStopover(id) {
        console.log("removeStopover"+id);
        $("#stopoverItem_" + id).remove();
    }
    function extractSites(siteListStr) {
        try {
            var sites = [];
            // 匹配每个站点的id和name
            var regex = /TSite\{id=(\d+), name=([^,}]+)/g;
            var match;
            while ((match = regex.exec(siteListStr)) !== null) {
                sites.push({
                    id: parseInt(match[1]),
                    name: match[2]
                });
            }
            return sites;
        } catch (e) {
            console.error("提取站点信息失败:", e);
            return [];
        }
    }
</script>
@}
ManagementOKTravel/guns-admin/src/main/webapp/static/modular/system/tLine/tLine_info.js
@@ -120,6 +120,20 @@
    var startSiteId = $("#startSiteId").val();
    var endSiteId = $("#endSiteId").val();
    // 获取经停站所有的值
    var stopoverValues = [];
    $("#stopoverSiteDiv .form-group").each(function() {
        var selectedValue = $(this).find("select").val();
        var selectedText = $(this).find("select option:selected").text();
        if (selectedValue) {
            stopoverValues.push({
                id: selectedValue,
                name: selectedText
            });
        }
    });
    var subArr=[];
    $(".typeValueClass").each(function () {
        subArr.push({
@@ -164,6 +178,8 @@
    ajax.set("endSiteId",endSiteId);
    ajax.set("subArr",JSON.stringify(subArr));
    ajax.set("shuArr",JSON.stringify(shuArr));
    ajax.set("stopoverValues",JSON.stringify(stopoverValues));
    console.log("fsahbAJdsaiujhds");
    ajax.start();
}
@@ -180,6 +196,19 @@
    var startSiteId = $("#startSiteId").val();
    var endSiteId = $("#endSiteId").val();
    // 获取经停站所有的值
    var stopoverValues = [];
    $("#stopoverSiteDiv .form-group").each(function() {
        var selectedValue = $(this).find("select").val();
        var selectedText = $(this).find("select option:selected").text();
        if (selectedValue) {
            stopoverValues.push({
                id: selectedValue,
                name: selectedText
            });
        }
    });
    var subArr=[];
    $(".typeValueClass").each(function () {
@@ -224,6 +253,8 @@
    ajax.set("endSiteId",endSiteId);
    ajax.set("subArr",JSON.stringify(subArr));
    ajax.set("shuArr",JSON.stringify(shuArr));
    ajax.set("stopoverValues",JSON.stringify(stopoverValues));
    console.log("fsahqeqdsddsdhds");
    ajax.start();
}