1.27

2update.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/examine/${id}`;
        fetch(requestUrl,
            {
                method: 'GET',
                headers: {
                    'Content-Type': 'application/json'
                },
            })
            .then(response => response.json())
            .then(data => {
                if (data.data != null) {
                    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>
                <label for="reason">出差事由:</label>
                <br>
                <input type="text" id="reason" name="reason" style="width: 300px; height:300px"
                       required>
                <br>
                <label for="go">出发车费:</label>
                <input type="text" id="go" name="go"
                       required>
                <br>
                <label for="return1">返回车费:</label>
                <input type="text" id="return1" name="return1"
                       required>
                <br>
                <label for="eat">伙食补助:</label>
                <input type="text" id="eat" name="eat"
                       required>
                <br>
                <label for="public1">公杂补助:</label>
                <input type="text" id="public1" name="public1"
                       required>
                <br>
                <label for="live">住宿费:</label>
                <input type="text" id="live" name="live"
                       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 go = parseFloat(document.getElementById('go').value) || 0;
        const return1 = parseFloat(document.getElementById('return1').value) || 0;
        const eat = parseFloat(document.getElementById('eat').value) || 0;
        const public1 = parseFloat(document.getElementById('public1').value) || 0;
        const live = parseFloat(document.getElementById('live').value) || 0;

        const total = go + return1 + eat + public1 + live;

        console.log(total+" "+paperNumber);

        const requestUrl = `http://localhost:8080/user/update2`;
        fetch(requestUrl,
            {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                    id: paperNumber,
                    name: name,
                    department: depart,
                    destination: dest,
                    departureDate: begin,
                    returnDate: re,
                    Reason: reason,
                    StartFare: go,
                    ReturnFare: return1,
                    foodAllowance: eat,
                    localTrans: public1,
                    Accommodation: live,
                    totalAmount: total,
                    schedule: '待审批',
                })
            })
            .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>

delete.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>撤销出差申请</title>
    <link rel="stylesheet" href="../Style.css">
</head>
<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>
                <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 requestUrl = `http://localhost:8080/user/delete/${paperNumber}`;
        fetch(requestUrl,
            {
                method: 'DELETE',
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .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>

pay.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() {
        var currentDate = new Date();
        var year = currentDate.getFullYear();
        let id = year;
        let count;
        const requestUrl = `http://localhost:8080/user/pay1/${id}`;
        fetch(requestUrl,
            {
                method: 'GET',
                headers: {
                    'Content-Type': 'application/json'
                },
            })
            .then(response => response.json())
            .then(data => {
                if (data != null) {
                    console.log(data);
                    count = data;
                    count = count + 1;
                    count = count.toString().padStart(4, '0');
                    id = id + count;
                    document.getElementById('paperNumber').value = id;
                } 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" readonly>
                <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>
                <label for="reason">出差事由:</label>
                <br>
                <input type="text" id="reason" name="reason" style="width: 300px; height:300px"
                       required>
                <br>
                <label for="go">出发车费:</label>
                <input type="text" id="go" name="go"
                       required>
                <br>
                <label for="return1">返回车费:</label>
                <input type="text" id="return1" name="return1"
                       required>
                <br>
                <label for="eat">伙食补助:</label>
                <input type="text" id="eat" name="eat"
                       required>
                <br>
                <label for="public1">公杂补助:</label>
                <input type="text" id="public1" name="public1"
                       required>
                <br>
                <label for="live">住宿费:</label>
                <input type="text" id="live" name="live"
                       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 go = document.getElementById('go').value;
        // const return1 = document.getElementById('return1').value;
        // const eat = document.getElementById('eat').value;
        // const public1 = document.getElementById('public1').value;
        // const live = document.getElementById('live').value;
        // const total = go + return1 + eat + public1 + live;
        const go = parseFloat(document.getElementById('go').value) || 0;
        const return1 = parseFloat(document.getElementById('return1').value) || 0;
        const eat = parseFloat(document.getElementById('eat').value) || 0;
        const public1 = parseFloat(document.getElementById('public1').value) || 0;
        const live = parseFloat(document.getElementById('live').value) || 0;

        const total = go + return1 + eat + public1 + live;

        console.log(total+" "+paperNumber);

        const requestUrl = `http://localhost:8080/user/add2`;
        fetch(requestUrl,
            {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                    id: paperNumber,
                    name: name,
                    department: depart,
                    destination: dest,
                    departureDate: begin,
                    returnDate: re,
                    reason: reason,
                    StartFare: go,
                    ReturnFare: return1,
                    foodAllowance: eat,
                    localTrans: public1,
                    Accommodation: live,
                    totalAmount: total,
                    schedule: '待审批',
                })
            })
            .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>

staff.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 = "1insert.html?username=" + encodeURIComponent(username);
    });
    document.getElementById('update1').addEventListener('click', function () {
        window.location.href = "1update.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 = "pay.html?username=" + encodeURIComponent(username);
    });
    document.getElementById('update2').addEventListener('click', function () {
        window.location.href = "2update.html?username=" + encodeURIComponent(username);
    })
    document.getElementById("select1").addEventListener("click", function () {
        window.location.href = "1select.html?username=" + encodeURIComponent(username);
    });
    document.getElementById("select2").addEventListener("click", function () {
        window.location.href = "2select.html?username=" + encodeURIComponent(username);
    });

</script>
</html>

 

posted @ 2024-01-27 18:28  七安。  阅读(15)  评论(0编辑  收藏  举报