angular 一个界面调用另一个界面的方式1

 

红色标记的hr都是顶级的module,每个路由节点都会引入hr这个module,所以这些嵌入的界面可以放在hr这个module下

angular.module('hr.templateCache').run(['$templateCache', function ($templateCache) {
    $templateCache.put('presc-create-modal.html', "<div hr-draggable class=\"create-presc\" modal=\"modalShow\" options=\"prescModalOpts\" ng-controller=\"PrescCreateModalController\">\n    <header class=\"modal-header\">\n        <button type=\"button\" class=\"close\" ng-click=\"closePrescCreateModal()\">&times;</button>\n        <h5>生成处方</h5>\n    </header>\n    <div class=\"mg5505\">\n        <div class=\"form-horizontal presc-attr\">\n            <!--处方类型-->\n            <div class=\"control-group label-four drug-type\">\n                <label class=\"control-label\">处方类型:</label>\n                <div class=\"controls\">\n                        <span ng-repeat=\"prescTypeDict in prescTypeDictList\"\n                              ng-if=\"isPrescTypeShow(prescTypeDict.codeName)\">\n                            <label class=\"checkbox inline\">\n                                <input type=\"checkbox\" value=\"{{prescTypeDict.codeName}}\" ng-click=\"applyCheckEvent()\"\n                                       ng-disabled=\"isRejectOption(prescTypeDict)\" ng-checked=\"isPrescAttrChecked(prescTypeDict.codeName)\"\n                                       name=\"prescAttr\">{{prescTypeDict.codeName}}\n                            </label>\n                        </span>\n                </div>\n            </div>\n            <!--药房-->\n            <div class=\"control-group label-two drug-room\" ng-show=\"clinicInfo.groupOrder != 2\">\n                <label class=\"control-label\">药房</label>\n                <div class=\"controls\">\n                    <select ui-select2 id=\"deptInfo\"\n                            enter-loop=\"1\" enterindex=\"3\"\n                            ng-model=\"performDeptIdPrescCreate\" ng-change=\"changePerformDept(performDeptIdPrescCreate)\">\n                        <option ng-repeat=\"dept in departmentWestDispensary\"\n                                code=\"{{dept.deptCode}}\"\n                                value=\"{{dept.deptCode}}\">{{dept.deptName}}\n                        </option>\n                    </select>\n                </div>\n            </div>\n        </div>\n        <div class=\"body-content border-line-top-left-right\" ng-grid=\"prescOrdersGrid\"></div>\n    </div>\n    <div class=\"modal-footer btn-right\">\n        <button class=\"btn btn-primary\" ng-click=\"createPresc()\">生成</button>\n        <button class=\"btn btn-default\" ng-click=\"closePrescCreateModal()\">关闭</button>\n    </div>\n</div>");
}]);

angular.module('hr').controller('PrescCreateModalController', ['$scope', '$http', '$timeout', 'hrDialog', 'HrDrugBillingAttr', 'hrProgress',
    function ($scope, $http, $timeout, hrDialog, HrDrugBillingAttr, hrProgress) {
    $scope.modalShow = true;
    //医嘱生成处方药房
    $scope.performDeptIdPrescCreate = null;
    //可生成处方医嘱List(药疗,不摆药,已执行)
    $scope.ordersDrugWestListPrescCreate = [];
    //页面显示可生成处方医嘱List
    $scope.orderDetailListPrescCreate = [];
    //医嘱最后发药信息List
    $scope.drugPrescDetailList = [];
    $scope.prescModalOpts = {
        dialogClass: "modal create-presc-modal",
        backdropFade: false,
        dialogFade: false,
        keyboard: true,
        backdrop: true,
        backdropClick: false
    };
    $scope.closePrescCreateModal = function () {
        $scope.modalShow = false;
        $scope.modal.close();
        $timeout(function () {
            $scope.$destroy();
        })
    };

    function initPrescCreate() {
        $scope.ordersDrugWestListPrescCreate = angular.copy($scope.ordersDrugWestOtherList.filter(function (doctorOrder) {
            return isOrderForPrescCreate(doctorOrder);
        }));
        for (var i = 0; i < $scope.ordersDrugWestListPrescCreate.length; i++) {
            var orderDetail = convertDrugWestToDetail($scope.ordersDrugWestListPrescCreate[i]);
            orderDetail.packageUnits = $scope.ordersDrugWestListPrescCreate[i].drugOrderDetail.packageUnits;
            orderDetail.totalAmount = null;
            orderDetail.days = null;
            $scope.orderDetailListPrescCreate.push(orderDetail);
        }
        $scope.performDeptIdPrescCreate = getDefaultDispensary($scope.departmentWestDispensary, $scope.defaultWestDispensary);
        setOrderDetailShow();
    }

    function getOrderFilterShow(rowIndex) {
        if (rowIndex > 0) {
            var orderDetail = $scope.orderDetailListPrescCreate[rowIndex];
            var orderDetailPre = $scope.orderDetailListPrescCreate[rowIndex - 1];
            var orderClass = orderDetail.orderClass;
            var orderClassPre = orderDetailPre.orderClass;
            if (orderClass === orderClassPre && orderDetail.groupNo === orderDetailPre.groupNo) {
                return false;
            }
        }
        return true;
    }

    function getOrderTxtExtendDrugWestShow(rowIndex) {
        var orderDetailList = $scope.orderDetailListPrescCreate;
        if (orderDetailList.length <= rowIndex) {
            return true;
        }

        var totalLen = orderDetailList.length - 1;
        var pre = 0;
        var next = 0;

        if (rowIndex === totalLen) {
            next = rowIndex;
        } else {
            next = rowIndex + 1;
        }
        if (rowIndex > 0) {
            pre = rowIndex - 1;
        }
        var currentGroupNo = orderDetailList[rowIndex].groupNo;
        var preGroupNo = orderDetailList[pre].groupNo;
        var nextGroupNo = orderDetailList[next].groupNo;

        if (rowIndex === 0) {
            if (next > rowIndex && currentGroupNo === nextGroupNo) {
                return true;
            }
        } else if (rowIndex === totalLen) {
            if (pre < rowIndex && currentGroupNo === preGroupNo) {
                return false;
            }
        } else {
            if (currentGroupNo === preGroupNo) {
                if (currentGroupNo === nextGroupNo) {
                    return false;
                } else {
                    return false;
                }
            } else {
                if (currentGroupNo === nextGroupNo) {
                    return true;
                } else {
                    return true;
                }
            }
        }
        return true;
    }

    $scope.changePerformDept = function(performDeptIdPrescCreate){
        angular.forEach($scope.ordersDrugWestListPrescCreate, function(item){
            item.performDeptId = performDeptIdPrescCreate;
        })
    };

    function setOrderDetailShow() {
        $scope.orderDetailListPrescCreate.forEach(function (item, index) {
            item.detailShow = getOrderFilterShow(index);
            item.orderTxtExtendShow = getOrderTxtExtendDrugWestShow(index);
            item.orderStatusCodeName = $scope.getOrderStatusByCode(item, "order");
            item.firmId = $scope.getDrugFirmIdByOrderId(item.orderId);
        });
    }

    function isOrderForPrescCreate(doctorOrder) {
        if (doctorOrder.orderClass === orderClassEnum.orderDrugWest && doctorOrder.drugBillingAttr === HrDrugBillingAttr.NONE && doctorOrder.orderStatus === orderStatusEnum.EXECUTE) {
            var index = $scope.getSelectedRowNumOther(doctorOrder.orderId);
            if (index !== -1) {//停止医嘱 护士站未回写doctorOrders状态 需要检查performStatus
                if ($scope.orderDetailOtherList[index].performStatus === orderStatusEnum.EXECUTE) {
                    return true;
                }
            }
        }
        return false;
    }

    function getDrugPrescDetailByOrderId(orderId) {
        var filter = $scope.drugPrescDetailList.filter(function (item) {
            return item.itemNo === orderId;
        });
        if (filter.length > 0) {
            return filter[0];
        }
        return null;
    }

    function calculateDays(drugOrderDetail,orderDetail) {
        /*var drugPrescDetail = getDrugPrescDetailByOrderId(drugOrderDetail.orderId);
        if (drugPrescDetail == null) {
            return null;
        }*/
        var amountPerPackage = drugOrderDetail.amountPerPackage || 0;  //包装数量
        var dosage = drugOrderDetail.dosage || 0;   //药品默认一次使用剂量 0.25
        var usageUnits = drugOrderDetail.usageUnits || "";   //使用单位
        var dosePerUnit = drugOrderDetail.dosePerUnit || 0;    //最小单位剂量 0.25
        var doseUnits = drugOrderDetail.doseUnits || "";     //剂量单位 mg
        var units = drugOrderDetail.units || "";     //单位 片
        var freqCounter = drugOrderDetail.freqCounter || 0;     //默认频率次数 3
        var freqInterval = drugOrderDetail.freqInterval || 0;   //默认频率间隔 1
        var freqIntervalUnit = drugOrderDetail.freqIntervalUnit || "";   //默认频率间隔单位 日
        var totalAmount = drugOrderDetail.quantity || 0;     //数量
        var dosageForUnits = 0;
        var countPerDay = 0;
        var countPerWeek = 0;

        if (usageUnits !== units) {
            dosageForUnits = dosage / dosePerUnit;
        } else {
            dosageForUnits = dosage;
        }
        if (freqIntervalUnit === "小时") {
            countPerDay = (24 / freqInterval) * freqCounter;
        } else if (freqIntervalUnit === "分钟" || freqIntervalUnit === "分") {
            countPerDay = (24 * 60 / freqInterval) * freqCounter;
        } else if (freqIntervalUnit === "日") {
            countPerDay = (freqCounter / freqInterval);
        } else if (freqIntervalUnit === "周") {
            countPerWeek = freqCounter / freqInterval;
        }
        var days = orderDetail.days;
        if (freqIntervalUnit === "周") {
            orderDetail.totalAmount = Math.ceil(Math.ceil(days / 7) * countPerWeek * dosageForUnits / amountPerPackage);
        } else {
            orderDetail.totalAmount = Math.ceil(days * countPerDay * dosageForUnits / amountPerPackage);
        }
        orderDetail.totalAmount = isNaN(orderDetail.totalAmount==0?null:orderDetail.totalAmount)==true?null:orderDetail.totalAmount;
    }

    //查询最后发药天数
    function getLastPerformDays(callback) {
        var orderIdList = $scope.ordersDrugWestListPrescCreate.map(function (item) {
            return item.orderId;
        });
        var successCallback = function (data) {
            $scope.drugPrescDetailList = data;
            callback();
        };
        var errorCallback = function (data) {
            hrDialog.dialog(hrDialog.typeEnum.WARN, {
                message: "查询发药信息失败!",
                detail: data.message
            });
            callback();
        };
        HrUtils.httpRequest($http, Path.getUri("api/inp-orders/presc-last-perform-days"), successCallback, errorCallback, hrDialog, HrUtils.httpMethod.POST, orderIdList);
    }

    //小包装大包装的转换
    function getPackageUnits(index) {
        var drugOrderDetail = $scope.ordersDrugWestListPrescCreate[index].drugOrderDetail;
        var successCallback = function (data) {
            data = data.filter(function (item) {
                return item.amountPerPackage > 1;
            });
            if (data.length > 0) {
                drugOrderDetail.packageSpec = data[0].packageSpec;
                drugOrderDetail.packageUnits = data[0].packageUnits;
                drugOrderDetail.amountPerPackage = data[0].amountPerPackage;
                $scope.orderDetailListPrescCreate[index].packageUnits = data[0].packageUnits;
                $scope.orderDetailListPrescCreate[index].orderTxt = $scope.getOrderTxtDrugWest(drugOrderDetail);
            }
            calculateDays(drugOrderDetail,$scope.orderDetailListPrescCreate[index]);
            if (index < $scope.ordersDrugWestListPrescCreate.length - 1) {
                getPackageUnits(++index);
            }
        };
        if (drugOrderDetail.amountPerPackage === 1) {
            HrUtils.httpRequest($http, Path.getUri("api/drug-info-list/special-drug-price-list"), successCallback, null, hrDialog, HrUtils.httpMethod.POST, drugOrderDetail);
        } else {
            calculateDays(drugOrderDetail,$scope.orderDetailListPrescCreate[index]);
            if (index < $scope.ordersDrugWestListPrescCreate.length - 1) {
                getPackageUnits(++index);
            }
        }
    }

    function convertDrugWestToDetail(inpOrders, prescSpecType) {
        var orderDetail = {};
        var drugOrderDetailTemp = inpOrders.drugOrderDetail;
        if (drugOrderDetailTemp.deleteStatus !== 1) {
            orderDetail = $scope.getOrderDetailDrug(inpOrders, drugOrderDetailTemp, true, 0, prescSpecType);
        }
        return orderDetail;
    }

    function getDrugPrescAttrDetail(data){
        if(Strings.isNullOrEmpty(data)){
            return "普通";
        }
        var prescAttr = "";
        switch (data.toxiCode) {
            case "2":
                prescAttr = "精1";
                break;
            case "7":
                prescAttr = "精2";
                break;
            case "6":
                prescAttr = "毒";
                break;
            case "5":
                prescAttr = "麻";
                break;
            default :
                prescAttr = "普通";
        }
        return prescAttr;
    }

    //获取药品属性
    function getDrugPrescAttr(ordersDrugWestListPresc, index, callback){
        var doctorOrders = ordersDrugWestListPresc[index];
        var successCallback = function (data) {
            doctorOrders.prescAttr = getDrugPrescAttrDetail(data);
            if (index < ordersDrugWestListPresc.length - 1) {
                getDrugPrescAttr(ordersDrugWestListPresc, ++index, callback);
            } else {
                callback();
            }
        };
        HrUtils.httpRequest($http, Path.getUri("api/inp-orders/get-drug-prescAttr?drugCode=" + doctorOrders.drugOrderDetail.drugCode), successCallback, null, hrDialog, HrUtils.httpMethod.POST, null);
    }

    //生成orderDrugInfo
    function getOrderDrugInfo(doctorOrders, drugOrderDetail, callback){
        var orderDrugInfo = new OrderDrugInfo();
        orderDrugInfo.operationStatus = doctorOrders.operationStatus;//
        orderDrugInfo.administration = drugOrderDetail.administration;
        orderDrugInfo.amountPerPackage = drugOrderDetail.amountPerPackage;
        orderDrugInfo.amountPerPackage = drugOrderDetail.amountPerPackage;
        orderDrugInfo.babyNo = doctorOrders.babyNo;
        orderDrugInfo.billingAttr = doctorOrders.billingAttr;
        orderDrugInfo.charge = drugOrderDetail.totalAmount * drugOrderDetail.price;
        orderDrugInfo.costs = drugOrderDetail.totalAmount * drugOrderDetail.price;
        orderDrugInfo.days = drugOrderDetail.days;
        orderDrugInfo.dosage = drugOrderDetail.dosage;
        orderDrugInfo.dosePerUnit = drugOrderDetail.dosePerUnit;
        orderDrugInfo.doseUnits = drugOrderDetail.doseUnits;
        orderDrugInfo.drugCode = drugOrderDetail.drugCode;
        orderDrugInfo.drugName = drugOrderDetail.drugName;
        orderDrugInfo.drugSpec = drugOrderDetail.drugSpec;
        orderDrugInfo.drugTradeCode = drugOrderDetail.drugTradeCode;
        orderDrugInfo.drugTradeName = drugOrderDetail.drugTradeName;
        orderDrugInfo.duration = drugOrderDetail.duration;
        orderDrugInfo.durationUnits = drugOrderDetail.durationUnits;
        orderDrugInfo.encounterNo = doctorOrders.encounterNo;
        orderDrugInfo.firmId = drugOrderDetail.firmId;
        orderDrugInfo.focusSelfPay = doctorOrders.focusSelfPay;
        orderDrugInfo.freqCounter = drugOrderDetail.freqCounter;
        orderDrugInfo.freqInterval = drugOrderDetail.freqInterval;
        orderDrugInfo.freqIntervalUnit = drugOrderDetail.freqIntervalUnit;
        orderDrugInfo.frequency = drugOrderDetail.frequency;
        orderDrugInfo.groupGraph = doctorOrders.groupGraph;
        orderDrugInfo.isGroup = doctorOrders.isGroup;//
        orderDrugInfo.memo = doctorOrders.memo;
        orderDrugInfo.menstruumIndicator = drugOrderDetail.menstruumIndicator;
        orderDrugInfo.packageSpec = drugOrderDetail.packageSpec;
        orderDrugInfo.packageUnits = drugOrderDetail.packageUnits;
        orderDrugInfo.performDeptId = doctorOrders.performDeptId;
        orderDrugInfo.prescAttr = doctorOrders.prescAttr;
        orderDrugInfo.price = drugOrderDetail.price;
        orderDrugInfo.stIndicator = drugOrderDetail.stIndicator;
        orderDrugInfo.totalAmount = drugOrderDetail.totalAmount;
        orderDrugInfo.units = drugOrderDetail.units;
        orderDrugInfo.usageUnits = drugOrderDetail.usageUnits;
        orderDrugInfo.userDescription = drugOrderDetail.userDescription;
        orderDrugInfo.visitNo = doctorOrders.visitNo;
        callback(orderDrugInfo);
    }

    //校验是否数量为空
    function checkTotalAmountOrDays(orderDetailListPresc, ordersDrugWestListPresc, callback){
        var filter = orderDetailListPresc.filter(function(item){
            if(Strings.isNullOrEmpty(item.totalAmount) || item.totalAmount == 0 || Strings.isNullOrEmpty(item.days) || item.days == 0){
                return item;
            }
        });
        if(filter.length > 0){
            for(var i=0; i< ordersDrugWestListPresc.length;){
                if(ordersDrugWestListPresc[i].orderId == filter[0].orderId){
                    hrDialog.dialog(hrDialog.typeEnum.WARN, {message: "请检查" + ordersDrugWestListPresc[i].drugOrderDetail.drugName + "药品天数或者数量"})
                        .close(function(){
                        });
                    return false;
                }
                ++i;
            }
        } else {
            callback();
        }
    }

    /*function checkDrugFirm(orderDrugInfo, callback) {
        var queryInfo = {
            "drugCode": orderDrugInfo.drugCode,
            "drugTradeName": "",
            "deptCode": $scope.performDeptIdPrescCreate,
            "chargeType": $scope.patientInfo.chargeType,
            "constrainedDoctorLevel": $scope.doctorInfo.constrainedDoctorLevel,
            "packageUnitsFlag": 1,
            "displayFlag": true
        };
        var drugInfoSuccessCallback = function (data) {
            if (data && data.length > 0) {
                var list = data.filter(function (item) {
                    if (item.drugCode === orderDrugInfo.drugCode && item.drugSpec === orderDrugInfo.drugSpec && item.firmId === orderDrugInfo.firmId && item.packageSpec === orderDrugInfo.packageSpec) {
                        return true;
                    }
                });
                if (list.length > 0) {
                    orderDrugInfo.price = data[0].price;
                    callback(orderDrugInfo);
                } else {
                    hrDialog.dialog(hrDialog.typeEnum.WARN, {message: orderDrugInfo.drugName + "(" + orderDrugInfo.packageSpec + ")" + "'药品不可供!"});
                }
            } else {
                hrDialog.dialog(hrDialog.typeEnum.WARN, {message: orderDrugInfo.drugName + "(" + orderDrugInfo.packageSpec + ")" + "'药品不可供!"});
            }
        };
        HrUtils.httpRequest($http, Path.getUri("api/drug-name-dict/drug-trade-price-info"), drugInfoSuccessCallback, null, hrDialog, HrUtils.httpMethod.POST, queryInfo);
    }*/

    //检验是否选中要生成处方的医嘱
    function checkOrdersQuantity(callback) {
        var orderDetailListPresc = [];
        var ordersDrugWestListPresc = [];
        angular.forEach($scope.orderDetailListPrescCreate, function(item,index){
            if(item.checked){
                orderDetailListPresc.push(item);
                ordersDrugWestListPresc.push($scope.ordersDrugWestListPrescCreate[index]);
            }
        });
        if(orderDetailListPresc.length == 0){
            hrDialog.dialog(hrDialog.typeEnum.WARN, {message: "请选择要生成的处方的医嘱!"});
            return false;
        } else {
            callback(orderDetailListPresc, ordersDrugWestListPresc);
        }
    }

    function getPrescAttr() {
        var prescAttrList = [];
        var checkBoxs = $('input[name="prescAttr"]');
        for (var i = 0; i < checkBoxs.length; i++) {
            var checkBox = checkBoxs.get(i);
            if (checkBox.checked && !angular.equals(checkBox.value, prescAttrEnum.PT)) {
                prescAttrList.push(checkBox.value)
            }
        }
        var prescAttr = prescAttrList.join(";");
        if (angular.equals(prescAttr, "")) {
            prescAttr = prescAttrEnum.PT;
        }
        return prescAttr;
    }

    $scope.columnDefsPrescOrders = [
        {
            field: '', displayName: '选择', width: "5%", cellClass: "text-center", cellTemplate: '' +
        '<div class="ngCellText">\n    <input type="checkbox" ng-model="row.entity.checked" ng-show="row.entity.groupSubNo == 1" ng-true-value="1" ng-false-value="0" ng-click="preventCheck(row.rowIndex)"/>\n</div>'
        },
        {
            field: 'startDateTime', displayName: '下达时间', width: "9%", cellClass: "text-center", cellTemplate: '' +
        '<div class="ngCellText" ng-show="row.entity.detailShow">{{::getOrderDateTime(row.getProperty(col.field))}}</div>'
        },
        {
            field: 'repeatIndicator', displayName: '长/临', width: "5%", cellTemplate: '' +
        '<div class="ngCellText" ng-show="row.entity.detailShow">{{::getOrderRepeatIndicator(row.getProperty(col.field))}}</div>'
        },
        {
            field: 'days',
            displayName: '天数',
            width: '5%',
            cellClass: "text-center",
            cellTemplate: '' +
            '    <div class="input-append">\n        <input class="input-mini drug-amount-presc text-right" type="text" ng-model="row.entity.days" ng-change="changeOrdersDays(row.rowIndex)"\n               number-only-by-condition number-type="+" decimal-type="integer"/>\n    </div>\n'

        },
        {
            field: 'totalAmount',
            displayName: '数量',
            width: "11%",
            cellTemplate: '' +
        '    <div class="input-append">\n        <input class="input-mini drug-amount-presc text-right" type="text" ng-model="row.entity.totalAmount" ng-disabled="true"/>\n        <span class="add-on">{{row.entity.packageUnits}}</span>\n    </div>\n'
        },
        {
            field: 'orderTxt', displayName: '医嘱', cellTemplate: '' +
        '<div class="ngCellText" title="{{::row.entity.firmId}}"> ' +
        '<span ng-bind-html="deliberatelyTrustDangerousSnippet(row.getProperty(col.field))"></span> ' +
        '<span class="drug-order-detail-flag">{{::row.entity.groupGraph}}</span> ' +
        '<span ng-show="row.entity.orderTxtExtendShow" ng-bind-html="deliberatelyTrustDangerousSnippet(row.getProperty(\'orderTxtExtend\'))"></span>' +
        '</div>'
        },
        {
            field: 'doctor', displayName: '医师', width: '8%', cellTemplate: '' +
        '<div class="ngCellText" ng-show="row.entity.detailShow">{{::row.getProperty(col.field)}}</div> '
        },
        {
            field: 'orderStatus', displayName: '状态', width: '7.5%', cellTemplate: '' +
        '<div class="ngCellText" title="{{::row.entity.orderStatusCodeName}}">' +
        '{{::row.entity.orderStatusCodeName}}' +
        '</div>'
        }
        /*,
        {
            field: 'prescDate',
            displayName: '最后发药时间',
            width: '10%',
            cellClass: "text-center",
            cellTemplate: '' +
            '<div class="ngCellText" title="{{::getOrderDateTime(row.getProperty(col.field))}}">' +
            '{{::getOrderDateTime(row.getProperty(col.field))}}' +
            '</div>'
        }*/
    ];

    var rowTemplatePrescOrders = "<div ng-style=\"{ \'cursor\': row.cursor}\" ng-repeat=\"col in renderedColumns\"\n    ng-class=\"col.colIndex()\" class=\"ngCell {{col.cellClass}} {{changeClassState(row.entity)}}\">\n    <div class=\"ngVerticalBar\" ng-style=\"{height: rowHeight}\" ng-class=\"{ ngVerticalBarVisible: !$last }\">&nbsp;</div>\n    <div ng-cell></div>\n</div>";

    $scope.prescOrdersGrid = {
        data: 'orderDetailListPrescCreate',
        columnDefs: 'columnDefsPrescOrders',
        rowTemplate: rowTemplatePrescOrders,
        enableColumnResize: false,
        multiSelect: false,
        enableSorting: false
    };

    $scope.preventCheck = function (index) {
        var orderDetail = $scope.orderDetailListPrescCreate[index];
        if(orderDetail.groupSubNo == 1){
            angular.forEach($scope.orderDetailListPrescCreate, function(item){
                if(item.groupNo == orderDetail.groupNo)
                item.checked = orderDetail.checked;
            })
        }
        event.stopPropagation();//已在rowTemplate 添加点击行选择
    };

    $scope.changeOrdersDays = function (index) {
        var orderDetail = $scope.orderDetailListPrescCreate[index];
        var days = orderDetail.days;
        angular.forEach($scope.orderDetailListPrescCreate,function(item,index){
            if(item.groupNo == orderDetail.groupNo){
                item.days = days;
                calculateDays($scope.ordersDrugWestListPrescCreate[index].drugOrderDetail,$scope.orderDetailListPrescCreate[index]);
            }
        });
    };

    $scope.isPrescTypeShow = function (codeName) {
        if (codeName === prescAttrEnum.PT) {
            return false;
        } else if (codeName === prescAttrEnum.ET && !$scope.isChildAvaliable) {
            return false;
        }
        return true;
    };

    $scope.isPrescAttrChecked = function (codeName) {
        if (codeName === prescAttrEnum.YB && $scope.prescInsuranceSign === "1") {
            return true;
        }
        if ($scope.clinicInfo.clinicSource === clinicSourceEnum.ER_ORDER_INP && codeName === prescAttrEnum.JZ) {
            return true;
        }
        return false;
    };

    $scope.isRejectOption = function (prescTypeDict) {
        if (!$scope.prescTypeDictList) {
            return false;
        }
        if (prescTypeDict.codeName === prescAttrEnum.YB && $scope.prescInsuranceSign === "0") {
            return true;//非医保患者,禁用医保
        }
        //急诊红区 默认勾选禁用
        if ($scope.clinicInfo.clinicSource === clinicSourceEnum.ER_ORDER_INP && prescTypeDict.codeName === prescAttrEnum.JZ) {
            return true;
        }
        var prescAttr = getPrescAttr();
        if (angular.equals(prescAttr, prescAttrEnum.PT)) {//普通处方,均可用
            return false;
        }
        var prescAttrList = $scope.prescTypeDictList.filter(function (e) {
            return prescAttr.split(";").some(function (codeName) {
                return e.codeName === codeName;
            })
        });
        var isReject = prescAttrList.some(function (e) {
            if (!e.ctrvalue1) {
                return false;
            } else {
                return e.ctrvalue1.split(";").some(function (rejectCodeId) {
                    return rejectCodeId === prescTypeDict.codeId;
                });
            }
        });
        var isReverseReject = prescAttrList.some(function (e) {
            if (!prescTypeDict.ctrvalue1) {
                return false;
            } else {
                return prescTypeDict.ctrvalue1.split(";").some(function (rejectCodeId) {
                    return rejectCodeId === e.codeId;
                })
            }
        });
        return isReject || isReverseReject;
    };

    $scope.applyCheckEvent = function () {
        if (!$scope.$$phase) {
            $scope.$apply();
        }
    };

    $scope.createPresc = function () {
        //检查是否选中
        checkOrdersQuantity(function(orderDetailListPresc, ordersDrugWestListPresc){//选中的要生成的处方的医嘱
            checkTotalAmountOrDays(orderDetailListPresc, ordersDrugWestListPresc, function(){
                getDrugPrescAttr(ordersDrugWestListPresc, 0, function(){
                    var groupNo = ordersDrugWestListPresc[0].groupNo;
                    for(var i=0; i<ordersDrugWestListPresc.length; ){
                        var doctorOrders = ordersDrugWestListPresc[i];
                        if(ordersDrugWestListPresc[i].groupNo == groupNo){
                            if(ordersDrugWestListPresc[i].groupSubNo == 1){
                                doctorOrders.operationStatus = "1";
                                doctorOrders.isGroup = "0";
                            } else {
                                doctorOrders.operationStatus = "0";
                                doctorOrders.isGroup = "1";
                            }
                        } else {
                            groupNo = doctorOrders.groupNo;
                            doctorOrders.operationStatus = "1";
                            doctorOrders.isGroup = "0";
                        }
                        var drugOrderDetail = doctorOrders.drugOrderDetail;
                        drugOrderDetail.totalAmount = orderDetailListPresc[i].totalAmount;
                        drugOrderDetail.days = orderDetailListPresc[i].days;
                        //封装new InpOrderDrugInfo();
                        getOrderDrugInfo(doctorOrders, drugOrderDetail, function(orderDrugInfo){
                            $scope.addDrugInfoDetailForOrder(orderDrugInfo);
                            i++;
                        })
                    }
                })
                $scope.closePrescCreateModal();
            });
        })
    };

    (function () {
        initPrescCreate();
        getLastPerformDays(function () {
            //getPackageUnits(0);
        });
    })();
}]);


angular.module('hr.service').factory('PrescCreate', ['$templateCache', '$document', '$compile', '$rootScope', '$timeout',
    function ($templateCache, $document, $compile, $rootScope, $timeout) {

        /**
         * 打开modal
         * @param scope 父级$scope
         */
        function _openPrescCreateModal(scope) {
            new PrescCreateModal(scope).open();

        }

        function PrescCreateModal(scope) {
            this._scope = scope;
            this._activeElement = null;
            this._element = angular.element($templateCache.get('presc-create-modal.html'));
        }

        PrescCreateModal.prototype.open = function () {
            if (event) {
                event.stopPropagation();
                event.preventDefault();
            }
            this._activeElement = $(document.activeElement);
            this._activeElement.blur();
            var scope = this._scope.$new();
            scope.modal = this;
            $document.find('body').append(this._element);
            $compile(this._element)(scope);
            $timeout(function () {
                Mousetrap.reset();
            });
        };

        PrescCreateModal.prototype.close = function () {
            this._element.remove();
            this._activeElement.focus();
        };

        return {
            openPrescCreateModal: _openPrescCreateModal
        }
    }
]);

使用方式:

var InpOrdersController = ["$scope", "$q", "$http", "$filter", "hrDialog", "$timeout", "PluginManager", "$window", "HrOrderStatus", "hrProgress", "HrDrugBillingAttr", "HrBillingAttr", "PrescCreate", "MainTreatGroupVerify", "CpVariationCheck", "HrOrder", "$rootScope", "HrChargeType", "$debounce", function ($scope, $q, $http, $filter, hrDialog, $timeout, PluginManager, $window, HrOrderStatus, hrProgress, HrDrugBillingAttr, HrBillingAttr, PrescCreate, MainTreatGroupVerify, CpVariationCheck, HrOrder, $rootScope, HrChargeType, $debounce) {
    //生成处方调用
    $scope.openCreatePrescModal = function () {
        if ($scope.operButtonDisabled.create) {
            return false;
        }
        findPerformOrders(function () {
            PrescCreate.openPrescCreateModal($scope);
        });
    };
}];

因为绑定InpOrdersControllr的module注入了hr所以在InpOrdersController可以注入hr下的PrescCreate

转载于:https://www.cnblogs.com/ms-grf/p/8940700.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值