python
입력창 리로드
bumychoi
2024. 5. 13. 19:38
{% 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: 300px;
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: 200px;
height: 30px;
}
.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;
}
.input {
width: 1600px;
background-color: rgb(222, 240, 164);
height: 350px;
/* display: none; */
}
.btn>button {
margin-left: auto;
margin-right: 10px;
width: 100px;
height: 50px;
}
tr {
cursor: pointer;
}
td {
width: auto;
}
.listclick {
border-color: blueviolet;
border-style: dashed;
box-shadow: 50cm;
border-width: 2px;
}
.form_in {
width: 1800px;
}
h4 {
background-color: rgb(239, 161, 43);
width: 400px;
margin-left: auto;
margin-right: auto;
text-align: center;
font-weight: 600;
font-style: italic;
}
</style>
<script>
let id
let idx
let clicked_id
let mv_id
$(document).ready(() => {
})
function input_list(idx) {
// console.log(idx)
let url = `/freight/d_list_input_list?list=${idx}`
fetch(url).then(res => res.json()).then(data => {
let rows = data['result1'];
$("#list_1").empty();
rows.forEach((row) => {
// console.log(row)
let id = row['id']
let list_id = row['list_id']
let number = row['number']
let tc_no = row['tc_no']
let bundle = row['bundle']
let offer = row['offer']
let gangjung = row['gangjung']
let size = row['size']
let mt = row['bunble_mt']
let hauju = row['hauju']
let temp_html2 = `<tr class=id_list id="${id}">
<td><input type="text" name="number" id="number">${number}</td>
<td><input type="text" name="tc_no" id="tc_no">${tc_no}</td>
<td><input type="text" name="huju" id="huju">${hauju}</td>
<td><input type="text" name="mt" id="mt">${mt}</td>
<td><input type="text" name="gangjung" id="gangjung">${gangjung}</td>
<td><input type="text" name="offer" id="offer">${offer}</td>
<td><input type="text" name="size" id="size">${size}</td>
<td>
<div class="btn-group">
<a href="#" class="btn btn-warning" aria-current="page">수정</a>
<a href="#" class="btn btn-danger">삭제</a>
</div>
</td>
</tr>
`
$('#list_1').append(temp_html2)
})
})
}
function d_list(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 name="hauju">${hauju}</td>
<td name="P_name">${p_name}</td>
<td name="offer">${offer}</td>
<td name="ganfjung">${gangjung}</td>
<td name="size">${size}</td>
<td name="bundle">${bundle}</td>
<td name="mt">${mt}</td>
<td name="storage">${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 name = data["mv_name"]
// console.log(name)
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 name="hauju">${hauju}</td>
<td name="P_name">${p_name}</td>
<td name="offer">${offer}</td>
<td name="gangjung">${gangjung}</td>
<td name="size">${size}</td>
<td name="bundle"style="text-align:right">${bundle}</td>
<td name="mt" style="text-align:right">${mt}</td>
<td name="storage">${storage}</td>
</tr>`
$("#list").append(temp_html)
})
})
}
}
function mv_click(id) {
mv_id = id
$(`#mv_mv`).text(`${id}`)
$(`.list-group`).addClass('clicked')
$(`#${id}`).removeClass('clicked')
d_list(id)
$(`.input`).hide();
}
function d_input(idx) {
let list_id = $('input[name=list_id]').val()
let number = $('input[name=number]').val()
let tc_no = $('input[name=tc_no]').val()
let bunble = $('input[name =bunble]').val()
let offer = $('input[name =offer]').val()
let gangjung = $('input[name=gangjung]').val()
let size = $('input[name=size]').val()
let hauju = $('input[name=hauju]').val()
let bunble_mt = $('input[name=mt]').val()
let formData = new FormData()
formData.append("list_id_give", list_id)
formData.append("number_give", number)
formData.append("tc_no_give", tc_no)
formData.append("bunble_give", bunble)
formData.append("offer_give", offer)
formData.append("gangjung_give", gangjung)
formData.append("size_give", size)
formData.append("hauju_give", hauju)
formData.append("bunble_mt_give", bunble_mt)
clicked_id = list_id
fetch('/freight/d_bar_input', { method: "POST", body: formData }).then(res => res.json()).then(data => {
alert(data["msg"])
})
list_click(clicked_id)
}
function list_click(idx) {
let msn = $(`#${idx}_add>td[name=msn]`).text()
let hauju = $(`#${idx}_add>td[name=hauju]`).text()
let p_name = $(`#${idx}_add>td[name=p_name]`).text()
let offer = $(`#${idx}_add>td[name=offer]`).text()
let bunble = $(`#${idx}_add>td[name=bundle]`).text()
let gangjung = $(`#${idx}_add>td[name=gangjung]`).text()
let size = $(`#${idx}_add>td[name=size]`).text()
let mt = $(`#${idx}_add>td[name=mt]`).text()
mt = Math.round(mt / bunble * 1000) / 1000
$('#mt').val(mt)
$('#hauju').val(hauju)
$('#gangjung').val(gangjung)
$('#offer').val(offer)
$('#size').val(size)
$(`#list_id`).val(idx)
$(`#number`).val('')
$(`#tc_no`).val(``)
$(`#bunble`).val('')
$(`.listclick`).removeClass('listclick')
$(`#${idx}_add`).addClass('listclick')
input_list(idx)
}
</script>
<header>
<div class="flex-row">
<div>
{% for d_list in d_lists %}
<a id="{{d_list._id}}" class="list-group" onclick="mv_click(`${id}`)" name="mv_name">{{d_list.date}}
{{d_list.mv_name}}</a>
{% endfor %}
</div>
<!-- <h1 id="nam">1</h1> -->
<div class=form_in>
<tr class=id_list id="id_list">
<td><input type="text" placeholder="전표번호" name="number" id="number"></td>
<td><input type="text" placeholder="차량번호" name="tc_no" id="tc_no"></td>
<td><input type="text" placeholder="수량" name="bunble" id="bunble"></td>
<td><input readonly type="text" placeholder="사이즈" name="size" id="size"></td>
<td><input readonly type="text" placeholder="강종" name="gangjung" id="gangjung"></td>
<td><input readonly type="text" placeholder="제강사" name="offer" id="offer"></td>
<td><input readonly type="text" placeholder="화주명" name="hauju" id="hauju"></td>
<td><input readonly type="text" placeholder="중량" name="mt" id="mt"></td>
<input type="hidden" name="list_id" id="list_id">`
<div class="btn">
<button type="button" class="btn btn-success" onclick="d_input(id)">입고</button>
</div>
</tr>
</div>
</div>
</header>
<body>
<div class="flex-col">
<div class="wrap bd-sidbar">
<table class="table" style="border: 8px blue;">
<thead class="table-primary">
<tr>
<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>
<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>
<table e class="table" style="border: 8px blue;">
<tbody class="table table-striped table">
<div>
</div>
</tbody>
</table>
</div>
</div>
<hr>
<h4>입 <sub style="font-size: 14px; color: red;">차량번호 & 수량만 <strong style="font-family: 900;">수정가능</strong></sub>고
</h4>
<div class="wrap bd-sidbar">
<table class="table" style="border: 8px blue;">
<thead class="table-primary">
<tr>
<th scope="col">전표번호</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">수정삭재</th>
</tr>
</thead>
<tbody class="table table-striped table" id=list_1 class="add-form">
<tr class=id_list id="id_list">
<td><input type="text" placeholder="전표번호" name="number" id="number"></td>
<td><input type="text" placeholder="차량번호" name="tc_no" id="tc_no"></td>
<td><input type="text" placeholder="수량" name="huju" id="huju"></td>
<td><input type="text" placeholder="중량" name="mt" id="mt"></td>
<td><input type="text" placeholder="강종" name="gangjung" id="gangjung"></td>
<td><input type="text" placeholder="제강사" name="offer" id="offer"></td>
<td><input type="text" placeholder="사이즈" name="size" id="size"></td>
<td>
<div class="btn-group">
<a href="#" class="btn btn-warning" aria-current="page">수정</a>
<a href="#" class="btn btn-danger">삭제</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</tr>
</div>
</body>
{% endblock %}
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')
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})
@bp.route('/d_bar_input',methods=['POST'])
def d_bar_input():
list_id_receive = request.form["list_id_give"]
number_receive = request.form["number_give"]
tc_no_receive = request.form["tc_no_give"]
bunble_receive = request.form["bunble_give"]
offer_receive = request.form["offer_give"]
gangjung_receive = request.form["gangjung_give"]
size_receive = request.form["size_give"]
hauju_receive = request.form["hauju_give"]
bunble_mt_recevive = request.form['bunble_mt_give']
doc ={
"list_id":list_id_receive,
"number":number_receive,
"tc_no":tc_no_receive,
"bunble":bunble_receive,
"offer":offer_receive,
"gangjung":gangjung_receive,
"size":size_receive,
"hauju":hauju_receive,
"bunble_mt":bunble_mt_recevive
}
db.d_input.insert_one(doc)
return jsonify({"msg":"저장완료"})
@bp.route('/d_list_input_list')
def d_list_input_list():
data = request.args.get('list')
input_lists = list(db.d_input.find({'list_id':data}))
for input_list in input_lists:
input_list["_id"] = str(input_list['_id'])
return jsonify({"result1":input_lists})