hxp
2024-11-19 3c433d5045813bd41d407b34a381cf100465621f
10310 【后台】优化游戏分支获取数据的功能
9个文件已修改
2个文件已添加
664 ■■■■ 已修改文件
Account/User.php 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
center/appversion_new.php 63 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
center/server_list.php 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
index.php 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
js/common.js 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverops/gameVersion.php 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverops/gameVersionEdit.php 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverops/packBranch.php 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverops/packBranchEdit.php 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverops/versionState.php 224 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverops/versionStateEdit.php 148 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Account/User.php
@@ -156,6 +156,7 @@
                "Name" => \Lang\gettext("运维管理"),
                "PList" => array(
                    Permission::P_OPSPackBranch => array("Name" => \Lang\gettext("打包分支管理")),
                    Permission::P_OPSVersionState => array("Name" => \Lang\gettext("版本状态管理")),
                    Permission::P_OPSGameVersion  => array("Name" => \Lang\gettext("内容版本管理")),
                    Permission::P_OPSServerList  => array("Name" => \Lang\gettext("服务器列表")),
                    Permission::P_OPSServerStateMgr  => array("Name" => \Lang\gettext("服务器状态管理"), "Log" => array("1")),
@@ -292,6 +293,7 @@
    //运维权限
    const P_OPSPackBranch = "P_OPSPackBranch";
    const P_OPSVersionState = "P_OPSVersionState";
    const P_OPSGameVersion = "P_OPSGameVersion";
    const P_OPSServerList = "P_OPSServerList";
    const P_OPSServerStateMgr = "P_OPSServerStateMgr";
center/appversion_new.php
@@ -23,44 +23,43 @@
    exit;
}
// 分支信息
if (\DBOper\FindOne("GamePackBranch", array("Channel" => $channel, "BranchNum" => $branch), $branchData)) {
// 版本强更信息
$VersionCount = 0; //强更
$downUrl = "";
$VersionState = 0;
// 优先读指定版本信息
if (\DBOper\FindOne("GameVersion", array("Channel" => $channel, "BranchNum" => $branch, "Version" => $versioncode), $versionInfo)) {
    $VersionState = $versionInfo["VersionState"] ? intval($versionInfo["VersionState"]) : 0;
    $curVersionNum = \CommFunc\VersionNum($versioncode);
    $versionNum = \CommFunc\VersionNum($versionInfo["Version"]);
    // \Logging\LogInfo("versionInfo: " . print_r($versionInfo, true));
    if ($curVersionNum < $versionNum) {
        if ($versionInfo["ForceDownUrl"]) {
            $VersionCount = 1;
            $downUrl = $versionInfo["ForceDownUrl"];
        }
        continue;
    }
}
$retVersion["VersionCount"] = $VersionCount;
$retVersion["downUrl"] = $downUrl;
// 版本状态
if ($VersionState > 0 && \DBOper\FindOne("GameVersionState", array("Channel" => $channel, "BranchNum" => $branch, "VersionState" => $VersionState), $stateInfo)) {
    // 保留前端json格式,但只下发本分支的数据
    $retVersion["notice_flag"] = array("" . $branch => $stateInfo["NoticeUrl"]);
    $retVersion["resource_url"] = array("" . $branch => $stateInfo["ResourceUrl"]);
    $retVersion["ResourceAward"] = $stateInfo["ResourceAwardInfo"];
    $retVersion["AuditState"] = 0;
}
// 没有指定版本,默认取分支信息
else if (\DBOper\FindOne("GamePackBranch", array("Channel" => $channel, "BranchNum" => $branch), $branchData)) {
    // 保留前端json格式,但只下发本分支的数据
    $retVersion["notice_flag"] = array("" . $branch => $branchData["NoticeUrl"]);
    $retVersion["resource_url"] = array("" . $branch => $branchData["ResourceUrl"]);
    $retVersion["ResourceAward"] = $branchData["ResourceAwardInfo"];
    $retVersion["AuditState"] = intval($branchData["AuditState"]);
    // $retVersion["ResourceAward"] = array(
    //     "version" => $branchData["ResourceAwardVer"],
    //     "awardItemList" => $branchData["ResourceAwardInfo"],
    // );
}
// 版本强更信息
$VersionCount = 0; //强更
$downUrl = "";
if (\DBOper\Find(
    "GameVersion",
    array("Channel" => $channel, "BranchNum" => $branch),
    $versionDatas
) && isset($versionDatas)) {
    $curVersionNum = \CommFunc\VersionNum($versioncode);
    foreach ($versionDatas as $versionInfo) {
        $versionNum = \CommFunc\VersionNum($versionInfo["Version"]);
        // \Logging\LogInfo("versionInfo: " . print_r($versionInfo, true));
        if ($curVersionNum < $versionNum) {
            if ($versionInfo["ForceDownUrl"]) {
                $VersionCount = 1;
                $downUrl = $versionInfo["ForceDownUrl"];
            }
            continue;
        }
    }
}
$retVersion["VersionCount"] = $VersionCount;
$retVersion["downUrl"] = $downUrl;
// \Logging\LogInfo("_GET: " . print_r($_GET, true) . " retVersion: " . print_r($retVersion, true));
echo \CommFunc\MyJson_encode($retVersion);
center/server_list.php
@@ -28,15 +28,24 @@
$branch = intval($flagInfo[1]);
$versioncode = $flagInfo[2];
// 分支信息
if (!DBOper\FindOne("GamePackBranch", array("Channel" => $channel, "BranchNum" => $branch), $branchData)) {
    \Logging\LogError("can not found db GamePackBranch data! channel:" . $channel . " branch:" . $branch);
    exit;
$VersionState = 0;
$JsonBranch = 0;
// 优先读指定版本信息
if (\DBOper\FindOne("GameVersion", array("Channel" => $channel, "BranchNum" => $branch, "Version" => $versioncode), $versionInfo)) {
    $VersionState = $versionInfo["VersionState"] ? intval($versionInfo["VersionState"]) : 0;
}
$JsonBranch = $branchData["JsonBranch"];
// 版本状态
if ($VersionState > 0 && \DBOper\FindOne("GameVersionState", array("Channel" => $channel, "BranchNum" => $branch, "VersionState" => $VersionState), $stateInfo)) {
    $JsonBranch = $stateInfo["JsonBranch"];
}
// 没有指定版本,默认取分支信息
else if (DBOper\FindOne("GamePackBranch", array("Channel" => $channel, "BranchNum" => $branch), $branchData)) {
    $JsonBranch = $branchData["JsonBranch"];
}
if ($JsonBranch <= 0) {
    \Logging\LogError("db GamePackBranch.JsonBranch value not set! channel:" . $channel . " branch:" . $branch);
    \Logging\LogError("db JsonBranch value not set! channel:" . $channel . " branch:" . $branch . " versioncode:" . $versioncode);
    exit;
}
index.php
@@ -101,6 +101,7 @@
    "运维管理" => array(
        array(\User\Permission::P_OPSPackBranch, "serverops/packBranch.php", "打包分支管理"),
        array(\User\Permission::P_OPSVersionState, "serverops/versionState.php", "版本状态管理"),
        array(\User\Permission::P_OPSGameVersion, "serverops/gameVersion.php", "内容版本管理"),
        array(\User\Permission::P_OPSServerList, "serverops/serverlist.php", "服务器列表"),
        array(\User\Permission::P_OPSServerStateMgr, "serverops/serverstatemgr.php", "服务器状态管理"),
js/common.js
@@ -122,6 +122,21 @@
    }
}
function doSubmit(to, p, method='GET') { // to:提交动作(action),p:参数
    var myForm = document.createElement("form");
    myForm.method = method;
    myForm.action = to;
    for (var i in p) {
        var myInput = document.createElement("input");
        myInput.setAttribute("name", i); // 为input对象设置name
        myInput.setAttribute("value", p[i]); // 为input对象设置value
        myForm.appendChild(myInput);
    }
    document.body.appendChild(myForm);
    myForm.submit();
    document.body.removeChild(myForm); // 提交后移除创建的form
}
function random(min, max) {
    return Math.round(Math.random() * (max - min)) + min;
}
serverops/gameVersion.php
@@ -14,6 +14,7 @@
    $channel = $_SESSION['spid'];
    $BranchNum = intval($_POST["BranchNum"]);
    $Version = $_POST["Version"];
    $VersionState = intval($_POST["VersionState"]);
    $ForceDownUrl = $_POST["ForceDownUrl"];
    $find = array(
@@ -36,6 +37,7 @@
        "Channel" => $channel,
        "BranchNum" => $BranchNum,
        "Version" => $Version,
        "VersionState" => $VersionState,
        "ForceDownUrl" => $ForceDownUrl,
        "UpdateTime" => date("Y-m-d H:i:s")
    );
@@ -82,19 +84,8 @@
    exit;
}
$AllChannel = \CommFunc\GetAllChannel();
if ($_POST["opType"]) {
    GameVersionEdit($_POST["opType"]);
}
DBOper\Find(
    "GameVersion",
    array("Channel" => $channel),
    $versionArray,
    null,
    array("BranchNum" => 1, "VersionTime" => -1)
);
// 打包分支
$BranchNum = 0;
$branchNameInfo = array();
DBOper\Find(
    "GamePackBranch",
@@ -104,15 +95,42 @@
);
foreach ($branchArray as $branchInfo) {
    $branchNameInfo[$branchInfo["BranchNum"]] = $branchInfo["BranchName"];
    if ($BranchNum == 0) {
        $BranchNum = $branchInfo["BranchNum"];
    }
}
// echo "branchNameInfo:", print_r($branchNameInfo, true), "<br/>";
if (array_key_exists("BranchNum", $_POST)) {
    $BranchNum = intval($_POST["BranchNum"]);
    GameVersionEdit($_POST["opType"]);
}
$BranchName = $branchNameInfo[$BranchNum];
// 版本状态
$stateNameInfo = array();
DBOper\Find(
    "GameVersionState",
    array("Channel" => $channel, "BranchNum" => $BranchNum),
    $versionStateArray
);
foreach ($versionStateArray as $stateInfo) {
    $stateNameInfo[$stateInfo["VersionState"]] = $stateInfo["StateName"];
}
DBOper\Find(
    "GameVersion",
    array("Channel" => $channel, "BranchNum" => $BranchNum),
    $versionArray,
    null,
    array("VersionTime" => -1)
);
//显示表格字段配置 key-参数名,value-说明
$tableArray = array(
    "BranchNum" => array("分支", "5%", "center"),
    "BranchName" => array("名称", "7%", "center"),
    // "BranchNum" => array("分支", "5%", "center"),
    // "BranchName" => array("名称", "7%", "center"),
    "Version" => array("游戏版本", "7%", "center"),
    "VsersionState" => array("版本状态", "5%", "center"),
    "VersionTime" => array("版本时间", "12%", "center"),
    "UpdateTime" => array("修改时间", "12%", "center"),
    "ForceDownUrl" => array("强更下载地址", "40%", "center"),
@@ -138,31 +156,37 @@
        <p><b>内容版本管理</b></P>
    </center>
    <input type="button" value="添加分支" onclick="window.location.href='packBranchEdit.php?opType=add'" />
    <?php
    // 先都展示测试用, 后续再优化布局
    foreach ($branchNameInfo as $BranchNum => $BranchName) {
        echo " <input type=\"button\" value=\"[" . $BranchName . "]分支 -> 添加版本\" " .
            "onclick=\"window.location.href='gameVersionEdit.php?opType=add&BranchNum=" . $BranchNum . "&BranchName=" . $BranchName . "'\" />";
    }
    ?>
    <hr />
    <table width="100%">
        <?php
        if ($versionArray) {
            echo "<thead><tr>";
            foreach ($tableArray as $value) {
                echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>";
    <form action="" method="post">
        打包分支:
        <select name="BranchNum" id="BranchNum" onchange="ChangeBranchNum(this)">
            <?php
            foreach ($branchNameInfo as $key => $value) {
                echo "<option value=\"" . $key . "\"";
                if ($BranchNum == $key) {
                    echo " selected";
                }
                echo ">" . $value . "</option>";
            }
            echo "</tr></thead>";
        } else {
            echo "无游戏版本,请添加版本!<br/>";
            ?>
        </select>
        &nbsp;&nbsp;
        <input type="button" value="添加版本" onclick="window.location.href='gameVersionEdit.php?opType=add&BranchNum=<?php echo $BranchNum ?>&BranchName=<?php echo $BranchName ?>'" />
    </form>
    <hr />
    <?php
    if ($versionArray) {
        echo '<table width="100%">';
        echo "<thead><tr>";
        foreach ($tableArray as $value) {
            echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>";
        }
        echo "</tr></thead>";
        foreach ($versionArray as $versionInfo) {
            echo "<tr class='trc'>";
            $BranchNum = $versionInfo["BranchNum"];
            $BranchName = $branchNameInfo[$BranchNum];
            $VersionState = $versionInfo["VersionState"];
            $StateName = $stateNameInfo[$VersionState];
            $Version = $versionInfo["Version"];
            foreach ($tableArray as $key => $value) {
                if (!$key) {
@@ -173,8 +197,8 @@
                    echo "</td>";
                    continue;
                }
                if ($key == "BranchName") {
                    $tdContent = $BranchName;
                if ($key == "VsersionState") {
                    $tdContent = $StateName;
                } else {
                    $tdContent = $versionInfo[$key];
                }
@@ -182,34 +206,26 @@
            }
            echo "</tr>";
        }
        ?>
    </table>
        echo '</table>';
    } else {
        echo "无游戏版本,请添加版本!<br/>";
    }
    ?>
    <script type='text/javascript' src="/js/common.js"></script>
    <script type="text/javascript">
        function doPost(to, p) { // to:提交动作(action),p:参数
            var myForm = document.createElement("form");
            myForm.method = "post";
            myForm.action = to;
            for (var i in p) {
                var myInput = document.createElement("input");
                myInput.setAttribute("name", i); // 为input对象设置name
                myInput.setAttribute("value", p[i]); // 为input对象设置value
                myForm.appendChild(myInput);
            }
            document.body.appendChild(myForm);
            myForm.submit();
            document.body.removeChild(myForm); // 提交后移除创建的form
        function ChangeBranchNum(obj) {
            document.forms[0].submit();
        }
        function suredel(Channel, BranchNum, Version) {
            if (!window.confirm("确定删除" + Channel + "分支" + BranchNum + "版本" + Version + "?")) {
                return false;
            }
            doPost("gameVersion.php", {
            doSubmit("gameVersion.php", {
                "opType": "del",
                "BranchNum": BranchNum,
                "Version": Version,
            });
            }, 'post');
            return true;
        }
    </script>
serverops/gameVersionEdit.php
@@ -27,6 +27,13 @@
    DBOper\FindOne("GameVersion", $find, $editInfo);
}
$stateNameInfo = array();
DBOper\Find(
    "GameVersionState",
    array("Channel" => $channel, "BranchNum" => $BranchNum),
    $versionStateArray
);
// echo "_GET:" . print_r($_GET, true);
// echo "editInfo:" . print_r($editInfo, true);
@@ -77,6 +84,23 @@
                </td>
            </tr>
            <tr>
                <td class="formTableTDName">版本状态: </td>
                <td class="formTableTDValue">
                    <select name="VersionState" id="VersionState">
                        <?php
                        $VersionState = array_key_exists("VersionState", $editInfo) ? $editInfo["VersionState"] : "";
                        foreach ($versionStateArray as $stateInfo) {
                            echo "<option value=\"" . $stateInfo["VersionState"] . "\"";
                            if ($VersionState == $stateInfo["VersionState"]) {
                                echo " selected";
                            }
                            echo ">" . $stateInfo["StateName"] . "</option>";
                        }
                        ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="formTableTDName">强更地址: </td>
                <td class="formTableTDValue">
                    <input type="input" name="ForceDownUrl" id="ForceDownUrl" value="<?php echo array_key_exists("ForceDownUrl", $editInfo)  ? $editInfo["ForceDownUrl"] : "" ?>" size="100" placeholder="可选,如果需要强更则输入强更地址" />
serverops/packBranch.php
@@ -131,6 +131,7 @@
    </center>
    <input type="button" value="添加分支" onclick="window.location.href='packBranchEdit.php?opType=add'" />
    &nbsp;注:打包分支对应的选服、资源、公告等为默认值,即如果对应版本不存在或版本状态不存在则读该打包分支下配置的默认信息;
    <hr />
    <table width="100%">
        <?php
@@ -168,30 +169,16 @@
        ?>
    </table>
    <script type='text/javascript' src="/js/common.js"></script>
    <script type="text/javascript">
        function doPost(to, p) { // to:提交动作(action),p:参数
            var myForm = document.createElement("form");
            myForm.method = "post";
            myForm.action = to;
            for (var i in p) {
                var myInput = document.createElement("input");
                myInput.setAttribute("name", i); // 为input对象设置name
                myInput.setAttribute("value", p[i]); // 为input对象设置value
                myForm.appendChild(myInput);
            }
            document.body.appendChild(myForm);
            myForm.submit();
            document.body.removeChild(myForm); // 提交后移除创建的form
        }
        function suredel(Channel, BranchNum, BranchName) {
            if (!window.confirm("确定删除" + Channel + "分支: " + BranchName + " (" + BranchNum + ") ?")) {
                return false;
            }
            doPost("packBranch.php", {
            doSubmit("packBranch.php", {
                "opType": "del",
                "BranchNum": BranchNum,
            });
            }, 'post');
            return true;
        }
    </script>
serverops/packBranchEdit.php
@@ -50,7 +50,7 @@
            <tr>
                <td class="formTableTDName">打包分支编号: </td>
                <td class="formTableTDValue">
                    <input type="number" name="BranchNum" id="BranchNum" value="<?php echo array_key_exists("BranchNum", $editInfo) ? $editInfo["BranchNum"] : "" ?>" />
                    <input type="number" name="BranchNum" id="BranchNum" value="<?php echo array_key_exists("BranchNum", $editInfo) ? $editInfo["BranchNum"] : "" ?>" min="1" />
                    <?php
                    if ($opType == "upd") {
                        echo "<input type='hidden' name='SrcBranchNum' value='" . $editInfo["BranchNum"] . "'/>";
@@ -133,23 +133,6 @@
                document.getElementById('JsonBranch').focus();
                return false;
            }
            // if (!document.getElementById("NoticeUrl").value) {
            //     alert("请输入分公告地址!");
            //     document.getElementById('NoticeUrl').focus();
            //     return false;
            // }
            // if (!document.getElementById("ResourceUrl").value) {
            //     alert("请输入资源地址!");
            //     document.getElementById('ResourceUrl').focus();
            //     return false;
            // }
            // if (document.getElementById("ResourceAwardVer").value > 0) {
            //     if (!document.getElementById("ResourceAwardInfo").value) {
            //         alert("需同步输入资源下载奖励信息!");
            //         document.getElementById('ResourceAwardInfo').focus();
            //         return false;
            //     }
            // }
            return true;
        }
    </script>
serverops/versionState.php
New file
@@ -0,0 +1,224 @@
<?php
include_once "/Common/Logging.php";
include_once "/Account/User.php";
include_once "/db/DBOper.php";
include_once "/Common/ServerOPS.php";
include_once "/Common/CommFunc.php";
include_once "/language/lang.php";
\Logging\CreateLogging("serverops.versionState.php");
function VersionStateEdit($opType)
{
    global $alertMsg;
    // echo "_POST: ", print_r($_POST, true), "<br/>";
    $channel = $_SESSION['spid'];
    $BranchNum = intval($_POST["BranchNum"]);
    $VersionState = intval($_POST["VersionState"]);
    $find = array(
        "Channel" => $channel,
        "BranchNum" => $BranchNum,
        "VersionState" => $VersionState,
    );
    if ($opType == "del") {
        if (!DBOper\Remove("GameVersionState", $find)) {
            $alertMsg = "删除失败!";
            \Logging\LogError($alertMsg . print_r($find, true));
            return false;
        }
        $alertMsg = "删除成功!";
        \Logging\LogInfo($alertMsg . print_r($find, true));
        return true;
    }
    $StateName = $_POST["StateName"];
    $JsonBranch = intval($_POST["JsonBranch"]);
    $NoticeUrl = $_POST["NoticeUrl"];
    $ResourceUrl = $_POST["ResourceUrl"];
    $ResourceAwardInfo = $_POST["ResourceAwardInfo"];
    $IsDefault = intval($_POST["IsDefault"]);
    $editArray = array(
        "Channel" => $channel,
        "BranchNum" => $BranchNum,
        "VersionState" => $VersionState,
        "StateName" => $StateName,
        "JsonBranch" => $JsonBranch,
        "NoticeUrl" => $NoticeUrl,
        "ResourceUrl" => $ResourceUrl,
        "ResourceAwardInfo" => $ResourceAwardInfo,
    );
    // 添加
    if ($opType == "add") {
        DBOper\FindOne("GameVersionState", $find, $ret);
        if (count($ret) > 0) {
            $alertMsg = "该版本状态已存在,不能重复添加!";
            \Logging\LogInfo($alertMsg . print_r($editArray, true));
            return false;
        }
        if (!DBOper\Insert("GameVersionState", $editArray, $find)) {
            $alertMsg = "添加版本状态失败!";
            \Logging\LogError($alertMsg . print_r($editArray, true));
            return false;
        }
        $alertMsg = "添加版本状态成功!";
        \Logging\LogInfo($alertMsg . print_r($editArray, true));
    }
    // 更新
    elseif ($opType == "upd") {
        $find["VersionState"] = intval($_POST["SrcVersionState"]);
        if (!DBOper\Update("GameVersionState", $find, $editArray, true)) {
            $alertMsg = "更新版本状态失败!";
            \Logging\LogError($alertMsg . print_r($editArray, true));
            return false;
        }
        $alertMsg = "更新版本状态成功!";
        \Logging\LogInfo($alertMsg . print_r($editArray, true));
    }
    return true;
}
$alertMsg = "";
$Permission = \User\Permission::P_OPSVersionState;
$channel = $_SESSION['spid'];
$user = new \User\User($_SESSION['UserAccount']);
if (!$user->HavePermission($Permission)) {
    exit;
}
// 打包分支
$BranchNum = 0;
$branchNameInfo = array();
DBOper\Find(
    "GamePackBranch",
    array("Channel" => $channel),
    $branchArray,
    array("BranchNum" => 1, "BranchName" => 1)
);
foreach ($branchArray as $branchInfo) {
    $branchNameInfo[$branchInfo["BranchNum"]] = $branchInfo["BranchName"];
    if ($BranchNum == 0) {
        $BranchNum = $branchInfo["BranchNum"];
    }
}
if (array_key_exists("BranchNum", $_POST)) {
    $BranchNum = intval($_POST["BranchNum"]);
    VersionStateEdit($_POST["opType"]);
}
// 版本状态
DBOper\Find(
    "GameVersionState",
    array("Channel" => $channel, "BranchNum" => $BranchNum),
    $versionStateArray
);
//显示表格字段配置 key-参数名,value-说明
$tableArray = array(
    "VersionState" => array("状态", "5%", "center"),
    "StateName" => array("状态名", "5%", "center"),
    "JsonBranch" => array("选服Json分支文件", "13%", "center"),
    "ResourceAwardInfo" => array("资源下载奖励信息", "9%", "center"),
    "ResourceUrl" => array("资源地址", "28%", "center"),
    "NoticeUrl" => array("公告地址", "28%", "center"),
    "" => array("操作", "", "center"),
);
if ($alertMsg) {
    echo "<script>alert('" . $alertMsg . "')</script>";
}
?>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>版本状态管理</title>
    <link rel="stylesheet" type="text/css" href="/css/table.css">
</head>
<body>
    <center>
        <p><b>版本状态管理</b></P>
    </center>
    <form action="" method="post">
        打包分支:
        <select name="BranchNum" id="BranchNum" onchange="ChangeBranchNum(this)">
            <?php
            foreach ($branchNameInfo as $key => $value) {
                echo "<option value=\"" . $key . "\"";
                if ($BranchNum == $key) {
                    echo " selected";
                }
                echo ">" . $value . "</option>";
            }
            ?>
        </select>
        &nbsp;&nbsp;
        <input type="button" value="添加版本状态" onclick="window.location.href='versionStateEdit.php?opType=add&BranchNum=<?php echo $BranchNum ?>'" />
    </form>
    <hr />
    <?php
    if ($versionStateArray) {
        echo '<table width="100%">';
        echo "<thead><tr>";
        foreach ($tableArray as $value) {
            echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>";
        }
        echo "</tr></thead>";
        foreach ($versionStateArray as $stateInfo) {
            echo "<tr class='trc'>";
            $BranchNum = $stateInfo["BranchNum"];
            $VersionState = $stateInfo["VersionState"];
            $StateName = $stateInfo["StateName"];
            foreach ($tableArray as $key => $value) {
                if (!$key) {
                    echo "<td align='center'>";
                    echo "&nbsp;<input type=\"button\" value=\"改\" onclick=\"window.location.href='versionStateEdit.php?" .
                        "opType=upd&BranchNum=$BranchNum&VersionState=$VersionState'\" />";
                    echo " <input type=\"button\" value=\"删\" onclick=\"return suredel('$channel', '$BranchNum', '$VersionState', '$StateName')\"/>&nbsp;";
                    echo "</td>";
                    continue;
                }
                $tdContent = $stateInfo[$key];
                if ($key == "JsonBranch") {
                    $tdContent = \ServerOPS\GetCommonServerlistJsonFileName($channel, $tdContent);
                }
                echo "<td align='" . $value[2] . "' width=\"100\">" . $tdContent . "</td>";
            }
            echo "</tr>";
        }
        echo "</table>";
    } else {
        echo "无版本状态,请添加状态!<br/>";
    }
    ?>
    <script type='text/javascript' src="/js/common.js"></script>
    <script type="text/javascript">
        function ChangeBranchNum(obj) {
            document.forms[0].submit();
        }
        function suredel(Channel, BranchNum, VersionState, StateName) {
            if (!window.confirm("确定删除" + Channel + "分支: " + BranchNum + " 版本状态:" + VersionState + "(" + StateName + ") ?")) {
                return false;
            }
            doSubmit("", {
                "opType": "del",
                "BranchNum": BranchNum,
                "VersionState": VersionState,
            }, 'post');
            return true;
        }
    </script>
</body>
</html>
serverops/versionStateEdit.php
New file
@@ -0,0 +1,148 @@
<?php
include_once "/Account/User.php";
include_once "/db/DBOper.php";
include_once "/Common/Logging.php";
include_once "/Common/CommFunc.php";
include_once "/language/lang.php";
\Logging\CreateLogging("serverops.versionStateEdit.php");
$Permission = \User\Permission::P_OPSVersionState;
$channel = $_SESSION['spid'];
$user = new \User\User($_SESSION['UserAccount']);
if (!$user->HavePermission($Permission)) {
    exit;
}
DBOper\Find(
    "GamePackBranch",
    array("Channel" => $channel),
    $branchArray,
    array("BranchNum" => 1, "BranchName" => 1)
);
$editInfo = $_GET;
$opType = $_GET["opType"];
$pageTitle = "版本状态 - 添加";
if ($opType == "upd") {
    $pageTitle = "版本状态 - 编辑";
    $find = array("Channel" => $channel, "BranchNum" => intval($_GET["BranchNum"]), "VersionState" => intval($_GET["VersionState"]));
    DBOper\FindOne("GameVersionState", $find, $editInfo);
}
// echo "editInfo:" . print_r($editInfo, true);
?>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php echo $pageTitle; ?></title>
    <link rel="stylesheet" type="text/css" href="/css/tableform.css">
</head>
<body>
    <center>
        <p><b><?php echo $pageTitle; ?></b></P>
    </center>
    <hr />
    <form action="versionState.php" method="post">
        <table id="tt" class="formTable">
            <tr>
                <td class="formTableTDName">渠道: </td>
                <td class="formTableTDValue">
                    <?php echo $channel; ?>
                </td>
            </tr>
            <tr>
                <td class="formTableTDName">打包分支: </td>
                <td class="formTableTDValue">
                    <select name="BranchNum" id="BranchNum">
                        <?php
                        $BranchNum = array_key_exists("BranchNum", $editInfo) ? $editInfo["BranchNum"] : "";
                        foreach ($branchArray as $branchInfo) {
                            echo "<option value=\"" . $branchInfo["BranchNum"] . "\"";
                            if ($BranchNum == $branchInfo["BranchNum"]) {
                                echo " selected";
                            }
                            echo ">" . $branchInfo["BranchName"] . "</option>";
                        }
                        ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="formTableTDName">状态值: </td>
                <td class="formTableTDValue">
                    <input type="number" name="VersionState" id="VersionState" value="<?php echo array_key_exists("VersionState", $editInfo) ? $editInfo["VersionState"] : "" ?>" min="1" />
                    <?php
                    if ($opType == "upd") {
                        echo "<input type='hidden' name='SrcVersionState' value='" . $editInfo["VersionState"] . "'/>";
                    }
                    ?>
                </td>
            </tr>
            <tr>
                <td class="formTableTDName">状态名: </td>
                <td class="formTableTDValue">
                    <input type="input" name="StateName" id="StateName" value="<?php echo array_key_exists("StateName", $editInfo) ? $editInfo["StateName"] : "" ?>" placeholder="一般是中文名,用于展示" />
                </td>
            </tr>
            <tr>
                <td class="formTableTDName">选服Json分支: </td>
                <td class="formTableTDValue">
                    <input type="number" name="JsonBranch" id="JsonBranch" value="<?php echo array_key_exists("JsonBranch", $editInfo)  ? $editInfo["JsonBranch"] : "" ?>" placeholder="对应xxx_分支.json" />
                </td>
            </tr>
            <tr>
                <td class="formTableTDName">公告地址: </td>
                <td class="formTableTDValue">
                    <input type="input" name="NoticeUrl" id="NoticeUrl" value="<?php echo array_key_exists("NoticeUrl", $editInfo)  ? $editInfo["NoticeUrl"] : "" ?>" size="100" />
                </td>
            </tr>
            <tr>
                <td class="formTableTDName">资源地址: </td>
                <td class="formTableTDValue">
                    <input type="input" name="ResourceUrl" id="ResourceUrl" value="<?php echo array_key_exists("ResourceUrl", $editInfo)  ? $editInfo["ResourceUrl"] : "" ?>" size="100" />
                </td>
            </tr>
            <tr>
                <td class="formTableTDName">资源下载奖励信息: </td>
                <td class="formTableTDValue">
                    <input type="input" name="ResourceAwardInfo" id="ResourceAwardInfo" value="<?php echo array_key_exists("ResourceAwardInfo", $editInfo)  ? $editInfo["ResourceAwardInfo"] : "" ?>" size="100" placeholder="可选,格式自定义,与前端沟通" />
                </td>
            </tr>
            <tr></tr>
            <tr>
                <td class="formTableTDName"></td>
                <td class="formTableTDValue">
                    <input type="submit" name="submit" align="center" value="提交" onclick="return CheckSubmit()" />
                </td>
            </tr>
            <input type="hidden" name="opType" id="opType" value="<?php echo $opType ?>" />
        </table>
    </form>
    <script type="text/javascript">
        function CheckSubmit() {
            if (!document.getElementById("VersionState").value || document.getElementById("VersionState").value <= 0) {
                alert("请输入大于0的状态值!");
                document.getElementById('VersionState').focus();
                return false;
            }
            if (!document.getElementById("StateName").value) {
                alert("请输入状态名称!");
                document.getElementById('StateName').focus();
                return false;
            }
            if (!document.getElementById("JsonBranch").value || document.getElementById("JsonBranch").value <= 0) {
                alert("请输入大于0选服Json分支!");
                document.getElementById('JsonBranch').focus();
                return false;
            }
            return true;
        }
    </script>
</body>
</html>