首页 > 其他分享 >1.29

1.29

时间:2024-01-29 19:45:01浏览次数: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/zzqq1314/p/17995201

相关文章

  • 1.29闲话
    科技改变生活!出现了传说中的考勤装置,并且一个人一个人录制面部aaaaaaaa请正视摄像头,请稳一点,请近一点,请远一点,请将面部置于框内,登记成功......xxx已签到纪要是记事类的,闲话是不知道什么类的存娘的歌非常好听感觉,但是存娘也开始用AI依了推歌:二十三/洛天依byJUSF周存子曰:"......
  • 1.29 深痛教训 关于 unsigned
    unsignedlonglong无符号长长整型,常用于比longlong大一倍的整数范围或自然溢出\(\bmod2^{64}\)unsignedlonglong范围为\(0\sim2^{64}-1\),而longlong是\(-2^{63}\sim2^{63}-1\),同时,unsignedlonglong是自动对\(2^{64}\)取模,也叫自然溢出,在特定题目尤其哈希......
  • 离线部署K8s V1.29.1版本
    准备私用的系统ISO镜像为:CentOS-7-x86_64-Everything-1908.iso安装方式为带GUI的服务器架构说明K8s集群规划VIP:192.168.24.2        通过keepalived提供harbor:镜像仓库、nfs、ntp        连接外网;        内网地址:192.168.24.5k8s-master0:......
  • 大二打卡(11.29)
    今天做了什么:清晨八点,我准时从睡梦中醒来。拉开窗帘,阳光透过窗户洒在我的床上,温暖而明亮。我迅速洗漱完毕,坐在书桌前,开始了今天的第一个任务——背诵英语听写的单词和短语。这已经是我连续第三天早起背单词了。每次大约半个小时,虽然时间不长,但效果还不错。今天的单词和短语不算......
  • Kubernetes v1.29 新特性一览
     Kubernetesv1.29新特性一览大纲 一、Core组件增强 调度器增强 在Kubernetesv1.29中,Core组件经历了一系列增强,其中一个重要的改进是调度器的增强。这些增强使得调度器能够更加智能和高效地管理容器的调度和分配。通过引入新的调度算法和策略,调度器能够更好地适应不同的资源......
  • 11.29
    final关键字:final关键字,意思是最终的、不可修改的,最见不得变化,用来修饰类、方法和变量,具有以下特点:修饰类:类不能继承,final类中的所有成员方法都会被隐式的指定为final方法;修饰符变量:该变量为常量,,如果是基本数据类型的变量,则其数值一旦在初始化之后便不能更改;如果是引用类......
  • 11.29
    《代码大全2》是一本非常有价值的软件开发类书籍,它深入浅出地介绍了软件开发过程中的各个环节和技术要点。作者以通俗易懂的语言,结合大量实例和案例,系统地阐述了软件开发的基本原理和方法,对于初学者和有一定经验的开发者都具有很大的借鉴意义。在阅读本书的过程中,我深刻体会到了......
  • 11.29
    今日学习内容<%--CreatedbyIntelliJIDEA.User:qq316TochangethistemplateuseFile|Settings|FileTemplates.--%><%@pagecontentType="text/html;charset=UTF-8"language="java"%><html><head><title>......
  • 11.29
    石家庄铁道大学选课管理系统1、项目需求:本项目所开发的学生选课系统完成学校对学生的选课信息的统计与管理,减少数据漏掉的情况,同时也节约人力、物力和财力。告别以往的人工统计。2.系统要求与功能设计2.1 页面要求(1)能够在Tomcat服务器中正确部署,并通过浏览器查看;(2)网站页面......
  • 11.29
    SELECT*fromAWHEREidin(SELECTidfromB)SELECT*fromAWHEREidEXISTS(SELECT1fromA.id=B.id)in是在内存中遍历比较exist需要查询数据库,所以当B的数据量比较大时,exists效率优于in.in()只执行一次,把B表中的所有id字段缓存起来,之后检查A表的id是否与......