首页 > 其他分享 >1.29

1.29

时间:2024-02-28 21:26:38浏览次数:21  
标签:username const 1.29 error document data row

index.html

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
    <link rel="stylesheet" href="Style.css">
</head>
<body>
<div class="centered-form">
    <div class="bordered-form">
        <h1>用户登录</h1>
        <form id="login">
            <label for="username">用户名:</label><input type="text" id="username">
            <br>
            <label for="password">密码:</label><input type="password" id="password">
            <br>
            <div class="centered-buttons">
                <button type="submit" style="display: block; margin: 0 auto;">登录</button>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    document.getElementById("login").addEventListener("submit", function (event) {
        event.preventDefault();
        const username = document.getElementById("username").value;
        const password = document.getElementById("password").value;
        const url = `user/getByUser?username=${username}&password=${password}`;
        fetch(url, {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            }
        })
            .then(res => res.json())
            .then(data => {
                if (data.msg === 'success') {
                    let l=data.data.position;
                    if (l === '职员') {
                        window.location.href = "STAFF/staff.html?username=" + encodeURIComponent(username);
                    } else if (l === '部门经理') {
                        window.location.href = "MANAGE/manage.html?username=" + encodeURIComponent(username);
                    } else if (l === '总经理') {
                        window.location.href = "GENERAL/general.html?username=" + encodeURIComponent(username);
                    } else if (l === '财务人员') {
                        window.location.href = "FINANCIAL/financial.html?username=" + encodeURIComponent(username);
                    }
                } else {
                    alert("登录失败");
                    console.log(data);
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    });
</script>
</html>
复制代码

1.html

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>审批</title>
</head>
<body>
<h1 style="text-align: center">查询</h1>
<!--边框居中-->
<div class="centered-form">
    <!--    增加边框-->
    <div class="bordered-form">
        <!--        调整边框大小-->
        <div class="form">
            <div id="container">

            </div>
        </div>
    </div>
</div>
</body>
<script>
    var urlParams = new URLSearchParams(window.location.search);
    var username = urlParams.get('username');
    console.log("用户名为:" + username);
    const requestU = `http://localhost:8080/user/getName/${username}`;
    fetch(requestU,
        {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            },
        })
        .then(res => res.json())
        .then(data => {
            if (data.msg === 'success' && data.data != null) {
                console.log(data.data.userName);
                g2(data.data.department);
            } else {
                alert("未查询到此教师信息");
            }
        })
        .catch(error => {
            alert("请求失败,请重试");
            console.error(error);
        });
</script>
<script>
    function g2(data)
    {
        console.log(data);

        const requestU = `http://localhost:8080/user/Select1/${data}`;
        fetch(requestU,
            {
                method: 'GET',
                headers: {
                    'Content-Type': 'application/json'
                },
            })
            .then(res => res.json())
            .then(data => {
                if (data.msg === 'success' && data.data != null) {
                    generate(data.data);
                } else {
                    alert("未查询到此信息");
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    }
</script>
<script>
    function generate(data) {
        const tableContainer = document.getElementById("container");
        // 清空 tableContainer 中的所有子节点
        while (tableContainer.hasChildNodes()) {
            tableContainer.removeChild(tableContainer.firstChild);
        }
        const table = document.createElement("table");
        const tableBody = document.createElement("tbody");
        let row = document.createElement("tr");
        row.innerHTML = '<td>编号</td><td>报销日期</td><td>申请事由</td><td>申请状态</td><td>审批理由</td>';

        tableBody.appendChild(row);
        // 查询方式是按姓名查询或多条查询
        for (let i = 0; i < data.length; i++) {
            let s;
            row = document.createElement("tr");
            row.innerHTML = `<td>${data[i].id}</td><td>${data[i].departureDate}</td><td>${data[i].reason}</td><td>${data[i].state}</td><td>${data[i].stateReason}</td><td><button class="approveButton">审批通过</button></td><td><button class="rejectButton">审批不通过</button></td>`;
            tableBody.appendChild(row);
            table.appendChild(tableBody);
            tableContainer.appendChild(table);
        }
    }
</script>
<script>
    function updateStateInDatabase(id,state)
    {
        const requestUrl = `http://localhost:8080/user/updateById/${id}/${state}`;
        fetch(requestUrl, {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            },
        })
            .then(response => response.json())
            .then(data => {
                if (data.msg === 'success') {
                    alert("审核成功")
                } else {
                    alert("审核失败");
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    }
</script>
<script>

        const tableContainer = document.getElementById("container");
        tableContainer.addEventListener("click", function (event) {
        // 获取到点击事件的目标元素
        let target = event.target;
        // 向上遍历DOM树,找到具有相应类名的祖先元素
        while (target !== tableContainer && ![...target.classList].some(className => ["approveButton", "rejectButton"].includes(className))) {
        target = target.parentNode;
    }
        if (target.classList.contains("approveButton")) {
        // 点击了"审批通过"按钮
        const row = target.closest("tr");
        const stuId = row.querySelector("td:first-child").textContent;
        updateStateInDatabase(stuId,"通过");
        // display(); // 重新显示数据
    } else if (target.classList.contains("rejectButton")) {
        // 点击了"审批不通过"按钮
        const row = target.closest("tr");
        const stuId = row.querySelector("td:first-child").textContent;

        updateStateInDatabase(stuId, "返回");
    }
    });

</script>
</html>
复制代码

2.html

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>审批</title>
</head>
<body>
<h1 style="text-align: center">查询</h1>
<!--边框居中-->
<div class="centered-form">
    <!--    增加边框-->
    <div class="bordered-form">
        <!--        调整边框大小-->
        <div class="form">
            <div id="container">

            </div>
        </div>
    </div>
</div>
</body>
<script>
    var urlParams = new URLSearchParams(window.location.search);
    var username = urlParams.get('username');
    console.log("用户名为:" + username);
    const requestU = `http://localhost:8080/user/getName/${username}`;
    fetch(requestU,
        {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            },
        })
        .then(res => res.json())
        .then(data => {
            if (data.msg === 'success' && data.data != null) {
                console.log(data.data.userName);
                g2(data.data.department);
            } else {
                alert("未查询到此教师信息");
            }
        })
        .catch(error => {
            alert("请求失败,请重试");
            console.error(error);
        });
</script>
<script>
    function g2(data)
    {
        console.log(data);

        const requestU = `http://localhost:8080/user/Select1/${data}`;
        fetch(requestU,
            {
                method: 'GET',
                headers: {
                    'Content-Type': 'application/json'
                },
            })
            .then(res => res.json())
            .then(data => {
                if (data.msg === 'success' && data.data != null) {
                    generate(data.data);
                } else {
                    alert("未查询到此信息");
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    }
</script>
<script>
    function generate(data) {
        const tableContainer = document.getElementById("container");
        // 清空 tableContainer 中的所有子节点
        while (tableContainer.hasChildNodes()) {
            tableContainer.removeChild(tableContainer.firstChild);
        }
        const table = document.createElement("table");
        const tableBody = document.createElement("tbody");
        let row = document.createElement("tr");
        row.innerHTML = '<td>编号</td><td>报销日期</td><td>申请事由</td><td>申请状态</td><td>审批理由</td>';

        tableBody.appendChild(row);
        // 查询方式是按姓名查询或多条查询
        for (let i = 0; i < data.length; i++) {
            let s;
            row = document.createElement("tr");
            row.innerHTML = `<td>${data[i].id}</td><td>${data[i].departureDate}</td><td>${data[i].reason}</td><td>${data[i].schedule}</td><td>${data[i].scheduleReason}</td><td><button class="approveButton">审批通过</button></td><td><button class="rejectButton">审批不通过</button></td>`;
            tableBody.appendChild(row);
            table.appendChild(tableBody);
            tableContainer.appendChild(table);
        }
    }
</script>
<script>
    function updateStateInDatabase(id,state)
    {
        const requestUrl = `http://localhost:8080/user/updateById2/${id}/${state}`;
        fetch(requestUrl, {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            },
        })
            .then(response => response.json())
            .then(data => {
                if (data.msg === 'success') {
                    alert("审核成功")
                } else {
                    alert("审核失败");
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    }
</script>
<script>

    const tableContainer = document.getElementById("container");
    tableContainer.addEventListener("click", function (event) {
        // 获取到点击事件的目标元素
        let target = event.target;
        // 向上遍历DOM树,找到具有相应类名的祖先元素
        while (target !== tableContainer && ![...target.classList].some(className => ["approveButton", "rejectButton"].includes(className))) {
            target = target.parentNode;
        }
        if (target.classList.contains("approveButton")) {
            // 点击了"审批通过"按钮
            const row = target.closest("tr");
            const stuId = row.querySelector("td:first-child").textContent;
            updateStateInDatabase(stuId,"通过");
            // display(); // 重新显示数据
        } else if (target.classList.contains("rejectButton")) {
            // 点击了"审批不通过"按钮
            const row = target.closest("tr");
            const stuId = row.querySelector("td:first-child").textContent;

            updateStateInDatabase(stuId, "返回");
        }
    });

</script>
</html>
复制代码

manage.html

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>信息管理系统</title>
    <link rel="stylesheet" href="../Style.css">
</head>
<body>
<h1 style="text-align: center">职员管理系统</h1>
<script>
    // 获取URL中的用户名参数
    var urlParams = new URLSearchParams(window.location.search);
    var username = urlParams.get('username');
    console.log(username);
</script>
<div class="form">
    <table border="1px" cellspacing="0" width="600px">
        <tr>
            <th>编号</th>
            <th>功能</th>
        </tr>
        <tr>
            <td>1</td>
            <td>
                <button id="insert1">审批出差申请</button>
            </td>
        </tr>
        <tr>
            <td>2</td>
            <td>
                <button id="update1">审批差旅费报销</button>
            </td>
        </tr>
        <tr>
            <td>3</td>
            <td>
                <button id="delete">查询差旅费花费情况</button>
            </td>
        </tr>
        <tr>
            <td>4</td>
            <td>
                <button id="pay">出差申请</button>
            </td>
        </tr>
        <tr>
            <td>5</td>
            <td>
                <button id="update2">报销差旅费</button>
            </td>
        </tr>
        <tr>
            <td>6</td>
            <td>
                <button id="select1">查看出差申请</button>
            </td>
        </tr>
        <tr>
            <td>7</td>
            <td>
                <button id="select2">查看报销进度</button>
            </td>
        </tr>

    </table>
</div>
</body>
<script>
    document.getElementById("insert1").addEventListener("click", function () {
        window.location.href = "1.html?username=" + encodeURIComponent(username);
    });
    document.getElementById('update1').addEventListener('click', function () {
        window.location.href = "2.html?username=" + encodeURIComponent(username);
    })
    document.getElementById("delete").addEventListener("click", function () {
        window.location.href = "delete.html?username=" + encodeURIComponent(username);
    });
    document.getElementById("pay").addEventListener("click", function () {
        window.location.href = "../STAFF/1insert.html?username=" + encodeURIComponent(username);
    });
    document.getElementById('update2').addEventListener('click', function () {
        window.location.href = "../STAFF/pay.html?username=" + encodeURIComponent(username);
    })
    document.getElementById("select1").addEventListener("click", function () {
        window.location.href = "../STAFF/1select.html?username=" + encodeURIComponent(username);
    });
    document.getElementById("select2").addEventListener("click", function () {
        window.location.href = "../STAFF/2select.html?username=" + encodeURIComponent(username);
    });

</script>
</html>
复制代码

标签:username,const,1.29,error,document,data,row
From: https://www.cnblogs.com/gjsgjs/p/18041873

相关文章

  • 1.29
    HTML5添加了很多语义元素如下所示:标签描述<article>定义页面独立的内容区域。<aside>定义页面的侧边栏内容。<bdi>允许您设置一段文本,使其脱离其父元素的文本方向设置。<command>定义命令按钮,比如单选按钮、复选框或按钮<details>用于描述文档或文档某个部......
  • 1.29
    全局注册uni-app 支持配置全局组件,需在 main.js 里进行全局注册,注册后就可在所有页面里使用该组件。注意Vue.component的第一个参数必须是静态的字符串。nvue页面暂不支持全局组件。main.js 里进行全局导入和注册 importVuefrom'vue' importpageHeadfrom'......
  • 二机制安装Kubernetes 1.29 高可用集群(5)--node节点配置
    1.1所有k8s-node节点安装cri-dockerrpm-ivhcri-dockerd-0.3.10-3.el8.x86_64.rpm1.2修改cri-docker启动文件,将默认的pod启动镜像地址修改为国内仓库源#vi/usr/lib/systemd/system/cri-docker.service将如下部分ExecStart=/usr/bin/cri-dockerd--container-runtime-en......
  • 二机制安装Kubernetes 1.29 高可用集群(4)--master节点配置
    1.1在k8s-master01上解压kubernetes可执行文件到/usr/local/bin目录tar-zxfkubernetes-server-linux-amd64.tar.gz--strip-components=3-C/usr/local/binkubernetes/server/bin/kube{let,ctl,-apiserver,-controller-manager,-scheduler,-proxy}注:--strip-components=3......
  • 二机制安装Kubernetes 1.29 高可用集群(3)--etcd集群配置
    1.在所有etcd节点解压安装包tar-zxfetcd-v3.5.12-linux-amd64.tar.gzcpetcd-v3.5.12-linux-amd64/etcd/usr/local/bin/&&cpetcd-v3.5.12-linux-amd64/etcdctl/usr/local/bin/#查看版本信息#etcdctlversionetcdctlversion:3.5.12APIversion:3.52.1在所有et......
  • 二机制安装Kubernetes 1.29 高可用集群(2)--haproxy节点配置
    1.1在所有haproxy节点安装haproxyyum-yinstallhaproxy1.2在所有haproxy节点创建haproxy配置文件cat>/etc/haproxy/haproxy.cfg<<EOFglobalmaxconn3000ulimit-n16384log127.0.0.1local0errstatstimeout30sde......
  • 二机制安装Kubernetes 1.29 高可用集群(1)--系统初始配置
    软件环境描述说明:OS:openEuler22.03LTSSP3kubernetes:1.29.2etcd:3.5.12calico:3.27.0cri-docker:0.3.10cfssl/cfssljson/cfssl-certinfo:1.64haproxy:2.2.6keepalived:2.2.4网段规划:物理主机:192.168.83.0/24      ServiceIP:10.66.0.0/16   PodIP:172.31.0.0......
  • 二机制安装Kubernetes 1.29 高可用集群(6)--calico网络组件和CoreDNS配置
    1.部署Calico网络组件1.1k8s-master节点上下载calico的创建文件下载地址:https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstartwgethttps://raw.githubusercontent.com/projectcalico/calico/v3.27.2/manifests/tigera-operator.yamlwgethttps://ra......
  • 「Log」做题记录 2024.1.29-
    \(2024.1.1-2024.1.7\)\(\color{royalblue}{P5903}\)树上\(k\)级祖先模板,长链剖分。\(\color{blueviolet}{CF1009F}\)长链剖分优化DP板子,每次继承重子节点信息,指针处理下下标平移,剩余节点暴力合并,复杂度线性。\(\color{blueviolet}{P5904}\)长链剖分优化DP。设\(f_{i......
  • (2024.1.29-2024.2.4)C语言学习小结
    本周主要围绕《HeadfirstC》这本书展开C语言学习,按照计划,我学习了的内容。基本内容这周学习的内容像是上学期最后的内容的扩展、延申、深入,高级函数那块有点绕但慢慢啃下来还可以接受。以下是思维导图:遇到的问题与解决、经验教训等问题0(上周的问题这周才解决):看到书里......