CMS.Controls.js 275 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853
  1. var CMSFunction = {
  2. ComboGrid: {
  3. SetValue: function (source, text, value) {
  4. var opts = $.data(source[0], "combogridX").options;
  5. if (text == "") {
  6. $(source).find('.combo-text').val(opts.emptyText);
  7. } else {
  8. $(source).find('.combo-text').val(text);
  9. }
  10. $(source).find('.combogridX-value').val(value);
  11. $(source).attr("loaded", "true");
  12. if ("undefined" != typeof EasyUIValidate) {
  13. if (EasyUIValidate.Events.ComboGridXOnChange) {
  14. EasyUIValidate.Events.ComboGridXOnChange.call(this);
  15. }
  16. }
  17. if (opts.onChange) opts.onChange.call(source);
  18. },
  19. OnLoadSuccessFunction: function (source, tableData, callBack) {
  20. var opts = $.data(source[0], "combogridX").options;
  21. var callbackCalled = false;
  22. var text = source.find(".combo-text").val();
  23. if (text == '' || text == null) {
  24. source.find('.combogridX-value').val("");
  25. }
  26. if (opts.value != '' && opts.value != -1 && $(source).attr("loaded") != "true") {
  27. callbackCalled = true;
  28. var dataGrid = source.find('.easyui-cmsXDataTable');
  29. var formData;
  30. if (opts.formData) {
  31. formData = $.unpackFormParams(opts.formData.QueryParamsDatas);
  32. } else {
  33. formData = new Object();
  34. }
  35. formData.Attribute = "{ \"ID\":\"00000000-0000-0000-0000-000000000000\",\"Value\":\"" + opts.valueField
  36. + "\",\"ControlType\":\"TextBox\"}";
  37. formData.Condition = "=";
  38. formData[opts.valueField + "_QueryTextBox"] = opts.value;
  39. var jsonString = "({'QueryParamsDatas':'" + $.packFormParams(formData) + "',page: 0,rows: 10 })";
  40. // var jsonString = "({'QueryParamsDatas':'Attribute|*|{\"ID\":\"00000000-0000-0000-0000-000000000000\",\"Value\":\"" + opts.valueField
  41. // + "\",\"ControlType\":\"TextBox\"}|@|Condition|*|=|@|ConditionValue|*|" + opts.value
  42. // + "|@|" + opts.valueField + "_QueryTextBox|*|" + opts.value + "|@|',page: 0,rows: 10 })";
  43. try {
  44. var dataGridOptions = dataGrid.cmsXDataTable("options");
  45. var url = dataGridOptions.url;
  46. $.post(url, eval(jsonString), function (data) {
  47. if (data.rows.length > 0) {
  48. CMSFunction.ComboGrid.SetValue(source, data.rows[0][opts.textField], opts.value);
  49. if (callBack) {
  50. callBack.call(source, tableData);
  51. }
  52. }
  53. });
  54. }
  55. catch (err) { }
  56. }
  57. var nowVal = source.find('.combogridX-value').val();
  58. if (!(nowVal && nowVal != "") && opts.selectedIndex != null && $(source).attr("loaded") != "true") {
  59. if (tableData.rows.length > opts.selectedIndex) {
  60. CMSFunction.ComboGrid.SetValue(source, tableData.rows[opts.selectedIndex][opts.textField], tableData.rows[opts.selectedIndex][opts.valueField]);
  61. }
  62. }
  63. //source.find(".combogridX-expander").width(source.find("table").width() + 16);
  64. source.find('tr.row>td').css("cursor", "pointer");
  65. source.find('tr.row').click(function () {
  66. var comboGrid = $(this).parents('.easyui-combogridX:first');
  67. var grid = $(this).parents('.easyui-cmsXDataTable:first');
  68. var opts = $.data(comboGrid[0], "combogridX").options;
  69. var gridOpts = $.data(grid[0], "cmsXDataTable").options;
  70. var gridData = gridOpts.data;
  71. var rowIndex = parseInt($(this).attr("xRowIndex"));
  72. var rowData = gridData.rows[rowIndex];
  73. CMSFunction.ComboGrid.SetValue(comboGrid, rowData[opts.textField], rowData[opts.valueField]);
  74. if (opts.onSelect) opts.onSelect.call(this, rowData);
  75. comboGrid.find(".combogridX-expander").css("display", "none");
  76. });
  77. var expander = source.find(".combogridX-expander");
  78. // expander.css("width", "");
  79. source.combogridX("setExpanderPosition", {
  80. expander: expander, dropdown: source, arrow: source.find('.combo-arrow')
  81. });
  82. if (callBack && !callbackCalled) {
  83. callBack.call(source, tableData);
  84. }
  85. }
  86. },
  87. Tree: {
  88. setParentsChecked: function (jq, node, ischeck) {
  89. var parent = jq.tree('getParent', node.target);
  90. if (parent) {
  91. if (parent.checked != ischeck) {
  92. if (!parent.attributes) parent.attributes = new Object();
  93. parent.attributes.isRecursionParent = true;
  94. jq.tree('update',{ target: parent.target, attributes: parent.attributes });
  95. if (ischeck) {
  96. jq.tree('check', parent.target);
  97. } else {
  98. jq.tree('uncheck', parent.target);
  99. }
  100. }
  101. //CMSFunction.Tree.setParentsChecked(jq, parent, ischeck);
  102. }
  103. },
  104. setChildrenChecked: function (jq, node, checked) {
  105. var childNodes = jq.tree('getChildren', node.target);
  106. for (var i = 0; i < childNodes.length; i++) {
  107. if (childNodes[i].checked != checked) {
  108. if (!childNodes[i].attributes) childNodes[i].attributes = new Object();
  109. childNodes[i].attributes.isRecursionChild = true;
  110. jq.tree('update',{ target: childNodes[i].target, attributes: childNodes[i].attributes });
  111. if (checked) jq.tree('check', childNodes[i].target);
  112. else jq.tree('uncheck', childNodes[i].target);
  113. }
  114. }
  115. },
  116. OnBeforeCheck: function (node, checked) {
  117. var treeView = $(this);
  118. var opts = treeView.tree('options');
  119. if (!node.attributes) node.attributes = new Object();
  120. if (!opts.cascadeCheck) {
  121. if (checked == node.checked) { return true; }
  122. if (checked) {
  123. if (!node.attributes.isRecursionChild) {
  124. CMSFunction.Tree.setParentsChecked(treeView, node, checked);
  125. }
  126. }
  127. if (!node.attributes.isRecursionParent) {
  128. CMSFunction.Tree.setChildrenChecked(treeView, node, checked);
  129. }
  130. node.attributes.isRecursionParent = false;
  131. node.attributes.isRecursionChild = false;
  132. treeView.tree('update',{ target: node.target, attributes: node.attributes });
  133. // else {
  134. // //opts.cascadeCheck = false;
  135. // var childNodes = treeView.tree('getChildren', node.target);
  136. // for (var i = 0; i < childNodes.length; i++) {
  137. // if (checked) treeView.tree('check', childNodes[i].target);
  138. // else treeView.tree('uncheck', childNodes[i].target);
  139. // }
  140. // }
  141. }
  142. },
  143. CheckBranch: function () {
  144. var parentid = event.srcElement.id;
  145. var myCheck = $(event.srcElement).attr("checked");
  146. $(event.srcElement).find("input[id^='" + parentid + "']").each(function () {
  147. if (!myCheck)
  148. { $(this).removeAttr("checked"); }
  149. else
  150. { $(this).attr("checked", myCheck); }
  151. });
  152. },
  153. OnClick: function (node) {
  154. var tree = $(node.target).parents('.easyui-tree');
  155. if (tree.tree('getChildren', node.target).length > 0) {
  156. tree.tree('toggle', node.target);
  157. }
  158. }
  159. },
  160. DataTable: {
  161. TriggerIndex: null,
  162. TriggerData: null,
  163. /// <summary>
  164. /// <para>本对象专门用于操作jQueryEasyUI框架的DataGrid</para>
  165. /// </summary>
  166. OnLoadSuccessFunction: function (data, callBack) {
  167. var target = $(this);
  168. var comboGrid = $(this).parents('.easyui-combogridX:first');
  169. if (comboGrid.length > 0) {
  170. CMSFunction.ComboGrid.OnLoadSuccessFunction(comboGrid, data, callBack);
  171. } else {
  172. if (callBack) {
  173. callBack.call(this, data);
  174. }
  175. }
  176. },
  177. CorssRowsStylerFunction: function (value, row, index) {
  178. if (index % 2 != 0) { //偶数行
  179. return 'background-color:#DAEEE1;';
  180. } else { //奇数行
  181. }
  182. },
  183. ColumnFormatterFunction: function (value, row, index, formatType, formatString, customFormatFun, overflowlength) {
  184. if (formatType == FormatType.None) {
  185. if (!value && value != 0) {
  186. value = "";
  187. }
  188. } else if (formatType == FormatType.DateTime) {
  189. if (!value && value != 0) {
  190. value = "";
  191. }
  192. else {
  193. try{
  194. value = value.toDateString(formatString);
  195. }
  196. catch(error){}
  197. }
  198. }
  199. if (overflowlength > 3) {
  200. value = value.toString().length <= overflowlength ? value : value.toString().substring(0, overflowlength - 3) + '...';
  201. }
  202. if (customFormatFun) {
  203. return customFormatFun.call(this, index, row, value);
  204. }
  205. return value;
  206. },
  207. OperaterColumnFormatterFunction: function (value, row, index, buttonArrayString) {
  208. var htmlString = "&nbsp;";
  209. buttonArrayString = buttonArrayString.replace(/\^\^/g, "\"");
  210. var buttonArray = $.parseJSON(buttonArrayString);
  211. for (var i = 0; i < buttonArray.length; i++) {
  212. htmlString += buttonArray[i][i] + "&nbsp;";
  213. }
  214. return htmlString;
  215. },
  216. LinkButtonColumnFormatterFunction: function (value, row, index, text, handleScript, formatType, formatString, overflowlength, emptyText) {
  217. var content = (text ? text : (!value && value != 0 ? "" : value));
  218. if(emptyText == undefined){
  219. emptyText = "";
  220. }
  221. if (content.length == 0 && emptyText.length > 0) {
  222. content = emptyText;
  223. }
  224. if (overflowlength > 3) {
  225. content = content.length < overflowlength ? content : content.substring(0, overflowlength - 3) + '...';
  226. }
  227. var html = "<a href=\"javascript:void(0);\" onclick=\"return " + handleScript + "(" + index + ",$(this).closest('.easyui-cmsXDataTable').cmsXDataTable('getRows')[" + index + "]);\" >" + content + "</a>";
  228. return html;
  229. },
  230. GetRowData: function (table) {
  231. /// <summary>
  232. /// <para>获取table中所有被选中的数据(最后返回的是数据是JSON格式的String类型数据)</para>
  233. /// <param name="table">jQuery对象,不传则默认为当前选项卡中的第一个DataGrid</param>
  234. /// </summary>
  235. var $table = null;
  236. if (table == undefined || table == null) {
  237. var $tabs = $('#index_center').tabs();
  238. $table = $tabs.tabs('getSelected').find("div.easyui-cmsXDataTable").eq(0);
  239. } else {
  240. $table = $(table);
  241. }
  242. if ($table == null || $table == undefined) {
  243. return ""
  244. }
  245. ;
  246. var rowsData = $table.cmsXDataTable('getSelections');
  247. if (rowsData.length > 0) {
  248. for (var i = 0; i < rowsData.length; i++) {
  249. var data = rowsData[i];
  250. data = BowinFunction.Untility.ConvertObjectDateFormat(data);
  251. }
  252. }
  253. // return rowsData == null ? "" : rowsData.length > 1 ? JSON.stringify(rowsData) : "[" + JSON.stringify(rowsData) + "]";
  254. return rowsData == null ? "" : JSON.stringify(rowsData);
  255. },
  256. GetCurrentRowData: function (obj) {
  257. /// <summary>
  258. /// <para>获取ojb对象所在行的数据(最后返回的是数据是JSON格式的String类型数据)</para>
  259. /// </summary>
  260. var rowIndex = $(obj).closest('tr').attr("xRowIndex");
  261. var rowDatas = $(obj).closest('.easyui-cmsXDataTable').cmsXDataTable("getRows");
  262. var data = BowinFunction.Untility.ConvertObjectDateFormat(rowDatas[rowIndex]);
  263. return "[" + JSON.stringify(data) + "]";
  264. }
  265. },
  266. DataTableFormatter: {
  267. TwoDigit: function (index, row, value) {
  268. if (!value || isNaN(value)) {
  269. if(value === 0)//判断是否为0
  270. {
  271. return value.toFixed(2).toString();
  272. }
  273. return "";
  274. }
  275. return value.toFixed(2).toString();
  276. }
  277. },
  278. DragDrop: {
  279. dragX: 0,
  280. dragY: 0,
  281. offsetX: 0,
  282. offsetY: 0,
  283. isInnerDrag: false,
  284. curPopupContainerItem: null,
  285. DropContainerItemClick: function (e) {
  286. var x = e.x || e.layerX || 0;
  287. var y = e.y || e.layerY || 0;
  288. var containerID = $(e.srcElement).parent().parent().attr("id");
  289. var menuID = containerID + "_menu";
  290. CMSFunction.DragDrop.curPopupContainerItem = $(e.srcElement).parent();
  291. $("#" + menuID).menu("show", { left: x, top: y });
  292. },
  293. DropFunc: function (e, source) {
  294. if (CMSFunction.DragDrop.isInnerDrag != true) {
  295. var newObj = $(source).clone();
  296. var myLeft = e.currentTarget.clientLeft;
  297. var myTop = e.currentTarget.clientTop;
  298. var myWidth = e.currentTarget.clientWidth;
  299. var myHeight = e.currentTarget.clientHeight;
  300. var myObj = e.currentTarget;
  301. var opts = $.data(this, "droppableContainer").options;
  302. newObj.css('top', CMSFunction.DragDrop.dragY - CMSFunction.DragDrop.offsetY)
  303. .css('position', 'absolute')
  304. .css('left', CMSFunction.DragDrop.dragX - CMSFunction.DragDrop.offsetX);
  305. newObj.find(".draggableTitle").css("color", opts.foreColor)
  306. newObj.appendTo($(this));
  307. newObj.draggable({
  308. handle: '.draggableTitle',
  309. onDrag: function (e) {
  310. CMSFunction.DragDrop.dragX = e.clientX;
  311. CMSFunction.DragDrop.dragY = e.clientY;
  312. },
  313. onBeforeDrag: function (e) {
  314. CMSFunction.DragDrop.offsetX = e.offsetX + e.srcElement.offsetLeft;
  315. CMSFunction.DragDrop.offsetY = e.offsetY + e.srcElement.offsetTop;
  316. CMSFunction.DragDrop.isInnerDrag = true;
  317. },
  318. onStopDrag: function (e) {
  319. if (e.clientX < myLeft || e.clientX > myLeft + myWidth || e.clientY < myTop || e.clientY > myTop + myHeight) {
  320. $(e.srcElement).offsetParent().remove();
  321. }
  322. }
  323. });
  324. }
  325. var hidden = $(e.currentTarget.nextSibling);
  326. hidden.val('');
  327. $.each($(e.currentTarget).find('.easyui-draggable'), function () {
  328. var valStr = '';
  329. if (hidden.val() != '') valStr = ',';
  330. var titleDiv = $(this).find('.draggableTitle');
  331. valStr += titleDiv.attr('value') + '|' + titleDiv.html() + '|' + $(this).css('left').replace("px", "") + '|' + $(this).css('top').replace("px", "");
  332. hidden.val(hidden.val() + valStr);
  333. });
  334. }
  335. }
  336. };
  337. //2013-05-31 begin added by pengbb 新增部门选择控件,由项目易系统开发提供
  338. var departmentSelector = function (dataUrl, multipleChoice, handlers) {
  339. var win;
  340. var tree;
  341. var pitchOnDataGrid;
  342. var rightTopQuey;
  343. var hasEasyUI = function (elementTypeName) {
  344. if ($(elementTypeName).length > 0) {
  345. return true;
  346. } else {
  347. return false;
  348. }
  349. }
  350. //private 创建Html元素
  351. var createElement = function (elementTypeName, elements, parentElments) {
  352. $(elementTypeName).removeClass();
  353. if (typeof parentElments != "undefined" && typeof elements == "string") {
  354. var elementsObject = $(elements);
  355. parentElments.append(elementsObject);
  356. return elementsObject;
  357. }
  358. else {
  359. if (typeof elements == "string")
  360. return $(elements);
  361. }
  362. };
  363. var createLinkButton = function (elements) {
  364. var links = elements.find("a");
  365. for (var i = 0; i < links.length; i++) {
  366. $(links[i]).linkbutton();
  367. }
  368. };
  369. var createTableString = function (name) {
  370. var table = "<table";
  371. return table.concat(" name='", name, "'>", "</table>");
  372. };
  373. var registEvent = function (target, eventType, handler) {
  374. target.unbind(eventType, handler);
  375. target.bind(eventType, handler);
  376. }
  377. //private 选择部门
  378. var selectWaitOrg = function (node) {
  379. var selectUser;
  380. if (multipleChoice) {
  381. selectUser = tree.tree('getChecked');
  382. } else {
  383. var selectUser = new Array();
  384. selectUser.push(node);
  385. }
  386. if (selectUser.length > 0) {
  387. if (!multipleChoice && selectUser.length > 1) {
  388. window.top.$.messager.alert("系统消息", "一次只能选择一个部门!");
  389. }
  390. else {
  391. var dataSource = "{\"total\":".concat(selectUser.length, ",", "\"rows\":[");
  392. for (var i = 0; i < selectUser.length; i++) {
  393. dataSource = dataSource.concat('{"OrgID":', "\"", selectUser[i].id, "\",", '"DepartmentName":',
  394. "\"", selectUser[i].text, "\"},"
  395. );
  396. }
  397. dataSource = dataSource.substring(0, dataSource.length - 1);
  398. dataSource = dataSource.concat("]}");
  399. pitchOnDataGrid.datagrid("loadData", $.parseJSON(dataSource));
  400. }
  401. } else if (multipleChoice == false) {
  402. window.top.$.messager.alert("系统消息", "未选择任何用户!");
  403. }
  404. };
  405. var InitGridFile = function (dataGrid, pagination, url) {
  406. return dataGrid.datagrid({
  407. url: pagination ? url : "",
  408. queryParams: pagination ? {
  409. departmentID: DepartmentID,
  410. userName: rightTopQuey.find("input[name='txtUserName']").val()
  411. } : "",
  412. pagination: pagination,
  413. pageSize: 1,
  414. pageList: [5, 10],
  415. loadMsg: "请稍等....",
  416. columns: [[
  417. { field: 'id', title: '', checkbox: true },
  418. { field: 'DepartmentName', title: '部门机构' }
  419. ]]
  420. });
  421. }
  422. var loadDepartmentTree = function () {
  423. var inputDepartment = leftQuery.find("input[name='txtDepartmentName']").val();
  424. $.cmsPost("/Common/GetSelectUserControlDepartmentTree",
  425. { departmentID: "", departmentName: inputDepartment },
  426. function (data) {
  427. $(tree).tree('loadData', data);
  428. });
  429. }
  430. var deleteSelectUser = function () {
  431. var deleteSource = pitchOnDataGrid.datagrid("getChecked");
  432. if (deleteSource.length > 0) {
  433. for (var i = 0; i < deleteSource.length; i++) {
  434. var rowIndex = pitchOnDataGrid.datagrid("getRowIndex", deleteSource[i]);
  435. pitchOnDataGrid.datagrid("deleteRow", rowIndex);
  436. if (multipleChoice) {
  437. var node = tree.tree("find", deleteSource[i].OrgID);
  438. tree.tree('uncheck', node.target);
  439. }
  440. }
  441. } else {
  442. window.top.$.messager.alert("系统消息", "未选中任何行!");
  443. }
  444. };
  445. var close = function () {
  446. var btnSelectOk = $((rightTopQuey.find("a"))[1]);
  447. btnSelectOk.unbind();
  448. btnSelectOk.bind("click", function () {
  449. var selectUser = pitchOnDataGrid.datagrid("getData");
  450. if (handlers instanceof Array) {
  451. for (var i = 0; i < handlers.length; i++) {
  452. handlers[i](selectUser);
  453. }
  454. } else if (typeof handlers != "undefined") {
  455. handlers(selectUser);
  456. }
  457. if (typeof (pitchOnDataGrid.data("SelectedUser")) != "undefined") {
  458. var catchData = pitchOnDataGrid.data("SelectedUser");
  459. pitchOnDataGrid.removeData("SelectedUser");
  460. }
  461. win.window("close");
  462. });
  463. };
  464. this.show = function () {
  465. if (true) {
  466. $("div[name='winOrgWarp']").remove();
  467. var warpElement = "<div class='selectOrg_warp clear' name='winOrgWarp'></div>";
  468. //var warp = createElement(".selectOrg_warp", warpElement, win);
  469. var warp = window.top.$(warpElement).appendTo(window.top.document.body);
  470. win = warp.window({
  471. width: 780,
  472. height: 530,
  473. modal: true,
  474. maximizable: false,
  475. title: '部门信息选择'
  476. });
  477. var elementLeft = createElement(".selectOrg_left",
  478. "<div class='selectOrg_left postion_border panel-margin'></div>", warp);
  479. var elementRight = createElement(".selectOrg_right",
  480. "<div class='selectOrg_right postion_border'></div>", warp);
  481. var leftQueryTable = "<table class='query'><tr>";
  482. leftQueryTable = leftQueryTable.concat("<td align='right'>渠道名称:</td>");
  483. leftQueryTable = leftQueryTable.concat("<td align='left'><input type='text' name='txtDepartmentName' class='selectUser_Input selectUser_inputCondition'/></td>");
  484. leftQueryTable = leftQueryTable.concat("<td colspan='2' align='center' ><a href='#' name='btnQueryDepartment'>查询</a> </td>");
  485. leftQueryTable = leftQueryTable.concat("</tr></table>");
  486. leftQuery = createElement(".query", leftQueryTable, elementLeft);
  487. createLinkButton(leftQuery);
  488. var left_panel_warp = createElement("div[panel_postion='org_left']", "<div class='panel_Data' panel_postion='org_left'><ul name='departmentTree'></ul></div>", elementLeft);
  489. left_panel_warp.panel({
  490. width: 350,
  491. height: 450,
  492. title: '部门信息',
  493. closable: false,
  494. collapsible: true,
  495. minimizable: false,
  496. maximizable: false
  497. });
  498. tree = $(left_panel_warp.find("ul[name='departmentTree']")[0]).tree({
  499. url: dataUrl + "?departmentName=",
  500. lines: true,
  501. checkbox: multipleChoice,
  502. onBeforeLoad: function (node, param) {
  503. if (node == null) {
  504. return true;
  505. } else {
  506. var children = $(this).tree("getChildren", node.target);
  507. if (children == "") {
  508. return true;
  509. } else {
  510. return false;
  511. }
  512. }
  513. },
  514. onClick: function (node) {
  515. selectWaitOrg(node);
  516. },
  517. onCheck: function (node) {
  518. selectWaitOrg();
  519. }
  520. });
  521. var rightQuery = '<p class="query_p right_query_Postion" pPostion="org_right_top"><a href="#" name="btnDel">删除</a>';
  522. rightQuery = rightQuery.concat("&nbsp;&nbsp;<a href='#' name='btnSelectOk' >确定</a></p>");
  523. rightTopQuey = createElement("p[pPostion='org_right_top']", rightQuery, elementRight);
  524. createLinkButton(rightTopQuey);
  525. var left_panel_warp = createElement("div[panel_postion='right_selectOrg']", "<div class='panel_Data' panel_postion='right_selectOrg'></div>", elementRight);
  526. var pitchOnPanel = left_panel_warp.panel({
  527. width: 380,
  528. height: 450,
  529. title: '已选部门',
  530. closable: false,
  531. collapsible: true,
  532. minimizable: false,
  533. maximizable: false
  534. });
  535. var pitchOnTable = createElement("table[name='pitchOnOrgDataGrid']", createTableString("pitchOnOrgDataGrid"), pitchOnPanel);
  536. pitchOnDataGrid = (InitGridFile(pitchOnTable, false));
  537. //查询部门树
  538. registEvent(leftQuery.find("a:first"), "click", loadDepartmentTree);
  539. //删除
  540. registEvent($(rightTopQuey.find("a")[0]), "click", deleteSelectUser);
  541. //确认
  542. close(handlers);
  543. } else {
  544. $("div[name='winOrgWarp']").window('open');
  545. }
  546. }
  547. };
  548. //2013-05-31 end added by pengbb 新增部门选择控件,由项目易系统开发提供
  549. //
  550. var brandSelector = function (dataUrl, multipleChoice, triggerboxTarget, handlers) {
  551. var win;
  552. var tree;
  553. var pitchOnDataGrid;
  554. var rightTopQuey;
  555. var hasEasyUI = function (elementTypeName) {
  556. if ($(elementTypeName).length > 0) {
  557. return true;
  558. } else {
  559. return false;
  560. }
  561. }
  562. //private 创建Html元素
  563. var createElement = function (elementTypeName, elements, parentElments) {
  564. $(elementTypeName).removeClass();
  565. if (typeof parentElments != "undefined" && typeof elements == "string") {
  566. var elementsObject = $(elements);
  567. parentElments.append(elementsObject);
  568. return elementsObject;
  569. }
  570. else {
  571. if (typeof elements == "string")
  572. return $(elements);
  573. }
  574. };
  575. var createLinkButton = function (elements) {
  576. var links = elements.find("a");
  577. for (var i = 0; i < links.length; i++) {
  578. $(links[i]).linkbutton();
  579. }
  580. };
  581. var createTableString = function (name) {
  582. var table = "<table";
  583. return table.concat(" name='", name, "'>", "</table>");
  584. };
  585. var registEvent = function (target, eventType, handler) {
  586. target.unbind(eventType, handler);
  587. target.bind(eventType, handler);
  588. }
  589. //private 选择品牌
  590. var selectWaitOrg = function (node) {
  591. var selectUser;
  592. if (multipleChoice) {
  593. selectUser = tree.tree('getChecked');
  594. } else {
  595. var selectUser = new Array();
  596. selectUser.push(node);
  597. }
  598. var removeArray = new Array();
  599. for (var i = 0; i < selectUser.length; i++) {
  600. if (!selectUser[i].attributes.parentDepartmentID) {//查找根节点
  601. removeArray.push(selectUser[i]);
  602. }
  603. else {
  604. for (var x = 0; x < selectUser.length; x++) {
  605. if (selectUser[i].attributes.parentDepartmentID == selectUser[x].id) {//查找父节点
  606. removeArray.push(selectUser[x]);
  607. }
  608. }
  609. }
  610. }
  611. for (var i = 0; i < removeArray.length; i++) { //移除选中项
  612. for (var x = 0; x < selectUser.length; x++) {
  613. if (removeArray[i].id == selectUser[x].id) {
  614. selectUser.splice(x, 1);
  615. break;
  616. }
  617. }
  618. }
  619. $(tree).data("Selections", selectUser);
  620. };
  621. this.show = function () {
  622. if (true) {
  623. $("div[name='winOrgWarp']").remove();
  624. var warpElement = "<div class='selectOrg_warp clear' name='winOrgWarp'></div>";
  625. var warp = window.top.$(warpElement).appendTo(window.top.document.body);
  626. var elementLeft = createElement(".selectOrg_left",
  627. "<div class='postion_border panel-margin'></div>", warp);
  628. var elementRight = createElement(".selectOrg_right",
  629. "<div class='selectOrg_right postion_border'></div>", warp);
  630. var left_panel_warp = createElement("div[panel_postion='org_left']", "<div class='panel_Data' panel_postion='org_left'><ul name='departmentTree'></ul></div>", elementLeft);
  631. tree = $(left_panel_warp.find("ul[name='departmentTree']")[0]).tree({
  632. url: dataUrl + "?departmentName=",
  633. lines: true,
  634. checkbox: multipleChoice,
  635. onBeforeLoad: function (node, param) {
  636. if (node == null) {
  637. return true;
  638. } else {
  639. var children = $(this).tree("getChildren", node.target);
  640. if (children == "") {
  641. return true;
  642. } else {
  643. return false;
  644. }
  645. }
  646. },
  647. onLoadSuccess: function (node, data) {
  648. var checkedData = $(triggerboxTarget).triggerbox("getValue");
  649. if (checkedData != "") {
  650. var checkedArray = checkedData.split(';');
  651. for (var i = 0; i < checkedArray.length; i++) {
  652. var checkedNode = tree.tree("find", checkedArray[i]);
  653. tree.tree("check", checkedNode.target);
  654. }
  655. }
  656. },
  657. onClick: function (node) {
  658. selectWaitOrg(node);
  659. },
  660. onCheck: function (node) {
  661. selectWaitOrg();
  662. }
  663. });
  664. win = warp.dialog({
  665. width: 400,
  666. height: 600,
  667. modal: true,
  668. maximizable: false,
  669. title: '品牌信息选择',
  670. buttons:
  671. [{
  672. text: '确定',
  673. handler: function () {
  674. var result = $(tree).data("Selections") || new Array();
  675. if (handlers instanceof Array) {
  676. for (var i = 0; i < result.length; i++) {
  677. handlers[i](result);
  678. }
  679. } else if (typeof handlers != "undefined") {
  680. handlers(result);
  681. }
  682. warp.dialog("close");
  683. }
  684. },
  685. {
  686. text: '取消',
  687. handler: function () {
  688. warp.dialog("close");
  689. }
  690. }]
  691. });
  692. } else {
  693. $("div[name='winOrgWarp']").dialog('open');
  694. }
  695. }
  696. };
  697. var brandSelectorHandlers = function (targe, node) {
  698. var datas = [];
  699. $.each(node, function () {
  700. datas.push([{ 'text': this.text, 'value': this.id }][0]);
  701. });
  702. $(targe).triggerbox('setValue', datas);
  703. };
  704. //
  705. //2013-05-29 begin added by pengbb 新增系统菜单控件
  706. /*用法:定义一个div,指定class 为 easyui-cmsTree
  707. <div class="easyui-cmsTree" data-options="url:'/Common/GetCurrentUserMenuList'" >
  708. </div>
  709. data-options参数如下:
  710. url:'/Common/GetCurrentUserMenuList'
  711. onMenuClick:function(node){}
  712. */
  713. (function ($) {
  714. $.parser.plugins.push("cmsTree");
  715. function _toggleChildMenu(currMenu) {
  716. //$(currMenu).next('div').toggle();
  717. if ($(currMenu).next('div').css("display") == "none") {
  718. $(currMenu).siblings("div").slideUp("normal");
  719. $(currMenu).next('div').slideDown("normal");
  720. } else {
  721. $(currMenu).next('div').slideUp("normal");
  722. }
  723. }
  724. function _hideAllChildMenu(jq) {
  725. $(jq).find('a+div').hide();
  726. }
  727. function _init(jq) {
  728. var opts = $.data(jq, "cmsTree").options;
  729. $(jq).addClass("menu_panel");
  730. //$(jq).height(opts.height);
  731. var defaultOpenMenu = null;
  732. var newUrl = opts.url;
  733. if (opts.loadingMessage) {
  734. $(jq).html($("<div class=\"panel-loading\"></div>").html(opts.loadingMessage));
  735. }
  736. $.post(newUrl, {}, function (responseJson) {
  737. var rootPanel = jq;
  738. var i = 0;
  739. $.each(responseJson, function () {
  740. var level1Menu = $("<a class=\"menu_item menu_item_level1\" href=\"javascript:void(0);\" click=\"return false;\" title=\"系统首页\"><span style=\"background-position: 0px 0px;background-repeat: no-repeat;\">系统首页</span> </a>");
  741. var level1MenuOption = this;
  742. level1Menu.appendTo(rootPanel);
  743. level1Menu.find("span").text(level1MenuOption.text);
  744. level1Menu.find("span").addClass("menu_item_level1_title");
  745. if (level1MenuOption.text != "系统首页" && level1MenuOption.text != "系统注销" && i == 0) {
  746. i = 1;
  747. defaultOpenMenu = level1Menu;
  748. }
  749. if (level1MenuOption.iconUrl) {
  750. level1MenuOption.iconUrl = "url(" + level1MenuOption.iconUrl + ")";
  751. level1Menu.find(">span").css({ backgroundPosition: "10px 6px", backgroundImage: level1MenuOption.iconUrl });
  752. }
  753. level1Menu.attr("title", level1MenuOption.text);
  754. level1Menu.data("menuOption", level1MenuOption);
  755. if (level1MenuOption.children.length > 0) {
  756. var level2Panel = $("<div class=\"menu_item_panel\"></div>").appendTo(rootPanel);
  757. $.each(level1MenuOption.children, function () {
  758. var level2Menu = $("<a class=\"menu_item menu_item_level2\" href=\"javascript:void(0);\" click=\"return false;\" title=\"系统首页\"><span >系统首页</span> </a>");
  759. var level2MenuOption = this;
  760. level2Menu.appendTo(level2Panel);
  761. level2Menu.find("span").text(level2MenuOption.text);
  762. level2Menu.find("span").addClass("menu_item_level2_title");
  763. level2Menu.attr("title", level2MenuOption.text);
  764. level2Menu.data("menuOption", level2MenuOption);
  765. if (level2MenuOption.children.length > 0) {
  766. //menu_item_level2_icon_opened
  767. //menu_item_level2_icon_closed
  768. level2Menu.addClass("menu_item_collapsable")
  769. .find("span").css({ paddingLeft: "20px" }).addClass("menu_item_level2_icon_closed");
  770. var levelLeafPanel = $("<div class=\"menu_item_leaf_panel\"></div>").appendTo(level2Panel);
  771. $.each(level2MenuOption.children, function () {
  772. var levelLeafMenu = $("<a class=\"menu_item menu_item_leaf\" href=\"javascript:void(0);\" click=\"return false;\" title=\"系统首页\"><span style=\"background-position: 0px 0px;background-repeat: no-repeat;background-size: 16px 12px;\">系统首页</span> </a>");
  773. var levelLeafMenuOption = this;
  774. levelLeafMenu.appendTo(levelLeafPanel);
  775. levelLeafMenu.find("span").text(levelLeafMenuOption.text);
  776. levelLeafMenu.find("span").addClass("menu_item_leaf_title");
  777. levelLeafMenu.find("span").addClass("menu_item_leaf_icon");
  778. levelLeafMenu.find("span").css({ backgroundImage: levelLeafMenuOption.iconUrl });
  779. levelLeafMenu.attr("title", levelLeafMenuOption.text);
  780. levelLeafMenu.data("menuOption", levelLeafMenuOption);
  781. });
  782. }
  783. });
  784. }
  785. _hideAllChildMenu(jq);
  786. });
  787. if (defaultOpenMenu) {
  788. _toggleChildMenu(defaultOpenMenu);
  789. }
  790. // $(rootPanel).find("div.menu_item_panel").tinyscrollbar();
  791. }, "json");
  792. return { cmsTree: jq };
  793. }
  794. $.fn.cmsTree = function (_7be, _7bf) {
  795. if (typeof _7be == "string") {
  796. var _7c0 = $.fn.cmsTree.methods[_7be];
  797. if (_7c0) {
  798. return _7c0(this, _7bf);
  799. } else {
  800. return this.cmsTree(_7be, _7bf);
  801. }
  802. }
  803. _7be = _7be || {};
  804. return this.each(function () {
  805. var _this = this;
  806. var _jqThis = $(_this);
  807. var cacheData = $.data(_this, "cmsTree");
  808. if (cacheData) {
  809. $.extend(cacheData.options, _7be);
  810. } else {
  811. cacheData = $.data(_this, "cmsTree", { options: $.extend({}, $.fn.cmsTree.defaults, $.fn.cmsTree.parseOptions(this), _7be) });
  812. var initCacheData = _init(_this);
  813. initCacheData.clickCallbacks = $.Callbacks();
  814. cacheData = $.data(_this, "cmsTree", $.extend({}, cacheData, initCacheData));
  815. _jqThis.find("a.menu_item").live("click", function (event) {
  816. //alert($(this).attr("title"));
  817. //alert(JSON.stringify($(this).data("menuOption")));
  818. //menu_item_level2_icon_opened
  819. //menu_item_level2_icon_closed
  820. if ($(this).hasClass("menu_item_collapsable")) {
  821. var span = $(this).find(">span");
  822. if (span.hasClass("menu_item_level2_icon_closed")) {
  823. span.removeClass("menu_item_level2_icon_closed");
  824. span.addClass("menu_item_level2_icon_opened");
  825. } else {
  826. span.removeClass("menu_item_level2_icon_opened");
  827. span.addClass("menu_item_level2_icon_closed");
  828. }
  829. $(this).siblings(".menu_item_collapsable").find(">span").removeClass("menu_item_level2_icon_opened").addClass("menu_item_level2_icon_closed");
  830. }
  831. var opts = _jqThis.data("cmsTree").options;
  832. _toggleChildMenu(this);
  833. var menuOption = $(this).data("menuOption");
  834. if (opts.onMenuClick) {
  835. opts.onMenuClick.call(_this, menuOption);
  836. }
  837. return false;
  838. });
  839. //_jqThis.find("div.menu_item_panel").tinyscrollbar({ axis: 'x', size: 20});
  840. }
  841. });
  842. };
  843. $.fn.cmsTree.methods = {
  844. options: function (jq) {
  845. var opts = $.data(jq[0], "cmsTree").options;
  846. return opts;
  847. }
  848. };
  849. $.fn.cmsTree.parseOptions = function (_7c7) {
  850. var t = $(_7c7);
  851. return $.extend({}, $.fn.cmsTree.defaults, $.parser.parseOptions(_7c7, []));
  852. };
  853. $.fn.cmsTree.defaults = {
  854. url: '',
  855. loadingMessage: '菜单正在加载中...',
  856. onMenuClick: function () { } //,
  857. //height: 700
  858. };
  859. })(jQuery);
  860. //2013-05-29 end added by pengbb 新增系统菜单控件
  861. //2013-05-21 begin added by pengbb 附件上传控件
  862. /*用法:定义一个div,指定class 为 easyui-AttachmentUploader
  863. <div class="easyui-AttachmentUploader" style="width:auto;height:200px;" data-options="formData:{ReferenceID:'999F598B-541E-4863-8354-D54F8D47AFDD',ReferenceKeyName:'CMS_ApplicationBill'}">
  864. </div>
  865. data-options参数如下:
  866. title: "附件列表",
  867. canUpload: true, //是否可以上传
  868. formData: {
  869. ReferenceID: '',
  870. ReferenceKeyName: 'CMS'
  871. },
  872. multi: true, //是否启用批量上传
  873. fileSizeLimit: 0, // The maximum size of an uploadable file in KB (Accepts units B KB MB GB if string, 0 for no limit)
  874. fileTypeDesc : 'Image Files', // The description for file types in the browse dialog
  875. fileTypeExts : '*.gif; *.jpg; *.png', // Allowed extensions in the browse dialog (server-side validation should also be used)
  876. buttonText: '上传附件',
  877. buttonClass: '',
  878. swf: '/Scripts/Plugins/Uploadify/uploadify.swf',
  879. uploader: '/UploadFile.axd',
  880. uploadSuccess: function (file, data, response) { },
  881. uploadFailure: function (file, data, response) { }
  882. */
  883. (function ($) {
  884. $.parser.plugins.push("AttachmentUploader");
  885. function s4() {
  886. return Math.floor((1 + Math.random()) * 0x10000)
  887. .toString(16)
  888. .substring(1);
  889. }
  890. function guid() {
  891. return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
  892. s4() + '-' + s4() + s4() + s4();
  893. }
  894. function _init(jq) {
  895. var opts = $.data(jq, "AttachmentUploader").options;
  896. var plAttachment = jq;
  897. var jqThis = $(jq);
  898. var dgAttachment = jqThis.find("div.upload_filelist>div");
  899. var btnUpload = jqThis.find("div.upload_tool>input");
  900. dgAttachment.cmsXDataTable();
  901. return { AttachmentUploader: jq, btnUpload: btnUpload, dgAttachment: dgAttachment };
  902. }
  903. function _deleteAttachment(jq, id) {
  904. var dgAttachment = $.data(jq, "AttachmentUploader").dgAttachment;
  905. $.messager.confirm('系统提示', '确定要删除该附件吗?', function (r) {
  906. if (r) {
  907. var ops = {
  908. URL: ("/" + CMS_SystemConfig.VirtualDirectoryPath + '/Common/RemoveAttachment/').replaceDoubleSlashesToSingle() + id,
  909. Before: function (rows) {
  910. },
  911. CallBack: function (result) {
  912. $.messager.alert('系统提示', '删除成功!', 'info', function () {
  913. setTimeout(function () { dgAttachment.cmsXDataTable('load') }, 100);
  914. });
  915. }
  916. }
  917. BowinFunction.Request.AJAX(ops);
  918. }
  919. })
  920. }
  921. $.fn.AttachmentUploader = function (_7be, _7bf) {
  922. if (typeof _7be == "string") {
  923. var _7c0 = $.fn.AttachmentUploader.methods[_7be];
  924. if (_7c0) {
  925. return _7c0(this, _7bf);
  926. } else {
  927. return this.AttachmentUploader(_7be, _7bf);
  928. }
  929. }
  930. _7be = _7be || {};
  931. return this.each(function () {
  932. var _this = this;
  933. var cacheData = $.data(_this, "AttachmentUploader");
  934. if (cacheData) {
  935. $.extend(cacheData.options, _7be);
  936. } else {
  937. cacheData = $.data(_this, "AttachmentUploader", { options: $.extend({}, $.fn.AttachmentUploader.defaults, $.fn.AttachmentUploader.parseOptions(this), _7be) });
  938. cacheData.options = $.extend({}, cacheData.options, {
  939. onUploadSuccess: function (file, data, response) {
  940. setTimeout(function () { dgAttachment.cmsXDataTable("load"); }, 100);
  941. if (opts.uploadSuccess) {
  942. opts.uploadSuccess.call(this, file, data, response);
  943. }
  944. },
  945. onAllComplete: function (event, data) {
  946. opts.onAllComplete.call(this, event, data);
  947. },
  948. onUploadError: function (file, data, response) {
  949. if (opts.uploadFailure) {
  950. opts.uploadFailure.call(this, file, data, response);
  951. }
  952. }
  953. });
  954. var initCacheData = _init(this);
  955. cacheData = $.data(this, "AttachmentUploader", $.extend({}, cacheData, initCacheData));
  956. }
  957. var opts = cacheData.options;
  958. var btnUpload = cacheData.btnUpload;
  959. var dgAttachment = cacheData.dgAttachment;
  960. if (opts.canUpload) {
  961. btnUpload.show();
  962. try {
  963. btnUpload.uploadify("destroy");
  964. } catch (ignore) { }
  965. btnUpload.uploadify(opts);
  966. } else {
  967. btnUpload.hide();
  968. }
  969. });
  970. };
  971. $.fn.AttachmentUploader.deleteColumnFormatFun = function (index, row, value) {
  972. if (row["IsOwn"]) {
  973. return "<a title=\"删除\" href=\"javascript:void(0);\" onclick=\"$(this).closest('div.easyui-AttachmentUploader').AttachmentUploader('deleteAttachment','" + value + "'); return false;\" >删除</a>";
  974. } else {
  975. return "<lable>&nbsp;&nbsp;&nbsp;&nbsp;</lable>";
  976. }
  977. };
  978. $.fn.AttachmentUploader.methods = {
  979. options: function (jq) {
  980. var opts = $.data(jq[0], "AttachmentUploader").options;
  981. return opts;
  982. },
  983. getDatagrid: function (jq) {
  984. var dgAttachment = $.data(jq[0], "AttachmentUploader").dgAttachment;
  985. return dgAttachment;
  986. },
  987. deleteAttachment: function (jq, id) {
  988. return _deleteAttachment(jq[0], id);
  989. },
  990. destroy: function (jq) {
  991. var btnUpload = $.data(jq[0], "AttachmentUploader").btnUpload;
  992. btnUpload.uploadify("destroy");
  993. }
  994. };
  995. $.fn.AttachmentUploader.parseOptions = function (_7c7) {
  996. var t = $(_7c7);
  997. return $.extend({}, $.fn.AttachmentUploader.defaults, $.parser.parseOptions(_7c7, []));
  998. };
  999. $.fn.AttachmentUploader.defaults = {
  1000. title: "附件列表",
  1001. canUpload: true,
  1002. formData: {
  1003. ReferenceID: '',
  1004. ReferenceKeyName: 'CMS'
  1005. },
  1006. width: 70, // The width of the browse button
  1007. height: 26, // The height of the browse button
  1008. createUserID: "",
  1009. canDelete: true,
  1010. multi: true,
  1011. fileSizeLimit: 0, // The maximum size of an uploadable file in KB (Accepts units B KB MB GB if string, 0 for no limit)
  1012. fileTypeDesc: '所有文件', // The description for file types in the browse dialog
  1013. fileTypeExts: '*.*', // Allowed extensions in the browse dialog (server-side validation should also be used)
  1014. buttonText: '上传附件',
  1015. buttonClass: '',
  1016. swf: ('/' + CMS_SystemConfig.VirtualDirectoryPath + '/Scripts/Plugins/Uploadify/uploadify.swf').replaceDoubleSlashesToSingle(),
  1017. uploader: ('/' + CMS_SystemConfig.VirtualDirectoryPath + '/UploadFile.axd').replaceDoubleSlashesToSingle(),
  1018. uploadSuccess: function (file, data, response) {
  1019. },
  1020. uploadFailure: function (file, data, response) { },
  1021. onAllComplete: function (event, data) {
  1022. //$('.easyui-window').window('close');
  1023. }
  1024. };
  1025. })(jQuery);
  1026. //2013-05-21 end added by pengbb 附件上传控件
  1027. //2013-08-01 begin added by pengbb 新增弹窗上传控件
  1028. (function ($) {
  1029. $.parser.plugins.push("FileUploaderWindow");
  1030. function s4() {
  1031. return Math.floor((1 + Math.random()) * 0x10000)
  1032. .toString(16)
  1033. .substring(1);
  1034. }
  1035. function guid() {
  1036. return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
  1037. s4() + '-' + s4() + s4() + s4();
  1038. }
  1039. function _init(jq) {
  1040. var opts = $.data(jq, "FileUploaderWindow").options;
  1041. var plAttachment = jq;
  1042. var jqThis = $(jq);
  1043. var win = jqThis.find(".FileUploaderWindowPanel");
  1044. var fileUploader = win.find(".easyui-AttachmentUploader");
  1045. //win.window();
  1046. return { FileUploaderWindow: jq, FileUploader: fileUploader, Window: win };
  1047. }
  1048. $.fn.FileUploaderWindow = function (_7be, _7bf) {
  1049. if (typeof _7be == "string") {
  1050. var _7c0 = $.fn.FileUploaderWindow.methods[_7be];
  1051. if (_7c0) {
  1052. return _7c0(this, _7bf);
  1053. } else {
  1054. return this.FileUploaderWindow(_7be, _7bf);
  1055. }
  1056. }
  1057. _7be = _7be || {};
  1058. return this.each(function () {
  1059. var _this = this;
  1060. var cacheData = $.data(_this, "FileUploaderWindow");
  1061. if (cacheData) {
  1062. $.extend(cacheData.options, _7be);
  1063. } else {
  1064. cacheData = $.data(_this, "FileUploaderWindow", { options: $.extend({}, $.fn.FileUploaderWindow.defaults, $.fn.FileUploaderWindow.parseOptions(this), _7be) });
  1065. var initCacheData = _init(this);
  1066. cacheData = $.data(this, "FileUploaderWindow", $.extend({}, cacheData, initCacheData));
  1067. }
  1068. });
  1069. };
  1070. $.fn.FileUploaderWindow.methods = {
  1071. options: function (jq) {
  1072. var opts = $.data(jq[0], "FileUploaderWindow").options;
  1073. return opts;
  1074. },
  1075. open: function (jq) {
  1076. var data = $.data(jq[0], "FileUploaderWindow");
  1077. var opts = data.options;
  1078. var win = data.Window;
  1079. var fileUploader = data.FileUploader;
  1080. fileUploader.AttachmentUploader(opts);
  1081. win.window().show().window("open");
  1082. },
  1083. close: function (jq) {
  1084. var data = $.data(jq[0], "FileUploaderWindow");
  1085. var opts = data.options;
  1086. var win = data.Window;
  1087. var fileUploader = data.FileUploader;
  1088. fileUploader.AttachmentUploader("destroy");
  1089. win.window("close");
  1090. }
  1091. };
  1092. $.fn.FileUploaderWindow.parseOptions = function (_7c7) {
  1093. var t = $(_7c7);
  1094. return $.extend({}, $.fn.FileUploaderWindow.defaults, $.parser.parseOptions(_7c7, []));
  1095. };
  1096. $.fn.FileUploaderWindow.defaults = $.extend({}, $.fn.AttachmentUploader.defaults, {
  1097. formData: {
  1098. ReferenceID: '',
  1099. ReferenceKeyName: 'TempFile'
  1100. }
  1101. });
  1102. })(jQuery);
  1103. //2013-08-01 end added by pengbb 新增弹窗上传控件
  1104. //2013-04-28 begin added by pengbb 新增triggerbox控件,用于用户选择和部门选择,号码规则选择
  1105. (function ($) {
  1106. $.parser.plugins.push("triggerbox");
  1107. function _init(jq) {
  1108. var widthCss = $(jq).width();
  1109. $(jq).addClass("triggerbox-f").hide();
  1110. var span = $("<span class=\"triggerbox\"></span>").insertAfter(jq);
  1111. var span_text = $("<input type=\"text\" readonly=\"true\" style=\"width:100%;\" class=\"triggerbox-text\">").appendTo(span);
  1112. var span_delete = $("<span><span class=\"triggerbox-delete\"></span></span>").appendTo(span);
  1113. var span_search = $("<span><span class=\"triggerbox-search\"></span></span>").appendTo(span);
  1114. $("<input type=\"hidden\" class=\"triggerbox-value\">").appendTo(span);
  1115. var name = $(jq).attr("name");
  1116. if (name) {
  1117. span.find("input.triggerbox-value").attr("name", name);
  1118. $(jq).removeAttr("name").attr("triggerboxName", name);
  1119. }
  1120. span_text.attr("autocomplete", "off");
  1121. //span.css("width", widthCss);
  1122. span_text.width(widthCss - span_search.width() - span_delete.width() - 10);
  1123. //span_text.width(span.width() - span_search.width() - span_delete.width());
  1124. return { triggerbox: span };
  1125. }
  1126. function _setValue(jq, newData, isValidate) {
  1127. var opts = $.data(jq, "triggerbox").options;
  1128. var data = $.data(jq, "triggerbox").data;
  1129. var span = $.data(jq, "triggerbox").triggerbox;
  1130. data = newData;
  1131. var ss = [];
  1132. for (var i = 0; i < newData.length; i++) {
  1133. var s = newData[i][opts.valueField];
  1134. if (opts.formatter) {
  1135. s = opts.formatter.call(jq, newData[i]);
  1136. }
  1137. ss.push(s);
  1138. }
  1139. var oldTriggerboxValue = span.find("input.triggerbox-value").val();
  1140. span.find("input.triggerbox-text").val(ss.join(opts.separator));
  1141. span.find("input.triggerbox-value").val(JSON.stringify(newData));
  1142. var reg = "/" + opts.separator + "/g";
  1143. span.find("input.triggerbox-text").attr("title", ss.join(opts.separator).replace(eval(reg), "\r\n"));
  1144. if (opts.required && isValidate) {
  1145. //try{
  1146. var _769 = span.find("input.triggerbox-text");
  1147. _769.validatebox("validate");
  1148. // }catch(ignore){}
  1149. }
  1150. // if (ss.join(opts.separator).length > 0 && vv.join(opts.separator).length > 0) {
  1151. // span.find(".triggerbox-delete").css("visibility", "visible");
  1152. // } else {
  1153. // span.find(".triggerbox-delete").css("visibility", "hidden");
  1154. // }
  1155. $.data(jq, "triggerbox", { options: opts, data: data, triggerbox: span });
  1156. if (oldTriggerboxValue != span.find("input.triggerbox-value").val()) {
  1157. var changeFn = opts.change || function () { };
  1158. if (typeof (changeFn) == "function") {
  1159. changeFn.call(jq);
  1160. }
  1161. }
  1162. }
  1163. function _initValidate(_768, doit) {
  1164. var opts = $.data(_768, "triggerbox").options;
  1165. var _769 = $.data(_768, "triggerbox").triggerbox.find("input.triggerbox-text");
  1166. _769.validatebox(opts);
  1167. $(_768).removeClass("easyui-validatebox validatebox-text");
  1168. if (doit) {
  1169. _769.validatebox("validate");
  1170. }
  1171. };
  1172. $.fn.triggerbox = function (_7be, _7bf) {
  1173. if (typeof _7be == "string") {
  1174. var _7c0 = $.fn.triggerbox.methods[_7be];
  1175. if (_7c0) {
  1176. return _7c0(this, _7bf);
  1177. } else {
  1178. return this.triggerbox(_7be, _7bf);
  1179. }
  1180. }
  1181. _7be = _7be || {};
  1182. return this.each(function () {
  1183. var _this = this;
  1184. var triggerboxData = $.data(this, "triggerbox");
  1185. if (triggerboxData) {
  1186. $.extend(triggerboxData.options, _7be);
  1187. } else {
  1188. triggerboxData = $.data(this, "triggerbox", { options: $.extend({}, $.fn.triggerbox.defaults, $.fn.triggerbox.parseOptions(this), _7be) });
  1189. var initTriggerboxData = _init(this);
  1190. triggerboxData = $.data(this, "triggerbox", $.extend({}, triggerboxData, initTriggerboxData));
  1191. }
  1192. if (triggerboxData.options.data) {
  1193. _setValue(this, triggerboxData.options.data, false);
  1194. }
  1195. triggerboxData.triggerbox.find(".triggerbox-search").unbind(".triggerbox");
  1196. triggerboxData.triggerbox.find(".triggerbox-delete").unbind(".triggerbox");
  1197. //注册事件
  1198. triggerboxData.triggerbox.find(".triggerbox-search").bind("mouseenter.triggerbox", function () {
  1199. $(this).addClass("triggerbox-search-hover");
  1200. }).bind("mouseleave.triggerbox", function () {
  1201. $(this).removeClass("triggerbox-search-hover");
  1202. }).bind("mousedown.triggerbox", function () {
  1203. if (triggerboxData.options.editable) {
  1204. //查询点击事件
  1205. if (triggerboxData.options.onSearch) {
  1206. triggerboxData.options.onSearch.call(_this);
  1207. }
  1208. }
  1209. });
  1210. triggerboxData.triggerbox.find(".triggerbox-search").bind("mouseenter.triggerbox", function () {
  1211. $(this).addClass("triggerbox-search-hover");
  1212. }).bind("mouseleave.triggerbox", function () {
  1213. $(this).removeClass("triggerbox-search-hover");
  1214. }).bind("mousedown.triggerbox", function () {
  1215. if (triggerboxData.options.editable) {
  1216. //查询点击事件
  1217. if (triggerboxData.options.onSearchClick) {
  1218. triggerboxData.options.onSearchClick.call(_this);
  1219. }
  1220. }
  1221. });
  1222. triggerboxData.triggerbox.find(".triggerbox-delete").bind("mouseenter.triggerbox", function () {
  1223. $(this).addClass("triggerbox-delete-hover");
  1224. }).bind("mouseleave.triggerbox", function () {
  1225. $(this).removeClass("triggerbox-delete-hover");
  1226. }).bind("mousedown.triggerbox", function () {
  1227. if (triggerboxData.options.editable) {
  1228. $.fn.triggerbox.methods["clear"]($(_this));
  1229. //$(this).css("visibility", "hidden");
  1230. }
  1231. });
  1232. _initValidate(_this, true);
  1233. });
  1234. };
  1235. $.fn.triggerbox.methods = {
  1236. options: function (jq) {
  1237. var opts = $.data(jq[0], "triggerbox").options;
  1238. return opts;
  1239. },
  1240. getData: function (jq) {
  1241. return $.data(jq[0], "triggerbox").data;
  1242. },
  1243. setValue: function (jq, newData) {
  1244. jq.each(function () {
  1245. _setValue(this, newData, true);
  1246. });
  1247. },
  1248. getValue: function (jq) {
  1249. return eval($.data(jq[0], "triggerbox").triggerbox.find("input.triggerbox-value").val());
  1250. },
  1251. clear: function (jq) {
  1252. jq.each(function () {
  1253. var opts = $(this).triggerbox("options");
  1254. opts.data = [];
  1255. $(this).triggerbox("setValue", opts.data);
  1256. });
  1257. }
  1258. };
  1259. $.fn.triggerbox.parseOptions = function (_7c7) {
  1260. var t = $(_7c7);
  1261. return $.extend({}, $.extend({}, $.fn.triggerbox.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"])), $.fn.validatebox.parseOptions(_7c7));
  1262. };
  1263. $.fn.triggerbox.defaults = $.extend({},
  1264. $.fn.validatebox.defaults, {
  1265. valueField: "value",
  1266. textField: "text",
  1267. separator: ",",
  1268. editable: true,
  1269. postData: {},
  1270. change: function () { },
  1271. formatter: function (row) {
  1272. var opts = $(this).triggerbox("options");
  1273. return row[opts.textField];
  1274. }
  1275. }
  1276. );
  1277. })(jQuery);
  1278. //2013-04-28 end added by pengbb 新增triggerbox控件,用于用户选择和部门选择,号码规则选择
  1279. //2013-05-03 begin added by pengbb 新增号码规则选择控件
  1280. function TelNumberRuleSelector(config) {
  1281. var defaultConfig = { onSelect: null, width: 600, height: 400, postData: {} };
  1282. config = $.extend({}, defaultConfig, config);
  1283. var newUrl = "/Common/GetTelNumberRuleListForSelector";
  1284. newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + newUrl).replaceDoubleSlashesToSingle();
  1285. var jqPanel = $("<div class=\"easyui-window\" style=\"width:800px;height:600px; \" title=\"选择号码规则\" data-options=\"modal:true,collapsible:false,shadow:true,minimizable:false,maximizable:false,inline:false,closed:true,resizable:false,maximizable:false \" ></div> ").appendTo(document.body);
  1286. var jqPanelLayout = $('<div style="width:100%;height:100%;" class="layout" ><div style="left: 0px; top: 0px; width:100%; " class="panel layout-panel layout-panel-center"><div class="panel-body panel-body-noheader panel-body-noborder layout-body" title="" style="position: relative; width:100%; height: 320px; overflow: auto;"></div></div><div style="left: 0px; top: 320px; width: 100%;" class="panel layout-panel layout-panel-south"><div class="panel-body panel-body-noheader panel-body-noborder layout-body" title="" style="height: 29px; text-align: right; padding: 5px 0px 0px; width: 100%;"><!-- 窗口操作按扭 --></div></div> </div>').appendTo(jqPanel);
  1287. var jqPanelLayoutCenter = jqPanelLayout.find("div.layout-panel-center>div.layout-body");
  1288. var jqPanelLayoutCenterContent = $('<div style="padding:5px;" ></div>').appendTo(jqPanelLayoutCenter);
  1289. var jqPanelLayoutSouth = jqPanelLayout.find("div.layout-panel-south>div.layout-body");
  1290. var btnYes = $("<a class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-ok'\" style=\"margin-right:5px;\" href=\"javascript:void(0)\" >确定</a>").appendTo(jqPanelLayoutSouth);
  1291. var btnNo = $("<a class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-cancel'\" style=\"margin-right:5px;\" href=\"javascript:void(0)\" >取消</a>").appendTo(jqPanelLayoutSouth);
  1292. if (config.width) {
  1293. jqPanel.width(config.width);
  1294. }
  1295. if (config.height) {
  1296. jqPanel.height(config.height);
  1297. }
  1298. jqPanel.window();
  1299. btnYes.linkbutton();
  1300. btnNo.linkbutton();
  1301. var isIE6 = false;
  1302. if ($.browser.msie) {
  1303. if ($.browser.version < 7) {
  1304. isIE6 = true;
  1305. }
  1306. }
  1307. var centerContentConfig = {
  1308. url: newUrl,
  1309. postData: config.postData,
  1310. onLoaded: function () {
  1311. jqPanelLayoutCenterContent.find("div.cmspanel>div.panel-header>div.panel-tool>a.cmspanel-tool-collapse").click(function () {
  1312. var _this = $(this);
  1313. if (_this.hasClass("panel-tool-expand")) {
  1314. _this.removeClass("panel-tool-expand");
  1315. if (isIE6) {
  1316. _this.closest("div.cmspanel").find("div.panel-body").show();
  1317. } else {
  1318. _this.closest("div.cmspanel").find("div.panel-body").slideDown();
  1319. }
  1320. } else {
  1321. _this.addClass("panel-tool-expand");
  1322. if (isIE6) {
  1323. _this.closest("div.cmspanel").find("div.panel-body").hide();
  1324. } else {
  1325. _this.closest("div.cmspanel").find("div.panel-body").slideUp();
  1326. }
  1327. }
  1328. });
  1329. }
  1330. };
  1331. jqPanelLayoutCenterContent.cmsLoadHtml(centerContentConfig);
  1332. var eventManager = { onSelect: [] };
  1333. var _select = function (fn) {
  1334. eventManager["onSelect"].push(fn);
  1335. }
  1336. if (config.onSelect) {
  1337. eventManager["onSelect"].push(config.onSelect);
  1338. }
  1339. btnYes.unbind(".SelectTelNumberRule");
  1340. btnNo.unbind(".SelectTelNumberRule");
  1341. btnYes.bind("click.SelectTelNumberRule", function () {
  1342. var selectDatas = [];
  1343. $(jqPanel).find("input[type=checkbox]:checked").each(function () {
  1344. selectDatas.push({ text: $(this).attr("text"), value: $(this).val() });
  1345. });
  1346. _postEvent(selectDatas);
  1347. _hide();
  1348. });
  1349. btnNo.bind("click.SelectTelNumberRule", function () {
  1350. _hide();
  1351. });
  1352. var _show = function () {
  1353. jqPanel.window('open');
  1354. };
  1355. var _hide = function () {
  1356. jqPanel.window('close');
  1357. };
  1358. var _postEvent = function (p) {
  1359. $.each(eventManager["onSelect"], function () {
  1360. this.call(_this, p);
  1361. });
  1362. }
  1363. var _this = { jq: jqPanel, show: _show, hide: _hide, select: _select };
  1364. return _this;
  1365. }
  1366. //2013-05-03 end added by pengbb新增号码规则选择控件
  1367. var SelectUserContorl = function (departmentID, multipleChoice, handlers) {
  1368. var groups = {};
  1369. var DepartmentID = departmentID;
  1370. var MultipleChoice = multipleChoice;
  1371. var waitDataGrid;
  1372. var pitchOnDataGrid;
  1373. var rightTopQuey;
  1374. var tree;
  1375. var win;
  1376. var leftQuery;
  1377. //private 创建Html元素
  1378. var createElement = function (elementTypeName, elements, parentElments) {
  1379. $(elementTypeName).removeClass();
  1380. if (typeof parentElments != "undefined" && typeof elements == "string") {
  1381. var elementsObject = $(elements);
  1382. parentElments.append(elementsObject);
  1383. return elementsObject;
  1384. } else {
  1385. if (typeof elements == "string")
  1386. return $(elements);
  1387. }
  1388. };
  1389. var createTableString = function (name) {
  1390. var table = "<table";
  1391. return table.concat(" name='", name, "'>", "</table>");
  1392. };
  1393. var InitGridFile = function (dataGrid, pagination, url) {
  1394. return dataGrid.datagrid({
  1395. url: pagination ? url : "",
  1396. queryParams: pagination ? {
  1397. departmentID: DepartmentID,
  1398. userName: rightTopQuey.find("input[name='txtUserName']").val()
  1399. } : "",
  1400. pagination: pagination,
  1401. pageSize: 1,
  1402. pageList: [5, 10],
  1403. loadMsg: "请稍等....",
  1404. columns: [[
  1405. { field: 'UserID', title: 'UserID', checkbox: true },
  1406. { field: 'DepartmentName', title: '部门机构' },
  1407. { field: 'LoginName', title: '登录名' },
  1408. { field: 'UserName', title: '用户名' }
  1409. ]]
  1410. });
  1411. }
  1412. //private 选择用户
  1413. var selectWaitUser = function () {
  1414. var selectUser = waitDataGrid.datagrid("getChecked");
  1415. if (selectUser.length > 0) {
  1416. if (!multipleChoice && selectUser.length > 1) {
  1417. $.messager.alert("系统消息", "一次只能选择一个用户!");
  1418. } else {
  1419. var dataSource = "{\"total\":".concat(selectUser.length, ",", "\"rows\":[");
  1420. for (var i = 0; i < selectUser.length; i++) {
  1421. dataSource = dataSource.concat('{"UserID":', "\"", selectUser[i].UserID, "\",", '"DepartmentName":',
  1422. "\"", selectUser[i].DepartmentName, "\",\"LoginID\":\"", selectUser[i].LoginName, "\",\"UserName\":\"",
  1423. selectUser[i].UserName, "\"},"
  1424. );
  1425. }
  1426. dataSource = dataSource.substring(0, dataSource.length - 1);
  1427. dataSource = dataSource.concat("]}");
  1428. var currentData = $.parseJSON(dataSource);
  1429. currentData.rows = currentData.rows.sort(function (a, b) {
  1430. return a > b;
  1431. });
  1432. if (typeof (pitchOnDataGrid.data("SelectedUser")) != "undefined") {
  1433. //先拿缓存数据
  1434. var cachData = pitchOnDataGrid.data("SelectedUser");
  1435. for (var i = 0; i < cachData.rows.length; i++) {
  1436. for (var j = 0; j < currentData.rows.length; j++) {
  1437. if (cachData.rows[i].UserID == currentData.rows[j].UserID) {
  1438. currentData.rows.splice(j, 1);
  1439. }
  1440. }
  1441. }
  1442. cachData.rows = $.merge(currentData.rows, cachData.rows);
  1443. pitchOnDataGrid.data("SelectedUser", cachData);
  1444. } else {
  1445. pitchOnDataGrid.data("SelectedUser", currentData);
  1446. }
  1447. pitchOnDataGrid.datagrid("loadData", pitchOnDataGrid.data("SelectedUser"));
  1448. }
  1449. } else {
  1450. $.messager.alert("系统消息", "未选择任何用户!");
  1451. }
  1452. };
  1453. var registEvent = function (target, eventType, handler) {
  1454. target.unbind(eventType, handler);
  1455. target.bind(eventType, handler);
  1456. }
  1457. var close = function () {
  1458. var btnSelectOk = $((rightTopQuey.find("a"))[1]);
  1459. btnSelectOk.unbind();
  1460. btnSelectOk.bind("click", function () {
  1461. var selectUser = pitchOnDataGrid.datagrid("getData");
  1462. if (handlers instanceof Array) {
  1463. for (var i = 0; i < handlers.length; i++) {
  1464. handlers[i](selectUser);
  1465. }
  1466. } else if (typeof handlers != "undefined") {
  1467. handlers(selectUser);
  1468. }
  1469. win.window("close");
  1470. });
  1471. };
  1472. var hasEasyUI = function (elementTypeName) {
  1473. if ($(elementTypeName).length > 0) {
  1474. return true;
  1475. } else {
  1476. return false;
  1477. }
  1478. }
  1479. var createLinkButton = function (elements) {
  1480. var links = elements.find("a");
  1481. for (var i = 0; i < links.length; i++) {
  1482. $(links[i]).linkbutton();
  1483. }
  1484. };
  1485. var getUserInfo = function () {
  1486. waitDataGrid.datagrid('load', {
  1487. departmentID: DepartmentID,
  1488. userName: rightTopQuey.find("input[name='txtUserName']").val()
  1489. }
  1490. );
  1491. }
  1492. var deleteSelectUser = function () {
  1493. var deleteSource = pitchOnDataGrid.datagrid("getChecked");
  1494. if (deleteSource.length > 0) {
  1495. for (var i = 0; i < deleteSource.length; i++) {
  1496. var rowIndex = pitchOnDataGrid.datagrid("getRowIndex", deleteSource[i]);
  1497. pitchOnDataGrid.datagrid("deleteRow", rowIndex);
  1498. }
  1499. }
  1500. //else {
  1501. // $.messager.alert("系统消息", "未选中任何行!");
  1502. // }
  1503. };
  1504. var loadDepartmentTree = function () {
  1505. var inputDepartment = leftQuery.find("input[name='txtDepartmentName']").val();
  1506. $.cmsPost("/Common/GetSelectUserControlDepartmentTree",
  1507. { departmentID: "", departmentName: inputDepartment },
  1508. function (data) {
  1509. $(tree).tree('loadData', data);
  1510. });
  1511. }
  1512. var show = function () {
  1513. if (!hasEasyUI("div[name='winWarp']")) {
  1514. var warpElement = "<div class='selectUser_warp clear'></div>";
  1515. var warp = createElement(".selectUser_warp", warpElement, win);
  1516. win = warp.window({
  1517. width: 760,
  1518. height: 500,
  1519. modal: true,
  1520. maximizable: false,
  1521. title: '用户信息选择'
  1522. });
  1523. var elementLeft = createElement(".selectUser_left",
  1524. "<div class='selectUser_left postion_border'></div>", warp);
  1525. var elementRight = createElement(".selectUser_right",
  1526. "<div class='selectUser_right postion_border'></div>", warp);
  1527. var leftQueryTable = "<table class='query'><tr>";
  1528. leftQueryTable = leftQueryTable.concat("<td align='right'>渠道名称:</td>");
  1529. leftQueryTable = leftQueryTable.concat("<td align='left'><input type='text' name='txtDepartmentName' class='selectUser_Input selectUser_inputCondition'/></td>");
  1530. leftQueryTable = leftQueryTable.concat("<td colspan='2' align='center' ><a id='btn' href='#' name='btnQueryDepartment'>查询</a> </td>");
  1531. leftQueryTable = leftQueryTable.concat("</tr></table>");
  1532. leftQuery = createElement(".query", leftQueryTable, elementLeft);
  1533. createLinkButton(leftQuery);
  1534. var left_panel_warp = createElement("div[panel_postion='left']", "<div class='panel_Data' panel_postion='left'><ul name='departmentTree'></ul></div>", elementLeft);
  1535. left_panel_warp.panel({
  1536. width: 350,
  1537. height: 450,
  1538. title: '部门信息',
  1539. closable: false,
  1540. collapsible: true,
  1541. minimizable: false,
  1542. maximizable: false
  1543. });
  1544. var departmentName = leftQuery.find("input[name='txtDepartmentName']").val();
  1545. tree = $(left_panel_warp.find("ul[name='departmentTree']")[0]).tree({
  1546. url: ("/" + CMS_SystemConfig.VirtualDirectoryPath + ("/Common/GetSelectUserControlDepartmentTree?departmentName=" + departmentName).replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle(),
  1547. lines: true,
  1548. onBeforeLoad: function (node, param) {
  1549. if (node == null) {
  1550. return true;
  1551. } else {
  1552. var children = $(this).tree("getChildren", node.target);
  1553. if (children == "") {
  1554. return true;
  1555. } else {
  1556. return false;
  1557. }
  1558. }
  1559. },
  1560. onClick: function (node) {
  1561. DepartmentID = eval(node).id;
  1562. getUserInfo();
  1563. }
  1564. });
  1565. var rightQuery = '<p class="query_p right_query_Postion" pPostion="right_top">帐号/用户名:<input type="text" name="txtUserName" class="selectUser_Input"/> <a href="#" name="btnQueryUser">查询</a>';
  1566. rightQuery = rightQuery.concat("&nbsp;&nbsp;<a href='#' name='btnSelectOk' >确定</a></p>");
  1567. rightTopQuey = createElement("p[pPostion='right_top']", rightQuery, elementRight);
  1568. createLinkButton(rightTopQuey);
  1569. var rightWaitChoise_paneDiv = createElement("div[panel_postion='right_middel']", "<div class='panel_Data' panel_postion='right_middel'></div>", elementRight);
  1570. var waitChoisePanel = rightWaitChoise_paneDiv.panel({
  1571. width: 380,
  1572. title: '待选用户',
  1573. closable: false,
  1574. collapsible: true,
  1575. minimizable: false,
  1576. maximizable: false
  1577. });
  1578. var selectAndDeteButtonStr = "<p class='query_p' pPostion='right_bottom'><a href='#' name='btnselectWaitUser' >选择</a> &nbsp;&nbsp;&nbsp;&nbsp;<a href='#' name='btnDelete'>删除</a> </p>";
  1579. var selectAndDeteButton = createElement("p[pPostion='right_bottom']", selectAndDeteButtonStr, elementRight);
  1580. createLinkButton(selectAndDeteButton);
  1581. var left_panel_warp = createElement("div[panel_postion='right_selectUser']", "<div class='panel_Data' panel_postion='right_selectUser'></div>", elementRight);
  1582. var pitchOnPanel = left_panel_warp.panel({
  1583. width: 380,
  1584. height: 150,
  1585. title: '已选用户',
  1586. closable: false,
  1587. collapsible: true,
  1588. minimizable: false,
  1589. maximizable: false
  1590. });
  1591. var waitTable = createElement("table[name='waitDataGrid']", createTableString("waitDataGrid"), waitChoisePanel);
  1592. var pitchOnTable = createElement("table[name='pitchOnDataGrid']", createTableString("pitchOnDataGrid"), pitchOnPanel);
  1593. waitDataGrid = InitGridFile(waitTable, true, ("/" + CMS_SystemConfig.VirtualDirectoryPath + ("/Common/GetSelectUserContorlViewPageList").replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle());
  1594. pitchOnDataGrid = (InitGridFile(pitchOnTable, false));
  1595. //查询部门树
  1596. registEvent(leftQuery.find("a:first"), "click", loadDepartmentTree);
  1597. //选择用户
  1598. registEvent(selectAndDeteButton.find("a:first"), "click", selectWaitUser);
  1599. //删除用户
  1600. registEvent($(selectAndDeteButton.find("a")[1]), "click", deleteSelectUser);
  1601. //关闭
  1602. registEvent(rightTopQuey.find("a:first"), "click", getUserInfo);
  1603. close(handlers);
  1604. } else {
  1605. $("div[name='winWarp']").window('open');
  1606. }
  1607. };
  1608. return { "show": show };
  1609. };
  1610. $.extend($.fn.validatebox.defaults.rules, {
  1611. baseRequired: {
  1612. validator: function (value, param) {
  1613. return value && value != "";
  1614. },
  1615. message: '必填'
  1616. },
  1617. dropdownListRequired: {
  1618. validator: function (value, param) {
  1619. return value != "" && value != "-1" && value != "全部" && value != "请选择";
  1620. },
  1621. message: '必选'
  1622. },
  1623. mobile: {
  1624. validator: function (value, param) {
  1625. return (/^1\d{10}$/gi).test(value);
  1626. },
  1627. message: '手机号码格式不对'
  1628. },
  1629. telnumber: {
  1630. validator: function (value, param) {
  1631. return (/((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/gi).test(value);
  1632. },
  1633. message: '号码格式不对'
  1634. },
  1635. IDCard: {
  1636. validator: function (value, param) {
  1637. var idcard = value; //身份证号码
  1638. var Errors = new Array(
  1639. "验证通过!OK",
  1640. "身份证号码位数不对!",
  1641. "身份证号码出生日期超出范围或含有非法字符!",
  1642. "身份证号码校验错误!",
  1643. "身份证地区非法!"
  1644. );
  1645. var area = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外" };
  1646. var idcard, Y, JYM;
  1647. var S, M;
  1648. var idcard_array = new Array();
  1649. idcard_array = idcard.split("");
  1650. //地区检验
  1651. if (area[parseInt(idcard.substr(0, 2))] == null) {
  1652. this.message = Errors[4];
  1653. return false;
  1654. }
  1655. //身份号码位数及格式检验
  1656. switch (idcard.length) {
  1657. case 15:
  1658. if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0)) {
  1659. ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/; //测试出生日期的合法性
  1660. } else {
  1661. ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/; //测试出生日期的合法性
  1662. }
  1663. if (ereg.test(idcard)) return true;
  1664. else {
  1665. this.message = Errors[2];
  1666. return false;
  1667. }
  1668. break;
  1669. case 18:
  1670. //18位身份号码检测
  1671. //出生日期的合法性检查
  1672. //闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
  1673. //平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
  1674. if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard.substr(6, 4)) % 4 == 0)) {
  1675. ereg = /^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/; //闰年出生日期的合法性正则表达式
  1676. } else {
  1677. ereg = /^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/; //平年出生日期的合法性正则表达式
  1678. }
  1679. if (ereg.test(idcard)) {//测试出生日期的合法性
  1680. //计算校验位
  1681. S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7
  1682. + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
  1683. + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10
  1684. + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
  1685. + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8
  1686. + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
  1687. + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2
  1688. + parseInt(idcard_array[7]) * 1
  1689. + parseInt(idcard_array[8]) * 6
  1690. + parseInt(idcard_array[9]) * 3;
  1691. Y = S % 11;
  1692. M = "F";
  1693. JYM = "10X98765432";
  1694. M = JYM.substr(Y, 1); //判断校验位
  1695. if (M == idcard_array[17]) return true; //检测ID的校验位
  1696. else {
  1697. this.message = Errors[3];
  1698. return false;
  1699. };
  1700. }
  1701. else {
  1702. this.message = Errors[2];
  1703. return false;
  1704. };
  1705. break;
  1706. default:
  1707. this.message = Errors[1];
  1708. return false;
  1709. break;
  1710. }
  1711. },
  1712. message: '证件号码格式不对'
  1713. },
  1714. filterWord: {
  1715. validator: function (value, param) {
  1716. var returnValue = true;
  1717. $(param[0]).each(function (i, item) {
  1718. if (item == value) {
  1719. returnValue = false;
  1720. return false;
  1721. }
  1722. });
  1723. return returnValue;
  1724. },
  1725. message: '敏感字过滤'
  1726. },
  1727. onlyNumber: {
  1728. validator: function (value, param) {
  1729. return (/^[0-9]\d*$/gi).test(value);
  1730. },
  1731. message: '仅允许输入数字'
  1732. },
  1733. onlyDiscount: {
  1734. validator: function (value, param) {
  1735. //^0\.[0-9]{1,2}$
  1736. return (/^(?:0(?:\.(?!00)[0-9]{1,2})?|1)$/gi).test(value);
  1737. // return (/^[1-9]([.]{1}[1-9])?$/gi).test(value);
  1738. },
  1739. message: '仅允许输入带二位小数的有效数字'
  1740. },
  1741. onlyChar: {
  1742. validator: function (value, param) {
  1743. return (/^[A-Za-z0-9]+$/gi).test(value);
  1744. },
  1745. message: '仅允许输入英文及数字'
  1746. },
  1747. onlyMoney: {
  1748. validator: function (value, param) {
  1749. return (/^-?\d+(\.\d{1,2})?$/gi).test(value);
  1750. },
  1751. message: '仅允许输入保留二位有效数字'
  1752. }
  1753. });
  1754. $.extend($.fn.validatebox.methods, {
  1755. remove: function (jq, newposition) {
  1756. return jq.each(function () {
  1757. $(this).removeClass("validatebox-text validatebox-invalid").unbind('focus.validatebox').unbind('blur.validatebox');
  1758. });
  1759. },
  1760. reduce: function (jq, newposition) {
  1761. return jq.each(function () {
  1762. var opt = $(this).data().validatebox.options;
  1763. $(this).addClass("validatebox-text").validatebox(opt);
  1764. });
  1765. }
  1766. });
  1767. $.extend($.fn.validatebox.methods, {
  1768. removeForCombobox: function (jq, newposition) {
  1769. return jq.each(function () {
  1770. var comboxText = $(this).next().find("input").first();
  1771. comboxText.removeClass("validatebox-text validatebox-invalid").unbind('focus.validatebox').unbind('blur.validatebox');
  1772. });
  1773. },
  1774. reduceForCombobox: function (jq, newposition) {
  1775. return jq.each(function () {
  1776. var comboxText = $(this).next().find("input").first();
  1777. var opt = comboxText.data().validatebox.options;
  1778. comboxText.addClass("validatebox-text").validatebox(opt);
  1779. });
  1780. }
  1781. });
  1782. //2013-12-05 begin added by pengbb 新增ajax加载html内容控件
  1783. /*用法:定义一个div,指定class 为 easyui-cmsLoadHtml
  1784. <div class="easyui-cmsLoadHtml" data-options="url:'/Common/GetHtmlContent'" >
  1785. </div>
  1786. data-options参数如下:
  1787. url:'/Common/GetHtmlContent',
  1788. loadingMessage:'正在加载中...',
  1789. postData : {}
  1790. */
  1791. (function ($) {
  1792. $.parser.plugins.push("cmsLoadHtml");
  1793. function _init(jq) {
  1794. var opts = $.data(jq, "cmsLoadHtml").options;
  1795. return { cmsLoadHtml: jq };
  1796. }
  1797. function _load(jq) {
  1798. var opts = $.data(jq, "cmsLoadHtml").options;
  1799. if (opts.url && opts.url != "") {
  1800. if (opts.loadingMessage) {
  1801. //loadPanel.prependTo(jq);
  1802. var loadPanel = $("<div style=\"float:left;width:100%; height:100%;position:relative;\"></div>").prependTo(jq);
  1803. $("<div style=\"clear:both;\"></div>").appendTo(jq);
  1804. $("<div class=\"loadhtml-mask\" style=\"display:block\"></div>").appendTo(loadPanel);
  1805. var msg = $("<div class=\"loadhtml-mask-msg\" style=\"display:block;left:50%\"></div>").html(opts.loadingMessage).appendTo(loadPanel);
  1806. msg.css("marginLeft", -msg.outerWidth() / 2);
  1807. }
  1808. setTimeout(function () {
  1809. $.ajax({
  1810. url: opts.url,
  1811. data: $.extend({}, {}, opts.postData),
  1812. cache: false,
  1813. dataType: "html",
  1814. success: function (data) {
  1815. $(jq).html(opts.extractor.call(jq, data));
  1816. if (typeof (opts.onLoaded) == "function") {
  1817. opts.onLoaded.call(jq);
  1818. }
  1819. }
  1820. });
  1821. }, opts.delay);
  1822. }
  1823. };
  1824. $.fn.cmsLoadHtml = function (_7be, _7bf) {
  1825. if (typeof _7be == "string") {
  1826. var _7c0 = $.fn.cmsLoadHtml.methods[_7be];
  1827. if (_7c0) {
  1828. return _7c0(this, _7bf);
  1829. } else {
  1830. return this.cmsLoadHtml(_7be, _7bf);
  1831. }
  1832. }
  1833. _7be = _7be || {};
  1834. return this.each(function () {
  1835. var _this = this;
  1836. var _jqThis = $(_this);
  1837. var cacheData = $.data(_this, "cmsLoadHtml");
  1838. if (cacheData) {
  1839. $.extend(cacheData.options, _7be);
  1840. } else {
  1841. cacheData = $.data(_this, "cmsLoadHtml", { options: $.extend({}, $.fn.cmsLoadHtml.defaults, $.fn.cmsLoadHtml.parseOptions(this), _7be) });
  1842. var initCacheData = _init(_this);
  1843. cacheData = $.data(_this, "cmsLoadHtml", $.extend({}, cacheData, initCacheData));
  1844. }
  1845. _load(_this);
  1846. });
  1847. };
  1848. $.fn.cmsLoadHtml.methods = {
  1849. options: function (jq) {
  1850. var opts = $.data(jq[0], "cmsLoadHtml").options;
  1851. return opts;
  1852. },
  1853. reload: function (jq) {
  1854. _load(jq[0]);
  1855. }
  1856. };
  1857. $.fn.cmsLoadHtml.parseOptions = function (_7c7) {
  1858. var t = $(_7c7);
  1859. return $.extend({}, $.fn.cmsLoadHtml.defaults, $.parser.parseOptions(_7c7, []));
  1860. };
  1861. $.fn.cmsLoadHtml.defaults = {
  1862. url: '',
  1863. delay: 0,
  1864. loadingMessage: '正在加载中...',
  1865. postData: {},
  1866. onLoaded: function () { },
  1867. extractor: function (data) {
  1868. var _1ef = /<body[^>]*>((.|[\n\r])*)<\/body>/im;
  1869. var _1f0 = _1ef.exec(data);
  1870. if (_1f0) {
  1871. return _1f0[1];
  1872. } else {
  1873. return data;
  1874. }
  1875. }
  1876. };
  1877. })(jQuery);
  1878. //2013-12-05 end added by pengbb 新增ajax加载html内容控件
  1879. //2013-12-10 begin added by pengbb 新增下一步审批人控件
  1880. /*用法:定义一个div,指定class 为 easyui-cmsNextApproverSelector
  1881. <div class="easyui-cmsNextApproverSelector" data-options="url:'/Common/GetHtmlContent'" >
  1882. </div>
  1883. data-options参数如下:
  1884. url:'/Common/GetHtmlContent',
  1885. loadingMessage:'正在加载中...',
  1886. postData : {}
  1887. */
  1888. (function ($) {
  1889. $.parser.plugins.push("cmsNextApproverSelector");
  1890. function _init(jq) {
  1891. var opts = $.data(jq, "cmsNextApproverSelector").options;
  1892. var approverCombobox = $("<input />").attr("name", opts.name).appendTo(jq);
  1893. var workPositionLabel = $("<label />").appendTo(jq);
  1894. return { cmsNextApproverSelector: jq, approverCombobox: approverCombobox, workPositionLabel: workPositionLabel };
  1895. }
  1896. function _load(jq) {
  1897. var opts = $.data(jq, "cmsNextApproverSelector").options;
  1898. var approverCombobox = $.data(jq, "cmsNextApproverSelector").approverCombobox;
  1899. var workPositionLabel = $.data(jq, "cmsNextApproverSelector").workPositionLabel;
  1900. var loadingMessage = opts.loadingMessage || "系统正在加载下一步审批人中,请稍候...";
  1901. var approverComboboxDefaultOptions = {
  1902. multiple: false,
  1903. panelHeight: 'auto',
  1904. onSelect: function (record) {
  1905. workPositionLabel.text(record.data[0].label);
  1906. if (typeof (opts.onSelect) == "function") {
  1907. opts.onSelect.call(jq);
  1908. }
  1909. },
  1910. onLoadSuccess: function () {
  1911. if (opts.showProgress) {
  1912. //$.messager.progress('close');
  1913. $.cmsLoading.hide();
  1914. }
  1915. if (approverCombobox.combobox("options").firstLoad) return;
  1916. var getData = approverCombobox.combobox("getData");
  1917. if (getData.length > 0) {
  1918. if (getData[0].data[0].label == "结束") {
  1919. approverCombobox.combobox("select", getData[0].id);
  1920. workPositionLabel.text(getData[0].data[0].label);
  1921. approverCombobox.combobox('disable');
  1922. } else {
  1923. approverCombobox.combobox('setValues', ['请选择']);
  1924. }
  1925. }
  1926. if (typeof (opts.onLoadSuccess) == "function") {
  1927. opts.onLoadSuccess.call(jq);
  1928. }
  1929. },
  1930. onLoadError: function () {
  1931. if (opts.showProgress) {
  1932. //$.messager.progress('close');
  1933. $.cmsLoading.hide();
  1934. }
  1935. //if (approverCombobox.combobox("options").firstLoad) return;
  1936. if (typeof (opts.onLoadError) == "function") {
  1937. opts.onLoadError.call(jq);
  1938. }
  1939. },
  1940. //firstLoad: true,
  1941. onBeforeLoad: function (param) {
  1942. //alert(approverCombobox.combobox("options").firstLoad);
  1943. //if (approverCombobox.combobox("options").firstLoad) {
  1944. // approverCombobox.combobox("options").firstLoad = false;
  1945. // return false;
  1946. //}
  1947. if (opts.showProgress) {
  1948. //$.messager.progress({ msg: loadingMessage, autoClose: true, interval: 600 });
  1949. $.cmsLoading.show(loadingMessage);
  1950. }
  1951. approverCombobox.combobox('enable');
  1952. workPositionLabel.text("");
  1953. $.extend(param, opts.postData);
  1954. }
  1955. };
  1956. approverCombobox.combobox($.extend({}, opts, approverComboboxDefaultOptions));
  1957. }
  1958. $.fn.cmsNextApproverSelector = function (_7be, _7bf) {
  1959. if (typeof _7be == "string") {
  1960. var _7c0 = $.fn.cmsNextApproverSelector.methods[_7be];
  1961. if (_7c0) {
  1962. return _7c0(this, _7bf);
  1963. } else {
  1964. return this.cmsNextApproverSelector(_7be, _7bf);
  1965. }
  1966. }
  1967. _7be = _7be || {};
  1968. return this.each(function () {
  1969. var _this = this;
  1970. var _jqThis = $(_this);
  1971. var cacheData = $.data(_this, "cmsNextApproverSelector");
  1972. if (cacheData) {
  1973. $.extend(cacheData.options, _7be);
  1974. } else {
  1975. cacheData = $.data(_this, "cmsNextApproverSelector", { options: $.extend({}, $.fn.cmsNextApproverSelector.defaults, $.fn.cmsNextApproverSelector.parseOptions(this), _7be) });
  1976. var initCacheData = _init(_this);
  1977. cacheData = $.data(_this, "cmsNextApproverSelector", $.extend({}, cacheData, initCacheData));
  1978. }
  1979. //cacheData.approverCombobox.combobox("reload");
  1980. _load(_this);
  1981. });
  1982. };
  1983. $.fn.cmsNextApproverSelector.methods = {
  1984. options: function (jq) {
  1985. var opts = $.data(jq[0], "cmsNextApproverSelector").options;
  1986. return opts;
  1987. },
  1988. reload: function (jq) {
  1989. var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
  1990. approverCombobox.combobox("reload");
  1991. },
  1992. getData: function (jq) {
  1993. var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
  1994. return approverCombobox.combobox("getData");
  1995. },
  1996. setValue: function (jq, val) {
  1997. var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
  1998. approverCombobox.combobox("setValue", val);
  1999. },
  2000. setValues: function (jq, vals) {
  2001. var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
  2002. approverCombobox.combobox("setValues", vals);
  2003. },
  2004. getValue: function (jq, vals) {
  2005. var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
  2006. return approverCombobox.combobox("getValue");
  2007. },
  2008. getValues: function (jq, vals) {
  2009. var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
  2010. return approverCombobox.combobox("getValues");
  2011. },
  2012. isValid: function (jq) {
  2013. var t = $(jq);
  2014. t.find(".validatebox-text:not(:disabled)").validatebox("validate");
  2015. var _3dd = t.find(".validatebox-invalid");
  2016. _3dd.filter(":not(:disabled):first").focus();
  2017. return _3dd.length == 0;
  2018. },
  2019. validate: function (jq) {
  2020. var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
  2021. return approverCombobox.combobox("validate");
  2022. }
  2023. };
  2024. $.fn.cmsNextApproverSelector.parseOptions = function (_7c7) {
  2025. var t = $(_7c7);
  2026. return $.extend({}, $.extend({}, $.fn.cmsNextApproverSelector.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"])), $.fn.validatebox.parseOptions(_7c7));
  2027. //return $.extend({}, $.fn.cmsNextApproverSelector.defaults, $.parser.parseOptions(_7c7, []));
  2028. };
  2029. $.fn.cmsNextApproverSelector.defaults = {
  2030. valueField: 'id',
  2031. textField: 'text',
  2032. url: '',
  2033. loadingMessage: '',
  2034. name: '',
  2035. postData: {},
  2036. showProgress: true,
  2037. onSelect: function () { },
  2038. onLoadSuccess: function () { },
  2039. onLoadError: function () { }
  2040. };
  2041. })(jQuery);
  2042. //2013-12-05 end added by pengbb 新增下一步审批人控件
  2043. //2014-01-19 begin added by pengbb 新增下拉控件
  2044. (function ($) {
  2045. $.parser.plugins.push("cmsCombobox");
  2046. function _getSelectedRecord(jq, selectedValue) {
  2047. var opts = $.data(jq, "cmsCombobox").options;
  2048. var reVal = null;
  2049. $.each(opts.data, function () {
  2050. if (this[opts.valueField] == selectedValue) {
  2051. reVal = this;
  2052. return false;
  2053. }
  2054. });
  2055. return reVal;
  2056. }
  2057. function _init(jq) {
  2058. var opts = $.data(jq, "cmsCombobox").options;
  2059. var jqThis = $(jq);
  2060. if (!opts.url) {
  2061. opts.value = jq.value;
  2062. opts.data = new Array();
  2063. jqThis.find("option").each(function () {
  2064. var rowRecord = new Object();
  2065. rowRecord[opts.valueField] = this.value;
  2066. rowRecord[opts.textField] = this.text;
  2067. opts.data.push(rowRecord);
  2068. });
  2069. }
  2070. $(jq).change(function () {
  2071. opts.value = $(this).val();
  2072. opts.onSelect.call(jq, _getSelectedRecord(jq, opts.value));
  2073. });
  2074. return { cmsCombobox: jq };
  2075. }
  2076. function _loadData(jq, data) {
  2077. var opts = $.data(jq, "cmsCombobox").options;
  2078. opts.data = data || [];
  2079. var optionList = new Array();
  2080. $.each(opts.data, function () {
  2081. optionList.push("<option value=\"" + this[opts.valueField] + "\">" + opts.formatter.call(jq, this) + "</option>");
  2082. });
  2083. $(jq).html(optionList.join(""));
  2084. opts.onLoadSuccess.apply(this);
  2085. }
  2086. function _load(jq) {
  2087. var opts = $.data(jq, "cmsCombobox").options;
  2088. if (opts.url) {
  2089. var params = {};
  2090. opts.onBeforeLoad.call(this, params);
  2091. opts.loader.call(jq, params,
  2092. function (responseJson) {
  2093. _loadData(jq, responseJson);
  2094. }, function () {
  2095. opts.onLoadError.call(this, arguments);
  2096. });
  2097. } else {
  2098. //opts.onLoadSuccess.call(this);
  2099. }
  2100. }
  2101. function _setValue(jq, val) {
  2102. //var opts = $.data(jq, "cmsCombobox").options;
  2103. jq.value = val;
  2104. }
  2105. $.fn.cmsCombobox = function (_7be, _7bf) {
  2106. if (typeof _7be == "string") {
  2107. var _7c0 = $.fn.cmsCombobox.methods[_7be];
  2108. if (_7c0) {
  2109. return _7c0(this, _7bf);
  2110. } else {
  2111. return this.cmsCombobox(_7be, _7bf);
  2112. }
  2113. }
  2114. _7be = _7be || {};
  2115. return this.each(function () {
  2116. var _this = this;
  2117. var _jqThis = $(_this);
  2118. var cacheData = $.data(_this, "cmsCombobox");
  2119. if (cacheData) {
  2120. $.extend(cacheData.options, _7be);
  2121. } else {
  2122. cacheData = $.data(_this, "cmsCombobox", { options: $.extend({}, $.fn.cmsCombobox.defaults, $.fn.cmsCombobox.parseOptions(this), _7be) });
  2123. var initCacheData = _init(_this);
  2124. cacheData = $.data(_this, "cmsCombobox", $.extend({}, cacheData, initCacheData));
  2125. }
  2126. _load(_this);
  2127. });
  2128. };
  2129. $.fn.cmsCombobox.methods = {
  2130. options: function (jq) {
  2131. var opts = $.data(jq[0], "cmsCombobox").options;
  2132. return opts;
  2133. },
  2134. reload: function (jq) {
  2135. },
  2136. getValue: function (jq) {
  2137. return jq.val();
  2138. },
  2139. setValue: function (jq, val) {
  2140. jq.each(function () {
  2141. _setValue(this, val);
  2142. });
  2143. },
  2144. disable: function (jq) {
  2145. jq.disable();
  2146. },
  2147. enable: function (jq) {
  2148. jq.enable();
  2149. }
  2150. };
  2151. $.fn.cmsCombobox.parseOptions = function (_7c7) {
  2152. var t = $(_7c7);
  2153. return $.extend({}, $.fn.combo.parseOptions(_7c7), $.parser.parseOptions(_7c7, ["valueField", "textField", "mode", "method", "url"]));
  2154. };
  2155. $.fn.cmsCombobox.defaults = $.extend({}, $.fn.combo.defaults, {
  2156. autoLoad: false,
  2157. valueField: "value", textField: "text", mode: "local", method: "post", url: null, data: null,
  2158. filter: function (q, row) {
  2159. var opts = $(this).cmsCombobox("options");
  2160. return row[opts.textField].indexOf(q) == 0;
  2161. }, formatter: function (row) {
  2162. var opts = $(this).cmsCombobox("options");
  2163. return row[opts.textField];
  2164. }, loader: function (_7c9, _7ca, _7cb) {
  2165. var opts = $(this).cmsCombobox("options");
  2166. if (!opts.url) {
  2167. return false;
  2168. }
  2169. $.ajax({
  2170. type: opts.method, url: opts.url, data: _7c9, dataType: "json", success: function (data) {
  2171. _7ca(data);
  2172. }, error: function () {
  2173. _7cb.call(this, arguments);
  2174. }
  2175. });
  2176. }, onBeforeLoad: function (_7cc) {
  2177. }, onLoadSuccess: function () {
  2178. }, onLoadError: function () {
  2179. }, onSelect: function (_7cd) {
  2180. }, onUnselect: function (_7ce) {
  2181. }
  2182. });
  2183. })(jQuery);
  2184. //2014-01-19 end added by pengbb 新增下拉控件
  2185. //2013-12-05 begin added by pengbb 新增时间选择控件
  2186. /*用法:指定class 为 easyui-cmsDatebox
  2187. <span class="easyui-cmsDatebox cmsDateTimeBox">
  2188. <input title="" style="width: auto;" readonly="false" class="cmsDateTimeBox-text" type="text">
  2189. <span class="cmsDateTimeBox-select"></span>
  2190. </span>
  2191. */
  2192. (function ($) {
  2193. $.parser.plugins.push("cmsDateTimeBox");
  2194. function _init(jq) {
  2195. var opts = $.data(jq, "cmsDateTimeBox").options;
  2196. var jqThis = $(jq);
  2197. var jqTxtValue = jqThis.find("input.cmsDateTimeBox-text");
  2198. var jqBtnSelect = jqThis.find("span.cmsDateTimeBox-select");
  2199. var wdatePickerOptions = $.extend({}, opts, {
  2200. el: jqTxtValue[0],
  2201. onpicking: function () {
  2202. }, onpicked: function () {
  2203. opts.onSelect.call(jq);
  2204. return true;
  2205. }, onclearing: function () {
  2206. }, oncleared: function () {
  2207. }
  2208. });
  2209. jqBtnSelect.bind("mouseenter.cmsDateTimeBox", function () {
  2210. $(this).addClass("cmsDateTimeBox-select-hover");
  2211. }).bind("mouseleave.cmsDatebox", function () {
  2212. $(this).removeClass("cmsDateTimeBox-select-hover");
  2213. }).bind("mousedown.cmsDatebox", function () {
  2214. WdatePicker(wdatePickerOptions);
  2215. });
  2216. jqTxtValue.click(function () {
  2217. WdatePicker(wdatePickerOptions);
  2218. });
  2219. return { cmsDateTimeBox: jq, txtValue: jqTxtValue, btnSelect: jqBtnSelect };
  2220. }
  2221. $.fn.cmsDateTimeBox = function (_7be, _7bf) {
  2222. if (typeof _7be == "string") {
  2223. var _7c0 = $.fn.cmsDateTimeBox.methods[_7be];
  2224. if (_7c0) {
  2225. return _7c0(this, _7bf);
  2226. } else {
  2227. return this.cmsDateTimeBox(_7be, _7bf);
  2228. }
  2229. }
  2230. _7be = _7be || {};
  2231. return this.each(function () {
  2232. var _this = this;
  2233. var _jqThis = $(_this);
  2234. var cacheData = $.data(_this, "cmsDateTimeBox");
  2235. if (cacheData) {
  2236. $.extend(cacheData.options, _7be);
  2237. } else {
  2238. cacheData = $.data(_this, "cmsDateTimeBox", { options: $.extend({}, $.fn.cmsDateTimeBox.defaults, $.fn.cmsDateTimeBox.parseOptions(this), _7be) });
  2239. var initCacheData = _init(_this);
  2240. cacheData = $.data(_this, "cmsDateTimeBox", $.extend({}, cacheData, initCacheData));
  2241. }
  2242. });
  2243. };
  2244. $.fn.cmsDateTimeBox.methods = {
  2245. options: function (jq) {
  2246. var opts = $.data(jq[0], "cmsDateTimeBox").options;
  2247. return opts;
  2248. },
  2249. getValue: function (jq) {
  2250. var txtValue = $.data(jq[0], "cmsDateTimeBox").txtValue;
  2251. return txtValue.val();
  2252. },
  2253. setValue: function (jq, val) {
  2254. jq.each(function () {
  2255. var txtValue = $.data(jq[0], "cmsDateTimeBox").txtValue;
  2256. return txtValue.val(val);
  2257. });
  2258. }
  2259. };
  2260. $.fn.cmsDateTimeBox.parseOptions = function (_7c7) {
  2261. var t = $(_7c7);
  2262. return $.extend({}, $.parser.parseOptions(_7c7, []));
  2263. };
  2264. $.fn.cmsDateTimeBox.defaults = $.extend({}, {}, {
  2265. dateFmt: 'yyyy-MM-dd',
  2266. lang: 'zh-cn',
  2267. onSelect: function () {
  2268. }
  2269. });
  2270. })(jQuery);
  2271. //2014-01-20 end added by pengbb 新增时间选择控件
  2272. //2014-01-21 begin added by pengbb 新增页面操作loading效果
  2273. $.cmsLoading = (function () {
  2274. var defaultSetting = {
  2275. panelElement: document.body,
  2276. defaultMessage: "正在努力处理中..."
  2277. };
  2278. var isInit = false;
  2279. var loadingPanel = null;
  2280. var f_getLoadingPanel = function () {
  2281. return loadingPanel;
  2282. };
  2283. var f_show = function (msg) {
  2284. if (!isInit) {
  2285. this.setting.panelElement = this.setting.panelElement || document.body;
  2286. loadingPanel = $('<div class="loading-panel"><div class="loading-mask" style="display:block"></div><div class="loading-mask-msg" style="display:block;left:46%;"></div></div>').appendTo(this.setting.panelElement);
  2287. isInit = true;
  2288. } else {
  2289. loadingPanel.show();
  2290. }
  2291. loadingPanel.find("div.loading-mask-msg").html(msg || this.setting.defaultMessage);
  2292. };
  2293. var f_hide = function () {
  2294. if (loadingPanel) {
  2295. loadingPanel.hide();
  2296. }
  2297. };
  2298. return { getLoadingPanel: f_getLoadingPanel, show: f_show, hide: f_hide, setting: defaultSetting };
  2299. })();
  2300. //2014-01-21 end added by pengbb 新增页面操作loading效果
  2301. //2014-01-23 begin added by pengbb 新增下一步审批人控件,审批页面使用
  2302. /*用法:定义一个div,指定class 为 easyui-cmsLocalNextApproverSelector
  2303. <div class="easyui-cmsLocalNextApproverSelector" data-options="" >
  2304. <select name="xxx"><option>xxx</option><option>xxx</option><option>xxx</option></select>
  2305. <label></label>
  2306. </div>
  2307. data-options参数如下:
  2308. url:'/Common/GetHtmlContent',
  2309. loadingMessage:'正在加载中...',
  2310. postData : {}
  2311. */
  2312. (function ($) {
  2313. $.parser.plugins.push("cmsLocalNextApproverSelector");
  2314. function _init(jq) {
  2315. var opts = $.data(jq, "cmsLocalNextApproverSelector").options;
  2316. var jqThis = $(jq);
  2317. var approverCombobox = jqThis.find(">select");
  2318. var workPositionLabel = jqThis.find(">label");
  2319. approverCombobox.validatebox(opts);
  2320. approverCombobox.unbind("cmsLocalNextApproverSelector");
  2321. approverCombobox.bind("change.cmsLocalNextApproverSelector", function () {
  2322. var selectedData = _getSelectedData(jq);
  2323. if (selectedData && selectedData.ApprovalPower.length > 0) {
  2324. workPositionLabel.text(selectedData.ApprovalPower[0].NodeName);
  2325. } else {
  2326. workPositionLabel.text("");
  2327. }
  2328. });
  2329. //2014-02-20 end added by pengbb 修改IE8下 下一步审批人为"结束"时验证不通过
  2330. if ($.browser.msie && $.browser.version > 6 && !approverCombobox.attr("disabled")) {
  2331. approverCombobox.validatebox("validate");
  2332. }
  2333. return { cmsNextApproverSelector: jq, approverCombobox: approverCombobox, workPositionLabel: workPositionLabel };
  2334. }
  2335. function _getSelectedData(jq) {
  2336. var opts = $.data(jq, "cmsLocalNextApproverSelector").options;
  2337. var approverCombobox = $.data(jq, "cmsLocalNextApproverSelector").approverCombobox;
  2338. var selectedValue = approverCombobox.val();
  2339. var selectedData = null;
  2340. $.each(opts.data, function () {
  2341. if (this[opts.valueField] == selectedValue) {
  2342. selectedData = this;
  2343. return false;
  2344. }
  2345. });
  2346. return selectedData;
  2347. }
  2348. function _loadData(jq, data) {
  2349. var opts = $.data(jq, "cmsLocalNextApproverSelector").options;
  2350. var approverCombobox = $.data(jq, "cmsLocalNextApproverSelector").approverCombobox;
  2351. approverCombobox.enable();
  2352. opts.data = data || [];
  2353. var optionList = new Array();
  2354. optionList.push("<option value=''>请选择</option>");
  2355. $.each(opts.data, function () {
  2356. if (this[opts.textField] == "结束") {
  2357. optionList.length = 0;
  2358. $(approverCombobox).attr("disabled", "disabled");
  2359. }
  2360. optionList.push("<option value=\"" + this[opts.valueField] + "\">" + opts.formatter.call(jq, this) + "</option>");
  2361. });
  2362. approverCombobox.html(optionList.join(""));
  2363. opts.onLoadSuccess.apply(this);
  2364. }
  2365. function _reload(jq, url, postData) {
  2366. var opts = $.data(jq, "cmsLocalNextApproverSelector").options;
  2367. var approverCombobox = $.data(jq, "cmsLocalNextApproverSelector").approverCombobox;
  2368. var workPositionLabel = $.data(jq, "cmsLocalNextApproverSelector").workPositionLabel;
  2369. approverCombobox.disable();
  2370. workPositionLabel.text("正在加载下一步审批人,请稍等...");
  2371. $.ajax({
  2372. type: "post", url: url, data: postData, dataType: "json", success: function (data) {
  2373. workPositionLabel.text("");
  2374. _loadData(jq, data);
  2375. //解决点击下一步审批人下拉框缩回去的Bug
  2376. if ($.browser.msie && $.browser.version > 6 && !approverCombobox.attr("disabled")) {
  2377. approverCombobox.validatebox("validate");
  2378. }
  2379. }, error: function () {
  2380. workPositionLabel.text("下一步审批人加载失败,请尝试重新打开,若多次出现这种请联系系统管理员");
  2381. opts.onLoadError.apply(this, arguments);
  2382. }
  2383. });
  2384. }
  2385. $.fn.cmsLocalNextApproverSelector = function (_7be, _7bf) {
  2386. if (typeof _7be == "string") {
  2387. var _7c0 = $.fn.cmsLocalNextApproverSelector.methods[_7be];
  2388. if (_7c0) {
  2389. return _7c0(this, _7bf);
  2390. } else {
  2391. return this.cmsLocalNextApproverSelector(_7be, _7bf);
  2392. }
  2393. }
  2394. _7be = _7be || {};
  2395. return this.each(function () {
  2396. var _this = this;
  2397. var _jqThis = $(_this);
  2398. var cacheData = $.data(_this, "cmsLocalNextApproverSelector");
  2399. if (cacheData) {
  2400. $.extend(cacheData.options, _7be);
  2401. } else {
  2402. cacheData = $.data(_this, "cmsLocalNextApproverSelector", { options: $.extend({}, $.fn.cmsLocalNextApproverSelector.defaults, $.fn.cmsLocalNextApproverSelector.parseOptions(this), _7be) });
  2403. var initCacheData = _init(_this);
  2404. cacheData = $.data(_this, "cmsLocalNextApproverSelector", $.extend({}, cacheData, initCacheData));
  2405. }
  2406. var opts = cacheData.options;
  2407. if (opts.url && (!opts.data || opts.data.length == 0)) {
  2408. _reload(_this, opts.url, opts.postData);
  2409. }
  2410. });
  2411. };
  2412. $.fn.cmsLocalNextApproverSelector.methods = {
  2413. options: function (jq) {
  2414. var opts = $.data(jq[0], "cmsLocalNextApproverSelector").options;
  2415. return opts;
  2416. },
  2417. reload: function (jq, p) {
  2418. jq.each(function () {
  2419. _reload(this, p.url, p.postData);
  2420. });
  2421. },
  2422. getValue: function (jq) {
  2423. var approverCombobox = $.data(jq[0], "cmsLocalNextApproverSelector").approverCombobox;
  2424. return approverCombobox.val();
  2425. },
  2426. isValid: function (jq) {
  2427. var t = $(jq);
  2428. t.find("select:not(:disabled)").validatebox("validate");
  2429. var _3dd = t.find(".validatebox-invalid");
  2430. _3dd.filter(":not(:disabled):first").focus();
  2431. return _3dd.length == 0;
  2432. },
  2433. validate: function (jq) {
  2434. var approverCombobox = $.data(jq[0], "cmsLocalNextApproverSelector").approverCombobox;
  2435. return approverCombobox.cmsCombobox("validate");
  2436. }
  2437. };
  2438. $.fn.cmsLocalNextApproverSelector.parseOptions = function (_7c7) {
  2439. var t = $(_7c7);
  2440. return $.extend({}, $.extend({}, $.fn.cmsLocalNextApproverSelector.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"])), $.fn.validatebox.parseOptions(_7c7));
  2441. //return $.extend({}, $.fn.cmsNextApproverSelector.defaults, $.parser.parseOptions(_7c7, []));
  2442. };
  2443. $.fn.cmsLocalNextApproverSelector.defaults = {
  2444. valueField: 'UserID',
  2445. textField: 'UserName',
  2446. url: '',
  2447. loadingMessage: '',
  2448. name: '',
  2449. postData: {},
  2450. data: [],
  2451. showProgress: true,
  2452. onSelect: function () { },
  2453. onLoadSuccess: function () { },
  2454. onLoadError: function () { },
  2455. formatter: function (row) {
  2456. var opts = $(this).cmsLocalNextApproverSelector("options");
  2457. return row[opts.textField];
  2458. }
  2459. };
  2460. })(jQuery);
  2461. //2014-01-23 end added by pengbb 新增下一步审批人控件,审批页面使用
  2462. //2014-02-21 begin added by pengbb 新增平铺品牌选择控件 cmsXBrandItemSelector
  2463. (function ($) {
  2464. $.parser.plugins.push("cmsXBrandItemSelector");
  2465. function _init(jq) {
  2466. var opts = $.data(jq, "cmsXBrandItemSelector").options;
  2467. var _jqThis = $(jq);
  2468. var brandPanel = _jqThis.find(".brandpanel");
  2469. var brandItemPanel = _jqThis.find(".branditempanel");
  2470. //品牌
  2471. var brandXOptionItemList = brandPanel.find(".xoption2 table.xTabOption_item");
  2472. brandXOptionItemList.unbind(".cmsXBrandItemSelector");
  2473. brandXOptionItemList.bind("mouseenter.cmsXBrandItemSelector",
  2474. function () {
  2475. var _this = $(this);
  2476. _this.addClass("xTabOption_item_hover");
  2477. }
  2478. );
  2479. brandXOptionItemList.bind("mouseleave.cmsXBrandItemSelector",
  2480. function () {
  2481. var _this = $(this);
  2482. _this.removeClass("xTabOption_item_hover");
  2483. }
  2484. );
  2485. brandXOptionItemList.bind('click.cmsXBrandItemSelector', function () {
  2486. var _this = $(this);
  2487. if (!_this.hasClass("xTabOption_item_selected")) {
  2488. brandPanel.find(".xTabOption_item_selected").each(function () {
  2489. $(this).removeClass("xTabOption_item_selected");
  2490. });
  2491. _this.addClass("xTabOption_item_selected");
  2492. brandPanel.trigger("selectChanged");
  2493. }
  2494. });
  2495. brandPanel.unbind(".cmsXBrandItemSelector");
  2496. brandPanel.bind("selectChanged.cmsXBrandItemSelector", function () {
  2497. var selectValue = brandPanel.find("table.xTabOption_item_selected:first").attr("xoptionValue");
  2498. if (selectValue != "-1") {
  2499. brandItemPanel.show();
  2500. } else {
  2501. brandItemPanel.hide();
  2502. }
  2503. var brandItemPanelContent = brandItemPanel.find(".branditempanel_content");
  2504. brandItemPanelContent.find("li.xoption").remove();
  2505. $.each(opts.brandList, function () {
  2506. if (this.BrandID == selectValue) {
  2507. $.each(this.BrandItemList, function () {
  2508. var newBrandItemLi = $('<LI class="xoption"><table class="xoption_item" cellpadding="0" cellspacing="0" border="0"><tr><td class="xoption_item_bg_left">&nbsp;</td><td class="xoption_item_bg_center">&nbsp;</td><td class="xoption_item_bg_right">&nbsp;</td></tr></table></LI>').appendTo(brandItemPanelContent);
  2509. newBrandItemLi.find("table").attr("xoptionValue", this.BrandItemID);
  2510. newBrandItemLi.find("table td.xoption_item_bg_center").text(this.BrandItemName);
  2511. });
  2512. }
  2513. });
  2514. opts.selectChanged.call(jq);
  2515. });
  2516. //品牌物品
  2517. var brandItemXOptionItemList = brandItemPanel.find("li.xoption table.xoption_item");
  2518. brandItemXOptionItemList.die(".cmsXBrandItemSelector");
  2519. brandItemXOptionItemList.live("mouseenter.cmsXBrandItemSelector",
  2520. function () {
  2521. var _this = $(this);
  2522. _this.addClass("xoption_item_hover");
  2523. }
  2524. );
  2525. brandItemXOptionItemList.live("mouseleave.cmsXBrandItemSelector",
  2526. function () {
  2527. var _this = $(this);
  2528. _this.removeClass("xoption_item_hover");
  2529. }
  2530. );
  2531. brandItemXOptionItemList.live("click.cmsXBrandItemSelector", function () {
  2532. var _this = $(this);
  2533. if (_this.hasClass("xoption_item_selected")) {
  2534. _this.removeClass("xoption_item_selected");
  2535. _this.find("td.xoption_item_bg_right>i").remove();
  2536. } else {
  2537. _this.addClass("xoption_item_selected");
  2538. $('<i class="xoption_item_icon_selected" >&nbsp;</i>').appendTo(_this.find("td.xoption_item_bg_right"));
  2539. }
  2540. brandItemPanel.trigger("selectChanged");
  2541. });
  2542. brandItemPanel.unbind(".cmsXBrandItemSelector");
  2543. brandItemPanel.bind("selectChanged.cmsXBrandItemSelector", function () {
  2544. opts.selectChanged.call(jq);
  2545. });
  2546. //清除所选按扭
  2547. // brandItemPanel.find("li.branditempanel_tools .xbutton").unbind(".cmsXBrandItemSelector");
  2548. // brandItemPanel.find("li.branditempanel_tools .xbutton").bind("click.cmsXBrandItemSelector", function () {
  2549. // if (brandItemPanel.find("li.xoption_selected a").length > 0) {
  2550. // brandItemPanel.find("li.xoption_selected a").each(function () {
  2551. // var li = $(this).closest("li");
  2552. // li.removeClass("xoption_selected");
  2553. // li.find("i").remove();
  2554. // });
  2555. // brandItemPanel.trigger("selectChanged");
  2556. // }
  2557. // });
  2558. return { cmsXBrandItemSelector: jq, brandPanel: brandPanel, brandItemPanel: brandItemPanel };
  2559. }
  2560. $.fn.cmsXBrandItemSelector = function (_7be, _7bf) {
  2561. if (typeof _7be == "string") {
  2562. var _7c0 = $.fn.cmsXBrandItemSelector.methods[_7be];
  2563. if (_7c0) {
  2564. return _7c0(this, _7bf);
  2565. } else {
  2566. return this.cmsXBrandItemSelector(_7be, _7bf);
  2567. }
  2568. }
  2569. _7be = _7be || {};
  2570. return this.each(function () {
  2571. var _this = this;
  2572. var cacheData = $.data(_this, "cmsXBrandItemSelector");
  2573. if (cacheData) {
  2574. $.extend(cacheData.options, _7be);
  2575. } else {
  2576. cacheData = $.data(_this, "cmsXBrandItemSelector", { options: $.extend({}, $.fn.cmsXBrandItemSelector.defaults, $.fn.cmsXBrandItemSelector.parseOptions(this), _7be) });
  2577. var initCacheData = _init(_this);
  2578. cacheData = $.data(_this, "cmsXBrandItemSelector", $.extend({}, cacheData, initCacheData));
  2579. }
  2580. });
  2581. };
  2582. function _getValue(jq) {
  2583. var opts = $.data(jq, "cmsXBrandItemSelector").options;
  2584. var brandPanel = $.data(jq, "cmsXBrandItemSelector").brandPanel;
  2585. var brandItemPanel = $.data(jq, "cmsXBrandItemSelector").brandItemPanel;
  2586. var brandPayType = { BrandPayTypeID: "-1", BrandPayTypeName: "全部" };
  2587. var brand = { BrandID: "-1", BrandName: "全部" };
  2588. var brandItemList = [];
  2589. brandPanel.find("table.xTabOption_item_selected:first").each(function () {
  2590. var selectedBrand = $(this);
  2591. brand = { BrandID: selectedBrand.attr("xoptionValue"), BrandName: selectedBrand.find("td.xTabOption_item_bg_center").text() };
  2592. });
  2593. brandItemPanel.find("table.xoption_item_selected").each(function () {
  2594. var selectedBrandItem = $(this);
  2595. brandItemList.push({
  2596. BrandItemID: selectedBrandItem.attr("xoptionValue"),
  2597. BrandItemName: selectedBrandItem.find("td.xoption_item_bg_center").text()
  2598. });
  2599. });
  2600. return {
  2601. BrandPayType: brandPayType,
  2602. Brand: brand,
  2603. BrandItemList: brandItemList
  2604. };
  2605. }
  2606. function _clearBrandSelections(jq) {
  2607. var brandPanel = $.data(jq, "cmsXBrandItemSelector").brandPanel;
  2608. var brandItemPanel = $.data(jq, "cmsXBrandItemSelector").brandItemPanel;
  2609. brandPanel.find("table.xTabOption_item_selected").removeClass("xTabOption_item_selected");
  2610. var btnSelectAll = brandPanel.find("table.xTabOption_item[xoptionValue='-1']");
  2611. btnSelectAll.addClass("xTabOption_item_selected");
  2612. brandItemPanel.find("table.xoption_item").remove();
  2613. brandItemPanel.hide();
  2614. }
  2615. function _clearBrandItemSelections(jq) {
  2616. var brandItemPanel = $.data(jq, "cmsXBrandItemSelector").brandItemPanel;
  2617. //brandItemPanel.find("table.xoption_item").remove();
  2618. brandItemPanel.find("table.xoption_item_selected").removeClass("xoption_item_selected");
  2619. //brandItemPanel.hide();
  2620. }
  2621. $.fn.cmsXBrandItemSelector.methods = {
  2622. options: function (jq) {
  2623. var opts = $.data(jq[0], "cmsXBrandItemSelector").options;
  2624. return opts;
  2625. },
  2626. getValue: function (jq) {
  2627. return _getValue(jq[0]);
  2628. },
  2629. clearBrandSelections: function (jq) {
  2630. jq.each(function () {
  2631. _clearBrandSelections(this);
  2632. });
  2633. },
  2634. clearBrandItemSelections: function (jq) {
  2635. jq.each(function () {
  2636. _clearBrandItemSelections(this);
  2637. });
  2638. }
  2639. };
  2640. $.fn.cmsXBrandItemSelector.parseOptions = function (_7c7) {
  2641. var t = $(_7c7);
  2642. return $.extend({}, $.fn.cmsXBrandItemSelector.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"]));
  2643. };
  2644. $.fn.cmsXBrandItemSelector.defaults = {
  2645. selectChanged: function () {
  2646. var val = $(this).cmsXBrandItemSelector("getValue");
  2647. //alert(val.Brand.BrandName);
  2648. //if (val.BrandItemList.length > 0) {
  2649. // var ss = [];
  2650. // $.each(val.BrandItemList, function () {
  2651. // ss.push(this.BrandItemName);
  2652. // });
  2653. // alert(ss.join(","));
  2654. //}
  2655. },
  2656. brandList: []
  2657. };
  2658. })(jQuery);
  2659. //2014-02-21 end added by pengbb 新增平铺品牌选择控件
  2660. //2014-02-24 begin added by pengbb 新增平铺选择控件 cmsXTileSelector
  2661. (function ($) {
  2662. $.parser.plugins.push("cmsXTileSelector");
  2663. function _init(jq) {
  2664. var opts = $.data(jq, "cmsXTileSelector").options;
  2665. var _jqThis = $(jq);
  2666. //var btnSelectAll = _jqThis.find(".col2 .selectall .xoption a");
  2667. var tileItemPanel = _jqThis.find(".tileItemPanel,.tileItemPanel_more");
  2668. if (tileItemPanel.find(".tileItemPanel_tools").length > 0) {
  2669. var tileItemPanelMore = _jqThis.find(".tileItemPanel_more");
  2670. var btnShowMore = tileItemPanel.find(".tileItemPanel_tools table.xbutton");
  2671. btnShowMore.unbind(".cmsXTileSelector");
  2672. btnShowMore.bind("click.cmsXTileSelector", function () {
  2673. var btn = $(this);
  2674. if (btn.hasClass("tileItemPanel_more_hide")) {
  2675. btn.find("td.xbutton_bg_center").text("更多");
  2676. btn.removeClass("tileItemPanel_more_hide");
  2677. tileItemPanelMore.hide();
  2678. } else {
  2679. btn.addClass("tileItemPanel_more_hide");
  2680. tileItemPanelMore.show();
  2681. btn.find("td.xbutton_bg_center").text("收起");
  2682. }
  2683. });
  2684. }
  2685. //选项
  2686. var optionItemList = tileItemPanel.find(".xoption table.xoption_item");
  2687. var btnAllOptionItem = tileItemPanel.find(".xoption table.xoption_item[xoptionValue='-1']");
  2688. optionItemList.unbind(".cmsXTileSelector");
  2689. optionItemList.bind("mouseenter.cmsXTileSelector",
  2690. function () {
  2691. var _this = $(this);
  2692. _this.addClass("xoption_item_hover");
  2693. }
  2694. );
  2695. optionItemList.bind("mouseleave.cmsXTileSelector",
  2696. function () {
  2697. var _this = $(this);
  2698. _this.removeClass("xoption_item_hover");
  2699. }
  2700. );
  2701. optionItemList.bind('click.cmsXTileSelector', function () {
  2702. var _this = $(this);
  2703. var _thisValue = _this.attr("xoptionvalue");
  2704. var isBtnAll = _thisValue == "-1";
  2705. var isSelected = _this.hasClass("xoption_item_selected");
  2706. if (opts.multiple) {
  2707. if (isSelected && isBtnAll) return;
  2708. if (_this.hasClass("xoption_item_selected")) {
  2709. _this.removeClass("xoption_item_selected");
  2710. _this.find("td.xoption_item_bg_right>i").remove();
  2711. } else {
  2712. _this.addClass("xoption_item_selected");
  2713. $('<i class="xoption_item_icon_selected" >&nbsp;</i>').appendTo(_this.find("td.xoption_item_bg_right"));
  2714. }
  2715. if (!isBtnAll) {
  2716. if (tileItemPanel.find(".xoption table.xoption_item_selected").length > 0) {
  2717. btnAllOptionItem.removeClass("xoption_item_selected");
  2718. btnAllOptionItem.find("td.xoption_item_bg_right>i").remove();
  2719. } else {
  2720. btnAllOptionItem.addClass("xoption_item_selected");
  2721. $('<i class="xoption_item_icon_selected" >&nbsp;</i>').appendTo(btnAllOptionItem.find("td.xoption_item_bg_right"));
  2722. }
  2723. } else {
  2724. var btnOtherOptionItemList = tileItemPanel.find(".xoption table.xoption_item[xoptionValue!='-1']");
  2725. btnOtherOptionItemList.removeClass("xoption_item_selected");
  2726. btnOtherOptionItemList.find("td.xoption_item_bg_right>i").remove();
  2727. }
  2728. } else {
  2729. if (_this.hasClass("xoption_item_selected")) {
  2730. return;
  2731. } else {
  2732. optionItemList.removeClass("xoption_item_selected");
  2733. optionItemList.find("td.xoption_item_bg_right>i").remove();
  2734. _this.addClass("xoption_item_selected");
  2735. $('<i class="xoption_item_icon_selected" >&nbsp;</i>').appendTo(_this.find("td.xoption_item_bg_right"));
  2736. }
  2737. }
  2738. opts.selectChanged.call(jq);
  2739. });
  2740. return { cmsXTileSelector: jq, tileItemPanel: tileItemPanel };
  2741. }
  2742. $.fn.cmsXTileSelector = function (_7be, _7bf) {
  2743. if (typeof _7be == "string") {
  2744. var _7c0 = $.fn.cmsXTileSelector.methods[_7be];
  2745. if (_7c0) {
  2746. return _7c0(this, _7bf);
  2747. } else {
  2748. return this.cmsXTileSelector(_7be, _7bf);
  2749. }
  2750. }
  2751. _7be = _7be || {};
  2752. return this.each(function () {
  2753. var _this = this;
  2754. var cacheData = $.data(_this, "cmsXTileSelector");
  2755. if (cacheData) {
  2756. $.extend(cacheData.options, _7be);
  2757. } else {
  2758. cacheData = $.data(_this, "cmsXTileSelector", { options: $.extend({}, $.fn.cmsXTileSelector.defaults, $.fn.cmsXTileSelector.parseOptions(this), _7be) });
  2759. var initCacheData = _init(_this);
  2760. cacheData = $.data(_this, "cmsXTileSelector", $.extend({}, cacheData, initCacheData));
  2761. }
  2762. });
  2763. };
  2764. function _getValue(jq) {
  2765. var opts = $.data(jq, "cmsXTileSelector").options;
  2766. var tileItemPanel = $.data(jq, "cmsXTileSelector").tileItemPanel;
  2767. var selectedValueList = [];
  2768. tileItemPanel.find("li.xoption table.xoption_item_selected").each(function () {
  2769. var selectedItem = $(this);
  2770. var selectedValue = new Object();
  2771. selectedValue[opts.valueField] = selectedItem.attr("xoptionValue");
  2772. selectedValue[opts.textField] = selectedItem.find("td.xoption_item_bg_center").text();
  2773. selectedValueList.push(selectedValue);
  2774. });
  2775. return selectedValueList;
  2776. }
  2777. function _clearSelections(jq) {
  2778. var tileItemPanel = $.data(jq, "cmsXTileSelector").tileItemPanel;
  2779. tileItemPanel.find("li.xoption table.xoption_item_selected td.xoption_item_bg_right i").remove();
  2780. tileItemPanel.find("li.xoption table.xoption_item_selected").removeClass("xoption_item_selected");
  2781. var btnAllOptionItem = tileItemPanel.find("li.xoption table.xoption_item[xoptionValue='-1']");
  2782. btnAllOptionItem.addClass("xoption_item_selected");
  2783. $('<i class="xoption_item_icon_selected" >&nbsp;</i>').appendTo(btnAllOptionItem.find("td.xoption_item_bg_right"));
  2784. }
  2785. $.fn.cmsXTileSelector.methods = {
  2786. options: function (jq) {
  2787. var opts = $.data(jq[0], "cmsXTileSelector").options;
  2788. return opts;
  2789. },
  2790. getValue: function (jq) {
  2791. return _getValue(jq[0]);
  2792. },
  2793. clearSelections: function (jq) {
  2794. jq.each(function () {
  2795. _clearSelections(this);
  2796. });
  2797. }
  2798. };
  2799. $.fn.cmsXTileSelector.parseOptions = function (_7c7) {
  2800. var t = $(_7c7);
  2801. return $.extend({}, $.fn.cmsXTileSelector.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"]));
  2802. };
  2803. $.fn.cmsXTileSelector.defaults = {
  2804. valueField: "Value",
  2805. textField: "Text",
  2806. selectChanged: function () {
  2807. },
  2808. multiple: true
  2809. };
  2810. })(jQuery);
  2811. //2014-02-24 end added by pengbb 新增平铺品牌选择控件
  2812. //2014-02-24 begin added by pengbb 新增平铺号码规则选择控件 cmsXTelnumberRuleSelector
  2813. (function ($) {
  2814. $.parser.plugins.push("cmsXTelnumberRuleSelector");
  2815. function _init(jq) {
  2816. var opts = $.data(jq, "cmsXTelnumberRuleSelector").options;
  2817. var _jqThis = $(jq);
  2818. var telnumberRuleTypePanel = _jqThis.find(".telnumberRuleTypePanel");
  2819. var telnumberRulePanel = _jqThis.find(".telnumberRulePanel");
  2820. //规则分类
  2821. var telNumberRuleTypeOptionItemList = telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item");
  2822. telNumberRuleTypeOptionItemList.die(".cmsXTelnumberRuleSelector");
  2823. telNumberRuleTypeOptionItemList.live("mouseenter.cmsXTelnumberRuleSelector",
  2824. function () {
  2825. var _this = $(this);
  2826. _this.addClass("xoption_item_hover");
  2827. }
  2828. );
  2829. telNumberRuleTypeOptionItemList.live("mouseleave.cmsXTelnumberRuleSelector",
  2830. function () {
  2831. var _this = $(this);
  2832. _this.removeClass("xoption_item_hover");
  2833. }
  2834. );
  2835. telNumberRuleTypeOptionItemList.live("click.cmsXTelnumberRuleSelector", function () {
  2836. var _this = $(this);
  2837. if (!_this.hasClass("xoption_item_selected")) {
  2838. var oldSelectedTelNumberRuleTypeOptionItemList = telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item_selected");
  2839. oldSelectedTelNumberRuleTypeOptionItemList.removeClass("xoption_item_selected");
  2840. oldSelectedTelNumberRuleTypeOptionItemList.find("td.xoption_item_bg_right>i").remove();
  2841. _this.addClass("xoption_item_selected");
  2842. $('<i class="xoption_item_icon_selected" >&nbsp;</i>').appendTo(_this.find("td.xoption_item_bg_right"));
  2843. telnumberRuleTypePanel.trigger("selectChanged");
  2844. }
  2845. });
  2846. telnumberRuleTypePanel.unbind(".cmsXTelnumberRuleSelector");
  2847. telnumberRuleTypePanel.bind("selectChanged.cmsXTelnumberRuleSelector", function () {
  2848. telnumberRulePanel.find(".xoption").remove();
  2849. var selectedTelNumberRuleTypeID = telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item_selected:first").attr("xoptionValue");
  2850. if (selectedTelNumberRuleTypeID == -1) {
  2851. telnumberRulePanel.hide();
  2852. //$.each(opts.telNumberRuleList, function () {
  2853. // $.each(this.TelNumberRuleList, function () {
  2854. // var newTelNumberRuleLi = $('<LI class="xoption"><A hideFocus href="javascript:void(0);" ><SPAN class="xoption_val"></SPAN></A></LI>').appendTo(telnumberRulePanel);
  2855. // newTelNumberRuleLi.find("a>span").attr("xoptionValue", this.TelNumberRuleID);
  2856. // newTelNumberRuleLi.find("a>span").text(this.TelNumberRuleName);
  2857. // });
  2858. //});
  2859. } else {
  2860. telnumberRulePanel.show();
  2861. $.each(opts.telNumberRuleList, function () {
  2862. if (this.TelNumberRuleTypeID == selectedTelNumberRuleTypeID) {
  2863. $.each(this.TelNumberRuleList, function () {
  2864. var newTelNumberRuleLi = $('<LI class="xoption"><table class="xoption_item" cellpadding="0" cellspacing="0" border="0"><tr><td class="xoption_item_bg_left">&nbsp;</td><td class="xoption_item_bg_center">&nbsp;</td><td class="xoption_item_bg_right">&nbsp;</td></tr></table></LI>').appendTo(telnumberRulePanel);
  2865. newTelNumberRuleLi.find("table").attr("xoptionValue", this.TelNumberRuleID);
  2866. newTelNumberRuleLi.find("table td.xoption_item_bg_center").text(this.TelNumberRuleName);
  2867. });
  2868. }
  2869. });
  2870. }
  2871. opts.selectChanged.call(jq);
  2872. });
  2873. //规则
  2874. var telnumberRuleOptionItemList = telnumberRulePanel.find(".xoption table.xoption_item");
  2875. telnumberRuleOptionItemList.die(".cmsXTelnumberRuleSelector");
  2876. telnumberRuleOptionItemList.live("mouseenter.cmsXTelnumberRuleSelector",
  2877. function () {
  2878. var _this = $(this);
  2879. _this.addClass("xoption_item_hover");
  2880. }
  2881. );
  2882. telnumberRuleOptionItemList.live("mouseleave.cmsXTelnumberRuleSelector",
  2883. function () {
  2884. var _this = $(this);
  2885. _this.removeClass("xoption_item_hover");
  2886. }
  2887. );
  2888. telnumberRuleOptionItemList.live('click.cmsXTelnumberRuleSelector', function () {
  2889. var _this = $(this);
  2890. if (_this.hasClass("xoption_item_selected")) {
  2891. _this.removeClass("xoption_item_selected");
  2892. _this.find("td.xoption_item_bg_right>i").remove();
  2893. } else {
  2894. _this.addClass("xoption_item_selected");
  2895. $('<i class="xoption_item_icon_selected" >&nbsp;</i>').appendTo(_this.find("td.xoption_item_bg_right"));
  2896. }
  2897. telnumberRulePanel.trigger("selectChanged");
  2898. });
  2899. telnumberRulePanel.unbind(".cmsXTelnumberRuleSelector");
  2900. telnumberRulePanel.bind("selectChanged.cmsXTelnumberRuleSelector", function () {
  2901. opts.selectChanged.call(jq);
  2902. });
  2903. telnumberRulePanel.find(".telnumberRulePanelTool table.xbutton").die(".cmsXTelnumberRuleSelector");
  2904. telnumberRulePanel.find(".telnumberRulePanelTool table.xbutton").live("click.cmsXTelnumberRuleSelector", function () {
  2905. telnumberRulePanel.find(".xoption table.xoption_item").each(function () {
  2906. var _this = $(this);
  2907. if (!_this.hasClass("xoption_item_selected")) {
  2908. _this.addClass("xoption_item_selected");
  2909. $('<i class="xoption_item_icon_selected" >&nbsp;</i>').appendTo(_this.find("td.xoption_item_bg_right"));
  2910. }
  2911. });
  2912. telnumberRulePanel.trigger("selectChanged");
  2913. });
  2914. return { cmsXTelnumberRuleSelector: jq, telnumberRuleTypePanel: telnumberRuleTypePanel, telnumberRulePanel: telnumberRulePanel };
  2915. }
  2916. $.fn.cmsXTelnumberRuleSelector = function (_7be, _7bf) {
  2917. if (typeof _7be == "string") {
  2918. var _7c0 = $.fn.cmsXTelnumberRuleSelector.methods[_7be];
  2919. if (_7c0) {
  2920. return _7c0(this, _7bf);
  2921. } else {
  2922. return this.cmsXTelnumberRuleSelector(_7be, _7bf);
  2923. }
  2924. }
  2925. _7be = _7be || {};
  2926. return this.each(function () {
  2927. var _this = this;
  2928. var cacheData = $.data(_this, "cmsXTelnumberRuleSelector");
  2929. if (cacheData) {
  2930. $.extend(cacheData.options, _7be);
  2931. } else {
  2932. cacheData = $.data(_this, "cmsXTelnumberRuleSelector", { options: $.extend({}, $.fn.cmsXTelnumberRuleSelector.defaults, $.fn.cmsXTelnumberRuleSelector.parseOptions(this), _7be) });
  2933. var initCacheData = _init(_this);
  2934. cacheData = $.data(_this, "cmsXTelnumberRuleSelector", $.extend({}, cacheData, initCacheData));
  2935. }
  2936. });
  2937. };
  2938. function _getValue(jq) {
  2939. var opts = $.data(jq, "cmsXTelnumberRuleSelector").options;
  2940. var telnumberRuleTypePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRuleTypePanel;
  2941. var telnumberRulePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRulePanel;
  2942. var selectedValueList = [];
  2943. var selectedTelNumberRuleType = {};
  2944. telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item_selected:first").each(function () {
  2945. selectedTelNumberRuleType["TelNumberRuleTypeID"] = $(this).attr("xoptionValue");
  2946. selectedTelNumberRuleType["TelNumberRuleTypeName"] = $(this).find("td.xoption_item_bg_center").text();
  2947. });
  2948. telnumberRulePanel.find("table.xoption_item_selected").each(function () {
  2949. var _this = $(this);
  2950. selectedValueList.push({
  2951. TelNumberRuleName: _this.find("td.xoption_item_bg_center").text(),
  2952. TelNumberRuleID: _this.attr("xoptionValue")
  2953. });
  2954. });
  2955. return { TelNumberRuleType: selectedTelNumberRuleType, TelNumberRuleList: selectedValueList };
  2956. }
  2957. function _clearSelections(jq) {
  2958. var telnumberRuleTypePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRuleTypePanel;
  2959. var telnumberRulePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRulePanel;
  2960. var selectedTelnumberRuleTypeOptionItemList = telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item_selected");
  2961. selectedTelnumberRuleTypeOptionItemList.removeClass("xoption_item_selected");
  2962. selectedTelnumberRuleTypeOptionItemList.find("td.xoption_item_bg_right>i").remove();
  2963. var telnumberRuleTypePanelSelectAll = telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item[xoptionValue='-1']");
  2964. telnumberRuleTypePanelSelectAll.addClass("xoption_item_selected");
  2965. $('<i class="xoption_item_icon_selected" >&nbsp;</i>').appendTo(telnumberRuleTypePanelSelectAll.find("td.xoption_item_bg_right"));
  2966. telnumberRulePanel.find("li.xoption table.xoption_item_selected td.xoption_item_bg_right i").remove();
  2967. telnumberRulePanel.find("li.xoption table.xoption_item_selected").removeClass("xoption_item_selected");
  2968. telnumberRulePanel.hide();
  2969. }
  2970. function _load(jq, param) {
  2971. var opts = $.data(jq, "cmsXTelnumberRuleSelector").options;
  2972. param = $.extend({}, { url: '', postData: {} }, param);
  2973. if (param.url) {
  2974. $.ajax({
  2975. type: "post", url: param.url, data: param.postData, dataType: "json", success: function (data) {
  2976. _loadData(jq, data);
  2977. }, error: function () {
  2978. if (typeof (opts.onLoadError) == "function") {
  2979. opts.onLoadError.call(jq);
  2980. }
  2981. }
  2982. });
  2983. }
  2984. }
  2985. function _loadData(jq, data) {
  2986. var opts = $.data(jq, "cmsXTelnumberRuleSelector").options;
  2987. var telnumberRuleTypePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRuleTypePanel;
  2988. var telnumberRulePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRulePanel;
  2989. opts.telNumberRuleList = data || [];
  2990. telnumberRuleTypePanel.find("li.telnumberRuleTypeItem").remove();
  2991. telnumberRulePanel.find("li.xoption").remove();
  2992. telnumberRulePanel.hide();
  2993. $('<li class="telnumberRuleTypeItem"><table class="xoption_item xoption_item_selected" xoptionValue="-1" cellpadding="0" cellspacing="0"border="0"><tr><td class="xoption_item_bg_left">&nbsp;</td><td class="xoption_item_bg_center">全部</td><td class="xoption_item_bg_right">&nbsp; <i class="xoption_item_icon_selected">&nbsp;</i></td></tr></table></li>').appendTo(telnumberRuleTypePanel);
  2994. $.each(opts.telNumberRuleList, function () {
  2995. var newTelNumberRuleTypeLi = $('<LI class="telnumberRuleTypeItem"><table class="xoption_item" cellpadding="0" cellspacing="0" border="0"><tr><td class="xoption_item_bg_left">&nbsp;</td><td class="xoption_item_bg_center">&nbsp;</td><td class="xoption_item_bg_right">&nbsp;</td></tr></table></LI>').appendTo(telnumberRuleTypePanel);
  2996. newTelNumberRuleTypeLi.find("table").attr("xoptionValue", this.TelNumberRuleTypeID);
  2997. newTelNumberRuleTypeLi.find("table td.xoption_item_bg_center").text(this.TelNumberRuleTypeName);
  2998. //$.each(this.TelNumberRuleList,function() {
  2999. // var newTelNumberRuleLi = $('<LI class="xoption"><A hideFocus href="javascript:void(0);" ><SPAN class="xoption_val"></SPAN></A></LI>').appendTo(telnumberRulePanel);
  3000. // newTelNumberRuleLi.find("a>span").attr("xoptionValue", this.TelNumberRuleID);
  3001. // newTelNumberRuleLi.find("a>span").text(this.TelNumberRuleName);
  3002. //});
  3003. });
  3004. if (typeof (opts.onLoadSuccess) == "function") {
  3005. opts.onLoadSuccess.call(jq);
  3006. }
  3007. }
  3008. $.fn.cmsXTelnumberRuleSelector.methods = {
  3009. options: function (jq) {
  3010. var opts = $.data(jq[0], "cmsXTelnumberRuleSelector").options;
  3011. return opts;
  3012. },
  3013. getTelNumberRuleList: function (jq) {
  3014. var opts = $.data(jq[0], "cmsXTelnumberRuleSelector").options;
  3015. return opts.telNumberRuleList;
  3016. },
  3017. getValue: function (jq) {
  3018. return _getValue(jq[0]);
  3019. },
  3020. clearSelections: function (jq) {
  3021. jq.each(function () {
  3022. _clearSelections(this);
  3023. });
  3024. },
  3025. //param:{url:'',postData:{}}
  3026. load: function (jq, param) {
  3027. jq.each(function () {
  3028. _load(this, param);
  3029. });
  3030. }
  3031. };
  3032. $.fn.cmsXTelnumberRuleSelector.parseOptions = function (_7c7) {
  3033. var t = $(_7c7);
  3034. return $.extend({}, $.fn.cmsXTelnumberRuleSelector.defaults, $.parser.parseOptions(_7c7, []));
  3035. };
  3036. $.fn.cmsXTelnumberRuleSelector.defaults = {
  3037. selectChanged: function () {
  3038. //alert(JSON.stringify($(this).cmsXTelnumberRuleSelector("getValue")));
  3039. //alert(0);
  3040. },
  3041. multiple: true,
  3042. telNumberRuleList: [],
  3043. onLoadSuccess: function (data) {
  3044. },
  3045. onLoadError: function () {
  3046. }
  3047. };
  3048. })(jQuery);
  3049. //2014-02-24 end added by pengbb 新增平铺号码规则选择控件
  3050. //2014-02-25 begin added by pengbb 新增号码精确查询输入控件 cmsXExactTelNumberInput
  3051. (function ($) {
  3052. $.parser.plugins.push("cmsXExactTelNumberInput");
  3053. function _init(jq) {
  3054. var opts = $.data(jq, "cmsXExactTelNumberInput").options;
  3055. var _jqThis = $(jq);
  3056. var numberInputList = _jqThis.find("li.numbercolumn span.numberinput>input");
  3057. var btnOK = _jqThis.find("li.toolcolumn .xbutton");
  3058. numberInputList.unbind(".cmsXExactTelNumberInput");
  3059. numberInputList.bind("keydown.cmsXExactTelNumberInput", function (event) {
  3060. //48-57,96-105,退格:8,左:37,右:39
  3061. var keyCode = event.keyCode;
  3062. if (!((48 <= keyCode && keyCode <= 57) || (96 <= keyCode && keyCode <= 105) || keyCode == 8)) {
  3063. return false;
  3064. }
  3065. this.value = "";
  3066. });
  3067. numberInputList.bind("keyup.cmsXExactTelNumberInput", function (event) {
  3068. var keyCode = event.keyCode;
  3069. if (keyCode == 37) {
  3070. $(this).closest("li").prev("li").find("span.numberinput>input").focus();
  3071. } else if (keyCode == 39) {
  3072. $(this).closest("li").next("li").find("span.numberinput>input").focus();
  3073. } else {
  3074. if (this.value != "") {
  3075. $(this).closest("li").next("li").find("span.numberinput>input").focus();
  3076. } else {
  3077. if (keyCode == 8) {
  3078. $(this).closest("li").prev("li").find("span.numberinput>input").focus().val("");
  3079. }
  3080. }
  3081. }
  3082. });
  3083. btnOK.unbind(".cmsXExactTelNumberInput");
  3084. btnOK.bind("click.cmsXExactTelNumberInput", function () {
  3085. opts.inputCompleted.call(jq, _getValue(jq));
  3086. });
  3087. return { cmsXExactTelNumberInput: jq, numberInputList: numberInputList, btnOK: btnOK };
  3088. }
  3089. $.fn.cmsXExactTelNumberInput = function (_7be, _7bf) {
  3090. if (typeof _7be == "string") {
  3091. var _7c0 = $.fn.cmsXExactTelNumberInput.methods[_7be];
  3092. if (_7c0) {
  3093. return _7c0(this, _7bf);
  3094. } else {
  3095. return this.cmsXExactTelNumberInput(_7be, _7bf);
  3096. }
  3097. }
  3098. _7be = _7be || {};
  3099. return this.each(function () {
  3100. var _this = this;
  3101. var cacheData = $.data(_this, "cmsXExactTelNumberInput");
  3102. if (cacheData) {
  3103. $.extend(cacheData.options, _7be);
  3104. } else {
  3105. cacheData = $.data(_this, "cmsXExactTelNumberInput", { options: $.extend({}, $.fn.cmsXExactTelNumberInput.defaults, $.fn.cmsXExactTelNumberInput.parseOptions(this), _7be) });
  3106. var initCacheData = _init(_this);
  3107. cacheData = $.data(_this, "cmsXExactTelNumberInput", $.extend({}, cacheData, initCacheData));
  3108. }
  3109. });
  3110. };
  3111. function _getValue(jq) {
  3112. var opts = $.data(jq, "cmsXExactTelNumberInput").options;
  3113. var numberInputList = $.data(jq, "cmsXExactTelNumberInput").numberInputList;
  3114. var valueList = [];
  3115. numberInputList.each(function () {
  3116. if (this.value == "") {
  3117. valueList.push("_");
  3118. } else {
  3119. valueList.push(this.value);
  3120. }
  3121. });
  3122. return valueList.join("");
  3123. }
  3124. function _reset(jq) {
  3125. var numberInputList = $.data(jq, "cmsXExactTelNumberInput").numberInputList;
  3126. numberInputList.each(function () {
  3127. this.value = "";
  3128. });
  3129. };
  3130. $.fn.cmsXExactTelNumberInput.methods = {
  3131. options: function (jq) {
  3132. var opts = $.data(jq[0], "cmsXExactTelNumberInput").options;
  3133. return opts;
  3134. },
  3135. getValue: function (jq) {
  3136. return _getValue(jq[0]);
  3137. },
  3138. reset: function (jq) {
  3139. jq.each(function () {
  3140. _reset(this);
  3141. });
  3142. }
  3143. };
  3144. $.fn.cmsXExactTelNumberInput.parseOptions = function (_7c7) {
  3145. var t = $(_7c7);
  3146. return $.extend({}, $.fn.cmsXExactTelNumberInput.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"]));
  3147. };
  3148. $.fn.cmsXExactTelNumberInput.defaults = {
  3149. inputCompleted: function (val) {
  3150. //alert("value:" + $(this).cmsXExactTelNumberInput("getValue"));
  3151. }
  3152. };
  3153. })(jQuery);
  3154. //2014-02-25 end added by pengbb 新增号码精确查询输入控件
  3155. //2014-02-25 begin added by pengbb 新增已选条件控件 cmsXSelectedCondition
  3156. (function ($) {
  3157. $.parser.plugins.push("cmsXSelectedCondition");
  3158. function _init(jq) {
  3159. var opts = $.data(jq, "cmsXSelectedCondition").options;
  3160. var _jqThis = $(jq);
  3161. var selectedConditionPanel = _jqThis.find(".selectedConditionPanel");
  3162. var conditionTool = selectedConditionPanel.find("li.conditionTool");
  3163. var conditionItemPanel = selectedConditionPanel;
  3164. var btnReset = conditionTool.find("table.xbutton_reset");
  3165. var btnQuery = conditionTool.find("table.xbutton_query");
  3166. btnReset.unbind(".cmsXSelectedCondition");
  3167. btnReset.bind("click.cmsXSelectedCondition", function () {
  3168. conditionItemPanel.find(">li.conditionItem").remove();
  3169. conditionItemPanel.trigger("onItemChanged");
  3170. opts.onReset.call(jq);
  3171. });
  3172. btnQuery.unbind(".cmsXSelectedCondition");
  3173. btnQuery.bind("click.cmsXSelectedCondition", function () {
  3174. var formDataJson = _getConditionJson(jq);
  3175. opts.onQuery.call(jq, formDataJson);
  3176. });
  3177. conditionItemPanel.find(">li.conditionItem i").die(".cmsXSelectedCondition");
  3178. conditionItemPanel.find(">li.conditionItem i").live("click.cmsXSelectedCondition", function () {
  3179. var li = $(this).closest("li");
  3180. li.remove();
  3181. var d = new Object();
  3182. d.name = li.attr("conditionName");
  3183. d.value = li.attr("conditionValue");
  3184. opts.onConditionRemoved.call(jq, d);
  3185. conditionItemPanel.trigger("onItemChanged");
  3186. });
  3187. conditionItemPanel.unbind("onItemChanged.cmsXSelectedCondition");
  3188. conditionItemPanel.bind("onItemChanged.cmsXSelectedCondition", function () {
  3189. var formDataJson = _getConditionJson(jq);
  3190. opts.onConditionChanged.call(jq, formDataJson);
  3191. });
  3192. //$('<LI class="conditionItem"><span class="conditionText">百万号段:全部 <i class="deleteButton">&nbsp;</i></span></LI>').appendTo(conditionItemPanel);
  3193. return { cmsXSelectedCondition: jq, selectedConditionPanel: selectedConditionPanel, conditionItemPanel: conditionItemPanel, conditionTool: conditionTool, btnQuery: btnQuery, btnReset: btnReset };
  3194. }
  3195. $.fn.cmsXSelectedCondition = function (_7be, _7bf) {
  3196. if (typeof _7be == "string") {
  3197. var _7c0 = $.fn.cmsXSelectedCondition.methods[_7be];
  3198. if (_7c0) {
  3199. return _7c0(this, _7bf);
  3200. } else {
  3201. return this.cmsXSelectedCondition(_7be, _7bf);
  3202. }
  3203. }
  3204. _7be = _7be || {};
  3205. return this.each(function () {
  3206. var _this = this;
  3207. var cacheData = $.data(_this, "cmsXSelectedCondition");
  3208. if (cacheData) {
  3209. $.extend(cacheData.options, _7be);
  3210. } else {
  3211. cacheData = $.data(_this, "cmsXSelectedCondition", { options: $.extend({}, $.fn.cmsXSelectedCondition.defaults, $.fn.cmsXSelectedCondition.parseOptions(this), _7be) });
  3212. var initCacheData = _init(_this);
  3213. cacheData = $.data(_this, "cmsXSelectedCondition", $.extend({}, cacheData, initCacheData));
  3214. }
  3215. });
  3216. };
  3217. function _getConditionJson(jq) {
  3218. var opts = $.data(jq, "cmsXSelectedCondition").options;
  3219. var conditionItemPanel = $.data(jq, "cmsXSelectedCondition").conditionItemPanel;
  3220. var formDataJson = new Object();
  3221. conditionItemPanel.find("li.conditionItem").each(function () {
  3222. var jqItem = $(this);
  3223. var d = new Object();
  3224. d.name = jqItem.attr("conditionName");
  3225. d.value = jqItem.attr("conditionValue");
  3226. if (d.name) {
  3227. if (formDataJson[d.name]) {
  3228. formDataJson[d.name] += "," + d.value;
  3229. } else {
  3230. formDataJson[d.name] = d.value;
  3231. }
  3232. }
  3233. });
  3234. return formDataJson;
  3235. }
  3236. //condition:{name:'',value:'',text:''}
  3237. function _addCondition(jq, condition) {
  3238. var opts = $.data(jq, "cmsXSelectedCondition").options;
  3239. var conditionItemPanel = $.data(jq, "cmsXSelectedCondition").conditionItemPanel;
  3240. if (condition && condition.name && condition.text) {
  3241. var newConditionLi = conditionItemPanel.find("li.conditionItem[conditionName='" + condition.name + "']");
  3242. if (newConditionLi.length == 0) {
  3243. newConditionLi = $('<LI class="conditionItem"><span class="conditionText"><p></p><i class="deleteButton">&nbsp;</i></span></LI>').appendTo(conditionItemPanel);
  3244. }
  3245. newConditionLi.attr("conditionName", condition.name);
  3246. newConditionLi.attr("conditionValue", condition.value);
  3247. newConditionLi.find(">span>p").html(condition.text);
  3248. conditionItemPanel.trigger("onItemChanged");
  3249. }
  3250. }
  3251. function _removeCondition(jq, conditionName) {
  3252. var opts = $.data(jq, "cmsXSelectedCondition").options;
  3253. var conditionItemPanel = $.data(jq, "cmsXSelectedCondition").conditionItemPanel;
  3254. var a = conditionItemPanel.find("li.conditionItem[conditionName='" + conditionName + "']");
  3255. if (a.length > 0) {
  3256. a.remove();
  3257. conditionItemPanel.trigger("onItemChanged");
  3258. }
  3259. }
  3260. $.fn.cmsXSelectedCondition.methods = {
  3261. options: function (jq) {
  3262. var opts = $.data(jq[0], "cmsXSelectedCondition").options;
  3263. return opts;
  3264. },
  3265. getConditionJson: function (jq) {
  3266. return _getConditionJson(jq[0]);
  3267. },
  3268. //condition:{name:'',value:'',text:''}
  3269. addCondition: function (jq, condition) {
  3270. jq.each(function () {
  3271. _addCondition(this, condition);
  3272. });
  3273. },
  3274. removeCondition: function (jq, conditionName) {
  3275. jq.each(function () {
  3276. _removeCondition(this, conditionName);
  3277. });
  3278. }
  3279. };
  3280. $.fn.cmsXSelectedCondition.parseOptions = function (_7c7) {
  3281. var t = $(_7c7);
  3282. return $.extend({}, $.fn.cmsXSelectedCondition.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"]));
  3283. };
  3284. $.fn.cmsXSelectedCondition.defaults = {
  3285. onConditionChanged: function (formDataJson) {
  3286. //alert("onConditionChanged:" + JSON.stringify(formDataJson));
  3287. },
  3288. onQuery: function (formDataJson) {
  3289. //alert("onQuery:" + JSON.stringify(formDataJson));
  3290. },
  3291. onConditionRemoved: function (removedCondition) {
  3292. },
  3293. onReset: function () {
  3294. }
  3295. };
  3296. })(jQuery);
  3297. //2014-02-25 end added by pengbb 新增已选条件控件
  3298. //2014-02-28 begin added by pengbb 新增cmsXDataTable
  3299. (function ($) {
  3300. $.parser.plugins.push("cmsXDataTable");
  3301. function _init(jq) {
  3302. var opts = $.data(jq, "cmsXDataTable").options;
  3303. var _jqThis = $(jq);
  3304. var header = _jqThis.find(">div.xDataTable_bodyPanel .xDataTableHeader");
  3305. var table = _jqThis.find(">div.xDataTable_bodyPanel .xDataTable");
  3306. var parentCtrl = _jqThis.parent();
  3307. var totalWidth = 0;
  3308. var columnList = new Array();
  3309. var contentContainer = table.parent();
  3310. // var container = _jqThis.find(".xDataTable_container");
  3311. // container.scroll(function () {
  3312. // table.find("tr.header").css("top", container.scrollTop());
  3313. // });
  3314. //初始化列属性
  3315. var columnIndex = 0;
  3316. header.find("tr.header>th").each(function () {
  3317. var jqThColumn = $(this);
  3318. var newColumn = $.extend({}, $.fn.cmsXDataTable.column.defaults, $.parser.parseOptions(jqThColumn, []));
  3319. // newColumn.columnType = $(this).attr("columnType");
  3320. // if(newColumn.columnType)
  3321. // newColumn.columnType = newColumn.columnType.replace(/[\']*/g, "");
  3322. if (newColumn.validateOption) {
  3323. if (newColumn.validateOption.required == "true") {
  3324. newColumn.validateOption.required = true;
  3325. }
  3326. else {
  3327. newColumn.validateOption.required = false;
  3328. }
  3329. }
  3330. newColumn.columnIndex = (columnIndex++);
  3331. newColumn.element = this;
  3332. if (newColumn.columnType == "checkbox") {
  3333. jqThColumn.find("input[type='checkbox']").unbind(".cmsXDataTable");
  3334. jqThColumn.find("input[type='checkbox']").bind("click.cmsXDataTable", function () {
  3335. var isChecked = !!$(this).attr("checked");
  3336. var allRow = table.find("tr.row>td[columnIndex='" + newColumn.columnIndex + "'] input[type='checkbox']");
  3337. allRow.attr("checked", isChecked);
  3338. if (isChecked) {
  3339. allRow.closest("tr").addClass("row_selected");
  3340. } else {
  3341. allRow.closest("tr").removeClass("row_selected");
  3342. }
  3343. });
  3344. table.find("tr.row>td[columnIndex='" + newColumn.columnIndex + "'] input[type='checkbox']").die(".cmsXDataTable");
  3345. table.find("tr.row>td[columnIndex='" + newColumn.columnIndex + "'] input[type='checkbox']").live("click.cmsXDataTable", function () {
  3346. var isChecked = !!$(this).attr("checked");
  3347. if (isChecked) {
  3348. $(this).closest("tr").addClass("row_selected");
  3349. } else {
  3350. $(this).closest("tr").removeClass("row_selected");
  3351. }
  3352. });
  3353. newColumn.width = 24;
  3354. }
  3355. else {
  3356. if (newColumn.width) {
  3357. if (newColumn.width < 1) {
  3358. newColumn.width = parentCtrl.width() * newColumn.width;
  3359. }
  3360. } else if (header.find("tr.header>th").length > 0){
  3361. newColumn.width = parseInt(parentCtrl.width() / header.find("tr.header>th").length);
  3362. }
  3363. }
  3364. if (newColumn.hidden) {
  3365. jqThColumn[0].style.display = "none";
  3366. }
  3367. jqThColumn.attr('align', newColumn.align);
  3368. jqThColumn.css("width", newColumn.width + "px");
  3369. totalWidth += newColumn.width;
  3370. columnList.push(newColumn);
  3371. });
  3372. var comboGrid = header.parents('.easyui-combogridX:first');
  3373. if (comboGrid.length > 0) {
  3374. if ((totalWidth + 24) > 150) {
  3375. comboGrid.find('.combogridX-expander').width(totalWidth + 24);
  3376. } else {
  3377. comboGrid.find('.combogridX-expander').width(150);
  3378. }
  3379. }
  3380. _calMaxSize(jq);
  3381. var pagerPanel = _jqThis.find(".xDataTablePanel_pager");
  3382. if (opts.pagerType == 0 && opts.pagination) {
  3383. pagerPanel.find("input.xDataTablePanel_pager-page-list").unbind("cmsXDataTable");
  3384. pagerPanel.find("input.xDataTablePanel_pager-page-list").bind("blur.cmsXDataTable", function () {
  3385. opts.pageNumber = 1;
  3386. opts.pageSize = $(this).val();
  3387. _load(jq, opts.queryParams, false);
  3388. });
  3389. pagerPanel.find("input.xDataTablePanel_pager-page-list").bind("keydown.cmsXDataTable", function () {
  3390. var keyCode = event.keyCode;
  3391. if (!((48 <= keyCode && keyCode <= 57) || (96 <= keyCode && keyCode <= 105) || keyCode == 8 || keyCode == 13)) {
  3392. return false;
  3393. }
  3394. });
  3395. pagerPanel.find("input.xDataTablePanel_pager-page-list").bind("keyup.cmsXDataTable", function () {
  3396. var keyCode = event.keyCode;
  3397. if (!((48 <= keyCode && keyCode <= 57) || (96 <= keyCode && keyCode <= 105) || keyCode == 8 || keyCode == 13)) {
  3398. return false;
  3399. }
  3400. if ($(this).val() >= 500) $(this).val(500);
  3401. //enter
  3402. if (keyCode == 13) {
  3403. $(this).blur();
  3404. opts.pageNumber = 1;
  3405. opts.pageSize = $(this).val();
  3406. _load(jq, opts.queryParams, false);
  3407. }
  3408. });
  3409. pagerPanel.find("input.xDataTablePanel_pager-num").unbind("cmsXDataTable");
  3410. pagerPanel.find("input.xDataTablePanel_pager-num").bind("keydown.cmsXDataTable", function () {
  3411. var keyCode = event.keyCode;
  3412. if (!((48 <= keyCode && keyCode <= 57) || (96 <= keyCode && keyCode <= 105) || keyCode == 8 || keyCode == 13)) {
  3413. return false;
  3414. }
  3415. });
  3416. pagerPanel.find("input.xDataTablePanel_pager-num").bind("keyup.cmsXDataTable", function () {
  3417. var keyCode = event.keyCode;
  3418. if (!((48 <= keyCode && keyCode <= 57) || (96 <= keyCode && keyCode <= 105) || keyCode == 8 || keyCode == 13)) {
  3419. return false;
  3420. }
  3421. //enter
  3422. if (keyCode == 13) {
  3423. $(this).blur();
  3424. var newPageNumber = $.trim($(this).val());
  3425. if (newPageNumber != "") {
  3426. opts.pageNumber = parseInt(newPageNumber);
  3427. _load(jq, opts.queryParams, false);
  3428. }
  3429. }
  3430. });
  3431. var btnPagerFirst = pagerPanel.find("a.pager-first");
  3432. btnPagerFirst.unbind("cmsXDataTable");
  3433. btnPagerFirst.bind("click.cmsXDataTable", function () {
  3434. if ($(this).hasClass("l-btn-disabled")) {
  3435. return false;
  3436. }
  3437. opts.pageNumber = 1;
  3438. _load(jq, opts.queryParams, false);
  3439. });
  3440. var btnPagerPrev = pagerPanel.find("a.pager-prev");
  3441. btnPagerPrev.unbind("cmsXDataTable");
  3442. btnPagerPrev.bind("click.cmsXDataTable", function () {
  3443. if ($(this).hasClass("l-btn-disabled")) {
  3444. return false;
  3445. }
  3446. opts.pageNumber = opts.pageNumber - 1;
  3447. _load(jq, opts.queryParams, false);
  3448. });
  3449. var btnPagerNext = pagerPanel.find("a.pager-next");
  3450. btnPagerNext.unbind("cmsXDataTable");
  3451. btnPagerNext.bind("click.cmsXDataTable", function () {
  3452. if ($(this).hasClass("l-btn-disabled")) {
  3453. return false;
  3454. }
  3455. opts.pageNumber = opts.pageNumber + 1;
  3456. _load(jq, opts.queryParams, false);
  3457. });
  3458. var btnPagerLast = pagerPanel.find("a.pager-last");
  3459. btnPagerLast.unbind("cmsXDataTable");
  3460. btnPagerLast.bind("click.cmsXDataTable", function () {
  3461. if ($(this).hasClass("l-btn-disabled")) {
  3462. return false;
  3463. }
  3464. opts.pageNumber = opts.totalPage;
  3465. _load(jq, opts.queryParams, false);
  3466. });
  3467. } else {
  3468. var btnPagerNext = pagerPanel.find(".xDataTablePanel_pager_Simp");
  3469. btnPagerNext.unbind("cmsXDataTable");
  3470. btnPagerNext.bind("click.cmsXDataTable", function () {
  3471. if ($(this).hasClass("l-btn-disabled")) {
  3472. return false;
  3473. }
  3474. opts.pageNumber = opts.pageNumber + 1;
  3475. _load(jq, opts.queryParams, false);
  3476. });
  3477. }
  3478. contentContainer.scroll(function() {
  3479. var headerContainer = header.parent();
  3480. headerContainer.scrollLeft($(this).scrollLeft());
  3481. });
  3482. return { cmsXDataTable: jq, table: table, totalWidth: totalWidth, header: header, columnList: columnList, pagerPanel: pagerPanel, btnPagerFirst: btnPagerFirst, btnPagerPrev: btnPagerPrev, btnPagerNext: btnPagerNext, btnPagerLast: btnPagerLast };
  3483. }
  3484. var _loadAll = function (jq, formData) {
  3485. var table = $.data(jq, "cmsXDataTable").table;
  3486. var opts = $.data(jq, "cmsXDataTable").options;
  3487. table.find("tr.row").remove();
  3488. opts.data = { total: 0, rows: [] };
  3489. _load(jq, formData, true);
  3490. };
  3491. var _calMaxSize = function (jq) {
  3492. var opts = $.data(jq, "cmsXDataTable").options;
  3493. if (opts.pagerType == 0) {
  3494. var tablePanel = $(jq).find(".xDataTable").parent();
  3495. if (opts.maxHeight) {
  3496. tablePanel.css("maxHeight", opts.maxHeight + "px");
  3497. } else {
  3498. var documentHeight = $(document).height();
  3499. // var bodyHeigh = $("body").height();
  3500. // var bodyTop = $('body').offset().top;
  3501. // var tablePanelHeight = tablePanel.height();
  3502. var maxHeight = documentHeight - 4 - tablePanel.offset().top - $(jq).find(".xDataTablePanel_pager").height();
  3503. //教务系统的特殊情况start
  3504. if ($("#BatchModifydiv").length > 0) {
  3505. if ($("#BatchModifydiv").css("display") != "none") {
  3506. maxHeight += $("#BatchModifydiv").height();
  3507. }
  3508. }
  3509. //教务系统的特殊情况end
  3510. // if ((bodyHeigh - tablePanelHeight + maxHeight) > (documentHeight - bodyTop - 30))
  3511. // {
  3512. // maxHeight = maxHeight - ((bodyHeigh - tablePanelHeight + maxHeight) - (documentHeight - bodyTop - 30));
  3513. // }
  3514. tablePanel.css("maxHeight", maxHeight + "px");
  3515. }
  3516. }
  3517. };
  3518. var _load = function (jq, formData, isLoadAll, orderby, isAsc) {
  3519. var opts = $.data(jq, "cmsXDataTable").options;
  3520. var table = $.data(jq, "cmsXDataTable").table;
  3521. var parent = table.closest(".xDataTable_bodyPanel");
  3522. if (!table.css("height") || table.css("height") == "") {
  3523. parent.css("height", "100%;");
  3524. }
  3525. if (typeof (opts.onBeforeLoad) == "function" && opts.onBeforeLoad.call(jq, formData) == false) {
  3526. return;
  3527. }
  3528. //loading msg
  3529. if (opts.loadMsg) {
  3530. $("<div class=\"datagrid-mask\" style=\"display:block\"></div>").appendTo(jq).height($(jq).outerHeight());
  3531. var msg = $("<div class=\"datagrid-mask-msg\" style=\"display:block;left:50%\"></div>").html(opts.loadMsg).appendTo(jq);
  3532. msg.css("marginLeft", -msg.outerWidth() / 2);
  3533. }
  3534. opts.queryParams = formData || opts.queryParams;
  3535. if (opts.pagination) {
  3536. formData = $.extend({}, opts.queryParams, { page: opts.pageNumber - 1, rows: opts.pageSize });
  3537. if (orderby) {
  3538. formData = $.extend({}, formData, { OrderBy: orderby, IsAsc: isAsc });
  3539. }
  3540. } else if (orderby) {
  3541. formData = $.extend({}, opts.queryParams, { OrderBy: orderby, IsAsc: isAsc });
  3542. }
  3543. if (!orderby) {
  3544. _clearOrderByAsc(jq);
  3545. }
  3546. $.ajax({
  3547. type: "post", url: opts.url, data: formData, dataType: "json", success: function (data) {
  3548. data = $.extend({}, { total: 0, rows: [] }, data);
  3549. $(jq).find(".datagrid-mask,.datagrid-mask-msg").remove();
  3550. _loadData(jq, data, isLoadAll);
  3551. }, error: function (e) {
  3552. $(jq).find(".datagrid-mask,.datagrid-mask-msg").remove();
  3553. if (typeof (opts.onLoadError) == "function") {
  3554. opts.onLoadError.call(jq);
  3555. }
  3556. }
  3557. });
  3558. };
  3559. var _getHighlightProp = function (jq, rowIndex) {
  3560. var opts = $.data(jq, "cmsXDataTable").options;
  3561. var row = opts.data.rows[rowIndex];
  3562. var result = "";
  3563. if (opts.rowHighlightColor) {
  3564. if (opts.rowHighlightFun) {
  3565. if (opts.rowHighlightFun.call(this, rowIndex, row)) {
  3566. result = " style=\"background-color: " + opts.rowHighlightColor + "\"";
  3567. }
  3568. }
  3569. }
  3570. return result;
  3571. }
  3572. var _loadData = function (jq, data, isLoadAll) {
  3573. var opts = $.data(jq, "cmsXDataTable").options;
  3574. var header = $.data(jq, "cmsXDataTable").header;
  3575. var table = $.data(jq, "cmsXDataTable").table;
  3576. var totalWidth = $.data(jq, "cmsXDataTable").totalWidth;
  3577. var columnList = $.data(jq, "cmsXDataTable").columnList;
  3578. var pagerPanel = $.data(jq, "cmsXDataTable").pagerPanel;
  3579. var btnPagerFirst = $.data(jq, "cmsXDataTable").btnPagerFirst;
  3580. var btnPagerPrev = $.data(jq, "cmsXDataTable").btnPagerPrev;
  3581. var btnPagerNext = $.data(jq, "cmsXDataTable").btnPagerNext;
  3582. var btnPagerLast = $.data(jq, "cmsXDataTable").btnPagerLast;
  3583. var tableid = table.closest(".easyui-cmsXDataTable").attr("id");
  3584. var tableDataHidden = $("#" + tableid + "_datajson");
  3585. var treeColumn;
  3586. $.each(columnList, function () {
  3587. if (this.columnType == 'tree') {
  3588. treeColumn = this;
  3589. return false;
  3590. }
  3591. });
  3592. if (treeColumn) {
  3593. var tmpRows = new Array();
  3594. _orderDataForTree(data.rows, treeColumn.field, treeColumn.parentIDField, treeColumn.orderByField, tmpRows);
  3595. data.rows = tmpRows;
  3596. }
  3597. if (opts.pagerType == 0 || !opts.data || isLoadAll) {
  3598. //这两句的顺序可不能错,remove的时候原来会触发textbox的propertychange事件,
  3599. //因为暂时没办法阻止这个触发,只好让它触发够了再重新赋值……
  3600. table.find("tr.row").remove();
  3601. opts.data = data;
  3602. } else {
  3603. for (var i = 0; i < data.rows.length; i++) {
  3604. opts.data.rows.push(data.rows[i]);
  3605. }
  3606. }
  3607. if (opts.isPostBack)
  3608. tableDataHidden.val(JSON.stringify(opts.data));
  3609. var deep = 0;
  3610. $.each(data.rows, function (rowIndex) {
  3611. var rowData = this;
  3612. var tdHtmlList = [];
  3613. var realRowIndex = rowIndex;
  3614. if (opts.pagerType == 1 && opts.pagination) {
  3615. realRowIndex += (opts.pageNumber - 1) * opts.pageSize;
  3616. }
  3617. //add by heyw,增加扩展行开始
  3618. //正常行增加一列,并带有展开按钮
  3619. if (opts.hasSubRow == true) {
  3620. if (opts.expandOnLoad == true) {
  3621. tdHtmlList.push("".concat('<td style="width: 20px; line-height: 16px;"><div class="subrow-expander tree-expanded" style="cursor: pointer;" rowIndex="' + realRowIndex + '"></div></td>'));
  3622. }
  3623. else {
  3624. tdHtmlList.push("".concat('<td style="width: 20px; line-height: 16px;"><div class="subrow-expander tree-collapsed" style="cursor: pointer;" rowIndex="' + realRowIndex + '"></div></td>'));
  3625. }
  3626. }
  3627. //add by heyw,增加扩展行结束
  3628. $.each(columnList, function () {
  3629. var columnOpts = this;
  3630. var tdStyle = "width:" + parseInt(columnOpts.width) + "px;";
  3631. if (opts.hasSubRow == true && columnOpts.field == "") { return; }
  3632. if (columnOpts.hidden) {
  3633. tdStyle = "display:none;";
  3634. }
  3635. if (columnOpts.columnType == "checkbox") {
  3636. tdHtmlList.push("".concat('<td columnIndex="', columnOpts.columnIndex, '" style="', tdStyle, '"><input type="checkbox" value="', eval("rowData." + columnOpts.field), '"'));
  3637. if (rowData[columnOpts.checkfield]) {
  3638. tdHtmlList.push("".concat(' checked '));
  3639. }
  3640. tdHtmlList.push("".concat('/></td>'));
  3641. var selectAll = $(header.find('.header th').get(columnOpts.columnIndex)).find('input[type="checkbox"]');
  3642. selectAll.removeAttr("checked");
  3643. } else if (columnOpts.columnType == "radiobox") {
  3644. var controlName = columnOpts.field;
  3645. if (columnOpts.customName && columnOpts.customName != "") {
  3646. controlName = columnOpts.customName;
  3647. }
  3648. tdHtmlList.push("".concat('<td columnIndex="', columnOpts.columnIndex, '" style="', tdStyle, '"><input type="radio" name="', controlName, '_', realRowIndex.toString(), '" value="', columnOpts.radioValue.toString(), '"'));
  3649. if (columnOpts.radioValue == eval("rowData." + columnOpts.field)) {
  3650. tdHtmlList.push("".concat(' checked="checked" '));
  3651. }
  3652. tdHtmlList.push("".concat('/></td>'));
  3653. } else if (columnOpts.columnType == "checkbutton") {
  3654. tdHtmlList.push("".concat('<td columnIndex="', columnOpts.columnIndex, '" style="', tdStyle, '"><input type="checkbox" name="', columnOpts.field, '_', realRowIndex.toString(), '"'));
  3655. if (eval("rowData." + columnOpts.field)) {
  3656. tdHtmlList.push("".concat(' checked="checked" '));
  3657. }
  3658. tdHtmlList.push("".concat('/></td>'));
  3659. } else if (columnOpts.columnType == "imagebutton") {
  3660. tdHtmlList.push("".concat('<td columnIndex="', columnOpts.columnIndex, '" style="', tdStyle, '"><a href="#this"'));
  3661. if (columnOpts.handle) {
  3662. tdHtmlList.push("".concat(' onclick="return ', columnOpts.handle, '(', rowIndex, ",$(this).closest('.easyui-cmsXDataTable').cmsXDataTable('getRows')[" + rowIndex + '])"'));
  3663. }
  3664. tdHtmlList.push("".concat('><img src="', eval("rowData." + columnOpts.field), '" style="border: 0px; width:', columnOpts.imageWidth, '; height:', columnOpts.itemHeight, '" />'));
  3665. tdHtmlList.push("".concat('</a></td>'));
  3666. } else if (columnOpts.columnType == "textbox" || columnOpts.columnType == "triggerbox") {
  3667. var formatterValue = columnOpts.formatter.call(jq, eval("rowData." + columnOpts.field), rowData, rowIndex, columnOpts.overflowlength);
  3668. if (formatterValue != 0) {
  3669. formatterValue = formatterValue || "";
  3670. }
  3671. if (!columnOpts.isMultiline) {
  3672. tdHtmlList.push("".concat('<td columnIndex="', columnOpts.columnIndex, '" style="', tdStyle, '"><input type="text" style="width: 98%;" value="', formatterValue, '" /></td>'));
  3673. } else {
  3674. tdHtmlList.push("".concat('<td columnIndex="', columnOpts.columnIndex, '" style="', tdStyle, '"><textarea rows="3" style="width: 98%;">', formatterValue, '</textarea></td>'));
  3675. }
  3676. } else if (columnOpts.columnType == "dropdownlist" || columnOpts.columnType == "dictionary") {
  3677. tdHtmlList.push("".concat('<td columnIndex="', columnOpts.columnIndex, '" style="', tdStyle, '">'));
  3678. tdHtmlList.push("".concat('<select id="', tableid, '_', columnOpts.fieldname, '_', columnOpts.columnIndex, '" name="', tableid, '_', columnOpts.fieldname, '_', columnOpts.columnIndex, '" style="width: 98%;"/>'));
  3679. tdHtmlList.push("".concat('</td>'));
  3680. } else if (columnOpts.columnType == "autocomplete") {
  3681. tdHtmlList.push("".concat('<td columnIndex="', columnOpts.columnIndex, '" style="', tdStyle, '">'));
  3682. tdHtmlList.push("".concat('<input type="text" id="', tableid, '_', columnOpts.fieldname, '_', columnOpts.columnIndex, '_text" name="', tableid, '_', columnOpts.fieldname, '_', columnOpts.columnIndex, '_text" style="width: 98%;"/>'));
  3683. tdHtmlList.push("".concat('<input type="hidden" id="', tableid, '_', columnOpts.fieldname, '_', columnOpts.columnIndex, '" name="', tableid, '_', columnOpts.fieldname, '_', columnOpts.columnIndex, '" value="', eval("rowData." + columnOpts.field), '" />'));
  3684. tdHtmlList.push("".concat('</td>'));
  3685. } else if (columnOpts.columnType == "tree") {
  3686. var fullID = _getFullID(data.rows, rowData, columnOpts.parentIDField, columnOpts.field);
  3687. deep = fullID.split('.').length - 1;
  3688. tdHtmlList.push("".concat('<td fullTreeID="', fullID, '" columnIndex="', columnOpts.columnIndex, '" align="left" style="', tdStyle, '">', _treeFormatter(columnOpts, rowData, data.rows[rowIndex + 1], deep), ' </td>'));
  3689. } else {
  3690. var formatterValue = columnOpts.formatter.call(jq, eval("rowData." + columnOpts.field), rowData, rowIndex, columnOpts.overflowlength, columnOpts.emptyText);
  3691. if (formatterValue != 0) {
  3692. formatterValue = formatterValue || columnOpts.defaultValue;
  3693. }
  3694. var titleValue;
  3695. if (!columnOpts.columnType) {
  3696. titleValue = eval("rowData." + columnOpts.field) == null ? '' : columnOpts.formatter.call(jq, eval("rowData." + columnOpts.field), rowData, rowIndex, 0, columnOpts.emptyText);
  3697. if (titleValue != 0) {
  3698. titleValue = titleValue || columnOpts.defaultValue;
  3699. }
  3700. } else {
  3701. titleValue = eval("rowData." + columnOpts.field) == null ? '' : eval("rowData." + columnOpts.field);
  3702. }
  3703. if (titleValue.toString().indexOf('<') >= 0) {
  3704. titleValue = eval("rowData." + columnOpts.field) == null ? '' : eval("rowData." + columnOpts.field);
  3705. }
  3706. tdHtmlList.push("".concat('<td columnIndex="', columnOpts.columnIndex, '" style="', tdStyle, '" title="', titleValue, '">', formatterValue, ' </td>'));
  3707. }
  3708. });
  3709. var rowStyle = opts.rowStyle.call(jq, realRowIndex, rowData);
  3710. var highlightProp = _getHighlightProp(jq, rowIndex);
  3711. if (realRowIndex % 2 == 0) {
  3712. $(''.concat('<tr class="row row2"' + highlightProp + ' style="' + rowStyle + '" xRowIndex="', realRowIndex, '">', tdHtmlList.join(""), '</tr>')).appendTo(table);
  3713. } else {
  3714. $(''.concat('<tr class="row"' + highlightProp + ' style="' + rowStyle + '" xRowIndex="', realRowIndex, '">', tdHtmlList.join(""), '</tr>')).appendTo(table);
  3715. }
  3716. //add by heyw,增加扩展行开始
  3717. //填写扩展行内容
  3718. if (opts.hasSubRow == true) {
  3719. var subRowHtml = opts.subRowFomatter(rowData, rowIndex);
  3720. if (opts.expandOnLoad == true) {
  3721. $(''.concat('<tr class="row" style="' + rowStyle + '"' + highlightProp + ' rowIndex="', realRowIndex, '"><td colspan=' + columnList.length + '>', subRowHtml, '</td></tr>')).appendTo(table);
  3722. }
  3723. else {
  3724. $(''.concat('<tr class="row" style="' + rowStyle + '"' + highlightProp + ' style="display: none;" rowIndex="', realRowIndex, '"><td colspan=' + columnList.length + '>', subRowHtml, '</td></tr>')).appendTo(table);
  3725. }
  3726. }
  3727. //add by heyw,增加扩展行结束
  3728. });
  3729. //add by heyw,增加扩展行开始
  3730. //绑定展开按钮事件
  3731. table.find("tr.row>td>div.subrow-expander").each(function () {
  3732. this.onclick = function () {
  3733. var subRow = table.find("tr.row[rowIndex=" + $(this).attr("rowIndex") + "]");
  3734. var oldDisplay = subRow.css("display");
  3735. if (oldDisplay == "none") {
  3736. subRow.css("display", "");
  3737. $(this).attr("class", "tree-expanded");
  3738. }
  3739. else {
  3740. subRow.css("display", "none");
  3741. $(this).attr("class", "tree-collapsed");
  3742. }
  3743. }
  3744. });
  3745. if (opts.isMouseOverHighlight) {
  3746. table.find("tr.row").mouseover(function() {
  3747. $(this).css("background-color", opts.rowHighlightColor);
  3748. $(this).find("td").css("background-color", opts.rowHighlightColor);
  3749. $(this).bind("mouseout.hightlight", function() {
  3750. $(this).css("background-color", "");
  3751. $(this).find("td").css("background-color", "");
  3752. $(this).unbind("mouseout.hightlight");
  3753. });
  3754. });
  3755. }
  3756. if (opts.checkOnSelect) {
  3757. var checkboxColumnIndexList = $.map(
  3758. $.grep(columnList, function (x){ return x.columnType == "checkbox"; }),
  3759. function(x) { return x.columnIndex; });
  3760. table.find('tr.row').click(function() {
  3761. if (event.srcElement.type == "checkbox") return;
  3762. for (var i = 0; i < checkboxColumnIndexList.length; i ++) {
  3763. var checkboxList = $(this).find('td[columnIndex=' + checkboxColumnIndexList[i] + '] input[type="checkbox"]');
  3764. for (var j = 0; j < checkboxList.length; j ++) {
  3765. checkbox = $(checkboxList[j]);
  3766. var isChecked = !checkbox.attr("checked");
  3767. checkbox.attr("checked", isChecked);
  3768. if (isChecked) {
  3769. $(this).addClass("row_selected");
  3770. } else {
  3771. $(this).removeClass("row_selected");
  3772. }
  3773. }
  3774. }
  3775. });
  3776. }
  3777. if (opts.onClickRow) {
  3778. table.find('tr.row').css("cursor", "pointer").click(function () {
  3779. var grid = $(this).parents('.easyui-cmsXDataTable:first');
  3780. var gridOpts = $.data(grid[0], "cmsXDataTable").options;
  3781. var gridData = gridOpts.data;
  3782. var rowIndex = parseInt($(this).attr("xRowIndex"));
  3783. var rowData = gridData.rows[rowIndex];
  3784. opts.onClickRow.call(grid, rowIndex, rowData);
  3785. });
  3786. }
  3787. if (opts.onDblClickRow) {
  3788. table.find('tr.row').css("cursor", "pointer").dblclick(function () {
  3789. var grid = $(this).parents('.easyui-cmsXDataTable:first');
  3790. var gridOpts = $.data(grid[0], "cmsXDataTable").options;
  3791. var gridData = gridOpts.data;
  3792. var rowIndex = parseInt($(this).attr("xRowIndex"));
  3793. var rowData = gridData.rows[rowIndex];
  3794. opts.onDblClickRow.call(grid, rowIndex, rowData);
  3795. });
  3796. }
  3797. //add by heyw,增加扩展行结束
  3798. //add by heyw,创建自定义控件开始
  3799. _createTableControls(jq);
  3800. //add by heyw,创建自定义控件结束
  3801. opts.totalPage = Math.ceil(opts.data.total / opts.pageSize);
  3802. if (opts.pagerType == 0 && opts.pagination) {
  3803. btnPagerFirst.removeClass("l-btn-disabled");
  3804. btnPagerPrev.removeClass("l-btn-disabled");
  3805. btnPagerNext.removeClass("l-btn-disabled");
  3806. btnPagerLast.removeClass("l-btn-disabled");
  3807. if (opts.pageNumber == 1) {
  3808. btnPagerFirst.addClass("l-btn-disabled");
  3809. btnPagerPrev.addClass("l-btn-disabled");
  3810. }
  3811. if (opts.pageNumber >= opts.totalPage) {
  3812. btnPagerNext.addClass("l-btn-disabled");
  3813. btnPagerLast.addClass("l-btn-disabled");
  3814. }
  3815. pagerPanel.find("input.xDataTablePanel_pager-num").val(opts.pageNumber);
  3816. pagerPanel.find(".xDataTablePanel_pager-totalInfo").html("共" + opts.totalPage + "页");
  3817. pagerPanel.find(".xDataTablePanel_pager_info").html("显示" + ((opts.pageNumber - 1) * opts.pageSize + 1) + "到" + ((opts.pageNumber - 1) * opts.pageSize + data.rows.length) + ",共" + data.total + "条记录");
  3818. } else {
  3819. pagerPanel.find(".xDataTablePanel_pager_Simp").removeClass("l-btn-disabled");
  3820. if (opts.pageNumber >= opts.totalPage) {
  3821. pagerPanel.find(".xDataTablePanel_pager_Simp").addClass("l-btn-disabled");
  3822. }
  3823. }
  3824. if (typeof (opts.onLoadSuccess) == "function") {
  3825. opts.onLoadSuccess.call(jq, data);
  3826. }
  3827. if (opts.isAutoHeight) {
  3828. if (table.parent().height() < table.height()) {
  3829. table.parent().height(table.height());
  3830. }
  3831. if (table[0].offsetWidth > table.parent()[0].offsetWidth) {
  3832. table.parent().height(table.height() + 16);
  3833. }
  3834. }
  3835. var firstRow = table.find("tr");
  3836. if (firstRow.length > 0) { //一行都没有一般就不会错位
  3837. header.find("tr.header>th").each(function(i, v) {
  3838. var width = $($(firstRow[0]).find("td")[i]).width();
  3839. $(this).width(width);
  3840. });
  3841. }
  3842. };
  3843. var _getFullID = function (dataRows, rowData, parentField, idField) {
  3844. var id = rowData[idField];
  3845. if (!rowData[parentField]) return id;
  3846. var parentData = $.grep(dataRows, function (v) { return v[idField] == rowData[parentField]; })[0];
  3847. return id + "." + _getFullID(dataRows, parentData, parentField, idField);
  3848. };
  3849. var _generalComparer = function (a, b) {
  3850. if (a == null && b == null) {
  3851. return 0;
  3852. }
  3853. else if (a == null) {
  3854. return -1;
  3855. }
  3856. else if (b == null) {
  3857. return 1;
  3858. }
  3859. else if (a == b) {
  3860. return 0;
  3861. }
  3862. else if (a > b) {
  3863. return 1;
  3864. }
  3865. else {
  3866. return -1;
  3867. }
  3868. };
  3869. var _orderDataForTree = function (dataRows, idField, parentField, orderField, result) {
  3870. var topRows = $.grep(dataRows, function (v) { return v[parentField] == null; })
  3871. .sort(function (a, b) { return _generalComparer(a[orderField], b[orderField]); });
  3872. $.each(topRows, function (i, v) {
  3873. result.push(v);
  3874. _pushChild(dataRows, v, idField, parentField, orderField, result);
  3875. })
  3876. };
  3877. var _pushChild = function (dataRows, value, idField, parentField, orderField, result) {
  3878. var childRows = $.grep(dataRows, function (v) { return v[parentField] == value[idField]; })
  3879. .sort(function (a, b) { return _generalComparer(a[orderField], b[orderField]); });
  3880. $.each(childRows, function (i, v) {
  3881. result.push(v);
  3882. _pushChild(dataRows, v, idField, parentField, orderField, result);
  3883. });
  3884. };
  3885. var _treeFormatter = function (columnOpts, rowData, nextRowData, deep) {
  3886. var html = new Array();
  3887. var i;
  3888. for (i = 0; i < deep; i++) {
  3889. html.push('<span class="tree-indent"></span>');
  3890. }
  3891. //有无子集
  3892. if (nextRowData && eval("nextRowData." + columnOpts.parentIDField) == eval("rowData." + columnOpts.field)) {
  3893. html.push('<span class="tree-hit tree-expanded"></span>');
  3894. }
  3895. else {
  3896. html.push('<span class="tree-indent"></span>');
  3897. }
  3898. html.push('<span class="tree-icon tree-folder"></span>');
  3899. html.push('<span class="tree-title">' + rowData[columnOpts.textField] + '</span>');
  3900. return html.join('');
  3901. };
  3902. var _getRealRowIndex = function (opts, rowIndex) {
  3903. var realRowIndex = rowIndex;
  3904. if (opts.pagerType == 1 && opts.pagination) {
  3905. realRowIndex += (opts.pageNumber - 1) * opts.pageSize;
  3906. }
  3907. return realRowIndex;
  3908. }
  3909. var _createTableControls = function (jq) {
  3910. var opts = $.data(jq, "cmsXDataTable").options;
  3911. var table = $.data(jq, "cmsXDataTable").table;
  3912. var columnList = $.data(jq, "cmsXDataTable").columnList;
  3913. $.each(columnList, function () {
  3914. var columnOpts = this;
  3915. var columnIndex = columnOpts.columnIndex;
  3916. var isEditableColumn = true;
  3917. if (columnOpts.columnType == "autocomplete") {
  3918. _createAutoCompleteControl(columnOpts, table);
  3919. }
  3920. else if (columnOpts.columnType == "textbox" && !columnOpts.isMultiline) {
  3921. _createTextBoxControl(columnOpts, table);
  3922. }
  3923. else if (columnOpts.columnType == "textbox" && columnOpts.isMultiline) {
  3924. _createMultilineControl(columnOpts, table);
  3925. }
  3926. else if (columnOpts.columnType == "triggerbox") {
  3927. _createTriggerBoxControl(columnOpts, table);
  3928. }
  3929. else if (columnOpts.columnType == "radiobox") {
  3930. _createRadioBoxControl(columnOpts, table);
  3931. }
  3932. else if (columnOpts.columnType == "checkbutton") {
  3933. _createCheckButtonControl(columnOpts, table);
  3934. }
  3935. else if (columnOpts.columnType == "dropdownlist") {
  3936. _createDropdownControl(columnOpts, table);
  3937. }
  3938. else if (columnOpts.columnType == "dictionary") {
  3939. _createDictionaryControl(columnOpts, table);
  3940. }
  3941. else if (columnOpts.columnType == "tree") {
  3942. isEditableColumn = false;
  3943. _createTreeControl(columnOpts, table);
  3944. }
  3945. else if (columnOpts.columnType == "linkbutton" || columnOpts.columnType == "imagebutton") {
  3946. var enableFieldName = columnOpts.enableFieldName;
  3947. if (enableFieldName && enableFieldName != "") {
  3948. $.each(opts.data.rows, function (index, rowData) {
  3949. var realRowIndex = _getRealRowIndex(opts, index);
  3950. var tableRow = table.find("tr.row[xRowIndex=" + realRowIndex.toString() + "]");
  3951. if (!eval("rowData." + enableFieldName)) {
  3952. //$(tableRow.find("td")[columnIndex]).html($(tableRow.find("td")[columnIndex]).text());
  3953. $(tableRow.find("td")[columnIndex]).find('*').attr("disabled", "disabled");
  3954. $(tableRow.find("td")[columnIndex]).find('*').addClass("disabledLink");
  3955. }
  3956. });
  3957. }
  3958. var visibleFieldName = columnOpts.visibleFieldName;
  3959. if (visibleFieldName && visibleFieldName != "") {
  3960. $.each(opts.data.rows, function (index, rowData) {
  3961. var realRowIndex = _getRealRowIndex(opts, index);
  3962. var tableRow = table.find("tr.row[xRowIndex=" + realRowIndex.toString() + "]");
  3963. if (!eval("rowData." + visibleFieldName)) {
  3964. $(tableRow.find("td")[columnIndex]).html("&nbsp;");
  3965. }
  3966. });
  3967. }
  3968. isEditableColumn = false;
  3969. }
  3970. else {
  3971. isEditableColumn = false;
  3972. }
  3973. if (isEditableColumn) {
  3974. var enableFieldName = columnOpts.enableFieldName;
  3975. if (enableFieldName && enableFieldName != "") {
  3976. $.each(opts.data.rows, function (index, rowData) {
  3977. var realRowIndex = _getRealRowIndex(opts, index);
  3978. var tableRow = table.find("tr.row[xRowIndex=" + realRowIndex.toString() + "]");
  3979. if (eval("!rowData." + enableFieldName)) {
  3980. $(tableRow.find("td")[columnIndex]).children().attr("disabled", "disabled");
  3981. }
  3982. });
  3983. }
  3984. var visibleFieldName = columnOpts.visibleFieldName;
  3985. if (visibleFieldName && visibleFieldName != "") {
  3986. $.each(opts.data.rows, function (index, rowData) {
  3987. var realRowIndex = _getRealRowIndex(opts, index);
  3988. var tableRow = table.find("tr.row[xRowIndex=" + realRowIndex.toString() + "]");
  3989. if (eval("!rowData." + visibleFieldName)) {
  3990. $(tableRow.find("td")[columnIndex]).children().css("display", "none");
  3991. }
  3992. });
  3993. }
  3994. }
  3995. });
  3996. };
  3997. var _createTreeControl = function (columnOpts, table) {
  3998. $(table).find(".tree-hit").each(function () {
  3999. $(this).mouseover(function (e) {
  4000. if ($(e.target).hasClass("tree-expanded"))
  4001. $(e.target).addClass("tree-expanded-hover");
  4002. else
  4003. $(e.target).addClass("tree-collapsed-hover");
  4004. });
  4005. $(this).mouseout(function (e) {
  4006. if ($(e.target).hasClass("tree-expanded-hover"))
  4007. $(e.target).removeClass("tree-expanded-hover");
  4008. else
  4009. $(e.target).removeClass("tree-collapsed-hover");
  4010. });
  4011. $(this).click(function (e) {
  4012. if ($(e.target).hasClass("tree-expanded-hover")) {
  4013. $(e.target).removeClass("tree-expanded");
  4014. $(e.target).removeClass("tree-expanded-hover");
  4015. $(e.target).addClass("tree-collapsed");
  4016. $(e.target).addClass("tree-collapsed-hover");
  4017. }
  4018. else {
  4019. $(e.target).removeClass("tree-collapsed");
  4020. $(e.target).removeClass("tree-collapsed-hover");
  4021. $(e.target).addClass("tree-expanded");
  4022. $(e.target).addClass("tree-expanded-hover");
  4023. }
  4024. var childRows = $(table).find("td[fullTreeID$='" + $(e.target).parent().attr("fullTreeID") + "']");
  4025. childRows = $.grep(childRows, function (v) {
  4026. return $(v).attr("fullTreeID") != $(e.target).parent().attr("fullTreeID");
  4027. });
  4028. $.each(childRows, function () {
  4029. if ($(this).parent().css("display") == "none") {
  4030. $(this).parent().css("display", "");
  4031. } else {
  4032. $(this).parent().css("display", "none");
  4033. }
  4034. });
  4035. });
  4036. });
  4037. };
  4038. var _createTextBoxControl = function (columnOpts, table) {
  4039. $(table).find("tr").each(function () {
  4040. if ($(this).find("th").length > 0) return true;
  4041. var rowIndex = $(this).attr("xRowIndex");
  4042. var textControl = $($(this).find("td")[columnOpts.columnIndex]).find('input');
  4043. textControl.on('input propertychange', function (e) {
  4044. var textValue;
  4045. if (!columnOpts.validateOption) {
  4046. textValue = $(this).val();
  4047. } else {
  4048. switch (columnOpts.validateOption.validType) {
  4049. case "onlyMoney" :
  4050. case "onlyDiscount" :
  4051. case "onlyNumber" :
  4052. if (isNaN($(this).val())) {
  4053. textValue = null;
  4054. } else {
  4055. textValue = parseFloat($(this).val());
  4056. }
  4057. break;
  4058. default :
  4059. textValue = $(this).val();
  4060. break;
  4061. }
  4062. }
  4063. _changeDataJson(table, rowIndex, columnOpts.field, textValue, columnOpts);
  4064. });
  4065. if (columnOpts.validateOption) {
  4066. textControl.validatebox(columnOpts.validateOption);
  4067. }
  4068. });
  4069. };
  4070. var _createMultilineControl = function (columnOpts, table) {
  4071. $(table).find("tr").each(function () {
  4072. if ($(this).find("th").length > 0) return true;
  4073. var rowIndex = $(this).attr("xRowIndex");
  4074. var textControl = $($(this).find("td")[columnOpts.columnIndex]).find('textarea');
  4075. textControl.on('textarea propertychange', function (e) {
  4076. var textValue;
  4077. if (!columnOpts.validateOption) {
  4078. textValue = $(this).val();
  4079. } else {
  4080. switch (columnOpts.validateOption.validType) {
  4081. case "onlyMoney" :
  4082. case "onlyDiscount" :
  4083. case "onlyNumber" :
  4084. if (isNaN($(this).val())) {
  4085. textValue = null;
  4086. } else {
  4087. textValue = parseFloat($(this).val());
  4088. }
  4089. break;
  4090. default :
  4091. textValue = $(this).val();
  4092. break;
  4093. }
  4094. }
  4095. _changeDataJson(table, rowIndex, columnOpts.field, textValue, columnOpts);
  4096. });
  4097. if (columnOpts.validateOption) {
  4098. textControl.validatebox(columnOpts.validateOption);
  4099. }
  4100. });
  4101. };
  4102. var _createTriggerBoxControl = function (columnOpts, table) {
  4103. $(table).find("tr").each(function () {
  4104. if ($(this).find("th").length > 0) return true;
  4105. var rowIndex = $(this).attr("xRowIndex");
  4106. var textControl = $($(this).find("td")[columnOpts.columnIndex]).find('input');
  4107. var jq = table.closest(".easyui-cmsXDataTable")[0];
  4108. var opts = $.data(jq, "cmsXDataTable").options;
  4109. textControl.triggerbox({
  4110. valueField: columnOpts.targetField,
  4111. textField: columnOpts.targetTextField,
  4112. separator: ",",
  4113. editable: true,
  4114. postData: {},
  4115. change: function () {
  4116. var selectedData = $(this).triggerbox("getData");
  4117. if (selectedData.length > 0) {
  4118. var value;
  4119. if (Object.prototype.toString.call(opts.data.rows[rowIndex][columnOpts.field]) === "[object Array]") {
  4120. value = selectedData;
  4121. } else {
  4122. value = $.map(selectedData, function(x) { return x[columnOpts.targetField];}).join(',');
  4123. }
  4124. var text = $.map(selectedData, function(x) { return x[columnOpts.targetTextField];}).join(',');
  4125. _changeDataJson(table, rowIndex, columnOpts.field, value, columnOpts);
  4126. _changeDataJson(table, rowIndex, columnOpts.textfield, text, columnOpts);
  4127. } else {
  4128. if (Object.prototype.toString.call(opts.data.rows[rowIndex][columnOpts.field]) === "[object Array]") {
  4129. _changeDataJson(table, rowIndex, columnOpts.field, [], columnOpts);
  4130. } else {
  4131. _changeDataJson(table, rowIndex, columnOpts.field, null, columnOpts);
  4132. }
  4133. _changeDataJson(table, rowIndex, columnOpts.textfield, null, columnOpts);
  4134. }
  4135. },
  4136. onSearch: columnOpts.triggerHandle
  4137. });
  4138. var newArray = new Array();
  4139. var newObj = new Object();
  4140. if (Object.prototype.toString.call(opts.data.rows[rowIndex][columnOpts.field]) === "[object Array]") {
  4141. newArray = opts.data.rows[rowIndex][columnOpts.field];
  4142. } else {
  4143. newObj[columnOpts.targetField] = opts.data.rows[rowIndex][columnOpts.field];
  4144. newObj[columnOpts.targetTextField] = opts.data.rows[rowIndex][columnOpts.textfield];
  4145. newArray.push(newObj);
  4146. }
  4147. textControl.triggerbox('setValue', newArray);
  4148. });
  4149. }
  4150. var _createRadioBoxControl = function (columnOpts, table) {
  4151. $(table).find("tr").each(function () {
  4152. if ($(this).find("th").length > 0) return true;
  4153. var rowIndex = $(this).attr("xRowIndex");
  4154. var radioControl = $($(this).find("td")[columnOpts.columnIndex]).find('input');
  4155. radioControl.click(function () {
  4156. _changeDataJson(table, rowIndex, columnOpts.field, $(this).val(), columnOpts);
  4157. });
  4158. });
  4159. };
  4160. var _createCheckButtonControl = function (columnOpts, table) {
  4161. $(table).find("tr").each(function () {
  4162. if ($(this).find("th").length > 0) return true;
  4163. var rowIndex = $(this).attr("xRowIndex");
  4164. var checkButtonControl = $($(this).find("td")[columnOpts.columnIndex]).find('input');
  4165. checkButtonControl.click(function () {
  4166. _changeDataJson(table, rowIndex, columnOpts.field, $(this).prop("checked"), columnOpts);
  4167. });
  4168. });
  4169. };
  4170. var _createDropdownControl = function (columnOpts, table) {
  4171. var jq = table.closest(".easyui-cmsXDataTable")[0];
  4172. var opts = $.data(jq, "cmsXDataTable").options;
  4173. $.ajax({
  4174. // try to leverage ajaxQueue plugin to abort previous requests
  4175. mode: "abort",
  4176. // limit abortion to this input
  4177. dataType: "json",
  4178. url: columnOpts.url,
  4179. data: $.extend({
  4180. bindType: 0
  4181. }, {}),
  4182. success: function (data) {
  4183. if (data && data.length) {
  4184. $(table).find("tr").each(function () {
  4185. if ($(this).find("th").length > 0) return true;
  4186. var rowIndex = $(this).attr("xRowIndex");
  4187. var selectControl = $($(this).find("td")[columnOpts.columnIndex]).find('select');
  4188. selectControl.empty();
  4189. $("<option value='-1'>---请选择---</option>").appendTo(selectControl);
  4190. $.each(data, function () {
  4191. if (this[columnOpts.valueField] == eval("opts.data.rows[rowIndex]." + columnOpts.fieldname)) {
  4192. $("<option value='" + this[columnOpts.valueField] + "' selected>" + this[columnOpts.textField] + "</option>").appendTo(selectControl);
  4193. } else {
  4194. $("<option value='" + this[columnOpts.valueField] + "'>" + this[columnOpts.textField] + "</option>").appendTo(selectControl);
  4195. }
  4196. });
  4197. $(selectControl).bind("click", function () {
  4198. var selectedValue = $(this).val();
  4199. if (selectedValue == "-1") selectedValue = null;
  4200. _changeDataJson(table, rowIndex, columnOpts.fieldname, selectedValue, columnOpts);
  4201. });
  4202. if (columnOpts.validateOption) {
  4203. $(selectControl).validatebox(columnOpts.validateOption);
  4204. }
  4205. });
  4206. }
  4207. }
  4208. });
  4209. };
  4210. var _createDictionaryControl = function (columnOpts, table) {
  4211. var jq = table.closest(".easyui-cmsXDataTable")[0];
  4212. var opts = $.data(jq, "cmsXDataTable").options;
  4213. var dictionaryCode = columnOpts.dictionaryCode;
  4214. if (dictionaryCode && dictionaryCode != "") {
  4215. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/Common/DictionaryDropDown', { bindType: 0, dictionaryCode: dictionaryCode }, function (dictionaryData) {
  4216. $(table).find("tr").each(function () {
  4217. if ($(this).find("th").length > 0) return true; //跳过标题行
  4218. var rowIndex = $(this).attr("xRowIndex");
  4219. var selectControl = $($(this).find("td")[columnOpts.columnIndex]).find('select');
  4220. selectControl.empty();
  4221. $.each(dictionaryData, function () {
  4222. if (this.Value == opts.data.rows[rowIndex][columnOpts.fieldname]) {
  4223. $("<option value='" + this.Value + "' selected>" + this.Text + "</option>").appendTo(selectControl);
  4224. } else {
  4225. $("<option value='" + this.Value + "'>" + this.Text + "</option>").appendTo(selectControl);
  4226. }
  4227. });
  4228. $(selectControl).bind("click", function () {
  4229. var selectedValue = $(this).val();
  4230. if (selectedValue == "-1") selectedValue = null;
  4231. _changeDataJson(table, rowIndex, columnOpts.fieldname, selectedValue, columnOpts);
  4232. });
  4233. if (columnOpts.validateOption) {
  4234. $(selectControl).validatebox(columnOpts.validateOption);
  4235. }
  4236. });
  4237. });
  4238. }
  4239. };
  4240. var _createAutoCompleteControl = function (columnOpts, table) {
  4241. var top = 10;
  4242. //这里开始要修改成一次过读出数据……
  4243. $.ajax({
  4244. // try to leverage ajaxQueue plugin to abort previous requests
  4245. mode: "abort",
  4246. // limit abortion to this input
  4247. dataType: "json",
  4248. url: columnOpts.url,
  4249. data: $.extend({
  4250. q: "",
  4251. limit: 99999
  4252. }, {}),
  4253. success: function (data) {
  4254. if (data && data.length) {
  4255. $(table).find("tr").each(function () {
  4256. if ($(this).find("th").length > 0) return true;
  4257. var rowIndex = $(this).attr("xRowIndex");
  4258. var textControl = $($(this).find("td")[columnOpts.columnIndex]).find('input[type="text"]');
  4259. var valueBox = $($(this).find("td")[columnOpts.columnIndex]).find('input[type="hidden"]');
  4260. $.each(data, function () {
  4261. if (this[columnOpts.valueField].toString() == $(valueBox).val()) {
  4262. $(textControl).val(this[columnOpts.textField]);
  4263. }
  4264. });
  4265. $(textControl).autocomplete(data, {
  4266. max: top,
  4267. minChars: 1,
  4268. width: columnOpts.width,
  4269. scrollHeight: columnOpts.scrollHeight,
  4270. matchContains: columnOpts.matchContains,
  4271. mustMatch: columnOpts.mustMatch,
  4272. cacheLength: 99999, //1- 无缓存
  4273. autoFill: columnOpts.autoFill,
  4274. dataType: 'json',
  4275. parse: function (data) {
  4276. var parsed = [];
  4277. for (var i = 0; i < data.length; i++) {
  4278. parsed[parsed.length] = {
  4279. data: data[i],
  4280. value: data[i][columnOpts.valueField].toString(),
  4281. result: data[i][columnOpts.textField]
  4282. };
  4283. }
  4284. return parsed;
  4285. },
  4286. formatItem: columnOpts.formatter,
  4287. formatMatch: function (row, i, max) {
  4288. return row[columnOpts.textField];
  4289. },
  4290. formatResult: function (row) {
  4291. $(valueBox).val(row[columnOpts.valueField]);
  4292. _changeDataJson(table, rowIndex, columnOpts.fieldname, row[columnOpts.valueField], columnOpts);
  4293. return row[columnOpts.textField];
  4294. }
  4295. });
  4296. if (columnOpts.validateOption) {
  4297. $(textControl).validatebox(columnOpts.validateOption);
  4298. }
  4299. });
  4300. }
  4301. }
  4302. });
  4303. }
  4304. var _changeDataJson = function (table, rowIndex, fieldName, value, columnOpts) {
  4305. var jq = table.closest(".easyui-cmsXDataTable")[0];
  4306. var config = $.data(jq, "cmsXDataTable");
  4307. var opts = config.options;
  4308. if (opts.data.rows.length <= rowIndex) return;
  4309. eval("opts.data.rows[rowIndex]." + fieldName + " = value");
  4310. //$.data(jq, "cmsXDataTable", config);
  4311. if (!opts.isPostBack) return;
  4312. var tableid = table.closest(".easyui-cmsXDataTable").attr("id");
  4313. var tableDataHidden = $("#" + tableid + "_datajson");
  4314. var data = JSON.parse($(tableDataHidden).val());
  4315. eval("data.rows[rowIndex]." + fieldName + " = value");
  4316. $(tableDataHidden).val(JSON.stringify(data));
  4317. if (columnOpts) {
  4318. if (columnOpts.onChanged) columnOpts.onChanged.call(columnOpts, rowIndex, data.rows[rowIndex]);
  4319. }
  4320. };
  4321. var _getRowDataByObj = function (jq, obj) {
  4322. var rowIndex = parseInt($(obj).closest("tr").attr("xRowIndex"));
  4323. var opts = $.data(jq, "cmsXDataTable").options;
  4324. var data = opts.data;
  4325. return data.rows[rowIndex];
  4326. };
  4327. var _getRows = function (jq) {
  4328. var opts = $.data(jq, "cmsXDataTable").options;
  4329. if (!opts.isPostBack)
  4330. return opts.data.rows;
  4331. else {
  4332. var tableid = $(jq).attr("id");
  4333. var tableDataHidden = $("#" + tableid + "_datajson");
  4334. if (tableDataHidden.val() != "") {
  4335. return JSON.parse(tableDataHidden.val()).rows;
  4336. } else {
  4337. return [];
  4338. }
  4339. }
  4340. };
  4341. var _getTotal = function (jq) {
  4342. var opts = $.data(jq, "cmsXDataTable").options;
  4343. return opts.data.total;
  4344. };
  4345. var _getSelections = function (jq) {
  4346. var opts = $.data(jq, "cmsXDataTable").options;
  4347. var table = $.data(jq, "cmsXDataTable").table;
  4348. var selectionsList = new Array();
  4349. table.find("tr.row_selected").each(function () {
  4350. selectionsList.push(opts.data.rows[$(this).attr("xRowIndex")]);
  4351. });
  4352. return selectionsList;
  4353. };
  4354. var _clearSelections = function (jq) {
  4355. var opts = $.data(jq, "cmsXDataTable").options;
  4356. var table = $.data(jq, "cmsXDataTable").table;
  4357. var columnList = $.data(jq, "cmsXDataTable").columnList;
  4358. var checkboxIndex = 0;
  4359. $.each(columnList, function () {
  4360. if (this.columnType == "checkbox") {
  4361. checkboxIndex = this.columnIndex;
  4362. return false;
  4363. }
  4364. });
  4365. table.find("tr.row_selected").removeClass("row_selected").each(function () {
  4366. $(this).find(">td[columnIndex='" + checkboxIndex + "']>input[type='checkbox']").attr("checked", false);
  4367. });
  4368. };
  4369. var _deleteSubRowItem = function (jq, delData) {
  4370. var tableSettings = $.data(jq, "cmsXDataTable");
  4371. var table = $.data(jq, "cmsXDataTable").table;
  4372. var opts = tableSettings.options;
  4373. var data = opts.data;
  4374. var rowIndex = delData.rowIndex;
  4375. var delValue = delData.value;
  4376. var listElement = delData.listElement;
  4377. var valueElement = delData.valueElement;
  4378. //debugger;
  4379. if (opts.onSubRowItemDelete) {
  4380. var deleted = $.grep(data.rows[rowIndex][listElement], function (v, i) {
  4381. var elementTree = valueElement.split('.');
  4382. var firstElement = elementTree[0];
  4383. elementTree.splice(0, 1);
  4384. var lastElement = elementTree.join('.');
  4385. var expression = 'new Object(v["' + firstElement + '"])';
  4386. if (lastElement != "") {
  4387. expression += '.' + lastElement;
  4388. }
  4389. return eval(expression) == delValue;
  4390. });
  4391. opts.onSubRowItemDelete(deleted[0]);
  4392. }
  4393. var afterDel = $.grep(data.rows[rowIndex][listElement], function (v, i) {
  4394. var elementTree = valueElement.split('.');
  4395. var firstElement = elementTree[0];
  4396. elementTree.splice(0, 1);
  4397. var lastElement = elementTree.join('.');
  4398. var expression = 'new Object(v["' + firstElement + '"])';
  4399. if (lastElement != "") {
  4400. expression += '.' + lastElement;
  4401. }
  4402. return eval(expression) != delValue;
  4403. });
  4404. data.rows[rowIndex][listElement] = afterDel;
  4405. tableSettings.options.data = data;
  4406. $.data(jq, "cmsXDataTable", tableSettings);
  4407. if (opts.isPostBack) {
  4408. var tableid = table.closest(".easyui-cmsXDataTable").attr("id");
  4409. var tableDataHidden = $("#" + tableid + "_datajson");
  4410. $(tableDataHidden).val(JSON.stringify(data));
  4411. }
  4412. tableSettings.table.find("tr.row[rowIndex=" + rowIndex + "]>td").html(opts.subRowFomatter(data.rows[rowIndex], rowIndex));
  4413. }
  4414. var _clearOrderByAsc = function (jq) {
  4415. var headerTable = $(jq).find('.xDataTableHeader');
  4416. $.each(headerTable.find('th div a'), function (i, v) {
  4417. $(v).attr('asc', '1');
  4418. });
  4419. }
  4420. $.fn.cmsXDataTable = function (_7be, _7bf) {
  4421. if (typeof _7be == "string") {
  4422. var _7c0 = $.fn.cmsXDataTable.methods[_7be];
  4423. if (_7c0) {
  4424. return _7c0(this, _7bf);
  4425. } else {
  4426. return this.cmsXDataTable(_7be, _7bf);
  4427. }
  4428. }
  4429. _7be = _7be || {};
  4430. return this.each(function () {
  4431. var _this = this;
  4432. var cacheData = $.data(_this, "cmsXDataTable");
  4433. if (cacheData) {
  4434. $.extend(cacheData.options, _7be);
  4435. } else {
  4436. cacheData = $.data(_this, "cmsXDataTable", { options: $.extend({}, $.fn.cmsXDataTable.defaults, $.fn.cmsXDataTable.parseOptions(this), _7be) });
  4437. var initCacheData = _init(_this);
  4438. cacheData = $.data(_this, "cmsXDataTable", $.extend({}, cacheData, initCacheData));
  4439. }
  4440. if (cacheData.options.autoLoad) {
  4441. if (cacheData.data && cacheData.data.length > 0) {
  4442. _loadData(this, cacheData.data, false);
  4443. } else {
  4444. var conditionControls = $.grep($("[data-condition='" + this.id + "']"), function(x) {
  4445. var opts = $.parser.parseOptions(x, []);
  4446. return !$(x).closest("ul").attr("dynamicWhere") && opts.value && opts.value != "" && opts.value != "-1";
  4447. });
  4448. var isReady = true;
  4449. $.each(conditionControls, function (i, x) {
  4450. var isCombobox = $(x).hasClass('easyui-combobox');
  4451. var isComboGrid = $(x).hasClass('easyui-combogridX');
  4452. var comboboxData = $.data(x, 'combobox');
  4453. var combogridData = $.data(x, 'combogridX');
  4454. if (!isCombobox && !isComboGrid) {
  4455. return true;
  4456. }
  4457. if (isCombobox && !comboboxData) {
  4458. isReady = false;
  4459. return false;
  4460. }
  4461. if (isComboGrid && !combogridData) {
  4462. isReady = false;
  4463. return false;
  4464. }
  4465. if (comboboxData) {
  4466. if (comboboxData.options.value && comboboxData.options.value != ''
  4467. && comboboxData.options.value != '-1' && $(x).next().find(".combo-value").val() == "") {
  4468. isReady = false;
  4469. return false;
  4470. } else {
  4471. return true;
  4472. }
  4473. } else {
  4474. if (combogridData.options.value && combogridData.options.value != '' && combogridData.options.value != -1
  4475. && combogridData.options.text != '' && $(x).attr("loaded") != "true") {
  4476. isReady = false;
  4477. return false;
  4478. } else {
  4479. return true;
  4480. }
  4481. }
  4482. });
  4483. if (isReady && $(this).length > 0 && $.data(this, "cmsXDataTable")) {
  4484. var opts = $.data(this, "cmsXDataTable").options;
  4485. opts.pageNumber = 1;
  4486. _load(this, $.getDataGridParams(this.id), false);
  4487. }
  4488. }
  4489. }
  4490. });
  4491. };
  4492. $.fn.cmsXDataTable.methods = {
  4493. options: function (jq) {
  4494. var opts = $.data(jq[0], "cmsXDataTable").options;
  4495. return opts;
  4496. },
  4497. load: function (jq, formData) {
  4498. jq.each(function () {
  4499. var conditionControls = $.grep($("[data-condition='" + this.id + "']"), function(x) {
  4500. var opts = $.parser.parseOptions(x, []);
  4501. return !$(x).closest("ul").attr("dynamicWhere") && opts.value && opts.value != "" && opts.value != "-1";
  4502. });
  4503. var isReady = true;
  4504. $.each(conditionControls, function (i, x) {
  4505. var isCombobox = $(x).hasClass('easyui-combobox');
  4506. var isComboGrid = $(x).hasClass('easyui-combogridX');
  4507. var comboboxData = $.data(x, 'combobox');
  4508. var combogridData = $.data(x, 'combogridX');
  4509. if (!isCombobox && !isComboGrid) {
  4510. return true;
  4511. }
  4512. if (isCombobox && !comboboxData) {
  4513. isReady = false;
  4514. return false;
  4515. }
  4516. if (isComboGrid && !combogridData) {
  4517. isReady = false;
  4518. return false;
  4519. }
  4520. if (comboboxData) {
  4521. if (comboboxData.options.value && comboboxData.options.value != ''
  4522. && comboboxData.options.value != '-1' && $(x).next().find(".combo-value").val() == "") {
  4523. isReady = false;
  4524. return false;
  4525. } else {
  4526. return true;
  4527. }
  4528. } else {
  4529. if (combogridData.options.value && combogridData.options.value != '' && combogridData.options.value != -1
  4530. && combogridData.options.text != '' && $(x).attr("loaded") != "true") {
  4531. isReady = false;
  4532. return false;
  4533. } else {
  4534. return true;
  4535. }
  4536. }
  4537. });
  4538. if (isReady && $(this).length > 0 && $.data(this, "cmsXDataTable")) {
  4539. var opts = $.data(this, "cmsXDataTable").options;
  4540. opts.pageNumber = 1;
  4541. _load(this, formData, false);
  4542. }
  4543. });
  4544. },
  4545. clearOrderByAsc: function (jq) {
  4546. jq.each(function () {
  4547. _clearOrderByAsc(this);
  4548. });
  4549. },
  4550. loadNextPage: function (jq) {
  4551. jq.each(function () {
  4552. var opts = $.data(this, "cmsXDataTable").options;
  4553. if (opts.data) {
  4554. if (opts.pagerType == 0) {
  4555. if ((opts.pageNumber - 1) * opts.pageSize + opts.data.rows.length < opts.data.total) {
  4556. opts.pageNumber += 1;
  4557. _load(this, opts.queryParams, false);
  4558. }
  4559. } else if (opts.pagerType == 1) {
  4560. if (opts.data.rows.length < opts.data.total) {
  4561. opts.pageNumber += 1;
  4562. _load(this, opts.queryParams, false);
  4563. }
  4564. }
  4565. }
  4566. });
  4567. },
  4568. loadAll: function (jq, formData) {
  4569. jq.each(function () {
  4570. var opts = $.data(this, "cmsXDataTable").options;
  4571. opts.pageNumber = 1;
  4572. _load(this, formData, true);
  4573. });
  4574. },
  4575. reload: function (jq) {
  4576. jq.each(function () {
  4577. var opts = $.data(this, "cmsXDataTable").options;
  4578. opts.pageNumber = 1;
  4579. _load(this, null, true);
  4580. });
  4581. },
  4582. orderLoad: function (jq, orderby) {
  4583. jq.each(function () {
  4584. var opts = $.data(this, "cmsXDataTable").options;
  4585. opts.pageNumber = 1;
  4586. _load(this, null, true, orderby.field, orderby.isAsc);
  4587. });
  4588. },
  4589. loadData: function (jq, data) {
  4590. jq.each(function () {
  4591. var opts = $.data(this, "cmsXDataTable").options;
  4592. opts.pageNumber = 1;
  4593. _loadData(this, data, true);
  4594. });
  4595. },
  4596. getRowDataByObj: function (jq, obj) {
  4597. return _getRowDataByObj(jq[0], obj);
  4598. },
  4599. getRows: function (jq) {
  4600. return _getRows(jq[0]);
  4601. },
  4602. getTotal: function (jq) {
  4603. return _getTotal(jq[0]);
  4604. },
  4605. getSelections: function (jq) {
  4606. return _getSelections(jq[0]);
  4607. },
  4608. clearSelections: function (jq) {
  4609. jq.each(function () {
  4610. _clearSelections(this);
  4611. });
  4612. },
  4613. deleteSubRowItem: function (jq, delData) {
  4614. jq.each(function () {
  4615. _deleteSubRowItem(this, delData);
  4616. }
  4617. );
  4618. },
  4619. setDataValueByIndex: function (jq, parameters) {
  4620. var rowIndex = parameters.rowIndex;
  4621. var columnName = parameters.columnName;
  4622. var newValue = parameters.newValue;
  4623. jq.each(function () {
  4624. var opts = $.data(this, "cmsXDataTable").options;
  4625. var table = $.data(this, "cmsXDataTable").table;
  4626. var columnList = $.data(this, "cmsXDataTable").columnList;
  4627. var columnOptsList = $.grep(columnList, function (x) { return x.field == columnName; });
  4628. var columnOpts = null;
  4629. if (columnOptsList.length > 0) {
  4630. columnOpts = $.grep(columnList, function (x) { return x.field == columnName; })[0];
  4631. }
  4632. _changeDataJson(table, rowIndex, columnName, newValue, columnOpts);
  4633. });
  4634. },
  4635. calMaxSize: function (jq) {
  4636. jq.each(function() {
  4637. _calMaxSize(this);
  4638. });
  4639. }
  4640. };
  4641. $.fn.cmsXDataTable.parseOptions = function (_7c7) {
  4642. var t = $(_7c7);
  4643. return $.extend({}, $.fn.cmsXDataTable.defaults, $.parser.parseOptions(_7c7, []));
  4644. };
  4645. $.fn.cmsXDataTable.column = {
  4646. defaults: {
  4647. defaultValue: '&nbsp;',
  4648. field: '',
  4649. formatter: function (value, row, index) {
  4650. return value;
  4651. }
  4652. }
  4653. };
  4654. $.fn.cmsXDataTable.defaults = {
  4655. pageNumber: 1,
  4656. pageSize: 10,
  4657. loadMsg: "努力加载中...",
  4658. emptyMsg: "",
  4659. pagination: true,
  4660. autoLoad: true,
  4661. rowHighlightColor: null,
  4662. isMouseOverHighlight: false,
  4663. RowHighlightFun: "true",
  4664. isAutoHeight: true,
  4665. onSubRowItemDelete: null,
  4666. checkOnSelect: true,
  4667. rowStyle: function (index, row) {
  4668. },
  4669. onLoadSuccess: function (data) {
  4670. },
  4671. onLoadError: function () {
  4672. },
  4673. onBeforeLoad: function (param) {
  4674. },
  4675. //暂未实现
  4676. onClickRow: function (rowIndex, rowData) {
  4677. },
  4678. //暂未实现
  4679. onDblClickRow: function (rowIndex, rowData) {
  4680. },
  4681. //暂未实现
  4682. onClickCell: function (rowIndex, field, value) {
  4683. },
  4684. //暂未实现
  4685. onDblClickCell: function (rowIndex, field, value) {
  4686. }
  4687. };
  4688. $(window).resize(function () {
  4689. $(".cmsXDataTable").cmsXDataTable("calMaxSize");
  4690. });
  4691. })(jQuery);
  4692. //2014-02-28 end added by pengbb 新增cmsXDataTable
  4693. //2014-03-25 begin added by pengbb 新增cmsPanel控件
  4694. (function ($) {
  4695. $.parser.plugins.push("cmsPanel");
  4696. function _init(jq) {
  4697. var opts = $.data(jq, "cmsPanel").options;
  4698. var _jqThis = $(jq);
  4699. var isIE6 = false;
  4700. if ($.browser.msie) {
  4701. if ($.browser.version < 7) {
  4702. isIE6 = true;
  4703. }
  4704. }
  4705. var btnCollapsable = _jqThis.find(">div.panel-header>div.panel-tool>a.cmspanel-tool-collapse");
  4706. btnCollapsable.unbind(".cmsPanel");
  4707. btnCollapsable.bind("click.cmsPanel", function () {
  4708. var _this = $(this);
  4709. if (_this.hasClass("panel-tool-expand")) {
  4710. _this.removeClass("panel-tool-expand");
  4711. if (isIE6) {
  4712. _jqThis.find("div.panel-body").show();
  4713. } else {
  4714. _jqThis.find("div.panel-body").slideDown();
  4715. }
  4716. if (typeof (opts.onExpanded) == "function") {
  4717. opts.onExpanded.call(jq);
  4718. }
  4719. } else {
  4720. _this.addClass("panel-tool-expand");
  4721. if (isIE6) {
  4722. _jqThis.find("div.panel-body").hide();
  4723. } else {
  4724. _jqThis.find("div.panel-body").slideUp();
  4725. }
  4726. if (typeof (opts.onExpanded) == "function") {
  4727. opts.onCollapsed.call(jq);
  4728. }
  4729. }
  4730. });
  4731. return { cmsPanel: jq };
  4732. }
  4733. $.fn.cmsPanel = function (_7be, _7bf) {
  4734. if (typeof _7be == "string") {
  4735. var _7c0 = $.fn.cmsPanel.methods[_7be];
  4736. if (_7c0) {
  4737. return _7c0(this, _7bf);
  4738. } else {
  4739. return this.cmsPanel(_7be, _7bf);
  4740. }
  4741. }
  4742. _7be = _7be || {};
  4743. return this.each(function () {
  4744. var _this = this;
  4745. var cacheData = $.data(_this, "cmsPanel");
  4746. if (cacheData) {
  4747. $.extend(cacheData.options, _7be);
  4748. } else {
  4749. cacheData = $.data(_this, "cmsPanel", { options: $.extend({}, $.fn.cmsPanel.defaults, $.fn.cmsPanel.parseOptions(this), _7be) });
  4750. var initCacheData = _init(_this);
  4751. cacheData = $.data(_this, "cmsPanel", $.extend({}, cacheData, initCacheData));
  4752. }
  4753. });
  4754. };
  4755. $.fn.cmsPanel.methods = {
  4756. options: function (jq) {
  4757. var opts = $.data(jq[0], "cmsPanel").options;
  4758. return opts;
  4759. }
  4760. };
  4761. $.fn.cmsPanel.parseOptions = function (_7c7) {
  4762. var t = $(_7c7);
  4763. return $.extend({}, $.fn.cmsPanel.defaults, $.parser.parseOptions(_7c7, []));
  4764. };
  4765. $.fn.cmsPanel.defaults = {
  4766. onExpanded: function () {
  4767. },
  4768. onCollapsed: function () {
  4769. }
  4770. };
  4771. })(jQuery);
  4772. //2014-03-25 end added by pengbb 新增cmspanel控件
  4773. //2014-03-25 begin added by pengbb 新增cmsMenu控件
  4774. (function ($) {
  4775. $.parser.plugins.push("cmsMenu");
  4776. var isIE6 = false;
  4777. if ($.browser.msie) {
  4778. if ($.browser.version < 7) {
  4779. isIE6 = true;
  4780. }
  4781. }
  4782. function _onMenuClick(jq, clickMenu) {
  4783. var opts = $.data(jq, "cmsMenu").options;
  4784. var _this = $(clickMenu);
  4785. var node = { text: _this.attr("menuTitle"), url: _this.attr("menuUrl"), mnuNo: _this.attr("menuNo") };
  4786. if (typeof (opts.onMenuClick) == "function") {
  4787. opts.onMenuClick.call(jq, node);
  4788. }
  4789. }
  4790. function _toggleChildMenu(currMenu) {
  4791. var menuItemPanel = $(currMenu);
  4792. if (!menuItemPanel.hasClass('nav_left_menuitem_expand')) {
  4793. menuItemPanel.closest("li").siblings("li").removeClass('gradient');
  4794. menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_expand').find(".nav_left_menuitem_right>div").removeClass('down_arrow');
  4795. menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_expand').removeClass('nav_left_menuitem_expand');
  4796. menuItemPanel.closest("li").siblings("li").find('>div.nav_left_menuitem_childpanel').slideUp("normal");
  4797. menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideDown("normal");
  4798. menuItemPanel.closest("li").addClass('gradient');
  4799. menuItemPanel.addClass('nav_left_menuitem_expand');
  4800. menuItemPanel.find(".nav_left_menuitem_right>div").addClass('down_arrow');
  4801. } else {
  4802. menuItemPanel.closest("li").removeClass('gradient');
  4803. menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideUp("normal");
  4804. menuItemPanel.removeClass('nav_left_menuitem_expand');
  4805. menuItemPanel.find(".nav_left_menuitem_right>div").removeClass('down_arrow');
  4806. }
  4807. }
  4808. function _toggleSecondChildMenu(currMenu) {
  4809. var menuItemPanel = $(currMenu);
  4810. if (!menuItemPanel.hasClass('nav_left_menuitem_second_expand')) {
  4811. menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_second_expand').find(".node_plus").removeClass('node_minus');
  4812. menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_second_expand').next().next('div.nav_left_menuitem_childpanel').slideUp("normal");
  4813. menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_second_expand').removeClass('nav_left_menuitem_second_expand');
  4814. menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideDown("normal");
  4815. menuItemPanel.addClass('nav_left_menuitem_second_expand');
  4816. menuItemPanel.find(".node_plus").addClass('node_minus');
  4817. } else {
  4818. menuItemPanel.removeClass('nav_left_menuitem_second_expand');
  4819. menuItemPanel.find(".node_plus").removeClass('node_minus');
  4820. menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideUp("normal");
  4821. }
  4822. }
  4823. function _toggleThirdChildMenu(currMenu) {
  4824. // var menuItemPanel = $(currMenu);
  4825. // if (!menuItemPanel.hasClass('nav_left_menuitem_third_expand')) {
  4826. //
  4827. // //menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_third_expand').find(".node_plus").removeClass('node_minus');
  4828. // menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_third_expand').removeClass('nav_left_menuitem_second_expand');
  4829. // menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_third_expand').slideUp("normal");
  4830. // menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideDown("normal");
  4831. // menuItemPanel.addClass('nav_left_menuitem_third_expand');
  4832. // //menuItemPanel.find(".node_plus").addClass('node_minus');
  4833. // } else {
  4834. //
  4835. // menuItemPanel.removeClass('nav_left_menuitem_third_expand');
  4836. // //menuItemPanel.find(".node_plus").removeClass('node_minus');
  4837. // menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideUp("normal");
  4838. // }
  4839. }
  4840. function _init(jq) {
  4841. var opts = $.data(jq, "cmsMenu").options;
  4842. var _jqThis = $(jq);
  4843. //一级菜单
  4844. _jqThis.find(".nav_left_menuitem").unbind(".cmsMenu");
  4845. _jqThis.find(".nav_left_menuitem").bind("click.cmsMenu",
  4846. function (event) {
  4847. _toggleChildMenu(this);
  4848. _onMenuClick(jq, $(this).find(".nav_left_menuitem_link"));
  4849. return false;
  4850. }
  4851. );
  4852. //二级菜单
  4853. _jqThis.find(".nav_left_menuitem_second").unbind(".cmsMenu");
  4854. _jqThis.find(".nav_left_menuitem_second").bind("click.cmsMenu",
  4855. function (event) {
  4856. _toggleSecondChildMenu(this);
  4857. _onMenuClick(jq, $(this).find(".nav_left_menuitem_link"));
  4858. return false;
  4859. }
  4860. );
  4861. //二级菜单hover效果
  4862. _jqThis.find(".nav_left_menuitem_second").bind("mouseenter.cmsMenu", function () {
  4863. if (!$(this).hasClass("nav_left_menuitem_second_hover")) {
  4864. $(this).addClass("nav_left_menuitem_second_hover");
  4865. }
  4866. });
  4867. _jqThis.find(".nav_left_menuitem_second").bind("mouseleave.cmsMenu", function () {
  4868. if ($(this).hasClass("nav_left_menuitem_second_hover")) {
  4869. $(this).removeClass("nav_left_menuitem_second_hover");
  4870. }
  4871. });
  4872. //三级菜单
  4873. _jqThis.find(".nav_left_menuitem_third").unbind(".cmsMenu");
  4874. _jqThis.find(".nav_left_menuitem_third").bind("click.cmsMenu",
  4875. function (event) {
  4876. _toggleThirdChildMenu(this);
  4877. _onMenuClick(jq, $(this).find(".nav_left_menuitem_link"));
  4878. return false;
  4879. }
  4880. );
  4881. //三级菜单hover效果
  4882. _jqThis.find(".nav_left_menuitem_third").bind("mouseenter.cmsMenu", function () {
  4883. if (!$(this).hasClass("nav_left_menuitem_third_hover")) {
  4884. $(this).addClass("nav_left_menuitem_third_hover");
  4885. }
  4886. });
  4887. _jqThis.find(".nav_left_menuitem_third").bind("mouseleave.cmsMenu", function () {
  4888. if ($(this).hasClass("nav_left_menuitem_third_hover")) {
  4889. $(this).removeClass("nav_left_menuitem_third_hover");
  4890. }
  4891. });
  4892. return { cmsMenu: jq };
  4893. }
  4894. $.fn.cmsMenu = function (_7be, _7bf) {
  4895. if (typeof _7be == "string") {
  4896. var _7c0 = $.fn.cmsMenu.methods[_7be];
  4897. if (_7c0) {
  4898. return _7c0(this, _7bf);
  4899. } else {
  4900. return this.cmsMenu(_7be, _7bf);
  4901. }
  4902. }
  4903. _7be = _7be || {};
  4904. return this.each(function () {
  4905. var _this = this;
  4906. var cacheData = $.data(_this, "cmsMenu");
  4907. if (cacheData) {
  4908. $.extend(cacheData.options, _7be);
  4909. } else {
  4910. cacheData = $.data(_this, "cmsMenu", { options: $.extend({}, $.fn.cmsMenu.defaults, $.fn.cmsMenu.parseOptions(this), _7be) });
  4911. var initCacheData = _init(_this);
  4912. cacheData = $.data(_this, "cmsMenu", $.extend({}, cacheData, initCacheData));
  4913. }
  4914. });
  4915. };
  4916. $.fn.cmsMenu.methods = {
  4917. options: function (jq) {
  4918. var opts = $.data(jq[0], "cmsMenu").options;
  4919. return opts;
  4920. }
  4921. };
  4922. $.fn.cmsMenu.parseOptions = function (_7c7) {
  4923. var t = $(_7c7);
  4924. return $.extend({}, $.fn.cmsPanel.defaults, $.parser.parseOptions(_7c7, []));
  4925. };
  4926. $.fn.cmsMenu.defaults = {
  4927. onMenuClick: function (node) { }
  4928. };
  4929. })(jQuery);
  4930. //2014-04-21 end added by pengbb 新增cmsMenu控件
  4931. //2014-06-26 begin added by heyw 新增autoComplete控件
  4932. (function ($) {
  4933. $.parser.plugins.push("autoComplete");
  4934. function _init(jq) {
  4935. var opts = $.data(jq, "autoComplete").options;
  4936. var top = 10;
  4937. var _jqThis = $(jq);
  4938. var isIE6 = false;
  4939. if ($.browser.msie) {
  4940. if ($.browser.version < 7) {
  4941. isIE6 = true;
  4942. }
  4943. }
  4944. var mainBox = _jqThis;
  4945. var valueBox = $("#" + _jqThis.attr("id") + "_value");
  4946. $(mainBox).autocomplete(opts.url, {
  4947. max: top,
  4948. minChars: 1,
  4949. width: opts.width,
  4950. scrollHeight: opts.scrollHeight,
  4951. matchContains: opts.matchContains,
  4952. mustMatch: opts.mustMatch,
  4953. cacheLength: 50, //1- 无缓存
  4954. autoFill: opts.autoFill,
  4955. dataType: 'json',
  4956. parse: function (data) {
  4957. var parsed = [];
  4958. for (var i = 0; i < data.length; i++) {
  4959. parsed[parsed.length] = {
  4960. data: data[i],
  4961. value: data[i][opts.valueField].toString(),
  4962. result: data[i][opts.textField]
  4963. };
  4964. }
  4965. return parsed;
  4966. },
  4967. formatItem: opts.formatter,
  4968. formatMatch: function (row, i, max) {
  4969. return row[opts.textField];
  4970. },
  4971. formatResult: function (row) {
  4972. $(valueBox).val(row[opts.valueField]);
  4973. return row[opts.textField];
  4974. }
  4975. });
  4976. if ($(valueBox).val())
  4977. mainBox[0].setDefaultValue($(valueBox).val(), opts.textField, opts.valueField);
  4978. return { autoComplete: jq };
  4979. }
  4980. $.fn.autoComplete = function (_7be, _7bf) {
  4981. if (typeof _7be == "string") {
  4982. var _7c0 = $.fn.autoComplete.methods[_7be];
  4983. if (_7c0) {
  4984. return _7c0(this, _7bf);
  4985. } else {
  4986. return this.autoComplete(_7be, _7bf);
  4987. }
  4988. }
  4989. _7be = _7be || {};
  4990. return this.each(function () {
  4991. var _this = this;
  4992. var cacheData = $.data(_this, "autoComplete");
  4993. if (cacheData) {
  4994. $.extend(cacheData.options, _7be);
  4995. } else {
  4996. cacheData = $.data(_this, "autoComplete", { options: $.extend({}, $.fn.autoComplete.defaults, $.fn.autoComplete.parseOptions(this), _7be) });
  4997. var initCacheData = _init(_this);
  4998. cacheData = $.data(_this, "autoComplete", $.extend({}, cacheData, initCacheData));
  4999. }
  5000. });
  5001. };
  5002. $.fn.autoComplete.methods = {
  5003. options: function (jq) {
  5004. var opts = $.data(jq[0], "autoComplete").options;
  5005. return opts;
  5006. },
  5007. setDefaultValue: function (jq, value) {
  5008. }
  5009. };
  5010. $.fn.autoComplete.parseOptions = function (_7c7) {
  5011. var t = $(_7c7);
  5012. return $.extend({}, $.fn.autoComplete.defaults, $.parser.parseOptions(_7c7, []));
  5013. };
  5014. $.fn.autoComplete.defaults = {
  5015. width: 600,
  5016. scrollHeight: 380,
  5017. matchContains: true,
  5018. mustMatch: true,
  5019. autoFill: false,
  5020. url: "",
  5021. textField: "",
  5022. valueField: "",
  5023. defaltValue: "",
  5024. formatter: function (row, i, max) {
  5025. return i;
  5026. }
  5027. };
  5028. })(jQuery);
  5029. //2014-06-26 begin added by heyw 新增autoComplete控件
  5030. //2014-08-13 begin added by heyw 新增draggableList控件
  5031. (function ($) {
  5032. $.parser.plugins.push("draggableList");
  5033. function _init(jq) {
  5034. var opts = $.data(jq, "draggableList").options;
  5035. var listID = jq.id;
  5036. var div = $("<div></div>").appendTo(jq);
  5037. $.ajax({
  5038. type: "post", url: opts.url, success: function (data) {
  5039. var length = 0;
  5040. $.each(data, function () {
  5041. var htmlList = new Array();
  5042. var className = listID + "_" + this[opts.valueField];
  5043. htmlList.push("<div class=\"easyui-draggable " + className + "\" style=\"cursor: pointer; height: " + opts.itemHeight + "px; line-height: " + opts.itemHeight + "px; float: left;\">");
  5044. if (opts.iconField && opts.iconField != "") {
  5045. htmlList.push("<img style=\"margin-left: 2px; margin-top: 2px; margin-bottom: 2px; float: left;\" src=\"" + this[opts.iconField] + "\" border=\"0\" />");
  5046. }
  5047. htmlList.push("<div class=\"draggableTitle\" style=\"margin-left: 2px; margin-top: 2px; margin-bottom: 2px; color: " + opts.foreColor + "; position: relative; float: left;\" value=\"" + this[opts.valueField] + "\">" + this[opts.titleField] + "</div>");
  5048. htmlList.push("</div>");
  5049. var itemElement = $(htmlList.join(""));
  5050. itemElement.appendTo(div);
  5051. length += itemElement.width();
  5052. $("." + className).draggable({
  5053. handle: ".draggableTitle",
  5054. proxy: "clone",
  5055. revert: true,
  5056. onDrag: function (e) {
  5057. CMSFunction.DragDrop.dragX = e.clientX;
  5058. CMSFunction.DragDrop.dragY = e.clientY;
  5059. },
  5060. onBeforeDrag: function (e) {
  5061. CMSFunction.DragDrop.isInnerDrag = false;
  5062. CMSFunction.DragDrop.offsetX = e.offsetX + e.srcElement.offsetLeft - e.srcElement.parentElement.offsetLeft;
  5063. CMSFunction.DragDrop.offsetY = e.offsetY + e.srcElement.offsetTop - e.srcElement.parentElement.offsetTop;
  5064. }
  5065. });
  5066. });
  5067. div.width(length);
  5068. //$(jq).height(opts.itemHeight + 16);
  5069. }
  5070. });
  5071. return { draggableList: jq };
  5072. }
  5073. $.fn.draggableList = function (_7be, _7bf) {
  5074. if (typeof _7be == "string") {
  5075. var _7c0 = $.fn.draggableList.methods[_7be];
  5076. if (_7c0) {
  5077. return _7c0(this, _7bf);
  5078. } else {
  5079. return this.draggableList(_7be, _7bf);
  5080. }
  5081. }
  5082. _7be = _7be || {};
  5083. return this.each(function () {
  5084. var _this = this;
  5085. var cacheData = $.data(_this, "draggableList");
  5086. if (cacheData) {
  5087. $.extend(cacheData.options, _7be);
  5088. } else {
  5089. cacheData = $.data(_this, "draggableList", { options: $.extend({}, $.fn.draggableList.defaults, $.fn.draggableList.parseOptions(this), _7be) });
  5090. var initCacheData = _init(_this);
  5091. cacheData = $.data(_this, "draggableList", $.extend({}, cacheData, initCacheData));
  5092. }
  5093. });
  5094. };
  5095. $.fn.draggableList.methods = {
  5096. options: function (jq) {
  5097. var opts = $.data(jq[0], "draggableList").options;
  5098. return opts;
  5099. },
  5100. setDefaultValue: function (jq, value) {
  5101. }
  5102. };
  5103. $.fn.draggableList.parseOptions = function (_7c7) {
  5104. var t = $(_7c7);
  5105. return $.extend({}, $.fn.draggableList.defaults, $.parser.parseOptions(_7c7, []));
  5106. };
  5107. $.fn.draggableList.defaults = {
  5108. url: "",
  5109. titleField: "",
  5110. valueField: "",
  5111. iconField: "",
  5112. itemHeight: 0,
  5113. foreColor: "#000000"
  5114. };
  5115. })(jQuery);
  5116. //2014-08-13 begin added by heyw 新增draggableList控件
  5117. //2014-08-18 begin added by heyw 新增droppableContainer控件
  5118. (function ($) {
  5119. $.parser.plugins.push("droppableContainer");
  5120. function _init(jq) {
  5121. var opts = $.data(jq, "droppableContainer").options;
  5122. var listID = jq.id;
  5123. var myLeft = jq.clientLeft;
  5124. var myTop = jq.clientTop;
  5125. var myWidth = jq.clientWidth;
  5126. var myHeight = jq.clientHeight;
  5127. document.body.oncontextmenu = function (e) {
  5128. e = e || window.event;
  5129. var target = e.target || e.srcElement;
  5130. if (($(target).hasClass("easyui-draggable") && $(target).parent().hasClass("easyui-droppableContainer"))
  5131. || ($(target).parent().hasClass("easyui-draggable") && $(target).parent().parent().hasClass("easyui-droppableContainer"))) {
  5132. CMSFunction.DragDrop.DropContainerItemClick(e);
  5133. return false;
  5134. }
  5135. }
  5136. if (opts.url && opts.url != "") {
  5137. $.ajax({
  5138. type: "post", url: opts.url, success: function (data) {
  5139. $.each(data, function () {
  5140. var htmlList = new Array();
  5141. var className = listID + "_" + this[opts.valueField];
  5142. htmlList.push("<div class=\"easyui-draggable " + className + "\" style=\"cursor: pointer; position: absolute; height: " + opts.itemHeight + "px; line-height: " + opts.itemHeight + "px; float: left; left: " + this[opts.leftField] + "px; top: " + this[opts.topField] + "px; \">");
  5143. if (opts.iconField && opts.iconField != "") {
  5144. htmlList.push("<img style=\"margin-top: 2px; margin-bottom: 2px; margin-left: 2px; float: left;\" border=\"0\" src=\"" + this[opts.iconField] + "\">");
  5145. }
  5146. htmlList.push("<div class=\"draggableTitle\" style=\"color: " + opts.foreColor + "; margin-left: 2px; margin-top: 2px; margin-bottom: 2px; float: left;\" value=\"" + this[opts.valueField] + "\">" + this[opts.titleField] + "</div>");
  5147. htmlList.push("</div>");
  5148. $(htmlList.join("")).appendTo(jq);
  5149. $("." + className).draggable({
  5150. handle: ".draggableTitle",
  5151. onDrag: function (e) {
  5152. CMSFunction.DragDrop.dragX = e.clientX;
  5153. CMSFunction.DragDrop.dragY = e.clientY;
  5154. },
  5155. onBeforeDrag: function (e) {
  5156. CMSFunction.DragDrop.isInnerDrag = true;
  5157. CMSFunction.DragDrop.offsetX = e.offsetX;
  5158. CMSFunction.DragDrop.offsetY = e.offsetY;
  5159. },
  5160. onStopDrag: function (e) {
  5161. if (e.clientX < myLeft || e.clientX > myLeft + myWidth || e.clientY < myTop || e.clientY > myTop + myHeight) {
  5162. $(e.srcElement).offsetParent().remove();
  5163. }
  5164. }
  5165. });
  5166. });
  5167. }
  5168. });
  5169. }
  5170. else if (opts.items && opts.items.length > 0) {
  5171. $.each(opts.items, function () {
  5172. var htmlList = new Array();
  5173. var className = listID + "_" + this.value;
  5174. htmlList.push("<div class=\"easyui-draggable " + className + "\" style=\"cursor: pointer; position: absolute; height: " + opts.itemHeight + "px; line-height: " + opts.itemHeight + "px; float: left; left: " + this.left + "px; top: " + this.top + "px; \">");
  5175. if (this.icon && this.icon != "") {
  5176. htmlList.push("<img style=\"margin-top: 2px; margin-bottom: 2px; margin-left: 2px; float: left;\" border=\"0\" src=\"" + this.icon + "\">");
  5177. }
  5178. htmlList.push("<div class=\"draggableTitle\" style=\"color: " + opts.foreColor + "; margin-left: 2px; margin-top: 2px; margin-bottom: 2px; float: left;\" value=\"" + this.value + "\">" + this.title + "</div>");
  5179. htmlList.push("</div>");
  5180. $(htmlList.join("")).appendTo(jq);
  5181. $("." + className).draggable({
  5182. handle: ".draggableTitle",
  5183. onDrag: function (e) {
  5184. CMSFunction.DragDrop.dragX = e.clientX;
  5185. CMSFunction.DragDrop.dragY = e.clientY;
  5186. },
  5187. onBeforeDrag: function (e) {
  5188. CMSFunction.DragDrop.isInnerDrag = true;
  5189. CMSFunction.DragDrop.offsetX = e.offsetX;
  5190. CMSFunction.DragDrop.offsetY = e.offsetY;
  5191. },
  5192. onStopDrag: function (e) {
  5193. if (e.clientX < myLeft || e.clientX > myLeft + myWidth || e.clientY < myTop || e.clientY > myTop + myHeight) {
  5194. $(e.srcElement).offsetParent().remove();
  5195. }
  5196. }
  5197. });
  5198. });
  5199. }
  5200. $(jq).droppable({});
  5201. var hidden = $(jq).next();
  5202. hidden.val('');
  5203. $.each($(jq).find('.easyui-draggable'), function () {
  5204. var valStr = '';
  5205. if (hidden.val() != '') valStr = ',';
  5206. var titleDiv = $(this).find('.draggableTitle');
  5207. valStr += titleDiv.attr('value') + '|' + titleDiv.html() + '|' + $(this).css('left').replace("px", "") + '|' + $(this).css('top').replace("px", "");
  5208. hidden.val(hidden.val() + valStr);
  5209. });
  5210. return { droppableContainer: jq };
  5211. }
  5212. $.fn.droppableContainer = function (_7be, _7bf) {
  5213. if (typeof _7be == "string") {
  5214. var _7c0 = $.fn.droppableContainer.methods[_7be];
  5215. if (_7c0) {
  5216. return _7c0(this, _7bf);
  5217. } else {
  5218. return this.droppableContainer(_7be, _7bf);
  5219. }
  5220. }
  5221. _7be = _7be || {};
  5222. return this.each(function () {
  5223. var _this = this;
  5224. var cacheData = $.data(_this, "droppableContainer");
  5225. if (cacheData) {
  5226. $.extend(cacheData.options, _7be);
  5227. } else {
  5228. cacheData = $.data(_this, "droppableContainer", { options: $.extend({}, $.fn.droppableContainer.defaults, $.fn.droppableContainer.parseOptions(this), _7be) });
  5229. var initCacheData = _init(_this);
  5230. cacheData = $.data(_this, "droppableContainer", $.extend({}, cacheData, initCacheData));
  5231. }
  5232. });
  5233. };
  5234. $.fn.droppableContainer.methods = {
  5235. options: function (jq) {
  5236. var opts = $.data(jq[0], "droppableContainer").options;
  5237. return opts;
  5238. },
  5239. getContainerItems: function (jq) {
  5240. var hidden = jq.next();
  5241. var valStr = hidden.val();
  5242. var items = valStr.split(',');
  5243. var result = new Array();
  5244. $.each(items, function () {
  5245. var colVals = this.split('|');
  5246. result.push({
  5247. Icon: null,
  5248. Value: colVals[0],
  5249. Title: colVals[1],
  5250. Left: parseInt(colVals[2]),
  5251. Top: parseInt(colVals[3])
  5252. });
  5253. });
  5254. return result;
  5255. }
  5256. };
  5257. $.fn.droppableContainer.parseOptions = function (_7c7) {
  5258. var t = $(_7c7);
  5259. return $.extend({}, $.fn.droppableContainer.defaults, $.parser.parseOptions(_7c7, []));
  5260. };
  5261. $.fn.droppableContainer.defaults = {
  5262. title: "",
  5263. value: "",
  5264. icon: "",
  5265. height: 0,
  5266. foreColor: "#000000"
  5267. };
  5268. })(jQuery);
  5269. //2014-08-18 begin added by heyw 新增droppableContainer控件
  5270. //2015-12-08 begin added by heyw 新增combogridX控件
  5271. (function ($) {
  5272. $.parser.plugins.push("combogridX");
  5273. function _init(jq) {
  5274. var opts = $.data(jq, "combogridX").options;
  5275. var bubbleKeyup = true;
  5276. var oldValue;
  5277. var lastScoreHeight = 0;
  5278. var expander = $(jq).find(".combogridX-expander");
  5279. if (opts.panelWidth) {
  5280. $(expander).width(opts.panelWidth);
  5281. }
  5282. $(document).click(function () {
  5283. if ($(event.srcElement).parents(".easyui-combogridX").length == 0) {
  5284. $('.combogridX-expander').css("display", "none");
  5285. }
  5286. });
  5287. var gridTable = $(jq).find('.easyui-cmsXDataTable');
  5288. var beforeScrollTop = $(gridTable).scrollTop();
  5289. $(expander).scroll(function (event) {
  5290. event = event || window.event;
  5291. var afterScrollTop = $(gridTable).scrollTop;
  5292. delta = afterScrollTop - beforeScrollTop;
  5293. beforeScrollTop = afterScrollTop;
  5294. var scrollTop = $(this).scrollTop();
  5295. var scrollHeight = $(gridTable).height();
  5296. var windowHeight = $(this).height();
  5297. if (scrollTop + windowHeight >= (scrollHeight - 10) && lastScoreHeight != scrollHeight) { //滚动到底部执行事件
  5298. lastScoreHeight = scrollHeight;
  5299. gridTable.cmsXDataTable("loadNextPage");
  5300. return;
  5301. }
  5302. });
  5303. $(jq).find(".combo-arrow").mouseover(function () {
  5304. $(this).addClass("combogridX-arrow-hover");
  5305. });
  5306. $(jq).find(".combo-arrow").mouseout(function () {
  5307. $(this).removeClass("combogridX-arrow-hover");
  5308. });
  5309. $(jq).find(".combo-clear").mouseover(function () {
  5310. $(this).addClass("combo-clear-hover");
  5311. });
  5312. $(jq).find(".combo-clear").mouseout(function () {
  5313. $(this).removeClass("combo-clear-hover");
  5314. });
  5315. var comboText = $(jq).find(".combo-text");
  5316. var controlWidth = comboText.width() + 4;
  5317. if ($(jq).attr("width")) {
  5318. controlWidth = parseInt($(jq).attr("width"));
  5319. }
  5320. comboText.width(controlWidth - 36 - 3);
  5321. $(jq).width(controlWidth);
  5322. $(jq).find(".combo-arrow").offset({
  5323. top: $(jq).find(".combo-arrow").offset().top,
  5324. left: $(jq).find(".combo-arrow").offset().left + 18
  5325. });
  5326. if (comboText.attr("placeholder") && $(jq).attr("placeholder") != "") {
  5327. comboText.placeholder();
  5328. }
  5329. //设置相应事件
  5330. if (opts.enabled == true) {
  5331. $(jq).find(".combo-arrow").click(function () {
  5332. var dropdown = $(this).parents('.easyui-combogridX:first');
  5333. var expander = dropdown.find(".combogridX-expander");
  5334. var display = expander.css("display");
  5335. $('.combogridX-expander').css("display", "none");
  5336. if (display == "none") {
  5337. _showExpander(expander, dropdown, $(this));
  5338. }
  5339. else expander.css("display", "none");
  5340. });
  5341. $(jq).find(".combo-clear").click(function () {
  5342. var dropdown = $(this).parents('.easyui-combogridX:first');
  5343. var comboText = dropdown.find(".combo-text");
  5344. CMSFunction.ComboGrid.SetValue(dropdown, "", "-1");
  5345. if (opts.isAutoComplete) {
  5346. _autoComplete(comboText, true, oldValue, { keyCode: 8 });
  5347. }
  5348. $('.combogridX-expander').css("display", "none");
  5349. if (opts.onSelect) opts.onSelect.call(this, null);
  5350. });
  5351. }
  5352. if (opts.value != '' && opts.value != -1 && opts.text != '') {
  5353. CMSFunction.ComboGrid.SetValue($(jq), opts.text, opts.value);
  5354. }
  5355. if (opts.isAutoComplete) {
  5356. $(jq).find(".combo-text")
  5357. // .keyup(function (ev) {
  5358. // _autoComplete($(this), bubbleKeyup, oldValue, ev);
  5359. // })
  5360. .keydown(function (ev) {
  5361. // oldValue = $(this).val();
  5362. // if (ev.keyCode == 229) {
  5363. // bubbleKeyup = false;
  5364. // } else {
  5365. // bubbleKeyup = true;
  5366. // }
  5367. var selfControl = $(this);
  5368. clearTimeout(selfControl.timeoutFunc);
  5369. $(this).timeoutFunc = setTimeout(function() {
  5370. _autoComplete(selfControl, bubbleKeyup, null, ev);
  5371. }, 300);
  5372. });
  5373. }
  5374. return { combogridX: jq };
  5375. }
  5376. function _autoComplete(comboText, bubbleKeyup, oldValue, ev) {
  5377. // if (!bubbleKeyup && ev.keyCode != 32 && ev.keyCode != 13
  5378. // && (oldValue.indexOf(comboText.val()) >= 0
  5379. // || (ev.keyCode == 229 && comboText.val().indexOf(oldValue) >= 0)
  5380. // )) {
  5381. // bubbleKeyup = false;
  5382. // return;
  5383. // }
  5384. var dropdown = comboText.parents('.easyui-combogridX:first');
  5385. var grid = dropdown.find('.easyui-cmsXDataTable');
  5386. var opts = $.data(dropdown[0], "combogridX").options;
  5387. var formData = opts.formData;
  5388. if (comboText.val().length >= opts.minReloadCharactor) {
  5389. var expander = dropdown.find(".combogridX-expander");
  5390. var arrow = dropdown.find(".combo-arrow");
  5391. var display = expander.css("display");
  5392. if (display == "none") {
  5393. _showExpander(expander, dropdown, arrow);
  5394. }
  5395. var queryParamString = "";
  5396. if (formData) {
  5397. queryParamString = formData.QueryParamsDatas;
  5398. }
  5399. var queryText = comboText.val();
  5400. if (queryText == opts.emptyText) {
  5401. queryText = "";
  5402. }
  5403. var jsonString = "({'QueryParamsDatas':'Attribute|*|{\"ID\":\"00000000-0000-0000-0000-000000000000\",\"Value\":\"" + opts.textField
  5404. + "\",\"ControlType\":\"TextBox\"}|@|Condition|*|中|@|ConditionValue|*|" + comboText.val()
  5405. + "|@|" + opts.textField + "_QueryTextBox|*|" + queryText + "|@|" + queryParamString + "'})";
  5406. try {
  5407. grid.cmsXDataTable("loadAll", eval(jsonString));
  5408. }
  5409. catch (err) { }
  5410. }
  5411. }
  5412. function _showExpander(expander, dropdown, arrow) {
  5413. expander.css("display", "block");
  5414. _setExpanderPosition(expander, dropdown, arrow);
  5415. }
  5416. function _setExpanderPosition(expander, dropdown, arrow) {
  5417. var panelLeft = expander.position().left;
  5418. var panelWidth = expander.width();
  5419. var panelHeight = expander.height();
  5420. var dropdownLeft = dropdown.position().left;
  5421. var dropdownTop = dropdown.offset().top;
  5422. var dropdownHeight = dropdown.height();
  5423. var panelTop = (dropdownTop + dropdownHeight);
  5424. var arrowLeft = arrow.position().left;
  5425. var documentWidth = $(window).width();
  5426. var documentHeight = $(window).height() - 5;
  5427. var newTop = 0;
  5428. var newLeft = 0;
  5429. if (panelTop + panelHeight >= documentHeight) {
  5430. if (panelHeight < dropdownTop) {
  5431. newTop = dropdownTop - panelHeight;
  5432. } else if (dropdownTop >= (documentHeight - panelTop)) { //当下拉控件位置偏下……
  5433. newTop = 0;
  5434. expander.height(documentHeight - panelTop);
  5435. } else { //当下拉控件位置偏上……
  5436. newTop = panelTop;
  5437. expander.height(documentHeight - panelTop);
  5438. }
  5439. } else {
  5440. newTop = panelTop;
  5441. }
  5442. if (dropdownLeft + panelWidth > documentWidth - 16) {
  5443. newLeft = arrowLeft + arrow.width() - panelWidth;
  5444. if (newLeft < 2) newLeft = 2;
  5445. }
  5446. else {
  5447. newLeft = dropdownLeft;
  5448. }
  5449. //设置高度如果用offset的话,第一次点击时,如果窗口被滚动过,会忽略滚动条来设置高度,第二次又不会了,不知道为什么……
  5450. expander.position({
  5451. top: newTop
  5452. });
  5453. expander.offset({
  5454. left: newLeft
  5455. });
  5456. }
  5457. function _setValue(jq, val, callback) {
  5458. if (!val) {
  5459. CMSFunction.ComboGrid.SetValue($(jq), "", "");
  5460. return;
  5461. } else if (val == "" || val == "-1") {
  5462. CMSFunction.ComboGrid.SetValue($(jq), "", val);
  5463. return;
  5464. }
  5465. var opts = $.data(jq, "combogridX").options;
  5466. var grid = $(jq).find('.easyui-cmsXDataTable:first');
  5467. var jsonString = "({'QueryParamsDatas':'Attribute|*|{\"ID\":\"00000000-0000-0000-0000-000000000000\",\"Value\":\"" + opts.valueField
  5468. + "\",\"ControlType\":\"TextBox\"}|@|Condition|*|=|@|ConditionValue|*|" + opts.value
  5469. + "|@|" + opts.valueField + "_QueryTextBox|*|" + val + "|@|',page: 0,rows: 10 })";
  5470. try {
  5471. var gridOptions = grid.cmsXDataTable("options");
  5472. var url = gridOptions.url;
  5473. $.post(url, eval(jsonString), function (data) {
  5474. if (data.rows.length > 0) {
  5475. CMSFunction.ComboGrid.SetValue($(jq), data.rows[0][opts.textField], val);
  5476. if (callback) {
  5477. callback.call($(jq));
  5478. }
  5479. }
  5480. });
  5481. }
  5482. catch (err) { }
  5483. // var gridOpts = $.data(grid[0], "cmsXDataTable").options;
  5484. // var gridData = gridOpts.data;
  5485. // CMSFunction.ComboGrid.SetValue($(jq), "", "-1");
  5486. // if (gridData) {
  5487. // $.each(gridData.rows, function (i, v) {
  5488. // if (v[opts.valueField] == val) {
  5489. // CMSFunction.ComboGrid.SetValue($(jq), v[opts.textField], v[opts.valueField]);
  5490. // return false;
  5491. // }
  5492. // });
  5493. // }
  5494. }
  5495. function _getValue(jq) {
  5496. return $(jq).find('.combogridX-value').val();
  5497. }
  5498. function _getSelectedRow(jq) {
  5499. var value = _getValue(jq);
  5500. var opts = $.data(jq, "combogridX").options;
  5501. var grid = $(jq).find('.easyui-cmsXDataTable:first');
  5502. var gridOpts = $.data(grid[0], "cmsXDataTable").options;
  5503. var gridData = gridOpts.data;
  5504. var selectedRow = null;
  5505. if (gridData) {
  5506. $.each(gridData.rows, function (i, v) {
  5507. if (v[opts.valueField] == value) {
  5508. selectedRow = v;
  5509. return false;
  5510. }
  5511. });
  5512. }
  5513. return selectedRow;
  5514. }
  5515. function _getText(jq) {
  5516. return $(jq).find('.combo-text').val();
  5517. }
  5518. function _loadData(jq, data) {
  5519. jq.each(function () {
  5520. var grid = $(jq).parent().find('.easyui-cmsXDataTable:first');
  5521. if (!$.data(grid[0], "cmsXDataTable")) return;
  5522. grid.cmsXDataTable("loadData", data);
  5523. });
  5524. }
  5525. function _reload(jq, formData) {
  5526. jq.each(function () {
  5527. var grid = $(jq).parent().find('.easyui-cmsXDataTable:first');
  5528. if (!$.data(grid[0], "cmsXDataTable")) return;
  5529. var opts = $.data(grid[0], "cmsXDataTable").options;
  5530. opts.pageNumber = 1;
  5531. if (typeof formData == "string") {
  5532. opts.url = formData;
  5533. grid.cmsXDataTable("loadAll", '');
  5534. }
  5535. else {
  5536. $.data(this, "combogridX").options.formData = formData;
  5537. grid.cmsXDataTable("loadAll", formData);
  5538. }
  5539. });
  5540. }
  5541. function _select(jq, index) {
  5542. var grid = $(jq).parent().find('.easyui-cmsXDataTable:first');
  5543. var opts = $.data(jq, "combogridX").options;
  5544. if (!$.data(grid[0], "cmsXDataTable")) return;
  5545. var data = grid.cmsXDataTable("getRows");
  5546. if (data[index]) {
  5547. var selectedText = eval("data[index]." + opts.textField);
  5548. var selectedValue = eval("data[index]." + opts.valueField);
  5549. CMSFunction.ComboGrid.SetValue($(jq), selectedText, selectedValue);
  5550. }
  5551. }
  5552. $.fn.combogridX = function (_7be, _7bf, _7bg) {
  5553. if (typeof _7be == "string") {
  5554. var _7c0 = $.fn.combogridX.methods[_7be];
  5555. if (_7c0) {
  5556. return _7c0(this, _7bf, _7bg);
  5557. } else {
  5558. return this.combogridX(_7be, _7bf, _7bg);
  5559. }
  5560. }
  5561. _7be = _7be || {};
  5562. return this.each(function () {
  5563. var _this = this;
  5564. var cacheData = $.data(_this, "combogridX");
  5565. if (cacheData) {
  5566. $.extend(cacheData.options, _7be);
  5567. } else {
  5568. cacheData = $.data(_this, "combogridX", { options: $.extend({}, $.fn.combogridX.defaults, $.fn.combogridX.parseOptions(this), _7be) });
  5569. var initCacheData = _init(_this);
  5570. cacheData = $.data(_this, "combogridX", $.extend({}, cacheData, initCacheData));
  5571. }
  5572. });
  5573. };
  5574. $.fn.combogridX.methods = {
  5575. options: function (jq) {
  5576. var opts = $.data(jq[0], "combogridX").options;
  5577. return opts;
  5578. },
  5579. getValue: function (jq) {
  5580. return _getValue(jq[0]);
  5581. },
  5582. getSelectedRow: function (jq) {
  5583. return _getSelectedRow(jq[0]);
  5584. },
  5585. setValue: function (jq, val, callback) {
  5586. _setValue(jq[0], val, callback);
  5587. },
  5588. select: function (jq, index) {
  5589. _select(jq[0], index);
  5590. },
  5591. getText: function (jq) {
  5592. return _getText(jq[0]);
  5593. },
  5594. reload: function (jq, formData) {
  5595. _reload(jq, formData);
  5596. },
  5597. loadData: function (jq, data) {
  5598. _loadData(jq, data);
  5599. },
  5600. setExpanderPosition: function (jq, opts) {
  5601. _setExpanderPosition(opts.expander, opts.dropdown, opts.arrow);
  5602. }
  5603. };
  5604. $.fn.combogridX.parseOptions = function (_7c7) {
  5605. var t = $(_7c7);
  5606. return $.extend({}, $.fn.combogridX.defaults, $.parser.parseOptions(_7c7, []));
  5607. };
  5608. $.fn.combogridX.defaults = {
  5609. textField: "",
  5610. valueField: "",
  5611. isAutoComplete: true,
  5612. minReloadCharactor: 0,
  5613. onSelect: function (value) { },
  5614. onChange: function () { },
  5615. panelHeight: 300,
  5616. formData: null,
  5617. value: "",
  5618. enabled: true,
  5619. };
  5620. })(jQuery);
  5621. //2014-08-18 begin added by heyw 新增droppableContainer控件
  5622. $(function () {
  5623. $.parser.parseEasyUI(["autoComplete"]);
  5624. $.parser.parseEasyUI(["combogridX"]);
  5625. $.parser.parseEasyUI(["draggableList"]);
  5626. $.parser.parseEasyUI(["droppableContainer"]);
  5627. $.parser.parseEasyUI(["checkList"]);
  5628. $.parser.parseEasyUI(["richtext"]);
  5629. //$(".popupWindowContent").width(window.);
  5630. });
  5631. $.extend({
  5632. packFormParams: function (obj) {
  5633. var result = [];
  5634. for (var p in obj) {
  5635. result.push(p.toString() + "|*|" + obj[p] + "|@|");
  5636. }
  5637. return result.join('');
  5638. },
  5639. unpackFormParams: function (str) {
  5640. var json = [];
  5641. var props = str.split('|@|');
  5642. json.push("({");
  5643. for (var i = 0; i < props.length; i++) {
  5644. if (props[i] == "") continue;
  5645. var kv = props[i].split('|*|');
  5646. if (i != 0) { json.push(","); }
  5647. json.push('"' + kv[0] + '":"' + kv[1] + '"');
  5648. }
  5649. json.push("})");
  5650. return eval(json.join(""));
  5651. },
  5652. popupTopWindow: function (title, url, width, height, func, data) {
  5653. var containerTop = top.$('#sysWindow').parent();
  5654. var windowID = "sysWindow" + Math.floor(Math.random() * 100000 + 1);
  5655. $("<div id=\"" + windowID + "\" />").appendTo(containerTop);
  5656. var loU = url.split("?");
  5657. var newUrl = url;
  5658. if (loU.length > 1) {
  5659. newUrl += "&WindowID=" + windowID;
  5660. } else {
  5661. newUrl += "?WindowID=" + windowID;
  5662. }
  5663. if (data) {
  5664. top.$('#' + windowID).data("inputData", data);
  5665. }
  5666. var windowHeight = $(top.document).height();
  5667. if (windowHeight < height) {
  5668. height = windowHeight;
  5669. }
  5670. top.$('#' + windowID).dialog({
  5671. title: title,
  5672. width: width,
  5673. height: height,
  5674. content: '<iframe id="iframe1" frameborder="0" scrolling="no" ></iframe>',
  5675. modal: true,
  5676. onClose: function () {
  5677. if (func)
  5678. func.call(this, top.$('#' + windowID).data("resultData"));
  5679. },
  5680. onOpen: function () {
  5681. $(this).find("iframe").attr("src", newUrl);
  5682. }
  5683. });
  5684. return top.$('#' + windowID);
  5685. },
  5686. popupTopWindowOutsite: function (title, url, width, height, func, data) {
  5687. var containerTop = top.$('#sysWindow').parent();
  5688. var windowID = "sysWindow" + Math.floor(Math.random() * 100000 + 1);
  5689. $("<div id=\"" + windowID + "\" />").appendTo(containerTop);
  5690. if (data) {
  5691. top.$('#' + windowID).data("inputData", data);
  5692. }
  5693. var windowHeight = $(top.document).height();
  5694. if (windowHeight < height) {
  5695. height = windowHeight;
  5696. }
  5697. top.$('#' + windowID).dialog({
  5698. title: title,
  5699. width: width,
  5700. height: height,
  5701. content: '<iframe id="iframe1" frameborder="0" scrolling="yes" ></iframe>',
  5702. modal: true,
  5703. onClose: function () {
  5704. if (func)
  5705. func.call(this, top.$('#' + windowID).data("resultData"));
  5706. },
  5707. onOpen: function () {
  5708. $(this).find("iframe").attr("src", url);
  5709. }
  5710. });
  5711. return top.$('#' + windowID);
  5712. },
  5713. closeCurPopupTopWindow: function () {
  5714. var windowID = $.SystemGeneral.getUrlParam("WindowID");
  5715. top.$("#" + windowID).dialog("close");
  5716. },
  5717. getPopupTopWindowInputData: function () {
  5718. var windowID = $.SystemGeneral.getUrlParam("WindowID");
  5719. return top.$('#' + windowID).data("inputData");
  5720. }
  5721. });
  5722. //2016-02-25 begin added by heyw 新增checkList控件
  5723. (function ($) {
  5724. $.parser.plugins.push("checkList");
  5725. function _init(jq) {
  5726. var opts = $.data(jq, "checkList").options;
  5727. if (opts.url && opts.url != "") {
  5728. $.ajax({
  5729. type: "post", url: opts.url, success: function (data) {
  5730. opts.data = data;
  5731. opts.values = $.map($.grep(data, function (x) { return x.IsSelected; }), function (x) { return x[opts.valueField]; });
  5732. _getInitValuesAndLoad(jq, opts);
  5733. }
  5734. });
  5735. }
  5736. else {
  5737. _getInitValuesAndLoad(jq, opts);
  5738. }
  5739. return { checkList: jq };
  5740. }
  5741. var _getInitValuesAndLoad = function (jq, opts) {
  5742. if (opts.valueUrl && opts.valueUrl != "") {
  5743. $.ajax({
  5744. type: "post", url: opts.valueUrl, success: function (valueData) {
  5745. opts.values = valueData;
  5746. _bind(jq);
  5747. }
  5748. });
  5749. }
  5750. else {
  5751. _bind(jq);
  5752. }
  5753. };
  5754. var _bind = function (jq) {
  5755. var opts = $.data(jq, "checkList").options;
  5756. var listID = jq.id;
  5757. var html = new Array();
  5758. var textField = opts.textField;
  5759. var valueField = opts.valueField;
  5760. if (!(textField && textField != "")) {
  5761. textField = "Text";
  5762. }
  5763. if (!(valueField && valueField != "")) {
  5764. valueField = "Value";
  5765. }
  5766. var styleHtml = new Array();
  5767. if (!opts.isShow) styleHtml.push('display: none;');
  5768. var pages = Math.ceil(opts.data.length / opts.columnCount);
  5769. html.push('<table border="0" width="100%"');
  5770. if (styleHtml.length > 0) html.push(' style="' + styleHtml.join('') + '"');
  5771. html.push('>');
  5772. for (var i = 0; i < pages; i++) {
  5773. html.push('<tr>');
  5774. for (var j = 0; j < opts.columnCount; j++) {
  5775. var curIndex = (i * opts.columnCount + j);
  5776. if (opts.data.length > curIndex) {
  5777. var checked = $.inArray(opts.data[curIndex][valueField], opts.values) >= 0;
  5778. var checkedString = "";
  5779. if (checked) checkedString = " checked";
  5780. var enabledString = "";
  5781. if (!opts.isEnabled) enabledString = " disabled";
  5782. html.push('<td>');
  5783. html.push(''.concat('<input name="', opts.checkName, '"', checkedString, ' type="checkbox" value="',
  5784. opts.data[curIndex][valueField], '"', enabledString, '/>', opts.data[curIndex][textField]));
  5785. html.push('</td>');
  5786. }
  5787. else {
  5788. html.push('<td>&nbsp;</td>');
  5789. }
  5790. }
  5791. html.push('</tr>');
  5792. }
  5793. html.push('</table>');
  5794. var div = $(''.concat("<div>", html.join(''), "</div>")).appendTo(jq);
  5795. if (opts.onclick) {
  5796. $(jq).find('input[name="' + opts.checkName + '"]').click(opts.onclick);
  5797. }
  5798. if (opts.onLoadSuccess) {
  5799. opts.onLoadSuccess.call(jq, opts.data);
  5800. }
  5801. };
  5802. $.fn.checkList = function (_7be, _7bf) {
  5803. if (typeof _7be == "string") {
  5804. var _7c0 = $.fn.checkList.methods[_7be];
  5805. if (_7c0) {
  5806. return _7c0(this, _7bf);
  5807. } else {
  5808. return this.checkList(_7be, _7bf);
  5809. }
  5810. }
  5811. _7be = _7be || {};
  5812. return this.each(function () {
  5813. var _this = this;
  5814. var cacheData = $.data(_this, "checkList");
  5815. if (cacheData) {
  5816. $.extend(cacheData.options, _7be);
  5817. } else {
  5818. cacheData = $.data(_this, "checkList", { options: $.extend({}, $.fn.checkList.defaults, $.fn.checkList.parseOptions(this), _7be) });
  5819. var initCacheData = _init(_this);
  5820. cacheData = $.data(_this, "checkList", $.extend({}, cacheData, initCacheData));
  5821. }
  5822. });
  5823. };
  5824. $.fn.checkList.methods = {
  5825. options: function (jq) {
  5826. var opts = $.data(jq[0], "checkList").options;
  5827. return opts;
  5828. }
  5829. };
  5830. $.fn.checkList.parseOptions = function (_7c7) {
  5831. var t = $(_7c7);
  5832. return $.extend({}, $.fn.checkList.defaults, $.parser.parseOptions(_7c7, []));
  5833. };
  5834. $.fn.checkList.defaults = {
  5835. url: "",
  5836. valueUrl: "",
  5837. textField: "",
  5838. valueField: "",
  5839. columnCount: 1,
  5840. data: [],
  5841. values: [],
  5842. onLoadSuccess: function (data) { },
  5843. isEnabled: true,
  5844. isShow: true
  5845. };
  5846. })(jQuery);
  5847. //2016-02-25 begin added by heyw 新增richtext控件
  5848. //2021-05-10 modify by heyw 实际控件从ueditor改为kindeditor
  5849. (function ($) {
  5850. $.parser.plugins.push("richtext");
  5851. var ueList = new Object();
  5852. function _init(jq) {
  5853. var id = $(jq).attr("id");
  5854. var name = $(jq).attr("name");
  5855. // var ue = new baidu.editor.ui.Editor();
  5856. // ue.render(id);
  5857. var ke;
  5858. KindEditor.ready(function(K) {
  5859. ke = K.create('#'+id, {
  5860. uploadJson: K.options.basePath + 'asp.net/upload_json.ashx',
  5861. fileManagerJson: K.options.basePath + 'asp.net/file_manager_json.ashx'
  5862. });
  5863. if (!ueList["richtext_" + id]) {
  5864. //ueList["richtext_" + id] = { name: name, editor: ue };
  5865. ueList["richtext_" + id] = { name: name, editor: ke };
  5866. }
  5867. });
  5868. $(jq).closest('form').submit(function () {
  5869. $(".easyui-richtext").richtext("sync");
  5870. });
  5871. return { richtext: jq };
  5872. }
  5873. function _getValue(jq) {
  5874. var id = $(jq).attr("id");
  5875. //var ue = ueList["richtext_" + id].editor;
  5876. //return ue.getContent();
  5877. var ke = ueList["richtext_" + id].editor;
  5878. ke.sync();
  5879. return editor.html();
  5880. }
  5881. function _setValue(jq, value) {
  5882. var id = $(jq).attr("id");
  5883. // var ue = ueList["richtext_" + id].editor;
  5884. // return ue.setContent(value);
  5885. var ke = ueList["richtext_" + id].editor;
  5886. return editor.html(value);
  5887. }
  5888. function _sync(jq) {
  5889. var id = $(jq).attr("id");
  5890. var opts = ueList["richtext_" + id]
  5891. // var ue = opts.editor;
  5892. //
  5893. // ue.sync();
  5894. // var content = ue.getContent();
  5895. // content = UE.utils.unhtml(content);
  5896. // content = content.replace(/&#39;/g,'');
  5897. var ke = opts.editor;
  5898. var content = ke.html();
  5899. content = KindEditor.escape(content);
  5900. $('[name="' + opts.name + '"]').val(content);
  5901. }
  5902. $.fn.richtext = function (_7be, _7bf) {
  5903. if (typeof _7be == "string") {
  5904. var _7c0 = $.fn.richtext.methods[_7be];
  5905. if (_7c0) {
  5906. return _7c0(this, _7bf);
  5907. } else {
  5908. return this.richtext(_7be, _7bf);
  5909. }
  5910. }
  5911. _7be = _7be || {};
  5912. return this.each(function () {
  5913. var _this = this;
  5914. var cacheData = $.data(_this, "richtext");
  5915. if (cacheData) {
  5916. $.extend(cacheData.options, _7be);
  5917. } else {
  5918. cacheData = $.data(_this, "richtext", { options: $.extend({}, $.fn.richtext.defaults, $.fn.richtext.parseOptions(this), _7be) });
  5919. var initCacheData = _init(_this);
  5920. cacheData = $.data(_this, "richtext", $.extend({}, cacheData, initCacheData));
  5921. }
  5922. });
  5923. };
  5924. $.fn.richtext.methods = {
  5925. options: function (jq) {
  5926. var opts = $.data(jq[0], "richtext").options;
  5927. return opts;
  5928. },
  5929. getValue: function (jq) {
  5930. return _getValue(jq[0]);
  5931. },
  5932. setValue: function (jq, val) {
  5933. $.each(jq, function (i, v) {
  5934. _setValue(jq[i], val);
  5935. });
  5936. },
  5937. sync: function (jq) {
  5938. $.each(jq, function (i, v) {
  5939. _sync(jq[i]);
  5940. });
  5941. }
  5942. };
  5943. $.fn.richtext.parseOptions = function (_7c7) {
  5944. var t = $(_7c7);
  5945. return $.extend({}, $.fn.richtext.defaults, $.parser.parseOptions(_7c7, []));
  5946. };
  5947. $.fn.richtext.defaults = {
  5948. isEnabled: true,
  5949. isShow: true
  5950. };
  5951. })(jQuery);
  5952. //2016-02-25 begin added by heyw 新增checkList控件
  5953. (function ($) {
  5954. $.parser.plugins.push("qqList");
  5955. function _init(jq) {
  5956. var opts = $.data(jq, "qqList").options;
  5957. if (opts.url && opts.url != "") {
  5958. $.ajax({
  5959. type: "post", url: opts.url, success: function (data) {
  5960. opts.data = data;
  5961. _bind(jq);
  5962. }
  5963. });
  5964. }
  5965. else {
  5966. _bind(jq);
  5967. }
  5968. return { qqList: jq };
  5969. }
  5970. var _bind = function (jq) {
  5971. var opts = $.data(jq, "qqList").options;
  5972. var listID = jq.id;
  5973. var html = new Array();
  5974. var textField = opts.textField;
  5975. var valueField = opts.valueField;
  5976. if (!(textField && textField != "")) {
  5977. textField = "Text";
  5978. }
  5979. if (!(valueField && valueField != "")) {
  5980. valueField = "Value";
  5981. }
  5982. var styleHtml = new Array();
  5983. var pages = Math.ceil(opts.data.length / opts.columnCount);
  5984. html.push('<table border="0" width="100%"');
  5985. if (styleHtml.length > 0) html.push(' style="' + styleHtml.join('') + '"');
  5986. html.push('>');
  5987. for (var i = 0; i < pages; i++) {
  5988. html.push('<tr>');
  5989. for (var j = 0; j < opts.columnCount; j++) {
  5990. var curIndex = (i * opts.columnCount + j);
  5991. if (opts.data.length > curIndex) {
  5992. var enabledString = "";
  5993. var qqNo = opts.data[curIndex][valueField];
  5994. if (!opts.isEnabled) enabledString = " disabled";
  5995. html.push('<td>');
  5996. html.push('<a name="', opts.itemName, '" href="tencent://Message/?Uin=' + qqNo + '&websiteName=q-zone.qq.com&Menu=yes"' + enabledString + '>')
  5997. html.push('<div><span style="text-align: center;"><img src="http://q2.qlogo.cn/headimg_dl?dst_uin=' + qqNo + '&spec=100" ');
  5998. html.push('style="border: 0px; width: ' + opts.itemWidth + '; height: ' + opts.itemHeight + '"/></span>');
  5999. html.push(''.concat('<span style="text-align: center;">', opts.data[curIndex][textField], '</span>'));
  6000. html.push('</div></a></td>');
  6001. }
  6002. else {
  6003. html.push('<td>&nbsp;</td>');
  6004. }
  6005. }
  6006. html.push('</tr>');
  6007. }
  6008. html.push('</table>');
  6009. var div = $(''.concat("<div>", html.join(''), "</div>")).appendTo(jq);
  6010. if (opts.onclick) {
  6011. $(jq).find('a[name="' + opts.itemName + '"]').click(opts.onclick);
  6012. }
  6013. if (opts.onLoadSuccess) {
  6014. opts.onLoadSuccess.call(jq, opts.data);
  6015. }
  6016. };
  6017. $.fn.qqList = function (_7be, _7bf) {
  6018. if (typeof _7be == "string") {
  6019. var _7c0 = $.fn.qqList.methods[_7be];
  6020. if (_7c0) {
  6021. return _7c0(this, _7bf);
  6022. } else {
  6023. return this.qqList(_7be, _7bf);
  6024. }
  6025. }
  6026. _7be = _7be || {};
  6027. return this.each(function () {
  6028. var _this = this;
  6029. var cacheData = $.data(_this, "qqList");
  6030. if (cacheData) {
  6031. $.extend(cacheData.options, _7be);
  6032. } else {
  6033. cacheData = $.data(_this, "qqList", { options: $.extend({}, $.fn.qqList.defaults, $.fn.qqList.parseOptions(this), _7be) });
  6034. var initCacheData = _init(_this);
  6035. cacheData = $.data(_this, "qqList", $.extend({}, cacheData, initCacheData));
  6036. }
  6037. });
  6038. };
  6039. $.fn.qqList.methods = {
  6040. options: function (jq) {
  6041. var opts = $.data(jq[0], "qqList").options;
  6042. return opts;
  6043. }
  6044. };
  6045. $.fn.qqList.parseOptions = function (_7c7) {
  6046. var t = $(_7c7);
  6047. return $.extend({}, $.fn.qqList.defaults, $.parser.parseOptions(_7c7, []));
  6048. };
  6049. $.fn.qqList.defaults = {
  6050. url: "",
  6051. textField: "",
  6052. columnCount: 1,
  6053. data: [],
  6054. onLoadSuccess: function (data) { },
  6055. isEnabled: true,
  6056. isShow: true
  6057. };
  6058. })(jQuery);