diff --git a/view/templates/admin/formula_add.html b/view/templates/admin/formula_add.html index 42aec48..e9ce61c 100644 --- a/view/templates/admin/formula_add.html +++ b/view/templates/admin/formula_add.html @@ -68,15 +68,6 @@ <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;"> <label>药材<font color='red'>*</font>:</label> <button class="add-button" type="button" onclick="addIngredient()">+</button> @@ -123,7 +114,8 @@ <!-- 批量上传 <div id="onetickupload"></div> --> </div> </div> - <textarea cols="200" rows="20" style="margin-top: 20px"></textarea> + <textarea cols="100" rows="10" style="margin-top: 20px" id="shibie_text"></textarea> + <button class="button info next" style="margin-top: 20px" id="shibie_btn" onclick="submitShibie(this)" >识别</button> <!--end of main section--> </div><!--end of container--> </section><!--end of #page--> @@ -262,18 +254,21 @@ }); } - function submitShibie(obj) { - obj.disabled = true; - - const original = document.getElementById('shibie_text').value; + function submitShibie() { + const text = document.getElementById('shibie_text').value; + const lines = text.split('\n'); + let name = lines[0]; + let original = lines[1]; + let method = lines[2]; + document.getElementById('name').value = name; + document.getElementById('method').value = method; $.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 = ''; @@ -281,7 +276,7 @@ addIngredient(row.herb_name,row.herb_desc,row.herb_num) }); }else{ - console.log('识别失败') + showAlert('识别失败') } return true; }