@ -17,11 +17,35 @@
< / style >
< / style >
< script th:inline = "javascript" >
< script th:inline = "javascript" >
onload = function () {
onload = function () {
let detailList=[[${querydetail}]]
if(detailList){
console.info(detailList)
for(let index in detailList) {
let fff
if(index==="0") {
fff = document.querySelector('div[class="input-group mt-3 order-frame fff"]')
fff.innerHTML += getSelect()
}else{
plus()
fff = document.querySelector('div[class="input-group mt-3 order-frame fff"]:last-child')
}
let fenlei = fff.querySelector('select[name$=fenlei]')
fenlei.value = detailList[index].menu.fenlei
let pinmu = fenlei.parentElement.querySelector('select[name$=pinmu]')
let cailiao = fenlei.parentElement.querySelector('select[name$=cailiao]')
let zuofa = fenlei.parentElement.querySelector('input[name$=sum]')
changeFenLei(fenlei, pinmu, cailiao, detailList[index])
zuofa.value = detailList[index].sum
changePinmu(fenlei, pinmu, cailiao, detailList[index])
jine.value = [[${query.jine}]]
}
}else {
let item = document.getElementsByClassName('fff')
let item = document.getElementsByClassName('fff')
for (let i in item) {
for (let i in item) {
item[i].innerHTML += getSelect()
item[i].innerHTML += getSelect()
}
}
}
}
}
function getSelect() {
function getSelect() {
let fenlei = [[${fenlei}]]
let fenlei = [[${fenlei}]]
@ -31,26 +55,26 @@
}
}
let count=document.querySelectorAll('select[name$=cailiao]').length
let count=document.querySelectorAll('select[name$=cailiao]').length
return `< select class = "custom-select" name = "diancans[${count}].fenlei" onchange = "changeFenLei(this,this.parentElement.querySelector('select[name$=pinmu]'),this.parentElement.querySelector('select[name$=cailiao]'))" >
return `< select class = "custom-select" name = "diancans[${count}].fenlei" onchange = "changeFenLei(this,this.parentElement.querySelector('select[name$=pinmu]'),this.parentElement.querySelector('select[name$=cailiao]'))" >
< option selected > 请选择分类< / option >
< option value = "" > 请选择分类< / option >
${fenleistr}
${fenleistr}
< / select >
< / select >
< select class = "custom-select" name = "diancans[${count}].pinmu" onchange = "changePinmu(this.parentElement.querySelector('select[name$=fenlei]'),this,this.parentElement.querySelector('select[name$=cailiao]'))" >
< select class = "custom-select" name = "diancans[${count}].pinmu" onchange = "changePinmu(this.parentElement.querySelector('select[name$=fenlei]'),this,this.parentElement.querySelector('select[name$=cailiao]'))" >
< option selected > 请选择品目< / option >
< option value = "" > 请选择品目< / option >
< / select >
< / select >
< select class = "custom-select" name = "diancans[${count}].cailiao" required oninvalid = "setCustomValidity('请选择材料')" onchange = "changeCailiao(document.querySelectorAll('select[name$=cailiao]'))" >
< select class = "custom-select" name = "diancans[${count}].cailiao" required oninvalid = "setCustomValidity('请选择材料')" onchange = "changeCailiao(document.querySelectorAll('select[name$=cailiao]'))" >
< option selected value = "" > 请选择材料< / option >
< option value = "" > 请选择材料< / option >
< / select >
< / select >
< input type = "text" class = "form-control" name = "diancans[${count}].sum" placeholder = "做法或数量" onchange = "changeCailiao(document.querySelectorAll('select[name$=cailiao]'))" oninput = "changeCailiao(document.querySelectorAll('select[name$=cailiao]'))" > `
< input type = "text" class = "form-control" name = "diancans[${count}].sum" placeholder = "做法或数量" onchange = "changeCailiao(document.querySelectorAll('select[name$=cailiao]'))" oninput = "changeCailiao(document.querySelectorAll('select[name$=cailiao]'))" > `
}
}
function plus(s ) {
function plus() {
let div = document.createElement('div')
let div = document.createElement('div')
div.classList.add('input-group', 'mt-3', 'order-frame')
div.classList.add('input-group', 'mt-3', 'order-frame','fff' )
div.innerHTML = `< div class = "col-3 text-right mt-auto mb-auto" >
div.innerHTML = `< div class = "col-3 text-right mt-auto mb-auto" >
< img src = "/icon/plus.svg" class = "icon action" onclick = "plus(this )" / >
< img src = "/icon/plus.svg" class = "icon action" onclick = "plus()" / >
< img src = "/icon/minus.svg" class = "icon action" onclick = "minus(this)" / >
< img src = "/icon/minus.svg" class = "icon action" onclick = "minus(this)" / >
< / div >
< / div >
${getSelect()}
${getSelect()}
@ -70,12 +94,16 @@
changeCailiao(document.querySelectorAll('select[name$=cailiao]'))
changeCailiao(document.querySelectorAll('select[name$=cailiao]'))
}
}
function changeFenLei(fenlei, pinmu, cailiao) {
function changeFenLei(fenlei, pinmu, cailiao,item ) {
pinmu.innerHTML = '< option selected > 请选择品目< / option > '
pinmu.innerHTML = '< option value = "" > 请选择品目< / option > '
cailiao.innerHTML = '< option selected > 请选择材料< / option > '
cailiao.innerHTML = '< option value = "" > 请选择材料< / option > '
fetch(new Request('/api/getPinMu?fenlei=' + fenlei.value)).then(res => res.json()).then(res => {
fetch(new Request('/api/getPinMu?fenlei=' + fenlei.value)).then(res => res.json()).then(res => {
for (let index in res) {
for (let index in res) {
pinmu.innerHTML += `< option > ${res[index]}< / option > `
if(item& & res[index]===item.menu.pinmu) {
pinmu.innerHTML += `< option selected value = "${res[index]}" > ${res[index]}< / option > `
} else {
pinmu.innerHTML += `< option value = "${res[index]}" > ${res[index]}< / option > `
}
}
}
})
})
let sum=fenlei.parentElement.querySelector('input[name$=sum]')
let sum=fenlei.parentElement.querySelector('input[name$=sum]')
@ -89,12 +117,17 @@
changeCailiao(document.querySelectorAll('select[name$=cailiao]'))
changeCailiao(document.querySelectorAll('select[name$=cailiao]'))
}
}
function changePinmu(fenlei, pinmu, cailiao) {
function changePinmu(fenlei, pinmu, cailiao,item) {
cailiao.innerHTML = '< option selected > 请选择材料< / option > '
cailiao.innerHTML = '< option value = "" > 请选择材料< / option > '
fetch(new Request(`/api/getMenu?fenlei=${fenlei.value}& pinmu=${pinmu.value}`)).then(res => res.json()).then(res => {
let pinmuval=item?item.menu.pinmu:pinmu.value
fetch(new Request(`/api/getMenu?fenlei=${fenlei.value}& pinmu=${pinmuval}`)).then(res => res.json()).then(res => {
for (let index in res) {
for (let index in res) {
if(item& & res[index].id===item.menu.id) {
cailiao.innerHTML += `< option selected value = "${res[index].id}" jine = "${res[index].jiage}" > ${res[index].cailiao}< / option > `
}else{
cailiao.innerHTML += `< option value = "${res[index].id}" jine = "${res[index].jiage}" > ${res[index].cailiao}< / option > `
cailiao.innerHTML += `< option value = "${res[index].id}" jine = "${res[index].jiage}" > ${res[index].cailiao}< / option > `
}
}
}
})
})
changeCailiao(document.querySelectorAll('select[name$=cailiao]'))
changeCailiao(document.querySelectorAll('select[name$=cailiao]'))
@ -151,18 +184,18 @@
< div class = "container" >
< div class = "container" >
< div class = "frame" >
< div class = "frame" >
< span th:text = "${span_name}" > < / span >
< span th:text = "${span_name}" > < / span >
< form method = "post" action = "/api/order" >
< form method = "post" action = "/api/order" th:object = "${query}" >
< div class = "input-group mt-3" >
< div class = "input-group mt-3" >
< div class = "input-group-prepend col-3 pr-2 justify-content-end" >
< div class = "input-group-prepend col-3 pr-2 justify-content-end" >
< span class = "input-group-text" > 桌号< / span >
< span class = "input-group-text" > 桌号< / span >
< / div >
< / div >
< input type = "text" name = "zhuohao" class = "form-control col-4" required oninvalid = "setCustomValidity('桌号不能为空')" oninput = "setCustomValidity('');hasYuding(this)" >
< input type = "text" th:field = "*{zhuohao}" th:readonly = "*{ zhuohao ne null} " class = "form-control col-4" required oninvalid = "setCustomValidity('桌号不能为空')" oninput = "setCustomValidity('');hasYuding(this)" >
< div class = "invalid-feedback mt-3 mb-3 text-center font-weight-bold" > 桌号已预定< / div >
< div class = "invalid-feedback mt-3 mb-3 text-center font-weight-bold" > 桌号已预定< / div >
< div class = "input-group-prepend col-3 pr-2 justify-content-end" >
< div class = "input-group-prepend col-3 pr-2 justify-content-end" >
< span class = "input-group-text" > 客人姓名< / span >
< span class = "input-group-text" > 客人姓名< / span >
< / div >
< / div >
< input type = "text" name = "xingming" class = "form-control col-4" oninvalid = "setCustomValidity('姓名不能为空')" oninput = "setCustomValidity('');" required maxlength = "15" >
< input type = "text" th:field = "*{ xingming} " class = "form-control col-4" oninvalid = "setCustomValidity('姓名不能为空')" oninput = "setCustomValidity('');" required maxlength = "15" >
< / div >
< / div >
< div class = "input-group mt-3" >
< div class = "input-group mt-3" >
@ -170,16 +203,16 @@
< span class = "input-group-text" > 用餐时间< / span >
< span class = "input-group-text" > 用餐时间< / span >
< / div >
< / div >
< div class = "custom-control custom-radio custom-control-inline mt-auto mb-auto" >
< div class = "custom-control custom-radio custom-control-inline mt-auto mb-auto" >
< input type = "radio" id = "customRadioInline1" name = "birthday" checked
< input type = "radio" id = "customRadioInline1" name = "birthday"
class="custom-control-input" value="1" onclick="birthdayValid(this.parentElement.parentElement.querySelector('input[name=shijian]'))">
class="custom-control-input" value="1" th:checked="*{birthday eq null}" onclick="birthdayValid(this.parentElement.parentElement.querySelector('input[name=shijian]'))">
< label class = "custom-control-label" for = "customRadioInline1" > 及时单< / label >
< label class = "custom-control-label" for = "customRadioInline1" > 及时单< / label >
< / div >
< / div >
< div class = "custom-control custom-radio custom-control-inline mt-auto mb-auto" >
< div class = "custom-control custom-radio custom-control-inline mt-auto mb-auto" >
< input type = "radio" id = "customRadioInline2" value = "2" name = "birthday" class = "custom-control-input" onclick = "changeBirthday(this.parentElement.parentElement.querySelector('input[name=shijian]'))" >
< input type = "radio" id = "customRadioInline2" value = "2" th:checked = "*{birthday ne null}" name = "birthday" class = "custom-control-input" onclick = "changeBirthday(this.parentElement.parentElement.querySelector('input[name=shijian]'))" >
< label class = "custom-control-label" for = "customRadioInline2" > 指定< / label >
< label class = "custom-control-label" for = "customRadioInline2" > 指定< / label >
< / div >
< / div >
< input type = "text" name = "shijian" oninput = "setCustomValidity('')" oninvalid = "setCustomValidity('时间不能为空')" class = "form-control col-4" >
< input type = "text" th:value = "${#dates.format(query.birthday, 'yyyyMMdd HHmm')}" name = "shijian" oninput = "setCustomValidity('')" oninvalid = "setCustomValidity('时间不能为空')" class = "form-control col-4" >
< / div >
< / div >
< div class = "input-group mt-3" >
< div class = "input-group mt-3" >
@ -187,7 +220,7 @@
< span class = "input-group-text" > 用餐人数< / span >
< span class = "input-group-text" > 用餐人数< / span >
< / div >
< / div >
< input type = "number" value = "1" name = "renshu" class = "form-control col-4" >
< input type = "number" th:field = "*{ renshu} " class = "form-control col-4" >
< / div >
< / div >
< div class = "input-group mt-3" >
< div class = "input-group mt-3" >
@ -195,7 +228,7 @@
< span class = "input-group-text" > 联系方式(手机)< / span >
< span class = "input-group-text" > 联系方式(手机)< / span >
< / div >
< / div >
< input type = "text" name = "tel" oninput = "checkMobie()" class = "form-control col-4" >
< input type = "text" th:field = "*{ tel} " oninput = "checkMobie()" class = "form-control col-4" >
< / div >
< / div >
< div class = "input-group mt-3 order-frame fff" >
< div class = "input-group mt-3 order-frame fff" >
@ -207,12 +240,12 @@
< div id = "list" >
< div id = "list" >
< div class = "input-group mt-3 order-frame d-none" id = "add" >
< div class = "input-group mt-3 order-frame d-none" id = "add" >
< div class = "col-3 text-right mt-auto mb-auto" >
< div class = "col-3 text-right mt-auto mb-auto" >
< img src = "/icon/plus.svg" class = "icon action" onclick = "plus(this )" / >
< img src = "/icon/plus.svg" class = "icon action" onclick = "plus()" / >
< / div >
< / div >
< / div >
< / div >
< div class = "input-group mt-3 order-frame fff" >
< div class = "input-group mt-3 order-frame fff" th:if = "${querydetail} eq null" >
< div class = "col-3 text-right mt-auto mb-auto" >
< div class = "col-3 text-right mt-auto mb-auto" >
< img src = "/icon/plus.svg" class = "icon action" onclick = "plus(this )" / >
< img src = "/icon/plus.svg" class = "icon action" onclick = "plus()" / >
< img src = "/icon/minus.svg" class = "icon action" onclick = "minus(this)" / >
< img src = "/icon/minus.svg" class = "icon action" onclick = "minus(this)" / >
< / div >
< / div >
< / div >
< / div >
@ -229,7 +262,7 @@
< div class = "input-group-prepend" >
< div class = "input-group-prepend" >
< span class = "input-group-text" > 备注< / span >
< span class = "input-group-text" > 备注< / span >
< / div >
< / div >
< textarea class = "form-control" name = "beizhu" aria-label = "With textarea" > < / textarea >
< textarea class = "form-control" th:field = "*{ beizhu} " aria-label = "With textarea" > < / textarea >
< / div >
< / div >
< div class = "mt-3 text-right" >
< div class = "mt-3 text-right" >
< button class = "btn btn-secondary col-3" > 提交< / button >
< button class = "btn btn-secondary col-3" > 提交< / button >