상세 컨텐츠

본문 제목

입고페이지

카테고리 없음

by bumychoi 2024. 5. 4. 12:37

본문

from main import *
from flask import Blueprint
from bson.objectid import ObjectId

bp = Blueprint("freight", __name__, url_prefix='/freight')

@bp.route("/")
def freight():
    d_lists = list(db.mv.find({"cago_name": "철근"}))
    return render_template("freight.html",d_lists=d_lists,title="철근상세")

@bp.route('/d_bar_lists',methods=['GET'])
def d_bar_lists():
    data = request.args.get('data')
    # mv_lists = list(db.mv.find({'_id': ObjectId(data)}))
    print(data)
    d_details = list(db.d_list.find({'mv_id':data}))
    for d_detail in d_details:
        d_detail["_id"] = str(d_detail['_id'])

    return jsonify({"result": d_details})
{% extends "main.html" %}
{% block contents %}

<style>
    html,
    body,
    h1,
    h2,
    h3,
    div,
    span,
    a,
    button,
    table,
    tbody,
    thead,
    input {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    header {
        background-color: hsl(57, 95%, 60%);
    }

    body {
        min-height: 110%;
        background-color: hsl(186, 77%, 74%);
    }

    .clicked {
        background-color: rgb(59, 62, 147);
        /* border-radius: 20%; */
        color: rgb(232, 132, 37);
        display: flex;
        text-align: start;
        flex-direction: column;
        width: 150px;
    }

    .clicked>ul>span {
        text-align: center;
    }

    .btn btn-warning {
        margin: 0;
        padding: 0;
    }

    ol,
    ul {
        padding: 4px 4px 4px 4px;
        /* margin: auto; */
    }

    /* .btn btn-secondary btn-lg {
        zoom: 0.5;
        margin: 0;
        padding: 0;
    } */
    .wrap {
        /* background-color: chartreuse; */
        width: 1600px;
        height: 850px;
        margin: auto;
        border: 1px;
    }

    td>input {
        border: none;
    }

    th>input {
        border: none;
    }

    tr {
        cursor: pointer;
    }

    td>button {
        zoom: 0.65;
    }

    .total {

        height: 800px;

    }

    table {
        width: 1200px;
        table-layout: fixed;
    }

    .flex-row {
        display: flex;
        flex-direction: row;
        align-items: flex-start
            /* justify-content: center; */
    }

    .flex-col {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .list-group {
        background-color: rgb(13, 170, 233);
        color: white;
        width: 200px;
    }

    .list-group>ul {
        height: 650px;
    }

    .list-group>ul>li {
        height: 30px;
    }

    tr {
        width: 1000px;
    }

    .add-form>td {
        background-color: rgb(173, 214, 243);
    }

    .clicked {
        background-color: azure;
        color: blue;
        width: 180px;
        height: 50px;
    }

    .sum {
        margin-right: 10px;
        margin-left: auto;
        background-color: rgb(212, 250, 130);
        font-size: 20px;
        font-weight: 500;
        padding: auto;
        border: 1.5px solid rgb(13, 59, 132);
    }

    .sum>span {
        /* border: 1.5px solid rgb(13, 59, 132); */
        margin-left: 2px;
    }
</style>
<script>
    $(document).ready(() => {
        d_list()
    })
    function d_list(id) {
        console.log(id)
        if (id == undefined) {
            fetch(`/freight/d_bar_lists`).then(res => res.json()).then(data => {
                let rows = data['result'];
                $("#list").empty();
                rows.forEach((row) => {
                    let id = row['_id']
                    let msn = row['msn']
                    let hauju = row['hauju']
                    let p_name = row['p_name']
                    let offer = row['offer']
                    let gangjung = row['gangjung']
                    let size = row['size']
                    let bundle = row['bundle']
                    let mt = row['mt']
                    let storage = row['storage']
                    let mv_id = row['mv_id']
                    let temp_html = ` <tr id='${id}_add' onclick="list_click('${id}')">
                                        <td name="msn">${msn}</td>
                                        <td>${hauju}</td>
                                        <td>${p_name}</td>
                                        <td>${offer}</td>
                                        <td>${gangjung}</td>
                                        <td>${size}</td>
                                        <td>${bundle}</td>
                                        <td>${mt}</td>
                                        <td>${storage}</td>  
                                    </tr>`

                    $("#list").append(temp_html)
                })

            })
        }
        else {
            let url = `/freight/d_bar_lists?data=${id}`
            fetch(url).then(res => res.json()).then(data => {
                let rows = data['result'];
                $("#list").empty();
                rows.forEach((row) => {
                    let id = row['_id']
                    let msn = row['msn']
                    let hauju = row['hauju']
                    let p_name = row['p_name']
                    let offer = row['offer']
                    let gangjung = row['gangjung']
                    let size = row['size']
                    let bundle = row['bundle']
                    let mt = row['mt']
                    let storage = row['storage']
                    let mv_id = row['mv_id']
                    let temp_html = ` <tr id='${id}_add' onclick="list_click('${id}')">
                                        <td name="msn">${msn}</td>
                                        <td>${hauju}</td>
                                        <td>${p_name}</td>
                                        <td>${offer}</td>
                                        <td>${gangjung}</td>
                                        <td>${size}</td>
                                        <td>${bundle}</td>
                                        <td>${mt}</td>
                                        <td>${storage}</td>  
                                    </tr>`

                    $("#list").append(temp_html)
                })
            })
        }
    }

    function mv_click(id) {
        $(`#mv_mv`).text(`${id}>a`)
        d_list(id)
    }

</script>
<header>
    <div class="flex-row">
        <div>
            <h1>입고</h1>
        </div>
        <div class="dropdown">
            <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown"
                aria-expanded="false">
                본선선택
            </button>
            <ul class="dropdown-menu">
                {% for d_list in d_lists %}
                <li><a id="{{d_list._id}}" class="list-group" onclick="mv_click(`${id}` )">{{d_list.date}}
                        {{d_list.mv_name}}</a></li>
                {% endfor %}
            </ul>
        </div>
    </div>
</header>

<body>
    <div class="flex-col">
        <div>
            본선내역
        </div>
        <div>
            <span id="mv_mv">mv</span>
        </div>
        <div class="wrap">
            <table class="table" style="border: 8px blue;">
                <thead class="table-primary">
                    <tr>
                        <!-- <th>모선명</th> -->
                        <th scope="col">MSN</th>
                        <th scope="col">화주명</th>
                        <th scope="col">품명</th>
                        <th scope="col">제강사</th>
                        <th scope="col">강종</th>
                        <th scope="col">싸이즈</th>
                        <th scope="col">총수량(B/D)</th>
                        <th scope="col">총중량(M/T)</th>
                        <th scope="col">입고창고</th>

                    </tr>
                </thead>
                <tbody class="table table-striped table" id=list class="add-form">
                    <tr class="add-form_1" id="add-form_1" style="background-color: aqua;">
                        <td><input type="text" placeholder="MSN" name="msn"></td>
                        <td><input type="text" placeholder="화주명" name="hauju"></td>
                        <td><input type="text" placeholder="세부품명" value="d_bar" name="p_name"></td>
                        <td><input type="text" placeholder="제강사" name="offer"></td>
                        <td><input type="text" placeholder="강 종" name="gangjung"></td>
                        <td><input type="text" placeholder="싸이즈" name="size"></td>
                        <td><input type="text" placeholder="수 량" name="bundle"></td>
                        <td><input type="text" placeholder="톤수" name="mt"></td>
                        <td><input type="text" placeholder="창고코드" name="storage"></td>
                        </td>
                    </tr>
                </tbody>
            </table>
            <div>
                입고내역
            </div>
        </div>
</body>
{% endblock %}