|
@ -42,7 +42,7 @@ |
|
|
<div class="wizard-container"><div> |
|
|
<div class="wizard-container"><div> |
|
|
<div class="inputs"> |
|
|
<div class="inputs"> |
|
|
<div id="form_area"> |
|
|
<div id="form_area"> |
|
|
<form id="prescription-form" onsubmit="submitForm(event)"> |
|
|
<form id="prescription-form" onsubmit="return false"> |
|
|
<input id="id" name="id" type="hidden" value="{$data.id}"> |
|
|
<input id="id" name="id" type="hidden" value="{$data.id}"> |
|
|
|
|
|
|
|
|
<div class="row"> </div> |
|
|
<div class="row"> </div> |
|
@ -68,6 +68,15 @@ |
|
|
|
|
|
|
|
|
<div class="row"> </div> |
|
|
<div class="row"> </div> |
|
|
|
|
|
|
|
|
|
|
|
<div class="row"> |
|
|
|
|
|
<label for="method">古方识别<font color='red'></font>:</label> |
|
|
|
|
|
<textarea rows="5" cols="70" id="shibie_text"></textarea> |
|
|
|
|
|
|
|
|
|
|
|
<button class="button info next" id="shibie_btn"><span class="tdesc_text" onclick="submitShibie(this)" style="color:white;">识别</span></button> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div class="row"> </div> |
|
|
|
|
|
|
|
|
<div class="row" style="position:relative;"> |
|
|
<div class="row" style="position:relative;"> |
|
|
<label>药材<font color='red'>*</font>:</label> |
|
|
<label>药材<font color='red'>*</font>:</label> |
|
|
<button class="add-button" type="button" onclick="addIngredient()">+</button> |
|
|
<button class="add-button" type="button" onclick="addIngredient()">+</button> |
|
@ -97,7 +106,7 @@ |
|
|
<div class="row" id="" style="position:relative;"> |
|
|
<div class="row" id="" style="position:relative;"> |
|
|
<label> </label> |
|
|
<label> </label> |
|
|
|
|
|
|
|
|
<button class="button primary next submitlock" id="submitbtn" onclick="submitForm()"><span class="tdesc_text" style="color:white;">提交</span></button> |
|
|
<button class="button primary next submitlock" id="submitbtn" onclick="submitForm(this)"><span class="tdesc_text" style="color:white;">提交</span></button> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="row"> </div> |
|
|
<div class="row"> </div> |
|
@ -157,12 +166,23 @@ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 动态添加药材输入字段 |
|
|
// 动态添加药材输入字段 |
|
|
function addIngredient() { |
|
|
function addIngredient(herb_name,herb_desc,herb_num) { |
|
|
const ingredientList = document.getElementById('ingredient-list'); |
|
|
const ingredientList = document.getElementById('ingredient-list'); |
|
|
const ingredientDiv = document.createElement('div'); |
|
|
const ingredientDiv = document.createElement('div'); |
|
|
ingredientDiv.classList.add('row'); |
|
|
ingredientDiv.classList.add('row'); |
|
|
|
|
|
|
|
|
ingredientDiv.innerHTML = ` |
|
|
if(herb_name){ |
|
|
|
|
|
ingredientDiv.innerHTML = ` |
|
|
|
|
|
<label> </label> |
|
|
|
|
|
<div class="herb_input"> |
|
|
|
|
|
<input type="text" name="herb_name[]" value="`+herb_name+`" placeholder="药材名" required /> |
|
|
|
|
|
<input type="text" name="herb_desc[]" value="`+herb_desc+`" placeholder="炮制方法"/> |
|
|
|
|
|
<input type="text" name="herb_num[]" value="`+herb_num+`" placeholder="药量" required /> |
|
|
|
|
|
<button class="" type="button" onclick="removeIngredient(this)">X</button> |
|
|
|
|
|
</div> |
|
|
|
|
|
`; |
|
|
|
|
|
}else{ |
|
|
|
|
|
ingredientDiv.innerHTML = ` |
|
|
<label> </label> |
|
|
<label> </label> |
|
|
<div class="herb_input"> |
|
|
<div class="herb_input"> |
|
|
<input type="text" name="herb_name[]" placeholder="药材名" required /> |
|
|
<input type="text" name="herb_name[]" placeholder="药材名" required /> |
|
@ -171,6 +191,8 @@ |
|
|
<button class="" type="button" onclick="removeIngredient(this)">X</button> |
|
|
<button class="" type="button" onclick="removeIngredient(this)">X</button> |
|
|
</div> |
|
|
</div> |
|
|
`; |
|
|
`; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ingredientList.appendChild(ingredientDiv); |
|
|
ingredientList.appendChild(ingredientDiv); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -179,8 +201,8 @@ |
|
|
button.parentElement.parentElement.remove(); |
|
|
button.parentElement.parentElement.remove(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function submitForm(e) { |
|
|
function submitForm(obj) { |
|
|
e.preventDefault(); // 阻止默认表单提交 |
|
|
obj.disabled = true; |
|
|
|
|
|
|
|
|
const form = document.getElementById('prescription-form'); |
|
|
const form = document.getElementById('prescription-form'); |
|
|
const formData = new FormData(form); |
|
|
const formData = new FormData(form); |
|
@ -230,6 +252,44 @@ |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
obj.disabled = false; |
|
|
|
|
|
showAlert(response.info) |
|
|
|
|
|
}, |
|
|
|
|
|
error: function (xhr, status, error) { |
|
|
|
|
|
console.error('错误:', response); |
|
|
|
|
|
alert('提交失败,请重试。'); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function submitShibie(obj) { |
|
|
|
|
|
obj.disabled = true; |
|
|
|
|
|
|
|
|
|
|
|
const original = document.getElementById('shibie_text').value; |
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
url: '/admin/ajax_shibie_original', // 替换为你的服务器端处理文件 |
|
|
|
|
|
type: 'POST', |
|
|
|
|
|
data: {original:original}, |
|
|
|
|
|
dataType: 'json', |
|
|
|
|
|
success: function (response) { |
|
|
|
|
|
obj.disabled = false; |
|
|
|
|
|
if (response.status == true) { |
|
|
|
|
|
if (Array.isArray(response.data)) { |
|
|
|
|
|
document.getElementById('ingredient-list').innerHTML = ''; |
|
|
|
|
|
response.data.forEach((row, index) => { |
|
|
|
|
|
addIngredient(row.herb_name,row.herb_desc,row.herb_num) |
|
|
|
|
|
}); |
|
|
|
|
|
}else{ |
|
|
|
|
|
console.log('识别失败') |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(response.data.code == 40002){ |
|
|
|
|
|
showAlert(response.info,"/admin/login") |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
showAlert(response.info) |
|
|
showAlert(response.info) |
|
|
}, |
|
|
}, |
|
|
error: function (xhr, status, error) { |
|
|
error: function (xhr, status, error) { |
|
|