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(''); $(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(''); $(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: '