UNPKG

xn-directive-lookup

Version:

xn-directive-lookup

958 lines (917 loc) 49.4 kB
var bankList = [ {"id": "1", "name": "渤海银行", "type": "BANK",prefix:"b"}, {"id": "2", "name": "广发银行", "type": "BANK",prefix:"g"}, {"id": "3", "name": "国家开发银行", "type": "BANK",prefix:"g"}, {"id": "4", "name": "恒丰银行", "type": "BANK",prefix:"h"}, {"id": "5", "name": "华夏银行", "type": "BANK",prefix:"h"}, {"id": "6", "name": "交通银行", "type": "BANK",prefix:"j"}, {"id": "7", "name": "平安银行", "type": "BANK",prefix:"p"}, {"id": "8", "name": "上海浦东发展银行", "type": "BANK",prefix:"s"}, {"id": "9", "name": "兴业银行", "type": "BANK",prefix:"x"}, {"id": "10", "name": "招商银行", "type": "BANK",prefix:"z"}, {"id": "11", "name": "浙商银行", "type": "BANK",prefix:"z"}, {"id": "12", "name": "中国工商银行", "type": "BANK",prefix:"z"}, {"id": "13", "name": "中国光大银行", "type": "BANK",prefix:"z"}, {"id": "14", "name": "中国建设银行", "type": "BANK",prefix:"z"}, {"id": "15", "name": "中国民生银行", "type": "BANK",prefix:"z"}, {"id": "16", "name": "中国农业银行", "type": "BANK",prefix:"z"}, {"id": "17", "name": "中国银行", "type": "BANK",prefix:"z"}, {"id": "18", "name": "中国邮政储蓄银行", "type": "BANK",prefix:"z"}, {"id": "19", "name": "中信银行", "type": "BANK",prefix:"z"}, {"id": "20", "name": "安阳银行", "type": "BANK",prefix:"a"}, {"id": "21","name": "鞍山银行","type": "BANK",prefix:"a"}, {"id": "22", "name": "包商银行", "type": "BANK",prefix:"b"}, {"id": "23", "name": "保定银行", "type": "BANK",prefix:"b"}, {"id": "24", "name": "北京银行","type": "BANK",prefix:"b"}, {"id": "25", "name": "本溪市商业银行", "type": "BANK",prefix:"b"}, {"id": "26", "name": "沧州银行", "type": "BANK",prefix:"c"}, {"id": "27", "name": "长安银行","type": "BANK",prefix:"c"}, {"id": "28", "name": "长沙银行", "type": "BANK",prefix:"c"}, {"id": "29", "name": "长治市商业银行", "type": "BANK",prefix:"c"}, {"id": "30","name": "朝阳银行","type": "BANK",prefix:"c"}, {"id": "31", "name": "成都银行", "type": "BANK",prefix:"c"}, {"id": "32", "name": "承德银行", "type": "BANK",prefix:"c"}, {"id": "33", "name": "重庆三峡银行", "type": "BANK",prefix:"c"}, {"id": "34", "name": "重庆银行", "type": "BANK",prefix:"c"}, {"id": "35", "name": "达州市商业银行", "type": "BANK",prefix:"d"}, {"id": "36", "name": "大连银行", "type": "BANK",prefix:"d"}, {"id": "37", "name": "大同市商业银行", "type": "BANK",prefix:"d"}, {"id": "38", "name": "丹东银行", "type": "BANK",prefix:"d"}, {"id": "39", "name": "德阳银行", "type": "BANK",prefix:"d"}, {"id": "40", "name": "德州银行", "type": "BANK",prefix:"d"}, {"id": "41", "name": "东莞银行", "type": "BANK",prefix:"d"}, { "id": "42", "name": "东营银行", "type": "BANK",prefix:"d"}, {"id": "43", "name": "鄂尔多斯银行", "type": "BANK",prefix:"e"}, {"id": "44", "name": "福建海峡银行", "type": "BANK",prefix:"f"}, { "id": "45", "name": "抚顺银行", "type": "BANK",prefix:"f"}, {"id": "46", "name": "阜新银行", "type": "BANK",prefix:"f"}, {"id": "47", "name": "富滇银行", "type": "BANK",prefix:"f"}, { "id": "48", "name": "甘肃银行", "type": "BANK",prefix:"g"}, {"id": "49", "name": "赣州银行", "type": "BANK",prefix:"g"}, {"id": "50", "name": "广东华兴银行", "type": "BANK",prefix:"g"}, { "id": "51", "name": "广东南粤银行", "type": "BANK",prefix:"g"}, {"id": "52", "name": "广西北部湾银行", "type": "BANK",prefix:"g"}, {"id": "53", "name": "广州银行", "type": "BANK",prefix:"g"}, { "id": "54", "name": "贵阳银行", "type": "BANK",prefix:"g"}, {"id": "55", "name": "贵州银行", "type": "BANK",prefix:"g"}, {"id": "56", "name": "桂林银行", "type": "BANK",prefix:"g"}, { "id": "57", "name": "哈尔滨银行", "type": "BANK",prefix:"h"}, {"id": "58", "name": "哈密市商业银行", "type": "BANK",prefix:"h"}, {"id": "59", "name": "邯郸银行", "type": "BANK",prefix:"h"}, { "id": "60", "name": "汉口银行", "type": "BANK",prefix:"h"}, {"id": "61", "name": "杭州银行", "type": "BANK",prefix:"h"}, {"id": "62", "name": "河北银行", "type": "BANK",prefix:"h"}, { "id": "63", "name": "鹤壁银行", "type": "BANK",prefix:"h"}, {"id": "64", "name": "衡水银行", "type": "BANK",prefix:"h"}, {"id": "65", "name": "葫芦岛银行", "type": "BANK",prefix:"h"}, { "id": "66", "name": "湖北银行", "type": "BANK",prefix:"h"}, {"id": "67", "name": "湖州银行", "type": "BANK",prefix:"h"}, {"id": "68", "name": "华融湘江银行", "type": "BANK",prefix:""}, { "id": "69", "name": "徽商银行", "type": "BANK",prefix:"h"}, {"id": "70", "name": "吉林银行", "type": "BANK",prefix:"j"}, {"id": "71", "name": "济宁银行", "type": "BANK",prefix:"j"}, { "id": "72", "name": "嘉兴银行", "type": "BANK",prefix:"j"}, {"id": "73", "name": "江苏银行", "type": "BANK",prefix:"j"}, {"id": "74", "name": "江苏长江商业银行", "type": "BANK",prefix:"j"}, { "id": "75", "name": "焦作市商业银行", "type": "BANK",prefix:"j"}, {"id": "76", "name": "金华银行", "type": "BANK",prefix:"j"}, {"id": "77", "name": "锦州银行", "type": "BANK",prefix:"j"}, { "id": "78", "name": "晋城银行", "type": "BANK",prefix:"j"}, {"id": "79", "name": "晋商银行", "type": "BANK",prefix:"j"}, {"id": "80", "name": "晋中市商业银行", "type": "BANK",prefix:"j"}, { "id": "81", "name": "景德镇市商业银行", "type": "BANK",prefix:"j"}, {"id": "82", "name": "九江银行", "type": "BANK",prefix:"j"}, {"id": "83", "name": "开封市商业银行", "type": "BANK",prefix:"k"}, { "id": "84", "name": "库尔勒市商业银行", "type": "BANK",prefix:"k"}, {"id": "85", "name": "昆仑银行", "type": "BANK",prefix:"k"}, {"id": "86", "name": "莱商银行", "type": "BANK",prefix:"l"}, { "id": "87", "name": "兰州银行", "type": "BANK",prefix:"l"}, {"id": "88", "name": "廊坊银行", "type": "BANK",prefix:"l"}, {"id": "89", "name": "乐山市商业银行", "type": "BANK",prefix:"l"}, { "id": "90", "name": "凉山州商业银行", "type": "BANK",prefix:"l"}, {"id": "91", "name": "辽阳银行", "type": "BANK",prefix:"l"}, {"id": "92", "name": "临商银行", "type": "BANK",prefix:"l"}, { "id": "93", "name": "柳州银行", "type": "BANK",prefix:"l"}, {"id": "94", "name": "龙江银行", "type": "BANK",prefix:"l"}, {"id": "95", "name": "泸州市商业银行", "type": "BANK",prefix:"l"}, { "id": "96", "name": "洛阳银行", "type": "BANK",prefix:"l"}, {"id": "97", "name": "漯河银行", "type": "BANK",prefix:"l"}, {"id": "98", "name": "绵阳市商业银行", "type": "BANK",prefix:"m"}, { "id": "99", "name": "南昌银行", "type": "BANK",prefix:"n"}, {"id": "100", "name": "南充市商业银行", "type": "BANK",prefix:"n"}, {"id": "101", "name": "南京银行", "type": "BANK",prefix:"n"}, { "id": "102", "name": "南阳银行", "type": "BANK",prefix:"n"}, {"id": "103", "name": "内蒙古银行", "type": "BANK",prefix:"n"}, {"id": "104", "name": "宁波东海银行", "type": "BANK",prefix:"n"}, { "id": "105", "name": "宁波通商银行", "type": "BANK",prefix:"n"}, {"id": "106", "name": "宁波银行", "type": "BANK",prefix:"n"}, {"id": "107", "name": "宁夏银行", "type": "BANK",prefix:"n"}, {"id": "108", "name": "攀枝花市商业银行", "type": "BANK",prefix:"p"}, {"id": "109", "name": "盘锦市商业银行", "type": "BANK",prefix:"p"}, {"id": "110", "name": "平顶山银行", "type": "BANK",prefix:"p"}, { "id": "111", "name": "濮阳银行", "type": "BANK",prefix:"p"}, {"id": "112", "name": "齐鲁银行", "type": "BANK",prefix:"q"}, {"id": "113", "name": "齐商银行", "type": "BANK",prefix:"q"}, {"id": "114", "name": "秦皇岛银行", "type": "BANK",prefix:"q"}, {"id": "115", "name": "青岛银行", "type": "BANK",prefix:"q"}, {"id": "116", "name": "青海银行", "type": "BANK",prefix:"q"}, { "id": "117", "name": "曲靖市商业银行", "type": "BANK",prefix:"q"}, {"id": "118", "name": "泉州银行", "type": "BANK",prefix:"q"}, {"id": "119", "name": "日照银行", "type": "BANK",prefix:"r"}, { "id": "120", "name": "三门峡银行", "type": "BANK",prefix:"s"}, {"id": "121", "name": "商丘银行", "type": "BANK",prefix:"s"}, {"id": "122", "name": "上海银行", "type": "BANK",prefix:"s"}, { "id": "123", "name": "上饶银行", "type": "BANK",prefix:"s"}, {"id": "124", "name": "绍兴银行", "type": "BANK",prefix:"s"}, {"id": "125", "name": "盛京银行", "type": "BANK",prefix:"s"}, { "id": "126", "name": "石嘴山银行", "type": "BANK",prefix:"s"}, {"id": "127", "name": "苏州银行", "type": "BANK",prefix:"s"}, {"id": "128", "name": "遂宁市商业银行", "type": "BANK",prefix:"s"}, { "id": "129", "name": "台州银行", "type": "BANK",prefix:"t"}, {"id": "130", "name": "泰安市商业银行", "type": "BANK",prefix:"t"}, {"id": "131", "name": "唐山市商业银行", "type": "BANK",prefix:"t"}, { "id": "132", "name": "天津银行", "type": "BANK",prefix:"t"}, {"id": "133", "name": "铁岭银行", "type": "BANK",prefix:"t"}, {"id": "134", "name": "威海市商业银行", "type": "BANK",prefix:"w"}, { "id": "135", "name": "潍坊银行", "type": "BANK",prefix:"w"}, {"id": "136", "name": "温州银行", "type": "BANK",prefix:"w"}, {"id": "137", "name": "乌海银行", "type": "BANK",prefix:"w"}, { "id": "138", "name": "乌鲁木齐市商业银行", "type": "BANK",prefix:"w"}, {"id": "139", "name": "西安银行", "type": "BANK",prefix:"x"}, {"id": "140", "name": "西藏银行", "type": "BANK",prefix:"x"}, { "id": "141", "name": "厦门国际银行", "type": "BANK",prefix:"x"}, {"id": "142", "name": "厦门银行", "type": "BANK",prefix:"x"}, {"id": "143", "name": "新疆汇和银行", "type": "BANK",prefix:"x"}, { "id": "144", "name": "新乡银行", "type": "BANK",prefix:"x"}, {"id": "145", "name": "信阳银行", "type": "BANK",prefix:"x"}, {"id": "146", "name": "邢台银行", "type": "BANK",prefix:"x"}, { "id": "147", "name": "许昌银行", "type": "BANK",prefix:"x"}, {"id": "148", "name": "雅安市商业银行", "type": "BANK",prefix:"y"}, {"id": "149", "name": "烟台银行", "type": "BANK",prefix:"y"}, { "id": "150", "name": "阳泉市商业银行", "type": "BANK",prefix:"y"}, {"id": "151", "name": "宜宾市商业银行", "type": "BANK",prefix:"y"}, {"id": "152", "name": "营口沿海银行", "type": "BANK",prefix:"y"}, { "id": "153", "name": "营口银行", "type": "BANK",prefix:"y"}, {"id": "154", "name": "玉溪市商业银行", "type": "BANK",prefix:"y"}, {"id": "155", "name": "枣庄银行", "type": "BANK",prefix:"z"}, { "id": "156", "name": "张家口市商业银行", "type": "BANK",prefix:"z"}, {"id": "157", "name": "浙江稠州商业银行", "type": "BANK",prefix:"z"}, { "id": "158", "name": "浙江民泰商业银行", "type": "BANK",prefix:"z"}, {"id": "159", "name": "浙江泰隆商业银行", "type": "BANK",prefix:"z"}, {"id": "160", "name": "郑州银行", "type": "BANK",prefix:"z"}, { "id": "161", "name": "中德住房储蓄银行", "type": "BANK",prefix:"z"}, {"id": "162", "name": "周口银行", "type": "BANK",prefix:"z"}, {"id": "163", "name": "珠海华润银行", "type": "BANK",prefix:"z"}, { "id": "164", "name": "驻马店银行", "type": "BANK",prefix:"z"}, {"id": "165", "name": "自贡市商业银行", "type": "BANK",prefix:"z"}, {"id": "166", "name": "南洋商业银行", "type": "BANK",prefix:"n"}, {"id": "167", "name": "昆山农村商业银行", "type": "BANK",prefix:"k"}, {"id": "168", "name": "江苏省农村信用社联合社", "type": "BANK",prefix:"j"}, {"id": "169", "name": "北京农商银行", "type": "BANK",prefix:"b"}, {"id": "170", "name": "浙江省农村信用社联合社(瑞丰银行)", "type": "BANK",prefix:"z"}, {"id": "171", "name": "中国农商银行", "type": "BANK",prefix:"z"}, {"id": "1000","name": "支付宝", "type": "THIRD_PAY","code": "ALIPAY",prefix:"z"}, {"id": "1001","name": "微信支付","type": "THIRD_PAY","code": "WECHAT",prefix:"w"} ]; angular.module("xn/template/lookup.html",[]).run(["$templateCache", function($templateCache){ "use strict"; $templateCache.put("xn/template/lookup/xnAccount.html", "<div id='{{id}}' class='xn-account-layout'>" + " <div class='account-input-box' ng-class='{\"account-input-focus\":vm.showList||vm.match}' >"+ " <input type='text' class='account-input' ng-model='vm.keyword' ng-required='{{vm.required}}' id='tableText' name='{{vm.name}}' autocomplete=\"off\" placeholder=\"{{xnPlaceholder}}\" " + " ng-focus='doFocus()' ng-blur='doBlur()' ng-keyup=\"keydown($event)\"/>"+ " <span class='expand' ng-class='{\"expand-active\":vm.showList}' ng-click='openList($event)'></span>"+ " <span class=\"delete-icon\" ng-show=\"vm.keyword\" ng-click=\"delete($event)\">X</span>"+ " </div>"+ " <div ng-if='vm.showList' class='account-list-layout'>" + " <div class='account-list' ng-show='itemList.length>0'>" + " <div class='account-description'>你可以在输入框内输入或者在下面选择一个会计科目</div>" + " <ul class='account-type-tabs clearfix'>" + " <li class='account-type-tab' ng-repeat='type in typeList' ng-class=\"type.state?'account-type-tab-active':''\" ng-click='changeTab(type,$index)'>{{type.value}}" + " </li>"+ " </ul>"+ " <ul class='account-items-box clearfix' ng-show=\"vm.showType=='ASSET'\">" + " <li class='account-item' ng-class='{\"account-item-active\":vm.index==$index}' ng-repeat=\"item in assetList track by $index\" ng-click='selectItem(item,$event)' >" + " <span>{{item.code}}</span>" + " <span class='account-name'>{{item.accountName}}</span>" + " </li>"+ " </ul>"+ " <ul class='account-items-box clearfix' ng-show=\"vm.showType=='LIABILITY'\">" + " <li class='account-item' ng-class='{\"account-item-active\":vm.index==$index}' ng-repeat=\"item in liabilityList track by $index\" ng-click='selectItem(item,$event)' >" + " <span>{{item.code}}</span>" + " <span class='account-name'>{{item.accountName}}</span>" + " </li>"+ " </ul>"+ " <ul class='account-items-box clearfix' ng-show=\"vm.showType=='COMMON'\">" + " <li class='account-item' ng-class='{\"account-item-active\":vm.index==$index}' ng-repeat=\"item in commonList track by $index\" ng-click='selectItem(item,$event)' >" + " <span>{{item.code}}</span>" + " <span class='account-name'>{{item.accountName}}</span>" + " </li>"+ " </ul>"+ " <ul class='account-items-box clearfix' ng-show=\"vm.showType=='OWNERS_EQUITY'\">" + " <li class='account-item' ng-class='{\"account-item-active\":vm.index==$index}' ng-repeat=\"item in owerseQuityList track by $index\" ng-click='selectItem(item,$event)' >" + " <span>{{item.code}}</span>" + " <span class='account-name'>{{item.accountName}}</span>" + " </li>"+ " </ul>"+ " <ul class='account-items-box clearfix' ng-show=\"vm.showType=='COST'\">" + " <li class='account-item' ng-class='{\"account-item-active\":vm.index==$index}' ng-repeat=\"item in costList track by $index\" ng-click='selectItem(item,$event)' >" + " <span>{{item.code}}</span>" + " <span class='account-name'>{{item.accountName}}</span>" + " </li>"+ " </ul>"+ " <ul class='account-items-box clearfix' ng-show=\"vm.showType=='PROFIT_LOSS'\">" + " <li class='account-item' ng-class='{\"account-item-active\":vm.index==$index}' ng-repeat=\"item in profitLossList track by $index\" ng-click='selectItem(item,$event)' >" + " <span>{{item.code}}</span>" + " <span class='account-name'>{{item.accountName}}</span>" + " </li>"+ " </ul>"+ " </div> "+ " <div class='account-list' ng-show='itemList.length==0'>没有输入的相关内容</div>"+ " </div>"+ " <div class='account-match-layout' ng-show=\"vm.match\" >" + " <div class='account-match-list' ng-show='itemList.length>0'>" + " <ul class='account-match-box clearfix'>" + " <li class='account-match-item clearfix' ng-class='{\"account-match-active\":vm.index==$index}' ng-repeat='item in itemList' ng-click='selectItem(item,$event)' >" + " <span class=\"xn-col-md-6\">{{item.code}}</span>" + " <span class='xn-col-md-16 account-match-name'>{{item.accountName}}</span>" + " </li>"+ " </ul>"+ " </div>"+ " <div class='account-match-list' ng-show='itemList.length==0'>没有相关内容</div>"+ " </div>"+ "</div>" ); $templateCache.put("xn/template/lookup/xnBank.html", "<div id='{{id}}' class='xn-bank-layout'>" + " <div class='bank-input-box' >"+ " <input type='text' class='bank-input' ng-model='vm.keyword' ng-required='{{vm.required}}' id='tableText' name='{{vm.name}}' autocomplete=\"off\" placeholder=\"{{xnPlaceholder}}\" " + " ng-focus='doFocus()' ng-blur='doBlur()' ng-keyup=\"onKeydown($event)\"/>"+ " <span class='expand' ng-class='{\"expand-active\":vm.showList}' ng-click='openList($event)'></span>"+ " <span class=\"delete-icon\" ng-show=\"vm.keyword\" ng-click=\"delete($event)\">X</span>"+ " </div>"+ " <div class='bank-list-layout' ng-show=\"vm.showList && vm.keyword.length==0\" >" + " <div class='bank-list' >" + " <div class='bank-description'>你可以在输入框内输入或者在下面选择一个银行</div>" + " <div>" + " <ul class='bank-tabs clearfix'>" + " <li class='tab-item' ng-class=\"{'tab-active':vm.tabState===1}\" ng-click='changeTab(1)'>常用</li>"+ " <li class='tab-item' ng-class=\"{'tab-active':vm.tabState===2}\" ng-click='changeTab(2)'>A-G</li>"+ " <li class='tab-item' ng-class=\"{'tab-active':vm.tabState===3}\" ng-click='changeTab(3)'>H-K</li>"+ " <li class='tab-item' ng-class=\"{'tab-active':vm.tabState===4}\" ng-click='changeTab(4)'>L-S</li>"+ " <li class='tab-item' ng-class=\"{'tab-active':vm.tabState===5}\" ng-click='changeTab(5)'>T-Z</li>"+ " </ul>"+ " </div> " + " <ul class='bank-items-box clearfix' ng-show=\"vm.tabState===1\">" + " <li class='bank-item' ng-repeat=\"item in bankGroups.host track by $index\" ng-click='selectItem(item,$event)' >" + " <span class='bank-name' ng-class='{\"bank-active\":vm.initIndex==$index}' ><i class='bank-icon bank-icon{{item.id}}''></i>{{item.name}}</span>" + " </li>"+ " </ul>"+ " <ul class='bank-items-box clearfix' ng-show=\"vm.tabState===2\">" + " <li class='bank-item' ng-repeat=\"item in bankGroups.AGList track by $index\" ng-click='selectItem(item,$event)' >" + " <span class='bank-name' ng-class='{\"bank-active\":vm.initIndex==$index}'><i class='bank-icon bank-icon{{item.id}}''></i>{{item.name}}</span>" + " </li>"+ " </ul>"+ " <ul class='bank-items-box clearfix' ng-show=\"vm.tabState===3\">" + " <li class='bank-item' ng-repeat=\"item in bankGroups.HKList track by $index\" ng-click='selectItem(item,$event)' >" + " <span class='bank-name' ng-class='{\"bank-active\":vm.initIndex==$index}'><i class='bank-icon bank-icon{{item.id}}''></i>{{item.name}}</span>" + " </li>"+ " </ul>"+ " <ul class='bank-items-box clearfix' ng-show=\"vm.tabState===4\">" + " <li class='bank-item' ng-repeat=\"item in bankGroups.LSList track by $index\" ng-click='selectItem(item,$event)' >" + " <span class='bank-name' ng-class='{\"bank-active\":vm.initIndex==$index}'><i class='bank-icon bank-icon{{item.id}}''></i>{{item.name}}</span>" + " </li>"+ " </ul>"+ " <ul class='bank-items-box clearfix' ng-show=\"vm.tabState===5\">" + " <li class='bank-item' ng-repeat=\"item in bankGroups.TZList track by $index\" ng-click='selectItem(item,$event)' >" + " <span class='bank-name' ng-class='{\"bank-active\":vm.initIndex==$index}'><i class='bank-icon bank-icon{{item.id}}''></i>{{item.name}}</span>" + " </li>"+ " </ul>"+ " </div> "+ " </div>"+ " <div class='bank-match-layout' ng-show=\"vm.showList && vm.keyword.length>0\" >" + " <div class='bank-match-list' ng-show='responseList.length>0'>" + " <ul class='bank-match-box clearfix'>" + " <li class='bank-match-item clearfix' ng-repeat='item in responseList' ng-click='selectItem(item,$event)' >" + " <span class='bank-name' ng-class='{\"bank-active\":vm.searchIndex==$index}'><i class='bank-icon bank-icon{{item.id}}''></i>{{item.name}}</span>" + " </li>"+ " </ul>"+ " </div>"+ " <div class='bank-match-list' ng-show='responseList.length==0'>没有相关内容</div>"+ " </div>"+ "</div>" ) }]); //财务 var xnAccount=function($timeout,$q){ return { restrict: "EA", scope: { data: "=ngModel", /*传出和传进的值*/ searchKey: "@", /*查的key一般是id*/ searchVal: "@", /*查的value一般是name*/ required: "@", /*本输入框是否必填*/ name: "@", /*输入框的名字*/ pageSize: "@", /*查询每页的数量*/ placeholder: "@", /*提示信息*/ callback: "&", /*回调函数*/ method: "&" , /*外部方法*/ showType:"@" }, templateUrl: "xn/template/lookup/xnAccount.html", replace: true, require: "^ngModel", link: function (scope, elements, attrs) { scope.typeList=[ {key:'ASSET',value:'资产类',state:false}, {key:'LIABILITY',value:'负债类',state:false}, {key:'COMMON',value:'共同类' ,state:false}, {key:'OWNERS_EQUITY',value:'所有者权益类',state:false}, {key:'COST',value:'成本类',state:false}, {key:'PROFIT_LOSS',value:'损益类',state:true} ]; scope.itemList = []; scope.assetList=[]; scope.liabilityList=[]; scope.commonList=[]; scope.owerseQuityList=[]; scope.costList=[]; scope.profitLossList=[]; var time = new Date().getTime(); scope.id = "xnLookup" + time; scope.vm={ showList:false, //显示tab选择框 match:false,//动态查询显示match框 showType:scope.showType, key:scope.searchKey||"accountId", //关键词 val:scope.searchVal||"accountName", //搜索关键词 name:scope.name||"LookupName"+time, //输入框名称 required:scope.required||false, //输入框是否必填 isPopup:scope.isPopup||false, keyword:"", pageSize:Number(scope.pageSize)|| 10, pageNumber:1 }; scope.xnPlaceholder = scope.placeholder || ""; var interval = 0; var hasSearch = true; setInterval(function () { interval += 10; if(interval >= 350 && !hasSearch) { getList(); } }, 10); //删除数据 scope.delete=function () { interval = 0; hasSearch = false; scope.data=""; scope.vm.keyword=""; scope.assetList=[]; scope.liabilityList=[]; scope.commonList=[]; scope.owerseQuityList=[]; scope.costList=[]; scope.profitLossList=[]; }; //获取焦距 scope.doFocus = function () { if (!scope.vm.keyword) { scope.vm.showList = true; scope.vm.match = false; } else { scope.vm.showList = false; scope.vm.match = true; scope.vm.typeEnumList = []; } getList(); }; //打开右边按钮 scope.openList=function (e) { scope.vm.showList=!scope.vm.showList; if(scope.vm.showList){ $timeout(function() { $("#"+scope.id+" .account-input").focus(); }, 0); }else { //关闭 if(!angular.isObject(scope.data)){ scope.vm.keyword=""; } } }; /*切换tab*/ scope.changeTab=function (type,index) { for(var i=0;i<scope.typeList.length;i++){ if(i==index){ scope.typeList[i].state=true; }else { scope.typeList[i].state=false; } } scope.vm.showType=type.key; ; scope.vm.showList=true; }; //监控外部ng-model是否有值 scope.$watch(function () { return scope.data; },function (newData) { if(angular.isObject(newData)){ scope.vm.keyword=angular.copy(newData[scope.vm.key]+"-"+newData[scope.vm.val]); } }); //获取列表数据 function getList() { scope.assetList=[]; scope.liabilityList=[]; scope.commonList=[]; scope.owerseQuityList=[]; scope.costList=[]; scope.profitLossList=[]; if (!scope.vm.keyword) { scope.vm.showList = true; scope.vm.match = false; } else { scope.vm.showList = false; scope.vm.match = true; } hasSearch = true; var deferred = $q.defer(); var data={ pageSize: scope.vm.pageSize, pageNumber:scope.vm.pageNumber }; if(scope.vm.keyword){ data.keyword= scope.vm.keyword.split("-")[0]; }else{ data.keyword= scope.vm.keyword; } scope.method({data:{"deferred":deferred,data:data}}); deferred.promise.then(function (data) { console.log(data); //列表负值 scope.itemList=[]; scope.itemList=data.itemList|| []; if(scope.itemList.length>0){ for (var i = 0; i <scope.itemList.length; i++) { if (scope.itemList[i].accountType == "ASSET") { scope.assetList.push(scope.itemList[i]); } else if (scope.itemList[i].accountType == "LIABILITY") { scope.liabilityList.push(scope.itemList[i]); } else if (scope.itemList[i].accountType == "COMMON") { scope.commonList.push(scope.itemList[i]); } else if (scope.itemList[i].accountType == "OWNERS_EQUITY") { scope.owerseQuityList.push(scope.itemList[i]); } else if (scope.itemList[i].accountType == "COST") { scope.costList.push(scope.itemList[i]); } else if (scope.itemList[i].accountType == "PROFIT_LOSS") { scope.profitLossList.push(scope.itemList[i]); } } } //判断第几个 if(scope.vm.match){ if(angular.isObject(scope.data)){ var state=true; angular.forEach(data,function (item,index) { if(item[scope.vm.key]==scope.data[scope.vm.key]){ scope.vm.index=index; state=false; } }); if(state){ scope.vm.index=0; } }else { scope.vm.index=0; } } }); } //选择 scope.selectItem=function (data,e) { e.preventDefault(); e.stopPropagation(); scope.data=angular.copy(data); scope.vm.keyword=angular.copy(data[scope.vm.key]+"-"+data[scope.vm.val]); scope.vm.showList=false; scope.vm.match=false; callback(data); }; //初始化pageNumber function initPage(){ scope.vm.pageNumber=1; } // 按键事件 scope.keydown = function(e) { scope.onKeydown(e); }; scope.onKeydown=function (e) { // //定义选中第几个 var e = window.event || arguments.callee.caller.arguments[0]; switch (e.keyCode||e.which||e.charCode){ case 13: //回车 var data=scope.itemList[scope.vm.index]; scope.data=angular.copy(data); scope.vm.keyword=angular.copy(data[scope.vm.val]); scope.vm.showList=false; //调用外部方法 callback(data); break; case 40: //向下 e.preventDefault(); e.stopPropagation(); if(scope.itemList.length-1>scope.vm.index){ scope.vm.index++; } break; case 38://向上 e.preventDefault(); e.stopPropagation(); if(scope.vm.index>0){ scope.vm.index--; } break; case 27: //退出 esc scope.vm.showList=false; scope.vm.match=false; if(!angular.isObject(scope.data)){ scope.vm.keyword=""; } break; case 8://backspace interval = 0; hasSearch = false; initPage(); scope.data=""; break; case 46://删除 interval = 0; hasSearch = false; scope.data=""; scope.vm.keyword=""; initPage(); scope.data=""; break; default: interval = 0; hasSearch = false; initPage(); scope.data=""; break; } }; //选择时调用外部方法 function callback(data){ if(scope.callback){ scope.callback({data:data}); } }; //已开鼠标 关闭 var getPar = function(tar) { if(tar.id==scope.id){ scope.count++; } if(tar.parentElement){ getPar(tar.parentElement); } }; angular.element(document).bind("click", function(e) { scope.count = 0; getPar(e.target); if(scope.count == 0) { scope.$apply(function(){ scope.vm.showList=false; if(!angular.isObject(scope.data)){ scope.vm.keyword=""; } }) } }); } } }; //银行 var xnBank=function($timeout,$filter,bankList){ return { restrict: "EA", scope: { data:"=ngModel", /*传出和传进的值*/ placeholder : "@", /*提示信息*/ required: "@", /*本输入框是否必填*/ name: "@", /*输入框的名字*/ callback: "&" /*回调函数*/ }, templateUrl: "xn/template/lookup/xnBank.html", replace: true, require: "^ngModel", link: function (scope, elements, attrs) { scope.bankList=bankList; //分类 scope.bankGroups={ host:[ {"id": "12", "name": "中国工商银行", "type": "BANK",prefix:"z"}, {"id": "16", "name": "中国农业银行", "type": "BANK",prefix:"z"}, {"id": "14", "name": "中国建设银行", "type": "BANK",prefix:"z"}, {"id": "6", "name": "交通银行", "type": "BANK",prefix:"j"}, {"id": "10", "name": "招商银行", "type": "BANK",prefix:"z"}, {"id": "17", "name": "中国银行", "type": "BANK",prefix:"z"}, {"id": "18", "name": "中国邮政储蓄银行", "type": "BANK",prefix:"z"}, {"id": "5", "name": "华夏银行", "type": "BANK",prefix:"h"}, {"id": "8", "name": "上海浦东发展银行", "type": "BANK",prefix:"s"}, {"id": "2", "name": "广发银行", "type": "BANK",prefix:"g"}, {"id": "15", "name": "中国民生银行", "type": "BANK",prefix:"z"}, {"id": "122", "name": "上海银行", "type": "BANK",prefix:"s"}, {"id": "9", "name": "兴业银行", "type": "BANK",prefix:"x"}, {"id": "11", "name": "浙商银行", "type": "BANK",prefix:"z"}, {"id": "24", "name": "北京银行","type": "BANK",prefix:"b"}, {"id": "1", "name": "渤海银行", "type": "BANK",prefix:"b"}, {"id": "13", "name": "中国光大银行", "type": "BANK",prefix:"z"}, {"id": "19", "name": "中信银行", "type": "BANK",prefix:"z"}, {"id": "4", "name": "恒丰银行", "type": "BANK",prefix:"h"}, {"id": "127", "name": "苏州银行", "type": "BANK",prefix:"s"} ], AGList:[], HKList:[], LSList:[], TZList:[] }; //过滤后返回的数据 scope.responseList=[]; //keydwon 切换后保存的数据 var bankTabList=angular.copy(scope.bankGroups.host); angular.forEach(bankList,function (bank) { switch (bank.prefix){ case "a": case "b": case "c": case "d": case "e": case "f": case "g": scope.bankGroups.AGList.push(bank); break; case "h": case "i": case "j": case "k": scope.bankGroups.HKList.push(bank); break; case "l": case "m": case "n": case "o": case "p": case "q": case "r": case "s": scope.bankGroups.LSList.push(bank); break; case "t": case "u": case "v": case "w": case "x": case "y": case "z": scope.bankGroups.TZList.push(bank); break; } }); console.log(scope.bankGroups); var time = new Date().getTime(); scope.id = "xnLookup" + time; scope.vm={ required : "@", name : "@", tabState:1, keyword:"", showList:false, //数据是否显示 dataState:false, //数据是否正确: initIndex:0, searchIndex:0 }; scope.xnPlaceholder=scope.placeholder||""; //获取焦距 scope.doFocus=function () { scope.vm.showList=true; scope.vm.initIndex=0; getList(); }; //切换 scope.changeTab=function (index) { scope.vm.tabState=index; scope.vm.initIndex=0; $timeout(function() { $("#"+scope.id+" .bank-input").focus(); }, 0); bankTabList=[]; switch(index){ case 1: bankTabList=angular.copy(scope.bankGroups.host); break; case 2: bankTabList=angular.copy(scope.bankGroups.AGList); break; case 3: bankTabList=angular.copy(scope.bankGroups.HKList); break; case 4: bankTabList=angular.copy(scope.bankGroups.LSList); break; case 5: bankTabList=angular.copy(scope.bankGroups.TZList); break; } }; //keyword 赋值 function defineKeyword(data){ scope.vm.keyword=angular.copy(data.name); scope.vm.dataState=true; } //判断数组 scope.$watch(function () { return scope.data; },function (newData) { if(scope.data){ angular.forEach(scope.bankList,function (bank) { if(bank.id==newData){ defineKeyword(bank); } }); }else { scope.vm.keyword=""; } }); scope.openList=function (e) { // e.preventDefault(); // e.stopPropagation(); scope.vm.showList=!scope.vm.showList; if(scope.vm.showList){ //打开 // getList(); $timeout(function() { $("#"+scope.id+" .bank-input").focus(); }, 0); }else { //关闭 if(!scope.vm.dataState){ scope.vm.keyword=""; } } }; //失去焦点 function doBlur() { $timeout(function() { $("#"+scope.id+" .bank-input").blur(); }, 0); } //删除数据 scope.delete=function () { scope.vm.keyword=""; scope.vm.dataState=false; scope.data=""; }; //获取列表数据 function getList() { scope.responseList=[]; scope.responseList=$filter('filter')(scope.bankList,{name:scope.vm.keyword}); //判断第几个 if(scope.vm.dataState){ var state=true; angular.forEach(function () { return scope.responseList; },function (item,index) { if(item.id==scope.data){ scope.vm.searchIndex=index; state=false; } }); if(state){ scope.vm.searchIndex=0; } }else { scope.vm.searchIndex=0; } } //选择时调用外部方法 function callback(data){ if(scope.callback){ scope.callback({data:data}); } } // 按键事件 scope.onKeydown=function (e) { scope.vm.showList=true; scope.vm.dataState=false; scope.data=""; switch (e.keyCode){ case 13: //回车 var data=""; if(scope.vm.keyword){ //有数据 data=scope.responseList[scope.vm.searchIndex]; }else { //没有数据 data=bankTabList[scope.vm.initIndex]; } scope.data=data.id; defineKeyword(data); scope.vm.showList=false; doBlur(); //调用外部方法 callback(data); break; case 40: //向下 e.preventDefault(); e.stopPropagation(); if(scope.vm.keyword && scope.responseList.length-1>scope.vm.searchIndex){ //有数据 scope.vm.searchIndex++; }else { //没有数据 if(bankTabList.length-1>scope.vm.initIndex){ scope.vm.initIndex++; } } break; case 38://向上 e.preventDefault(); e.stopPropagation(); if(scope.vm.keyword && scope.vm.searchIndex>0){ //有数据 scope.vm.searchIndex--; }else { //没有数据 if(scope.vm.initIndex>0){ scope.vm.initIndex--; } } break; case 39: //右边 break; case 37: //向左 break; case 27: //退出 esc case 9: //退出 teb scope.vm.showList=false; doBlur(); if(!scope.vm.dataState){ scope.vm.keyword=""; } break; case 8://backspace getList(); break; case 46://删除 scope.vm.keyword=""; break; default: getList(); break; } console.log( scope.vm.dataState); }; //选择 scope.selectItem=function (data,e) { e.preventDefault(); e.stopPropagation(); scope.data=data.id; defineKeyword(data); scope.vm.showList=false; doBlur(); callback(data); }; //已开鼠标 关闭 var getPar = function(tar) { if(tar.id==scope.id){ scope.count++; } if(tar.parentElement){ getPar(tar.parentElement); } }; angular.element(document).bind("click", function(e) { scope.count = 0; getPar(e.target); if(scope.count == 0) { scope.$apply(function(){ scope.vm.showList=false; doBlur(); console.log(scope.vm.dataState); if(!scope.vm.dataState){ scope.vm.keyword=""; } }) } }); } } }; /*ng-blur=\"isShow=false\"*/ angular.module("xn.directive.lookup",["xn/template/lookup.html"]) .constant('bankList', bankList) .directive("xnAccount",["$timeout","$q",xnAccount]) .directive("xnBank",["$timeout","$filter","bankList",xnBank]);