customformCtrl.2.js 308 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709
  1. var appFormly = angular.module('formlyExample', [
  2. 'formly', 'formlyBootstrap', 'ui.bootstrap',
  3. 'ngSanitize', 'ui.select', 'ui.grid'
  4. ]);
  5. app.requires.push('formlyExample');
  6. // var appFormly = angular.module('formlyExample', [
  7. // 'formly', 'formlyBootstrap','ui.bootstrap',
  8. // 'ngSanitize','ui.select','ui.grid'],
  9. appFormly.config(
  10. function config(formlyConfigProvider) {
  11. //格式转换方法 XXX-XXX转驼峰命名
  12. function camelize(string) {
  13. string = string.replace(/[\-_\s]+(.)?/g, function(match, chr) {
  14. return chr ? chr.toUpperCase() : '';
  15. });
  16. // Ensure 1st char is always lowercase
  17. return string.replace(/^([A-Z])/, function(match, chr) {
  18. return chr ? chr.toLowerCase() : '';
  19. });
  20. }
  21. //获取ngModelAttr对象设置
  22. function getNgModelAttr(attrs, bindings) {
  23. var ngModelAttrs = {};
  24. angular.forEach(attrs, function(attr) {
  25. ngModelAttrs[camelize(attr)] = { attribute: attr };
  26. });
  27. angular.forEach(bindings, function(binding) {
  28. ngModelAttrs[camelize(binding)] = { bound: binding };
  29. });
  30. return ngModelAttrs;
  31. }
  32. formlyConfigProvider.setWrapper({
  33. name: 'bootstrapLabel',
  34. templateUrl: 'assets/views/customform/tpl/normal-label.html'
  35. });
  36. formlyConfigProvider.setType({
  37. name: 'ui-panel',
  38. templateUrl: 'assets/views/customform/tpl/ui-panel.html'
  39. });
  40. //当前用户名
  41. formlyConfigProvider.setType({
  42. name: 'ui-currentuser',
  43. extends: 'input',
  44. templateUrl: 'assets/views/customform/tpl/ui-username.html',
  45. controller: ['$scope', function($scope) {
  46. if ($scope.options.templateOptions.user) {
  47. $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
  48. $scope.options.initialValue = $scope.model[$scope.options.key];
  49. }
  50. }]
  51. });
  52. //请求人最近事件
  53. formlyConfigProvider.setType({
  54. name: 'ui-recentIncident',
  55. templateUrl: 'assets/views/customform/tpl/ui-recentincident.html',
  56. controller: ['$scope', '$modal', 'api_solution', function($scope, $modal, api_solution) {
  57. var filterData = {
  58. 'incident': {
  59. 'requester': {
  60. 'id': ''
  61. }
  62. },
  63. idx: 0,
  64. sum: 3
  65. };
  66. setInterval(function() {
  67. if (filterData.incident.requester.id == "" || filterData.incident.requester.id != $scope.model.requester.id) {
  68. var requester = $scope.model.requester;
  69. if (requester != null && angular.isDefined(requester.id)) {
  70. filterData.incident.requester.id = $scope.model.requester.id;
  71. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function(result) {
  72. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  73. if (modelData.status == 200) {
  74. $scope.lastrequst = modelData.list;
  75. }
  76. });
  77. requester = null
  78. } else {}
  79. } else {}
  80. }, 1000);
  81. $scope.detail = function(data) {
  82. var modalInstance = $modal.open({
  83. templateUrl: 'assets/views/incident/tpl/detailincident.html',
  84. controller: function($scope, $modalInstance) {
  85. console.log(data)
  86. $scope.entity = {};
  87. $scope.entity = data;
  88. },
  89. size: 'lg',
  90. });
  91. };
  92. $scope.myData = [{
  93. id: 1
  94. },
  95. {
  96. id: 2
  97. },
  98. {
  99. id: 3
  100. },
  101. {
  102. id: 4
  103. }
  104. ];
  105. $scope.myIndex = -1;
  106. $scope.getIndex = function(id) {
  107. if ($scope.myIndex) {
  108. if ($scope.myIndex == id) {
  109. $scope.myIndex = -1;
  110. } else {
  111. $scope.myIndex = id;
  112. }
  113. }
  114. }
  115. }]
  116. });
  117. //优先级级联可编辑控件
  118. formlyConfigProvider.setType({
  119. name: 'ui-overtime',
  120. extends: 'input',
  121. templateUrl: 'assets/views/customform/tpl/ui-overtime.html',
  122. controller: ['$scope', '$modal', 'api_bpm_domain', function($scope, $modal, api_bpm_domain) {
  123. var filteData = {};
  124. var datas = {}
  125. setInterval(function() {
  126. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  127. filteData = "L" + $scope.model.priority.id;
  128. datas = $scope.model.priority.id;
  129. // console.log($scope.options.templateOptions)
  130. api_bpm_domain.expectedTime(filteData).then(function(requester) {
  131. // var overtime=requester.date;
  132. if (requester.state == 200) {
  133. // if($scope.options.key=="date"){
  134. $scope.model[$scope.options.key] = requester.date
  135. // }
  136. }
  137. })
  138. }
  139. }, 1000);
  140. }]
  141. });
  142. formlyConfigProvider.setType({
  143. name: 'ui-responsetime',
  144. extends: 'input',
  145. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  146. controller: ['$scope', '$modal', 'api_bpm_domain', function($scope, $modal, api_bpm_domain) {
  147. var filteData = {};
  148. var datas = {}
  149. setInterval(function() {
  150. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  151. filteData = "L" + $scope.model.priority.id;
  152. datas = $scope.model.priority.id;
  153. // console.log($scope.options.templateOptions)
  154. api_bpm_domain.expectedTime(filteData).then(function(requester) {
  155. // var overtime=requester.date;
  156. if (requester.state == 200) {
  157. var keyName = {};
  158. if ($scope.options.key == "expectIntroTime") {
  159. keyName = "resolveTime";
  160. } else if ($scope.options.key == "expectResponseTime") { keyName = "responseTime"; }
  161. $scope.model[$scope.options.key] = requester.serviceLevelAgreement[keyName];
  162. // }
  163. }
  164. })
  165. }
  166. }, 1000);
  167. }]
  168. });
  169. //知识库按钮组件
  170. formlyConfigProvider.setType({
  171. name: 'ui-discasecade',
  172. extends: 'input',
  173. templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
  174. defaultOptions: function(options) {
  175. return {
  176. templateOptions: {
  177. relationAction: function(fields, modelscope, item) {}
  178. }
  179. }
  180. },
  181. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', function($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside) {
  182. var titles = {}
  183. setInterval(function() {
  184. if ($scope.model.category != null && titles != $scope.model.category) {
  185. $scope.searchData = {};
  186. if ($scope.options.key == "title") {
  187. var filterData = { "idx": 0, "sum": 1000 };
  188. api_bpm_data.fetchDataList('incidentcategory', filterData).then(function(data) {
  189. var datalist = data.list;
  190. angular.forEach(datalist, function(item) {
  191. if (item.id == $scope.model.category.id) {
  192. $scope.model[$scope.options.key] = item.category
  193. $scope.titles = item.category;
  194. // }
  195. // })
  196. // })
  197. // }
  198. titles = $scope.model.category;
  199. api_solution.searchSolutionByKey($scope.titles, $rootScope.user.id).then(function(response) {
  200. $scope.dlideboxslide = true
  201. if (response && response.length > 0) {
  202. // $scope.searchData = response;
  203. angular.forEach(response, function(item) {
  204. api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function(data) {
  205. if (data.status == 200) {
  206. var quote = { 'totalNum': data.totalNum }
  207. item = angular.extend(item, quote)
  208. }
  209. })
  210. $scope.searchData = response;
  211. })
  212. $scope.changes = false;
  213. $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  214. $scope.closepages = function(e) {
  215. $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  216. event.preventDefault();
  217. };
  218. $scope.shows = false;
  219. $scope.tempData = {};
  220. $scope.showpage = function(item) {
  221. $scope.shows = true;
  222. $scope.tempData = item;
  223. if (item.content != null) {
  224. $scope.tempData.content = $scope.tempData.content.replace("<p>", "").replace("</p>", "")
  225. }
  226. $scope.knowledgedata = item;
  227. $scope.pageid = item.id;
  228. $scope.changes = !$scope.changes;
  229. api_solution.fetchDataList('file', { "file": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function(data) {
  230. if (data) {
  231. $scope.attachments = data.list;
  232. $scope.view = function(attachmentId) {
  233. for (var i = 0; i < $scope.attachments.length; i++) {
  234. if ($scope.attachments[i].id == attachmentId) {
  235. window.open($scope.attachments[i].previewUrl);
  236. // var modalInstance = $modal.open({
  237. // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  238. // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  239. // }
  240. // });
  241. }
  242. }
  243. };
  244. $scope.download = function(contentId, filename) {
  245. api_solution.getSolutionDowpath(contentId).then(function(response) {
  246. var file = new Blob([response], {
  247. type: 'application/octet-stream'
  248. });
  249. // var filename = filename;
  250. var fileURL = URL.createObjectURL(file);
  251. var a = document.createElement('a');
  252. a.href = fileURL;
  253. a.target = '_blank';
  254. a.download = filename;
  255. document.body.appendChild(a);
  256. a.click();
  257. })
  258. };
  259. }
  260. })
  261. }
  262. $scope.related = function(item) {
  263. if (item.content != null) {
  264. item.content = item.content.replace("<p>", "").replace("</p>", "")
  265. }
  266. $scope.$parent.$parent.$parent.model.directClose = true;
  267. $scope.model.handleDescription = item.content;
  268. var data = { 'solutionQuote': { 'solutionId': item.id, 'incidentsign': $scope.model.incidentsign } };
  269. api_solution.addModel('solutionQuote', data).then(function(response) {
  270. if (response.status == 200) {
  271. SweetAlert.swal("引用成功", "知识库已引用", "success");
  272. } else {
  273. SweetAlert.swal("引用失败", "知识库未引用", "error");
  274. };
  275. })
  276. }
  277. $scope.close = function() {
  278. $scope.changes = !$scope.changes;
  279. event.preventDefault();
  280. }
  281. } else {}
  282. });
  283. }
  284. })
  285. })
  286. }
  287. }
  288. }, 1000);
  289. $scope.options.templateOptions.onChange = function(key, options, fildata, $event, model) {
  290. if (key && key.length > 1) {
  291. api_solution.searchSolutionByKey(key, $rootScope.user.id).then(function(response) {
  292. $scope.dlideboxslide = true
  293. if (response && response.length > 0) {
  294. // $scope.searchData = response;
  295. angular.forEach(response, function(item) {
  296. api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function(data) {
  297. if (data.status == 200) {
  298. var quote = { 'totalNum': data.totalNum }
  299. item = angular.extend(item, quote)
  300. }
  301. })
  302. $scope.searchData = response;
  303. })
  304. $scope.changes = false;
  305. $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  306. $scope.closepages = function(e) {
  307. $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  308. event.preventDefault();
  309. };
  310. $scope.shows = false;
  311. $scope.tempData = {};
  312. $scope.showpage = function(item) {
  313. $scope.shows = true;
  314. $scope.tempData = item;
  315. if (item.content != null) {
  316. $scope.tempData.content = $scope.tempData.content.replace("<p>", "").replace("</p>", "")
  317. }
  318. $scope.knowledgedata = item;
  319. $scope.pageid = item.id;
  320. $scope.changes = !$scope.changes;
  321. api_solution.fetchDataList('file', { "file": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function(data) {
  322. if (data) {
  323. $scope.attachments = data.list;
  324. $scope.view = function(attachmentId) {
  325. for (var i = 0; i < $scope.attachments.length; i++) {
  326. if ($scope.attachments[i].id == attachmentId) {
  327. window.open($scope.attachments[i].previewUrl);
  328. }
  329. }
  330. };
  331. $scope.download = function(contentId, filename) {
  332. api_solution.getSolutionDowpath(contentId).then(function(response) {
  333. var file = new Blob([response], {
  334. type: 'application/octet-stream'
  335. });
  336. // var filename = filename;
  337. var fileURL = URL.createObjectURL(file);
  338. var a = document.createElement('a');
  339. a.href = fileURL;
  340. a.target = '_blank';
  341. a.download = filename;
  342. document.body.appendChild(a);
  343. a.click();
  344. })
  345. };
  346. }
  347. })
  348. }
  349. $scope.related = function(item) {
  350. if (item.content != null) {
  351. item.content = item.content.replace("<p>", "").replace("</p>", "")
  352. }
  353. fildata.$parent.$parent.$parent.model.directClose = true;
  354. options.model.handleDescription = item.content;
  355. var data = { 'solutionQuote': { 'solutionId': item.id, 'incidentsign': options.model.incidentsign } };
  356. api_solution.addModel('solutionQuote', data).then(function(response) {
  357. if (response.status == 200) {
  358. SweetAlert.swal("引用成功", "知识库已引用", "success");
  359. } else {
  360. SweetAlert.swal("引用失败", "知识库未引用", "error");
  361. };
  362. })
  363. }
  364. $scope.close = function() {
  365. $scope.changes = !$scope.changes;
  366. event.preventDefault();
  367. }
  368. } else {}
  369. });
  370. }
  371. };
  372. }]
  373. });
  374. // formlyConfigProvider.setType({
  375. // name: 'ui-discasecade',
  376. // extends: 'input',
  377. // templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
  378. // defaultOptions:function(options){
  379. // return{
  380. // templateOptions: {
  381. // refresh:function(){},
  382. // refreshDelay: 0,
  383. // linkage:function(modelName, data, model, modelKey, key){
  384. // console.log(model)
  385. // }
  386. // }
  387. // };
  388. // }
  389. // });
  390. //重构组件模板
  391. //获取当前人
  392. formlyConfigProvider.setType({
  393. name: 'ui-users',
  394. extends: 'input',
  395. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  396. defaultOptions: function(options) {
  397. return {
  398. templateOptions: {
  399. translate: '',
  400. refreshDelay: 0
  401. }
  402. }
  403. },
  404. controller: ['$scope', function($scope) {
  405. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  406. $scope.options.templateOptions.translate = $scope.$root.user.name;
  407. }]
  408. });
  409. //只读控件
  410. formlyConfigProvider.setType({
  411. name: 'ui-label',
  412. extends: 'input',
  413. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  414. defaultOptions: function(options) {
  415. return {
  416. templateOptions: {
  417. translate: '',
  418. refreshDelay: 0
  419. }
  420. }
  421. },
  422. controller: ['$scope', function($scope) {
  423. console.log($scope.options.templateOptions)
  424. var value = $scope.model[$scope.options.key];
  425. function treeDesc(children, key, label) {
  426. if (label == "") {
  427. label = children[key];
  428. } else {
  429. label = children[key] + "-" + label;
  430. }
  431. if (angular.isDefined(children.parent)) {
  432. treeDesc(children.parent, key, label);
  433. } else {
  434. return label;
  435. }
  436. }
  437. if (angular.isArray(value)) {
  438. var tempValue = "";
  439. angular.forEach(value, function(item) {
  440. if (tempValue != "") {
  441. tempValue = tempValue + ",";
  442. }
  443. tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
  444. });
  445. $scope.options.templateOptions.translate = tempValue;
  446. } else if (angular.isObject(value)) {
  447. if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
  448. //tree
  449. // console.log("value.parent="+JSON.stringify(value.parent))
  450. var nameLabel = value[$scope.options.templateOptions.labelProp];
  451. nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
  452. $scope.options.templateOptions.translate = nameLabel;
  453. } else {
  454. $scope.options.templateOptions.translate = value;
  455. }
  456. } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
  457. console.log("value=" + value);
  458. $scope.options.templateOptions.translate = value;
  459. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  460. // console.log("value="+value);
  461. // $scope.options.templateOptions.translate = value;
  462. } else {
  463. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  464. $scope.options.templateOptions.translate = value;
  465. }
  466. if (angular.isFunction($scope.options.templateOptions.transform)) {
  467. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  468. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value);
  469. }
  470. }]
  471. });
  472. //标题组件
  473. formlyConfigProvider.setType({
  474. name: 'ui-title',
  475. template: '<section id="page-title-form"><div class="row"><div class="col-sm-8"><h1 class="mainTitle" style="font-weight:bold">{{options.templateOptions.label}}</h1><span class="mainDescription">{{options.templateOptions.placeholder}}</span></div></div></section>'
  476. // templateUrl: 'assets/views/customform/tpl/ui-title.html'
  477. });
  478. //分类标题组件
  479. formlyConfigProvider.setType({
  480. name: 'ui-typeTitle',
  481. templateUrl: 'assets/views/customform/tpl/ui-typeTitle.html'
  482. });
  483. //按钮组
  484. formlyConfigProvider.setType({
  485. name: 'ui-button',
  486. templateUrl: 'assets/views/customform/tpl/ui-button.html',
  487. defaultOptions: function(options) {
  488. return {
  489. noFormControl: true
  490. }
  491. }
  492. });
  493. //3d组link
  494. formlyConfigProvider.setType({
  495. name: 'ui-link',
  496. templateUrl: 'assets/views/customform/tpl/ui-link.html',
  497. defaultOptions: function(options) {
  498. return {
  499. noFormControl: true
  500. }
  501. }
  502. });
  503. //隐藏域组件
  504. formlyConfigProvider.setType({
  505. name: 'ui-hidden',
  506. extends: 'input',
  507. template: '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  508. defaultOptions: function(options) {
  509. return {
  510. // noFormControl: true
  511. };
  512. }
  513. });
  514. //文本框组件
  515. formlyConfigProvider.setType({
  516. name: 'ui-input',
  517. extends: 'input',
  518. templateUrl: 'assets/views/customform/tpl/ui-input.html',
  519. defaultOptions: function(options) {
  520. return {
  521. templateOptions: {
  522. transform: function(value) {}
  523. }
  524. };
  525. }
  526. });
  527. // //可删除文本框组件
  528. // formlyConfigProvider.setType({
  529. // name: 'ui-input',
  530. // extends: 'input',
  531. // templateUrl : 'assets/views/customform/tpl/ui-inputremoveable.html',
  532. // defaultOptions:function(options){
  533. // return {
  534. // };
  535. // },
  536. // controller: ['$scope',function($scope){
  537. // // $scope.removeopen=JSON.parse(sessionStorage.removeopen);
  538. // // console.log(sessionStorage.removeopen)
  539. // console.log($scope)
  540. // }]
  541. // });
  542. //只读文本
  543. formlyConfigProvider.setType({
  544. name: 'ui-disableinput',
  545. extends: 'input',
  546. templateUrl: 'assets/views/customform/tpl/ui-disableinput.html',
  547. defaultOptions: function(options) {
  548. return {
  549. templateOptions: {
  550. transform: function(value) {
  551. var ret = "";
  552. if (value) {
  553. ret = "已删除";
  554. } else {
  555. ret = "正常";
  556. }
  557. return ret;
  558. }
  559. }
  560. };
  561. }
  562. });
  563. formlyConfigProvider.setType({
  564. name: 'ui-disinput',
  565. extends: 'input',
  566. templateUrl: 'assets/views/customform/tpl/ui-disinput.html',
  567. defaultOptions: function(options) {
  568. return {
  569. templateOptions: {}
  570. };
  571. }
  572. });
  573. //数字组件
  574. formlyConfigProvider.setType({
  575. name: 'ui-number',
  576. extends: 'input',
  577. templateUrl: 'assets/views/customform/tpl/ui-number.html',
  578. defaultOptions: function(options) {
  579. return {};
  580. }
  581. });
  582. //区域选择组件
  583. formlyConfigProvider.setType({
  584. name: 'ui-grund',
  585. extends: 'select',
  586. templateUrl: 'assets/views/customform/tpl/ui-grund.html',
  587. defaultOptions: function(options) {
  588. return {
  589. templateOptions: {
  590. refresh: function() {},
  591. refreshDelay: 0
  592. }
  593. };
  594. },
  595. controller: ['$scope', function($scope) {
  596. var CityData = [{
  597. label: '中国',
  598. flag: 'cn.png',
  599. provinces: [{
  600. label: '北京',
  601. cities: [{
  602. label: '朝阳区'
  603. },
  604. {
  605. label: '宣武区'
  606. },
  607. {
  608. label: '海淀区'
  609. }
  610. ]
  611. },
  612. {
  613. label: '河北',
  614. cities: [{
  615. label: '石家庄'
  616. },
  617. {
  618. label: '承德'
  619. },
  620. {
  621. label: '唐山'
  622. }
  623. ]
  624. }
  625. ]
  626. },
  627. {
  628. label: '美国',
  629. flag: 'us.png',
  630. provinces: [{
  631. label: '纽约',
  632. cities: [{
  633. label: '曼哈顿区'
  634. },
  635. {
  636. label: '皇后区'
  637. }
  638. ]
  639. },
  640. {
  641. label: '德克萨斯州',
  642. cities: [{
  643. label: '休斯顿'
  644. },
  645. {
  646. label: '达拉斯'
  647. }
  648. ]
  649. },
  650. {
  651. label: '加利福尼亚州'
  652. }
  653. ]
  654. }
  655. ]
  656. var vm = $scope.vm = {};
  657. vm.countries = CityData;
  658. // 更换国家的时候清空省
  659. $scope.$watch('vm.country', function(country) {
  660. vm.province = null;
  661. console.log(vm.country)
  662. });
  663. // 更换省的时候清空城市
  664. $scope.$watch('vm.province', function(province) {
  665. vm.city = null;
  666. });
  667. $scope.model[$scope.options.key] = vm;
  668. }]
  669. });
  670. //下拉框组件
  671. formlyConfigProvider.setType({
  672. name: 'ui-select',
  673. extends: 'select',
  674. templateUrl: 'assets/views/customform/tpl/ui-select.html',
  675. defaultOptions: function(options) {
  676. return {
  677. templateOptions: {
  678. refresh: function() {},
  679. refreshDelay: 0,
  680. linkage: function(modelName, data, model, modelKey, key) {
  681. angular.extend(data, { "idx": 0, "sum": 1000 });
  682. options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
  683. var myData = options.templateOptions.Restangular.stripRestangular(response);
  684. var list = myData.list;
  685. if (list.length == 1) {
  686. angular.forEach(model.fields, function(item) {
  687. angular.forEach(model.fields, function(item) {
  688. if (item.templateOptions.pkey == modelKey + "." + key) {
  689. item.model.id = "";
  690. if (key == "place") {
  691. item.templateOptions.options = list;
  692. } else { item.value(list[0][key][item.key]); }
  693. }
  694. })
  695. })
  696. } else {
  697. angular.forEach(model.fields, function(item) {
  698. angular.forEach(model.fields, function(item) {
  699. if (item.templateOptions.pkey == modelKey + "." + key) {
  700. item.model.id = "";
  701. if (key == "place") {
  702. item.templateOptions.options = list;
  703. }
  704. }
  705. })
  706. })
  707. }
  708. });
  709. }
  710. }
  711. };
  712. }
  713. });
  714. //可修改下拉框组件
  715. formlyConfigProvider.setType({
  716. name: 'ui-selectchange',
  717. extends: 'select',
  718. templateUrl: 'assets/views/customform/tpl/ui-selectchange.html',
  719. defaultOptions: function(options) {
  720. return {
  721. templateOptions: {
  722. refresh: function() {},
  723. refreshDelay: 0,
  724. linkage: function(modelName, data, model, modelKey, key) {
  725. angular.extend(data, { "idx": 0, "sum": 1000 });
  726. options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
  727. var myData = options.templateOptions.Restangular.stripRestangular(response);
  728. var list = myData.list;
  729. if (list.length == 1) {
  730. angular.forEach(model.fields, function(item) {
  731. angular.forEach(model.fields, function(item) {
  732. if (item.templateOptions.pkey == modelKey + "." + key) {
  733. item.model.id = "";
  734. if (key == "place") {
  735. item.templateOptions.options = list;
  736. } else { item.value(list[0][key][item.key]); }
  737. }
  738. })
  739. })
  740. } else {
  741. angular.forEach(model.fields, function(item) {
  742. angular.forEach(model.fields, function(item) {
  743. if (item.templateOptions.pkey == modelKey + "." + key) {
  744. item.model.id = "";
  745. if (key == "place") {
  746. item.templateOptions.options = list;
  747. }
  748. }
  749. })
  750. })
  751. }
  752. });
  753. }
  754. },
  755. controller: ['$scope', function($scope) {
  756. if (angular.isArray($scope.model[$scope.options.key])) {
  757. } else {
  758. $scope.model[$scope.options.key] = [];
  759. }
  760. }]
  761. };
  762. }
  763. });
  764. //下拉多选框组件
  765. formlyConfigProvider.setType({
  766. name: 'ui-multiselect',
  767. extends: 'select',
  768. templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
  769. defaultOptions: function(options) {
  770. return {
  771. templateOptions: {
  772. refresh: function() {},
  773. refreshDelay: 0
  774. }
  775. };
  776. },
  777. controller: ['$scope', function($scope) {
  778. $scope.model[$scope.options.key] = [];
  779. }]
  780. });
  781. //下拉多选框灵活组件
  782. formlyConfigProvider.setType({
  783. name: 'ui-multiselectplus',
  784. extends: 'select',
  785. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  786. defaultOptions: function(options) {
  787. return {
  788. templateOptions: {
  789. refreshData: function(search, options, model, that) {
  790. var process = options.templateOptions.ApiService.all("");
  791. if (search) {
  792. } else {
  793. }
  794. var postData = options.templateOptions.optionsPostData;
  795. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  796. postData = options.templateOptions.optionsPostData(options, model, that);
  797. }
  798. process.customPOST(postData, options.templateOptions.optionsUrl).then(function(result) {
  799. if (!options.templateOptions.options) {
  800. options.templateOptions.options = [];
  801. }
  802. if (options.templateOptions.optionsDataKey) {
  803. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  804. } else {
  805. options.templateOptions.options = result;
  806. }
  807. if (options.templateOptions.optionsChecked) {
  808. options.value(options.templateOptions.options);
  809. }
  810. });
  811. },
  812. refreshDelay: 0
  813. }
  814. };
  815. },
  816. controller: ['$scope', function($scope) {
  817. if (angular.isArray($scope.model[$scope.options.key])) {
  818. } else {
  819. $scope.model[$scope.options.key] = [];
  820. }
  821. }]
  822. });
  823. //多选下拉框组件
  824. formlyConfigProvider.setType({
  825. name: 'ui-multi-select-tree',
  826. extends: 'multiCheckbox',
  827. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  828. defaultOptions: function(options) {
  829. return {
  830. templateOptions: {
  831. linkage: function(modelName, data, model, modelKey, key) {
  832. angular.extend(data, { "idx": 0, "sum": 10 });
  833. options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
  834. var myData = options.templateOptions.Restangular.stripRestangular(response);
  835. var list = myData.list;
  836. if (list.length == 1) {
  837. angular.forEach(model.fields, function(item) {
  838. angular.forEach(model.fields, function(item) {
  839. if (item.templateOptions.pkey == modelKey + "." + key) {
  840. item.model.id = "";
  841. if (key == "place") {
  842. item.templateOptions.options = list;
  843. } else { item.value(list[0][key][item.key]); }
  844. }
  845. })
  846. })
  847. }
  848. });
  849. },
  850. refresh: function(items) {
  851. //console.log(items);
  852. function convertListToTree(data, treeMap) {
  853. for (var i = 0; i < data.length; i++) {
  854. for (var j = 0; j < data.length; j++) {
  855. if (data[i].pid && data[i].id && data[i].pid != 0) {
  856. if (data[i].pid == data[j].id) {
  857. data[i].parent = data[j];
  858. }
  859. }
  860. }
  861. }
  862. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  863. var root = null; //Initially set our loop to null
  864. //loop over data
  865. for (var i = 0; i < data.length; i++) {
  866. var datum = data[i];
  867. //each node will have children, so let's give it a "children" poperty
  868. datum.children = [];
  869. //add an entry for this node to the map so that any future children can
  870. //lookup the parent
  871. idToNodeMap[datum.id] = datum;
  872. //Does this node have a parent?
  873. // console.log("datum="+JSON.stringify(datum))
  874. if (typeof datum.parent === "undefined") {
  875. //Doesn't look like it, so this node is the root of the tree
  876. root = datum;
  877. treeMap[datum.id] = root;
  878. } else {
  879. //This node has a parent, so let's look it up using the id
  880. parentNode = idToNodeMap[datum.parent.id];
  881. //We don't need this property, so let's delete it.
  882. delete datum.parent;
  883. //Let's add the current node as a child of the parent node.
  884. parentNode.children.push(datum);
  885. }
  886. }
  887. return root;
  888. }
  889. function convertParentToChildList(data) {
  890. // console.log("data="+JSON.stringify(data))
  891. var treeMap = {};
  892. var list = [];
  893. convertListToTree(data, treeMap);
  894. angular.forEach(treeMap, function(item) {
  895. // console.log("item="+JSON.stringify(item))
  896. list.push(item);
  897. });
  898. return list;
  899. }
  900. function selectItem(pmodel, childrens) {
  901. if (angular.isArray(pmodel)) {
  902. } else {
  903. if (pmodel && pmodel.id) {
  904. angular.forEach(childrens, function(item) {
  905. if (item.id == pmodel.id) {
  906. item.selected = true;
  907. }
  908. if (item && item.children) {
  909. selectItem(pmodel, item.children);
  910. }
  911. });
  912. }
  913. }
  914. }
  915. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  916. options.templateOptions.refreshData(options.templateOptions.APIService).then(function(result) {
  917. if (!options.templateOptions.options) {
  918. options.templateOptions.options = [];
  919. }
  920. if (options.templateOptions.optionsDataKey) {
  921. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  922. } else {
  923. options.templateOptions.options = convertParentToChildList(result);
  924. }
  925. //set default value
  926. var pmodel, i = 0;
  927. if (options.templateOptions.pkey) {
  928. if (options.templateOptions.pkey.indexOf(".") > 0) {
  929. angular.forEach(options.templateOptions.pkey.split("."), function(p) {
  930. if (i == 0) {
  931. if (options.model[p] == null) {
  932. options.model[p] = {};
  933. }
  934. pmodel = options.model[p];
  935. i++;
  936. } else {
  937. if (pmodel[p] == null) {
  938. pmodel[p] = {};
  939. }
  940. pmodel = pmodel[p];
  941. }
  942. });
  943. } else {
  944. pmodel = options.model[options.templateOptions.pkey];
  945. }
  946. }
  947. if (pmodel) {
  948. pmodel = pmodel[options.key];
  949. } else if (options.model) {
  950. pmodel = options.model[options.key];
  951. } else {
  952. pmodel = options.templateOptions.options;
  953. }
  954. if (pmodel && pmodel.id) {
  955. selectItem(pmodel, options.templateOptions.options);
  956. }
  957. // for(var i=0;i<options.templateOptions.options.length;i++){
  958. // options.templateOptions.options[i]={'id':options.templateOptions.options[i].id,'recate':options.templateOptions.options[i].recate}
  959. // }
  960. items.inputModel = options.templateOptions.options;
  961. });
  962. }
  963. },
  964. validators: {
  965. required: {
  966. expression: function(viewValue, modelValue) {
  967. var value = modelValue || viewValue;
  968. if (angular.isArray(value)) {
  969. return value.length > 0
  970. } else {
  971. return value != null;
  972. }
  973. }
  974. }
  975. }
  976. }
  977. },
  978. controller: ['$scope', 'api_configure_form', function($scope, api_configure_form) {
  979. if ($scope.options.templateOptions.isMultiSelect) {
  980. } else {
  981. if ($scope.model[$scope.options.key]) {
  982. }
  983. }
  984. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  985. // console.log(item)
  986. // // if(){
  987. // // }
  988. // // $scope.model[$scope.options.key]=item.id;
  989. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  990. // $scope.propTypeOptions = data;
  991. // });
  992. // }
  993. //$scope.model[$scope.options.key]=[];
  994. }]
  995. });
  996. //勾选组件
  997. formlyConfigProvider.setType({
  998. name: 'ui-checkbox',
  999. templateUrl: 'assets/views/customform/tpl/ui-checkbox.html',
  1000. });
  1001. //换行组件
  1002. formlyConfigProvider.setType({
  1003. name: 'ui-nextLine',
  1004. /*extends: 'input',*/
  1005. template: '<div></div>',
  1006. });
  1007. //多选框组件
  1008. formlyConfigProvider.setType({
  1009. name: 'ui-checklist',
  1010. extends: 'multiCheckbox',
  1011. templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
  1012. defaultOptions: function(options) {
  1013. return {
  1014. templateOptions: {
  1015. refresh: function() {},
  1016. refreshDelay: 0
  1017. }
  1018. };
  1019. }
  1020. });
  1021. //单选框组件
  1022. formlyConfigProvider.setType({
  1023. name: 'ui-radio',
  1024. extends: 'radio',
  1025. templateUrl: 'assets/views/customform/tpl/ui-radio.html',
  1026. defaultOptions: function(options) {
  1027. return {
  1028. templateOptions: {
  1029. refresh: function() {},
  1030. refreshDelay: 0
  1031. }
  1032. };
  1033. }
  1034. });
  1035. //文本域组件
  1036. formlyConfigProvider.setWrapper({
  1037. name: 'validation',
  1038. types: ['ui-textarea'],
  1039. template: "<formly-transclude></formly-transclude><div class=\"has-error\" ng-messages=\"fc.$error\" ng-if=\"options.formControl.$touched\"><div class=\"error\" ng-message=\"{{::name}}\" ng-repeat=\"(name, message) in ::options.validation.messages\">{{message(fc.$viewValue, fc.$modelValue, this)}}</div></div>"
  1040. });
  1041. formlyConfigProvider.setType({
  1042. name: 'ui-textarea',
  1043. extends: 'textarea',
  1044. templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
  1045. defaultOptions: function(options) {
  1046. return {
  1047. templateOptions: {
  1048. transform: function(model, value) {
  1049. return value;
  1050. },
  1051. },
  1052. validation: {
  1053. messages: {
  1054. maxlength: function(viewValue, modelValue, scope) {
  1055. if (viewValue != null) {
  1056. if (viewValue.length > scope.to.maxlength) {
  1057. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  1058. } else {
  1059. return "";
  1060. }
  1061. }
  1062. },
  1063. }
  1064. }
  1065. }
  1066. },
  1067. controller: ['$scope', function($scope) {
  1068. var value = $scope.model[$scope.options.key];
  1069. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1070. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1071. }
  1072. }]
  1073. });
  1074. //改动的组件 ckeditor封装后的组件
  1075. formlyConfigProvider.setType({
  1076. name: 'ui-text-check',
  1077. extends: 'textarea',
  1078. templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
  1079. defaultOptions: function(options) {
  1080. return {
  1081. templateOptions: {
  1082. extraPlugins: 'uploadimage',
  1083. uploadimageConfig: {
  1084. backend: 'basic',
  1085. settings: {
  1086. uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
  1087. headers: '',
  1088. downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
  1089. }
  1090. },
  1091. refresh: function(APIService, contentId, data) {
  1092. return APIService.fetchDataList(contentId, data);
  1093. },
  1094. downloadUri: function(APIService, contentId) {
  1095. return APIService.downloadAttachment(contentId).getRequestedUrl();
  1096. },
  1097. upload: function(APIService, contentId) {
  1098. return APIService.getSolutionDowpath(contentId);
  1099. },
  1100. view: function(attachmentId) {
  1101. // return APIService.attachmentsPreviewUrl(contentId);
  1102. },
  1103. refreshDelay: 0,
  1104. transform: function(model, value) {
  1105. return value;
  1106. },
  1107. },
  1108. validation: {
  1109. messages: {
  1110. maxlength: function(viewValue, modelValue, scope) {
  1111. if (viewValue != null) {
  1112. if (viewValue.length > scope.to.maxlength) {
  1113. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  1114. } else {
  1115. return "";
  1116. }
  1117. }
  1118. },
  1119. }
  1120. }
  1121. }
  1122. },
  1123. controller: ['$scope', '$rootScope', function($scope, $rootScope) {
  1124. var value = $scope.model[$scope.options.key];
  1125. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1126. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1127. }
  1128. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  1129. //var expiry={'expiry':14804244006};
  1130. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  1131. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  1132. $scope.upload = function(contentId, filename) {
  1133. var filename = filename;
  1134. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  1135. var file = new Blob([response], { type: 'application/octet-stream' });
  1136. // var filename = filename;
  1137. var fileURL = URL.createObjectURL(file);
  1138. var a = document.createElement('a');
  1139. a.href = fileURL;
  1140. a.target = '_blank';
  1141. a.download = filename;
  1142. document.body.appendChild(a);
  1143. a.click();
  1144. })
  1145. };
  1146. }]
  1147. });
  1148. // formlyConfigProvider.setType({
  1149. // name: 'ui-mentio',
  1150. // extends: 'textarea',
  1151. // templateUrl : 'assets/views/customform/tpl/mentio.html',
  1152. // defaultOptions:function(options){
  1153. // return {
  1154. // templateOptions: {
  1155. // transform:function(model, value){
  1156. // return value;
  1157. // },
  1158. // },
  1159. // validation: {
  1160. // messages: {
  1161. // maxlength: function(viewValue, modelValue, scope) {
  1162. // if(viewValue!=null){
  1163. // if(viewValue.length>scope.to.maxlength){
  1164. // return scope.to.label + ' 字数('+ viewValue.length +')超限('+scope.to.maxlength+')'
  1165. // }else{
  1166. // return "";
  1167. // }
  1168. // }
  1169. // },
  1170. // }
  1171. // }
  1172. // }
  1173. // },
  1174. // controller: ['$scope',function($scope){
  1175. // $scope.people = [
  1176. // { label: 'Joe'},
  1177. // { label: 'Mike'},
  1178. // { label: 'Diane'}
  1179. // ]
  1180. // var value = $scope.model[$scope.options.key];
  1181. // if(angular.isFunction($scope.options.templateOptions.transform)){
  1182. // $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1183. // }
  1184. // }]
  1185. // });
  1186. //文本框自定义选择面板组件
  1187. formlyConfigProvider.setType({
  1188. name: 'ui-input-selectmodal',
  1189. extends: 'input',
  1190. templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
  1191. defaultOptions: function(options) {
  1192. return {
  1193. templateOptions: {
  1194. openModal: function(size, options, modal) {
  1195. var modalInstance = modal.open({
  1196. templateUrl: 'assets/views/customform/tpl/modal-content.html',
  1197. controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
  1198. size: size,
  1199. resolve: options.templateOptions.modalParam
  1200. });
  1201. modalInstance.result.then(function(selectedItem) {
  1202. options.value(selectedItem);
  1203. }, function() {
  1204. //console.log('Modal dismissed at: ' + new Date());
  1205. });
  1206. }
  1207. }
  1208. };
  1209. }
  1210. });
  1211. //日期控件
  1212. var datepicker_attr = [
  1213. 'date-disabled',
  1214. 'custom-class',
  1215. 'show-weeks',
  1216. 'starting-day',
  1217. 'init-date',
  1218. 'min-mode',
  1219. 'max-mode',
  1220. 'format-day',
  1221. 'format-month',
  1222. 'format-year',
  1223. 'format-day-header',
  1224. 'format-day-title',
  1225. 'format-month-title',
  1226. 'year-range',
  1227. 'shortcut-propagation',
  1228. 'datepicker-popup',
  1229. 'show-button-bar',
  1230. 'current-text',
  1231. 'clear-text',
  1232. 'close-text',
  1233. 'close-on-date-selection',
  1234. 'datepicker-append-to-body'
  1235. ];
  1236. var datepicker_bindings = [
  1237. 'datepicker-mode',
  1238. 'min-date',
  1239. 'max-date'
  1240. ];
  1241. formlyConfigProvider.setType({
  1242. name: 'ui-datetime',
  1243. templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
  1244. extends: 'input',
  1245. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1246. defaultOptions: {
  1247. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  1248. templateOptions: {
  1249. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  1250. }
  1251. },
  1252. controller: ['$scope', '$filter', function($scope, $filter) {
  1253. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  1254. $scope.options.initialValue = $scope.model[$scope.options.key];
  1255. }]
  1256. });
  1257. //日期控件
  1258. formlyConfigProvider.setType({
  1259. name: 'ui-datepicker',
  1260. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  1261. extends: 'input',
  1262. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1263. defaultOptions: {
  1264. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  1265. templateOptions: {
  1266. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  1267. }
  1268. },
  1269. controller: ['$scope', '$filter', function($scope, $filter) {
  1270. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  1271. if ($scope.model[$scope.options.key]) {
  1272. } else {
  1273. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  1274. }
  1275. $scope.options.initialValue = $scope.model[$scope.options.key];
  1276. $scope.endOpen = true;
  1277. $scope.datepicker = {};
  1278. $scope.datepicker.opened = false;
  1279. $scope.datepicker.open = function($event) {
  1280. $scope.datepicker.opened = true;
  1281. };
  1282. }]
  1283. });
  1284. //含有周的日期
  1285. formlyConfigProvider.setType({
  1286. name: 'ui-datepickerweek',
  1287. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  1288. extends: 'input',
  1289. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1290. defaultOptions: {
  1291. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  1292. templateOptions: {
  1293. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  1294. }
  1295. },
  1296. controller: ['$scope', '$filter', function($scope, $filter) {
  1297. $scope.mindata = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
  1298. if ($scope.model[$scope.options.key]) {
  1299. } else {
  1300. $scope.model[$scope.options.key] = $filter('date')(new Date(new Date().getTime() + 24 * 60 * 60 * 1000), $scope.options.templateOptions.datepickerPopup);
  1301. }
  1302. $scope.options.initialValue = $scope.model[$scope.options.key];
  1303. $scope.endOpen = true;
  1304. $scope.datepicker = {};
  1305. $scope.datepicker.opened = false;
  1306. $scope.datepicker.open = function($event) {
  1307. $scope.datepicker.opened = true;
  1308. };
  1309. }]
  1310. });
  1311. //状态追踪
  1312. formlyConfigProvider.setType({
  1313. name: 'ui-followStatus',
  1314. templateUrl: 'assets/views/customform/tpl/ui-followStatus.html',
  1315. controller: ['$scope', 'api_bpm_data', 'Restangular', function($scope, api_bpm_data, Restangular) {
  1316. setTimeout(function() {
  1317. var pkey = $scope.options.templateOptions.pkey;
  1318. var dataId = $scope.model.id;
  1319. api_bpm_data.fetchData(pkey, dataId).then(function(response) {
  1320. if (response) {
  1321. var myData = Restangular.stripRestangular(response);
  1322. var processInstanceId = myData.data.processInstanceId;
  1323. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function(result) {
  1324. if (result.status == 200) {
  1325. var newData = Restangular.stripRestangular(result);
  1326. $scope.followData = newData.data;
  1327. }
  1328. });
  1329. }
  1330. })
  1331. }, 10);
  1332. }]
  1333. });
  1334. //历史记录
  1335. formlyConfigProvider.setType({
  1336. name: 'ui-history',
  1337. templateUrl: 'assets/views/customform/tpl/ui-history.html',
  1338. controller: ['$scope', 'api_bpm_data', 'Restangular', function($scope, api_bpm_data, Restangular) {
  1339. setTimeout(function() {
  1340. var pkey = $scope.options.templateOptions.pkey;
  1341. var dataId = $scope.model.id;
  1342. api_bpm_data.fetchData(pkey, dataId).then(function(response) {
  1343. if (response) {
  1344. var myData = Restangular.stripRestangular(response);
  1345. var processInstanceId = myData.data.processInstanceId;
  1346. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function(result) {
  1347. if (result.status == 200) {
  1348. var newData = Restangular.stripRestangular(result);
  1349. var long = newData.data.length - 1;
  1350. $scope.followData = newData.data[long];
  1351. }
  1352. });
  1353. }
  1354. })
  1355. }, 10);
  1356. }]
  1357. });
  1358. //请求人信息显示
  1359. formlyConfigProvider.setType({
  1360. name: "ui-disrequester",
  1361. templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  1362. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1363. defaultOptions: function(options) {
  1364. return {
  1365. templateOptions: {}
  1366. };
  1367. },
  1368. controller: ['$scope', function($scope) {
  1369. $scope.options.templateOptions.that = $scope;
  1370. }]
  1371. });
  1372. //退回人信息显示
  1373. formlyConfigProvider.setType({
  1374. name: "ui-returnperson",
  1375. templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
  1376. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1377. defaultOptions: function(options) {
  1378. return {
  1379. templateOptions: {}
  1380. };
  1381. },
  1382. controller: ['$scope', function($scope) {
  1383. $scope.group = "";
  1384. $scope.role = "";
  1385. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  1386. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  1387. } else {
  1388. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  1389. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  1390. }
  1391. }
  1392. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  1393. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  1394. } else {
  1395. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  1396. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  1397. }
  1398. }
  1399. $scope.options.templateOptions.that = $scope;
  1400. $scope.options.templateOptions.that = $scope;
  1401. }]
  1402. });
  1403. //指派技术人员
  1404. formlyConfigProvider.setType({
  1405. name: "ui-apiontperson",
  1406. templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
  1407. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1408. defaultOptions: function(options) {
  1409. return {
  1410. templateOptions: {
  1411. transtlara: function(value, $scope) {}
  1412. }
  1413. };
  1414. },
  1415. controller: ['$scope', 'api_user_data', 'Restangular', function($scope, api_user_data, Restangular) {
  1416. var filterData = { "idx": 0, "sum": 10 }
  1417. api_user_data.fetchDataList('group', filterData).then(function(response) {
  1418. if (response.status == 200) {
  1419. $scope.select = {};
  1420. $scope.multipleDemo = {};
  1421. $scope.userdata = {};
  1422. var data = response.list;
  1423. var item = [];
  1424. $scope.multipleDemo = data;
  1425. $scope.multipleDemo;
  1426. }
  1427. })
  1428. $scope.options.templateOptions.onChange = function(id, options, groupdata, $event, model) {
  1429. if (groupdata.option) {
  1430. $scope.model[$scope.options.key] = {};
  1431. var fildate = {
  1432. "idx": 0,
  1433. "sum": 10,
  1434. "user": {
  1435. "roledata": { "rolecode": model.currentRole },
  1436. "selectType": "1",
  1437. "groupdata": { "id": groupdata.option.id }
  1438. }
  1439. }
  1440. api_user_data.fetchDataList('user', fildate).then(function(response) {
  1441. if (response.status == 200) {
  1442. $scope.userdata = {};
  1443. $scope.userdata = response.list;
  1444. }
  1445. })
  1446. } else {
  1447. $scope.model[$scope.options.key] = { id: groupdata.id.id }
  1448. $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
  1449. }
  1450. }
  1451. // }
  1452. }]
  1453. });
  1454. //请求人
  1455. // formlyConfigProvider.setType({
  1456. // name: "ui-requesterselect",
  1457. // templateUrl: 'assets/views/customform/tpl/selector.html',
  1458. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1459. // defaultOptions:function(options){
  1460. // return {
  1461. // templateOptions: {
  1462. // // transtlara:function(){}
  1463. // }
  1464. // };
  1465. // },
  1466. // controller:['$scope','api_user_data', function($scope,api_user_data){
  1467. // $scope.myBrowsers ={};
  1468. // var filterData = {idx:0,sum:6};
  1469. // api_user_data.fetchDataList('requester',filterData).then(function(data){
  1470. // var myData = data.list;
  1471. // });
  1472. // $scope.phone = function(phone){
  1473. // window.location.href = 'tel://' + phone;
  1474. // }
  1475. // }]
  1476. // });
  1477. //用户单选控件
  1478. formlyConfigProvider.setType({
  1479. name: "ui-requesterselect",
  1480. templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  1481. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1482. defaultOptions: function(options, $scope) {
  1483. return {
  1484. templateOptions: {
  1485. checkform: function(options) {
  1486. if (options.model.requester) {
  1487. options.value(options.model.requester);
  1488. }
  1489. },
  1490. linkage: function(searchtype) {
  1491. var filterData = {
  1492. 'requester': {
  1493. 'account': searchtype.account
  1494. // ,
  1495. // 'name':searchtype.name
  1496. },
  1497. idx: 0,
  1498. sum: 6
  1499. };
  1500. $scope.nameshow = false;
  1501. $scope.accountshow = false;
  1502. if (angular.isDefined(searchtype.account) && searchtype.account != '') {
  1503. $scope.accountshow = true;
  1504. } else { $scope.accountshow = false; }
  1505. // if(angular.isDefined(searchtype.name)&&searchtype.name!=''){
  1506. // $scope.nameshow=true;
  1507. // }else{$scope.nameshow=false;}
  1508. options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function(response) {
  1509. var myData = options.templateOptions.Restangular.stripRestangular(response);
  1510. $scope.myData = myData.list;
  1511. if (myData.list.length >= 1) {
  1512. if (myData.list.length == 1) {
  1513. $scope.accountshow = false;
  1514. $scope.nameshow = false;
  1515. options.value(myData.list[0]);
  1516. } else if (myData.list.length > 1) {
  1517. var requesternum = {};
  1518. requesternum['account'] = searchtype.account;
  1519. options.value(requesternum);
  1520. }
  1521. }
  1522. });
  1523. $scope.show = function(name, account) {
  1524. $scope.nameshow = false;
  1525. $scope.accountshow = false;
  1526. // $scope.model[options.key].name=name;
  1527. // $scope.model[options.key].account=account;
  1528. filterData.requester.name = name;
  1529. filterData.requester.account = account;
  1530. if (filterData.requester.account != '') {
  1531. options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function(response) {
  1532. var myData = options.templateOptions.Restangular.stripRestangular(response);
  1533. $scope.myData = myData.list;
  1534. $scope.model[options.key] = $scope.myData[0];
  1535. // if(myData.list.length>=1){
  1536. // if(myData.list.length==1){
  1537. // options.value(myData.list[0]);
  1538. // }else if(myData.list.length>1){
  1539. // // $scope.accountshow=true;
  1540. // }
  1541. // }
  1542. });
  1543. } else { $scope.accountshow = false; }
  1544. // if(filterData.requester.name!=''){
  1545. // options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function(response){
  1546. // var myData = options.templateOptions.Restangular.stripRestangular(response);
  1547. // $scope.myData=myData.list;
  1548. // if(myData.list.length>=1){
  1549. // if(myData.list.length==1){
  1550. // options.value(myData.list[0]);
  1551. // }else if(myData.list.length>1){
  1552. // $scope.accountshow=true;
  1553. // }
  1554. // }
  1555. // });
  1556. // }else{$scope.nameshow=false;}
  1557. }
  1558. },
  1559. openModal: function(size, options, modal) {
  1560. var modelObject = options.value();
  1561. var searchModal = function(filterSearchData) {
  1562. var modalInstance = modal.open({
  1563. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  1564. controller: function($scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchData, api_bpm_data) {
  1565. $scope.langs = i18nService.getAllLangs();
  1566. $scope.lang = 'zh-cn';
  1567. i18nService.setCurrentLang($scope.lang);
  1568. $scope.gridOptions = {};
  1569. $scope.gridOptions.data = 'myData';
  1570. $scope.gridOptions.enableColumnResizing = true;
  1571. $scope.gridOptions.enableFiltering = false;
  1572. $scope.gridOptions.enableGridMenu = false;
  1573. $scope.gridOptions.showGridFooter = true;
  1574. $scope.gridOptions.showColumnFooter = true;
  1575. $scope.gridOptions.fastWatch = true;
  1576. $scope.gridOptions.useExternalPagination = true;
  1577. $scope.gridOptions.paginationPageSizes = [10];
  1578. $scope.gridOptions.paginationPageSize = 10;
  1579. $scope.gridOptions.multiSelect = false;
  1580. $scope.gridOptions.rowIdentity = function(row) {
  1581. return row.id;
  1582. };
  1583. $scope.gridOptions.getRowIdentity = function(row) {
  1584. return row.id;
  1585. };
  1586. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  1587. $scope.gridOptions.columnDefs = [
  1588. { name: 'account', displayName: '账号', width: 140 },
  1589. { name: 'name', displayName: '名称', width: 100 },
  1590. { name: 'gender', displayName: '性别', width: 140 },
  1591. { name: 'mphone', displayName: '电话', width: 100 },
  1592. { name: 'email', displayName: '邮件', width: 100 },
  1593. { name: 'dept.dept', displayName: '部门', width: 100 },
  1594. { name: 'group[0].groupName', displayName: '角色', width: 100 }
  1595. ];
  1596. $scope.gridOptions.onRegisterApi = function(gridApi) {
  1597. $scope.gridApi = gridApi;
  1598. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  1599. $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  1600. });
  1601. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  1602. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  1603. $scope.selected.item = data.entity;
  1604. // }else{alert ("请求人工号格式不对,账号应为6位数,请重新填写!")}
  1605. });
  1606. };
  1607. $scope.loadData = function(filterData) {
  1608. items.fetchItems(filterData, APIService).then(function(data) {
  1609. var myData = Restangular.stripRestangular(data);
  1610. $scope.gridOptions.totalItems = myData.totalNum;
  1611. $scope.myData = myData.list;
  1612. });
  1613. };
  1614. $scope.title = title;
  1615. if (searchData) {
  1616. $scope.loadData(searchData);
  1617. } else {
  1618. $scope.loadData({
  1619. idx: 0,
  1620. sum: 10
  1621. });
  1622. }
  1623. $scope.selected = {
  1624. item: {}
  1625. };
  1626. $scope.ok = function() {
  1627. $modalInstance.close($scope.selected.item);
  1628. };
  1629. $scope.cancel = function() {
  1630. $modalInstance.dismiss('cancel');
  1631. };
  1632. },
  1633. size: size,
  1634. resolve: {
  1635. items: function() {
  1636. return {
  1637. fetchItems: function(filterData, APIService) {
  1638. filterData = filterData || {};
  1639. if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
  1640. filterData = {
  1641. idx: 0,
  1642. sum: 10
  1643. };
  1644. }
  1645. return options.templateOptions.fetchItems(filterData, APIService);
  1646. }
  1647. };
  1648. },
  1649. title: function() {
  1650. return options.templateOptions.modalTitle;
  1651. },
  1652. Restangular: function() {
  1653. return options.templateOptions.Restangular;
  1654. },
  1655. APIService: function() {
  1656. return options.templateOptions.ApiService;
  1657. },
  1658. language: function() {
  1659. return options.templateOptions.language;
  1660. },
  1661. searchData: function() {
  1662. return filterSearchData;
  1663. }
  1664. }
  1665. });
  1666. modalInstance.result.then(function(selectedItem) {
  1667. options.value(selectedItem);
  1668. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  1669. options.templateOptions.callback(selectedItem, options);
  1670. }
  1671. }, function() {
  1672. //console.log('Modal dismissed at: ' + new Date());
  1673. });
  1674. }
  1675. // if(modelObject!=null&&angular.isDefined(modelObject.account)){
  1676. // var searchAccount=modelObject.account;
  1677. // var searchName=modelObject.name;
  1678. // if(searchAccount.length==6){
  1679. // var filterData = {
  1680. // 'requester':{
  1681. // 'account':searchAccount
  1682. // // ,
  1683. // // 'name':searchName
  1684. // },
  1685. // idx:0,
  1686. // sum:10
  1687. // };
  1688. // options.templateOptions.ApiService.fetchDataList('requester',filterData).then(function(data){
  1689. // var myData = options.templateOptions.Restangular.stripRestangular(data);
  1690. // if(myData.list.length>=1){
  1691. // if(myData.list.length==1){
  1692. // options.value(myData.list[0]);
  1693. // }else{
  1694. // searchModal(filterData);
  1695. // }
  1696. // }else{
  1697. // searchModal();
  1698. // }
  1699. // });
  1700. // var filData = {
  1701. // 'incident':{
  1702. // 'requester':{
  1703. // 'id':searchAccount
  1704. // }
  1705. // },
  1706. // idx:0,
  1707. // sum:5
  1708. // };
  1709. // options.templateOptions.ApiService.fetchDataList('incident', filData).then(function(response){
  1710. // var myData = options.templateOptions.Restangular.stripRestangular(response);
  1711. // // options.value(myData.list[0]);
  1712. // });
  1713. // }else{
  1714. // searchModal();
  1715. // }
  1716. // }else{
  1717. searchModal();
  1718. // }
  1719. },
  1720. addRequeter: function(size, options, modal) {
  1721. var modalInstance = modal.open({
  1722. templateUrl: 'assets/views/customform/tpl/modal-add-requester.html',
  1723. controller: function($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService) {
  1724. $scope.title = "新增请求人";
  1725. $scope.requester = {
  1726. };
  1727. $scope.refreshDepts = function(key) {
  1728. var filterData = {
  1729. 'idx': 0,
  1730. 'sum': 5,
  1731. 'dept': {
  1732. 'name': key
  1733. }
  1734. };
  1735. UserService.fetchDataList('department', filterData).then(function(response) {
  1736. if (response.status == 200) {
  1737. $scope.depts = response.list;
  1738. }
  1739. })
  1740. }
  1741. $scope.ok = function() {
  1742. if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  1743. SweetAlert.swal("请求人姓名未填!", "请填写请求人姓名", "error");
  1744. } else if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
  1745. SweetAlert.swal("请求人工号未填!", "请填写请求人工号", "error");
  1746. } else {
  1747. $modalInstance.close($scope.requester);
  1748. }
  1749. };
  1750. $scope.cancel = function() {
  1751. $modalInstance.dismiss('cancel');
  1752. };
  1753. },
  1754. size: size,
  1755. resolve: {
  1756. items: function() {
  1757. return {
  1758. fetchItems: function(filterData, APIService) {
  1759. filterData = filterData || {};
  1760. if (!filterData.idx) {
  1761. filterData = {
  1762. idx: 0,
  1763. sum: 10
  1764. };
  1765. }
  1766. return options.templateOptions.fetchItems(filterData, APIService);
  1767. }
  1768. };
  1769. },
  1770. title: function() {
  1771. return options.templateOptions.modalTitle;
  1772. },
  1773. Restangular: function() {
  1774. return options.templateOptions.Restangular;
  1775. },
  1776. APIService: function() {
  1777. return options.templateOptions.ApiService;
  1778. },
  1779. UserService: function() {
  1780. return options.templateOptions.UserService;
  1781. }
  1782. }
  1783. });
  1784. modalInstance.result.then(function(selectedItem) {
  1785. if (selectedItem) {
  1786. var data = {
  1787. 'requester': selectedItem
  1788. };
  1789. options.templateOptions.UserService.addData('requester', data).then(function(response) {
  1790. if (response.status == 200) {
  1791. options.value(response.data);
  1792. }
  1793. })
  1794. }
  1795. }, function() {
  1796. //console.log('Modal dismissed at: ' + new Date());
  1797. });
  1798. },
  1799. changeRequeter: function(size, options, modal) {
  1800. var modalInstance = modal.open({
  1801. templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
  1802. controller: function($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService) {
  1803. $scope.title = "修改请求人";
  1804. $scope.requester = {
  1805. account: options.model.requester.account,
  1806. name: options.model.requester.name,
  1807. gender: options.model.requester.gender,
  1808. email: options.model.requester.email,
  1809. deptName: options.model.requester.deptName,
  1810. mphone: options.model.requester.mphone,
  1811. telephone: options.model.requester.telephone
  1812. };
  1813. $scope.refreshDepts = function(key) {
  1814. var filterData = {
  1815. 'idx': 0,
  1816. 'sum': 5,
  1817. 'dept': {
  1818. 'name': key
  1819. }
  1820. };
  1821. UserService.fetchDataList('department', filterData).then(function(response) {
  1822. if (response.status == 200) {
  1823. $scope.depts = response.list;
  1824. }
  1825. })
  1826. }
  1827. $scope.ok = function() {
  1828. if ($scope.requester.account == "" || $scope.requester.name == "") {
  1829. SweetAlert.swal("请求人姓名或工号未填!", "请补全请求人信息", "error");
  1830. } else {
  1831. $modalInstance.close($scope.requester);
  1832. }
  1833. };
  1834. $scope.cancel = function() {
  1835. $modalInstance.dismiss('cancel');
  1836. };
  1837. },
  1838. size: size,
  1839. resolve: {
  1840. items: function() {
  1841. return {
  1842. fetchItems: function(filterData, APIService) {
  1843. filterData = filterData || {};
  1844. if (!filterData.idx) {
  1845. filterData = {
  1846. idx: 0,
  1847. sum: 10
  1848. };
  1849. }
  1850. return options.templateOptions.fetchItems(filterData, APIService);
  1851. }
  1852. };
  1853. },
  1854. title: function() {
  1855. return options.templateOptions.modalTitle;
  1856. },
  1857. Restangular: function() {
  1858. return options.templateOptions.Restangular;
  1859. },
  1860. APIService: function() {
  1861. return options.templateOptions.ApiService;
  1862. },
  1863. UserService: function() {
  1864. return options.templateOptions.UserService;
  1865. }
  1866. }
  1867. });
  1868. modalInstance.result.then(function(selectedItem) {
  1869. if (selectedItem) {
  1870. var data = {
  1871. 'requester': selectedItem
  1872. };
  1873. options.templateOptions.UserService.addData('requester', data).then(function(response) {
  1874. if (response.status == 200) {
  1875. options.value(response.data);
  1876. }
  1877. })
  1878. // }
  1879. }
  1880. }, function() {
  1881. //console.log('Modal dismissed at: ' + new Date());
  1882. });
  1883. }
  1884. }
  1885. };
  1886. },
  1887. controller: ['$scope', function($scope) {
  1888. $scope.options.templateOptions.that = $scope;
  1889. // console.log($scope.model.requester)
  1890. // api_user_data.fetchDataList('requester', {"idx":0,"sum":10}).then(function(data){
  1891. // var myData = Restangular.stripRestangular(data);
  1892. // $scope.gridOptions.totalItems = myData.totalNum;
  1893. // $scope.myData = myData.list;
  1894. // });
  1895. // if(model.){
  1896. // }
  1897. }]
  1898. });
  1899. //处理人信息
  1900. formlyConfigProvider.setType({
  1901. name: "ui-userinformation",
  1902. templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
  1903. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1904. defaultOptions: function(options) {
  1905. return {
  1906. templateOptions: {}
  1907. };
  1908. },
  1909. controller: ['$scope', function($scope) {
  1910. $scope.group = "";
  1911. $scope.role = "";
  1912. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  1913. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  1914. } else {
  1915. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  1916. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  1917. }
  1918. }
  1919. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  1920. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  1921. } else {
  1922. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  1923. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  1924. }
  1925. }
  1926. $scope.options.templateOptions.that = $scope;
  1927. }]
  1928. });
  1929. //处理界面处理人信息
  1930. formlyConfigProvider.setType({
  1931. name: "ui-handler",
  1932. templateUrl: 'assets/views/customform/tpl/ui-handler.html',
  1933. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1934. defaultOptions: function(options) {
  1935. return {
  1936. templateOptions: {}
  1937. };
  1938. },
  1939. controller: ['$scope', function($scope) {
  1940. $scope.group = "";
  1941. // $scope.role="";
  1942. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  1943. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  1944. } else {
  1945. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  1946. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  1947. }
  1948. }
  1949. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  1950. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  1951. // }else{
  1952. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  1953. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  1954. // }
  1955. // }
  1956. $scope.options.templateOptions.that = $scope;
  1957. }]
  1958. });
  1959. //关闭界面处理人信息
  1960. formlyConfigProvider.setType({
  1961. name: "ui-closehandler",
  1962. templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  1963. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1964. defaultOptions: function(options) {
  1965. return {
  1966. templateOptions: {}
  1967. };
  1968. },
  1969. controller: ['$scope', '$rootScope', 'api_text', function($scope, $rootScope, api_text) {
  1970. $scope.dialout = function(teleno) {
  1971. var gid = "@0"
  1972. var telephone = '9' + teleno
  1973. api_text.dialout($rootScope.takes, gid, telephone).then(function(data) {
  1974. if (data.errno == 0) {
  1975. $rootScope.status = 6;
  1976. }
  1977. })
  1978. }
  1979. $scope.options.templateOptions.that = $scope;
  1980. }]
  1981. });
  1982. // formlyConfigProvider.setType({
  1983. // name: "ui-closehandler",
  1984. // templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  1985. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1986. // defaultOptions:function(options){
  1987. // return {
  1988. // templateOptions: {
  1989. // }
  1990. // };
  1991. // },
  1992. // controller:['$scope','$rootScope','SweetAlert','api_text', function($scope,$rootScope,SweetAlert,api_text){
  1993. // $scope.group="";
  1994. // // $scope.role="";
  1995. // if(angular.isDefined($scope.model.handlingPersonnelUser.group) &&$scope.model.handlingPersonnelUser.group.length==1){
  1996. // $scope.group=$scope.model.handlingPersonnelUser.group[0].groupName;
  1997. // }else{
  1998. // for(var i=0;i<$scope.model.handlingPersonnelUser.group.length;i++){
  1999. // $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName +",";
  2000. // }
  2001. // }
  2002. // // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  2003. // // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  2004. // // }else{
  2005. // // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  2006. // // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  2007. // // }
  2008. // // }
  2009. // $scope.options.templateOptions.that = $scope;
  2010. // $scope.dialout = function(teleno){
  2011. // api_text.callout($rootScope.takes,teleno).then(function(data){
  2012. // if(data.errno==0){
  2013. // SweetAlert.swal({
  2014. // title: "呼叫成功",
  2015. // text: "呼叫中心呼叫成功!",
  2016. // type: "success"
  2017. // });
  2018. // }else{SweetAlert.swal({
  2019. // title: "呼叫失败",
  2020. // text: "请重新呼叫!",
  2021. // type: "error"
  2022. // });
  2023. // }
  2024. // })
  2025. // }
  2026. // }]
  2027. // });
  2028. //用户单选控件
  2029. formlyConfigProvider.setType({
  2030. name: "ui-userselect",
  2031. templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  2032. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2033. defaultOptions: function(options) {
  2034. return {
  2035. templateOptions: {
  2036. openModal: function(size, options, modal) {
  2037. var modalInstance = modal.open({
  2038. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  2039. controller: function($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  2040. $scope.langs = i18nService.getAllLangs();
  2041. $scope.lang = 'zh-cn';
  2042. i18nService.setCurrentLang($scope.lang);
  2043. $scope.gridOptions = {};
  2044. $scope.gridOptions.data = 'myData';
  2045. $scope.gridOptions.enableColumnResizing = true;
  2046. $scope.gridOptions.enableFiltering = true;
  2047. $scope.gridOptions.enableGridMenu = false;
  2048. $scope.gridOptions.showGridFooter = true;
  2049. $scope.gridOptions.showColumnFooter = true;
  2050. $scope.gridOptions.fastWatch = true;
  2051. $scope.gridOptions.useExternalFiltering = true;
  2052. $scope.gridOptions.useExternalPagination = true;
  2053. $scope.gridOptions.paginationPageSizes = [10];
  2054. $scope.gridOptions.paginationPageSize = 10;
  2055. $scope.gridOptions.multiSelect = false;
  2056. $scope.gridOptions.rowIdentity = function(row) {
  2057. return row.id;
  2058. };
  2059. $scope.gridOptions.getRowIdentity = function(row) {
  2060. return row.id;
  2061. };
  2062. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  2063. $scope.gridOptions.columnDefs = [
  2064. // { name:'id', width:80, enableFiltering:false},
  2065. { name: 'account', displayName: '工号', width: 120 },
  2066. { name: 'name', displayName: '名称', width: 100 },
  2067. { name: 'gender', displayName: '性别', width: 80, enableFiltering: false },
  2068. { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
  2069. { name: 'email', displayName: '邮件', width: 120, enableFiltering: false },
  2070. { name: 'dept.dept', displayName: '部门', width: 100, enableFiltering: false },
  2071. { name: 'role[0].role', displayName: '角色', width: 100, enableFiltering: false },
  2072. { name: 'taskCount', displayName: '处理中事件数', width: 100, enableFiltering: false }
  2073. ];
  2074. $scope.gridOptions.onRegisterApi = function(gridApi) {
  2075. $scope.gridApi = gridApi;
  2076. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  2077. var filtersData = $scope.memoryfilterData;
  2078. filtersData.idx = newPage - 1;
  2079. filtersData.sum = pageSize;
  2080. $scope.loadData(filtersData);
  2081. //console.log(pageSize);
  2082. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  2083. });
  2084. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  2085. $scope.selected.item = data.entity;
  2086. //console.log(data);
  2087. });
  2088. gridApi.core.on.filterChanged($scope, function() {
  2089. var grid = this.grid;
  2090. var filtersData = {
  2091. idx: 0,
  2092. sum: 10,
  2093. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  2094. };
  2095. angular.forEach(grid.columns, function(item) {
  2096. if (item.enableFiltering) {
  2097. console.log("item.filters[0]=" + JSON.stringify(item.filters));
  2098. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  2099. if (angular.isUndefined(filtersData['user'])) {
  2100. filtersData['user'] = {};
  2101. }
  2102. filtersData['user'][item.field] = item.filters[0].term;
  2103. }
  2104. }
  2105. });
  2106. $scope.memoryfilterData = filtersData;
  2107. $scope.loadData(filtersData);
  2108. });
  2109. };
  2110. if (!options.model) {
  2111. var mouse = { "model": { "currentRole": "" } };
  2112. angular.extend(options, mouse);
  2113. }
  2114. $scope.memoryfilterData = {
  2115. "idx": 0,
  2116. "sum": 10,
  2117. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  2118. }
  2119. $scope.loadData = function(filterData) {
  2120. console.log("filtersData=111" + JSON.stringify(filterData))
  2121. items.fetchItems(filterData, APIService).then(function(data) {
  2122. var myData = Restangular.stripRestangular(data);
  2123. $scope.gridOptions.totalItems = myData.totalNum;
  2124. $scope.myData = myData.list;
  2125. });
  2126. };
  2127. $scope.title = title;
  2128. $scope.loadData({
  2129. idx: 0,
  2130. sum: 10,
  2131. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  2132. });
  2133. $scope.selected = {
  2134. item: {}
  2135. };
  2136. $scope.ok = function() {
  2137. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  2138. // onDataCallback($scope.selected.item, parentScope);
  2139. // }
  2140. $modalInstance.close($scope.selected.item);
  2141. };
  2142. $scope.cancel = function() {
  2143. $modalInstance.dismiss('cancel');
  2144. };
  2145. },
  2146. size: size,
  2147. resolve: {
  2148. items: function() {
  2149. return {
  2150. fetchItems: function(filterData, APIService) {
  2151. filterData = filterData || {};
  2152. console.log(options)
  2153. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  2154. filterData = {
  2155. idx: 0,
  2156. sum: 10,
  2157. "user": { "roledata": { "rolecode": options.model.incident.currentRole }, "selectType": "1" }
  2158. };
  2159. }
  2160. // function (filterData, APIService){filterData.user.roledata.rolecode='question investigation';return APIService.fetchDataList('user',filterData);}
  2161. return options.templateOptions.fetchItems(filterData, APIService);
  2162. }
  2163. };
  2164. },
  2165. title: function() {
  2166. return options.templateOptions.modalTitle;
  2167. },
  2168. Restangular: function() {
  2169. return options.templateOptions.Restangular;
  2170. },
  2171. APIService: function() {
  2172. return options.templateOptions.ApiService;
  2173. },
  2174. onDataCallback: function() {
  2175. return options.templateOptions.callback;
  2176. },
  2177. parentScope: function() {
  2178. return options.templateOptions.that;
  2179. }
  2180. }
  2181. });
  2182. modalInstance.result.then(function(selectedItem) {
  2183. // console.log(selectedItem);
  2184. options.value(selectedItem);
  2185. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  2186. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  2187. }
  2188. }, function() {
  2189. //console.log('Modal dismissed at: ' + new Date());
  2190. });
  2191. }
  2192. }
  2193. };
  2194. },
  2195. controller: ['$scope', function($scope) {
  2196. $scope.model[$scope.options.key] = [];
  2197. $scope.options.templateOptions.that = $scope;
  2198. }]
  2199. });
  2200. //可编辑列表控件
  2201. // formlyConfigProvider.setType({
  2202. // name: "ui-multiuserselectchange",
  2203. // templateUrl: 'assets/views/customform/tpl/ui-multiuserselectchange.html',
  2204. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2205. // defaultOptions:function(options){
  2206. // return {
  2207. // templateOptions: {
  2208. // refresh:function(filterData,APIService){
  2209. // return APIService.fetchDataList('user',filterData);
  2210. // }
  2211. // },
  2212. // validators:{
  2213. // required:{
  2214. // expression:function(viewValue, modelValue){
  2215. // var value = modelValue || viewValue;
  2216. // return value.length>=1;
  2217. // }
  2218. // }
  2219. // }
  2220. // };
  2221. // },
  2222. // controller:['$scope','$filter', function($scope,$filter){
  2223. // $scope.model[$scope.options.key] = [];
  2224. // var filterData = {
  2225. // idx:0,
  2226. // sum:10,
  2227. // "user":{"roledata":{"rolecode":$scope.model.currentRole},"selectType":"1"}
  2228. // };
  2229. // $scope.options.templateOptions.refresh(filterData, $scope.options.templateOptions.ApiService).then(function(data){
  2230. // var myData = data.list;
  2231. // $scope.model[$scope.options.key]=myData;
  2232. // $scope.options.value(myData);
  2233. // $scope.options.formControl.$validate();
  2234. // });
  2235. // $scope.addlist = function(){
  2236. // $scope.editId =6;
  2237. // $scope.model[$scope.options.key].push("");
  2238. // }
  2239. // // $scope.tableParams = new ngTableParams({
  2240. // // page: 1,
  2241. // // count: 10
  2242. // // }, {
  2243. // // total: data.length,
  2244. // // getData: function ($defer, params) {
  2245. // // var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  2246. // // $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  2247. // // }
  2248. // // });
  2249. // $scope.editId = -1;
  2250. // $scope.setEditId = function (pid,usersdata) {
  2251. // $scope.usersdata={};
  2252. // $scope.editId = pid;
  2253. // angular.extend($scope.usersdata,usersdata)
  2254. // };
  2255. // $scope.savelist = function (usersdata,pid) {
  2256. // // console.log($scope.model[$scope.options.key])
  2257. // for(i=0;i<$scope.model[$scope.options.key].length;i++){
  2258. // if(usersdata.account==$scope.model[$scope.options.key][i].account){
  2259. // $scope.model[$scope.options.key][i]=$scope.usersdata;
  2260. // }
  2261. // }
  2262. // $scope.editId = pid;
  2263. // };
  2264. // $scope.remove = function(itemId){
  2265. // angular.forEach($scope.model[$scope.options.key], function(entry,index){
  2266. // if(entry.id == itemId){
  2267. // $scope.model[$scope.options.key].splice(index,1);
  2268. // console.log($scope.options.formControl)
  2269. // $scope.options.formControl.$validate();
  2270. // }else{
  2271. // }
  2272. // });
  2273. // }
  2274. // }]
  2275. // });
  2276. formlyConfigProvider.setType({
  2277. name: "ui-multiuserselectchange",
  2278. templateUrl: 'assets/views/customform/tpl/ui-multiuserselectchange.html',
  2279. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2280. defaultOptions: function(options) {
  2281. return {
  2282. templateOptions: {
  2283. // refresh:function(filterData,APIService){
  2284. // return APIService.fetchDataList('user',filterData);
  2285. // }
  2286. },
  2287. validators: {
  2288. required: {
  2289. expression: function(viewValue, modelValue) {
  2290. var value = modelValue || viewValue;
  2291. return value.length >= 1;
  2292. }
  2293. }
  2294. }
  2295. };
  2296. },
  2297. controller: ['$scope', '$filter', function($scope, $filter) {
  2298. $scope.model[$scope.options.key] = [];
  2299. var filterData = {
  2300. idx: 0,
  2301. sum: 10,
  2302. "user": { "roledata": { "rolecode": $scope.model.currentRole }, "selectType": "1" }
  2303. };
  2304. $scope.options.templateOptions.refresh(filterData, $scope.options.templateOptions.ApiService).then(function(data) {
  2305. var myData = data.list;
  2306. $scope.model[$scope.options.key] = myData;
  2307. $scope.options.value(myData);
  2308. $scope.options.formControl.$validate();
  2309. });
  2310. $scope.addlist = function() {
  2311. $scope.editId = 6;
  2312. $scope.model[$scope.options.key].push("");
  2313. }
  2314. $scope.editId = -1;
  2315. $scope.setEditId = function(pid, usersdata) {
  2316. $scope.usersdata = {};
  2317. $scope.editId = pid;
  2318. angular.extend($scope.usersdata, usersdata)
  2319. };
  2320. $scope.savelist = function(usersdata, pid) {
  2321. // console.log($scope.model[$scope.options.key])
  2322. for (i = 0; i < $scope.model[$scope.options.key].length; i++) {
  2323. if (usersdata.account == $scope.model[$scope.options.key][i].account) {
  2324. $scope.model[$scope.options.key][i] = $scope.usersdata;
  2325. }
  2326. }
  2327. $scope.editId = pid;
  2328. };
  2329. $scope.remove = function(itemId) {
  2330. angular.forEach($scope.model[$scope.options.key], function(entry, index) {
  2331. if (entry.id == itemId) {
  2332. $scope.model[$scope.options.key].splice(index, 1);
  2333. console.log($scope.options.formControl)
  2334. $scope.options.formControl.$validate();
  2335. } else {
  2336. }
  2337. });
  2338. }
  2339. }]
  2340. });
  2341. //用户多选控件
  2342. formlyConfigProvider.setType({
  2343. name: "ui-multiuserselect",
  2344. templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
  2345. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2346. defaultOptions: function(options) {
  2347. return {
  2348. templateOptions: {
  2349. openModal: function(size, options, modal, model) {
  2350. var modalInstance = modal.open({
  2351. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  2352. controller: function($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
  2353. $scope.langs = i18nService.getAllLangs();
  2354. $scope.lang = 'zh-cn';
  2355. i18nService.setCurrentLang($scope.lang);
  2356. $scope.gridOptions = {};
  2357. $scope.gridOptions.data = 'myData';
  2358. $scope.gridOptions.enableColumnResizing = true;
  2359. $scope.gridOptions.enableFiltering = true;
  2360. $scope.gridOptions.enableGridMenu = true;
  2361. $scope.gridOptions.showGridFooter = true;
  2362. $scope.gridOptions.showColumnFooter = true;
  2363. $scope.gridOptions.fastWatch = true;
  2364. $scope.gridOptions.useExternalFiltering = true;
  2365. $scope.gridOptions.useExternalPagination = true;
  2366. $scope.gridOptions.paginationPageSizes = [10];
  2367. $scope.gridOptions.paginationPageSize = 10;
  2368. $scope.gridOptions.multiSelect = true;
  2369. $scope.gridOptions.rowIdentity = function(row) {
  2370. return row.id;
  2371. };
  2372. $scope.gridOptions.getRowIdentity = function(row) {
  2373. return row.id;
  2374. };
  2375. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  2376. $scope.gridOptions.columnDefs = [
  2377. // { name:'id', width:80, enableFiltering:false},
  2378. { name: 'account', displayName: '账号', width: 140 },
  2379. { name: 'name', displayName: '名称', width: 100 },
  2380. { name: 'gender', displayName: '性别', width: 140, enableFiltering: false },
  2381. { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
  2382. { name: 'email', displayName: '邮件', width: 100, enableFiltering: false },
  2383. { name: 'dept.dept', displayName: '部门', width: 100, enableFiltering: false },
  2384. { name: 'group[0].groupName', displayName: '职位', width: 100, enableFiltering: false }
  2385. ];
  2386. $scope.selected = {
  2387. items: selectItems
  2388. };
  2389. $scope.gridOptions.onRegisterApi = function(gridApi) {
  2390. $scope.gridApi = gridApi;
  2391. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  2392. var filtersData = $scope.memoryfilterData;
  2393. filtersData.idx = newPage - 1;
  2394. filtersData.sum = pageSize;
  2395. $scope.loadData(filtersData);
  2396. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  2397. });
  2398. gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
  2399. var j = 0;
  2400. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  2401. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  2402. j++;
  2403. break;
  2404. }
  2405. }
  2406. if (j == 1) {
  2407. scope.grid.appScope.selected.items.splice(i, 1);
  2408. } else {
  2409. scope.grid.appScope.selected.items.push(scope.entity)
  2410. for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
  2411. for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
  2412. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  2413. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  2414. if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
  2415. scope.grid.appScope.selected.items.splice(i, 1);
  2416. }
  2417. }
  2418. }
  2419. }
  2420. });
  2421. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  2422. // $scope.grid.appScope.selected.items.push($scope.entity);
  2423. // });
  2424. gridApi.core.on.filterChanged($scope, function() {
  2425. var grid = this.grid;
  2426. var filtersData = {
  2427. idx: 0,
  2428. sum: 10,
  2429. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  2430. };
  2431. angular.forEach(grid.columns, function(item) {
  2432. if (item.enableFiltering) {
  2433. //console.log("filtersData="+JSON.stringify(filtersData))
  2434. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  2435. if (angular.isUndefined(filtersData['user'])) {
  2436. filtersData['user'] = {};
  2437. }
  2438. filtersData['user'][item.field] = item.filters[0].term;
  2439. }
  2440. }
  2441. });
  2442. $scope.memoryfilterData = filtersData;
  2443. $scope.loadData(filtersData);
  2444. });
  2445. };
  2446. if (!options.model) {
  2447. var mouse = { "model": { "currentRole": "" } };
  2448. angular.extend(options, mouse);
  2449. }
  2450. $scope.memoryfilterData = {
  2451. "idx": 0,
  2452. "sum": 10,
  2453. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  2454. }
  2455. $scope.loadData = function(filterData) {
  2456. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  2457. items.fetchItems(filterData, APIService).then(function(data) {
  2458. var myData = Restangular.stripRestangular(data);
  2459. $scope.gridOptions.totalItems = myData.totalNum;
  2460. $scope.myData = myData.list;
  2461. //console.log($scope.gridOptions.pagination.getTotalPages());
  2462. // if($scope.selected.items){
  2463. // angular.forEach($scope.selected.items,function(selectItem){
  2464. // $scope.gridApi.selection.selectRow(selectItem);
  2465. // });
  2466. // }
  2467. });
  2468. };
  2469. $scope.title = title;
  2470. $scope.loadData({
  2471. idx: 0,
  2472. sum: 10,
  2473. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  2474. });
  2475. // $timeout(function(){
  2476. // if($scope.selected.items){
  2477. // angular.forEach($scope.selected.items,function(selectItem){
  2478. // $scope.gridApi.selection.selectRow(selectItem);
  2479. // });
  2480. // }
  2481. // },2000)
  2482. $scope.ok = function() {
  2483. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  2484. $modalInstance.close($scope.selected.items);
  2485. };
  2486. $scope.cancel = function() {
  2487. $modalInstance.dismiss('cancel');
  2488. };
  2489. },
  2490. size: size,
  2491. resolve: {
  2492. items: function() {
  2493. return {
  2494. fetchItems: function(filterData, APIService) {
  2495. filterData = filterData || {};
  2496. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  2497. filterData = {
  2498. idx: 0,
  2499. sum: 10,
  2500. "user": { "roledata": { "rolecode": options.model.incident.currentRole }, "selectType": "1" }
  2501. };
  2502. }
  2503. return options.templateOptions.fetchItems(filterData, APIService);
  2504. }
  2505. };
  2506. },
  2507. title: function() {
  2508. return options.templateOptions.modalTitle;
  2509. },
  2510. Restangular: function() {
  2511. return options.templateOptions.Restangular;
  2512. },
  2513. APIService: function() {
  2514. return options.templateOptions.ApiService;
  2515. },
  2516. selectItems: function() {
  2517. return model || [];
  2518. }
  2519. }
  2520. });
  2521. modalInstance.result.then(function(selectedItem) {
  2522. options.value(selectedItem);
  2523. options.formControl.$validate();
  2524. }, function() {
  2525. //console.log('Modal dismissed at: ' + new Date());
  2526. });
  2527. }
  2528. },
  2529. validators: {
  2530. required: {
  2531. expression: function(viewValue, modelValue) {
  2532. var value = modelValue || viewValue;
  2533. return value.length >= 1;
  2534. }
  2535. }
  2536. }
  2537. };
  2538. },
  2539. controller: ['$scope', function($scope) {
  2540. $scope.model[$scope.options.key] = [];
  2541. $scope.remove = function(itemId) {
  2542. angular.forEach($scope.model[$scope.options.key], function(entry, index) {
  2543. if (entry.id == itemId) {
  2544. $scope.model[$scope.options.key].splice(index, 1);
  2545. console.log($scope.options.formControl)
  2546. $scope.options.formControl.$validate();
  2547. } else {
  2548. }
  2549. });
  2550. }
  2551. }]
  2552. });
  2553. //选项选择控件
  2554. formlyConfigProvider.setType({
  2555. name: "ui-modelselect",
  2556. extends: 'input',
  2557. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  2558. defaultOptions: function(options) {
  2559. return {
  2560. templateOptions: {
  2561. openModal: function(size, options, modal) {
  2562. var modalInstance = modal.open({
  2563. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  2564. controller: function($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  2565. $scope.langs = i18nService.getAllLangs();
  2566. $scope.lang = 'zh-cn';
  2567. i18nService.setCurrentLang($scope.lang);
  2568. $scope.gridOptions = {};
  2569. $scope.gridOptions.data = 'myData';
  2570. $scope.gridOptions.enableColumnResizing = true;
  2571. $scope.gridOptions.enableFiltering = true;
  2572. $scope.gridOptions.enableGridMenu = true;
  2573. $scope.gridOptions.showGridFooter = true;
  2574. $scope.gridOptions.showColumnFooter = true;
  2575. $scope.gridOptions.fastWatch = true;
  2576. $scope.gridOptions.useExternalPagination = true;
  2577. $scope.gridOptions.useExternalFiltering = true;
  2578. $scope.gridOptions.paginationPageSizes = [10];
  2579. $scope.gridOptions.paginationPageSize = 10;
  2580. $scope.gridOptions.multiSelect = false;
  2581. $scope.gridOptions.rowIdentity = function(row) {
  2582. return row.id;
  2583. };
  2584. $scope.gridOptions.getRowIdentity = function(row) {
  2585. return row.id;
  2586. };
  2587. $scope.gridOptions.columnDefs = items.columnDefs();
  2588. $scope.gridOptions.onRegisterApi = function(gridApi) {
  2589. $scope.gridApi = gridApi;
  2590. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  2591. // console.log(newPage);
  2592. // console.log(pageSize);
  2593. $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  2594. });
  2595. gridApi.core.on.filterChanged($scope, function() {
  2596. var grid = this.grid;
  2597. var filtersData = {
  2598. idx: 0,
  2599. sum: 10
  2600. };
  2601. angular.forEach(grid.columns, function(item) {
  2602. if (item.enableFiltering) {
  2603. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  2604. // console.log("filtersData="+JSON.stringify(filtersData))
  2605. if (angular.isUndefined(filtersData['incident'])) {
  2606. filtersData['incident'] = {};
  2607. }
  2608. filtersData['incident'][item.field] = item.filters[0].term;
  2609. if (angular.isUndefined(filtersData['problem'])) {
  2610. filtersData['problem'] = {};
  2611. }
  2612. filtersData['problem'][item.field] = item.filters[0].term;
  2613. if (angular.isUndefined(filtersData['change'])) {
  2614. filtersData['change'] = {};
  2615. }
  2616. filtersData['change'][item.field] = item.filters[0].term;
  2617. if (angular.isUndefined(filtersData['release'])) {
  2618. filtersData['release'] = {};
  2619. }
  2620. filtersData['release'][item.field] = item.filters[0].term;
  2621. }
  2622. }
  2623. });
  2624. $scope.loadData(filtersData);
  2625. });
  2626. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  2627. $scope.selected.item = data.entity;
  2628. //console.log(data);
  2629. });
  2630. };
  2631. $scope.loadData = function(filterData) {
  2632. items.fetchItems(filterData, APIService).then(function(data) {
  2633. var myData = Restangular.stripRestangular(data);
  2634. $scope.gridOptions.totalItems = myData.totalNum;
  2635. $scope.myData = myData.list;
  2636. });
  2637. };
  2638. $scope.title = title;
  2639. $scope.loadData({
  2640. idx: 0,
  2641. sum: 10
  2642. });
  2643. $scope.selected = {
  2644. item: {}
  2645. };
  2646. $scope.ok = function() {
  2647. //console.log($scope.selected.item);
  2648. $modalInstance.close($scope.selected.item);
  2649. };
  2650. $scope.cancel = function() {
  2651. $modalInstance.dismiss('cancel');
  2652. };
  2653. },
  2654. size: size,
  2655. resolve: {
  2656. items: function() {
  2657. return {
  2658. fetchItems: function(filterData, APIService) {
  2659. filterData = filterData || {};
  2660. // if(!filterData.idx){
  2661. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  2662. filterData = {
  2663. idx: 0,
  2664. sum: 10
  2665. };
  2666. }
  2667. return options.templateOptions.fetchItems(filterData, APIService, options);
  2668. },
  2669. columnDefs: function() {
  2670. return options.templateOptions.columnDefs;
  2671. }
  2672. };
  2673. },
  2674. title: function() {
  2675. return options.templateOptions.modalTitle;
  2676. },
  2677. Restangular: function() {
  2678. return options.templateOptions.Restangular;
  2679. },
  2680. APIService: function() {
  2681. return options.templateOptions.ApiService;
  2682. }
  2683. }
  2684. });
  2685. modalInstance.result.then(function(selectedItem) {
  2686. options.value(selectedItem);
  2687. }, function() {
  2688. //console.log('Modal dismissed at: ' + new Date());
  2689. });
  2690. }
  2691. }
  2692. };
  2693. }
  2694. });
  2695. formlyConfigProvider.setType({
  2696. name: 'ui-requestform',
  2697. extends: 'input',
  2698. templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
  2699. controller: ['$scope', function($scope) {
  2700. setTimeout(function() {
  2701. var filterData = {
  2702. "idx": 0,
  2703. "sum": 5,
  2704. "incident": { "requester": { "id": "" } }
  2705. }
  2706. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function(result) {
  2707. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  2708. });
  2709. }, 1000);
  2710. }]
  2711. });
  2712. //工单控件
  2713. formlyConfigProvider.setType({
  2714. name: 'ui-workernumber',
  2715. extends: 'input',
  2716. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  2717. controller: ['$scope', function($scope) {
  2718. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  2719. setTimeout(function() {
  2720. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result) {
  2721. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  2722. if (modelData.status == 200) {
  2723. $scope.model[$scope.options.key] = modelData.data;
  2724. $scope.options.initialValue = $scope.model[$scope.options.key];
  2725. }
  2726. });
  2727. }, 1000);
  2728. }
  2729. }]
  2730. });
  2731. //cmdb工单
  2732. formlyConfigProvider.setType({
  2733. name: 'ui-cmdbworkernumber',
  2734. extends: 'input',
  2735. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  2736. controller: ['$scope', function($scope) {
  2737. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  2738. setTimeout(function() {
  2739. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function(result) {
  2740. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  2741. // if(modelData.status==200){
  2742. $scope.model[$scope.options.key] = modelData[$scope.options.key];
  2743. $scope.options.initialValue = $scope.model[$scope.options.key];
  2744. // }
  2745. });
  2746. }, 1000);
  2747. }
  2748. }]
  2749. });
  2750. //无上传按钮附件上传组件
  2751. formlyConfigProvider.setType({
  2752. name: 'ui-dropfilenotup',
  2753. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  2754. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2755. controller: ['$scope', 'FileUploader', function($scope, FileUploader) {
  2756. // if(angular.isUndefined($scope.form.dropState)){
  2757. // $scope.form.dropState=false;
  2758. // }
  2759. // //附件上传数据
  2760. // var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader= new FileUploader({
  2761. // url: 'upload.php'
  2762. // });;
  2763. // //$scope.options.templateOptions.uploader();
  2764. //
  2765. // // FILTERS
  2766. // uploader.filters.push({
  2767. // name: 'customFilter',
  2768. // fn: function(item /*{File|FileLikeObject}*/ , options) {
  2769. // return this.queue.length < 10;
  2770. // }
  2771. // });
  2772. //
  2773. // uploader.filters.push({
  2774. // name: 'imageFilter',
  2775. // fn: function (item/*{File|FileLikeObject}*/, options) {
  2776. // var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
  2777. // return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
  2778. // }
  2779. // });
  2780. //
  2781. //
  2782. // $scope.dropfile = function(APIService, processInstanceId, taskId, userId){
  2783. // uploader.onBeforeUploadItem = function(item) {
  2784. // angular.extend(item.headers,$rootScope.getSession());
  2785. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  2786. // item.formData.push({'fileName':item.file.name});
  2787. // console.info('onBeforeUploadItem', item);
  2788. // };
  2789. // uploader.uploadAll();
  2790. // }
  2791. //
  2792. // // CALLBACKS
  2793. // uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  2794. // console.info('onWhenAddingFileFailed', item, filter, options);
  2795. // };
  2796. // uploader.onAfterAddingFile = function(fileItem) {
  2797. // console.info('onAfterAddingFile', fileItem);
  2798. // };
  2799. // uploader.onAfterAddingAll = function(addedFileItems) {
  2800. // console.info('onAfterAddingAll', addedFileItems);
  2801. // };
  2802. // uploader.onBeforeUploadItem = function(item) {
  2803. // // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  2804. // // // $scope.uploader.options.url();
  2805. // // $scope.uploader.onBeforeUploadItem = function(item) {
  2806. // // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  2807. // // console.info('onBeforeUploadItem', item);
  2808. // // };
  2809. // // $scope.uploader.uploadAll();
  2810. // // }
  2811. // console.info('onBeforeUploadItem', item);
  2812. // };
  2813. // uploader.onProgressItem = function(fileItem, progress) {
  2814. // console.info('onProgressItem', fileItem, progress);
  2815. // };
  2816. // uploader.onProgressAll = function(progress) {
  2817. // console.info('onProgressAll', progress);
  2818. // };
  2819. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  2820. // console.info('onSuccessItem', fileItem, response, status, headers);
  2821. // };
  2822. // uploader.onErrorItem = function(fileItem, response, status, headers) {
  2823. // console.info('onErrorItem', fileItem, response, status, headers);
  2824. // };
  2825. // uploader.onCancelItem = function(fileItem, response, status, headers) {
  2826. // console.info('onCancelItem', fileItem, response, status, headers);
  2827. // };
  2828. // uploader.onCompleteItem = function(fileItem, response, status, headers) {
  2829. // console.info('onCompleteItem', fileItem, response, status, headers);
  2830. // };
  2831. // uploader.onCompleteAll = function() {
  2832. // console.info('onCompleteAll');
  2833. // };
  2834. var uploaderImages = $scope.uploaderImages = new FileUploader({
  2835. url: 'upload.php'
  2836. });
  2837. // FILTERS
  2838. uploaderImages.filters.push({
  2839. name: 'imageFilter',
  2840. fn: function(item /*{File|FileLikeObject}*/ , options) {
  2841. var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
  2842. return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
  2843. }
  2844. });
  2845. // CALLBACKS
  2846. uploaderImages.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  2847. console.info('onWhenAddingFileFailed', item, filter, options);
  2848. };
  2849. uploaderImages.onAfterAddingFile = function(fileItem) {
  2850. console.info('onAfterAddingFile', fileItem);
  2851. };
  2852. uploaderImages.onAfterAddingAll = function(addedFileItems) {
  2853. console.info('onAfterAddingAll', addedFileItems);
  2854. };
  2855. uploaderImages.onBeforeUploadItem = function(item) {
  2856. console.info('onBeforeUploadItem', item);
  2857. };
  2858. uploaderImages.onProgressItem = function(fileItem, progress) {
  2859. console.info('onProgressItem', fileItem, progress);
  2860. };
  2861. uploaderImages.onProgressAll = function(progress) {
  2862. console.info('onProgressAll', progress);
  2863. };
  2864. uploaderImages.onSuccessItem = function(fileItem, response, status, headers) {
  2865. console.info('onSuccessItem', fileItem, response, status, headers);
  2866. };
  2867. uploaderImages.onErrorItem = function(fileItem, response, status, headers) {
  2868. console.info('onErrorItem', fileItem, response, status, headers);
  2869. };
  2870. uploaderImages.onCancelItem = function(fileItem, response, status, headers) {
  2871. console.info('onCancelItem', fileItem, response, status, headers);
  2872. };
  2873. uploaderImages.onCompleteItem = function(fileItem, response, status, headers) {
  2874. console.info('onCompleteItem', fileItem, response, status, headers);
  2875. };
  2876. uploaderImages.onCompleteAll = function() {
  2877. console.info('onCompleteAll');
  2878. };
  2879. console.info('uploader', uploaderImages);
  2880. }]
  2881. });
  2882. //无按钮知识库上传
  2883. formlyConfigProvider.setType({
  2884. name: 'ui-dropfielkn',
  2885. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  2886. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2887. controller: ['$scope', function($scope) {
  2888. if (angular.isUndefined($scope.form.dropState)) {
  2889. $scope.form.dropState = false;
  2890. }
  2891. //附件上传数据
  2892. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  2893. //$scope.options.templateOptions.uploader();
  2894. // FILTERS
  2895. uploader.filters.push({
  2896. name: 'customFilter',
  2897. fn: function(item /*{File|FileLikeObject}*/ , options) {
  2898. return this.queue.length < 10;
  2899. }
  2900. });
  2901. $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
  2902. uploader.onBeforeUploadItem = function(item) {
  2903. angular.extend(item.headers, $rootScope.getSession());
  2904. item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
  2905. item.formData.push({ 'fileName': item.file.name });
  2906. console.info('onBeforeUploadItem', item);
  2907. };
  2908. uploader.uploadAll();
  2909. }
  2910. // CALLBACKS
  2911. uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  2912. console.info('onWhenAddingFileFailed', item, filter, options);
  2913. };
  2914. uploader.onAfterAddingFile = function(fileItem) {
  2915. console.info('onAfterAddingFile', fileItem);
  2916. };
  2917. uploader.onAfterAddingAll = function(addedFileItems) {
  2918. console.info('onAfterAddingAll', addedFileItems);
  2919. };
  2920. uploader.onBeforeUploadItem = function(item) {
  2921. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  2922. // // $scope.uploader.options.url();
  2923. // $scope.uploader.onBeforeUploadItem = function(item) {
  2924. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  2925. // console.info('onBeforeUploadItem', item);
  2926. // };
  2927. // $scope.uploader.uploadAll();
  2928. // }
  2929. console.info('onBeforeUploadItem', item);
  2930. };
  2931. uploader.onProgressItem = function(fileItem, progress) {
  2932. console.info('onProgressItem', fileItem, progress);
  2933. };
  2934. uploader.onProgressAll = function(progress) {
  2935. console.info('onProgressAll', progress);
  2936. };
  2937. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  2938. console.info('onSuccessItem', fileItem, response, status, headers);
  2939. };
  2940. uploader.onErrorItem = function(fileItem, response, status, headers) {
  2941. console.info('onErrorItem', fileItem, response, status, headers);
  2942. };
  2943. uploader.onCancelItem = function(fileItem, response, status, headers) {
  2944. console.info('onCancelItem', fileItem, response, status, headers);
  2945. };
  2946. uploader.onCompleteItem = function(fileItem, response, status, headers) {
  2947. console.info('onCompleteItem', fileItem, response, status, headers);
  2948. };
  2949. uploader.onCompleteAll = function() {
  2950. console.info('onCompleteAll');
  2951. };
  2952. }]
  2953. });
  2954. //附件上传列表组件
  2955. formlyConfigProvider.setType({
  2956. name: 'ui-dropfile',
  2957. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  2958. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2959. controller: ['$scope', '$rootScope', function($scope, $rootScope) {
  2960. if (angular.isUndefined($scope.form.dropState)) {
  2961. $scope.form.dropState = false;
  2962. }
  2963. //附件上传数据
  2964. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  2965. //$scope.options.templateOptions.uploader();
  2966. // FILTERS
  2967. uploader.filters.push({
  2968. name: 'customFilter',
  2969. fn: function(item /*{File|FileLikeObject}*/ , options) {
  2970. return this.queue.length < 10;
  2971. }
  2972. });
  2973. $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
  2974. uploader.onBeforeUploadItem = function(item) {
  2975. angular.extend(item.headers, $rootScope.getSession());
  2976. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  2977. item.formData.push({ 'fileName': item.file.name });
  2978. console.info('onBeforeUploadItem', item);
  2979. };
  2980. uploader.uploadAll();
  2981. }
  2982. // CALLBACKS
  2983. uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  2984. console.info('onWhenAddingFileFailed', item, filter, options);
  2985. };
  2986. uploader.onAfterAddingFile = function(fileItem) {
  2987. console.info('onAfterAddingFile', fileItem);
  2988. };
  2989. uploader.onAfterAddingAll = function(addedFileItems) {
  2990. console.info('onAfterAddingAll', addedFileItems);
  2991. };
  2992. uploader.onBeforeUploadItem = function(item) {
  2993. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  2994. // // $scope.uploader.options.url();
  2995. // $scope.uploader.onBeforeUploadItem = function(item) {
  2996. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  2997. // console.info('onBeforeUploadItem', item);
  2998. // };
  2999. // $scope.uploader.uploadAll();
  3000. // }
  3001. console.info('onBeforeUploadItem', item);
  3002. };
  3003. uploader.onProgressItem = function(fileItem, progress) {
  3004. console.info('onProgressItem', fileItem, progress);
  3005. };
  3006. uploader.onProgressAll = function(progress) {
  3007. console.info('onProgressAll', progress);
  3008. };
  3009. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3010. console.info('onSuccessItem', fileItem, response, status, headers);
  3011. };
  3012. uploader.onErrorItem = function(fileItem, response, status, headers) {
  3013. console.info('onErrorItem', fileItem, response, status, headers);
  3014. };
  3015. uploader.onCancelItem = function(fileItem, response, status, headers) {
  3016. console.info('onCancelItem', fileItem, response, status, headers);
  3017. };
  3018. uploader.onCompleteItem = function(fileItem, response, status, headers) {
  3019. console.info('onCompleteItem', fileItem, response, status, headers);
  3020. };
  3021. uploader.onCompleteAll = function() {
  3022. console.info('onCompleteAll');
  3023. };
  3024. }]
  3025. });
  3026. //知识库附件上传
  3027. formlyConfigProvider.setType({
  3028. name: 'ui-dropfielknow',
  3029. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  3030. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  3031. controller: ['$scope', '$rootScope', function($scope, $rootScope) {
  3032. if (angular.isUndefined($scope.form.dropState)) {
  3033. $scope.form.dropState = false;
  3034. }
  3035. //附件上传数据
  3036. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3037. //$scope.options.templateOptions.uploader();
  3038. // FILTERS
  3039. uploader.filters.push({
  3040. name: 'customFilter',
  3041. fn: function(item /*{File|FileLikeObject}*/ , options) {
  3042. return this.queue.length < 10;
  3043. }
  3044. });
  3045. $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
  3046. uploader.onBeforeUploadItem = function(item) {
  3047. angular.extend(item.headers, $rootScope.getSession());
  3048. item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
  3049. item.formData.push({ 'fileName': item.file.name, 'type': 'solution', 'solutionId': $scope.model.knowledge.id });
  3050. console.info('onBeforeUploadItem', item);
  3051. };
  3052. uploader.uploadAll();
  3053. }
  3054. // CALLBACKS
  3055. uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  3056. console.info('onWhenAddingFileFailed', item, filter, options);
  3057. };
  3058. uploader.onAfterAddingFile = function(fileItem) {
  3059. console.info('onAfterAddingFile', fileItem);
  3060. };
  3061. uploader.onAfterAddingAll = function(addedFileItems) {
  3062. console.info('onAfterAddingAll', addedFileItems);
  3063. };
  3064. uploader.onBeforeUploadItem = function(item) {
  3065. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  3066. // // $scope.uploader.options.url();
  3067. // $scope.uploader.onBeforeUploadItem = function(item) {
  3068. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  3069. // console.info('onBeforeUploadItem', item);
  3070. // };
  3071. // $scope.uploader.uploadAll();
  3072. // }
  3073. console.info('onBeforeUploadItem', item);
  3074. };
  3075. uploader.onProgressItem = function(fileItem, progress) {
  3076. console.info('onProgressItem', fileItem, progress);
  3077. };
  3078. uploader.onProgressAll = function(progress) {
  3079. console.info('onProgressAll', progress);
  3080. };
  3081. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3082. console.info('onSuccessItem', fileItem, response, status, headers);
  3083. };
  3084. uploader.onErrorItem = function(fileItem, response, status, headers) {
  3085. console.info('onErrorItem', fileItem, response, status, headers);
  3086. };
  3087. uploader.onCancelItem = function(fileItem, response, status, headers) {
  3088. console.info('onCancelItem', fileItem, response, status, headers);
  3089. };
  3090. uploader.onCompleteItem = function(fileItem, response, status, headers) {
  3091. console.info('onCompleteItem', fileItem, response, status, headers);
  3092. };
  3093. uploader.onCompleteAll = function() {
  3094. console.info('onCompleteAll');
  3095. };
  3096. }]
  3097. });
  3098. //知识库附件下载列表
  3099. formlyConfigProvider.setType({
  3100. name: 'ui-dropfileknowledge',
  3101. templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
  3102. defaultOptions: function(options) {
  3103. return {
  3104. templateOptions: {
  3105. refresh: function(APIService, contentId, data) {
  3106. return APIService.fetchDataList(contentId, data);
  3107. },
  3108. downloadUri: function(APIService, contentId) {
  3109. return APIService.downloadAttachment(contentId).getRequestedUrl();
  3110. },
  3111. download: function(APIService, contentId) {
  3112. return APIService.getSolutionDowpath(contentId);
  3113. },
  3114. view: function(attachmentId) {
  3115. // return APIService.attachmentsPreviewUrl(contentId);
  3116. },
  3117. refreshDelay: 0
  3118. }
  3119. };
  3120. },
  3121. controller: ['$scope', '$timeout', '$rootScope', 'api_solution', '$http', function($scope, $timeout, $rootScope, api_solution, $http) {
  3122. var _refreshDelayPromise;
  3123. $scope.downloadUrl = function(contentId) {
  3124. return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
  3125. };
  3126. $scope.download = function(contentId, filename) {
  3127. $http({
  3128. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
  3129. method: 'GET',
  3130. headers: {
  3131. //'Content-type' : 'application/xls',
  3132. 'Accept': '*/*'
  3133. },
  3134. responseType: 'arraybuffer'
  3135. }).success(function(data, status, headers, config) {
  3136. var file = new Blob([data], {
  3137. type: 'application/octet-stream'
  3138. });
  3139. //trick to download store a file having its URL
  3140. var fileURL = URL.createObjectURL(file);
  3141. var a = document.createElement('a');
  3142. a.href = fileURL;
  3143. a.target = '_blank';
  3144. a.download = filename;
  3145. document.body.appendChild(a);
  3146. a.click();
  3147. }).error(function(data, status, headers, config) {
  3148. console.log(data);
  3149. });
  3150. }
  3151. $scope._refresh = function(refreshAttr) {
  3152. if (refreshAttr !== undefined) {
  3153. if (_refreshDelayPromise) {
  3154. $timeout.cancel(_refreshDelayPromise);
  3155. }
  3156. _refreshDelayPromise = $timeout(function() {
  3157. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  3158. 'file', { "file": { "solutionId": $scope.model.knowledge.id }, "idx": "0", "sum": "1000" }).then(function(response) {
  3159. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  3160. if (myData) {
  3161. $scope.attachments = myData.list;
  3162. $scope.view = function(attachmentId) {
  3163. for (var i = 0; i < $scope.attachments.length; i++) {
  3164. if ($scope.attachments[i].id == attachmentId) {
  3165. window.open($scope.attachments[i].previewUrl);
  3166. // var modalInstance = $modal.open({
  3167. // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  3168. // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  3169. // }
  3170. // });
  3171. }
  3172. }
  3173. };
  3174. }
  3175. });
  3176. }, $scope.options.templateOptions.refreshDelay);
  3177. }
  3178. }
  3179. $scope._refresh({});
  3180. // $scope.attachments = $scope.model[$scope.options.key]
  3181. }]
  3182. });
  3183. //附件下载列表组件
  3184. formlyConfigProvider.setType({
  3185. name: 'ui-dropfiletable',
  3186. templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
  3187. defaultOptions: function(options) {
  3188. return {
  3189. templateOptions: {
  3190. refresh: function(APIService, processInstanceId, data) {
  3191. return APIService.listAttachments(processInstanceId, data);
  3192. },
  3193. downloadUri: function(APIService, contentId) {
  3194. return APIService.downloadAttachment(contentId).getRequestedUrl();
  3195. },
  3196. view: function(APIService, contentId) {
  3197. return APIService.attachmentsPreviewUrl(contentId);
  3198. },
  3199. download: function(APIService, contentId, item) {
  3200. var item = { 'url': APIService.download(contentId), 'headers': headers };
  3201. return item;
  3202. },
  3203. refreshDelay: 0
  3204. }
  3205. };
  3206. },
  3207. controller: ['$scope', '$timeout', '$rootScope', '$http', function($scope, $timeout, $rootScope, $http) {
  3208. var _refreshDelayPromise;
  3209. // $scope.downloadUrl = function(contentId){
  3210. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  3211. // };
  3212. $scope.download = function(contentId, filename) {
  3213. // var headers=
  3214. $http({
  3215. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  3216. method: 'GET',
  3217. headers: {
  3218. //'Content-type' : 'application/xls',
  3219. 'Accept': '*/*'
  3220. },
  3221. responseType: 'arraybuffer'
  3222. }).success(function(data, status, headers, config) {
  3223. var file = new Blob([data], {
  3224. type: 'application/octet-stream'
  3225. });
  3226. //trick to download store a file having its URL
  3227. var fileURL = URL.createObjectURL(file);
  3228. var a = document.createElement('a');
  3229. a.href = fileURL;
  3230. a.target = '_blank';
  3231. a.download = filename;
  3232. document.body.appendChild(a);
  3233. a.click();
  3234. }).error(function(data, status, headers, config) {
  3235. console.log(data);
  3236. });
  3237. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  3238. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  3239. // var file = new Blob([response], {
  3240. // type : 'application/octet-stream'
  3241. // });
  3242. // // var filename = filename;
  3243. // //var file = new Blob([response], {type: 'application/pdf'});
  3244. // var fileURL = URL.createObjectURL(file);
  3245. // var a = document.createElement('a');
  3246. // a.href = fileURL;
  3247. // a.target = '_blank';
  3248. // a.download = filename ;
  3249. // document.body.appendChild(a);
  3250. // a.click();
  3251. // })
  3252. };
  3253. $scope.view = function(contentId) {
  3254. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  3255. if (response.state == 200) {
  3256. window.open(response.previewUrl);
  3257. }
  3258. })
  3259. };
  3260. /**
  3261. * refresh
  3262. */
  3263. $scope._refresh = function(refreshAttr) {
  3264. if (refreshAttr !== undefined) {
  3265. if (_refreshDelayPromise) {
  3266. $timeout.cancel(_refreshDelayPromise);
  3267. }
  3268. _refreshDelayPromise = $timeout(function() {
  3269. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  3270. $scope.options.templateOptions.processInstanceId, { 'idx': 0, 'sum': 1000 }).then(function(response) {
  3271. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  3272. if (myData) {
  3273. $scope.attachments = myData.data;
  3274. }
  3275. });
  3276. }, $scope.options.templateOptions.refreshDelay);
  3277. }
  3278. }
  3279. $scope._refresh({});
  3280. // $scope.attachments = $scope.model[$scope.options.key]
  3281. }]
  3282. });
  3283. formlyConfigProvider.setType({
  3284. name: 'ui-paralleltask',
  3285. templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
  3286. defaultOptions: function(options) {
  3287. return {
  3288. templateOptions: {
  3289. refresh: function(APIService, processInstanceId, data) {
  3290. //return APIService.listAttachments(processInstanceId, data);
  3291. },
  3292. refreshDelay: 0
  3293. }
  3294. };
  3295. },
  3296. controller: ['$scope', '$timeout', function($scope, $timeout) {}]
  3297. });
  3298. //repeatSection
  3299. //
  3300. formlyConfigProvider.setType({
  3301. name: 'ui-repeatSection',
  3302. templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
  3303. defaultOptions: function(options) {
  3304. return {
  3305. templateOptions: {
  3306. unique: 1,
  3307. initDisplay: false
  3308. }
  3309. };
  3310. },
  3311. controller: function($scope) {
  3312. //$scope.options.templateOptions.unique;
  3313. $scope.formOptions = { formState: $scope.formState };
  3314. $scope.addNew = addNew;
  3315. $scope.copyFields = copyFields;
  3316. function copyFields(fields) {
  3317. fields = angular.copy(fields);
  3318. addRandomIds(fields);
  3319. return fields;
  3320. }
  3321. function addNew() {
  3322. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
  3323. var repeatsection = $scope.model[$scope.options.key];
  3324. var lastSection = repeatsection[repeatsection.length - 1];
  3325. var newsection = {};
  3326. // if (lastSection) {
  3327. // newsection = angular.copy(lastSection);
  3328. // }
  3329. repeatsection.push(newsection);
  3330. }
  3331. function addRandomIds(fields) {
  3332. $scope.options.templateOptions.unique++;
  3333. angular.forEach(fields, function(field, index) {
  3334. if (field.fieldGroup) {
  3335. addRandomIds(field.fieldGroup);
  3336. return; // fieldGroups don't need an ID
  3337. }
  3338. if (field.templateOptions && field.templateOptions.fields) {
  3339. addRandomIds(field.templateOptions.fields);
  3340. }
  3341. field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
  3342. });
  3343. }
  3344. function getRandomInt(min, max) {
  3345. return Math.floor(Math.random() * (max - min)) + min;
  3346. }
  3347. if ($scope.options.templateOptions.initDisplay) {
  3348. addNew();
  3349. }
  3350. }
  3351. });
  3352. //时间轴任务列表组件
  3353. // //主题控件
  3354. // formlyConfigProvider.setType({
  3355. // name: 'ui-titlesearch',
  3356. // templateUrl: 'assets/views/customform/tpl/ui-knowledge.html',
  3357. // extends: 'input',
  3358. // templateUrl : 'assets/views/system/tpl/asideContent.html',
  3359. // defaultOptions:function(options){
  3360. // return {
  3361. // };
  3362. // },
  3363. // controller: ['$scope','$aside',function($scope,$aside){
  3364. // $scope.openAside = function (position) {
  3365. // $aside.open({
  3366. // templateUrl: 'asideContent.html',
  3367. // placement: position,
  3368. // size: 'sm',
  3369. // backdrop: true,
  3370. // controller: function ($scope, $modalInstance) {
  3371. // $scope.ok = function (e) {
  3372. // $modalInstance.close();
  3373. // e.stopPropagation();
  3374. // };
  3375. // $scope.cancel = function (e) {
  3376. // $modalInstance.dismiss();
  3377. // e.stopPropagation();
  3378. // };
  3379. // }
  3380. // });
  3381. // };
  3382. // }]
  3383. // })
  3384. //知识库按钮组件
  3385. formlyConfigProvider.setType({
  3386. name: 'ui-search',
  3387. templateUrl: 'assets/views/customform/tpl/ui-knowledge.html',
  3388. defaultOptions: function(options) {
  3389. return {
  3390. templateOptions: {
  3391. search: function(size, options, modal, keys, fields, el) {
  3392. var modalInstance = modal.open({
  3393. templateUrl: 'assets/views/customform/tpl/search-knowledge.html',
  3394. controller: function($rootScope, $scope, $modalInstance, searchKey, title, Restangular, APIService, modelscope, relatedAction) {
  3395. $scope.options = {
  3396. language: 'zh-cn',
  3397. allowedContent: true,
  3398. entities: false
  3399. };
  3400. $scope.onReady = function() {
  3401. // ...
  3402. };
  3403. $scope.searchKey = searchKey;
  3404. $scope.search = function(key) {
  3405. // var datas={'key':key}
  3406. APIService.searchSolutionByKey(key, $rootScope.user.id).then(function(response) {
  3407. var myData = Restangular.stripRestangular(response);
  3408. // var status=myData.status;
  3409. // if(status=="500"){
  3410. // //toaster.pop('warning', '没有数据', '查询'+keys+'没有数据');
  3411. // }else
  3412. if (myData && myData.length > 0) {
  3413. var data = myData;
  3414. if (data.length > 0) {
  3415. $scope.searchData = data;
  3416. }
  3417. }
  3418. });
  3419. };
  3420. $scope.related = function(item) {
  3421. // angular.forEach(fields, function(field){
  3422. // if(field.key == 'directClose'){
  3423. // field.value(true);
  3424. // modelscope.$parent.$parent.$parent.model['start_code']='close';
  3425. // }
  3426. // if(field.key == 'handleDescription'){
  3427. // field.model['handleDescription']=tentity.content;
  3428. // }
  3429. // });
  3430. if (relatedAction && angular.isFunction(relatedAction)) {
  3431. relatedAction(fields, modelscope, item);
  3432. }
  3433. $scope.cancel();
  3434. // angular.forEach(fields,function(field){
  3435. // });
  3436. }
  3437. $scope.title = title;
  3438. $scope.search(searchKey);
  3439. $scope.selected = {
  3440. item: {}
  3441. };
  3442. $scope.ok = function() {
  3443. //console.log($scope.selected.item);
  3444. $modalInstance.close($scope.selected.item);
  3445. };
  3446. $scope.cancel = function() {
  3447. $modalInstance.dismiss('cancel');
  3448. };
  3449. },
  3450. size: size,
  3451. resolve: {
  3452. searchKey: function() {
  3453. return keys;
  3454. },
  3455. title: function() {
  3456. return options.templateOptions.modalTitle;
  3457. },
  3458. Restangular: function() {
  3459. return options.templateOptions.Restangular;
  3460. },
  3461. APIService: function() {
  3462. return options.templateOptions.ApiService;
  3463. },
  3464. modelscope: function() {
  3465. return el.$parent;
  3466. },
  3467. relatedAction: function() {
  3468. return options.templateOptions.relationAction;
  3469. }
  3470. }
  3471. });
  3472. // modalInstance.result.then(function(selectedItem) {
  3473. // options.value(selectedItem);
  3474. // }, function() {
  3475. // //console.log('Modal dismissed at: ' + new Date());
  3476. // });
  3477. }
  3478. }
  3479. };
  3480. },
  3481. controller: ['$scope', function($scope) {
  3482. // $scope.searchModal = $scope.model[$scope.options.key];
  3483. // $scope.$watch('searchModal',function(newValue, oldValue){
  3484. // if (newValue === oldValue) { return; }
  3485. // if (newValue.flag == oldValue.flag) { return; }
  3486. // if (angular.isDefined(newValue.flag)&&(newValue.flag==true)){
  3487. // if (newValue.searchKey!=''&&angular.isDefined(newValue.searchKey)){
  3488. // $scope.options.templateOptions.search('lg',$scope.options,newValue.searchKey);
  3489. // }
  3490. // }
  3491. // })
  3492. //
  3493. }]
  3494. });
  3495. //cmdb控件
  3496. formlyConfigProvider.setType({
  3497. name: 'ui-cmdb',
  3498. extends: 'input',
  3499. templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
  3500. defaultOptions: function(options) {
  3501. return {
  3502. templateOptions: {
  3503. onClick: function(size, options, modal, event, model) {
  3504. var modalInstance = modal.open({
  3505. templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
  3506. controller: function($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster) {
  3507. var width = $scope.width = 600;
  3508. var height = $scope.height = 400;
  3509. var tree;
  3510. var d3 = window.d3;
  3511. $scope.my_tree_handler = function(branch) {
  3512. //var _ref;
  3513. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  3514. APIService.query({ 'sign': classify }).then(function(data) {
  3515. var myData = Restangular.stripRestangular(data);
  3516. console.log(myData.data.node);
  3517. if (myData.data && myData.status == 200) {
  3518. var ret = myData.data;
  3519. redrawSvg(myData);
  3520. }
  3521. });
  3522. };
  3523. $scope.my_data = [];
  3524. function convertListToTree(data, treeMap) {
  3525. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3526. var root = null; //Initially set our loop to null
  3527. var parentNode = null;
  3528. //loop over data
  3529. for (var i = 0; i < data.length; i++) {
  3530. var datum = data[i];
  3531. //each node will have children, so let's give it a "children" poperty
  3532. datum.children = [];
  3533. //add an entry for this node to the map so that any future children can
  3534. //lookup the parent
  3535. idToNodeMap[datum.id] = datum;
  3536. //Does this node have a parent?
  3537. if (typeof datum.parent === "undefined" || datum.parent == null) {
  3538. //Doesn't look like it, so this node is the root of the tree
  3539. root = datum;
  3540. treeMap[datum.id] = root;
  3541. } else {
  3542. //This node has a parent, so let's look it up using the id
  3543. parentNode = idToNodeMap[datum.parent.id];
  3544. //We don't need this property, so let's delete it.
  3545. delete datum.parent;
  3546. //Let's add the current node as a child of the parent node.
  3547. parentNode.children.push(datum);
  3548. }
  3549. }
  3550. return root;
  3551. }
  3552. function convertParentToChildList(data) {
  3553. var treeMap = {};
  3554. var list = [];
  3555. convertListToTree(data, treeMap);
  3556. angular.forEach(treeMap, function(item) {
  3557. list.push(item);
  3558. });
  3559. return list;
  3560. }
  3561. $scope.my_tree = tree = {};
  3562. $scope.try_async_load = function() {
  3563. $scope.my_data = [];
  3564. $scope.select_treedata = [];
  3565. $scope.doing_async = true;
  3566. ConfigDataService.fetchDataList('ciclassify', { 'idx': 0, 'sum': 100 }).then(function(result) {
  3567. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  3568. $scope.doing_async = false;
  3569. });
  3570. };
  3571. $scope.select_treedata = [];
  3572. $scope.propTypeOptions = [];
  3573. $scope.try_async_load();
  3574. $scope.onFilterCallback = function(item) {
  3575. //console.log(item);
  3576. if (angular.isDefined(item.children) && item.children.length >= 1) {
  3577. //not valid
  3578. } else {
  3579. var tempclassify = item.prefix.toLowerCase() + item.sign;
  3580. $scope.cifilter_classic = tempclassify;
  3581. ConfigFormService.renderTabForm(tempclassify).then(function(data) {
  3582. var myData = Restangular.stripRestangular(data);
  3583. $scope.propTypeOptions = myData;
  3584. });
  3585. }
  3586. }
  3587. $scope.onPropTypeChange = function(form) {
  3588. $scope.propOptions = form.fields;
  3589. }
  3590. $scope.onPropChange = function(prop) {
  3591. $scope.cifilter_prop = prop;
  3592. }
  3593. $scope.searchCI = function(searchKey, propObj, ciclassify) {
  3594. //if(searchKey!=null&&searchKey.length>1){
  3595. var searchData = {};
  3596. if (angular.isUndefined(propObj)) {
  3597. propObj = $scope.cifilter_prop;
  3598. }
  3599. if (angular.isUndefined(ciclassify)) {
  3600. ciclassify = $scope.cifilter_classic;
  3601. }
  3602. searchData['sign'] = ciclassify;
  3603. if (angular.isDefined(propObj)) {
  3604. searchData[propObj.key] = searchKey;
  3605. }
  3606. APIService.query(searchData).then(function(response) {
  3607. var data = Restangular.stripRestangular(response);
  3608. //此处不清空nodes
  3609. var node = data.data.node;
  3610. var tempNode = [];
  3611. //nodes 或者links 要去重
  3612. for (var i = 0; i < node.length; i++) {
  3613. var tmp = 0;
  3614. for (var j = 0; j < nodes.length; j++) {
  3615. if (node[i].uuid == nodes[j].uuid) {
  3616. tmp++;
  3617. break;
  3618. }
  3619. }
  3620. if (tmp == 0) {
  3621. tempNode.push(node[i]);
  3622. }
  3623. }
  3624. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  3625. nodes.push(tempNode[i]);
  3626. }
  3627. restart();
  3628. })
  3629. }
  3630. $scope.refresh = function() {
  3631. nodes.length = 0;
  3632. links.length = 0;
  3633. restart();
  3634. }
  3635. $scope.traversal = function() {
  3636. if ($scope.selected_node == null) {
  3637. SweetAlert.swal({
  3638. title: "错误的操作!",
  3639. text: "没有配置项被选中!",
  3640. type: "error"
  3641. });
  3642. } else {
  3643. var uuid = $scope.selected_node.uuid;
  3644. APIService.traversal(uuid).then(function(response) {
  3645. var d = response.data;
  3646. var node = d.node;
  3647. var link = d.edge;
  3648. var tempNode = [];
  3649. var tempLink = [];
  3650. //nodes 或者links 要去重
  3651. for (var i = 0; i < node.length; i++) {
  3652. var tmp = 0;
  3653. for (var j = 0; j < nodes.length; j++) {
  3654. if (node[i].id == nodes[j].id) {
  3655. tmp++;
  3656. break;
  3657. }
  3658. }
  3659. if (tmp == 0) {
  3660. tempNode.push(node[i]);
  3661. }
  3662. }
  3663. for (var i = 0; i < link.length; i++) {
  3664. var tmp = 0;
  3665. for (var j = 0; j < links.length; j++) {
  3666. if (link[i].id == links[j].id) {
  3667. tmp++;
  3668. break;
  3669. }
  3670. }
  3671. if (tmp == 0) {
  3672. tempLink.push(link[i]);
  3673. }
  3674. }
  3675. //数据写入页面
  3676. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  3677. nodes.push(tempNode[i]);
  3678. }
  3679. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  3680. links.push(tempLink[i]);
  3681. }
  3682. //links转换
  3683. for (var i = 0; i < links.length; i++) {
  3684. for (var j = 0; j < nodes.length; j++) {
  3685. if (links[i].source == nodes[j].id) {
  3686. links[i].source = nodes[j];
  3687. }
  3688. if (links[i].target == nodes[j].id) {
  3689. links[i].target = nodes[j];
  3690. }
  3691. }
  3692. }
  3693. restart();
  3694. })
  3695. }
  3696. }
  3697. var svg;
  3698. var force;
  3699. var drag_line, path, circle;
  3700. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  3701. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  3702. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  3703. var nodes = [],
  3704. links = [];
  3705. var treeNodes = [];
  3706. //读取labels (node)
  3707. var labels = [];
  3708. function redrawSvg(json) {
  3709. nodes.length = 0; //先清空
  3710. links.length = 0;
  3711. var data = json.data;
  3712. for (var i = 0; i < data.node.length; i++) {
  3713. nodes.push(data.node[i]);
  3714. }
  3715. restart();
  3716. }
  3717. //读取status (节点 连线)
  3718. var statuses = [];
  3719. ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  3720. if (result && result.status == 200) {
  3721. d3.select('#nodeStatus').selectAll('option')
  3722. .data(statuses).enter()
  3723. .append('option')
  3724. .attr('value', function(d) { return d.code; })
  3725. .html(function(d) { return d.desc; });
  3726. } else {
  3727. SweetAlert.swal({
  3728. title: "提示!",
  3729. text: "服务器请求异常!",
  3730. type: "error"
  3731. });
  3732. }
  3733. });
  3734. //查询relationship_type表 name 为表里的type,label为显示值
  3735. var linkType = [];
  3736. function fetchEdgeTypes() {
  3737. ConfigDataService.fetchDataList('ciedgetype', { 'idx': 0, 'sum': 100 }).then(function(response) {
  3738. if (response) {
  3739. if (response['list']) {
  3740. linkType = response['list'];
  3741. // d3.select('#linkName').selectAll('option')
  3742. // .data(linkType).enter()
  3743. // .append('option')
  3744. // .attr('value',function(d){return d.type;})
  3745. // .html(function(d){ return d.label;});
  3746. } else {
  3747. SweetAlert.swal({
  3748. title: "提示!",
  3749. text: "服务器请求异常!",
  3750. type: "error"
  3751. });
  3752. }
  3753. } else {
  3754. SweetAlert.swal({
  3755. title: "提示!",
  3756. text: "服务器请求异常!",
  3757. type: "error"
  3758. });
  3759. }
  3760. })
  3761. }
  3762. fetchEdgeTypes();
  3763. /*
  3764. // init D3 force layout
  3765. var force = d3.layout.force()
  3766. .nodes(nodes)
  3767. .links(links)
  3768. .size([width, height])
  3769. .gravity(.05)
  3770. .linkDistance(150)
  3771. .linkStrength(2)
  3772. .charge(-500)
  3773. .on('tick', tick);
  3774. // define arrow markers for graph links
  3775. svg.append('svg:defs').append('svg:marker')
  3776. .attr('id', 'end-arrow')
  3777. .attr('viewBox', '0 -5 10 10')
  3778. .attr('refX', 6)
  3779. .attr('markerWidth', 3)
  3780. .attr('markerHeight', 3)
  3781. .attr('orient', 'auto')
  3782. .append('svg:path')
  3783. .attr('d', 'M0,-5L10,0L0,5')
  3784. .attr('fill', '#000');
  3785. svg.append('svg:defs').append('svg:marker')
  3786. .attr('id', 'start-arrow')
  3787. .attr('viewBox', '0 -5 10 10')
  3788. .attr('refX', 4)
  3789. .attr('markerWidth', 3)
  3790. .attr('markerHeight', 3)
  3791. .attr('orient', 'auto')
  3792. .append('svg:path')
  3793. .attr('d', 'M10,-5L0,0L10,5')
  3794. .attr('fill', '#000');
  3795. // line displayed when dragging new nodes
  3796. var drag_line = svg.append('svg:path')
  3797. .attr('class', 'link dragline hidden')
  3798. .attr('d', 'M0,0L0,0');
  3799. // handles to link and node element groups
  3800. //(1)var path = svg.append('svg:g').selectAll('g')
  3801. var path = svg.append('svg:g').selectAll('g'),
  3802. circle = svg.append('svg:g').selectAll('g');
  3803. */
  3804. // mouse event vars
  3805. var selected_node = null,
  3806. selected_link = null,
  3807. mousedown_link = null,
  3808. mousedown_node = null,
  3809. mouseup_node = null;
  3810. function resetMouseVars() {
  3811. mousedown_node = null;
  3812. mouseup_node = null;
  3813. mousedown_link = null;
  3814. }
  3815. // update force layout (called automatically each iteration)
  3816. function tick() {
  3817. // draw directed edges with proper padding from node centers
  3818. path.selectAll('path').attr('d', function(d) {
  3819. var deltaX = d.target.x - d.source.x,
  3820. deltaY = d.target.y - d.source.y,
  3821. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  3822. normX = deltaX / dist,
  3823. normY = deltaY / dist,
  3824. sourcePadding = d.left ? 27 : 22,
  3825. targetPadding = d.right ? 27 : 22,
  3826. sourceX = d.source.x + (sourcePadding * normX),
  3827. sourceY = d.source.y + (sourcePadding * normY),
  3828. targetX = d.target.x - (targetPadding * normX),
  3829. targetY = d.target.y - (targetPadding * normY);
  3830. return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
  3831. });
  3832. circle.attr('transform', function(d) {
  3833. return 'translate(' + d.x + ',' + d.y + ')';
  3834. });
  3835. }
  3836. // update graph (called when needed)
  3837. function restart() {
  3838. //绑定link 数据
  3839. path.datum(links);
  3840. // path (link) group
  3841. path = path.data(links, function(d) { return d.id; });
  3842. var p = path.enter().append('svg:g');
  3843. //update existing links
  3844. path.selectAll('path').classed('selected', function(d) { return d === selected_link; })
  3845. .style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; })
  3846. .style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; });
  3847. // add new links
  3848. p.append('svg:path')
  3849. .attr('class', 'link')
  3850. .attr('id', function(d) { return "path_" + d.id; })
  3851. // .attr('startOffset', '0%')
  3852. .classed('selected', function(d) { return d === selected_link; })
  3853. .style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; })
  3854. .style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; })
  3855. .on('mousedown', function(d) {
  3856. if (d3.event.ctrlKey) return;
  3857. //去除没有提交的连线
  3858. for (var i = 0; i < links.length; i++) {
  3859. if (links[i].id == -1 && d.id != -1) {
  3860. links.splice(i, 1);
  3861. }
  3862. }
  3863. // select link
  3864. mousedown_link = d;
  3865. if (mousedown_link === selected_link) {
  3866. selected_link = $scope.selected_link = null;
  3867. selected_node = $scope.selected_node = null;
  3868. // d3.select("#linkDetail").attr('style','display:none');
  3869. //hideLinkForm(true);//return ;
  3870. } else {
  3871. selected_link = $scope.selected_link = mousedown_link;
  3872. selected_node = $scope.selected_node = null;
  3873. }
  3874. selected_node = $scope.selected_node = null;
  3875. restart();
  3876. });
  3877. p.append('svg:text')
  3878. .attr('x', 30)
  3879. .attr('y', 20)
  3880. .attr('class', 'fontM')
  3881. .append('textPath')
  3882. .attr('xlink:xlink:href', function(d, i) { return "#path_" + d.id; })
  3883. .html(function(d) {
  3884. for (var i = 0; i < linkType.length; i++) {
  3885. if (linkType[i].type == d.name) {
  3886. return linkType[i].label;
  3887. }
  3888. }
  3889. });
  3890. // remove old links
  3891. path.exit().remove();
  3892. // circle (node) group
  3893. // NB: the function arg is crucial here! nodes are known by id, not by index!
  3894. circle.datum(nodes);
  3895. circle = circle.data(nodes, function(d) { return d.id; });
  3896. // update existing nodes (reflexive & selected visual states)
  3897. circle.selectAll('circle')
  3898. .style('fill', function(d) { return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label); })
  3899. .style('fill-opacity', 0.75) // add by xi
  3900. .classed('reflexive', function(d) { return d.reflexive; });
  3901. // add new nodes
  3902. var g = circle.enter().append('svg:g');
  3903. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  3904. //g.append('svg:circle').attr('r',24).style('fill','rgb(255,255,255)').style('stroke', function(d) { return d3.rgb(colors(d.label)).darker().toString(); }).style('stroke-width','2');
  3905. g.append('svg:circle').attr('r', 24).style('fill', function(d) { return (d === selected_node) ? 'rgb(153,153,153)' : 'rgb(255,255,255)'; }).style('stroke', function(d) { return d3.rgb(colors(d.label)).darker().toString(); }).style('stroke-width', '2');
  3906. g.append('svg:circle')
  3907. .attr('class', 'node')
  3908. .attr('r', 18)
  3909. .style('fill', function(d) { return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label); })
  3910. .style('stroke', function(d) { return d3.rgb(colors(d.label)).darker().toString(); })
  3911. .style('fill-opacity', 0.25) //add by xj
  3912. .style('stroke-opacity', 0.5) //add by xj
  3913. .classed('reflexive', function(d) { return d.reflexive; });
  3914. g.on('mouseover', function(d) {
  3915. //if(!mousedown_node || d === mousedown_node) return;
  3916. // enlarge target node
  3917. //d3.select(this).attr('transform', 'scale(1.1)');
  3918. })
  3919. .on('mouseout', function(d) {
  3920. //if(!mousedown_node || d === mousedown_node) return;
  3921. // unenlarge target node
  3922. //d3.select(this).attr('transform', '');
  3923. })
  3924. .on('mousedown', function(d) {
  3925. if (d3.event.ctrlKey) return;
  3926. //hideLinkForm(true);
  3927. //去除没有提交的连线
  3928. for (var i = 0; i < links.length; i++) {
  3929. if (links[i].id == -1) {
  3930. links.splice(i, 1);
  3931. }
  3932. }
  3933. // select node
  3934. mousedown_node = d;
  3935. if (mousedown_node === selected_node) {
  3936. selected_node = $scope.selected_node = null;
  3937. } else {
  3938. selected_node = $scope.selected_node = mousedown_node;
  3939. selected_link = $scope.selected_link = null;
  3940. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  3941. APIService.findRefById(selected_node.id).then(function(result) {
  3942. var d = result.data;
  3943. var node = d.node;
  3944. var link = d.edge;
  3945. var tempNode = [];
  3946. var tempLink = [];
  3947. //nodes 或者links 要去重
  3948. for (var i = 0; i < node.length; i++) {
  3949. var tmp = 0;
  3950. for (var j = 0; j < nodes.length; j++) {
  3951. if (node[i].id == nodes[j].id) {
  3952. tmp++;
  3953. break;
  3954. }
  3955. }
  3956. if (tmp == 0) {
  3957. tempNode.push(node[i]);
  3958. }
  3959. }
  3960. for (var i = 0; i < link.length; i++) {
  3961. var tmp = 0;
  3962. for (var j = 0; j < links.length; j++) {
  3963. if (link[i].id == links[j].id) {
  3964. tmp++;
  3965. break;
  3966. }
  3967. }
  3968. if (tmp == 0) {
  3969. tempLink.push(link[i]);
  3970. }
  3971. }
  3972. //数据写入页面
  3973. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  3974. nodes.push(tempNode[i]);
  3975. }
  3976. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  3977. links.push(tempLink[i]);
  3978. }
  3979. //links转换
  3980. for (var i = 0; i < links.length; i++) {
  3981. for (var j = 0; j < nodes.length; j++) {
  3982. if (links[i].source == nodes[j].id) {
  3983. links[i].source = nodes[j];
  3984. }
  3985. if (links[i].target == nodes[j].id) {
  3986. links[i].target = nodes[j];
  3987. }
  3988. }
  3989. }
  3990. restart();
  3991. });
  3992. }
  3993. // reposition drag line
  3994. drag_line
  3995. .style('marker-end', 'url(#end-arrow)')
  3996. .classed('hidden', false)
  3997. .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
  3998. restart();
  3999. })
  4000. .on('mouseup', function(d) {
  4001. if (!mousedown_node) return;
  4002. });
  4003. // show node name
  4004. g.append('svg:text')
  4005. .attr('x', 0)
  4006. .attr('y', 34)
  4007. .attr('class', 'id')
  4008. .text(function(d) { return d.name; }); //TODO 改为 d.name
  4009. //设置图片
  4010. g.append('svg:foreignObject')
  4011. .attr("width", 32)
  4012. .attr("height", 32)
  4013. .attr('x', "-16px")
  4014. .attr('y', "-11px")
  4015. .html(function(d) {
  4016. for (var i = 0; i < labels.length; i++) {
  4017. if (d.label == labels[i].sign) {
  4018. return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
  4019. }
  4020. }
  4021. });
  4022. // remove old nodes
  4023. circle.exit().remove();
  4024. // set the graph in motion
  4025. force.start();
  4026. }
  4027. function mousedown() {
  4028. // prevent I-bar on drag
  4029. //d3.event.preventDefault();
  4030. // because :active only works in WebKit?
  4031. svg.classed('active', true);
  4032. if (mousedown_node) {
  4033. viewNode(mousedown_node);
  4034. }
  4035. if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
  4036. restart();
  4037. }
  4038. function mousemove() {
  4039. if (!mousedown_node) return;
  4040. // update drag line
  4041. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  4042. //restart();
  4043. }
  4044. function mouseup() {
  4045. if (mousedown_node) {
  4046. // hide drag line
  4047. drag_line
  4048. .classed('hidden', true)
  4049. .style('marker-end', '');
  4050. }
  4051. // because :active only works in WebKit?
  4052. svg.classed('active', false);
  4053. // clear mouse event vars
  4054. resetMouseVars();
  4055. }
  4056. function spliceLinksForNode(node) {
  4057. var toSplice = links.filter(function(l) {
  4058. return (l.source === node || l.target === node);
  4059. });
  4060. toSplice.map(function(l) {
  4061. links.splice(links.indexOf(l), 1);
  4062. });
  4063. }
  4064. // only respond once per keydown
  4065. var lastKeyDown = -1;
  4066. function keydown() {
  4067. //d3.event.preventDefault();
  4068. if (lastKeyDown !== -1) return;
  4069. lastKeyDown = d3.event.keyCode;
  4070. // ctrl
  4071. if (d3.event.keyCode === 17) {
  4072. circle.call(force.drag);
  4073. svg.classed('ctrl', true);
  4074. }
  4075. if (!selected_node && !selected_link) return;
  4076. switch (d3.event.keyCode) {
  4077. case 8: // backspace
  4078. case 66: // B
  4079. if (selected_link) {
  4080. // set link direction to both left and right
  4081. selected_link.left = true;
  4082. selected_link.right = true;
  4083. }
  4084. restart();
  4085. break;
  4086. case 76: // L
  4087. if (selected_link) {
  4088. // set link direction to left only
  4089. selected_link.left = true;
  4090. selected_link.right = false;
  4091. }
  4092. restart();
  4093. break;
  4094. case 82: // R
  4095. if (selected_node) {
  4096. // toggle node reflexivity
  4097. selected_node.reflexive = !selected_node.reflexive;
  4098. } else if (selected_link) {
  4099. // set link direction to right only
  4100. selected_link.left = false;
  4101. selected_link.right = true;
  4102. }
  4103. restart();
  4104. break;
  4105. }
  4106. }
  4107. function keyup() {
  4108. lastKeyDown = -1;
  4109. // ctrl
  4110. if (d3.event.keyCode === 17) {
  4111. circle
  4112. .on('mousedown.drag', null)
  4113. .on('touchstart.drag', null);
  4114. svg.classed('ctrl', false);
  4115. }
  4116. }
  4117. function viewNode(node) {
  4118. console.log(svg.attr('left'));
  4119. //var el = angular.element('div.modal-dialog')[0];
  4120. var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
  4121. if (!$scope.selected_node.props.state) { $scope.selected_node.props.state = "空" } else if ($scope.selected_node.props.state) {
  4122. if ($scope.selected_node.props.state == "1") { $scope.selected_node.props.state = "未审核" } else if ($scope.selected_node.props.state == "2") { $scope.selected_node.props.state = "已审核" } else if ($scope.selected_node.props.state == "3") { $scope.selected_node.props.state = "不匹配" } else if ($scope.selected_node.props.state == "4") { $scope.selected_node.props.state = "丢失" }
  4123. };
  4124. if (!$scope.selected_node.name) { $scope.selected_node.name = "空" }
  4125. if (!$scope.selected_node.status) { $scope.selected_node.statu = "空" }
  4126. if (!$scope.selected_node.props.useradmin) { $scope.selected_node.props.useradmin = "空" }
  4127. Toaster.pop({
  4128. // type: 'info',
  4129. // title: title,
  4130. body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
  4131. '<p>配置标题:' + $scope.selected_node.name + '</p>' +
  4132. '<p>状态:' + $scope.selected_node.status + '</p>' +
  4133. '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
  4134. '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
  4135. bodyOutputType: 'trustedHtml',
  4136. timeout: 3000
  4137. })
  4138. }
  4139. //GT 颜色与数值对照表
  4140. function colors(sign) {
  4141. //num=num>20?num%20:parseInt(num);
  4142. for (var i = 0; i < labels.length; i++) {
  4143. var entity = labels[i];
  4144. if (sign == entity.sign) {
  4145. return entity.color;
  4146. }
  4147. if (i == labels.length - 1 && sign != entity.sign) {
  4148. return '#ffeeee';
  4149. }
  4150. }
  4151. }
  4152. $scope.init = function() {
  4153. svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  4154. // init D3 force layout
  4155. force = d3.layout.force()
  4156. .nodes(nodes)
  4157. .links(links)
  4158. .size([width, height])
  4159. .gravity(.05)
  4160. .linkDistance(150)
  4161. .linkStrength(2)
  4162. .charge(-500)
  4163. .on('tick', tick);
  4164. // define arrow markers for graph links
  4165. svg.append('svg:defs').append('svg:marker')
  4166. .attr('id', 'end-arrow')
  4167. .attr('viewBox', '0 -5 10 10')
  4168. .attr('refX', 6)
  4169. .attr('markerWidth', 3)
  4170. .attr('markerHeight', 3)
  4171. .attr('orient', 'auto')
  4172. .append('svg:path')
  4173. .attr('d', 'M0,-5L10,0L0,5')
  4174. .attr('fill', '#000');
  4175. svg.append('svg:defs').append('svg:marker')
  4176. .attr('id', 'start-arrow')
  4177. .attr('viewBox', '0 -5 10 10')
  4178. .attr('refX', 4)
  4179. .attr('markerWidth', 3)
  4180. .attr('markerHeight', 3)
  4181. .attr('orient', 'auto')
  4182. .append('svg:path')
  4183. .attr('d', 'M10,-5L0,0L10,5')
  4184. .attr('fill', '#000');
  4185. // line displayed when dragging new nodes
  4186. drag_line = svg.append('svg:path')
  4187. .attr('class', 'link dragline hidden')
  4188. .attr('d', 'M0,0L0,0');
  4189. // handles to link and node element groups
  4190. //(1)var path = svg.append('svg:g').selectAll('g')
  4191. path = svg.append('svg:g').selectAll('g');
  4192. circle = svg.append('svg:g').selectAll('g');
  4193. svg.on('mousedown', mousedown)
  4194. .on('mousemove', mousemove)
  4195. .on('mouseup', mouseup);
  4196. d3.select(window)
  4197. .on('keydown', keydown)
  4198. .on('keyup', keyup);
  4199. }
  4200. var CI = {};
  4201. window.CI = CI;
  4202. $scope.ok = function() {
  4203. $modalInstance.close($scope.selected_node);
  4204. };
  4205. $scope.cancel = function() {
  4206. $modalInstance.dismiss('cancel');
  4207. };
  4208. },
  4209. size: size,
  4210. resolve: {
  4211. title: function() {
  4212. return options.templateOptions.title;
  4213. },
  4214. Restangular: function() {
  4215. return options.templateOptions.Restangular;
  4216. },
  4217. APIService: function() {
  4218. return options.templateOptions.ApiService;
  4219. },
  4220. ConfigDataService: function() {
  4221. return options.templateOptions.ConfigDataService;
  4222. },
  4223. ConfigFormService: function() {
  4224. return options.templateOptions.ConfigFormService;
  4225. },
  4226. SweetAlert: function() {
  4227. return options.templateOptions.Alert;
  4228. },
  4229. Toaster: function() {
  4230. return options.templateOptions.toaster;
  4231. }
  4232. }
  4233. });
  4234. modalInstance.result.then(function(selectedItem) {
  4235. options.value(selectedItem.name + '-' + selectedItem.uuid);
  4236. }, function() {
  4237. //console.log('Modal dismissed at: ' + new Date());
  4238. });
  4239. }
  4240. }
  4241. }
  4242. },
  4243. controller: ['$scope', function($scope) {
  4244. // setTimeout(function(){
  4245. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  4246. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  4247. // if(modelData.status==200){
  4248. // $scope.model[$scope.options.key] = modelData.data;
  4249. // $scope.options.initialValue = $scope.model[$scope.options.key];
  4250. // }
  4251. // });
  4252. // },1000);
  4253. }]
  4254. });
  4255. });
  4256. appFormly.run(function(formlyConfig, $parse) {
  4257. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  4258. var removeOnHideTransformer = function(fields, model) {
  4259. return fields.map(function(field) {
  4260. if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
  4261. addFieldRemoveOnHideWatcher(field);
  4262. }
  4263. if (field.type == "ui-title") {
  4264. addFieldRemoveOnHideWatcher(field);
  4265. }
  4266. return field;
  4267. });
  4268. };
  4269. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  4270. function addFieldRemoveOnHideWatcher(field) {
  4271. var watcher = getWatcher();
  4272. if (field.watcher) {
  4273. if (!angular.isArray(field.watcher)) {
  4274. field.watcher = [field.watcher];
  4275. }
  4276. field.watcher.push(watcher);
  4277. } else {
  4278. field.watcher = watcher;
  4279. }
  4280. }
  4281. function getWatcher() {
  4282. return {
  4283. expression: function(field) {
  4284. return field.hide;
  4285. },
  4286. listener: function(field, newHide, oldHide, scope) {
  4287. if (field.hide) {
  4288. if (field.templateOptions.pkey) {
  4289. if (field.key == 'transferuser') {
  4290. $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
  4291. }
  4292. } else {
  4293. $parse(field.key).assign(scope.model, undefined);
  4294. }
  4295. }
  4296. if (field.type == "ui-title") {
  4297. $parse(field.key).assign(scope.model, undefined);
  4298. }
  4299. }
  4300. };
  4301. }
  4302. });
  4303. appFormly.controller('CustomformCtrl', ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'SweetAlert', 'FileUploader', 'i18nService', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_bpm_domain', 'api_bpm_data', 'api_user_data',
  4304. function($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, SweetAlert, FileUploader, i18nService, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_bpm_domain, api_bpm_data, api_user_data) {
  4305. //console.log($parse('Restangular')($scope));
  4306. //console.log($injector.get('Restangular'));
  4307. //console.log($stateParams);
  4308. var vm = this;
  4309. vm.options = {};
  4310. vm.exampleTitle = ['expressionProperties', 'model property'];
  4311. vm.fields = [];
  4312. vm.model = {};
  4313. $scope.langs = i18nService.getAllLangs();
  4314. $scope.lang = 'zh-cn';
  4315. i18nService.setCurrentLang($scope.lang);
  4316. //alert($rootScope.user.id,null,2);
  4317. vm.model["loginUser"] = $rootScope.user;
  4318. var that = $injector;
  4319. var parse = $parse;
  4320. var formKey = "";
  4321. var pdKey = "";
  4322. var modelWatch = "";
  4323. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  4324. modelWatch = JSON.parse($stateParams.model);
  4325. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  4326. }
  4327. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  4328. pdKey = $state.current.pdKey;
  4329. }
  4330. console.log("pdKey::" + JSON.stringify($state.current.title));
  4331. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  4332. formKey = $stateParams.formKey;
  4333. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  4334. }
  4335. if (angular.isDefined($stateParams.model)) {
  4336. var formModel = $stateParams.model;
  4337. }
  4338. //用户测试数据,后续从header的auth中获取
  4339. var userId = 2;
  4340. userId = $rootScope.user.id;
  4341. //==============处理表单设计数据 开始====================
  4342. //处理组件加载后台数据选项的方法
  4343. function refreshSelectOptions(searchVal, field) {
  4344. if (field.templateOptions.optionsUrl) {
  4345. var process = BpmRestangular.all("");
  4346. if (field.templateOptions.ApiService) {
  4347. process = UserRestangular.all("");
  4348. }
  4349. process.customPOST({ "idx": 0, "sum": 1000 }, field.templateOptions.optionsUrl).then(function(result) {
  4350. if (!field.templateOptions.options) {
  4351. field.templateOptions.options = [];
  4352. }
  4353. if (field.templateOptions.optionsDataKey) {
  4354. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  4355. } else {
  4356. field.templateOptions.options = result;
  4357. }
  4358. });
  4359. }
  4360. }
  4361. //解析自定义表单设计数据
  4362. function decodeVMForm(vmForm) {
  4363. var result = { model: {}, fields: [] };
  4364. //设置模型实体数据 begin
  4365. // var mdata = vmForm.model;
  4366. //解析数据实体
  4367. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  4368. angular.extend(result.model, mdata);
  4369. if (modelWatch != null && modelWatch != '') {
  4370. //angular.extend(result.model.incident,modelWatch.incident);
  4371. //result.model.alarmType = modelWatch.alarmType;
  4372. // vmForm.cancelUrl = modelWatch.cancelUrl;
  4373. console.log(modelWatch.cancelUrl)
  4374. for (var index in modelWatch.model) {
  4375. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  4376. if (result.model[index] != null) {
  4377. angular.extend(result.model[index], modelWatch.model[index]);
  4378. } else {
  4379. result.model[index] = modelWatch.model[index];
  4380. }
  4381. }
  4382. }
  4383. //设置模型实体数据 end
  4384. //解析设计数据生成表单项 begin
  4385. var fields = [];
  4386. //处理修改设计数据中展示设置
  4387. angular.forEach(vmForm.fields, function(field) {
  4388. if (field.key == "") {
  4389. delete field.key;
  4390. }
  4391. if (angular.isDefined(field.extjson)) {
  4392. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  4393. angular.extend(field.templateOptions, extObj.templateOptions);
  4394. delete extObj.templateOptions;
  4395. for (var prop in extObj) {
  4396. if (new RegExp("Expression").test(prop)) {
  4397. //var obj = $scope.$eval(extObj[prop]);
  4398. //extObj[prop] = $scope.$eval(extObj[prop]);
  4399. if (extObj[prop] != null) {
  4400. if (new RegExp("function").test(extObj[prop])) {
  4401. var propValue = eval(extObj[prop]);
  4402. extObj[prop] = propValue;
  4403. } else {
  4404. //console.log(extObj[prop]);
  4405. var obj = $scope.$eval(extObj[prop]);
  4406. extObj[prop] = obj;
  4407. //console.log(obj);
  4408. }
  4409. }
  4410. } else if (new RegExp("expressionProperties").test(prop)) {
  4411. for (var p in extObj[prop]) {
  4412. if (new RegExp("function").test(extObj[prop][p])) {
  4413. var propValue = eval(extObj[prop][p]);
  4414. extObj[prop][p] = propValue;
  4415. } else {
  4416. //if(p.indexOf("'")>=0){
  4417. // var obj = $scope.$eval(extObj[prop][p]);
  4418. // extObj[prop][$scope.$eval(p)]=obj;
  4419. //}
  4420. }
  4421. }
  4422. } else if ("watcher" == prop) {
  4423. if (angular.isArray(extObj[prop])) {
  4424. angular.forEach(extObj[prop], function(item, index) {
  4425. for (var p in item) {
  4426. if (new RegExp("function").test(item[p])) {
  4427. var propValue = eval(item[p]);
  4428. extObj[prop][index][p] = propValue;
  4429. }
  4430. }
  4431. });
  4432. } else if (angular.isObject(extObj[prop])) {
  4433. for (var p in extObj[prop]) {
  4434. if (new RegExp("function").test(extObj[prop][p])) {
  4435. var propValue = eval(extObj[prop][p]);
  4436. extObj[prop][p] = propValue;
  4437. }
  4438. }
  4439. }
  4440. }
  4441. }
  4442. angular.extend(field, extObj);
  4443. delete field.extjson;
  4444. }
  4445. if (angular.isDefined(field.templateOptions)) {
  4446. var templateOs = field.templateOptions;
  4447. for (var property in templateOs) {
  4448. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  4449. if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  4450. if (new RegExp("function").test(templateOs[property])) {
  4451. var propValue = eval(templateOs[property]);
  4452. field.templateOptions[property] = propValue;
  4453. } else {
  4454. if (that.has(templateOs[property])) {
  4455. field.templateOptions[property] = that.get(templateOs[property]);
  4456. } else {
  4457. field.templateOptions[property] = templateOs[property];
  4458. }
  4459. }
  4460. } else if (templateOs[property] == null) {
  4461. //delete field.templateOptions[property];
  4462. } else {}
  4463. }
  4464. }
  4465. //console.log(field);
  4466. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  4467. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  4468. angular.extend(field.templateOptions, extObj);
  4469. delete field.templateOptions.extjson;
  4470. }
  4471. //...
  4472. if (field.templateOptions) {
  4473. //处理远程获取数据控件方法调用
  4474. if (field.templateOptions.optionsUrl) {
  4475. field.templateOptions.refresh = refreshSelectOptions;
  4476. }
  4477. //事件脚本处理
  4478. // if(field.templateOptions.ngChangeScript){
  4479. // if(!field.expressionProperties)field.expressionProperties={};
  4480. // field.expressionProperties.ngChange = function(modelVal,viewVal,ev){
  4481. //// console.log(ev);
  4482. //// console.log("change>>"+ev.options.key);
  4483. // eval(field.templateOptions.ngChangeScript);
  4484. // }
  4485. // }
  4486. // if(field.templateOptions.ngClickScript){
  4487. // if(!field.expressionProperties)field.expressionProperties={};
  4488. // field.expressionProperties.ngClick = function(modelVal,viewVal,ev){
  4489. //// console.log(ev);
  4490. //// console.log("click>>"+ev.options.key);
  4491. // eval(field.templateOptions.ngClickScript);
  4492. // }
  4493. // }
  4494. //处理嵌套属性数据绑定/
  4495. if (field.templateOptions.pkey) {
  4496. var pmodel, i = 0;
  4497. angular.forEach(field.templateOptions.pkey.split("."), function(p) {
  4498. if (i == 0) {
  4499. if (result.model[p] == null) {
  4500. result.model[p] = {};
  4501. }
  4502. pmodel = result.model[p];
  4503. i++;
  4504. } else {
  4505. if (pmodel[p] == null) {
  4506. pmodel[p] = {};
  4507. }
  4508. pmodel = pmodel[p];
  4509. }
  4510. });
  4511. if (pmodel != null) {
  4512. field.model = pmodel;
  4513. if (pmodel[field.key] == null) {
  4514. pmodel[field.key] = null;
  4515. }
  4516. }
  4517. } else {
  4518. if (result.model[field.key] == null) {
  4519. result.model[field.key] = null;
  4520. }
  4521. }
  4522. //处理弹出框组件初始化
  4523. if (field.type == "ui-input-selectmodal") {
  4524. field.templateOptions.modal = $modal;
  4525. //field.templateOptions.Restangular = Restangular;
  4526. } else if (field.type == "ui-requesterselect") {
  4527. //field.templateOptions.language = $scope.lang;
  4528. field.templateOptions.modal = $modal;
  4529. field.templateOptions.UserService = api_user_data;
  4530. } else if (field.type == "ui-userselect") {
  4531. field.templateOptions.modal = $modal;
  4532. //field.templateOptions.Restangular = Restangular;
  4533. } else if (field.type == "ui-multiuserselect") {
  4534. field.templateOptions.modal = $modal;
  4535. } else if (field.type == "ui-search") {
  4536. field.templateOptions.modal = $modal;
  4537. } else if (field.type == "ui-modelselect") {
  4538. field.templateOptions.modal = $modal;
  4539. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  4540. field.templateOptions.loginUser = $rootScope.user;
  4541. //field.templateOptions.Restangular = Restangular;
  4542. } else if (field.type == "ui-dropfile") {
  4543. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  4544. url: '/uploader'
  4545. });
  4546. field.templateOptions.taskId = $stateParams.taskId;
  4547. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  4548. field.templateOptions.userId = $rootScope.user.id;
  4549. } else if (field.type == "ui-dropfielknow") {
  4550. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  4551. url: '/uploader'
  4552. });
  4553. field.templateOptions.taskId = $stateParams.taskId;
  4554. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  4555. field.templateOptions.userId = $rootScope.user.id;
  4556. } else if (field.type == "ui-dropfilenotup") {
  4557. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  4558. url: '/uploader'
  4559. });
  4560. field.templateOptions.taskId = $stateParams.taskId;
  4561. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  4562. field.templateOptions.userId = $rootScope.user.id;
  4563. //field.ApiService=api_bpm_domain;
  4564. } else if (field.type == "ui-dropfiletable") {
  4565. if (field.templateOptions.processInstanceId) {
  4566. } else {
  4567. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  4568. }
  4569. } else if (field.type == "ui-repeatSection") {
  4570. var repeatForm = {
  4571. model: {
  4572. },
  4573. fields: field.templateOptions.fields
  4574. };
  4575. repeatForm.model[field.key] = [];
  4576. decodeVMForm(repeatForm);
  4577. } else if (field.type == "ui-currentuser") {
  4578. field.templateOptions.user = vm.model["loginUser"];
  4579. }
  4580. }
  4581. // console.log(field);
  4582. result.fields.push(field);
  4583. });
  4584. angular.extend($scope.vm.fields, result.fields);
  4585. angular.extend($scope.vm.model, result.model);
  4586. // console.log("$scope.vm.model="+JSON.stringify($scope.vm.model));
  4587. vm.model["loginUser"] = $rootScope.user;
  4588. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  4589. vmForm.cancelUrl = modelWatch.cancelUrl;
  4590. }
  4591. $scope.formData = vmForm;
  4592. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  4593. if ($scope.formData.url == "start") {
  4594. $scope.Reset = true;
  4595. $scope.close = false;
  4596. } else if ($scope.formData.url == "complete") {
  4597. $scope.Reset = false;
  4598. $scope.close = true;
  4599. }
  4600. //解析设计数据生成表单项 end
  4601. return result;
  4602. }
  4603. //======================处理表单设计数据 结束========================
  4604. $scope.ldloading = {};
  4605. function filter(obj) {
  4606. angular.forEach(obj, function(key, value) {
  4607. if (value === "" || value === null) {
  4608. delete obj[key];
  4609. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  4610. filter(value);
  4611. } else if (angular.isArray(value)) {
  4612. angular.forEach(value, function(item) {
  4613. filter(item);
  4614. });
  4615. }
  4616. });
  4617. }
  4618. $scope.closeModel = function() {
  4619. // console.log("pdKey="+pdKey);
  4620. if (pdKey == "bpm_incident") {
  4621. $state.go('app.incident.list', {});
  4622. } else if (pdKey == "bpm_change") {
  4623. $state.go('app.change.list', {});
  4624. } else if (pdKey == "bpm_problem") {
  4625. $state.go('app.problem.list', {});
  4626. } else if (pdKey == "bpm_release") {
  4627. $state.go('app.release.list', {});
  4628. } else if (pdKey == "bpm_schedule") {
  4629. $state.go('app.scheduling.list', {});
  4630. } else if (pdKey == "bpm_configure") {
  4631. $state.go('app.cmdb.plist', {});
  4632. } else if (pdKey == "bpm_reService") {
  4633. $state.go('app.reService.manager', {});
  4634. }
  4635. event.preventDefault();
  4636. };
  4637. $scope.save = function(data) {
  4638. api_bpm_domain.save($stateParams.taskId, data).then(function(response) {
  4639. if (response) {
  4640. var resData = Restangular.stripRestangular(response);
  4641. SweetAlert.swal({
  4642. title: "暂存成功!",
  4643. confirmButtonColor: "#007AFF"
  4644. }, function() {
  4645. $state.go($scope.formData.cancelUri);
  4646. });
  4647. } else {
  4648. SweetAlert.swal({
  4649. title: "系统错误",
  4650. text: "系统错误,请稍后重试!",
  4651. type: "error",
  4652. confirmButtonColor: "#DD6B55"
  4653. });
  4654. }
  4655. });
  4656. event.preventDefault();
  4657. }
  4658. vm.submit = function(data, style) {
  4659. if (vm.form.$valid) {
  4660. $scope.ldloading[style.replace('-', '_')] = true;
  4661. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  4662. // console.log("vm.options:"+ JSON.stringify(vm.options));
  4663. vm.options.updateInitialValue();
  4664. // console.log("dfjkasdhfkhskjf ")
  4665. var _ = window._;
  4666. vm.model = (function filter(obj) {
  4667. var dateTransKeys = [];
  4668. var filtered = _.pick(obj, function(v, k, obj) {
  4669. if (_.isDate(v)) {
  4670. dateTransKeys.push(k);
  4671. }
  4672. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  4673. });
  4674. return _.cloneDeep(filtered, function(v, index, object) {
  4675. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  4676. angular.forEach(dateTransKeys, function(item) {
  4677. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  4678. })
  4679. dateTransKey = [];
  4680. return v;
  4681. }
  4682. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  4683. });
  4684. })(vm.model);
  4685. if (pdKey != "") {
  4686. if ($scope.oprcode == "save") { //保存
  4687. api_bpm_domain.save(taskId, vm.model).then(function(response) {
  4688. if (response) {
  4689. var resData = Restangular.stripRestangular(response);
  4690. SweetAlert.swal({
  4691. title: "保存成功!",
  4692. confirmButtonColor: "#007AFF"
  4693. }, function() {
  4694. $state.go($scope.formData.cancelUri);
  4695. });
  4696. // if(resData.status){
  4697. // resData
  4698. // }
  4699. } else {
  4700. SweetAlert.swal({
  4701. title: "系统错误",
  4702. text: "系统错误,请稍后重试!",
  4703. type: "error",
  4704. confirmButtonColor: "#DD6B55"
  4705. });
  4706. }
  4707. $scope.ldloading[style.replace('-', '_')] = false;
  4708. });
  4709. } else {
  4710. switch ($scope.formData.url) {
  4711. case "start":
  4712. vm.model["initUser"] = $rootScope.user.id;
  4713. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  4714. } else {
  4715. vm.model["assignee"] = $rootScope.user.id;
  4716. }
  4717. api_bpm_domain.start(pdKey, vm.model).then(function(response) {
  4718. // console.log("response="+JSON.stringify(response));
  4719. if (response) {
  4720. var resData = Restangular.stripRestangular(response);
  4721. if (resData) {
  4722. // console.log("$scope.fileUploader="+$scope.fileUploader)
  4723. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  4724. //$scope.uploader.options.url();
  4725. $scope.fileUploader.onBeforeUploadItem = function(item) {
  4726. item.url = api_bpm_domain.saveAttachments(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  4727. item.formData.push({ 'fileName': item.file.name });
  4728. //console.log();
  4729. };
  4730. $scope.fileUploader.uploadAll();
  4731. }
  4732. }
  4733. SweetAlert.swal({
  4734. title: "提交成功!",
  4735. confirmButtonColor: "#007AFF"
  4736. }, function() {
  4737. $state.go($scope.formData.cancelUrl);
  4738. });
  4739. } else {
  4740. SweetAlert.swal({
  4741. title: "系统错误",
  4742. text: "系统错误,请稍后重试!",
  4743. type: "error",
  4744. confirmButtonColor: "#DD6B55"
  4745. });
  4746. }
  4747. $scope.ldloading[style.replace('-', '_')] = false;
  4748. });
  4749. break;
  4750. case "complete":
  4751. // api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  4752. //console.log("complete taskId::"+$stateParams.taskId);
  4753. api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function(response) {
  4754. if (response) {
  4755. var resData = Restangular.stripRestangular(response);
  4756. SweetAlert.swal({
  4757. title: "提交成功!",
  4758. confirmButtonColor: "#007AFF"
  4759. }, function() {
  4760. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  4761. // // $scope.uploader.options.url();
  4762. // $scope.uploader.onBeforeUploadItem = function(item) {
  4763. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  4764. // console.info('onBeforeUploadItem', item);
  4765. // };
  4766. // $scope.uploader.uploadAll();
  4767. // }
  4768. $state.go($scope.formData.cancelUrl);
  4769. });
  4770. } else {
  4771. SweetAlert.swal({
  4772. title: "系统错误",
  4773. text: "系统错误,请稍后重试!",
  4774. type: "error",
  4775. confirmButtonColor: "#DD6B55"
  4776. });
  4777. }
  4778. $scope.ldloading[style.replace('-', '_')] = false;
  4779. });
  4780. break;
  4781. case "back":
  4782. $state.go($scope.formData.cancelUrl);
  4783. break;
  4784. default:
  4785. $scope.ldloading[style.replace('-', '_')] = false;
  4786. break;
  4787. }
  4788. }
  4789. // var submitFunc = api_bpm_domain[$scope.formData.url]
  4790. // if(anuglar.isFunction(submitFunc)){
  4791. // submitFunc.apply(null, pdKey)
  4792. // }
  4793. }
  4794. } else {
  4795. console.log(data)
  4796. // angular.forEach(vm.form.$error.required, function(item){
  4797. // var i=(item.$name).substring(item.$name.length-2)
  4798. var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
  4799. // for(var i=0;i<vm.fields.length;i++){
  4800. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  4801. SweetAlert.swal({
  4802. title: vm.fields[i].templateOptions.label + '未填',
  4803. text: "请填写此项!",
  4804. type: "error",
  4805. confirmButtonColor: "#DD6B55"
  4806. });
  4807. }
  4808. // }
  4809. // angular.forEach(vm.fields,function(f){
  4810. // if(f.name == item.$name){
  4811. // f.validation.show = true;
  4812. // SweetAlert.swal({
  4813. // title: f.templateOptions.label+'未填',
  4814. // text: "请填写此项!",
  4815. // type: "error",
  4816. // confirmButtonColor: "#DD6B55"
  4817. // });
  4818. // }
  4819. // });
  4820. // })
  4821. }
  4822. };
  4823. $scope.vm = vm;
  4824. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  4825. // console.log("taskId>>"+$stateParams.taskId);
  4826. // editor process task form
  4827. var processInstanceId = $stateParams.processInstanceId;
  4828. api_bpm_domain.taskformkey($stateParams.taskId).then(function(response) {
  4829. if (response) {
  4830. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  4831. api_configure_form.renderForm(myData.data, userId, processInstanceId).then(function(responseData) {
  4832. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  4833. var vmForm = Restangular.stripRestangular(responseData);
  4834. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  4835. decodeVMForm(vmForm);
  4836. //console.log($scope);
  4837. }
  4838. }
  4839. });
  4840. }
  4841. })
  4842. } else {
  4843. // create process instance
  4844. if (pdKey != "") { //for process
  4845. api_bpm_domain.startformkey(pdKey).then(function(response) {
  4846. if (response) {
  4847. var myData = Restangular.stripRestangular(response);
  4848. //myData.data = "arrangeform";
  4849. api_configure_form.renderForm(myData.data, userId).then(function(responseData) {
  4850. if (responseData) {
  4851. var vmForm = Restangular.stripRestangular(responseData);
  4852. if (vmForm) {
  4853. decodeVMForm(vmForm);
  4854. //console.log($rootScope);
  4855. }
  4856. }
  4857. });
  4858. }
  4859. });
  4860. } else { //for form
  4861. //TODO
  4862. //测试数据 开始
  4863. var testJson = {
  4864. fields: [{
  4865. key: 'formtitle',
  4866. type: 'ui-title',
  4867. noFormControl: true,
  4868. templateOptions: {
  4869. label: 'title is ',
  4870. placeholder: 'Formly is terrific!'
  4871. }
  4872. },
  4873. // {
  4874. // key:'a',type:'ui-input',className:'col-xs-4',
  4875. // templateOptions: {
  4876. // type: 'input',label: 'input a',placeholder:'search a...',
  4877. // lBtn:{
  4878. // label:'input',
  4879. // onClick: function(val,opt,el,ev,model){alert(val);}
  4880. // },
  4881. // rAddon:'@111.cc'
  4882. // }
  4883. // },
  4884. {
  4885. key: 'b',
  4886. type: 'ui-input',
  4887. className: 'col-xs-4',
  4888. templateOptions: {
  4889. type: 'input',
  4890. label: 'input a',
  4891. placeholder: 'search a...',
  4892. rBtn: {
  4893. icon: 'fa fa-phone',
  4894. onClick: function(val, opt, el, ev, model) { alert(val); }
  4895. },
  4896. lAddon: '<i class="fa fa-phone"/>'
  4897. }
  4898. },
  4899. // {
  4900. // key:'first',type:'ui-input',className:'col-xs-2',
  4901. // templateOptions: {
  4902. // type: 'input',
  4903. // label: 'first name',
  4904. // pkey:'name'
  4905. // }
  4906. // },
  4907. // {
  4908. // key:'first',type:'ui-number',className:'col-xs-3',
  4909. // templateOptions: {
  4910. // label: '时长',
  4911. // pkey:'name',
  4912. // min:0,
  4913. // rAddon:'分钟'
  4914. // }
  4915. // },
  4916. // {
  4917. // key:'last',type:'ui-input',className:'col-xs-2',
  4918. // templateOptions: {type: 'input',label: 'last name',pkey:'name'}},
  4919. // {
  4920. // key:'username',
  4921. // type:'ui-input',
  4922. // className:'col-xs-4',
  4923. // templateOptions: {
  4924. // type: 'input',
  4925. // label: 'User Name',
  4926. // placeholder: 'Enter name',
  4927. // required:true,
  4928. // maxLength:10
  4929. // }
  4930. // },
  4931. // {
  4932. // key: 'password',
  4933. // type: 'ui-input',
  4934. // className:'col-xs-4',
  4935. // templateOptions: {
  4936. // type: 'password',
  4937. // label: 'Password',
  4938. // placeholder: 'Password',
  4939. // required:true
  4940. // },
  4941. // expressionProperties: {
  4942. // 'templateOptions.disabled': '!model.username'
  4943. // }
  4944. // },
  4945. // {
  4946. // key: 'selectmodal',
  4947. // type: 'ui-input-selectmodal',
  4948. // className:'col-xs-6',
  4949. // templateOptions:{
  4950. // label: 'selectmodal',
  4951. // btnLabel:'search',
  4952. // btnClassName:'btn-o',
  4953. // modalParam:{
  4954. // items: function(){
  4955. // return ['a','b','c','d'];
  4956. // },
  4957. // title: function(){
  4958. // return '测试标题';
  4959. // }
  4960. // }
  4961. // }
  4962. // },
  4963. // {
  4964. // key: 'email',
  4965. // type: 'ui-input',
  4966. // className:'col-xs-6',
  4967. // templateOptions:{
  4968. // type: 'email',
  4969. // maxlength: 10,
  4970. // minlength: 6,
  4971. // label: 'EMail'
  4972. // }
  4973. // },
  4974. // {
  4975. // key: 'date',
  4976. // type: 'ui-datepicker',
  4977. // className:'col-xs-6',
  4978. // templateOptions: {
  4979. // label: 'Date',
  4980. // type: 'text',
  4981. // datepickerPopup: 'yyyy-MM-dd hh:mm:ss',
  4982. // initDate : function(){
  4983. // return new Date();
  4984. // }
  4985. // }
  4986. // },
  4987. {
  4988. key: 'multiselectItem',
  4989. type: 'ui-multi-select-tree',
  4990. className: 'col-xs-6',
  4991. templateOptions: {
  4992. label: 'multiSelect',
  4993. placeholder: '请选择...',
  4994. isMultiSelect: false,
  4995. selLeafs: false, //只选叶子节点
  4996. refreshData: function(APIService) {
  4997. return APIService.fetchDataList('changeclassify', { 'idx': 0, 'sum': 100 });
  4998. },
  4999. APIService: api_bpm_data,
  5000. optionsDataKey: 'list',
  5001. refreshDelay: 1000,
  5002. onDataCallback: function(item, selectItems, options, field, model) {
  5003. model[options.key] = { id: item.id };
  5004. // console.log("item="+JSON.stringify(model))
  5005. }
  5006. }
  5007. },
  5008. // {
  5009. // key:'selectItem',
  5010. // type:'ui-select',
  5011. // className:'col-xs-4',
  5012. // templateOptions:{
  5013. // label:'ui-select',
  5014. // valueProp: 'code',//对应value
  5015. // labelProp: 'source',//对应key
  5016. // optionsUrl:'data/fetchDataList/incidentsource',//对应后台地址,api/之前的部分省略
  5017. // optionsDataKey:'list',//对应返回数组数据的键值,
  5018. // required:true,
  5019. // onChange:function(val, options, field, event ,model){
  5020. // model.start_code = val;
  5021. // }
  5022. // }
  5023. // },
  5024. // {
  5025. // key:'id',
  5026. // type:'ui-multiselect',
  5027. // className:'col-xs-4',
  5028. // templateOptions:{
  5029. // label:'multi-select',
  5030. // pkey:"change.systemType",
  5031. // valueProp: 'id',//对应value
  5032. // labelProp: 'source',//对应key
  5033. // optionsUrl:'data/fetchDataList/changesystemtype',//对应后台地址,api/之前的部分省略
  5034. // optionsDataKey:'list',//对应返回数组数据的键值,
  5035. // required:true,
  5036. // onChange:function(val, options, field, event ,model){
  5037. // console.log(val);
  5038. // console.log(model);
  5039. // //model.start_code = val;
  5040. // }
  5041. // }
  5042. // },
  5043. {
  5044. key: 'checklistItem',
  5045. type: 'ui-checklist',
  5046. className: 'col-xs-4',
  5047. templateOptions: {
  5048. label: 'checklistItem',
  5049. options: [
  5050. { name: 'Iron Man', value: 'iron_man' },
  5051. { name: 'Captain America', value: 'captain_america' },
  5052. { name: 'Black Widow', value: 'black_widow' },
  5053. { name: 'Hulk', value: 'hulk' },
  5054. { name: 'Captain Marvel', value: 'captain_marvel' }
  5055. ]
  5056. }
  5057. },
  5058. {
  5059. key: 'radioItem',
  5060. type: 'ui-radio',
  5061. className: 'col-xs-8',
  5062. templateOptions: {
  5063. label: 'radioItem',
  5064. options: [
  5065. { name: 'Iron Man', value: 'iron_man' },
  5066. { name: 'Captain America', value: 'captain_america' },
  5067. { name: 'Black Widow', value: 'black_widow' },
  5068. { name: 'Hulk', value: 'hulk' },
  5069. { name: 'Captain Marvel', value: 'captain_marvel' }
  5070. ],
  5071. type: 'number'
  5072. }
  5073. },
  5074. // {
  5075. // key:'selectUser',
  5076. // type:'ui-userselect',
  5077. // className:'col-xs-12',
  5078. // templateOptions:{
  5079. // label:'请求人信息',
  5080. // modalTitle:'请求人列表',
  5081. // fetchItems:function(filterData, APIService){
  5082. // return APIService.fetchDataList('user',filterData);
  5083. // },
  5084. // Restangular:Restangular,
  5085. // ApiService:api_user_data,
  5086. // onClick:function(val, options, field, event , model){
  5087. // //model.start_code++;
  5088. // console.log(options);
  5089. // }
  5090. // }
  5091. // },
  5092. {
  5093. key: 'selectUser',
  5094. type: 'ui-requesterselect',
  5095. className: 'col-xs-12',
  5096. templateOptions: {
  5097. label: '请求人信息',
  5098. modalTitle: '请求人列表',
  5099. fetchItems: function(filterData, APIService) {
  5100. return APIService.fetchDataList('requester', filterData);
  5101. },
  5102. Restangular: Restangular,
  5103. ApiService: api_user_data
  5104. // onClick:function(val, options, field, event , model){
  5105. // console.log(options);
  5106. // }
  5107. }
  5108. },
  5109. {
  5110. key: 'cabUser',
  5111. type: 'ui-multiuserselect',
  5112. className: 'col-xs-12',
  5113. templateOptions: {
  5114. label: 'CAB评审成员',
  5115. modalTitle: 'CAB成员列表',
  5116. fetchItems: function(filterData, APIService) {
  5117. return APIService.fetchDataList('user', filterData);
  5118. },
  5119. Restangular: Restangular,
  5120. ApiService: api_user_data,
  5121. onClick: function(val, options, field, event, model) {
  5122. // console.log(model);
  5123. }
  5124. }
  5125. },
  5126. // {
  5127. // key:'incident',
  5128. // type:'ui-modelselect',
  5129. // className:'col-xs-3',
  5130. // templateOptions:{
  5131. // label:'关联事件工单',
  5132. // modalTitle:'事件列表',
  5133. // fetchItems:function(filterData,APIService){
  5134. // return APIService.fetchDataList('incident',filterData);
  5135. // },
  5136. // Restangular:"Restangular",
  5137. // ApiService:"api_bpm_data",
  5138. // columnDefs:[
  5139. // { name:'id', width:80, enableFiltering:false},
  5140. // { name:'title', displayName:'事件主题', width:140},
  5141. // { name:'type.name', displayName:'事件类型', width:140},
  5142. // { name:'emergency.name', displayName:'紧急度', width:80},
  5143. // { name:'state.name', displayName:'状态', width:100},
  5144. // { name:'emergency.name', displayName:'紧急度', width:80},
  5145. // { name:'influence.name', displayName:'影响度', width:80},
  5146. // { name:'priority.name', displayName:'优先级', width:80},
  5147. // { name:'handlerUser.name', displayName:'当前处理人', width:100},
  5148. // { name:'acceptDate', displayName:'创建时间', width:100}
  5149. // ],
  5150. // displayName:'title',
  5151. // onClick:function(val, options, field, event , model){
  5152. // //model.start_code++;
  5153. // console.log(options);
  5154. // }
  5155. // }
  5156. // },
  5157. // {
  5158. // key: 'worknumber',
  5159. // type: 'ui-workernumber',
  5160. // className:'col-xs-3',
  5161. // templateOptions: {
  5162. // label: 'work number',
  5163. // Restangular:Restangular,
  5164. // ApiService:api_bpm_domain,
  5165. // getWorkernumber: function(APIService){
  5166. // return APIService.workernumber('bg');
  5167. // }
  5168. // }
  5169. // },
  5170. // {
  5171. // key: 'chkme',
  5172. // type: 'ui-checkbox',
  5173. // className:'col-xs-3',
  5174. // templateOptions: {
  5175. // label: 'Check me out'
  5176. // }
  5177. // },
  5178. // {
  5179. // key: 'droplink',
  5180. // type: 'ui-link',
  5181. // className: 'col-xs-3',
  5182. // templateOptions:{
  5183. // label:'添加附件',
  5184. // onClick:function(val, options, field, event ,model){
  5185. // if(angular.isUndefined(field.form.dropState)){
  5186. // field.form.dropState=false;
  5187. // }
  5188. // field.form.dropState=!field.form.dropState;
  5189. // console.log(field);
  5190. // }
  5191. // }
  5192. // },
  5193. // {
  5194. // key: 'dropfile',
  5195. // type: 'ui-dropfile',
  5196. // className: 'col-xs-12',
  5197. // templateOptions:{
  5198. // label:'附件',
  5199. // uploadUrl:'http://127.0.0.1:9008/saveAttachments'
  5200. // }
  5201. // },
  5202. // {
  5203. // type: 'ui-label',
  5204. // key: 'changesign',
  5205. // className: 'col-xs-4',
  5206. // templateOptions: {
  5207. // label:'变更请求单号',
  5208. // pkey:'change'
  5209. // }
  5210. // },
  5211. // {
  5212. // type: 'ui-label',
  5213. // key: 'title',
  5214. // className: 'col-xs-4',
  5215. // templateOptions: {
  5216. // label:'变更标题',
  5217. // pkey:'change'
  5218. // }
  5219. // },
  5220. // //关联发布单号
  5221. // //新建发布
  5222. // {
  5223. // key: 'droplist',
  5224. // type: 'ui-dropfiletable',
  5225. // className: 'col-xs-12',
  5226. // templateOptions:{
  5227. // label:'附件下载列表',
  5228. // Restangular:Restangular,
  5229. // processInstanceId:'250033',
  5230. // ApiService:api_bpm_domain
  5231. // }
  5232. // },
  5233. // {
  5234. // type: 'ui-repeatSection',
  5235. // key: 'investments',
  5236. // className: 'col-xs-12',
  5237. // templateOptions: {
  5238. // btnText: '新增变更施工单',
  5239. // fields: [
  5240. // {
  5241. // className: 'col-xs-3',
  5242. // type: 'ui-input',
  5243. // key: 'aboutci',
  5244. // templateOptions: {
  5245. // label: '关联的配置项',
  5246. // required: true
  5247. // }
  5248. // },
  5249. // {
  5250. // className: 'col-xs-3',
  5251. // type: 'ui-datepicker',
  5252. // key: 'planbegintime',
  5253. // templateOptions: {
  5254. // label: '计划开始时间',
  5255. // required: true
  5256. // }
  5257. // },
  5258. // {
  5259. // className: 'col-xs-3',
  5260. // type: 'ui-datepicker',
  5261. // key: 'planendtime',
  5262. // templateOptions: {
  5263. // label: '计划完成时间',
  5264. // required: true
  5265. // }
  5266. // },
  5267. // {
  5268. // className: 'col-xs-12',
  5269. // type: 'ui-userselect',
  5270. // key: 'handleruser',
  5271. // templateOptions: {
  5272. // label: '实施人员信息',
  5273. // modalTitle:'实施人列表',
  5274. // required: true,
  5275. // fetchItems:function(filterData, APIService){
  5276. // return APIService.fetchDataList('user',filterData);
  5277. // },
  5278. // Restangular:Restangular,
  5279. // ApiService:api_user_data,
  5280. // onClick:function(val, options, field, event , model){
  5281. // //model.start_code++;
  5282. // console.log(options);
  5283. // }
  5284. // }
  5285. // },
  5286. // {
  5287. // className: 'col-xs-8',
  5288. // type: 'ui-textarea',
  5289. // key: 'handlerContent',
  5290. // templateOptions: {
  5291. // label: '实施内容',
  5292. // required: true,
  5293. // row:10
  5294. // }
  5295. // },{
  5296. // noFormControl: true,
  5297. // template:'<hr>'
  5298. // }]
  5299. // }
  5300. // },
  5301. // {
  5302. // key: 'droplist',
  5303. // type: 'ui-dropfiletable',
  5304. // className: 'col-xs-12',
  5305. // templateOptions:{
  5306. // label:'附件下载列表',
  5307. // Restangular:Restangular,
  5308. // processInstanceId:'250033',
  5309. // ApiService:api_bpm_domain
  5310. // }
  5311. // },
  5312. // {
  5313. // key: 'start_code',
  5314. // className:'col-xs-6',
  5315. // type: 'ui-hidden'
  5316. // },
  5317. // {
  5318. // key:'remark',
  5319. // type:'ui-textarea',
  5320. // className:'col-xs-12',
  5321. // templateOptions:{
  5322. // label:'remark is ',
  5323. // rows:3
  5324. // }
  5325. // },
  5326. {
  5327. key: 'setStartCode',
  5328. type: 'ui-button',
  5329. className: 'col-xs-4',
  5330. templateOptions: {
  5331. label: '升级为变更',
  5332. onClick: function(val, options, field, event, model) {
  5333. //console.log(options);
  5334. event.preventDefault();
  5335. //model.start_code++;
  5336. //console.log(options);
  5337. }
  5338. }
  5339. }
  5340. ],
  5341. model: {
  5342. username: "robin lau",
  5343. password: "123456",
  5344. chkme: false,
  5345. start_code: 0,
  5346. formtitle: "Hey!I am title value!",
  5347. name: {
  5348. first: "robin",
  5349. last: "lau"
  5350. },
  5351. multiselectItem: []
  5352. //date:"2015-09-15 00:00:00"
  5353. }
  5354. };
  5355. setTimeout(function() {
  5356. decodeVMForm(testJson);
  5357. $scope.$apply();
  5358. }, 500);
  5359. //测试数据结束
  5360. }
  5361. }
  5362. //console.log("end decode");
  5363. }
  5364. ]);