1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915 |
- window.$Request = {
- post: function (url, data, response, type) {
- NProgress.start();
- $Request.httpRequest({
- url: url,
- data: data ? data : {},
- type: type ? type : 'POST',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
- 'X-CSRF-TOKEN': ($('meta[name="csrf-token"]').attr('content') ? $('meta[name="csrf-token"]').attr('content') : $(window.parent.document).find('meta[name="csrf-token"]').attr('content'))
- },
- response: function (res, status, header) {
- // console.log(status);
- /*错误码 400*/
- if (status > 399 && status < 500) {
- NProgress.done();
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- // window.location = '/404?msg=页面未找到';
- return false;
- }
- /*错误码 500*/
- else if (status >= 500) {
- NProgress.done();
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- return false;
- } else {
- if (!res) {
- NProgress.done();
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- return false;
- }
- NProgress.done();
- response(res);
- }
- }
- })
- },
- postJson: function (url, data, response, type) {
- var platform = $('meta[name="framework-platform"]').attr('content');
- NProgress.start();
- $Request.httpJsonRequest({
- url: url,
- data: data ? data : {},
- type: type ? type : 'POST',
- headers: {
- 'Request-Source' :platform,
- 'Content-Type': 'application/json; charset=UTF-8',
- 'X-CSRF-TOKEN': ($('meta[name="csrf-token"]').attr('content') ? $('meta[name="csrf-token"]').attr('content') : $(window.parent.document).find('meta[name="csrf-token"]').attr('content'))
- },
- response: function (res, status, header) {
- // console.log(status);
- /*错误码 400*/
- if (status > 399 && status < 500) {
- NProgress.done();
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- // window.location = '/404?msg=页面未找到';
- return false;
- }
- /*错误码 500*/
- else if (status >= 500) {
- NProgress.done();
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- return false;
- } else {
- if (!res) {
- NProgress.done();
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- return false;
- }
- NProgress.done();
- response(res);
- }
- }
- })
- },
- get: function (url, data) {
- url = url ? url : window.location.href;
- data = data ? data : {};
- if ($.isEmptyObject(data)) {
- window.location.href = url;
- } else {
- window.location.href = url + '?' + $Request.getQueryString(data);
- }
- },
- open: function (url, data) {
- url = url ? url : window.location.href;
- data = data ? data : {};
- if ($.isEmptyObject(data)) {
- window.open(url);
- } else {
- window.open(url + '?' + $Request.getQueryString(data));
- }
- },
- frame: function (url, data, options) {
- if (!$.isEmptyObject(data)) {
- url = url + '?' + $Request.getQueryString(data)
- }
- var _s = Object.assign({
- width: (parseInt((document.documentElement.clientWidth / 100) * 55)) + 'px',
- height: (parseInt((document.documentElement.clientHeight / 100) * 77)) + 'px',
- msg: '正在打开页面,请稍后。。。'
- }, options);
- var iframe = document.createElement("iframe");
- iframe.id = $Request.random(12);
- iframe.src = url;
- iframe.width = _s.width;
- iframe.height = _s.height;
- iframe.className = 'va-frame__wrapper_iframe';
- $(".va-frame__wrapper").find('iframe').remove();
- window.$__frameLoading = $App.$loading({
- lock: true,
- text: _s.msg,
- spinner: 'el-icon-loading',
- });
- $(".va-frame__wrapper").append(iframe);
- $(window).resize(function () {
- $("body").find('.va-frame__wrapper_iframe').attr('width', (parseInt((document.documentElement.clientWidth / 100) * 55)) + 'px');
- $("body").find('.va-frame__wrapper_iframe').attr('height', (parseInt((document.documentElement.clientHeight / 100) * 77)) + 'px');
- });
- },
- href: function (url, data) {
- url = url ? url : window.location.href;
- data = data ? data : {};
- if ($.isEmptyObject(data)) {
- return url;
- } else {
- return url + '?' + $Request.getQueryString(data);
- }
- },
- load: function (url, data, callback) {
- var stateObject = {};
- url = url ? url : window.location.href;
- data = data ? data : {};
- if (!$.isEmptyObject(data)) {
- url = url + '?' + $Request.getQueryString(data);
- }
- $("#app").load(url, null, function (response, status, xhr) {
- if (xhr.status === 404) {
- $App.layouts.loading = false;
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- if (typeof callback === 'function') {
- callback(xhr.status);
- }
- } else if (xhr.status === 500) {
- $App.layouts.loading = false;
- $App.$message({message: '服务器响应错误,请稍后再试!', type: 'error'});
- if (typeof callback === 'function') {
- callback(xhr.status);
- }
- } else {
- history.pushState(stateObject, '', url);
- if (typeof callback === 'function') {
- callback(xhr.status);
- }
- $App.layouts.loading = false;
- }
- });
- },
- random: function (length) {
- length = length ? length : 16;
- var result = '';
- for (var i = 0; i < length; i++) {
- result += Math.floor(Math.random() * 16).toString(16);
- }
- return result.toUpperCase();
- },
- httpRequest: function (settings) {
- var _s = Object.assign({
- url: window.location.href,
- type: 'POST',
- dataType: 'json',
- async: true,
- data: null,
- headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
- timeout: 0,
- encrypt: true,
- beforeSend: function (xhr) {
- },
- success: function (result, status, xhr) {
- },
- error: function (xhr, status, error) {
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- },
- response: function (xhr, status) {
- }
- }, settings);
- if (!_s.url) {
- _s.url = window.location.href
- }
- // 参数验证
- if (!_s.url || !_s.type || !_s.dataType || !_s.async) {
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- return;
- }
- // 创建XMLHttpRequest请求对象
- var xhr = new XMLHttpRequest();
- // 请求开始回调函数
- xhr.addEventListener('loadstart', function (e) {
- _s.beforeSend(xhr);
- });
- // 请求成功回调函数
- xhr.addEventListener('load', function (e) {
- var status = xhr.status;
- if ((status >= 200 && status < 300) || status === 304) {
- var result;
- if (xhr.responseType === 'text') {
- result = xhr.responseText;
- } else if (xhr.responseType === 'document') {
- result = xhr.responseXML;
- } else {
- result = xhr.response;
- }
- _s.success(result, status, xhr);
- } else {
- _s.error(xhr, status, e);
- }
- });
- // 请求结束
- xhr.addEventListener('loadend', function (e) {
- var result;
- if (xhr.responseType === 'text') {
- result = xhr.responseText;
- } else if (xhr.responseType === 'document') {
- result = xhr.responseXML;
- } else {
- result = xhr.response;
- }
- _s.response(result, xhr.status);
- });
- // 请求出错
- xhr.addEventListener('error', function (e) {
- _s.error(xhr, xhr.status, e);
- });
- // 请求超时
- xhr.addEventListener('timeout', function (e) {
- _s.error(xhr, 408, e);
- });
- var useUrlParam = false;
- var sType = _s.type.toUpperCase();
- if (sType === 'GET' || sType === 'DELETE') {
- useUrlParam = true;
- _s.url += $Request.getUrlParam(_s.url, _s.data);
- }
- xhr.open(_s.type, _s.url, _s.async);
- xhr.responseType = _s.dataType;
- var headers_keys = Object.keys(_s.headers);
- // 设置请求头
- headers_keys.forEach(function (value, index, array) {
- xhr.setRequestHeader(value, _s.headers[value]);
- });
- if (_s.async && _s.timeout) {
- xhr.timeout = _s.timeout;
- }
- xhr.send(useUrlParam ? null : $Request.getQueryData(_s.data));
- },
- httpJsonRequest: function (settings) {
- var _s = Object.assign({
- url: window.location.href,
- type: 'POST',
- dataType: 'json',
- async: true,
- data: null,
- headers: {'Content-Type': 'application/json; charset=UTF-8'},
- timeout: 0,
- encrypt: true,
- beforeSend: function (xhr) {
- },
- success: function (result, status, xhr) {
- },
- error: function (xhr, status, error) {
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- },
- response: function (xhr, status) {
- }
- }, settings);
- if (!_s.url) {
- _s.url = window.location.href
- }
- // 参数验证
- if (!_s.url || !_s.type || !_s.dataType || !_s.async) {
- $App.$message({message: '网络请求异常,请稍后再试!', type: 'error'});
- return;
- }
- // 创建XMLHttpRequest请求对象
- var xhr = new XMLHttpRequest();
- // 请求开始回调函数
- xhr.addEventListener('loadstart', function (e) {
- _s.beforeSend(xhr);
- });
- // 请求成功回调函数
- xhr.addEventListener('load', function (e) {
- var status = xhr.status;
- if ((status >= 200 && status < 300) || status === 304) {
- var result;
- if (xhr.responseType === 'text') {
- result = xhr.responseText;
- } else if (xhr.responseType === 'document') {
- result = xhr.responseXML;
- } else {
- result = xhr.response;
- }
- _s.success(result, status, xhr);
- } else {
- _s.error(xhr, status, e);
- }
- });
- // 请求结束
- xhr.addEventListener('loadend', function (e) {
- var result;
- if (xhr.responseType === 'text') {
- result = xhr.responseText;
- } else if (xhr.responseType === 'document') {
- result = xhr.responseXML;
- } else {
- result = xhr.response;
- }
- _s.response(result, xhr.status);
- });
- // 请求出错
- xhr.addEventListener('error', function (e) {
- _s.error(xhr, xhr.status, e);
- });
- // 请求超时
- xhr.addEventListener('timeout', function (e) {
- _s.error(xhr, 408, e);
- });
- var useUrlParam = false;
- var sType = _s.type.toUpperCase();
- if (sType === 'GET' || sType === 'DELETE') {
- useUrlParam = true;
- _s.url += $Request.getUrlParam(_s.url, _s.data);
- }
- xhr.open(_s.type, _s.url, _s.async);
- xhr.responseType = _s.dataType;
- var headers_keys = Object.keys(_s.headers);
- // 设置请求头
- headers_keys.forEach(function (value, index, array) {
- xhr.setRequestHeader(value, _s.headers[value]);
- });
- if (_s.async && _s.timeout) {
- xhr.timeout = _s.timeout;
- }
- // xhr.send(useUrlParam ? null : $Request.getQueryData(_s.data));
- xhr.send(useUrlParam ? null : JSON.stringify(_s.data));
- },
- getUrlParam: function (url, data) {
- if (!data) {
- return '';
- }
- var paramsStr = data instanceof Object ? $Request.getQueryString(data) : data;
- return (url.indexOf('?') !== -1) ? paramsStr : '?' + paramsStr;
- },
- getQueryData: function (data) {
- if (!data) {
- return null;
- }
- if (typeof data === 'string') {
- return data;
- }
- if (data instanceof FormData) {
- return data;
- }
- return $Request.getQueryString(data);
- },
- getQueryString: function (data) {
- var paramsArr = [];
- if (data instanceof Object) {
- Object.keys(data).forEach(function (key) {
- var val = data[key];
- paramsArr.push(encodeURIComponent(key) + '=' + encodeURIComponent(val));
- });
- }
- return paramsArr.join('&');
- }
- };
- var $Config = {
- data: function () {
- return {
- isCollapse: false,
- }
- },
- methods: {
- /*主题色右侧菜单事件*/
- themeCommandEvent: function (theme) {
- let root = document.querySelector(":root");
- Cookies.set('theme', theme);
- root.style.setProperty("--themeColors", themeStyle[theme].themeColors);
- root.style.setProperty("--themeTextColors", themeStyle[theme].themeTextColors);
- root.style.setProperty("--themeSelectColors", themeStyle[theme].themeSelectColors);
- root.style.setProperty("--headerBackground", themeStyle[theme].headerBackground);
- root.style.setProperty("--headerTextColors", themeStyle[theme].headerTextColors);
- root.style.setProperty("--leftBackground", themeStyle[theme].leftBackground);
- root.style.setProperty("--leftTextColors", themeStyle[theme].leftTextColors);
- root.style.setProperty("--buttonHoverColors", themeStyle[theme].buttonHoverColors);
- },
- /*左侧菜单展合*/
- menuClose() {
- var that = this;
- if (that.isCollapse === true) {
- that.isCollapse = false;
- $('#app-main').css('--real-sidebar-width', '200px')
- $('.left-title span').css('display', 'inline')
- } else {
- that.isCollapse = true;
- $('#app-main').css('--real-sidebar-width', '64px')
- $('.left-title span').css('display', 'none')
- }
- // 监听窗口大小变化
- that.handleResize()
- },
- handleResize(){
- // 监听窗口开合
- }
- },
- beforeCreate: function () {
- },
- created: function () {
- },
- mounted: function () {
- //设置主体
- var $theme = Cookies.get('theme');
- this.themeCommandEvent($theme ? $theme : 'index');
- }
- };
- var $Layouts = {
- data: function () {
- return {
- config: {
- menuLayouts: 'left', permissions: true, breadcrumb: true,
- header: {show: false, msg: '详细页面', back: '', callback: ''}, menu_id: 0,
- },
- menuRule:'index',
- fastAdminPath:'/admin.php',
- currentItemsKey:'currentItems',
- layoutsLeftMenuEventKey:'layoutsLeftMenuEvent',
- permissions: [],
- layouts: {
- tabs: {
- menuOpenIds: [],
- active: 0,
- menus: {},
- show: true,
- custom: false,
- openeds: [],
- headerParentId: 0
- },
- left: {
- menuOpenIds: [],
- active: '0',
- menus: {},
- show: true,
- custom: false,
- openeds: [],
- headerParentId: 0,
- },
- drawerFormsHeight: {'height': '600px'},
- drawerFixedHeight: {'height': '480px'},
- dialogFormsHeight: {'height': '480px'},
- dialogFixedHeight: {'height': '480px'},
- },
- GalleryParams: {
- models: '',
- action: '/admin/framework/common/gallery/upload',
- driver: 'local',
- domain: '',
- options: {
- max: 1,
- size: 20,
- suffix: 'bmp,gif,jpg,jpeg,png',
- type: 1,
- cat: false,
- tabs: false,
- upload: true,
- addPage: false,
- addIcon: false,
- },
- fileTypeMaps: {
- '1': 'image', '2': 'media', '3': 'file'
- },
- postHeaders: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- },
- postData: {},
- operation: {
- groupManage: false,
- groupMax: 6,
- imageTotal: 0,
- dialog: false,
- loading: false,
- loadingMsg: '',
- error: false
- },
- search: {
- group_id: 0,
- page: 1,
- keyword: '',
- size: 12,
- type: 1
- },
- size:0,
- groupItems: [],
- imagesItems: [],
- selected: [],
- },
- CenterParams:{
- // 监测抽屉鼠标事件
- mousedownClassBol: false,//抽屉遮盖层误触
- dialogClassModel: '',//抽屉遮盖层误触
- // 监测抽屉鼠标事件 End.
- loadingMsg:'正在加载数据,请稍后...',
- dialog: false, loading: false,updatePasswordStatus:false,
- action: '',
- model: {name:'',account:'',password:''},
- rules: {
- name: [
- { required: true, message: '请填写用户名', trigger: 'blur'}
- ],
- account: [
- { required: true, message: '请填写登录账号', trigger: 'blur'}
- ]
- }
- },
- }
- },
- methods: {
- copy(context){
- let that = this
- navigator.clipboard.writeText(context)
- .then(()=>{
- that.$Message('复制成功', 'success');
- })
- .catch(err => {
- that.$Message('复制失败', 'warning');
- })
- },
- /*格式化时间戳*/
- formatTableDate: function (row, column, value) {
- if ((typeof (value) === 'undefined') || parseInt(value) === 0) {
- return '---';
- }
- return $Utils.formatDate('yyyy-MM-dd hh:mm:ss', value);
- },
- formatTableDay: function (row, column, value) {
- if ((typeof (value) === 'undefined') || parseInt(value) === 0) {
- return '---';
- }
- return $Utils.formatDate('yyyy-MM-dd', value);
- },
- /*确认信息*/
- $Alerts: function (msg, successCallback, errorCallback, options) {
- options = options ? options : {
- type: 'warning',
- lockScroll: true,
- center: true,
- confirm: '确定',
- cancel: '取消',
- showClose: true,
- showCancelButton: true,
- };
- var that = this;
- that.$confirm(msg, '系统提示', {
- dangerouslyUseHTMLString: true,
- confirmButtonText: options.confirm ? options.confirm : '确定',
- cancelButtonText: options.cancel ? options.cancel : '取消',
- type: options.type ? options.type : 'warning',
- lockScroll: options.lockScroll ? options.lockScroll : false,
- showClose: options.showClose ? options.showClose : true,
- center: options.center ? options.center : true,
- showCancelButton: options.showCancelButton ? options.showCancelButton : true,
- }).then(function () {
- if (successCallback) {
- successCallback();
- }
- }).catch(function () {
- if (errorCallback) {
- errorCallback();
- }
- });
- },
- /*确认信息*/
- $Confirm: function (msg, successCallback, errorCallback, options) {
- var that = this;
- options = options ? options : {};
- var _s = Object.assign({
- dangerouslyUseHTMLString: true,
- lockScroll: false,
- type: 'warning',
- center: true,
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- closeOnClickModal: true,
- showCancelButton: true
- }, options);
- that.$confirm(msg, '系统提示', _s).then(function () {
- if (successCallback) {
- successCallback();
- }
- }).catch(function () {
- if (errorCallback) {
- errorCallback();
- }
- });
- },
- /*提示信息*/
- $Message: function (msg, callback, type, duration) {
- var that = this;
- if (typeof callback === 'string') {
- type = callback;
- } else {
- if (!type) {
- type = 'success'; //warning error
- }
- }
- duration = duration ? duration : 1500;
- that.$message({
- type: type, duration: duration, message: msg, dangerouslyUseHTMLString: true, onClose: function (res) {
- if (callback && (typeof callback) === 'function') {
- callback(res);
- }
- }
- });
- },
- $Loading: function () {
- var loading = this.$loading({
- lock: true,
- text: 'Loading',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- setTimeout(() => {
- loading.close();
- }, 2000);
- },
- emptyChange: function () {
- },
- PermissionsCallbackEvent: function (res) {
- return true;
- },
- layoutsLeftMenuEvent: function (key, keyPath, e) {
- var that = this;
- var menuItems = e.$attrs.items;
- var $loading = that.$loading({
- lock: true,
- background: 'rgba(255, 255, 255, 0.4)'
- });
- if ((typeof e.$attrs.items) != 'object') {
- if (!$Validator.json(e.$attrs.items)) {
- return true;
- }
- menuItems = JSON.parse(e.$attrs.items);
- }
- var currentItems = Cookies.getJSON(that.currentItemsKey);
- Cookies.set(that.layoutsLeftMenuEventKey, menuItems.id);
- Cookies.set(that.currentItemsKey, menuItems);
- that.layoutsTabsMenuEvent(menuItems);
- $Request.get(menuItems.path, {}, function (status) {
- $loading.close();
- if (status !== 200) {
- Cookies.set(that.currentItemsKey, currentItems);
- Cookies.set(that.layoutsLeftMenuEventKey, currentItems.id);
- $Request.get(currentItems.path, {});
- }
- });
- },
- layoutsLeftMenuEventSet: function (menuItems) {
- var that = this
- var $loading = this.$loading({
- lock: true,
- background: 'rgba(255, 255, 255, 0.4)'
- });
- var currentItems = Cookies.getJSON(that.currentItemsKey);
- Cookies.set(that.layoutsLeftMenuEventKey, menuItems.id);
- Cookies.set(that.currentItemsKey, menuItems);
- $Request.get(menuItems.path, {}, function (status) {
- $loading.close();
- if (status !== 200) {
- Cookies.set(that.currentItemsKey, currentItems);
- Cookies.set(that.layoutsLeftMenuEventKey, currentItems.id);
- $Request.get(currentItems.path, {});
- }
- });
- },
- layoutsTabsMenuClickEvent: function (e) {
- var that = this;
- if (!that.layouts.tabs.show) return false;
- if (!that.layouts.tabs.active || parseInt(that.layouts.tabs.active) === 0) {
- Cookies.remove(that.currentItemsKey);
- Cookies.remove(that.layoutsLeftMenuEventKey);
- $Request.get('/admin', {});
- return true;
- }
- $.each(that.layouts.tabs.menus, function (key, val) {
- if (parseInt(val.id) === parseInt(that.layouts.tabs.active)) {
- that.layoutsLeftMenuEventSet(val);
- return true;
- }
- });
- },
- layoutsTabsMenuRemoveEvent: function (e) {
- var that = this;
- var _Key = 0;
- if (!that.layouts.tabs.show) return false;
- $.each(that.layouts.tabs.menus, function (key, val) {
- if (parseInt(val.id) === e) {
- _Key = (key + 1);
- that.layouts.tabs.menus.splice(key, 1);
- return false;
- }
- });
- var _Length = that.layouts.tabs.menus.length;
- if (_Length < 1) {
- sessionStorage.removeItem('9ca5hgd13b48hfcddfdab76c63ddf8u2');
- Cookies.remove(that.currentItemsKey);
- Cookies.remove(that.layoutsLeftMenuEventKey);
- $Request.get('/admin', {});
- return true;
- }
- sessionStorage.setItem('9ca5hgd13b48hfcddfdab76c63ddf8u2', JSON.stringify(that.layouts.tabs.menus));
- if (parseInt(that.layouts.tabs.active) === e) {
- if (parseInt(_Key) === 1) {
- that.layoutsLeftMenuEventSet(that.layouts.tabs.menus[0]);
- return true;
- }
- that.layoutsLeftMenuEventSet(that.layouts.tabs.menus[_Key - 2]);
- }
- return true;
- },
- layoutsTabsMenuEvent: function (items) {
- var that = this;
- var _isS = true;
- if (!that.layouts.tabs.show) return false;
- $.each(that.layouts.tabs.menus, function (key, val) {
- if (parseInt(val.id) === parseInt(items.id)) {
- that.layouts.tabs.active = val.id;
- _isS = false;
- return true;
- }
- });
- if (_isS === true) {
- var menus = sessionStorage.getItem('9ca5hgd13b48hfcddfdab76c63ddf8u2');
- if (menus) {
- menus = JSON.parse(menus);
- menus.push(items);
- } else {
- menus = [items];
- }
- sessionStorage.setItem('9ca5hgd13b48hfcddfdab76c63ddf8u2', JSON.stringify(menus));
- return true;
- }
- },
- layoutsTabsMenuCommandEvent: function (e) {
- var that = this;
- if (!that.layouts.tabs.show) return false;
- if (that.layouts.tabs.menus.length < 1) {
- return true;
- }
- if (e === 'all') {
- sessionStorage.removeItem('9ca5hgd13b48hfcddfdab76c63ddf8u2');
- Cookies.remove(that.currentItemsKey);
- Cookies.remove(that.layoutsLeftMenuEventKey);
- $Request.get('/admin', {});
- return true;
- } else if (e === 'other') {
- var tabsMenus = [];
- if (that.layouts.tabs.menus && that.layouts.tabs.menus.length > 0) {
- if (parseInt(this.layouts.tabs.active) > 0) {
- $.each(that.layouts.tabs.menus, function (key, val) {
- if (parseInt(val.id) === parseInt(that.layouts.tabs.active)) {
- tabsMenus[0] = val;
- }
- });
- that.layouts.tabs.menus = tabsMenus;
- sessionStorage.setItem('9ca5hgd13b48hfcddfdab76c63ddf8u2', JSON.stringify(tabsMenus));
- } else {
- sessionStorage.removeItem('9ca5hgd13b48hfcddfdab76c63ddf8u2');
- Cookies.remove(that.currentItemsKey);
- Cookies.remove(that.layoutsLeftMenuEventKey);
- $Request.get('/admin', {});
- }
- }
- } else {
- if (parseInt(this.layouts.tabs.active) > 0) {
- that.layoutsTabsMenuRemoveEvent(that.layouts.tabs.active);
- }
- }
- },
- getLayoutsTabsMenus: function (items) {
- var that = this;
- if (!that.layouts.tabs.show) return false;
- that.layouts.tabs.menus = [];
- if (!that.layouts.tabs.show) return true;
- var currentItems = sessionStorage.getItem('9ca5hgd13b48hfcddfdab76c63ddf8u2');
- if (!currentItems) {
- return true;
- }
- currentItems = JSON.parse(currentItems);
- that.layouts.tabs.show = true;
- that.layouts.tabs.menus = currentItems;
- },
- /*获取页面操作项*/
- getUserOperationPermissions: function (menu_rule) {
- var that = this;
- $Request.postJson(that.fastAdminPath + '/vue/operationPermissions', {menu_rule: menu_rule}, function (res) {
- if (res.code === 200) {
- that.permissions = res.result;
- // console.log(that.permissions);
- that.PermissionsCallbackEvent(res.result);
- }
- });
- },
- redirectPage: function (url, data, type) {
- var that = this;
- var backLoading = that.$loading({
- lock: true,
- background: 'rgba(255, 255, 255, 0.4)'
- });
- switch (type) {
- case 'load':
- that.layouts.loading = true;
- $Request.load(url, data);
- break;
- case 'open':
- backLoading.close();
- $Request.open(url, data);
- break;
- case 'reload':
- window.location.reload();
- break;
- case 'post':
- $Request.postJson(url, data, function (res) {
- backLoading.close();
- that.$Message('成功!');
- });
- break;
- default:
- that.layouts.loading = true;
- $Request.get(url, data);
- break;
- }
- return true;
- },
- /*计算页面高度*/
- computingWindowHeight: function (reload) {
- var that = this;
- if (reload === true) {
- if (that.layouts.isCollapse) {
- that.layouts.isCollapse = false;
- that.layouts.menuWidth = {'width': '220px !important'}
- } else {
- that.layouts.isCollapse = true;
- that.layouts.menuWidth = {'width': '64px !important'}
- }
- if (!that.layouts.left.show) {
- that.layouts.isCollapse = false;
- that.layouts.menuWidth = {'width': '0 !important'};
- }
- }
- var documentClientHeight = document.documentElement.clientHeight;
- that.layouts.containerHeight = {
- 'height': (documentClientHeight - 20) + 'px',
- };
- that.layouts.mainHeight = {
- 'min-height': (documentClientHeight - 120) + 'px',
- };
- that.layouts.drawerFormsHeight = {
- 'max-height': parseInt((documentClientHeight * 0.71) - 120) + 'px'
- };
- that.layouts.dialogFormsHeight = {
- 'max-height': parseInt((documentClientHeight * 0.81) - 120) + 'px'
- };
- that.layouts.drawerFixedHeight = {
- 'height': (documentClientHeight - 131) + 'px',
- };
- that.layouts.dialogFixedHeight = {
- 'height': (documentClientHeight - 380) + 'px',
- };
- that.layouts.windowHeight = documentClientHeight - 120;
- },
- handleCommand: function (command) {
- var that = this;
- switch (command) {
- case 'logout': //退出
- that.logout();
- break;
- case 'clear_cache':
- that.clearCache();
- break;
- case 'center':
- that.centerDialogOpen();
- break;
- default:
- break;
- }
- },
- logout: function () {
- $Request.get('/admin/passport/logout', {});
- },
- clearCache: function () {
- this.redirectPage('/admin/framework/common/cacheClear', {}, 'post')
- },
- centerDialogOpen: function () {
- $Center.CenterDialogOpen();
- },
- },
- beforeCreate: function () {
- },
- created: function () {
- var that = this;
- var path = window.location.pathname.split('/')[1];
- path = path === undefined ? '' : '/' + path;
- that.layoutsLeftMenuEventKey = $('meta[name="layouts-left"]').attr('content');
- that.currentItemsKey = $('meta[name="current-items"]').attr('content');
- that.fastAdminPath = path;
- that.getUserOperationPermissions(that.menuRule);
- },
- mounted: function () {
- var that = this;
- that.computingWindowHeight(true);
- $(window).resize(function () {
- that.computingWindowHeight(false);
- });
- }
- };
- var $Tables = {
- data: function () {
- return {
- tables: {
- remove: {url: '', msg: '', field: ''},
- status: {url: '', msg: '', field: '', maps: {1: '禁用', 2: '启用'}},
- sort: {url: '', item: '', field: ''},
- selects: [],
- options: {
- cell: true,
- loading: true,
- loadingMsg: '正在加载数据,请稍后...'
- },
- url: '', search: {},
- prop: 'id',
- orderBy: 'desc',
- pagination: {
- layouts: 'total, sizes, prev, pager, next, jumper',
- sizes: [15, 30, 50, 100, 300, 500],
- page: 1,
- size: 15,
- total: 20,
- },
- data: []
- },
- }
- },
- methods: {
- formatTableColumn: function (row, column, value) {
- },
- tablesCellMoveEvent: function (row, column, cell, event) {
- var that = this;
- if (column.filterPlacement === 'false' || !that.tables.options.cell) {
- return false;
- }
- event.stopPropagation();
- if ($(cell).find('.cell').hasClass('Va-table-move')) {
- return false;
- } else {
- $('.cell').removeClass('Va-table-move');
- $('.Va-table-move-close').remove();
- if (!row[column.property]) {
- return false;
- }
- $(cell).find('.cell').append('<i class="el-icon-close Va-table-move-close" onclick="removeTableMoveEvent(this)"></i>');
- $(cell).find('.cell').addClass('Va-table-move');
- if (($(cell).width() - 20) > $(cell).parent().find('.Va-table-move').width()) {
- $('.cell').removeClass('Va-table-move');
- $('.Va-table-move-close').remove();
- }
- }
- },
- tablesPaginationSizeChange: function (size) {
- var that = this;
- that.tables.pagination.size = size;
- that.tablesGetTableList();
- },
- tablesPaginationCurrentChange: function (page) {
- var that = this;
- that.tables.pagination.page = page;
- that.$refs.formContainerTables.clearSelection();
- that.tablesGetTableList();
- },
- /*排序发生改变时触发*/
- tablesPaginationSortChange: function (rows) {
- var that = this;
- that.$set(that.tables, 'orderBy', rows.orderBy);
- if (typeof rows.column.sortBy === 'undefined') {
- that.$set(that.tables, 'prop', rows.prop);
- } else {
- that.$set(that.tables, 'prop', rows.column.sortBy);
- }
- that.tablesGetTableList();
- },
- /*多选发生改变时触发*/
- tablesSelectChange: function (rows) {
- var that = this;
- that.selects = rows;
- that.$set(that.tables, 'selects', rows);
- },
- tablesClearSelect: function () {
- var that = this;
- that.$nextTick(function () {
- that.$refs.formContainerTables.clearSelection();
- })
- },
- getTablesSelected: function () {
- var that = this;
- if (!that.tables.selects.length || that.tables.selects.length <= 0) {
- return [];
- }
- var selects_ids = [];
- that.tables.selects.forEach(function (item, index) {
- selects_ids.push(item.id);
- });
- if (!selects_ids || selects_ids.length <= 0) {
- return [];
- }
- return selects_ids;
- },
- tablesGetTableList: function () {
- var that = this;
- if (!that.tablesGetTableListFront()) {
- return false;
- }
- if (!that.tables.url) {
- that.tables.url = window.location.href;
- }
- that.tables.options.loading = true;
- that.tables.search.page = that.tables.pagination.page;
- that.tables.search.size = that.tables.pagination.size;
- that.tables.search.orderBy = that.tables.orderBy;
- that.tables.search.prop = that.tables.prop;
- $Request.postJson(that.tables.url, that.tables.search, function (res) {
- if (that.tablesGetTablesListsAfter(res)) {
- if ((typeof (res) === 'undefined')) {
- return false;
- }
- if ((typeof (res.result) === 'undefined')) {
- return false;
- }
- // console.log(that.tables.data);
- that.tables.options.loading = false;
- that.tables.data = res.result.rows ? res.result.rows : res.result.data;
- that.tables.pagination.total = res.result.total;
- }
- that.tablesGetTablesListsFinish(res);
- })
- if (that.parking && that.parking.search.store_id){
- that.getParkingList()
- }
- },
- tablesGetTableListFront: function () {
- return true;
- },
- tablesGetTablesListsAfter: function () {
- return true;
- },
- tablesGetTablesListsFinish: function () {
- return true;
- },
- tablesRowsRemove: function (rows, params) {
- var that = this;
- if (!that.tables.remove.url) {
- return false;
- }
- var requestData = {};
- if (params) {
- requestData = params;
- }
- that.tables.remove.msg = that.tables.remove.msg ? that.tables.remove.msg : '确认删除当前数据吗?';
- that.tables.remove.field = that.tables.remove.field ? that.tables.remove.field : 'id';
- if (!rows[that.tables.remove.field]) {
- return false;
- }
- requestData[that.tables.remove.field] = rows[that.tables.remove.field];
- that.$confirm(that.tables.remove.msg, '操作提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true,
- dangerouslyUseHTMLString: true,
- lockScroll: false,
- }).then(function () {
- $Request.postJson(that.tables.remove.url, requestData, function (res) {
- if (res.code === 200) {
- that.$message({
- message: res.message, type: 'success', duration: 2400, onClose: function () {
- }
- });
- that.tablesGetTableList();
- } else {
- that.$message({
- message: res.message, type: 'error', duration: 2400, onClose: function () {
- }
- });
- }
- })
- }).catch(function () {
- });
- },
- tablesRowsStatus: function (rows, params) {
- var that = this;
- if (!that.tables.status.url || !that.tables.status.field) {
- return false;
- }
- if (!rows[that.tables.status.field] && rows[that.tables.status.field] !== 0) {
- return false;
- }
- if (!that.tables.status.maps[rows[that.tables.status.field]]) {
- return false;
- }
- that.tables.status.msg = '确认' + that.tables.status.maps[rows[that.tables.status.field]] + '当前数据吗?';
- var requestData = {};
- if (params) {
- requestData = params;
- }
- requestData[that.tables.status.field] = rows[that.tables.status.field];
- that.$confirm(that.tables.status.msg, '操作提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: false,
- dangerouslyUseHTMLString: true,
- lockScroll: false,
- }).then(function () {
- $Request.postJson(that.tables.status.url, requestData, function (res) {
- if (res.code === 200) {
- that.$message({
- message: res.message, type: 'success', duration: 2400, onClose: function () {
- }
- });
- that.tablesGetTableList();
- } else {
- that.$message({
- message: res.message, type: 'error', duration: 2400, onClose: function () {
- }
- });
- }
- })
- }).catch(function () {
- });
- },
- tablesRowsSort: function (rows) {
- var that = this;
- if (!that.tables.sort.url) {
- return false;
- }
- var requestData = {};
- that.tables.sort.field = that.tables.sort.field ? that.tables.sort.field : 'id';
- that.tables.sort.item = that.tables.sort.item ? that.tables.sort.item : 'sort';
- if (!rows[that.tables.sort.field]) {
- return false;
- }
- if (!rows[that.tables.sort.item]) {
- return false;
- }
- requestData[that.tables.sort.field] = rows[that.tables.sort.field];
- requestData[that.tables.sort.item] = rows[that.tables.sort.item];
- $Request.postJson(that.tables.sort.url, requestData, function (res) {
- if (res.code === 200) {
- that.$message({message: res.message, type: 'success', duration: 2100});
- that.tablesGetTableList();
- } else {
- that.$message({message: res.message, type: 'error', duration: 2100});
- }
- })
- },
- tablesRowsType: function (rows) {
- var that = this;
- if (!that.tables.type.url) {
- return false;
- }
- var requestData = {};
- that.tables.type.field = that.tables.type.field ? that.tables.type.field : 'id';
- that.tables.type.item = that.tables.type.item ? that.tables.type.item : 'type';
- if (!rows[that.tables.type.field]) {
- return false;
- }
- if (!rows[that.tables.type.item]) {
- return false;
- }
- requestData[that.tables.type.field] = rows[that.tables.type.field];
- requestData[that.tables.type.item] = rows[that.tables.type.item];
- $Request.postJson(that.tables.type.url, requestData, function (res) {
- if (res.code === 200) {
- that.$message({message: res.message, type: 'success', duration: 2100});
- that.tablesGetTableList();
- } else {
- that.$message({message: res.message, type: 'error', duration: 2100});
- }
- })
- },
- // 公共执行操作
- tablesRowsOperate: function (url, params, msg = '确定要执行当前操作吗?') {
- var that = this;
- var requestData = {};
- if (params) {
- requestData = params;
- }
- that.$confirm(msg, '操作提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: false,
- dangerouslyUseHTMLString: true,
- lockScroll: false,
- }).then(function () {
- $Request.postJson(url, requestData, function (res) {
- if (res.code === 200) {
- that.$message({
- message: res.message, type: 'success', duration: 2400, onClose: function () {
- }
- });
- that.tablesGetTableList();
- } else {
- that.$message({
- message: res.message, type: 'error', duration: 2400, onClose: function () {
- }
- });
- }
- })
- }).catch(function () {
- });
- },
- tablesSearchEvent: function () {
- this.tables.pagination.page = 1;
- this.tablesGetTableList();
- },
- tablesResetsEvent: function () {
- },
- },
- mounted: function () {
- var that = this;
- that.tablesGetTableList();
- },
- beforeCreate: function () {
- var that = this;
- },
- created: function () {
- }
- };
- var $DrawerForms = {
- data: function () {
- return {
- drawerFormsOptions: {
- models: 'drawerForms',
- refs: 'create.model',
- status: false,
- },
- drawerOpens: [],
- __key: '',
- drawerForms: {},
- // 监测抽屉鼠标事件
- mousedownClassBol: false,//抽屉遮盖层误触
- drawerClassModel: '',//抽屉遮盖层误触
- // 监测抽屉鼠标事件 End.
- }
- },
- methods: {
- // 监测抽屉鼠标事件
- handleWrapperMousedown(e) {
- var that = this;
- // 如果为true,则表示点击发生在遮罩层
- that.drawerClassModel = !!e.target.classList.contains('el-drawer__container')
- },
- handleWrapperMouseup(e) {
- var that = this;
- if ((!!e.target.classList.contains('el-drawer__container')) && that.drawerClassModel) {
- that.drawerFormsCloses(that.drawerFormsOptions.models);
- }
- },
- // 监测抽屉鼠标事件 End.
- drawerFormsCloses: function (model) {
- var that = this;
- if (model && typeof model == 'string') that.drawerFormsOptions.models = model;
- that[that.drawerFormsOptions.models].drawer = false;
- that[that.drawerFormsOptions.models].loading = false;
- if (that.drawerOpens.length > 0) {
- that.drawerOpens.splice(that.drawerOpens.length - 1)
- that.drawerFormsOptions.models = that.drawerOpens[that.drawerOpens.length - 1] ? that.drawerOpens[that.drawerOpens.length - 1] : 'drawerForms'
- }
- if (that.$refs[that.drawerFormsOptions.refs]) {
- setTimeout(function () {
- that.$refs[that.drawerFormsOptions.refs].resetFields();
- }, 500);
- }
- },
- drawerFormsBeforeCloses: function (model) {
- var that = this;
- if (model && typeof model == 'string') that.drawerFormsOptions.models = model;
- // console.log(that.drawerFormsOptions.models);
- that[that.drawerFormsOptions.models].drawer = false;
- that[that.drawerFormsOptions.models].loading = false;
- },
- drawerFormsSubmits: function (model) {
- var that = this;
- if (model && typeof model == 'string') that.drawerFormsOptions.models = model;
- /*防止重复提交*/
- if (that[that.drawerFormsOptions.models].loading) {
- return false;
- }
- if ((typeof (that.$refs[that.drawerFormsOptions.refs]) === 'undefined')) {
- that[that.drawerFormsOptions.models].loading = true;
- var formsdrawerFunction = that.drawerFormsOptions.models + 'FormsSubmits';
- if (that.hasOwnProperty(formsdrawerFunction)) {
- that[formsdrawerFunction](that[that.drawerFormsOptions.models].model);
- } else {
- that.drawerFormsRequests(that[that.drawerFormsOptions.models].model);
- }
- that[that.drawerFormsOptions.models].loading = false;
- return true;
- } else {
- that.$refs[that.drawerFormsOptions.refs].validate(function (valid) {
- if (valid) {
- that[that.drawerFormsOptions.models].loading = true;
- var formsdrawerFunction = that.drawerFormsOptions.models + 'FormsSubmits';
- if (that.hasOwnProperty(formsdrawerFunction)) {
- that[formsdrawerFunction](that[that.drawerFormsOptions.models].model);
- } else {
- that.drawerFormsRequests(that[that.drawerFormsOptions.models].model);
- }
- } else {
- that[that.drawerFormsOptions.models].loading = false;
- }
- });
- }
- },
- drawerFormsOpens: function (model) {
- var that = this;
- that.config.__key = $Request.random(12);
- that.drawerFormsOptions.models = model;
- if ((typeof (model) === 'undefined') || (typeof (model) === 'object')) {
- that.drawerFormsOptions.models = 'drawerForms';
- }
- if ((typeof (that[that.drawerFormsOptions.models])) === 'undefined') {
- that[that.drawerFormsOptions.models] = {
- drawer: false,
- loading: false,
- action: '',
- model: {},
- rules: {}
- };
- }
- if ((typeof (that[that.drawerFormsOptions.models].drawer)) === 'undefined') {
- that[that.drawerFormsOptions.models].drawer = false;
- }
- if ((typeof (that[that.drawerFormsOptions.models].loading)) === 'undefined') {
- that[that.drawerFormsOptions.models].loading = false;
- }
- if ((typeof (that[that.drawerFormsOptions.models].loadingTables)) === 'undefined') {
- that[that.drawerFormsOptions.models].loadingTables = true;
- }
- if ((typeof (that[that.drawerFormsOptions.models].model)) === 'undefined') {
- that[that.drawerFormsOptions.models].model = {};
- }
- if ((typeof (that[that.drawerFormsOptions.models].rules)) === 'undefined') {
- that[that.drawerFormsOptions.models].rules = {};
- }
- that.drawerFormsOptions.refs = that.drawerFormsOptions.models + '.model';
- that.drawerFormsOptions.status = true;
- that.drawerOpens.push(that.drawerFormsOptions.models);
- that[that.drawerFormsOptions.models].drawer = true;
- that[that.drawerFormsOptions.models].loading = false;
- if (!(typeof (that.$refs[that.drawerFormsOptions.refs]) === 'undefined')) {
- that.$refs[that.drawerFormsOptions.refs].resetFields();
- }
- return true;
- },
- drawerFormsRequests: function (model) {
- var that = this;
- if (!that[that.drawerFormsOptions.models].action) {
- console.error('$drawerForms:Forms component does not configure submit parameters!');
- that[that.drawerFormsOptions.models].loading = false;
- return false;
- }
- $Request.postJson(that[that.drawerFormsOptions.models].action, model, function (res) {
- if (res.code === 200) {
- that.$message({
- message: res.message, type: 'success', duration: 1500, onClose: function () {
- if (that.hasOwnProperty('tablesGetTableList')) {
- that[that.drawerFormsOptions.models].loading = false;
- that[that.drawerFormsOptions.models].drawer = false;
- if (that[that.drawerFormsOptions.models].loadingTables) {
- that.tablesGetTableList();
- }
- that.drawerFormsRequestsAfter(res);
- }
- if (that[that.drawerFormsOptions.models].success) {
- var success = that[that.drawerFormsOptions.models].success;
- if (that.hasOwnProperty(success)) {
- that[success](res)
- }
- }
- }
- });
- } else {
- that[that.drawerFormsOptions.models].loading = false;
- that.$message({message: res.message, type: 'error', duration: 1500});
- }
- });
- },
- drawerFormsRequestsAfter: function () {
- return true;
- },
- drawerFormsRequestsErrors: function () {
- var that = this;
- },
- drawerFormsValidateErrors: function (forms) {
- var that = this;
- },
- drawerListPageFormsOpens:function (model) {
- var that = this;
- var __table = that[model].model.__table;
- $Request.postJson('/admin/arts/setup/pageGetSetup', {__table: __table}, function (res) {
- if(res.code === 200){
- if(res.result && !Array.isArray(res.result)) {
- that[model].model = res.result;
- }
- that[model].model.__table = __table;
- }
- that.drawerFormsOpens(model);
- })
- }
- },
- mounted: function () {
- },
- beforeCreate: function () {
- var that = this;
- },
- created: function () {
- var that = this;
- }
- };
- var $DialogForms = {
- data: function () {
- return {
- dialogFormsOptions: {
- models: 'dialogForms',
- refs: 'create.model',
- status: false,
- },
- dialogOpens: [],
- __key: '',
- dialogForms: {},
- // 监测抽屉鼠标事件
- mousedownClassBol: false,//抽屉遮盖层误触
- dialogClassModel: '',//抽屉遮盖层误触
- // 监测抽屉鼠标事件 End.
- }
- },
- methods: {
- // 监测抽屉鼠标事件
- handleWrapperMousedown(e) {
- var that = this;
- // 如果为true,则表示点击发生在遮罩层
- that.dialogClassModel = !!e.target.classList.contains('el-dialog__wrapper')
- },
- handleWrapperMouseup(e) {
- var that = this;
- if ((!!e.target.classList.contains('el-dialog__wrapper')) && that.dialogClassModel) {
- that.dialogFormsCloses(that.dialogFormsOptions.models);
- }
- },
- // 监测抽屉鼠标事件 End.
- dialogFormsCloses: function (model) {
- var that = this;
- if (model && typeof model == 'string') that.dialogFormsOptions.models = model;
- that[that.dialogFormsOptions.models].dialog = false;
- that[that.dialogFormsOptions.models].loading = false;
- if (that.dialogOpens.length > 0) {
- that.dialogOpens.splice(that.dialogOpens.length - 1)
- that.dialogFormsOptions.models = that.dialogOpens[that.dialogOpens.length - 1] ? that.dialogOpens[that.dialogOpens.length - 1] : 'drawerForms'
- }
- if (that.$refs[that.dialogFormsOptions.refs]) {
- setTimeout(function () {
- that.$refs[that.dialogFormsOptions.refs].resetFields();
- }, 500);
- }
- },
- dialogFormsBeforeCloses: function (model) {
- var that = this;
- if (model && typeof model == 'string') that.dialogFormsOptions.models = model;
- // console.log(that.dialogFormsOptions.models);
- that[that.dialogFormsOptions.models].dialog = false;
- that[that.dialogFormsOptions.models].loading = false;
- },
- dialogFormsSubmits: function (model) {
- var that = this;
- if (model && typeof model == 'string') that.dialogFormsOptions.models = model;
- /*防止重复提交*/
- if (that[that.dialogFormsOptions.models].loading) {
- return false;
- }
- if ((typeof (that.$refs[that.dialogFormsOptions.refs]) === 'undefined')) {
- that[that.dialogFormsOptions.models].loading = true;
- var formsdialogFunction = that.dialogFormsOptions.models + 'FormsSubmits';
- if (that.hasOwnProperty(formsdialogFunction)) {
- that[formsdialogFunction](that[that.dialogFormsOptions.models].model);
- } else {
- that.dialogFormsRequests(that[that.dialogFormsOptions.models].model);
- }
- that[that.dialogFormsOptions.models].loading = false;
- return true;
- } else {
- that.$refs[that.dialogFormsOptions.refs].validate(function (valid) {
- if (valid) {
- that[that.dialogFormsOptions.models].loading = true;
- var formsdialogFunction = that.dialogFormsOptions.models + 'FormsSubmits';
- if (that.hasOwnProperty(formsdialogFunction)) {
- that[formsdialogFunction](that[that.dialogFormsOptions.models].model);
- } else {
- that.dialogFormsRequests(that[that.dialogFormsOptions.models].model);
- }
- } else {
- that[that.dialogFormsOptions.models].loading = false;
- }
- });
- }
- },
- dialogFormsOpens: function (model) {
- var that = this;
- that.config.__key = $Request.random(12);
- that.dialogFormsOptions.models = model;
- if ((typeof (model) === 'undefined') || (typeof (model) === 'object')) {
- that.dialogFormsOptions.models = 'dialogForms';
- }
- if ((typeof (that[that.dialogFormsOptions.models])) === 'undefined') {
- that[that.dialogFormsOptions.models] = {
- dialog: false,
- loading: false,
- action: '',
- model: {},
- rules: {}
- };
- }
- if ((typeof (that[that.dialogFormsOptions.models].dialog)) === 'undefined') {
- that[that.dialogFormsOptions.models].dialog = false;
- }
- if ((typeof (that[that.dialogFormsOptions.models].loading)) === 'undefined') {
- that[that.dialogFormsOptions.models].loading = false;
- }
- if ((typeof (that[that.dialogFormsOptions.models].loadingTables)) === 'undefined') {
- that[that.dialogFormsOptions.models].loadingTables = true;
- }
- if ((typeof (that[that.dialogFormsOptions.models].model)) === 'undefined') {
- that[that.dialogFormsOptions.models].model = {};
- }
- if ((typeof (that[that.dialogFormsOptions.models].rules)) === 'undefined') {
- that[that.dialogFormsOptions.models].rules = {};
- }
- that.dialogFormsOptions.refs = that.dialogFormsOptions.models + '.model';
- that.dialogFormsOptions.status = true;
- that[that.dialogFormsOptions.models].dialog = true;
- that[that.dialogFormsOptions.models].loading = false;
- if (!(typeof (that.$refs[that.dialogFormsOptions.refs]) === 'undefined')) {
- that.$refs[that.dialogFormsOptions.refs].resetFields();
- }
- return true;
- },
- dialogFormsRequests: function (model) {
- var that = this;
- if (!that[that.dialogFormsOptions.models].action) {
- console.error('$dialogForms:Forms component does not configure submit parameters!');
- that[that.dialogFormsOptions.models].loading = false;
- return false;
- }
- $Request.postJson(that[that.dialogFormsOptions.models].action, model, function (res) {
- if (res.code === 200) {
- that.$message({
- message: res.message, type: 'success', duration: 1500, onClose: function () {
- if (that.hasOwnProperty('tablesGetTableList')) {
- that[that.dialogFormsOptions.models].loading = false;
- that[that.dialogFormsOptions.models].dialog = false;
- if (that[that.dialogFormsOptions.models].loadingTables) {
- that.tablesGetTableList();
- that.tablesDialogGetTableList();
- }
- that.dialogFormsRequestsAfter(res);
- }
- if (that[that.dialogFormsOptions.models].success) {
- that[that.dialogFormsOptions.models].loading = false;
- var success = that[that.dialogFormsOptions.models].success;
- if (that.hasOwnProperty(success)) {
- that[success](res)
- }
- }
- }
- });
- } else {
- that[that.dialogFormsOptions.models].loading = false;
- that.$message({message: res.message, type: 'error', duration: 1500});
- }
- });
- },
- dialogFormsRequestsAfter: function () {
- return true;
- },
- dialogFormsRequestsErrors: function () {
- var that = this;
- },
- dialogFormsValidateErrors: function (forms) {
- var that = this;
- },
- dialogListPageFormsOpens:function (model) {
- var that = this;
- var __table = that[model].model.__table;
- $Request.postJson('/admin/arts/setup/pageGetSetup', {__table: __table}, function (res) {
- if(res.code === 200){
- if(res.result && !Array.isArray(res.result)) {
- that[model].model = res.result;
- }
- that[model].model.__table = __table;
- }
- that.dialogFormsOpens(model);
- })
- }
- },
- mounted: function () {
- },
- beforeCreate: function () {
- var that = this;
- },
- created: function () {
- var that = this;
- }
- };
- var $Login = {
- data: function () {
- return {}
- },
- methods: {
- hasClass: function (elem, cls) {
- cls = cls || '';
- if (cls.replace(/\s/g, '').length == 0) return false; //当cls没有参数时,返回false
- return new RegExp(' ' + cls + ' ').test(' ' + elem.className + ' ');
- },
- addClass(ele, cls) {
- if (!this.hasClass(ele, cls)) {
- ele.className = ele.className == '' ? cls : ele.className + ' ' + cls;
- }
- },
- removeClass(ele, cls) {
- if (this.hasClass(ele, cls)) {
- var newClass = ' ' + ele.className.replace(/[\t\r\n]/g, '') + ' ';
- while (newClass.indexOf(' ' + cls + ' ') >= 0) {
- newClass = newClass.replace(' ' + cls + ' ', ' ');
- }
- ele.className = newClass.replace(/^\s+|\s+$/g, '');
- }
- },
- removeLocal(){
- Cookies.remove('9ca8e8d13b4369cddfdab26c63d69ce2');
- Cookies.remove('f63dcfe3c89a14e80c9cdf60b4b94f4b');
- localStorage.clear();
- sessionStorage.clear();
- }
- },
- beforeCreate: function () {
- },
- created: function () {
- },
- mounted: function () {
- //设置主体
- var $theme = Cookies.get('theme');
- this.themeCommandEvent($theme ? $theme : 'index');
- }
- };
- var $TableDialog = {
- data: function () {
- return {
- tableDialog:{
- model: 'dialog'
- }
- }
- },
- methods: {
- formatTableDialogColumn: function (row, column, value) {},
- tablesDialogCellMoveEvent: function (row, column, cell, event) {
- var that = this;
- if (column.filterPlacement === 'false' || !that[that.tableDialog.models].options.cell) {
- return false;
- }
- event.stopPropagation();
- if ($(cell).find('.cell').hasClass('Va-table-move')) {
- return false;
- } else {
- $('.cell').removeClass('Va-table-move');
- $('.Va-table-move-close').remove();
- if (!row[column.property]) {
- return false;
- }
- $(cell).find('.cell').append('<i class="el-icon-close Va-table-move-close" onclick="removeTableMoveEvent(this)"></i>');
- $(cell).find('.cell').addClass('Va-table-move');
- if (($(cell).width() - 20) > $(cell).parent().find('.Va-table-move').width()) {
- $('.cell').removeClass('Va-table-move');
- $('.Va-table-move-close').remove();
- }
- }
- },
- tablesDialogPaginationSizeChange: function (size) {
- var that = this;
- that[that.tableDialog.models].pagination.size = size;
- that.tablesDialogGetTableList();
- },
- tablesDialogPaginationCurrentChange: function (page) {
- var that = this;
- that[that.tableDialog.models].pagination.page = page;
- that.$refs.formContainerTables.clearSelection();
- that.tablesDialogGetTableList();
- },
- /*排序发生改变时触发*/
- tablesDialogPaginationSortChange: function (rows) {
- var that = this;
- that.$set(that[that.tableDialog.models], 'orderBy', rows.orderBy);
- if (typeof rows.column.sortBy === 'undefined') {
- that.$set(that[that.tableDialog.models], 'prop', rows.prop);
- } else {
- that.$set(that[that.tableDialog.models], 'prop', rows.column.sortBy);
- }
- that.tablesDialogGetTableList();
- },
- /*多选发生改变时触发*/
- tablesDialogSelectChange: function (rows) {
- var that = this;
- that.selects = rows;
- that.$set(that[that.tableDialog.models], 'selects', rows);
- },
- tablesDialogClearSelect: function () {
- var that = this;
- that.$nextTick(function () {
- that.$refs.formContainerTables.clearSelection();
- })
- },
- getTablesDialogSelected: function () {
- var that = this;
- if (!that[that.tableDialog.models].selects.length || that[that.tableDialog.models].selects.length <= 0) {
- return [];
- }
- var selects_ids = [];
- that[that.tableDialog.models].selects.forEach(function (item, index) {
- selects_ids.push(item.id);
- });
- if (!selects_ids || selects_ids.length <= 0) {
- return [];
- }
- return selects_ids;
- },
- tablesDialogGetTableList: function (model) {
- var that = this;
- if (model && typeof model == 'string') that.tableDialog.models = model;
- if (!that.tablesDialogGetTableListFront()) {
- return false;
- }
- if (!that[that.tableDialog.models].url) {
- that[that.tableDialog.models].url = window.location.href;
- }
- that[that.tableDialog.models].options.loading = true;
- that[that.tableDialog.models].search.page = that[that.tableDialog.models].pagination.page;
- that[that.tableDialog.models].search.size = that[that.tableDialog.models].pagination.size;
- that[that.tableDialog.models].search.orderBy = that[that.tableDialog.models].orderBy;
- that[that.tableDialog.models].search.prop = that[that.tableDialog.models].prop;
- $Request.postJson(that[that.tableDialog.models].url, that[that.tableDialog.models].search, function (res) {
- if (that.tablesDialogGetTablesListsAfter(res)) {
- if ((typeof (res) === 'undefined')) {
- return false;
- }
- if ((typeof (res.result) === 'undefined')) {
- return false;
- }
- that[that.tableDialog.models].options.loading = false;
- that[that.tableDialog.models].data = res.result.rows ? res.result.rows : res.result.data;
- that[that.tableDialog.models].pagination.total = res.result.total;
- }
- that.tablesDialogGetTablesListsFinish(res);
- })
- },
- tablesDialogGetTableListFront: function () {
- return true;
- },
- tablesDialogGetTablesListsAfter: function () {
- return true;
- },
- tablesDialogGetTablesListsFinish: function () {
- return true;
- },
- tablesDialogRowsRemove: function (model, rows, params) {
- var that = this;
- if (model && typeof model == 'string') that.tableDialog.models = model;
- if (!that[that.tableDialog.models].remove.url) {
- return false;
- }
- var requestData = {};
- if (params) {
- requestData = params;
- }
- that[that.tableDialog.models].remove.msg = that[that.tableDialog.models].remove.msg ? that[that.tableDialog.models].remove.msg : '确认删除当前数据吗?';
- that[that.tableDialog.models].remove.field = that[that.tableDialog.models].remove.field ? that[that.tableDialog.models].remove.field : 'id';
- if (!rows[that.tables.remove.field]) {
- return false;
- }
- requestData[that[that.tableDialog.models].remove.field] = rows[that[that.tableDialog.models].remove.field];
- that.$confirm(that[that.tableDialog.models].remove.msg, '操作提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true,
- dangerouslyUseHTMLString: true,
- lockScroll: false,
- }).then(function () {
- $Request.postJson(that[that.tableDialog.models].remove.url, requestData, function (res) {
- if (res.code === 200) {
- that.$message({
- message: res.message, type: 'success', duration: 2400, onClose: function () {
- }
- });
- that.tablesDialogGetTableList();
- } else {
- that.$message({
- message: res.message, type: 'error', duration: 2400, onClose: function () {
- }
- });
- }
- })
- }).catch(function () {
- });
- },
- tablesDialogRowsStatus: function (model, rows, params) {
- var that = this;
- if (model && typeof model == 'string') that.tableDialog.models = model;
- if (!that[that.tableDialog.models].status.url || !that[that.tableDialog.models].status.field) {
- return false;
- }
- if (!rows[that[that.tableDialog.models].status.field] && rows[that[that.tableDialog.models].status.field] !== 0) {
- return false;
- }
- if (!that[that.tableDialog.models].status.maps[rows[that[that.tableDialog.models].status.field]]) {
- return false;
- }
- that[that.tableDialog.models].status.msg = '确认' + that[that.tableDialog.models].status.maps[rows[that[that.tableDialog.models].status.field]] + '当前数据吗?';
- var requestData = {};
- if (params) {
- requestData = params;
- }
- requestData[that[that.tableDialog.models].status.field] = rows[that[that.tableDialog.models].status.field];
- that.$confirm(that[that.tableDialog.models].status.msg, '操作提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: false,
- dangerouslyUseHTMLString: true,
- lockScroll: false,
- }).then(function () {
- $Request.postJson(that[that.tableDialog.models].status.url, requestData, function (res) {
- if (res.code === 200) {
- that.$message({
- message: res.message, type: 'success', duration: 2400, onClose: function () {
- }
- });
- that.tablesDialogGetTableList();
- } else {
- that.$message({
- message: res.message, type: 'error', duration: 2400, onClose: function () {
- }
- });
- }
- })
- }).catch(function () {
- });
- },
- tablesDialogRowsSort: function (model, rows) {
- var that = this;
- if (model && typeof model == 'string') that.tableDialog.models = model;
- if (!that[that.tableDialog.models].sort.url) {
- return false;
- }
- var requestData = {};
- that[that.tableDialog.models].sort.field = that[that.tableDialog.models].sort.field ? that[that.tableDialog.models].sort.field : 'id';
- that[that.tableDialog.models].sort.item = that[that.tableDialog.models].sort.item ? that[that.tableDialog.models].sort.item : 'sort';
- if (!rows[that[that.tableDialog.models].sort.field]) {
- return false;
- }
- if (!rows[that[that.tableDialog.models].sort.item]) {
- return false;
- }
- requestData[that[that.tableDialog.models].sort.field] = rows[that[that.tableDialog.models].sort.field];
- requestData[that[that.tableDialog.models].sort.item] = rows[that[that.tableDialog.models].sort.item];
- $Request.postJson(that[that.tableDialog.models].sort.url, requestData, function (res) {
- if (res.code === 200) {
- that.$message({message: res.message, type: 'success', duration: 2100});
- that.tablesDialogGetTableList();
- } else {
- that.$message({message: res.message, type: 'error', duration: 2100});
- }
- })
- },
- tablesDialogRowsType: function (rows) {
- var that = this;
- if (model && typeof model == 'string') that.tableDialog.models = model;
- if (!that[that.tableDialog.models].type.url) {
- return false;
- }
- var requestData = {};
- that[that.tableDialog.models].type.field = that[that.tableDialog.models].type.field ? that[that.tableDialog.models].type.field : 'id';
- that[that.tableDialog.models].type.item = that[that.tableDialog.models].type.item ? that[that.tableDialog.models].type.item : 'type';
- if (!rows[that[that.tableDialog.models].type.field]) {
- return false;
- }
- if (!rows[that[that.tableDialog.models].type.item]) {
- return false;
- }
- requestData[that[that.tableDialog.models].type.field] = rows[that[that.tableDialog.models].type.field];
- requestData[that[that.tableDialog.models].type.item] = rows[that[that.tableDialog.models].type.item];
- $Request.postJson(that[that.tableDialog.models].type.url, requestData, function (res) {
- if (res.code === 200) {
- that.$message({message: res.message, type: 'success', duration: 2100});
- that.tablesDialogGetTableList();
- } else {
- that.$message({message: res.message, type: 'error', duration: 2100});
- }
- })
- },
- tablesDialogSearchEvent: function (model) {
- var that = this;
- if (model && typeof model == 'string') that.tableDialog.models = model;
- that[that.tableDialog.models].pagination.page = 1;
- that.tablesDialogGetTableList();
- },
- tablesDialogResetsEvent: function () {},
- },
- mounted: function () {},
- beforeCreate: function () {},
- created: function () {}
- };
- window.$Utils = {
- formatDate: function (fmt, time) {
- time = time ? time * 1000 : (new Date()).getTime();
- var date = new Date(parseInt(time));
- var o = {
- "M+": date.getMonth() + 1,
- "d+": date.getDate(),
- "h+": date.getHours(),
- "m+": date.getMinutes(),
- "s+": date.getSeconds(),
- "q+": Math.floor((date.getMonth() + 3) / 3),
- "S": date.getMilliseconds()
- };
- if (/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt))
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- },
- /*加密数据*/
- encrypt: function (str, KEY, IV) {
- if (!str) return false;
- KEY = KEY ? KEY : $Public.request.key;
- IV = IV ? IV : $Public.request.iv;
- var key = CryptoJS.enc.Utf8.parse(KEY);
- var iv = CryptoJS.enc.Utf8.parse(IV);
- var encrypted = CryptoJS.AES.encrypt(str, key, {
- iv: iv,
- mode: CryptoJS.mode.CBC,
- padding: CryptoJS.pad.Pkcs7
- });
- return encrypted.toString();
- },
- /*解密数据*/
- decrypt: function (str, KEY, IV) {
- if (!str) return false;
- KEY = KEY ? KEY : $Public.request.key;
- IV = IV ? IV : $Public.request.iv;
- var key = CryptoJS.enc.Utf8.parse(KEY);
- var iv = CryptoJS.enc.Utf8.parse(IV);
- var decrypted = CryptoJS.AES.decrypt(str, key, {
- iv: iv,
- padding: CryptoJS.pad.Pkcs7
- });
- return decrypted.toString(CryptoJS.enc.Utf8);
- },
- getUrlParams: function (name)
- {
- return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null
- }
- };
- window.$Public = {
- request: {
- key: '5B9ADC14C705F1B041DDC2D9B16A2D94',
- iv: '33092152342590AD',
- encrypt: true,
- debug: true,
- }
- };
- window.$Validator = {
- json: function (str) {
- if (typeof str == 'string') {
- try {
- var obj = JSON.parse(str);
- if (typeof obj == 'object' && obj) {
- return true;
- } else {
- return false;
- }
- } catch (e) {
- return false;
- }
- } else {
- return false;
- }
- },
- typeOf: function (str, type) {
- if ((typeof str) === type) {
- return true;
- } else {
- return false;
- }
- }
- };
- window.$Gallery = {
- GalleryDialogOpen: function (options) {
- $App.GalleryParams.options = Object.assign({
- max: 10,//上传条数
- size: 20, //上传大小
- type: '1',//文件类型;1:图片;2:视频;3:音频;4:文件;5:图标;20:网页
- tabs: false,//是否使用多标签菜单
- suffix: '', //上传类型
- multiple: true, //多选
- file_name: '',
- callback: function (result) {
- },
- }, options);
- $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
- $Gallery.GalleryUploadInit();
- $App.GalleryParams.operation.dialog = true;
- },
- GalleryDialogPages: function (options) {
- $App.GalleryParams.selected = [];
- $App.GalleryParams.search.keyword = '';
- $App.GalleryParams.options = Object.assign({
- max: 1,//上传条数
- size: 20, //上传大小
- type: '1',//文件类型;1:图片;2:视频;3:音频;4:文件;5:图标;20:网页
- tabs: false,//是否使用多标签菜单
- suffix: '', //上传类型
- multiple: false, //多谢
- callback: function (result) {
- },
- }, options);
- $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
- $Gallery.GalleryUploadInit();
- },
- GalleryUploadToken: function (callback, type) {
- type = type ? type : $App.GalleryParams.options.type;
- $Request.postJson('/admin/framework/common/uploadToken', {type: type}, function (res) {
- if (res.code === 200) {
- if ($Validator.typeOf(callback, 'function')) {
- callback(res.result);
- return true;
- }
- if (res.result.driver === "qiniu") {
- $App.GalleryParams.driver = res.result.driver;
- $App.GalleryParams.action = res.result.action;
- $App.GalleryParams.domain = res.result.domain;
- $App.GalleryParams.postData.token = res.result.token;
- if (res.result.key) {
- $App.GalleryParams.postData.key = res.result.key;
- }
- if (res.result.save_path) {
- // TODO
- }
- }
- if (res.result.driver === "oss") {
- $App.GalleryParams.driver = res.result.driver;
- $App.GalleryParams.action = res.result.ssl + '://' + res.result.domain;
- $App.GalleryParams.domain = res.result.ssl + '://' + res.result.domain;
- $App.GalleryParams.postData.OSSAccessKeyId = res.result.accessKeyId;
- $App.GalleryParams.postData.policy = res.result.policy;
- $App.GalleryParams.postData.Signature = res.result.signature;
- // $App.GalleryParams.postData['x-oss-security-token'] = res.result.stsToken;
- $App.GalleryParams.postData.bucket = res.result.bucket;
- $App.GalleryParams.postData.region = res.result.region;
- $App.GalleryParams.postData.success_action_status = 200;
- if (res.result.save_path) {
- // TODO
- }
- }
- if (res.result.driver === "cos"){
- // console.log(res.result)
- $App.GalleryParams.driver = res.result.driver;
- $App.GalleryParams.action = res.result.ssl + '://' + res.result.domain;
- $App.GalleryParams.domain = res.result.ssl + '://' + res.result.domain;
- $App.GalleryParams.postData.policy = res.result.policy;
- $App.GalleryParams.postData.success_action_status = 200;
- $App.GalleryParams.postData['q-sign-algorithm'] = res.result.q_sign_algorithm;
- $App.GalleryParams.postData['q-ak'] = res.result.q_ak;
- $App.GalleryParams.postData['q-key-time'] = res.result.q_key_time;
- $App.GalleryParams.postData['q-signature'] = res.result.q_signature;
- if (res.result.key) {
- $App.GalleryParams.postData.key = res.result.key;
- }
- if (res.result.save_path) {
- // TODO
- }
- }
- if (res.result.driver === 'local') {
- $App.GalleryParams.action = '/admin/framework/common/gallery/upload';
- }
- } else {
- callback(false);
- }
- })
- },
- GalleryUploadInit: function () {
- var that = this;
- $App.GalleryParams.selected = [];
- $App.GalleryParams.search.keyword = '';
- $App.GalleryParams.search.page = 1;
- $App.GalleryParams.search.size = 12;
- $App.GalleryParams.options.upload = true;
- $App.GalleryParams.options.suffix = '';
- $App.GalleryParams.options.addPage = '';
- $App.GalleryParams.options.addIcon = '';
- switch (parseInt($App.GalleryParams.options.type)) {
- case 1://图片
- $App.GalleryParams.options.suffix = $App.GalleryParams.options.suffix ?
- $App.GalleryParams.options.suffix : 'bmp,gif,jpg,jpeg,png';
- break;
- case 2://视频
- $App.GalleryParams.options.suffix = $App.GalleryParams.options.suffix ?
- $App.GalleryParams.options.suffix : 'mp3,wma,avi,rm,rmvb,flv,mpg,mov,mk,mp4';
- break;
- case 3://文件
- $App.GalleryParams.options.suffix = $App.GalleryParams.options.suffix ?
- $App.GalleryParams.options.suffix : 'doc,docx,xls,xlsx,xlsm,xlt,csv';
- break;
- case 4://网页
- $App.GalleryParams.options.suffix = '';
- $App.GalleryParams.options.upload = false;
- $App.GalleryParams.options.addPage = true;
- $App.GalleryParams.options.addIcon = false;
- $App.GalleryParams.search.size = 7;
- break;
- case 5://音频
- break;
- case 20:
- $App.GalleryParams.options.suffix = '';
- $App.GalleryParams.options.upload = false;
- $App.GalleryParams.options.addIcon = true;
- $App.GalleryParams.options.addPage = false;
- break;
- default:
- }
- $App.GalleryParams.search.type = $App.GalleryParams.options.type;
- $App.GalleryParams.imagesItems = [];
- $App.GalleryParams.operation.imageTotal = 0;
- $App.GalleryParams.search.group_id = 0;
- $Gallery.GalleryUploadParams();
- $Gallery.GalleryRequestLists();
- },
- GalleryUploadParams: function () {
- $App.GalleryParams.postData = {
- type: $App.GalleryParams.options.type,
- size: $App.GalleryParams.options.size,
- suffix: $App.GalleryParams.options.suffix,
- max: $App.GalleryParams.options.max,
- group_id: $App.GalleryParams.search.group_id,
- dir: '',
- file_name: $App.GalleryParams.options.file_name
- };
- },
- GalleryUploadProgress: function (event, file, fileList) {
- if ($App.GalleryParams.operation.error === false) {
- $App.GalleryParams.operation.loading = true;
- $App.GalleryParams.operation.loadingMsg = '文件正在上传 (' + parseFloat((event.percent).toFixed(2)) + '%), 请稍后...';
- }
- },
- GalleryUploadSuccess: function (response, file, fileList) {
- let params = {};
- // console.log('size:',$App.GalleryParams.size)
- switch ($App.GalleryParams.driver) {
- case 'qiniu':
- response.group_id = $App.GalleryParams.search.group_id;
- response.type = $App.GalleryParams.search.type;
- response.code = 200;
- response.url = $App.GalleryParams.domain + '/' + response.key;
- response.file_name = $App.GalleryParams.options.file_name;
- response.size = $App.GalleryParams.size;
- if (response.code === 200) {
- $Request.postJson('/admin/framework/common/gallery/insert', response, function (res) {
- if (res.code !== 200) {
- $App.$Message(res.message, 'warning');
- return true;
- }
- $App.$Message('文件上传成功!');
- $App.GalleryParams.operation.loadingMsg = '';
- $App.GalleryParams.operation.loading = false;
- $App.$refs.GalleryDialogUpload.clearFiles();
- $App.GalleryParams.search.page = 1;
- $Gallery.GalleryRequestLists();
- $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
- });
- }
- break;
- case'oss':
- case'cos':
- params.group_id = $App.GalleryParams.search.group_id;
- params.type = $App.GalleryParams.search.type;
- params.code = 200;
- params.url = $App.GalleryParams.domain + '/' + $App.GalleryParams.postData.key;
- params.file_name = $App.GalleryParams.options.file_name;
- params.size = $App.GalleryParams.size;
- params.driver = $App.GalleryParams.driver;
- params.key = $App.GalleryParams.postData.key;
- if (params.code === 200){
- $Request.postJson('/admin/framework/common/gallery/insert', params, function (res) {
- if (res.code !== 200) {
- $App.$Message(res.message, 'warning');
- return true;
- }
- $App.$Message('文件上传成功!');
- $App.GalleryParams.operation.loadingMsg = '';
- $App.GalleryParams.operation.loading = false;
- $App.$refs.GalleryDialogUpload.clearFiles();
- $App.GalleryParams.search.page = 1;
- $Gallery.GalleryRequestLists();
- $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
- });
- }
- break;
- // case'cos':
- // params.group_id = $App.GalleryParams.search.group_id;
- // params.type = $App.GalleryParams.search.type;
- // params.code = 200;
- // params.url = $App.GalleryParams.domain + '/' + $App.GalleryParams.postData.key;
- // params.file_name = $App.GalleryParams.options.file_name;
- // params.size = $App.GalleryParams.postData.size;
- // params.driver = $App.GalleryParams.driver;
- // params.key = $App.GalleryParams.postData.key;
- // if (params.code === 200){
- // $Request.postJson('/admin/framework/common/gallery/insert', params, function (res) {
- // if (res.code !== 200) {
- // $App.$Message(res.message, 'warning');
- // return true;
- // }
- // $App.$Message('文件上传成功!');
- // $App.GalleryParams.operation.loadingMsg = '';
- // $App.GalleryParams.operation.loading = false;
- // $App.$refs.GalleryDialogUpload.clearFiles();
- // $App.GalleryParams.search.page = 1;
- // $Gallery.GalleryRequestLists();
- // $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
- // });
- // }
- // break;
- default:
- $App.GalleryParams.operation.loadingMsg = '';
- $App.GalleryParams.operation.loading = false;
- $App.$refs.GalleryDialogUpload.clearFiles();
- if (response.code !== 200) {
- $App.$Message(response.message, 'warning');
- return true;
- } else {
- $App.$Message('文件上传成功!');
- $App.GalleryParams.search.page = 1;
- $Gallery.GalleryRequestLists();
- break;
- }
- }
- },
- GalleryUploadError: function () {
- var that = this;
- $App.$Message('文件上传失败,请重试!', 'warning');
- $App.GalleryParams.operation.loadingMsg = '';
- $App.GalleryParams.operation.loading = false;
- // that.GalleryUploadParams();
- // $App.$refs.GalleryDialogUpload.clearFiles();
- },
- GalleryUploadBefore: function (file) {
- $App.GalleryParams.size = file.size;
- return new Promise(async (resolve, reject) => {
- /*验证图片大小*/
- if ($App.GalleryParams.options.size) {
- if ((file.size / 1048576) > $App.GalleryParams.options.size) {
- $App.$Message('请上传' + $App.GalleryParams.options.size + 'M以内的文件', 'warning');
- $Gallery.GalleryCloseOperationLoading();
- return reject();
- }
- }
- /*验证文件后缀*/
- if ($App.GalleryParams.options.suffix) {
- var args = ((file.name).split('.'));
- if (args[args.length - 1]) {
- var args_suffix = (args[args.length - 1]).toLowerCase();
- var suffix = ($App.GalleryParams.options.suffix).split(',');
- if ($.inArray(args_suffix, suffix) < 0) {
- $App.$Message('请上传' + $App.GalleryParams.options.suffix + '类型的文件', 'warning');
- $Gallery.GalleryCloseOperationLoading();
- return reject();
- }
- }
- }
- $App.GalleryParams.options.file_name = file.name;
- $App.GalleryParams.postData.file_name = file.name;
- $App.GalleryParams.operation.loadingMsg = '文件正在上传 (0%), 请稍后...';
- $App.GalleryParams.operation.loading = true;
- await $Gallery.GalleryGetFileKey().catch(err => {
- $App.$Message('操作失败!');
- $Gallery.GalleryCloseOperationLoading();
- return reject();
- });
- switch ($App.GalleryParams.driver) {
- case 'qiniu':
- break;
- case 'oss':
- // console.log('oss',$App.GalleryParams.postData);
- break;
- default:
- break;
- }
- $App.GalleryParams.operation.error = false
- return resolve();
- })
- },
- GalleryCloseOperationLoading: function () {
- setTimeout(function () {
- $App.$refs.GalleryDialogUpload.clearFiles();
- $App.GalleryParams.operation.loadingMsg = '';
- $App.GalleryParams.operation.loading = false;
- $App.GalleryParams.operation.error = true;
- $App.GalleryParams.search.page = 1;
- $Gallery.GalleryRequestLists();
- $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
- }, 1000)
- },
- // 获取文件地址
- GalleryGetFileKey() {
- return new Promise(function (resolve, reject) {
- switch ($App.GalleryParams.driver) {
- case 'qiniu':
- case 'oss':
- case 'cos':
- $Request.postJson('/admin/framework/common/getFileKey', $App.GalleryParams.postData, function (res) {
- if (res.code !== 200) {
- $App.$Message(res.message, 'warning');
- reject()
- return false;
- }
- $App.GalleryParams.postData.key = res.result.key;
- resolve()
- });
- break;
- default:
- resolve()
- return true;
- }
- })
- },
- GalleryUploadDialogClose: function () {
- $App.GalleryParams.selected = [];
- $App.GalleryParams.operation.loadingMsg = '';
- $App.GalleryParams.operation.loading = false;
- $App.GalleryParams.operation.dialog = false;
- },
- GalleryUploadDialogSubmit: function () {
- var that = this;
- var selected = $App.GalleryParams.selected;
- if (selected.length <= 0) {
- $App.$Message('请选择文件!', 'warning');
- return false;
- }
- if (!$App.GalleryParams.options.multiple) {
- selected = selected[0];
- }
- $App.GalleryParams.options.callback(selected);
- $App.GalleryParams.selected = [];
- $App.GalleryParams.operation.loading = false;
- $App.GalleryParams.operation.dialog = false;
- },
- GalleryGroupChangeEvent: function (item) {
- $.each($App.GalleryParams.groupItems, function (key, val) {
- val.active = false;
- });
- item.active = true;
- $App.GalleryParams.imagesItems = [];
- $App.GalleryParams.search.page = 1;
- $App.GalleryParams.operation.imageTotal = 0;
- $App.GalleryParams.search.group_id = item.id;
- $Gallery.GalleryRequestLists();
- },
- GalleryGroupRemoveEvent: function (index, item) {
- $App.$Confirm('确认删除当前分组吗?', function (res) {
- $Request.postJson('/admin/framework/common/gallery/groupRemove', {
- id: item.id
- }, function (res) {
- if (res.code === 200) {
- $App.$message({message: res.message, type: 'success', duration: 2400});
- $Gallery.GalleryRequestLists();
- } else {
- $App.$message({message: res.message, type: 'error', duration: 2400});
- }
- });
- });
- },
- GalleryRemotePictureEvent: function () {
- var that = this;
- $App.GalleryParams.operation.loading = true;
- $App.$prompt('', '图片地址', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputValue: '',
- lockScroll: false,
- inputPlaceholder: '请输入图片地址',
- inputValidator: function (e) {
- return $Validator.image(e);
- },
- inputErrorMessage: '请输入图片地址',
- }).then(function (result) {
- if (!result.value) {
- $App.$message({type: 'error', message: '请输入图片地址!'});
- return false;
- }
- $App.GalleryParams.postData._value = result.value;
- $Request.postJson('/admin/framework/common/gallery/remote', $App.GalleryParams.postData, function (res) {
- if (res.code === 200) {
- $App.$message({message: '图片保存成功!', type: 'success', duration: 2400});
- $Gallery.GalleryRequestLists();
- that.GalleryUploadParams();
- } else {
- $App.$message({message: res.message, type: 'error', duration: 2400});
- }
- $App.GalleryParams.operation.loading = false;
- });
- }).catch(function () {
- $App.GalleryParams.operation.loading = false;
- });
- },
- GalleryAddPageEvent: function (item, is_update) {
- var params = {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- lockScroll: false,
- inputPlaceholder: '网页地址规则:网页名称,网页地址',
- inputErrorMessage: '请输入图片地址',
- };
- if (is_update && item.id) {
- params.inputValue = item.original + ',' + item.url;
- }
- $App.$prompt('', '网页地址', params).then(function (result) {
- if (!result.value) {
- $App.$message({type: 'error', message: '请输入网页地址!'});
- return false;
- }
- $App.GalleryParams.postData._value = result.value;
- if (is_update && item.id) {
- $App.GalleryParams.postData._id = item.id;
- $App.GalleryParams.postData._is_update = 1;
- }
- $App.GalleryParams.postData._value = result.value;
- $Request.postJson('/admin/framework/common/gallery/pages', $App.GalleryParams.postData, function (res) {
- if (res.code === 200) {
- $App.$message({message: res.message, type: 'success', duration: 2400});
- $Gallery.GalleryRequestLists();
- } else {
- $App.$message({message: res.message, type: 'error', duration: 2400});
- }
- });
- }).catch(function () {
- });
- },
- GalleryItemUpdateOriginalEvent: function (item) {
- $App.$prompt('', '修改文件名', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputPlaceholder: '请输入文件名',
- inputValue: item.original,
- lockScroll: false,
- closeOnClickModal: false,
- }).then(function (params) {
- if (!params.value) {
- $App.$message({message: '请输入文件名!', type: 'error', duration: 2400});
- } else {
- $Request.postJson('/admin/framework/common/gallery/original', {
- id: item.id, name: params.value
- }, function (res) {
- if (res.code === 200) {
- $App.$message({message: '文件名修改成功!', type: 'success', duration: 2400});
- $Gallery.GalleryRequestLists();
- } else {
- $App.$message({message: '文件名修改失败,请稍后再试!', type: 'error', duration: 2400});
- }
- })
- }
- }).catch(function () {
- });
- },
- GalleryItemRemoveEvent: function (item) {
- $App.$confirm('确认删除当前数据吗?删除后不可恢复!', '操作提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- dangerouslyUseHTMLString: true,
- lockScroll: false,
- center: true
- }).then(function () {
- $Request.postJson('/admin/framework/common/gallery/remove', {
- id: item.id
- }, function (res) {
- if (res.code === 200) {
- $App.$message({message: '文件删除成功!', type: 'success', duration: 2400});
- $Gallery.GalleryRequestLists();
- } else {
- $App.$message({message: '文件删除失败,请稍后再试!', type: 'error', duration: 2400});
- }
- })
- }).catch(function () {
- });
- },
- GalleryTabEvent: function () {
- $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
- $Gallery.GalleryUploadInit();
- },
- GalleryGroupUpdateEvent: function (index, item) {
- $App.$prompt('', '修改分组', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputValue: item.name,
- lockScroll: false,
- inputPlaceholder: '请输入分组名称',
- inputValidator: function (e) {
- return (e && e.length < 10) ? true : false;
- },
- inputErrorMessage: '请输入分组名称',
- }).then(function (result) {
- if (!result.value) {
- $App.$message({type: 'error', message: '请输入分组名称!'});
- return false;
- }
- $Request.postJson('/admin/framework/common/gallery/groupUpdate', {
- id: item.id,
- name: result.value
- }, function (res) {
- if (res.code === 200) {
- $App.$message({message: res.message, type: 'success', duration: 2400});
- $Gallery.GalleryRequestLists();
- } else {
- $App.$message({message: res.message, type: 'error', duration: 2400});
- }
- });
- }).catch(function () {
- });
- },
- GalleryGroupInsertEvent: function () {
- if ($App.GalleryParams.groupItems.length > 6) {
- $App.$message({message: '分组最多可添加5个!', type: 'error', duration: 2400});
- return false;
- }
- $App.$prompt('', '添加分组', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- lockScroll: false,
- inputPlaceholder: '请输入分组名称,最长10个字符',
- inputValidator: function (e) {
- return (e && e.length < 10) ? true : false;
- },
- inputErrorMessage: '请输入分组名称',
- }).then(function (result) {
- if (!result.value) {
- $App.$message({type: 'error', message: '请输入分组名称!'});
- return false;
- }
- $Request.postJson('/admin/framework/common/gallery/groupCreate', {
- name: result.value,
- type: $App.GalleryParams.options.type
- }, function (res) {
- if (res.code === 200) {
- $App.$message({message: res.message, type: 'success', duration: 2400});
- $Gallery.GalleryRequestLists();
- } else {
- $App.$message({message: res.message, type: 'error', duration: 2400});
- }
- });
- }).catch(function () {
- });
- },
- GalleryGroupManageEvent: function () {
- $App.GalleryParams.operation.groupManage = !$App.GalleryParams.operation.groupManage;
- },
- GalleryImagesPageChange: function (page) {
- var that = this;
- $App.GalleryParams.search.page = page;
- $Gallery.GalleryRequestLists();
- },
- GalleryItemCheckboxEvent: function (item) {
- var that = this;
- // console.log(11111,item);
- if (item.active === 0 || item.active === false) {
- /*多选*/
- if ($App.GalleryParams.options.max > 1) {
- if ($App.GalleryParams.selected.length >= $App.GalleryParams.options.max) {
- $App.$message({
- message: '最多可选择' + $App.GalleryParams.options.max + '项!',
- type: 'warning'
- });
- return true;
- } else {
- item.active = true;
- $App.GalleryParams.selected.push(item);
- }
- } else {
- if ($App.GalleryParams.selected.length > 0) {
- $App.GalleryParams.selected.forEach(function (selected_item) {
- $App.GalleryParams.imagesItems.forEach(function (rows, index) {
- if (selected_item.id === rows.id) {
- rows.active = false;
- }
- });
- });
- }
- item.active = true;
- $App.GalleryParams.selected = [];
- $App.GalleryParams.selected[0] = item;
- }
- } else {
- $Gallery.GalleryItemActiveInEvent(item);
- }
- },
- GalleryItemActiveInEvent: function (item) {
- /*取消选中*/
- if ($App.GalleryParams.options.max > 1) {
- if ($App.GalleryParams.selected.length > 0) {
- $App.GalleryParams.selected.forEach(function (rows, index) {
- if (rows.id === item.id) {
- $App.GalleryParams.selected.splice(index, 1);
- item.active = false;
- return true;
- }
- });
- } else {
- item.active = false;
- $App.GalleryParams.selected = [];
- return true;
- }
- } else {
- item.active = false;
- $App.GalleryParams.selected = [];
- return true;
- }
- },
- GalleryItemDropdownEvent: function (e, item) {
- var that = this;
- if (e.target.dataset.command === 'edit') {
- that.GalleryItemUpdateOriginalEvent(item);
- } else {
- that.GalleryItemRemoveEvent(item);
- }
- },
- GalleryRequestLists: function () {
- $App.GalleryParams.operation.loading = true;
- $App.GalleryParams.operation.groupManage = false;
- $Gallery.GalleryUploadParams();
- $Gallery.GalleryGroupRequestLists();
- $Request.postJson('/admin/framework/common/gallery/iframe', $App.GalleryParams.search, function (res) {
- if (res.code === 200) {
- $App.GalleryParams.imagesItems = res.result.data;
- $App.GalleryParams.operation.imageTotal = res.result.total;
- $App.GalleryParams.selected.forEach(function (selected_item) {
- $App.GalleryParams.imagesItems.forEach(function (item, index) {
- if (selected_item.id === item.id) {
- item.active = true;
- }
- });
- });
- }
- $App.GalleryParams.operation.loadingMsg = '';
- $App.GalleryParams.operation.loading = false;
- $App.layouts.dialogFormsHeight = {
- 'max-height': parseInt((document.documentElement.clientHeight * 0.75) - 120) + 'px'
- };
- // console.log($App.layouts.dialogFormsHeight)
- });
- },
- GalleryGroupRequestLists: function () {
- $App.GalleryParams.loading = true;
- $Request.postJson('/admin/framework/common/gallery/group', $App.GalleryParams.search, function (res) {
- if (res.code === 200) {
- $App.GalleryParams.groupItems = res.result;
- }
- });
- },
- };
- window.$Center = {
- CenterDialogOpen: function () {
- $App.CenterParams.loadingMsg = '正在加载数据,请稍后...';
- $App.CenterParams.loading = true;
- $App.CenterParams.dialog = true;
- $App.CenterParams.model = {name:'',account:'',password:''};
- $Request.postJson('/admin/framework/common/center/info', {}, function (res) {
- if(res.code === 200){
- $App.CenterParams.model = res.result;
- $App.CenterParams.loading = false;
- } else {
- $App.$message({message: res.message, type: 'error'});
- $App.CenterParams.loadingMsg = res.message;
- }
- })
- },
- CenterDialogClose: function () {
- $App.CenterParams.dialog = false;
- },
- CenterDialogSubmits: function (){
- $App.CenterParams.loadingMsg = '正在提交,请稍后...';
- $App.CenterParams.loading = true;
- var params = $App.CenterParams.model;
- $Request.postJson('/admin/framework/common/center/update', params, function (res) {
- if(res['code'] === 200) {
- $App.$Message(res['message'], function () {
- $App.CenterParams.loading = false;
- $App.CenterParams.dialog = false;
- location.reload();
- });
- } else {
- $App.$Message(res.message, 'error');
- }
- });
- },
- // 监测抽屉鼠标事件
- handleWrapperMousedown(e) {
- // 如果为true,则表示点击发生在遮罩层
- $App.CenterParams.dialogClassModel = !!e.target.classList.contains('el-dialog__wrapper')
- },
- handleWrapperMouseup(e) {
- if ((!!e.target.classList.contains('el-dialog__wrapper')) && $App.CenterParams.dialogClassModel) {
- $App.CenterParams.dialog = false;
- }
- },
- // 监测抽屉鼠标事件 End.
- };
- window.$Arrays = {
- /* arrayLookup(data,'id',1,'name');*/
- arrayLookup: function (data, key, value, targetKey) {
- if (!data) return '---';
- var data_length = data.length;
- var targetValue = "";
- for (var i = 0; i < data_length; i++) {
- if (!data[i][key]) {
- break;
- }
- if (data[i][key] == value) {
- targetValue = targetKey ? data[i][targetKey] : data[i];
- break;
- }
- }
- return targetValue ? targetValue : '---';
- }
- };
- // 自定义模板
- Vue.component('va-media', {
- props: {
- size: {type: Number, default: 20},
- file: {type: String, default: ''},
- width:{ type: String, default: '400px'},
- height:{ type: String, default: '240px'}
- },
- model: {
- prop: 'file',
- event: 'change'
- },
- template: '<div style="border: 1px dashed #2d8cf0;border-radius: 5px;cursor: pointer" :style="{\'width\':width,\'height\':height}" @click="pictureGalleryOpen">' +
- '<img src="/statics/v1/image/empty/data.png" style="width: 100%;height: 100%;object-fit: contain;" v-if="!file">' +
- '<video :src="file" :poster="file+\'?vframe/jpg/offset/2/w/130/h/140/\'" ' +
- 'controls="controls" width="100%" height="100%" autoplay v-if="file">' +
- '<source :src="file" type="video/mp4" /></video></div>',
- methods: {
- pictureGalleryOpen: function() {
- var that = this;
- $Gallery.GalleryDialogOpen({
- max: 1,
- size: that.size,
- multiple: false,
- type: 2,
- cat:true,
- callback: function(res) {
- that.$emit('change', res.url);
- }
- });
- }
- },
- mounted: function() {
- }
- });
- Vue.component('va-image', {
- props: {
- size: {type: Number, default: 20},
- src: {type: String, default: ''},
- key: {type: String, default: ''}
- },
- data: function () {
- return {
- imageUrl: '',
- imageUrlList: [],
- };
- },
- watch: {
- src(value) {
- if (!this.imageUrl) {
- this._init(value);
- }
- },
- },
- template: '<el-image class="tables-image" :src="imageUrl" fit="contain" lazy :size="size" :key="key" :preview-src-list="imageUrlList">' +
- '<div slot="error" class="image-slot"><i class="fa fa-picture-o"></i></div>' +
- '</el-image>',
- methods: {
- _init: function (value) {
- var that = this;
- if (!value) {
- that.imageUrl = '/statics/v1/image/common/empty.jpeg';
- return true;
- }
- if ($Validator.json(value)) {
- var fileItems = JSON.parse(value);
- if (fileItems.length && fileItems.length > 0) {
- $.each(fileItems, function (key, item) {
- that.imageUrlList.push(item.url);
- });
- that.imageUrl = that.imageUrlList[0];
- } else {
- that.imageUrl = fileItems.url;
- }
- } else {
- if (value.includes('base64')){
- that.imageUrlList = [value];
- }else {
- that.imageUrlList = value.split(",").filter(function (n) {
- return n
- });
- }
- if (that.imageUrlList.length < 1) {
- that.imageUrl = '/statics/v1/image/common/empty.jpeg';
- } else {
- that.imageUrl = that.imageUrlList[0];
- }
- }
- }
- },
- mounted: function () {
- this._init(this.src);
- }
- });
- Vue.component('va-forms-tips', {
- props: {},
- data: function () {
- return {};
- },
- template: '<span class="Va-help-block" data-7512a93d><i class="el-icon-info"></i> <slot></slot></span>',
- mounted: function () {
- }
- });
- Vue.component("va-picture", {
- props: {
- action: {
- type: String,
- default: '/admin/framework/common/pictureUploads'
- },
- size: {
- type: Number,
- default: 20
- },
- suffix: {
- type: String,
- default: 'png,bmp,jpeg,jpg,gif'
- },
- postData: {
- type: Object,
- default: {}
- },
- file: {
- type: String,
- default: ''
- },
- gallery: {
- type: Boolean,
- default: true
- },
- alt: {
- type: Boolean,
- default: false
- },
- name: {
- type: Boolean,
- default: false
- },
- disabled: {
- type: Boolean,
- default: false
- },
- onSuccess: {
- type: Function,
- default: function (res) {
- }
- },
- },
- data: function () {
- return {
- picture: {
- postHeaders: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- },
- uploadStatus: false,
- progress: 0,
- },
- fileItems: {
- url: '',
- alt: '',
- name: ''
- },
- _fileName: '', _fileSize: 0,
- galleryOptions: {},
- uploadOption: {driver: 'local', action: '', token: '', domain: ''},
- }
- },
- model: {
- prop: 'file',
- event: 'change'
- },
- computed: {
- fileItemsAlt() {
- return this.fileItems.alt;
- },
- fileItemsName() {
- return this.fileItems.name;
- }
- },
- watch: {
- file(value) {
- var that = this;
- if (that.alt || that.name) {
- if ($Validator.json(value)) {
- that.fileItems = JSON.parse(value);
- }
- } else {
- that.fileItems = {
- url: value,
- alt: '',
- name: ''
- };
- }
- },
- fileItemsAlt(value) {
- this.emitItemsEvent()
- },
- fileItemsName(value) {
- this.emitItemsEvent()
- },
- },
- template: '<div v-if="!fileItems.url" :disabled="disabled">\n' +
- ' <el-upload\n' +
- ' :action="action"\n' +
- ' :show-file-list="false"\n' +
- ' :headers="picture.postHeaders"\n' +
- ' :data="postData"\n' +
- ' :on-success="pictureUploadSuccess"\n' +
- ' :on-progress="pictureUploadProgress"\n' +
- ' :on-change="pictureChangeEvent"\n' +
- ' :on-error="pictureUploadError"\n' +
- ' ref="pictureUploadRef"\n' +
- ' :disabled="disabled"\n' +
- ' :before-upload="pictureUploadBefore" v-if="!gallery">\n' +
- ' <div class="va-component-picture" :disabled="disabled" v-if="!picture.uploadStatus">\n' +
- ' <div class="upload" :disabled="disabled">\n' +
- ' <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' <div class="va-component-picture" v-else :disabled="disabled">\n' +
- ' <el-progress type="circle" :percentage="picture.progress" style="margin-top: 5px;" ></el-progress>\n' +
- ' </div>\n' +
- ' </el-upload>\n' +
- ' <div v-else class="va-component-picture gallery" :disabled="disabled" @click="pictureGalleryOpen">\n' +
- ' <div class="upload" :disabled="disabled">\n' +
- ' <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
- ' </div>\n' +
- ' </div>\n' +
- '</div>\n' +
- '<div class="va-component-picture" v-else :disabled="disabled">\n' +
- ' <div class="show" :title="fileItems.alt">\n' +
- ' <el-image class="image" :src="fileItems.url"></el-image>\n' +
- ' <div class="shadow" v-if="!disabled">\n' +
- ' <i class="el-icon-delete icon" @click="pictureItemsRemove(fileItems)"></i>\n' +
- ' <el-dropdown class= "dropdown-picture-edit" placement="top" size="mini" style="position:absolute" @command="pictureItemsEdit(event)" v-if="alt || name">\n' +
- ' <span class="el-dropdown-link"><i class="el-icon-edit icon"></i> </span>\n' +
- ' <el-dropdown-menu slot="dropdown">\n' +
- ' <el-dropdown-item command="name" data-command="name" v-if="name">名称</el-dropdown-item>\n' +
- ' <el-dropdown-item command="alt" data-command="alt" v-if="alt">alt</el-dropdown-item>\n' +
- ' </el-dropdown-menu></el-dropdown>\n' +
- ' </div>\n' +
- ' </div>\n' +
- '</div>',
- methods: {
- pictureGalleryOpen: function () {
- var that = this;
- if (that.disabled) {
- return false;
- }
- $Gallery.GalleryDialogOpen({
- max: 1,
- size: that.size,
- suffix: that.suffix,
- multiple: false,
- type: '1',
- tabs: false,
- callback: function (res) {
- that.fileItems = {url: res.url, alt: res.original, name: res.original};
- that.emitItemsEvent();
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- }
- });
- },
- pictureItemsEdit: function (e, item, index) {
- var that = this;
- if (that.disabled) {
- return false;
- }
- var tips = (e.target.dataset.command === 'name') ? '名称' : 'alt';
- $App.$prompt('', '修改图片' + tips, {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputPlaceholder: '请输入图片' + tips,
- inputValue: that.fileItems[e.target.dataset.command],
- lockScroll: false,
- }).then(function (params) {
- if (!params.value) {
- $App.$message({
- message: '请输入图片' + tips,
- type: 'error',
- duration: 2400
- });
- } else {
- that.fileItems[e.target.dataset.command] = params.value;
- that.emitItemsEvent();
- }
- }).catch(function () {
- });
- return true;
- },
- pictureItemsRemove: function () {
- var that = this;
- that.fileItems = {
- url: '',
- alt: '',
- name: ''
- };
- that.emitItemsEvent();
- },
- pictureAltEvent: function (items, index) {
- var that = this;
- that.$refs[('picturePopoverAlt00101')].doClose();
- },
- pictureUploadProgress: function (event, file, fileList) {
- var that = this;
- that.picture.progress = parseFloat((event.percent).toFixed(2));
- },
- pictureUploadSuccess: function (response, file, fileList) {
- var that = this;
- var url;
- that.$refs.pictureUploadRef.clearFiles();
- if (response.code !== 200) {
- switch (that.uploadOption.driver) {
- case 'qiniu':
- response.url = that.uploadOption.domain + '/' + response.key;
- url = response.url;
- that.onSuccess(response);
- break;
- case'oss':
- default:
- url = response.result.url;
- $App.$Message(response.msg, 'warning');
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- break;
- }
- that.fileItems = {
- url: url,
- alt: that.fileItems.alt,
- name: that.fileItems.name,
- defaultImg: that.uploadOption.defaultImg
- };
- that.emitItemsEvent();
- $App.$Message('文件上传成功!', 'success');
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- return true;
- } else {
- $App.$Message(response.msg, 'warning');
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- }
- },
- pictureUploadError: function () {
- var that = this;
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- $App.$Message('文件上传失败,请重试!', 'warning');
- that.$refs.pictureUploadRef.clearFiles();
- return true;
- },
- pictureUploadBefore: function (file, e) {
- var that = this;
- /*验证图片大小*/
- if (that.size) {
- if ((file.size / 1048576) > that.size) {
- $App.$Message('请上传' + that.size + 'M以内的文件', 'warning');
- that.$refs.pictureUploadRef.clearFiles();
- return false;
- }
- }
- /*验证文件后缀*/
- if (that.suffix) {
- var args = ((file.name).split('.'));
- if (args[args.length - 1]) {
- var suffix = (that.suffix).split(',');
- if ($.inArray((args[args.length - 1]).toLowerCase(), suffix) < 0) {
- $App.$Message('请上传' + that.suffix + '类型的文件', 'warning');
- that.$refs.pictureUploadRef.clearFiles();
- return false;
- }
- }
- }
- that._fileSize = (file.size / 1048576).toFixed(2);
- that._fileName = file.name;
- that.picture.uploadStatus = true;
- that.picture.progress = 1;
- return true;
- },
- emitItemsEvent: function () {
- var that = this;
- if (that.alt || that.name) {
- that.$emit('change', JSON.stringify(that.fileItems));
- } else {
- that.$emit('change', that.fileItems.url);
- }
- that.UploadToken();
- },
- UploadToken: function () {
- var that = this;
- if (that.gallery) return true;
- $Gallery.GalleryUploadToken(function (res) {
- that.uploadOption.driver = res.result.driver;
- that.uploadOption.domain = res.result.domain;
- that.action = res.result.action;
- that.postData.token = res.result.token;
- if (res.result.key) {
- $App.postData.key = res.result.key;
- }
- if (res.result.driver === 'local') {
- $App.action = '/admin/framework/common/pictureUploads';
- }
- }, 1)
- }
- },
- mounted: function () {
- var that = this;
- that.UploadToken();
- if (!that.size) {
- that.postData.size = 20;
- } else {
- that.postData.size = that.size;
- }
- if (!that.suffix) {
- that.postData.suffix = 'png,bmp,jpeg,jpg,gif';
- } else {
- that.postData.suffix = that.suffix;
- }
- if (that.alt) {
- if (that.file) {
- if ((typeof that.file) == 'object') {
- that.fileItems = that.file;
- } else {
- if (!$Validator.json(that.file)) {
- console.error('va-picture components. File parameter requires a JSON string');
- } else {
- that.fileItems = JSON.parse(that.file);
- }
- }
- } else {
- that.fileItems = {
- url: '',
- alt: ''
- };
- }
- } else {
- that.fileItems = {
- url: (that.file && that.file != 'null') ? that.file : '',
- alt: '',
- name: ''
- };
- }
- that.galleryOptions = {
- max: 1,
- size: that.size,
- suffix: that.suffix,
- type: 'image',
- callback: 'pictureSelectedSuccess'
- };
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- }
- });
- Vue.component("va-picture-multiple", {
- props: {
- action: {
- type: String,
- default: '/admin/framework/common/pictureUploads'
- },
- size: {
- type: Number,
- default: 20
- },
- suffix: {
- type: String,
- default: 'png,bmp,jpeg,jpg,gif'
- },
- postData: {
- type: Object,
- default: {}
- },
- limit: {
- type: Number,
- default: 10
- },
- file: {
- type: String,
- default: ''
- },
- gallery: {
- type: Boolean,
- default: true
- },
- alt: {
- type: Boolean,
- default: false
- },
- name: {
- type: Boolean,
- default: false
- },
- disabled: {
- type: Boolean,
- default: false
- },
- },
- data: function () {
- return {
- picture: {
- postHeaders: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- },
- uploadStatus: false,
- progress: 0,
- },
- fileItems: [],
- galleryOptions: {},
- uploadOption: {driver: 'local', action: '', token: '', domain: ''},
- }
- },
- model: {
- prop: 'file',
- event: 'change'
- },
- watch: {
- file(value) {
- if (this.fileItems && this.fileItems.length > 0) {
- return true;
- }
- this.formatFileEvent(value);
- }
- },
- template: '<div class="va-component-picture-multiple" :disabled="disabled" id="_va-component-picture">\n' +
- ' <template v-if="fileItems.length > 0" >\n' +
- ' <div v-for="(item, index) in fileItems" class="va-component-picture picture__Sortable" :data-no="index" :disabled="disabled">\n' +
- ' <div class="show" :title="item.alt">\n' +
- ' <img class="image" :src="item.url">\n' +
- ' <div class="shadow" v-if="!disabled">\n' +
- ' <i class="el-icon-delete icon" @click="pictureItemsRemove(item, index)"></i>\n' +
- ' <el-dropdown class= "dropdown-picture-edit" placement="top" style="position:absolute" size="mini" @command="pictureItemsEdit(event, item, index)" v-if="alt || name">\n' +
- ' <span class="el-dropdown-link"><i class="el-icon-edit icon"></i> </span>\n' +
- ' <el-dropdown-menu slot="dropdown">\n' +
- ' <el-dropdown-item command="name" data-command="name" v-if="name">名称</el-dropdown-item>\n' +
- ' <el-dropdown-item command="alt" data-command="alt" v-if="alt">alt</el-dropdown-item>\n' +
- ' </el-dropdown-menu>' +
- ' </el-dropdown>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </div>' +
- ' </template>\n' +
- ' <template v-if="fileItems.length < limit">\n' +
- ' <el-upload\n' +
- ' :action="action"\n' +
- ' :show-file-list="false"\n' +
- ' :headers="picture.postHeaders"\n' +
- ' :data="postData"\n' +
- ' :multiple="true"\n' +
- ' :limit="limit"\n' +
- ' :on-success="pictureUploadSuccess"\n' +
- ' :on-progress="pictureUploadProgress"\n' +
- ' :on-error="pictureUploadError"\n' +
- ' ref="pictureMultipleUploadRef"\n' +
- ' :before-upload="pictureUploadBefore" v-if="!gallery">\n' +
- ' <div class="va-component-picture" :disabled="disabled" v-if="!picture.uploadStatus" >\n' +
- ' <div class="upload" :disabled="disabled">\n' +
- ' <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' <div class="va-component-picture" :disabled="disabled" v-else>\n' +
- ' <el-progress type="circle" :percentage="picture.progress" style="margin-top: 10px;" ></el-progress>\n' +
- ' </div>\n' +
- ' </el-upload>\n' +
- ' <div v-else class="va-component-picture gallery" :disabled="disabled" @click="pictureGalleryOpen">\n' +
- ' <div class="upload" :disabled="disabled">\n' +
- ' <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </template>\n' +
- '</div>',
- methods: {
- pictureGalleryOpen: function () {
- var that = this;
- if (that.disabled) {
- return false;
- }
- $Gallery.GalleryDialogOpen({
- max: (that.limit - that.fileItems.length),
- size: that.size,
- suffix: that.suffix,
- multiple: true,
- type: '1',
- tabs: false,
- callback: function (res) {
- res.forEach(function (item, key) {
- if (that.fileItems.length < 1) {
- that.fileItems.push({url: item.url, alt: item.original, name: item.original});
- } else {
- if (that.fileItems.length < that.limit) {
- that.fileItems.push({url: item.url, alt: item.original, name: item.original});
- }
- }
- });
- that.emitItemsEvent();
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- }
- });
- },
- pictureItemsEdit: function (e, item, index) {
- var that = this;
- if (that.disabled) {
- return false;
- }
- var tips = (e.target.dataset.command === 'name') ? '名称' : 'alt';
- $App.$prompt('', '修改图片' + tips, {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputPlaceholder: '请输入图片' + tips,
- inputValue: item[e.target.dataset.command],
- lockScroll: false,
- }).then(function (params) {
- if (!params.value) {
- $App.$message({
- message: '请输入图片' + tips,
- type: 'error',
- duration: 2400
- });
- } else {
- item[e.target.dataset.command] = params.value;
- that.emitItemsEvent();
- }
- }).catch(function(){});
- return true;
- },
- pictureItemsRemove: function (items, index) {
- var that = this;
- that.fileItems.splice(index, 1);
- that.emitItemsEvent();
- },
- pictureUploadProgress: function (event, file, fileList) {
- var that = this;
- that.picture.progress = parseFloat((event.percent).toFixed(2));
- },
- pictureUploadSuccess: function (response, file, fileList) {
- var that = this;
- var fileItemsMaps = that.fileItems;
- var url;
- switch (that.uploadOption.driver) {
- case 'qiniu':
- url = that.uploadOption.domain + '/' + response.key;
- break;
- case'oss':
- default:
- if (response.code !== 200) {
- $App.$Message(response.msg, 'warning');
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- return true;
- } else {
- url = response.result.url;
- }
- break;
- }
- if (fileItemsMaps.length < that.limit) {
- fileItemsMaps.push({url: url, alt: '', name: ''});
- }
- ;
- that.fileItems = fileItemsMaps;
- that.emitItemsEvent();
- $App.$Message('文件上传成功!', 'success');
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- return true;
- },
- pictureUploadError: function () {
- var that = this;
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- $App.$Message('文件上传失败,请重试!', 'warning');
- that.$refs.pictureMultipleUploadRef.clearFiles();
- return true;
- },
- pictureUploadBefore: function (file, e) {
- var that = this;
- that.UploadToken();
- /*验证图片大小*/
- if (that.size) {
- if ((file.size / 1048576) > that.size) {
- $App.$Message('请上传' + that.size + 'M以内的文件', 'warning');
- that.$refs.pictureMultipleUploadRef.clearFiles();
- return false;
- }
- }
- /*验证文件后缀*/
- if (that.suffix) {
- var args = ((file.name).split('.'));
- if (args[args.length - 1]) {
- var suffix = (that.suffix).split(',');
- if ($.inArray((args[args.length - 1]).toLowerCase(), suffix) < 0) {
- $App.$Message('请上传' + that.suffix + '类型的文件', 'warning');
- that.$refs.pictureMultipleUploadRef.clearFiles();
- return false;
- }
- }
- }
- that.picture.uploadStatus = true;
- that.picture.progress = 1;
- return true;
- },
- emitItemsEvent: function () {
- var that = this;
- that.UploadToken();
- if (that.alt || that.name) {
- that.$emit('change', JSON.stringify(that.fileItems));
- that.SortTableEvent();
- } else {
- var fileItems = '';
- if (that.fileItems.length > 0) {
- that.fileItems.forEach(function (item, key) {
- if (key === that.fileItems.length) {
- fileItems += item.url;
- } else {
- fileItems += item.url + ',';
- }
- });
- that.SortTableEvent();
- }
- that.$emit('change', fileItems);
- }
- },
- formatFileEvent: function () {
- var that = this;
- if (that.alt || that.name) {
- if (that.file) {
- if ((typeof that.file) == 'object') {
- that.fileItems = that.file;
- } else {
- if (!$Validator.json(that.file)) {
- console.info('va-picture-multiple components. File parameter requires a JSON string');
- } else {
- that.fileItems = JSON.parse(that.file);
- that.emitItemsEvent();
- }
- }
- } else {
- that.fileItems = [];
- }
- } else {
- if (!that.file || that.file == '[]' || that.file == '{}') {
- that.fileItems = [];
- } else {
- if (that.file) {
- var fileItems = (that.file).split(',');
- if (fileItems && fileItems.length > 0) {
- for (var i = 0; i <= fileItems.length; i++) {
- if (fileItems[i]) {
- that.fileItems.push({
- url: fileItems[i],
- alt: ''
- });
- }
- }
- that.emitItemsEvent();
- } else {
- that.fileItems = [];
- }
- } else {
- that.fileItems = [];
- }
- }
- }
- },
- UploadToken: function () {
- var that = this;
- if (that.gallery) return true;
- $Gallery.GalleryUploadToken(function (res) {
- that.uploadOption.driver = res.driver;
- that.uploadOption.domain = res.domain;
- that.action = res.action;
- that.postData.token = res.token;
- if (res.key) {
- that.postData.key = res.key;
- }
- if (res.driver === 'local') {
- that.action = '/admin/framework/common/pictureUploads';
- }
- }, 1);
- },
- SortTableEvent: function () {
- //获取对象
- var that = this;
- var el = document.getElementById('_va-component-picture');
- //设置配置
- var ops = {
- animation: 1000,
- dataIdAttr: "data-no",
- draggable: ".picture__Sortable",
- //拖动结束
- onEnd: function (evt) {
- var asd = [];
- var sortableArr = sortable.toArray();
- $.each(sortableArr, function (key, val) {
- asd.push(that.fileItems[val]);
- });
- that.fileItems = asd;
- that.emitItemsEvent();
- },
- };
- //初始化
- var sortable = Sortable.create(el, ops);
- }
- },
- mounted: function () {
- var that = this;
- that.UploadToken();
- if (!that.size) {
- that.postData.size = 20;
- } else {
- that.postData.size = that.size;
- }
- if (!that.suffix) {
- that.postData.suffix = 'png,bmp,jpeg,jpg,gif';
- } else {
- that.postData.suffix = that.suffix;
- }
- that.formatFileEvent();
- that.galleryOptions = {
- max: that.limit,
- size: that.size,
- suffix: that.suffix,
- type: 'image',
- callback: 'pictureSelectedSuccess'
- };
- that.picture.uploadStatus = false;
- that.picture.progress = 0;
- }
- });
- Vue.component("va-video", {
- props: {
- action: {
- type: String,
- default: '/admin/framework/common/fileUploads'
- },
- size: {
- type: Number,
- default: 20
- },
- suffix: {
- type: String,
- default: 'mp3,wma,avi,rm,rmvb,flv,mpg,mov,mk,mp4'
- },
- postData: {
- type: Object,
- default: {
- size: 20,
- suffix: 'mp3,wma,avi,rm,rmvb,flv,mpg,mov,mk,mp4'
- }
- },
- file: {
- type: String,
- default: "{url:'', size:'', original:''}"
- },
- gallery: {
- type: Boolean,
- default: true
- },
- preview: {
- type: Boolean,
- default: false
- },
- disabled: {
- type: String,
- default: false
- },
- onSuccess: {
- type: String,
- default: ''
- },
- },
- data: function () {
- return {
- postHeaders: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- },
- uploadOption: {driver: 'local', domain: ''},
- uploadStatus: false,
- _fileName: '',
- _fileSize: 0,
- percentage: 0,
- fileItems: {url: '', size: '', original: ''},
- galleryOptions: {}
- }
- },
- model: {
- prop: 'file',
- event: 'change'
- },
- watch: {
- file(value) {
- if (!this.fileItems.url) {
- this.fileItems = JSON.parse(value);
- this.$emit('change', JSON.stringify(this.fileItems));
- }
- }
- },
- template: '<div class="va-component-file" :disabled="disabled">\n' +
- ' <el-upload\n' +
- ' v-if="!fileItems.url && !uploadStatus && !gallery"\n' +
- ' :action="action"\n' +
- ' :headers="postHeaders"\n' +
- ' limit="1" drag\n' +
- ' :show-file-list="false"\n' +
- ' :data="postData"\n' +
- ' :disabled="disabled"\n' +
- ' :on-progress="fileUploadProgress"\n' +
- ' :on-success="fileUploadSuccess"\n' +
- ' :on-error="fileUploadError"\n' +
- ' :before-upload="fileUploadBefore"\n' +
- ' ref="fileDialogUpload"\n' +
- ' >\n' +
- ' <div class="upload">\n' +
- ' <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
- ' <div class="el-upload__text" style="margin-top: -12px">\n' +
- ' <el-link type="primary" :underline="false">\n' +
- ' <span style="font-weight: 500;font-size: 15px">点击视频上传</span>\n' +
- ' </el-link>\n' +
- ' <div style="font-size: 12px;margin-top:-15px">\n' +
- ' <div style="color: #909399;height: 15px">视频大小{{size}}MB以内</div>\n' +
- ' <div style="color: #909399;height: 15px">支持类型:{{suffix}}</div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </el-upload>\n' +
- ' <div class="upload" @click="fileGalleryOpen" v-if="!fileItems.url && !uploadStatus && gallery">\n' +
- ' <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
- ' <div class="el-upload__text" style="margin-top: -12px">\n' +
- ' <el-link type="primary" :disabled="disabled" :underline="false">\n' +
- ' <span style="font-weight: 500;font-size: 15px">点击视频上传</span>\n' +
- ' </el-link>\n' +
- ' <div style="font-size: 12px;margin-top:-15px">\n' +
- ' <div style="color: #909399;margin-top: 0">视频大小{{size}}MB以内</div>\n' +
- ' <div style="color: #909399;margin-top: -20px">支持类型:{{suffix}}</div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- '\n' +
- ' <div class="progress" v-if="uploadStatus && percentage > 0">\n' +
- ' <el-progress type="circle" :percentage="percentage" color=" var(--themeColors)"></el-progress>\n' +
- ' </div>\n' +
- '\n' +
- ' <div class="files" v-if="fileItems.url && !uploadStatus">\n' +
- ' <el-button :disabled="disabled" class="Va-button button" size="mini" type="default" @click="fileUploadAgain">重新上传</el-button>\n' +
- ' <el-button :disabled="disabled" class="Va-button button" size="mini" v-if="preview" type="default" @click="fileUploadPreview" style="top:42px">预览视频</el-button>\n' +
- ' <i class="el-icon-document icon"></i>\n' +
- ' <div class="text">\n' +
- ' <span class="text-space" style="font-weight: 500;font-size: 15px;line-height: 20px;display: inline-block;width: 90%;margin-top:10px">{{fileItems.original}}</span>\n' +
- ' <div style="font-size: 12px;margin-top: -20px">\n' +
- ' <div class="el-upload__tip" slot="tip" style="color: #909399">视频大小:{{fileItems.size}}字节</div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- '</div>',
- methods: {
- fileGalleryOpen: function () {
- var that = this;
- $Gallery.GalleryDialogOpen({
- max: 1,
- size: that.size,
- suffix: that.suffix,
- multiple: false,
- type: '2',
- tabs: false,
- callback: function (res) {
- that.emitItemsEvent(res);
- $App.$Message('视频上传成功!', 'success');
- that.uploadStatus = false;
- that.percentage = 0;
- }
- });
- },
- fileUploadPreview: function () {
- var that = this;
- $Preview.PreviewDialogOpen(that.fileItems.url);
- },
- fileUploadAgain: function () {
- var that = this;
- that.fileItems = {url: '', size: '', original: ''};
- that.emitItemsEvent({url: '', size: '', original: ''});
- that.uploadStatus = false;
- that.percentage = 0;
- if (that.onSuccess) {
- that.onSuccess();
- }
- },
- fileUploadProgress: function (event) {
- var that = this;
- that.percentage = parseFloat((event.percent).toFixed(2));
- },
- fileUploadSuccess: function (response, file, fileList) {
- var that = this;
- var _result = {url: '', original: '', size: '', code: 200};
- switch (that.uploadOption.driver) {
- case 'qiniu':
- _result.url = that.uploadOption.domain + '/' + response.key;
- _result.original = that._fileName;
- _result.size = that._fileSize;
- that.percentage = 0;
- that.uploadStatus = false;
- that.emitItemsEvent(_result);
- if (that.onsuccess) {
- that.onsuccess(_result);
- }
- $App.$Message('视频上传成功!', 'success');
- break;
- case'oss':
- default:
- if (response.code !== 200) {
- that.percentage = 0;
- that.uploadStatus = false;
- $App.$Message(response.msg, 'warning');
- return true;
- } else {
- that.percentage = 0;
- that.uploadStatus = false;
- that.emitItemsEvent(response.result);
- if (that.onsuccess) {
- that.onsuccess(response.result);
- }
- $App.$Message('视频上传成功!', 'success');
- return true;
- }
- }
- },
- fileUploadError: function () {
- var that = this;
- that.percentage = 0;
- that.uploadStatus = false;
- $App.$Message('视频上传失败,请重试!', 'warning');
- that.$refs.fileDialogUpload.clearFiles();
- return true;
- },
- fileUploadBefore: function (file, e) {
- var that = this;
- /*验证图片大小*/
- if (that.size) {
- if ((file.size / 1048576) > that.size) {
- $App.$Message('请上传' + that.size + 'M以内的视频', 'warning');
- that.$refs.fileDialogUpload.clearFiles();
- return false;
- }
- }
- /*验证视频后缀*/
- if (that.suffix) {
- var args = ((file.name).split('.'));
- if (args[args.length - 1]) {
- var suffix = (that.suffix).split(',');
- if ($.inArray(args[args.length - 1], suffix) < 0) {
- $App.$Message('请上传' + that.suffix + '类型的视频', 'warning');
- that.$refs.fileDialogUpload.clearFiles();
- return false;
- }
- }
- }
- that._fileSize = (file.size / 1048576).toFixed(2);
- that._fileName = file.name;
- that.percentage = 1;
- that.uploadStatus = true;
- return true;
- },
- emitItemsEvent: function (value) {
- var that = this;
- that.fileItems = {
- url: value.url,
- size: value.size,
- original: value.original
- };
- that.UploadToken();
- that.$emit('change', JSON.stringify(that.fileItems));
- },
- UploadToken: function () {
- var that = this;
- if (that.gallery) return true;
- $Gallery.GalleryUploadToken(function (res) {
- that.uploadOption.driver = res.driver;
- that.uploadOption.domain = res.domain;
- that.action = res.action;
- that.postData.token = res.token;
- if (res.key) {
- that.postData.key = res.key;
- }
- if (res.driver === 'local') {
- that.action = '/admin/framework/common/fileUploads';
- }
- }, 3);
- }
- },
- mounted: function () {
- var that = this;
- that.UploadToken();
- that.postData.size = that.size ? that.size : 20;
- that.postData.suffix = that.suffix ? that.suffix : 'doc,docx,xls,xlsx,xlsm,xlt,csv';
- if (that.file) {
- if ((typeof that.file) == 'object') {
- that.fileItems = that.file;
- that.$emit('change', JSON.stringify(that.fileItems));
- } else {
- if (!$Validator.json(that.file)) {
- console.error('va-file components. File parameter requires a JSON string');
- } else {
- that.fileItems = JSON.parse(that.file);
- that.$emit('change', JSON.stringify(that.fileItems));
- }
- }
- } else {
- that.fileItems = {
- url: '',
- size: '',
- original: ''
- };
- that.$emit('change', JSON.stringify(that.fileItems));
- }
- that.uploadStatus = false;
- that.percentage = 0;
- }
- });
- Vue.component("va-file", {
- props: {
- action: {
- type: String,
- default: '/admin/framework/common/fileUploads'
- },
- size: {
- type: Number,
- default: 20
- },
- suffix: {
- type: String,
- default: 'doc,docx,xls,xlsx,xlsm,xlt,csv'
- },
- postData: {
- type: Object,
- default: {
- size: 20,
- suffix: 'doc,docx,xls,xlsx,xlsm,xlt,csv'
- }
- },
- file: {
- type: String,
- default: "{url:'', size:'', original:''}"
- },
- gallery: {
- type: Boolean,
- default: true
- },
- preview: {
- type: Boolean,
- default: false
- },
- disabled: {
- type: String,
- default: false
- },
- onSuccess: {
- type: String,
- default: ''
- },
- },
- data: function () {
- return {
- postHeaders: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- },
- uploadOption: {driver: 'local', domain: ''},
- uploadStatus: false,
- _fileName: '',
- _fileSize: 0,
- percentage: 0,
- fileItems: {url: '', size: '', original: ''},
- galleryOptions: {}
- }
- },
- model: {
- prop: 'file',
- event: 'change'
- },
- watch: {
- file(value) {
- if (!this.fileItems.url) {
- this.fileItems = JSON.parse(value);
- this.$emit('change', JSON.stringify(this.fileItems));
- }
- }
- },
- template: '<div class="va-component-file" :disabled="disabled">\n' +
- ' <el-upload\n' +
- ' v-if="!fileItems.url && !uploadStatus && !gallery"\n' +
- ' :action="action"\n' +
- ' :headers="postHeaders"\n' +
- ' limit="1" drag\n' +
- ' :show-file-list="false"\n' +
- ' :data="postData"\n' +
- ' :disabled="disabled"\n' +
- ' :on-progress="fileUploadProgress"\n' +
- ' :on-success="fileUploadSuccess"\n' +
- ' :on-error="fileUploadError"\n' +
- ' :before-upload="fileUploadBefore"\n' +
- ' ref="fileDialogUpload"\n' +
- ' >\n' +
- ' <div class="upload">\n' +
- ' <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
- ' <div class="el-upload__text" style="margin-top: -12px">\n' +
- ' <el-link type="primary" :underline="false">\n' +
- ' <span style="font-weight: 500;font-size: 15px">点击文件上传</span>\n' +
- ' </el-link>\n' +
- ' <div style="font-size: 12px;margin-top:-15px">\n' +
- ' <div style="color: #909399;height: 15px">文件大小{{size}}MB以内</div>\n' +
- ' <div style="color: #909399;height: 15px">支持类型:{{suffix}}</div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </el-upload>\n' +
- ' <div class="upload" @click="fileGalleryOpen" v-if="!fileItems.url && !uploadStatus && gallery">\n' +
- ' <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
- ' <div class="el-upload__text" style="margin-top: -12px">\n' +
- ' <el-link type="primary" :disabled="disabled" :underline="false">\n' +
- ' <span style="font-weight: 500;font-size: 15px">点击文件上传</span>\n' +
- ' </el-link>\n' +
- ' <div style="font-size: 12px;margin-top:-15px">\n' +
- ' <div style="color: #909399;margin-top: 0">文件大小{{size}}MB以内</div>\n' +
- ' <div style="color: #909399;margin-top: -20px">支持类型:{{suffix}}</div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- '\n' +
- ' <div class="progress" v-if="uploadStatus && percentage > 0">\n' +
- ' <el-progress type="circle" :percentage="percentage" color=" var(--themeColors)"></el-progress>\n' +
- ' </div>\n' +
- '\n' +
- ' <div class="files" v-if="fileItems.url && !uploadStatus">\n' +
- ' <el-button :disabled="disabled" class="Va-button button" size="mini" type="default" @click="fileUploadAgain">重新上传</el-button>\n' +
- ' <el-button :disabled="disabled" class="Va-button button" size="mini" v-if="preview" type="default" @click="fileUploadPreview" style="top:42px">预览文件</el-button>\n' +
- ' <i class="el-icon-document icon"></i>\n' +
- ' <div class="text">\n' +
- ' <span style="font-weight: 500;font-size: 15px;line-height: 20px;display: inline-block;width: 90%;margin-top:10px">{{fileItems.original}}</span>\n' +
- ' <div style="font-size: 12px;margin-top: -20px">\n' +
- ' <div class="el-upload__tip" slot="tip" style="color: #909399">文件大小:{{fileItems.size}}字节</div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </div>\n' +
- '</div>',
- methods: {
- fileGalleryOpen: function () {
- var that = this;
- $Gallery.GalleryDialogOpen({
- max: 1,
- size: that.size,
- suffix: that.suffix,
- multiple: false,
- type: '3',
- tabs: false,
- callback: function (res) {
- that.emitItemsEvent(res);
- $App.$Message('文件上传成功!', 'success');
- that.uploadStatus = false;
- that.percentage = 0;
- }
- });
- },
- fileUploadPreview: function () {
- var that = this;
- $Preview.PreviewDialogOpen(that.fileItems.url);
- },
- fileUploadAgain: function () {
- var that = this;
- that.fileItems = {url: '', size: '', original: ''};
- that.emitItemsEvent({url: '', size: '', original: ''});
- that.uploadStatus = false;
- that.percentage = 0;
- if (that.onSuccess) {
- that.onSuccess();
- }
- },
- fileUploadProgress: function (event) {
- var that = this;
- that.percentage = parseFloat((event.percent).toFixed(2));
- },
- fileUploadSuccess: function (response, file, fileList) {
- var that = this;
- var _result = {url: '', original: '', size: '', code: 200};
- switch (that.uploadOption.driver) {
- case 'qiniu':
- _result.url = that.uploadOption.domain + '/' + response.key;
- _result.original = that._fileName;
- _result.size = that._fileSize;
- that.percentage = 0;
- that.uploadStatus = false;
- that.emitItemsEvent(_result);
- if (that.onsuccess) {
- that.onsuccess(_result);
- }
- $App.$Message('文件上传成功!', 'success');
- break;
- case'oss':
- default:
- if (response.code !== 200) {
- that.percentage = 0;
- that.uploadStatus = false;
- $App.$Message(response.msg, 'warning');
- return true;
- } else {
- that.percentage = 0;
- that.uploadStatus = false;
- that.emitItemsEvent(response.result);
- if (that.onsuccess) {
- that.onsuccess(response.result);
- }
- $App.$Message('文件上传成功!', 'success');
- return true;
- }
- }
- },
- fileUploadError: function () {
- var that = this;
- that.percentage = 0;
- that.uploadStatus = false;
- $App.$Message('文件上传失败,请重试!', 'warning');
- that.$refs.fileDialogUpload.clearFiles();
- return true;
- },
- fileUploadBefore: function (file, e) {
- var that = this;
- /*验证图片大小*/
- if (that.size) {
- if ((file.size / 1048576) > that.size) {
- $App.$Message('请上传' + that.size + 'M以内的文件', 'warning');
- that.$refs.fileDialogUpload.clearFiles();
- return false;
- }
- }
- /*验证文件后缀*/
- if (that.suffix) {
- var args = ((file.name).split('.'));
- if (args[args.length - 1]) {
- var suffix = (that.suffix).split(',');
- if ($.inArray(args[args.length - 1], suffix) < 0) {
- $App.$Message('请上传' + that.suffix + '类型的文件', 'warning');
- that.$refs.fileDialogUpload.clearFiles();
- return false;
- }
- }
- }
- that._fileSize = (file.size / 1048576).toFixed(2);
- that._fileName = file.name;
- that.percentage = 1;
- that.uploadStatus = true;
- return true;
- },
- emitItemsEvent: function (value) {
- var that = this;
- that.fileItems = {
- url: value.url,
- size: value.size,
- original: value.original
- };
- that.UploadToken();
- that.$emit('change', JSON.stringify(that.fileItems));
- },
- UploadToken: function () {
- var that = this;
- if (that.gallery) return true;
- $Gallery.GalleryUploadToken(function (res) {
- that.uploadOption.driver = res.driver;
- that.uploadOption.domain = res.domain;
- that.action = res.action;
- that.postData.token = res.token;
- if (res.key) {
- that.postData.key = res.key;
- }
- if (res.driver === 'local') {
- that.action = '/admin/framework/common/fileUploads';
- }
- }, 3);
- }
- },
- mounted: function () {
- var that = this;
- that.UploadToken();
- that.postData.size = that.size ? that.size : 20;
- that.postData.suffix = that.suffix ? that.suffix : 'doc,docx,xls,xlsx,xlsm,xlt,csv';
- if (that.file) {
- if ((typeof that.file) == 'object') {
- that.fileItems = that.file;
- that.$emit('change', JSON.stringify(that.fileItems));
- } else {
- if (!$Validator.json(that.file)) {
- console.error('va-file components. File parameter requires a JSON string');
- } else {
- that.fileItems = JSON.parse(that.file);
- that.$emit('change', JSON.stringify(that.fileItems));
- }
- }
- } else {
- that.fileItems = {
- url: '',
- size: '',
- original: ''
- };
- that.$emit('change', JSON.stringify(that.fileItems));
- }
- that.uploadStatus = false;
- that.percentage = 0;
- }
- });
- /*弹窗时需要销毁 va-editor; 最好是同弹窗一起v-if*/
- Vue.component("va-editor", {
- props: {
- height: {
- type: String,
- default: '200'
- },
- max_height: {
- type: String,
- default: '500'
- },
- id: {
- type: String,
- default: $Request.random(12)
- },
- placeholder: {
- type: String,
- default: '请填写内容'
- },
- disabled: {
- type: String,
- default: false
- },
- content: {
- type: String,
- default: ''
- },
- inline: {
- type: Boolean,
- default: false
- },
- toolbar: {
- type: String,
- default: '#fixed-editor-util'
- },
- mode: {
- type: String,
- default: 'ordinary'
- }, //simple, ordinary ,complex
- is_news: {
- type: String,
- default: '0'
- },
- },
- data: function () {
- return {
- vaEditorObj: {},
- reloadNum: 5,
- }
- },
- model: {
- prop: 'content',
- event: 'change'
- },
- watch: {
- content(value) {
- var that = this;
- // if (!that.vaEditorObj.getContent({
- // format: 'text'
- // }) && value) {
- // that.vaEditorObj.setContent(value);
- // }
- return true;
- },
- },
- template: '<div :id="id" class="va-editor tinymce-editor-ele" style="opacity: 0;width: 0;height: 0"></div>',
- methods: {
- createEditor: function () {
- var that = this;
- var plugins, toolbar = '';
- that.mode = that.mode ? that.mode : 'ordinary';
- switch (that.mode) {
- /*emoticons*/
- case 'simple':
- plugins = 'print autosave preview searchreplace autolink directionality visualblocks visualchars fullscreen gallery image link code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern emoticons bdmap autoresize toolbarsticky';//media
- toolbar = 'code undo redo | removeformat formats fontselect fontsizeselect bold italic underline strikethrough hr blockquote forecolor backcolor | gallery table \
- //| alignleft aligncenter alignright alignjustify outdent indent indent2em lineheight ';//image media imagetools
- break;
- case 'ordinary':
- plugins = 'print autosave preview searchreplace autolink directionality visualblocks visualchars fullscreen gallery link code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern emoticons bdmap autoresize toolbarsticky';//media
- toolbar = 'code undo redo | removeformat formats fontselect fontsizeselect bold italic underline strikethrough hr blockquote forecolor backcolor \
- //| alignleft aligncenter alignright alignjustify outdent indent indent2em lineheight | gallery';//media
- break;
- case 'complex':
- plugins = '';
- toolbar = '';
- break;
- }
- $(function () {
- tinymce.init({
- selector: '#' + that.id,
- resize: true,
- language: 'zh_CN',
- menubar: that.mode === 'simple' ? false : ' file edit view table insert tool format image',
- inline: that.inline,
- font_formats: "微软雅黑='微软雅黑';宋体='宋体';黑体='黑体';仿宋='仿宋';楷体='楷体';隶书='隶书';幼圆='幼圆';Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings",
- toolbar_groups: {
- textformat: {
- text: '文字格式',
- icon: 'text-color',
- tooltip: 'Formatting',
- items: 'forecolor backcolor bold italic underline strikethrough',
- },
- paragraph: {
- text: '段落',
- icon: 'align-left',
- tooltip: 'alignment',
- items: 'alignleft aligncenter alignright alignjustify outdent indent indent2em lineheight',
- },
- alignments: {
- text: '对齐方式',
- icon: 'align-left',
- tooltip: 'alignment',
- items: 'alignleft aligncenter alignright alignjustify outdent indent indent2em lineheight ',
- },
- },
- plugins: plugins,
- toolbar: toolbar,
- // plugins: 'print autosave preview searchreplace autolink directionality visualblocks visualchars fullscreen image media link code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern emoticons bdmap autoresize ',//autosave
- // toolbar: 'preview fullscreen code undo redo restoredraft | textformat | paragraph | styleselect formatselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \
- // table emoticons hr | powerpaste',
- // plugins: 'print autosave preview searchreplace autolink directionality visualblocks visualchars fullscreen image media link code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern emoticons bdmap autoresize ',//autosave
- // toolbar: 'code undo redo restoredraft formatting | forecolor backcolor bold italic underline strikethrough | alignleft aligncenter alignright alignjustify outdent indent | \
- // styleselect formatselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \
- // table emoticons hr | powerpaste',
- placeholder: that.placeholder ? that.placeholder : '请输入内容',
- readonly: that.disabled, //只读模式
- branding: false, //隐藏右下角技术支持
- statusbar: false,
- elementpath: false, //隐藏底栏的元素路径
- custom_undo_redo_levels: 30, //撤销次数
- object_resizing: true, //调整大小控件开关
- contextmenu_never_use_native: false, //在编辑器中屏蔽浏览器本身的右键菜单
- fixed_toolbar_container: that.inline ? that.toolbar : '', // '#fixed-editor-util',//指定工具栏在某一容器顶部固定。
- // fixed_toolbar_container: '#va-editor-content',//指定工具栏在某一容器顶部固定。
- custom_ui_selector: 'body',
- toolbar_mode: 'wrap',
- // toolbar_sticky: true,
- cfyun_toolbar_sticky: true,
- toolbar_sticky_type: false,
- toolbar_sticky_elem_height: 60,
- toolbar_sticky_wrap: '.Va-container',
- fontsize_formats: '12px 14px 16px 18px 24px 36px 48px 56px 72px',
- remove_trailing_brs: true, //删除最尾的br
- width: '100%',
- min_height: parseInt(that.height),
- autoresize_bottom_margin: 50, //自动调整编辑器大小的方法以适应内容
- //autoresize_overflow_padding: 50,//指定编辑器body初始化时两侧的距离,相当于padding-left加padding-right
- max_height: parseInt(that.max_height),
- autolink: true, //autolink插件会自动创建超链接
- fullscreen_native: true, //全屏将不在是网页全屏,而是使用浏览器的全屏模式
- /*图片参数*/
- image_uploadtab: true, //配置了images_upload_url后会在图像对话框中添加“上传”标签用于上传本地图像,此选项设false可关闭该标签。
- image_advtab: true, //为图像属性编辑窗口添加高级属性
- automatic_uploads: false, //Data URL/Blob URL插入图片和文件到内容区的方式
- images_upload_credentials: true,
- file_picker_types: 'image media',
- images_upload_url: '/admin/framework/common/uploadEditor',
- autosave_ask_before_unload: false, //当关闭或跳转URL时,弹出提示框提醒用户仍未保存变更内容。
- autosave_interval: '5s', //自动存稿的世界间隔。注意该值为字符串,以秒为单位
- convert_urls: false, //上传文件自动转换相对路径
- image_caption: true, //在弹出框中增加一个“标题”选项,开启后图片将被包含在figure(HTML5新增)内。
- image_description: true, //为img添加属性alt
- typeahead_urls: true, //设false就是关闭地址input的自动完成。
- media_alt_source: false, //显示隐藏资源备用地址输入框
- media_poster: false, //显示隐藏图片封面输入框
- media_live_embeds: true,
- hidden_input: false,
- visual: false,
- inline_boundaries: false,
- auto_focus: false,
- setup: function (editor) {
- that.vaEditorObj = editor;
- editor.on('input change undo redo execCommand KeyUp', function (e) {
- $(".el-container.is-vertical").css({
- flexDirection: 'inherit'
- });
- $(".el-container.is-vertical").css({
- flexDirection: 'column'
- });
- that.$emit('change', editor.getContent());
- });
- that.vaEditorObj.setMode(that.disabled ? 'readonly' : 'design');
- },
- init_instance_callback: function (editor) {
- setTimeout(function () {
- that.vaEditorObj.setContent(that.content);
- }, 100);
- //that.vaEditorObj.focus();
- },
- handle_event_callback: function (event) {
- that.vaEditorObj.focus();
- },
- audio_template_callback: function (data) {
- return '<audio controls>' + '\n<source src="' + data.source1 + '"' + (data.source1mime ? ' type="' + data.source1mime + '"' : '') + ' />\n' + '</audio>';
- },
- /*文件上传回调*/
- file_picker_callback: function (callback, value, meta) {
- window.galleryObj = {};
- var fileParams = {
- ts: meta.filetype,
- ft: 1,
- is_news: that.is_news,
- mx: 1,
- ck: 'ComponentPictureTemporaryEvent',
- se: 20,
- };
- switch (meta.filetype) {
- case "image":
- fileParams.ft = 1;
- fileParams.mx = 1;
- fileParams.se = 20;
- break;
- case "media":
- fileParams.ft = 2;
- fileParams.mx = 1;
- fileParams.se = 100;
- break;
- case "file":
- fileParams.ft = 3;
- fileParams.mx = 1;
- fileParams.se = 100;
- break;
- default:
- break;
- }
- $Gallery.GalleryDialogOpen({
- max: fileParams.mx,
- size: fileParams.se,
- is_new: fileParams.is_news,
- multiple: false,
- type: fileParams.ft,
- callback: function (res) {
- callback(res.url, {
- source2: res.url,
- poster: res.original
- });
- }
- });
- },
- });
- });
- if (!that.vaEditorObj.id && that.reloadNum > 0) {
- setTimeout(function () {
- that.createEditor();
- that.reloadNum = that.reloadNum - 1;
- }, 500);
- }
- }
- },
- beforeDestroy: function () {
- tinymce.remove();
- },
- beforeCreate: function () {
- },
- created: function () {
- var that = this;
- setTimeout(function () {
- that.createEditor()
- }, 100);
- },
- mounted: function () {
- }
- });
- Vue.component('va-timer', {
- props: {
- time: {type: Number, default: 0},
- },
- data: function () {
- return {
- flag:null,
- hour:0,
- minute:0,
- second:0,
- hour_time:'00',
- minute_time:'00',
- second_time:'00',
- }
- },
- model: {
- prop: 'file',
- event: 'change'
- },
- template: '<div style="display: inline">' +
- '<span>{{hour_time}}</span>' +
- '<span>:</span>' +
- '<span>{{minute_time}}</span>' +
- '<span>:</span>' +
- '<span>{{second_time}}</span>' +
- '</div>',
- methods: {
- start(time){
- var that = this;
- if (time > 0){
- // 初始化时间
- var nowTime = Date.now()
- var date = new Date(parseInt(nowTime - (time * 1000)))
- that.hour = date.getUTCHours();
- that.minute = date.getUTCMinutes();
- that.second = date.getUTCSeconds();
- }
- // 开始定时
- that.flag = setInterval(()=>{
- that.second += 1;
- if(that.second >= 60){
- that.second = 0;
- that.minute += 1;
- }
- if (that.minute >= 60){
- that.minute = 0;
- that.hour += 1;
- }
- that.hour_time = that.zeroize(that.hour);
- that.minute_time = that.zeroize(that.minute);
- that.second_time = that.zeroize(that.second);
- },1000)
- },
- zeroize(n){
- return n < 10 ? '0' + n : "" + n;
- }
- },
- mounted: function() {
- var that = this;
- that.start(that.time);
- }
- });
- // Other
- $(function () {
- // document.getElementsByClassName('el-drawer__container').onclick = function () {
- $('body').on('mousedown', '.el-drawer__container', function (e) {
- // $DrawerForms.methods.handleWrapperMousedown(e);
- })
- $('body').on('mouseup', '.el-drawer__container', function (e) {
- // $DrawerForms.methods.handleWrapperMouseup(e);
- })
- $('body').on('mousedown', '.el-dialog__wrapper', function (e) {
- // $DialogForms.methods.handleWrapperMousedown(e);
- })
- $('body').on('mouseup', '.el-dialog__wrapper', function (e) {
- // $DialogForms.methods.handleWrapperMouseup(e);
- })
- /**
- * panda
- * 页面加载进度条
- */
- if (location.hostname.match(/ricostacruz\.com$/)) {
- var _gaq = _gaq || [];
- _gaq.push(["_setAccount", "UA-20473929-1"]), _gaq.push(["_trackPageview"]), function () {
- var a = document.createElement("script");
- a.type = "text/javascript", a.async = !0, a.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
- var b = document.getElementsByTagName("script")[0];
- b.parentNode.insertBefore(a, b)
- }()
- }
- $('body').show();
- $('.version').text(NProgress.version);
- NProgress.start();
- setTimeout(function () {
- NProgress.done();
- $('.fade').removeClass('out');
- }, 1000);
- $("#b-0").click(function () {
- NProgress.start();
- });
- $("#b-40").click(function () {
- NProgress.set(0.4);
- });
- $("#b-inc").click(function () {
- NProgress.inc();
- });
- $("#b-100").click(function () {
- NProgress.done();
- });
- var HN = [];
- HN.factory = function (e) {
- return function () {
- HN.push([e].concat(Array.prototype.slice.call(arguments, 0)))
- };
- },
- HN.on = HN.factory("on"),
- HN.once = HN.factory("once"),
- HN.off = HN.factory("off"),
- HN.emit = HN.factory("emit"),
- HN.load = function () {
- var e = "hn-button.js";
- if (document.getElementById(e)) return;
- var t = document.createElement("script");
- //t.id=e,t.src="//hn-button.herokuapp.com/hn-button.js";
- var n = document.getElementsByTagName("script")[0];
- n.parentNode.insertBefore(t, n)
- }, HN.load();
- /**
- * panda
- * 页面加载进度条end.
- */
- })
- //表格关闭
- function removeTableMoveEvent(obj) {
- $(obj).parent().removeClass('Va-table-move');
- $(obj).remove();
- }
- function in_array(val, arr) {
- for (var i = 0, len = arr.length; i < len; i++) {
- if (val === arr[i]) {
- return true;
- }
- }
- return false;
- }
- // 主题色
- var themeStyle = {
- index: {
- themeColors: "#009688",
- themeTextColors: "#F9F9F9",
- themeSelectColors: "#606266",
- headerBackground: "#fff",
- headerTextColors: "#303133",
- leftBackground: "#344058",
- leftTextColors: "#fff",
- buttonHoverColors: "#009688"
- },
- purple: {
- themeColors: "#d21074",
- themeTextColors: "#F9F9F9",
- themeSelectColors: "#606266",
- headerBackground: "#fff",
- headerTextColors: "#303133",
- leftBackground: "#564d67",
- leftTextColors: "#fff",
- buttonHoverColors: "#d21074"
- },
- blue: {
- themeColors: "#2790a6",
- themeTextColors: "#F9F9F9",
- themeSelectColors: "#606266",
- headerBackground: "#fff",
- headerTextColors: "#303133",
- leftBackground: "#2d6973",
- leftTextColors: "#fff",
- buttonHoverColors: "#d21074"
- }
- }
|