首页 > 其他分享 >1.26

1.26

时间:2024-01-26 18:24:31浏览次数:29  
标签:const value getElementById error document data 1.26

1update.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改出差申请</title>
    <link rel="stylesheet" href="../Style.css">
</head>
<script>
    var urlParams = new URLSearchParams(window.location.search);
    var username = urlParams.get('username');
    console.log("用户名为:" + username);

    const requestUrl = `http://localhost:8080/user/getName/${username}`;
    fetch(requestUrl,
        {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            },
        })
        .then(response => response.json())
        .then(data => {
            if (data.msg === 'success') {
                document.getElementById('name').value = data.data.userName;
                document.getElementById('depart').value = data.data.department;
            } else {
                alert("查询失败");
            }
        })
        .catch(error => {
            alert("请求失败,请重试");
            console.error(error);
        });
</script>
<script>
    function generatePaperNumber() {
        const id = document.getElementById('paperNumber').value;
        const requestUrl = `http://localhost:8080/user/reasonable/${id}`;
        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>
<body>
<h1 style="text-align: center">修改出差申请</h1>
<!--边框居中-->
<div class="centered-form">
    <!--    增加边框-->
    <div class="bordered-form">
        <!--        调整边框大小-->
        <div class="form">
            <form id="addForm">
                <label for="paperNumber">出差编号:</label>
                <input type="text" id="paperNumber" name="paperNumber">
                <br>
                <br>
                <button type="button" style="display: block; margin: 0 auto;" onclick="generatePaperNumber()">检查合理性
                </button>
                <br>
                <label for="name">姓名:</label>
                <input type="text" id="name" name="name">
                <br>
                <br>
                <label for="depart">部门:</label>
                <input type="text" id="depart" name="depart">
                <br>
                <label for="dest">目的地:</label>
                <input type="text" id="dest" name="dest">
                <br>
                <label for="begin">出发日期:</label>
                <input type="datetime-local" id="begin" name="begin">
                <br>
                <label for="re">返回日期:</label>
                <input type="datetime-local" id="re" name="re">
                <br>
                出差类别:
                <div id="type">
                    <label><input type="radio" name="type" value="业务洽谈">业务洽谈</label>
                    <label><input type="radio" name="type" value="培训">培训</label>
                    <label><input type="radio" name="type" value="会议">会议</label>
                    <label>
                        <input type="radio" name="type" value="其他">其他
                        <input type="text" id="other" name="other">
                    </label>
                </div>
                <label for="reason">出差事由:</label>
                <br>
                <input type="text" id="reason" name="reason" style="width: 300px; height:300px"
                       required>
                <button type="submit" style="display: block; margin: 0 auto;">添加信息</button>
            </form>
        </div>
    </div>
</div>
</body>
<script>
    document.getElementById('addForm').addEventListener('submit', function (event) {
        event.preventDefault();
        const paperNumber = document.getElementById('paperNumber').value;
        const name = document.getElementById('name').value;
        const depart = document.getElementById('depart').value;
        const dest = document.getElementById('dest').value;
        const begin = document.getElementById('begin').value;
        const re = document.getElementById('re').value;
        const reason = document.getElementById('reason').value;
        const type = document.querySelectorAll('input[name="type"]');
        let t;
        type.forEach(radio => {
            if (radio.checked) {
                t = radio.value;
                console.log(t);
            }
        });
        let other1;
        let t1;
        if (t === "其他") {
            other1 = document.getElementById('other');
            t1 = "其他," + other1.value;
            console.log(other1.value);
        }
        const requestUrl = `http://localhost:8080/user/update1`;
        fetch(requestUrl,
            {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                    id: paperNumber,
                    name: name,
                    department: depart,
                    destination: dest,
                    departureDate: begin,
                    returnDate: re,
                    type: t,
                    typeContent: t1,
                    reason: reason,
                    state: "待审批"
                })
            })
            .then(res => res.json())
            .then(data => {
                if (data.msg === 'success') {
                    alert("出差信息添加成功!请等待审批");
                    console.log(data);
                } else {
                    alert("添加失败  " + data.msg);
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    });
</script>
</html>

2select.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.userName);
            } else {
                alert("未查询到此教师信息");
            }
        })
        .catch(error => {
            alert("请求失败,请重试");
            console.error(error);
        });
</script>
<script>
    function g2(data) {
        console.log(data);

        const requestU = `http://localhost:8080/user/SelectBao/${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>';

        tableBody.appendChild(row);
        // 查询方式是按姓名查询或多条查询
        for (let i = 0; i < data.length; i++) {
            let s;
            row = document.createElement("tr");
            row.innerHTML = `<td>${data[i].departureDate}</td><td>${data[i].reason}</td><td>${data[i].schedule}</td><td>${data[i].scheduleReason}</td>`;
            tableBody.appendChild(row);
            table.appendChild(tableBody);
            tableContainer.appendChild(table);
        }
    }
</script>
</html>

 

标签:const,value,getElementById,error,document,data,1.26
From: https://www.cnblogs.com/zzqq1314/p/17990428

相关文章

  • rke2 offline install kubernetes v1.26.12
    文章目录1.准备2.安装ansible3.基础配置3.1配置hosts3.2安装软件包3.3内核参数3.4连接数限制3.5关闭swap、selinux、防火墙3.6时间同步4.RKE2安装4.1下载安装4.2配置其他管理节点4.3新增worker节点1.准备7台主机主机名ipcpu内存diskos角色user密码kube-mast......
  • k8s1.26部署etcd集群挂载nfs failed to save Raft hard state and entries","error":"
    背景:使用helm部署apisix时会把etcd也一起部署了,etcd数据需要持久化的,这边因为测试环境使用nfs,挂载nfs时发现只有一个etcd节点启动正常其他两个均报错如下:failedtosaveRafthardstateandentries","error":"input/outputerror截图:排错过程:1查看节点是否都可以挂载nfs  ---......
  • KubeKey 离线部署 KubeSphere v3.4.1 和 K8s v1.26 实战指南
    作者:运维有术前言知识点定级:入门级了解清单(manifest)和制品(artifact)的概念掌握manifest清单的编写方法根据manifest清单制作artifactKubeKey离线集群配置文件编写KubeKey离线部署HarborKubeKey离线部署KubeSphere和K8sKubeKey离线部署常见问题排......
  • #6 2023.11.26
    395.arc140dOnetoOne原图是基环树森林。先把已知的边连上,会变成若干个基环树和若干个内向树。我们对环的期望数量计数。对于基环树,贡献显然为1。对于内向树,我们枚举大小的有序序列\(v_1,..,v_k\),贡献是\({1\overk}\prod{v_i\overn}\)。分治NTT算即可。396.a......
  • k8s 安装kubevirt v0.59.0 (k3s v1.26.4)
    1.安装kubevirt-operator.yaml(可以直接指定VERSION=v0.59.0-alpha.2;可以直接先在浏览器访问github下载yaml)exportVERSION=$(curl-shttps://api.github.com/repos/kubevirt/kubevirt/releases|greptag_name|grep-v--'-rc'|sort-r|head-1|awk-F':'&#......
  • 11.26-task5-条件
    条件if语句if(condition):后面为condition为trueelse:后面为false布尔表达式的使用:我们知道当布尔值为true是返回值为1,false时返回值为0他的返回值意思是:检查n是否为负数,若为负数n<0为true=1n>=0为false=0,+前面就为1*-n,+后就为0,为正数时逻辑相同ifelse推导式......
  • 2023.11.26——每日总结
    学习所花时间(包括上课):9h代码量(行):0行博客量(篇):1篇今天,上午学习,下午学习;我了解到的知识点:1.filter拦截器技术;明日计划:学习......
  • 2023.11.26 一周总结
    比赛11.24lxldsRound170+[spjfailed]+40=110,Rank2。自评:T1不过过啥题啊。没想到能用网络流做。后面两道题有点过于神秘了。11.25hez联考\(25+20+0=45\),Rank5。自评:T1不过过啥题啊。T1属于「不那么规整的构造」。打表发现最劣操作次数是远小于\(O......
  • 百度网盘(百度云)SVIP超级会员共享账号每日更新(2023.11.26)
    一、百度网盘SVIP超级会员共享账号可能很多人不懂这个共享账号是什么意思,小编在这里给大家做一下解答。我们多知道百度网盘很大的用处就是类似U盘,不同的人把文件上传到百度网盘,别人可以直接下载,避免了U盘的物理载体,直接在网上就实现文件传输。百度网盘SVIP会员可以让自己百度账......
  • 11.26每日总结
    1.将结果存在数据库中取用。 2.数据库表结构 3.源代码Equation类: publicclassEquation{ }  Compute类:packageCalculation;  publicclassComputeextendsJFrame{    } ......