Browse Source

药品与诊疗的编辑与删除功能开发完成

hurugang 4 years ago
parent
commit
9183e0ada4

+ 115 - 14
src/main/java/cn/hnthyy/thmz/controller/mz/YpZdClassController.java

@@ -16,8 +16,9 @@ public class YpZdClassController {
     @Autowired
     private YpZdClassService ypZdClassService;
 
+
     /**
-     * 查询所有药品、检验、检查的分类
+     * 查询所有药品分类
      *
      * @return
      */
@@ -33,10 +34,44 @@ public class YpZdClassController {
             } else {
                 treeList = getYpZdClassTreeList(ypZdClasses);
             }
+            List<Map<String, Object>> fullTree = new ArrayList<>();
+            if(treeList!=null){
+                Map<String, Object> parentMap = new HashMap<>();
+                fullTree.add(parentMap);
+                //初始化时不知道自己有子节点,所以设置为非父节点
+                parentMap.put("isParent", true);
+                parentMap.put("id", 1);
+                parentMap.put("name", "西成药");
+                parentMap.put("children", treeList);
+            }
+            resultMap.put("code", 0);
+            resultMap.put("message", "查询所有的分类成功");
+            resultMap.put("data", fullTree);
+            return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("查询所有药品分类失败,错误信息{}", e.getMessage());
+            resultMap.put("code", -1);
+            resultMap.put("message", "查询所有药品分类失败,错误原因【" + e.getMessage() + "】");
+            return resultMap;
+        }
+    }
 
+
+
+    /**
+     * 查询所有检验、检查的分类
+     *
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/getJyJcZdClasses", method = {RequestMethod.GET})
+    public Map<String, Object> getJyJcZdClasses() {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
             List<Map<String, Object>> jyZdClasses = ypZdClassService.queryJyZdClasses();
             List<Map<String, Object>> jyTreeList = null;
-            if (ypZdClasses == null || ypZdClasses.size() == 0) {
+            if (jyZdClasses == null || jyZdClasses.size() == 0) {
                 log.info("未查询到检验分类");
             } else {
                 jyTreeList = getJyZdClassTreeList(jyZdClasses);
@@ -50,15 +85,6 @@ public class YpZdClassController {
                 jcTreeList = getJcZdClassTreeList(jcZdClasses);
             }
             List<Map<String, Object>> fullTree = new ArrayList<>();
-            if(treeList!=null){
-                Map<String, Object> parentMap = new HashMap<>();
-                fullTree.add(parentMap);
-                //初始化时不知道自己有子节点,所以设置为非父节点
-                parentMap.put("isParent", true);
-                parentMap.put("id", 1);
-                parentMap.put("name", "西成药");
-                parentMap.put("children", treeList);
-            }
             if(jyTreeList!=null){
                 Map<String, Object> parentMap = new HashMap<>();
                 fullTree.add(parentMap);
@@ -83,13 +109,88 @@ public class YpZdClassController {
             return resultMap;
         } catch (Exception e) {
             e.printStackTrace();
-            log.error("查询所有药品、检验、检查的分类失败,错误信息{}", e.getMessage());
+            log.error("查询所有检验、检查的分类失败,错误信息{}", e.getMessage());
             resultMap.put("code", -1);
-            resultMap.put("message", "查询所有药品、检验、检查的分类失败,错误原因【" + e.getMessage() + "】");
+            resultMap.put("message", "查询所有检验、检查的分类失败,错误原因【" + e.getMessage() + "】");
             return resultMap;
         }
     }
 
+
+//    /**
+//     * 查询所有药品、检验、检查的分类
+//     *
+//     * @return
+//     */
+//    @UserLoginToken
+//    @RequestMapping(value = "/getYpZdClasses", method = {RequestMethod.GET})
+//    public Map<String, Object> getYpZdClasses() {
+//        Map<String, Object> resultMap = new HashMap<>();
+//        try {
+//            List<YpZdClass> ypZdClasses = ypZdClassService.queryYpZdClasses();
+//            List<Map<String, Object>> treeList = null;
+//            if (ypZdClasses == null || ypZdClasses.size() == 0) {
+//                log.info("未查询到药品分类");
+//            } else {
+//                treeList = getYpZdClassTreeList(ypZdClasses);
+//            }
+//
+//            List<Map<String, Object>> jyZdClasses = ypZdClassService.queryJyZdClasses();
+//            List<Map<String, Object>> jyTreeList = null;
+//            if (jyZdClasses == null || jyZdClasses.size() == 0) {
+//                log.info("未查询到检验分类");
+//            } else {
+//                jyTreeList = getJyZdClassTreeList(jyZdClasses);
+//            }
+//
+//            List<Map<String, Object>> jcZdClasses = ypZdClassService.queryJcZdClasses();
+//            List<Map<String, Object>> jcTreeList = null;
+//            if (jcZdClasses == null || jcZdClasses.size() == 0) {
+//                log.info("未查询到检查分类");
+//            } else {
+//                jcTreeList = getJcZdClassTreeList(jcZdClasses);
+//            }
+//            List<Map<String, Object>> fullTree = new ArrayList<>();
+//            if(treeList!=null){
+//                Map<String, Object> parentMap = new HashMap<>();
+//                fullTree.add(parentMap);
+//                //初始化时不知道自己有子节点,所以设置为非父节点
+//                parentMap.put("isParent", true);
+//                parentMap.put("id", 1);
+//                parentMap.put("name", "西成药");
+//                parentMap.put("children", treeList);
+//            }
+//            if(jyTreeList!=null){
+//                Map<String, Object> parentMap = new HashMap<>();
+//                fullTree.add(parentMap);
+//                //初始化时不知道自己有子节点,所以设置为非父节点
+//                parentMap.put("isParent", true);
+//                parentMap.put("id", 2);
+//                parentMap.put("name", "检验项目");
+//                parentMap.put("children", jyTreeList);
+//            }
+//            if(jcTreeList!=null){
+//                Map<String, Object> parentMap = new HashMap<>();
+//                fullTree.add(parentMap);
+//                //初始化时不知道自己有子节点,所以设置为非父节点
+//                parentMap.put("isParent", true);
+//                parentMap.put("id", 3);
+//                parentMap.put("name", "检查项目");
+//                parentMap.put("children", jcTreeList);
+//            }
+//            resultMap.put("code", 0);
+//            resultMap.put("message", "查询所有的分类成功");
+//            resultMap.put("data", fullTree);
+//            return resultMap;
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            log.error("查询所有药品、检验、检查的分类失败,错误信息{}", e.getMessage());
+//            resultMap.put("code", -1);
+//            resultMap.put("message", "查询所有药品、检验、检查的分类失败,错误原因【" + e.getMessage() + "】");
+//            return resultMap;
+//        }
+//    }
+
     /**
      * 获取药品字典树
      *
@@ -217,7 +318,7 @@ public class YpZdClassController {
             String xlCode = (String) jcZdClass.get("xl_code");
             String xlName = (String) jcZdClass.get("xl_name");
             //父编码是2位数 说明是一级树
-            if(dlCode.length()==2){
+            if(dlCode.length()==2 && !dlCode.equals(currentGrandParentDlCode)){
                 grandParentMap = new HashMap<>();
                 treeList.add(grandParentMap);
                 //初始化时不知道自己有子节点,所以设置为非父节点

+ 1 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/zd/MzZdYpYshMapper.java

@@ -26,7 +26,7 @@ public interface MzZdYpYshMapper {
             "    FROM view_mz_zd_yp_ysh(nolock) ",
             "where  stock_amount_virtual <![CDATA[>]]> 0 and (case when bill_code='TC' or group_no='00' then  '71' else group_no end)=#{groupNo}  ",
             "<when test='commonParams!=null'>",
-            " and (py_code like #{commonParams} or d_code  like #{commonParams} or code like #{commonParams} or name like #{commonParams} ",
+            " and (py_code like #{commonParams} or d_code  like #{commonParams} or code like #{commonParams} or name like #{commonParams} or class_code like #{commonParams}",
             "<when test='letterParamsLowerCase!=null'>",
             " or py_code like #{letterParamsLowerCase} or d_code  like #{letterParamsLowerCase} or code like #{letterParamsLowerCase} or name like #{letterParamsLowerCase}  ",
             "</when>",

+ 15 - 1
src/main/resources/static/js/common/message.js

@@ -41,4 +41,18 @@ function errorMesageSimaple(message) {
         hide: true,
         styling: 'bootstrap3'
     });
-}
+}
+
+/**
+ * 警告消息处理
+ * @param result
+ */
+function warningMesageSimaple(message) {
+    new PNotify({
+        title: '错误提示',
+        text: message,
+        hide: true,
+        styling: 'bootstrap3'
+    });
+}
+

+ 585 - 100
src/main/resources/static/js/mz/clinic.js

@@ -128,6 +128,34 @@ $(function () {
     initNavTabs(0);
     //初始医生工作太配置
     initWorkspaceConfigForCurrent();
+
+    /**
+     * 西药点击事件
+     */
+    $("#western_medicine_name").on("click", function (t) {
+        var obj = $("#westernMedicinePopoverContent").parent().parent().parent();
+        if ($(obj).hasClass("in") || $(obj).css("display") == "block") {
+            $('#western_medicine_name').webuiPopover('hide');
+            $("#treeButton").webuiPopover('hide');
+            return;
+        }
+        $('#western_medicine_name').webuiPopover('show');
+        loadYpList(0);
+    });
+
+    /**
+     * 项目点击事件
+     */
+    $("#jcJyItem").on("click", function (t) {
+        if ($("#jcJyItemPopoverContent").parent().parent().parent().hasClass("in")) {
+            $('#jcJyItem').webuiPopover('hide');
+            $("#treeButton").webuiPopover('hide');
+            return;
+        }
+        $('#jcJyItem').webuiPopover('show');
+        loadjcJyItemList();
+    });
+
 });
 
 /**
@@ -193,11 +221,11 @@ function groupIdChange() {
             //天数
             $("#dayNum").selectpicker('val', dayNum);
             $('#dayNum').selectpicker('refresh');
-           // $("#dayNum").attr("disabled", "disabled");
+            // $("#dayNum").attr("disabled", "disabled");
             //频次编码
             $("#orderFrequency").selectpicker('val', orderFrequency);
             $('#orderFrequency').selectpicker('refresh');
-          //  $("#orderFrequency").attr("disabled", "disabled");
+            //  $("#orderFrequency").attr("disabled", "disabled");
         }
     }
 }
@@ -1382,20 +1410,6 @@ function initZySupplyTypes(id) {
 function changeDate(ev) {
 }
 
-/**
- * 列表类型按钮切换事件
- * @param object
- */
-function titleButtonChange(object) {
-    $("#regi_List_btn_group").find("button").each(function (index, element) {
-        if ($(element).hasClass("btn-primary")) {
-            $(element).removeClass("btn-primary").addClass("btn-default");
-        }
-    });
-    $(object).removeClass("btn-default").addClass("btn-primary");
-    loadRegistrationList(true);
-}
-
 
 /**
  * 表格类型切换事件  卡片展示或者列表形式
@@ -1477,6 +1491,8 @@ function saveWesternMedicine() {
     var medicalAdvice = $("#medicalAdvice").val();
     //金额
     var totalRetprice = parseFloat($("#totalRetprice").val());
+    //单价
+    var packRetprice = $("#packRetprice").val();
     if (currentCode == null || currentCode == '') {
         errorMesageSimaple("未选择任何药品!");
         return;
@@ -1493,22 +1509,77 @@ function saveWesternMedicine() {
     if (medicalAdvice != null && medicalAdvice != '') {
         html += '医嘱:' + medicalAdvice;
     }
-    html += ' <i class="fa fa-long-arrow-left" style="cursor: pointer;height: 20px;line-height: 20px;width: 30px;font-size: 20px;"></i>';
-    html += '<i class="fa fa-remove" style="cursor: pointer;height: 20px;line-height: 20px;width: 30px;font-size: 20px;"></i>';
+    html += ' <i class="fa fa-long-arrow-left" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;margin-left: 10px;" onclick="editWesternMedicine(this)"></i>';
+    html += '<i class="fa fa-remove" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;margin-left: 10px;" onclick="removeYpOrProject(0,this)"></i>';
     html += '<input type="hidden" class="temporary_items_code" value="' + currentCode + '"/>';
     html += '<input type="hidden" class="temporary_items_serial" value="' + currentSerial + '"/>';
     html += '<input type="hidden" class="temporary_items_amount" value="' + totalRetprice + '"/>';
+    html += '<input type="hidden" class="temporary_items_groupId" value="' + groupId + '"/>';
+    html += '<input type="hidden" class="temporary_items_westernMedicineNamme" value="' + westernMedicineNamme + '"/>';
+    html += '<input type="hidden" class="temporary_items_drugWinDb" value="' + drugWinDb + '"/>';
+    html += '<input type="hidden" class="temporary_items_drugWin" value="' + drugWin + '"/>';
+    html += '<input type="hidden" class="temporary_items_drugWinUnit" value="' + drugWinUnit + '"/>';
+    html += '<input type="hidden" class="temporary_items_gross" value="' + gross + '"/>';
+    html += '<input type="hidden" class="temporary_items_packUnit" value="' + packUnit + '"/>';
+    html += '<input type="hidden" class="temporary_items_supplyType" value="' + supplyType + '"/>';
+    html += '<input type="hidden" class="temporary_items_orderFrequency" value="' + orderFrequency + '"/>';
+    html += '<input type="hidden" class="temporary_items_dayNum" value="' + dayNum + '"/>';
+    html += '<input type="hidden" class="temporary_items_medicalAdvice" value="' + medicalAdvice + '"/>';
+    html += '<input type="hidden" class="temporary_items_packRetprice" value="' + packRetprice + '"/>';
     html += '</div>';
 
     var tableId = $("#xyTab li.active").find("a").attr("href");
-    $(tableId).find("div:eq(0)").append(html);
-    //设置单张处方金额
-    var cfAmount = $(tableId).find("span.cf_amount").html();
-    if (cfAmount != null && cfAmount != "") {
-        cfAmount = parseFloat($(tableId).find("span.cf_amount").html());
+    var temporaryItemsAmount = 0;
+    //是新增药品还是编辑 true 修改 默认false
+    var updateFlag = $("#update_flag").val();
+    if (updateFlag == undefined || updateFlag == null) {
+        updateFlag = false;
     }
-    cfAmount = Add(cfAmount, totalRetprice);
-    $(tableId).find("span.cf_amount").html(cfAmount);
+    //原药品金额 如果是修改则需要设置
+    var temporaryItemsAmount = 0;
+    //当前需要被移除元素的下个兄弟节点
+    var nextObj = null;
+    //当前修改的药品是不是最后一个
+    var isLast = false;
+    var formGroups = $(tableId).find("div.cf_content").find("div.form-group");
+    if (formGroups != null && formGroups.length > 0) {
+        //如果是修改,需要减去原来的费用
+        if (updateFlag=="true" || updateFlag==true) {
+            for (var i = 0; i < formGroups.length; i++) {
+                var temporaryItemsCode = $(formGroups[i]).find("input.temporary_items_code").val();
+                var temporaryItemsSerial = $(formGroups[i]).find("input.temporary_items_serial").val();
+                if (temporaryItemsCode === currentCode && temporaryItemsSerial === currentSerial) {
+                    temporaryItemsAmount = $(formGroups[i]).find("input.temporary_items_amount").val();
+                    if (formGroups.length > 1) {
+                        nextObj = $(formGroups[i]).next();
+                    }
+                    isLast = (i + 1) === formGroups.length;
+                    $(formGroups[i]).remove();
+                    break;
+                }
+            }
+        }else {
+            //因为药品可以换组号,要保证相同组号的在一起
+            for (var i = 0; i < formGroups.length; i++) {
+                var temporaryItemsGroupId = parseInt($(formGroups[i]).find("input.temporary_items_groupId").val());
+                //如果当前的组号小与遍历到的组号,说明是原组号的下一个兄弟节点,新的药品插入到兄弟节点前就可以了
+                if (temporaryItemsGroupId > groupId) {
+                    nextObj = $(formGroups[i]);
+                    break;
+                }
+            }
+        }
+    }
+
+
+    //当没有下一个兄弟节点或者当前编辑的药品是最后一个时,直接添加
+    if (nextObj == null || isLast) {
+        $(tableId).find("div:eq(0)").append(html);
+    } else {
+        $(nextObj).before(html);
+    }
+    //设置当前处方金额
+    calculateCfAmount(tableId, totalRetprice, temporaryItemsAmount, 0, 0);
     //设置总金额
     calculateTotalAmount();
     //判断当前组号是不是最后一个,是最后一个组号,就需要新增组号
@@ -1528,6 +1599,145 @@ function saveWesternMedicine() {
     clearWesternMedicine(false);
 }
 
+/**
+ * 上移
+ * @param obj
+ */
+function arrowUp(obj){
+    var parentObject = $(obj).parent();
+    if($(parentObject).prev()==null){
+        return;
+    }
+    //当前元素的序号
+    var thisJcjyItemGroupId=null;
+    //前一个兄弟节点的序号
+    var prevJcjyItemGroupId=null;
+    //当是项目时有序号,进行序号调整
+    if($(parentObject).find("span.jcjyItemGroupId")!=null){
+        thisJcjyItemGroupId=$(parentObject).find("span.jcjyItemGroupId").html();
+        prevJcjyItemGroupId=$(parentObject).prev().find("span.jcjyItemGroupId").html();
+        $(parentObject).find("span.jcjyItemGroupId").html(prevJcjyItemGroupId);
+        $(parentObject).prev().find("span.jcjyItemGroupId").html(thisJcjyItemGroupId);
+    }
+    $(parentObject).prev().before($(parentObject));
+}
+
+/**
+ * 下移
+ * @param obj
+ */
+function arrowDown(obj){
+    var parentObject = $(obj).parent();
+    if($(parentObject).next()==null){
+        return;
+    }
+    //当前元素的序号
+    var thisJcjyItemGroupId=null;
+    //后一个兄弟节点的序号
+    var afterJcjyItemGroupId=null;
+    //当是项目时有序号,进行序号调整
+    if($(parentObject).find("span.jcjyItemGroupId")!=null){
+        thisJcjyItemGroupId=$(parentObject).find("span.jcjyItemGroupId").html();
+        afterJcjyItemGroupId=$(parentObject).after().find("span.jcjyItemGroupId").html();
+        $(parentObject).find("span.jcjyItemGroupId").html(afterJcjyItemGroupId);
+        $(parentObject).after().find("span.jcjyItemGroupId").html(thisJcjyItemGroupId);
+    }
+    $(parentObject).next().after($(parentObject));
+}
+
+/**
+ * 修改西药
+ * @param obj
+ */
+function editWesternMedicine(obj) {
+    //是新增药品还是编辑 true 修改 默认false
+    $("#update_flag").val(true);
+    var parentObject = $(obj).parent();
+    //组号
+    $("#groupId").val($(parentObject).find("input.temporary_items_groupId").val());
+    $('#groupId').selectpicker('refresh');
+    //药品名称
+    $("#western_medicine_name").val($(parentObject).find("input.temporary_items_westernMedicineNamme").val());
+    //当前药品编码
+    $("#current_code").val($(parentObject).find("input.temporary_items_code").val());
+    //当前药品规格
+    $("#current_serial").val($(parentObject).find("input.temporary_items_serial").val());
+    //用法编码
+    $("#supplyType").val($(parentObject).find("input.temporary_items_supplyType").val());
+    $('#supplyType').selectpicker('refresh');
+
+    //药品默认单次使用剂量
+    $("#drugWinDb").val($(parentObject).find("input.temporary_items_drugWinDb").val());
+    //处方实际单次使用剂量
+    $("#drugWin").val($(parentObject).find("input.temporary_items_drugWin").val());
+    //剂量单位
+    $("#drugWinUnit").val($(parentObject).find("input.temporary_items_drugWinUnit").val());
+    $('#drugWinUnit').selectpicker('refresh');
+    //天数
+    $("#dayNum").val($(parentObject).find("input.temporary_items_dayNum").val());
+    $('#dayNum').selectpicker('refresh');
+    //频次编码
+    $("#orderFrequency").val($(parentObject).find("input.temporary_items_orderFrequency").val());
+    $('#orderFrequency').selectpicker('refresh');
+    //总量
+    $("#gross").val($(parentObject).find("input.temporary_items_gross").val());
+    //包装单位
+    $("#packUnit").val($(parentObject).find("input.temporary_items_packUnit").val());
+    $('#packUnit').selectpicker('refresh');
+    //医嘱
+    $("#medicalAdvice").val($(parentObject).find("input.temporary_items_medicalAdvice").val());
+    //金额
+    $("#totalRetprice").val($(parentObject).find("input.temporary_items_amount").val());
+    //单价
+    $("#packRetprice").val($(parentObject).find("input.temporary_items_packRetprice").val());
+}
+
+
+/**
+ * 修改中药
+ * @param obj
+ */
+function editChineseMedicine(obj) {
+    //是新增药品还是编辑 true 修改 默认false
+    $("#update_flag").val(true);
+    var parentObject = $(obj).parent();
+    //当前药品编码
+    $("#current_code").val($(parentObject).find("input.temporary_items_code").val());
+    //当前药品规格
+    $("#current_serial").val($(parentObject).find("input.temporary_items_serial").val());
+    //中药类型
+    $("#zyClassType").val($(parentObject).find("input.temporary_items_zyClassType").val());
+    $('#zyClassType').selectpicker('refresh');
+    //药品名称
+    $("#chinese_medicine_name").val($(parentObject).find("input.temporary_items_chineseMedicineNamme").val());
+    //单价
+    $("#zy_packRetprice").val($(parentObject).find("input.temporary_items_zyPackRetprice").val());
+    //处方实际单次使用剂量
+    $("#zy_drugWin").val($(parentObject).find("input.temporary_items_drugWin").val());
+    //医嘱码
+    $("#zyInstruction").val($(parentObject).find("input.temporary_items_zyInstruction").val());
+    $('#zyInstruction').selectpicker('refresh');
+
+}
+
+
+/**
+ * 修改项目
+ * @param obj
+ */
+function editJyJcItem(obj) {
+    //是新增药品还是编辑 true 修改 默认false
+    $("#update_flag").val(true);
+    var parentObject = $(obj).parent();
+    //当前项目编码
+    $("#current_code").val($(parentObject).find("input.temporary_items_code").val());
+    //项目名称
+    $("#jcJyItem").val($(parentObject).find("input.temporary_items_jcJyItemName").val());
+    //单价
+    $("#jcjyItemPrice").val($(parentObject).find("input.temporary_items_amount").val());
+    //备注
+    $("#remark").val($(parentObject).find("input.temporary_items_remark").val());
+}
 
 /**
  * 保存当前项目到右边处方区域
@@ -1537,9 +1747,9 @@ function saveJyJcItem() {
     var tableId = $("#zlTab li.active").find("a").attr("href");
     //组号
     var groupId = $(tableId).find("div:eq(0)").children().length + 1;
-    //药品名称
+    //项目名称
     var jcJyItem = $("#jcJyItem").val();
-    //当前药品编码
+    //当前项目编码
     var currentCode = $("#current_code").val();
     //当前项目价格
     var jcjyItemPrice = $("#jcjyItemPrice").val();
@@ -1550,36 +1760,91 @@ function saveJyJcItem() {
         return;
     }
     var html = '<div class="form-group">';
-    html += groupId + '.&nbsp;&nbsp;';
+    html+='<span class="jcjyItemGroupId">'+groupId+'</span>.&nbsp;&nbsp;'
     html += jcJyItem + ' ';
     if (remark != null && remark != '') {
         html += '备注:' + remark;
     }
-    html += ' <i class="fa fa-long-arrow-left" style="cursor: pointer;height: 20px;line-height: 20px;width: 30px;font-size: 20px;"></i>';
-    html += '<i class="fa fa-remove" style="cursor: pointer;height: 20px;line-height: 20px;width: 30px;font-size: 20px;"></i>';
-    html += '<i class="fa fa-eye" style="cursor: pointer;height: 20px;line-height: 20px;width: 30px;font-size: 20px;" onclick="getJcJyItemChargeByCode(\'' + currentCode + '\')"></i>';
+    html += ' <i class="fa fa-long-arrow-up" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;margin-left: 10px;" onclick="arrowUp(this)"></i>';
+    html += '<i class="fa fa-long-arrow-down" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;" onclick="arrowDown(this)"></i>';
+    html += ' <i class="fa fa-long-arrow-left" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;" onclick="editJyJcItem(this)"></i>';
+    html += '<i class="fa fa-remove" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;margin-left: 10px;" onclick="removeYpOrProject(2,this)"></i>';
+    html += '<i class="fa fa-eye" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;" onclick="getJcJyItemChargeByCode(\'' + currentCode + '\')"></i>';
     html += '<input type="hidden" class="temporary_items_code" value="' + currentCode + '"/>';
+    html += '<input type="hidden" class="temporary_items_jcJyItemName" value="' + jcJyItem + '"/>';
     html += '<input type="hidden" class="temporary_items_amount" value="' + jcjyItemPrice + '"/>';
+    html += '<input type="hidden" class="temporary_items_remark" value="' + remark + '"/>';
     html += '</div>';
-    $(tableId).find("div:eq(0)").append(html);
-    //设置单张处方金额
-    var cfAmount = $(tableId).find("span.cf_amount").html();
-    if (cfAmount != null && cfAmount != "") {
-        cfAmount = parseFloat($(tableId).find("span.cf_amount").html());
+
+    //原药品金额 如果是修改则需要设置
+    var temporaryItemsAmount = 0;
+    //当前需要被移除元素的下个兄弟节点
+    var nextObj = null;
+    //当前修改的药品是不是最后一个
+    var isLast = false;
+    //是新增药品还是编辑 true 修改 默认false
+    var updateFlag = $("#update_flag").val();
+    if (updateFlag == undefined || updateFlag == null) {
+        updateFlag = false;
     }
-    cfAmount = Add(cfAmount, jcjyItemPrice);
-    $(tableId).find("span.cf_amount").html(cfAmount);
+    //如果是修改,需要减去原来的费用
+    if (updateFlag=="true" || updateFlag==true) {
+        var formGroups = $(tableId).find("div.cf_content").find("div.form-group");
+        if (formGroups != null && formGroups.length > 0) {
+            for (var i = 0; i < formGroups.length; i++) {
+                var temporaryItemsCode = $(formGroups[i]).find("input.temporary_items_code").val();
+                if (temporaryItemsCode === currentCode) {
+                    temporaryItemsAmount = $(formGroups[i]).find("input.temporary_items_amount").val();
+                    if (formGroups.length > 1) {
+                        nextObj = $(formGroups[i]).next();
+                    }
+                    isLast = (i + 1) === formGroups.length;
+                    $(formGroups[i]).remove();
+                    break;
+                }
+            }
+        }
+    }
+    //当没有下一个兄弟节点或者当前编辑的药品是最后一个时,直接添加
+    if (nextObj == null || isLast) {
+        $(tableId).find("div:eq(0)").append(html);
+    } else {
+        $(nextObj).before(html);
+    }
+    //设置当前处方金额
+    calculateCfAmount(tableId, jcjyItemPrice, temporaryItemsAmount, 2, 0);
     //设置总金额
     calculateTotalAmount();
     clearJyJcItem();
 }
 
 
+function removeYpOrProject(index, obj) {
+    var tabId = null;
+    //西药
+    if (index == 0) {
+        tabId = "xyTab";
+    } else if (index == 1) {
+        //中成药
+        tabId = "zyTab";
+    } else if (index == 2) {
+        //医技与诊疗
+        tabId = "zlTab";
+    }
+    var tableId = $("#" + tabId + " li.active").find("a").attr("href");
+    var totalRetprice = $(obj).parent().find("input.temporary_items_amount").val();
+    calculateCfAmount(tableId, totalRetprice, null, index, 1);
+    calculateTotalAmount();
+    $(obj).parent().remove();
+}
+
+
 /**
  * 清空西药
  * @param flag 是否全部清空 因为 西药有分组,同一组的药品用药方式和频率以及天数一样,不能改变。所以不换组是不能改变 并且设置成不可编辑
  */
 function clearWesternMedicine(flag) {
+    $("#update_flag").val(false);
     //药品名称
     $("#western_medicine_name").val(null);
     //当前药品编码
@@ -1594,15 +1859,15 @@ function clearWesternMedicine(flag) {
         //天数
         $("#dayNum").selectpicker('val', null);
         $('#dayNum').selectpicker('refresh');
-       // $("#dayNum").removeAttr("disabled");
+        // $("#dayNum").removeAttr("disabled");
         //频次编码
         $("#orderFrequency").selectpicker('val', null);
         $('#orderFrequency').selectpicker('refresh');
-      //  $("#orderFrequency").removeAttr("disabled");
+        //  $("#orderFrequency").removeAttr("disabled");
     } else {
         //$("#supplyType").attr("disabled", "disabled");
         //$("#dayNum").attr("disabled", "disabled");
-       // $("#orderFrequency").attr("disabled", "disabled");
+        // $("#orderFrequency").attr("disabled", "disabled");
     }
     //药品默认单次使用剂量
     $("#drugWinDb").val(null);
@@ -1637,7 +1902,7 @@ function saveChineseMedicine() {
     var currentSerial = $("#current_serial").val();
     //处方实际单次使用剂量
     var drugWin = $("#zy_drugWin").val();
-    //医嘱
+    //医嘱
     var zyInstruction = $("#zyInstruction").val();
     //医嘱
     var zyInstructionText = $('#zyInstruction option:selected').text();
@@ -1645,6 +1910,8 @@ function saveChineseMedicine() {
     var zyPackRetprice = parseFloat($("#zy_packRetprice").val());
     //当前中药的总价
     var totalRetprice = Multiply(drugWin, zyPackRetprice);
+    //中药类型
+    var zyClassType = $("#zyClassType").val();
     if (currentCode == null || currentCode == '') {
         errorMesageSimaple("未选择任何药品!");
         return;
@@ -1656,27 +1923,59 @@ function saveChineseMedicine() {
     }
     html += '&nbsp;&nbsp;';
     html += drugWin + 'g';
-    html += ' <i class="fa fa-long-arrow-left" style="cursor: pointer;height: 20px;line-height: 20px;width: 30px;font-size: 20px;"></i>';
-    html += '<i class="fa fa-remove" style="cursor: pointer;height: 20px;line-height: 20px;width: 30px;font-size: 20px;"></i>';
+    html += ' <i class="fa fa-long-arrow-up" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;margin-left: 10px;" onclick="arrowUp(this)"></i>';
+    html += '<i class="fa fa-long-arrow-down" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;" onclick="arrowDown(this)"></i>';
+    html += ' <i class="fa fa-long-arrow-left" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;" onclick="editChineseMedicine(this)"></i>';
+    html += '<i class="fa fa-remove" style="cursor: pointer;height: 20px;line-height: 20px;width: 20px;font-size: 20px;margin-left:10px;" onclick="removeYpOrProject(1,this)"></i>';
     html += '<input type="hidden" class="temporary_items_code" value="' + currentCode + '"/>';
     html += '<input type="hidden" class="temporary_items_serial" value="' + currentSerial + '"/>';
     html += '<input type="hidden" class="temporary_items_amount" value="' + totalRetprice + '"/>';
+    html += '<input type="hidden" class="temporary_items_zyClassType" value="' + zyClassType + '"/>';
+    html += '<input type="hidden" class="temporary_items_chineseMedicineNamme" value="' + chineseMedicineNamme + '"/>';
+    html += '<input type="hidden" class="temporary_items_zyPackRetprice" value="' + zyPackRetprice + '"/>';
+    html += '<input type="hidden" class="temporary_items_drugWin" value="' + drugWin + '"/>';
+    html += '<input type="hidden" class="temporary_items_zyInstruction" value="' + zyInstruction + '"/>';
     html += '</div>';
 
     var tableId = $("#zyTab li.active").find("a").attr("href");
-    $(tableId).find("div:eq(0)").append(html);
-    //获取中药付数
-    var zyfs = $(tableId).find("input.zyfs").val();
-    //当前处方单付金额
-    var singleAmount = $("#singleAmount").val();
-    if (singleAmount == null || singleAmount == '') {
-        singleAmount = 0;
+    //原药品金额 如果是修改则需要设置
+    var temporaryItemsAmount = 0;
+    //当前需要被移除元素的下个兄弟节点
+    var nextObj = null;
+    //当前修改的药品是不是最后一个
+    var isLast = false;
+    //是新增药品还是编辑 true 修改 默认false
+    var updateFlag = $("#update_flag").val();
+    if (updateFlag == undefined || updateFlag == null) {
+        updateFlag = false;
     }
-    singleAmount = Add(singleAmount, totalRetprice);
-    var cfAmount = Multiply(singleAmount, zyfs);
-    $(tableId).find("span.cf_amount").html(cfAmount);
-    //单张处方的价格
-    $("#singleAmount").val(singleAmount);
+    //如果是修改,需要减去原来的费用
+    if (updateFlag=="true" || updateFlag==true) {
+        var formGroups = $(tableId).find("div.cf_content").find("div.form-group");
+        if (formGroups != null && formGroups.length > 0) {
+            for (var i = 0; i < formGroups.length; i++) {
+                var temporaryItemsCode = $(formGroups[i]).find("input.temporary_items_code").val();
+                var temporaryItemsSerial = $(formGroups[i]).find("input.temporary_items_serial").val();
+                if (temporaryItemsCode === currentCode && temporaryItemsSerial === currentSerial) {
+                    temporaryItemsAmount = $(formGroups[i]).find("input.temporary_items_amount").val();
+                    if (formGroups.length > 1) {
+                        nextObj = $(formGroups[i]).next();
+                    }
+                    isLast = (i + 1) === formGroups.length;
+                    $(formGroups[i]).remove();
+                    break;
+                }
+            }
+        }
+    }
+    //当没有下一个兄弟节点或者当前编辑的药品是最后一个时,直接添加
+    if (nextObj == null || isLast) {
+        $(tableId).find("div:eq(0)").append(html);
+    } else {
+        $(nextObj).before(html);
+    }
+    //设置当前处方金额
+    calculateCfAmount(tableId, totalRetprice, temporaryItemsAmount, 1, 0);
     //设置总金额
     calculateTotalAmount();
     clearChineseMedicine();
@@ -1687,6 +1986,7 @@ function saveChineseMedicine() {
  * 清空中药
  */
 function clearChineseMedicine() {
+    $("#update_flag").val(false);
     //药品名称
     $("#chinese_medicine_name").val(null);
     //当前药品编码
@@ -1707,6 +2007,7 @@ function clearChineseMedicine() {
  * 清空项目
  */
 function clearJyJcItem() {
+    $("#update_flag").val(false);
     //项目名称
     $("#jcJyItem").val(null);
     //当前项目编码
@@ -1717,6 +2018,74 @@ function clearJyJcItem() {
     $("#remark").val(null);
 }
 
+/**
+ * 设置当前处方金额
+ * @param tableId
+ * @param totalRetprice 新项目金额
+ * @param temporaryItemsAmount 原项目金额
+ * @param index 0 西药 1 中药 2诊疗
+ * @param opFlag 0 保存药品或者项目   1 删除药品或者项目
+ */
+function calculateCfAmount(tableId, totalRetprice, temporaryItemsAmount, index, opFlag) {
+    if (opFlag == 0) {
+        if (index == 1) {
+            //获取中药付数
+            var zyfs = $(tableId).find("input.zyfs").val();
+            //当前处方单付金额
+            var singleAmount = $("#singleAmount").val();
+            if (singleAmount == null || singleAmount == '') {
+                singleAmount = 0;
+            }
+            //如果是修改,需要减去原来的费用
+            if (temporaryItemsAmount != null) {
+                singleAmount = Minus(singleAmount, temporaryItemsAmount);
+            }
+            singleAmount = Add(singleAmount, totalRetprice);
+            var cfAmount = Multiply(singleAmount, zyfs);
+            $(tableId).find("span.cf_amount").html(cfAmount);
+            //单张处方的价格
+            $("#singleAmount").val(singleAmount);
+        } else {
+            //设置单张处方金额
+            var cfAmount = $(tableId).find("span.cf_amount").html();
+            if (cfAmount != null && cfAmount != "") {
+                cfAmount = parseFloat($(tableId).find("span.cf_amount").html());
+            }
+            //如果是修改,需要减去原来的费用
+            if (temporaryItemsAmount != null) {
+                cfAmount = Minus(cfAmount, temporaryItemsAmount);
+            }
+            cfAmount = Add(cfAmount, totalRetprice);
+            $(tableId).find("span.cf_amount").html(cfAmount);
+        }
+    } else if (opFlag == 1) {
+        if (index == 1) {
+            //获取中药付数
+            var zyfs = $(tableId).find("input.zyfs").val();
+            //当前处方单付金额
+            var singleAmount = $("#singleAmount").val();
+            if (singleAmount == null || singleAmount == '') {
+                singleAmount = 0;
+            }
+            singleAmount = Minus(singleAmount, totalRetprice);
+            var cfAmount = Multiply(singleAmount, zyfs);
+            $(tableId).find("span.cf_amount").html(cfAmount);
+            //单张处方的价格
+            $("#singleAmount").val(singleAmount);
+        } else {
+            //设置单张处方金额
+            var cfAmount = $(tableId).find("span.cf_amount").html();
+            if (cfAmount != null && cfAmount != "") {
+                cfAmount = parseFloat($(tableId).find("span.cf_amount").html());
+            }
+            cfAmount = Minus(cfAmount, totalRetprice);
+            $(tableId).find("span.cf_amount").html(cfAmount);
+        }
+    }
+    //计算结束都设置成新增药品或者项目
+    $("#update_flag").val(false);
+}
+
 /**
  * 计算总金额
  */
@@ -1724,7 +2093,6 @@ function calculateTotalAmount() {
     var cfAmounts = $("span.cf_amount");
     var totalAmount = 0;
     if (cfAmounts != null && cfAmounts.length > 0) {
-
         for (var i = 0; i < cfAmounts.length; i++) {
             totalAmount = Add(totalAmount, parseFloat($(cfAmounts[i]).html()));
         }
@@ -1959,7 +2327,7 @@ function initUserList() {
         style: '',
         delay: 300,
         padding: true,
-        height: 300
+        height: 300,
     };
     var webuiPopover = $('#rapidAcceptsUserName').webuiPopover('destroy').webuiPopover(settings);
     //用户姓名选中事件
@@ -2075,7 +2443,7 @@ function initRecommendList() {
     var width = $("#symptom").parent().css("width");
     var settings = {
         placement: 'bottom-right',//值: auto,top,right,bottom,left,top-right,top-left,bottom-right,bottom-left  要显示的位置
-        trigger: 'click', //值:click,hover 触发方式
+        trigger: 'click', //值:click,hover 触发方式 manual 手动
         content: '',//内容,内容可以是函数
         width: width,
         //arrow:false,//是否显示箭头
@@ -2099,12 +2467,17 @@ function initRecommendList() {
     //西药弹窗
     settings.width = 680;
     settings.closeable = false;
+    settings.arrow = false;//显示箭头或不显示箭头
     settings.content = '<div id="westernMedicinePopoverContent"><table id="tb_table_western_medicine"></table></div>';
+    //手动触发
+    settings.trigger = 'manual';
     var westernMedicineWebuiPopover = $('#western_medicine_name').webuiPopover('destroy').webuiPopover(settings);
     //中药弹窗
+    settings.trigger = 'click';
     settings.content = '<div id="chineseMedicinePopoverContent"><table id="tb_table_chinese_medicine"></table></div>';
     var chineseMedicineWebuiPopover = $('#chinese_medicine_name').webuiPopover('destroy').webuiPopover(settings);
     //诊疗与医技弹窗
+    settings.trigger = 'manual';
     settings.content = '<div id="jcJyItemPopoverContent"><table id="tb_table_jc_jy_item"></table></div>';
     var jcJyItemWebuiPopover = $('#jcJyItem').webuiPopover('destroy').webuiPopover(settings);
     //主诉选中事件
@@ -2221,13 +2594,13 @@ function initRecommendList() {
         fitEmrPsData();
     });
 
-    //西药选中事件
-    $("#western_medicine_name").on("click", function (t) {
-        if ($(westernMedicineWebuiPopover).css("display") == "block") {
-            $("#westernMedicinePopoverContent").parent().parent().prev().css("left", "23px");
-            loadYpList(0);
-        }
-    });
+    // //西药选中事件
+    // $("#western_medicine_name").on("click", function (t) {
+    //     if ($(westernMedicineWebuiPopover).css("display") == "block") {
+    //         $("#westernMedicinePopoverContent").parent().parent().prev().css("left", "23px");
+    //         loadYpList(0);
+    //     }
+    // });
 
     //中药选中事件
     $("#chinese_medicine_name").on("click", function (t) {
@@ -2237,12 +2610,26 @@ function initRecommendList() {
         }
     });
 
-    //诊疗与医技弹窗选中事件
-    $("#jcJyItem").on("click", function (t) {
-        if ($(jcJyItemWebuiPopover).css("display") == "block") {
-            $("#jcJyItemPopoverContent").parent().parent().prev().css("left", "23px");
-            loadjcJyItemList();
-        }
+    // //诊疗与医技弹窗选中事件
+    // $("#jcJyItem").on("click", function (t) {
+    //     if ($(jcJyItemWebuiPopover).css("display") == "block") {
+    //         $("#jcJyItemPopoverContent").parent().parent().prev().css("left", "23px");
+    //         loadjcJyItemList();
+    //     }
+    // });
+
+
+    //帮助字典弹窗
+    settings.width = 250;
+    settings.height = 200;
+    settings.placement = 'right';//值: auto,top,right,bottom,left,top-right,top-left,bottom-right,bottom-left  要显示的位置
+    settings.content = '<div id="treePopoverContent"><div><ul id="treeDemo" class="ztree"></ul></div></div>';
+    settings.trigger = 'click';
+    var treeWebuiPopover = $('#treeButton').webuiPopover('destroy').webuiPopover(settings);
+    $("#treeButton").on("click", function (t) {
+        // $("#treePopoverContent").parent().parent().prev().css("left", "23px");
+        //初始化药品,检查检验菜单树
+        initzTree();
     });
 }
 
@@ -2558,25 +2945,25 @@ function fitValue(value, id) {
  * @param index
  */
 function loadYpList(index) {
-    var medicinePopoverContent = null;
+    //var medicinePopoverContent = null;
     var tableMedicine = null;
     var MedicineName = null;
     //var groupNo=null;
     if (index == 0) {
-        medicinePopoverContent = "westernMedicinePopoverContent";
+        //  medicinePopoverContent = "westernMedicinePopoverContent";
         tableMedicine = "tb_table_western_medicine";
         MedicineName = "western_medicine_name";
         // groupNo=71;
     }
     if (index == 1) {
-        medicinePopoverContent = "chineseMedicinePopoverContent";
+        //   medicinePopoverContent = "chineseMedicinePopoverContent";
         tableMedicine = "tb_table_chinese_medicine";
         MedicineName = "chinese_medicine_name";
         // groupNo=$("#zyClassType").val();
     }
-    if (!$("#" + medicinePopoverContent).parent().parent().parent().hasClass("in")) {
-        return;
-    }
+    // if (!$("#" + medicinePopoverContent).parent().parent().parent().hasClass("in")) {
+    //     return;
+    // }
     $('#' + tableMedicine).bootstrapTable('refresh');
     $('#' + tableMedicine).bootstrapTable({
         url: '/thmz/getYpListByCommonParams',         //请求后台的URL(*)
@@ -2722,6 +3109,7 @@ function checkYpInfo(code, serial) {
     if (verifyRepeat(code, serial, 0)) {
         return;
     }
+    $("#treeButton").webuiPopover('hide');
     $.ajax({
         type: "GET",
         url: '/thmz/getYpZdDictByCodeAndSerial?code=' + code + "&serial=" + serial,
@@ -2801,9 +3189,9 @@ function checkZyInfo(code, serial) {
  * @param index
  */
 function loadjcJyItemList() {
-    if (!$("#jcJyItemPopoverContent").parent().parent().parent().hasClass("in")) {
-        return;
-    }
+    // if (!$("#jcJyItemPopoverContent").parent().parent().parent().hasClass("in")) {
+    //     return;
+    // }
     $('#tb_table_jc_jy_item').bootstrapTable('refresh');
     $('#tb_table_jc_jy_item').bootstrapTable({
         url: '/thmz/getJcJyItemByCommonParams',         //请求后台的URL(*)
@@ -2899,6 +3287,7 @@ function checkJcJyItemInfo(code, name) {
     if (verifyRepeat(code, null, 2)) {
         return;
     }
+    $("#treeButton").webuiPopover('hide');
     $.ajax({
         type: "GET",
         url: '/thmz/getJcJyItemChargeByCode?code=' + code,
@@ -3070,6 +3459,14 @@ function getJcJyItemChargeByCode(code) {
  * @param index
  */
 function verifyRepeat(code, serial, index) {
+    //是新增药品还是编辑 true 修改 默认false
+    var updateFlag = $("#update_flag").val();
+    if (updateFlag == undefined || updateFlag == null) {
+        updateFlag = false;
+    }
+    if (updateFlag=="true" || updateFlag==true) {
+        return false;
+    }
     var tabId = null;
     //西药
     if (index == 0) {
@@ -3760,24 +4157,24 @@ function initListDoctorSelect() {
     });
 }
 
-
-/**
- * 加载挂号列表
- * @param flag 是否清空挂号卡片列表区域
- */
-function loadRegistrationList(flag) {
-    if (flag) {
-        pageIndex = 0;
-        $("#card_regi_list").empty();
-        $("div.page").removeClass("in").addClass("hide");
-    }
-    var regiListType = getIndex("regi_List_type");
-    if (regiListType == 0) {
-        loadCardList();
-    } else if (regiListType == 1) {
-        loadTableList();
-    }
-}
+//
+// /**
+//  * 加载挂号列表
+//  * @param flag 是否清空挂号卡片列表区域
+//  */
+// function loadRegistrationList(flag) {
+//     if (flag) {
+//         pageIndex = 0;
+//         $("#card_regi_list").empty();
+//         $("div.page").removeClass("in").addClass("hide");
+//     }
+//     var regiListType = getIndex("regi_List_type");
+//     if (regiListType == 0) {
+//         loadCardList();
+//     } else if (regiListType == 1) {
+//         loadTableList();
+//     }
+// }
 
 
 /**
@@ -3948,4 +4345,92 @@ function saveWorkspaceConfig() {
             }
         }
     });
-}
+}
+
+
+/**
+ * 初始化药品,检查检验菜单树
+ */
+function initzTree() {
+    var index = getIndex("bill_item_group");
+    if (index == 0) {
+        $("#western_medicine_name").webuiPopover('hide');
+        $.ajax({
+            type: "GET",
+            url: '/thmz/getYpZdClasses',
+            contentType: "application/json;charset=UTF-8",
+            dataType: "json",
+            async: false,
+            headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+            success: function (res) {
+                if (res == '401' || res == 401) {
+                    window.location.href = '/thmz/login/view'
+                    return;
+                }
+                if (res.code == 0) {
+                    // zTree 的参数配置,深入使用请参考 API 文档(setting 配置详解)
+                    var setting = {
+                        callback: {
+                            onClick: zTreeOnClick
+                        }
+                    };
+                    $.fn.zTree.init($("#treeDemo"), setting, res.data);
+                } else {
+                    errorMesage(res);
+                }
+            }
+        });
+    } else if (index == 2) {
+        $("#jcJyItem").webuiPopover('hide');
+        $.ajax({
+            type: "GET",
+            url: '/thmz/getJyJcZdClasses',
+            contentType: "application/json;charset=UTF-8",
+            dataType: "json",
+            async: false,
+            headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+            success: function (res) {
+                if (res == '401' || res == 401) {
+                    window.location.href = '/thmz/login/view'
+                    return;
+                }
+                if (res.code == 0) {
+                    // zTree 的参数配置,深入使用请参考 API 文档(setting 配置详解)
+                    var setting = {
+                        callback: {
+                            onClick: zTreeOnClick
+                        }
+                    };
+                    $.fn.zTree.init($("#treeDemo"), setting, res.data);
+                } else {
+                    errorMesage(res);
+                }
+            }
+        });
+    } else {
+        $("#treeButton").webuiPopover('hide');
+        warningMesageSimaple("中药暂无帮助字典");
+    }
+
+}
+
+
+/**
+ * 节点点击事件
+ * @param event
+ * @param treeId
+ * @param treeNode
+ */
+function zTreeOnClick(event, treeId, treeNode) {
+    var index = getIndex("bill_item_group");
+    if (index == 0) {
+        $("#western_medicine_name").val(treeNode.id);
+        $('#western_medicine_name').webuiPopover('show');
+        loadYpList(0);
+    } else if (index == 2) {
+        $("#jcJyItem").val(treeNode.id);
+        $('#jcJyItem').webuiPopover('show');
+        loadjcJyItemList();
+    }
+}
+

+ 9 - 1
src/main/resources/templates/mz/clinic.html

@@ -411,7 +411,7 @@
                         </div>
                     </div>
                     <div class="item form-group">
-                        <div class="btn-group" id="bill_item_group">
+                        <div class="btn-group" id="bill_item_group" style="float: left">
                             <button class="btn btn-sm btn-primary" type="button" onclick="billItemButtonChange(this,0)">
                                 &nbsp;&nbsp;西成药&nbsp;&nbsp;
                             </button>
@@ -426,6 +426,12 @@
                             <!--<button class="btn btn-sm btn-default" type="button" onclick="billItemButtonChange(this)">&nbsp;&nbsp;&nbsp;精二&nbsp;&nbsp;&nbsp;&nbsp;-->
                             <!--</button>-->
                         </div>
+                        <div style="float: left;margin-left: 30px;">
+                            <button type="button" class="btn btn-primary"
+                                    style="height: 30px;line-height: 15px;" id="treeButton"><i
+                                    class="fa fa-search">&nbsp;&nbsp;</i>查看帮助字典
+                            </button>
+                        </div>
                         <div style="float: right;">
                             <button type="button" class="btn btn-primary" id="saveapidAccepts"
                                     style="height: 30px;line-height: 15px;"><i
@@ -438,6 +444,8 @@
                         <input id="current_serial" type="hidden"/>
                         <!-- 当前选中药品编码-->
                         <input id="current_code" type="hidden"/>
+                        <!-- 当前选中药品是否是修改状态 true 修改 false 新增-->
+                        <input id="update_flag" type="hidden"/>
                         <div style="margin-top: 5px;width: 386px;float: left;" class="thmz_alert" id="rp_form0">
                             <form class="form-horizontal form-label-left mz-fixed-form" novalidate autocomplete="off">
                                 <div class="item form-group">