"use strict"; var _Vue$component; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /* auteltech-webpack */ function getElePosition(element) { function getElementPageLeft(element) { var actualLeft = element.offsetLeft; var parent = element.offsetParent; while (parent != null) { actualLeft += parent.offsetLeft + parent.clientLeft; parent = parent.offsetParent; } return actualLeft; } function getElementPageTop(element) { var actualTop = element.offsetTop; var parent = element.offsetParent; while (parent != null) { actualTop += parent.offsetTop + parent.clientTop; parent = parent.offsetParent; } return actualTop; } var left = getElementPageLeft(element); var top = getElementPageTop(element); var eleH = element.clientHeight; var eleW = element.clientWidth; var ww = document.documentElement.clientWidth; var hh = document.documentElement.clientHeight; return { top: top, left: left, eleW: eleW, eleH: eleH, width: ww, height: hh }; } function getRect(element) { var rect = element.getBoundingClientRect(); var w = rect.width || rect.right - rect.left; var h = rect.height || rect.bottom - rect.top; var ww = document.documentElement.clientWidth; var hh = document.documentElement.clientHeight; return { top: window.outerHeight - window.innerHeight + Math.floor(rect.top), bottom: Math.floor(hh - rect.bottom), left: Math.floor(rect.left), right: Math.floor(ww - rect.right), width: ww, height: hh, eleW: rect.width, eleH: rect.height }; } ; // 判断有没有指定ID的父节点 function getParentNodeByID(dom, id) { if (!dom || !id) return false; if (dom.getAttribute('id') == id) { return true; } else { if (dom.nodeName == 'BODY') { return false; } return getParentNodeByID(dom.parentNode, id); } } var M = {}; function tip(msg) { if (window.jqueryAlert) { M.tip = jqueryAlert({ 'content': msg, 'closeTime': 5000, 'top': '15%', 'className': 'tip-box', 'end': function end() {} }); } } function _confirm(msg, onOk, onCancel, config) { config = config ? config : {}; var okBtnName = config.okBtnName || 'OK'; var cancelBtnName = config.cancelBtnName || 'Cancel'; if (window.jqueryAlert) { return new Promise(function (resolve) { var buttons = {}; buttons[okBtnName] = function () { onOk && onOk(); M.confirm.close(); resolve(true); }; if (onCancel) { buttons[cancelBtnName] = function () { onCancel(); M.confirm.close(); resolve(false); }; } M.confirm = jqueryAlert({ 'content': msg, 'modal': true, 'top': '30%', 'className': 'confirm-box', 'buttons': buttons }); }); } else { return new Promise(function (resolve) { window.confirm(msg); resolve(true); }); } } Vue.prototype.$tip = function (msg) { tip(msg); }; Vue.prototype.$confirm = function (msg, onOk, onCancel) { var okBtnName = this.$t ? this.$t('BUTTONS.确定') : 'OK'; var cancelBtnName = this.$t ? this.$t('BUTTONS.取消') : 'Cancel'; _confirm(msg, onOk, onCancel, { okBtnName: okBtnName, cancelBtnName: cancelBtnName }); }; function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return false; } Vue.prototype.$query = getQueryVariable; /**loading 组件 */ Vue.component("c-loading", { template: "\n\t
\n\t\t
\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t
\n\t
\n ", props: { loading: Boolean }, data: function data() { return {}; }, computed: { _loading: function _loading() { return this.loading; } }, methods: {} }); /**Modal 组件 */ Vue.component("c-modal", { template: "\n\t
\n\t\t
\n\t\t
\n\t\t\t
\n\t\t\t\t\n\t\t\t\t

{{title}}

\n \n \n
\n
\n \u786E\u5B9A\n
\n
\n
\n\t\t\t
\n\t\t
\n\t
\n ", props: { title: String, showclose: { type: Boolean, "default": true } }, data: function data() { return { showModal: false }; }, methods: { show: function show() { this.showModal = true; }, hide: function hide() { this.showModal = false; }, close: function close() { this.showModal = false; this.$emit('close', 'hide'); } } }); /** Select 组件 */ Vue.component("c-select", { template: "\n
\n
\n \n \n
\n
\n \n
\n ", props: { formdata: { type: Object, "default": {} }, prepend: { type: Array, "default": null }, field: String, arr: Array }, data: function data() { return { showList: false, options: [], id: "SELECT_".concat(Math.floor(Math.random() * 100000)) }; }, computed: { _arr: function _arr() { var _this = this; this.options = this.prepend ? this.prepend.concat(this.arr) : this.arr; return this.options.map(function (option) { if (option.value == _this.formdata[_this.field]) { option.selected = true; } else { option.selected = false; } return option; }); }, _name: function _name() { var _this2 = this; var selects = this.options.filter(function (option) { return option.value == _this2.formdata[_this2.field]; }); return selects[0] ? selects[0].name : ''; } }, created: function created() {}, mounted: function mounted() { // console.log('InputNumber mounted', this.formdata, this.field) var that = this; // 监听 document.body 点击 var originEvent = document.body.onclick; var id = this.id; document.body.addEventListener('click', function (e) { originEvent && originEvent(); if (getParentNodeByID(e.target, id)) { return false; } that.showList = false; }); }, methods: { onClick: function onClick() { this.showList = true; }, onClickIcon: function onClickIcon() { this.showList = !this.showList; }, onBlur: function onBlur() {// console.log('失去焦点') // setTimeout(() => { // this.showList = false // }, 200); }, onSelect: function onSelect(option) { console.log(option); this.showList = false; this.options.forEach(function (_option) { if (_option.value == option.value) { _option.selected = true; } else { _option.selected = false; } }); this.formdata[this.field] = option.value; !option.ignore && this.$emit('onselect', { selected: option }); } } }); /** Select 组件 (支持搜索) */ Vue.component("c-select2", { template: "\n
\n
\n \n \n \n \n
\n
\n \n \n \n\n
\n
\n \n
\n
\n ", props: { formdata: { type: Object, "default": {} }, field: String, search: { type: Boolean, "default": false }, clicksearch: { type: Boolean, "default": true }, showicon: { type: Boolean, "default": true }, disabled: { type: Boolean, "default": false }, emitchange: { type: Boolean, "default": false }, mode: { type: String, "default": 'mode01' }, lang: { type: String, "default": 'en' }, max: { type: Number }, filter: { type: Function, "default": null }, placeholder: { type: String, "default": 'select' }, arr: Array }, data: function data() { return { showList: false, id: Math.floor(Math.random() * 100000), searchArr: [], keyword: '', popStyle: { top: 0, width: 0 }, useSelect: false }; }, computed: { _cid: function _cid() { return "SELECT_".concat(this.id); }, _popId: function _popId() { return "SELECT_POP_".concat(this.id); }, _arr: function _arr() { var _this3 = this; return this.arr.map(function (option) { if (option.value == _this3.formdata[_this3.field]) { option.selected = true; } return option; }).filter(function (item) { if (_this3.search) { return item.show == true; } return true; }); }, _name: function _name() { var _this4 = this; var selects = this.arr.filter(function (option) { return option.value == _this4.formdata[_this4.field]; }); return selects[0] ? selects[0].name : ''; }, _popStyle: function _popStyle() { return this.popStyle; }, showclear: function showclear() { return this.search && this.keyword != ''; } }, mounted: function mounted() { var _this5 = this; var that = this; // 监听 document.body 点击 var originEvent = document.body.onclick; var id = this._cid; document.body.addEventListener('click', function (e) { originEvent && originEvent(); if (getParentNodeByID(e.target, id)) { return false; } that.hidePop(); }); this.$watch(function () { return _this5.formdata[_this5.field]; }, function (val) { console.log('新值', _this5.field, val); // this._arr if (_this5.search) { _this5.keyword = val; } }); }, methods: { hidePop: function hidePop() { var that = this; if (document.querySelector("#".concat(this._popId))) { that.showList = false; document.querySelector("#".concat(this._popId)).style.display = 'none'; } if (this.search) {// this.keyword = this.formdata[this.field] } }, onClick: function onClick() { if (!this.clicksearch && !this.keyword) return; if (this.disabled) return; this.showList = true; this.onSearchKey(); }, onClickIcon: function onClickIcon() { if (this.disabled) return; this.showList = !this.showList; if (this.showList) { this.onSearchKey(); } }, onClickIconAll: function onClickIconAll() { if (this.disabled) return; this.showList = !this.showList; if (this.showList) { this.onSearchAll(); } else { this.hidePop(); } }, onClear: function onClear() { this.keyword = ''; this.formdata[this.field] = ''; // this.$emit('onclear') this.searchArr = this.searchArr.map(function (item) { item.selected = false; return item; }); this.$emit('onselect', { selected: null }); }, onSearch2: function onSearch2() { if (this.disabled) return; console.log('search'); this.showList = true; this.onSearchKey(); }, onSearchKey: function onSearchKey() { var _this6 = this; if (this.disabled) return; this.showList = true; this.searchArr = []; this.arr.map(function (item) { var name = ''; if (_this6.filter) { name = _this6.filter(item.name); } else { name = item.name; } if ("".concat(name).toLowerCase().indexOf("".concat(_this6.keyword).toLowerCase()) > -1 || "".concat(item.name).toLowerCase().indexOf("".concat(_this6.keyword).toLowerCase()) > -1) { if (_this6.max && _this6.searchArr.length >= _this6.max) {} else { _this6.searchArr.push(item); } } }); }, onChange: function onChange() { var _this7 = this; if (!this.emitchange) return false; this.useSelect = false; console.log('onChange 1'); setTimeout(function () { if (!_this7.useSelect) { console.log('onchange 2', _this7.keyword); _this7.showList = false; _this7.formdata[_this7.field] = _this7.keyword; // this.$emit('onchange', { keyword: this.keyword }) _this7.$emit('onselect', { selected: { name: _this7.keyword, value: _this7.keyword } }); } }, 500); }, onSearchAll: function onSearchAll() { var _this8 = this; if (this.disabled) return; this.showList = true; this.searchArr = []; this.arr.map(function (item) { _this8.searchArr.push(item); }); }, onBlur: function onBlur() {// console.log('失去焦点') // setTimeout(() => { // this.showList = false // }, 200); }, onSelect: function onSelect(option) { console.log('onSelect', option); this.useSelect = true; this.showList = false; this.arr.forEach(function (_option) { if (_option.value == option.value) { _option.selected = true; } else { _option.selected = false; } }); this.formdata[this.field] = option.value; if (this.search) { this.keyword = option.value; } this.$emit('onselect', { selected: option }); } } }); /** Checkbox 组件 */ Vue.component("c-checkbox", { template: "\n
\n
\n \n
\n
\n ", props: { formdata: { type: Object, "default": {} }, field: String, arr: Array }, emits: ["oncheck"], data: function data() { return { id: "CBOX_".concat(Math.floor(Math.random() * 100000)) }; }, computed: { _arr: function _arr() { var _vals = "".concat(this._formData[this.field] || "").split(","); return this.arr.map(function (item) { if (~_vals.indexOf("".concat(item.value))) { item.checked = true; } return item; }); }, values: function values() { return this._arr.filter(function (item) { return item.checked; }).map(function (item) { return item.value; }).join(","); }, _formData: function _formData() { return this.formdata; } }, mounted: function mounted() {}, methods: { change: function change(item, e) { item.checked = !item.checked; this.$emit("oncheck", { values: this._formData[this.field] = this.values, field: this.field, selects: this.selects }); } } }); /** Multi-Select 组件 */ Vue.component("c-select-multi", { template: "\n
\n
\n
\n \n {{select.value}}\n \n \n \n \n
\n \n
\n \n
\n ", props: { formdata: { type: Object, "default": {} }, field: String, arr: Array }, data: function data() { return { showList: false, id: "SELECT_M_".concat(Math.floor(Math.random() * 100000)), selects: [] }; }, computed: { _arr: function _arr() { return this.arr; } }, watch: { arr: function arr(newVal, oldVal) { var _this9 = this; this.arr.forEach(function (option) { if (_this9.formdata[_this9.field].split(',').indexOf(option.value) > -1) { option.selected = true; } else { option.selected = false; } }); this.selects = [].concat(this._arr.filter(function (option) { return option.selected; })); } }, mounted: function mounted() { var that = this; // 监听 document.body 点击 var originEvent = document.body.onclick; var id = this.id; document.body.addEventListener('click', function (e) { originEvent && originEvent(); if (getParentNodeByID(e.target, id)) { return false; } that.showList = false; }); }, methods: { onRemove: function onRemove(option) { this.onSelect(option); }, onClick: function onClick() { this.showList = !this.showList; }, onClickIcon: function onClickIcon() { this.showList = !this.showList; }, onSelect: function onSelect(option) { var _this10 = this; console.log(option); // 在 selects 中添加/删除,有顺序 if (option.selected == false) { this.selects.push(option); } else { this.selects.forEach(function (select, index) { if (select.value == option.value) { _this10.selects.splice(index, 1); } }); } var _selects = this._arr.filter(function (_option) { if (_option.value == option.value) { _option.selected = !option.selected; } return _option.selected; }); this.formdata[this.field] = _selects.map(function (select) { return select.value; }).join(','); this.$emit('onselect', { selected: _selects }); } } }); /** Search 组件 */ Vue.component("c-search", { template: "\n
\n \n \n
\n ", props: { formdata: { type: Object, "default": {} }, field: String, placeholder: String }, data: function data() { return {}; }, computed: {}, mounted: function mounted() {}, methods: { onSearch: function onSearch() { this.$emit('onsearch'); } } }); /**异步按钮 组件 */ Vue.component("c-async-button", { template: "\n
\n
\n {{name}}\n \n \n
\n
\n ", props: { name: String, opend: Boolean, asyncfn: Function }, data: function data() { return { loading: false }; }, computed: { _opened: function _opened() { return this.opend; } }, methods: { onClick: function onClick() { var _this11 = this; if (this.loading) return; this.loading = true; console.log('异步按钮 开始 loading'); this.asyncfn().then(function (res) { console.log('异步按钮 拿到异步数据', res); _this11.loading = false; console.log('异步按钮 结束 loading'); // return new Promise((resolve) => { // console.log('异步按钮 111') // resolve(res) // console.log('异步按钮 222') // }) }); } } }); /**下拉菜单 组件 */ Vue.component("c-dropbox", { template: "\n
\n
\n
\n {{name}} \n
\n
\n
\n \n
\n
\n ", props: { name: String, position: { type: String, "default": 'right' } }, data: function data() { return { opened: false, id: "DROPBOX_".concat(Math.floor(Math.random() * 100000)) }; }, computed: {}, mounted: function mounted() { var that = this; // 监听 document.body 点击 var originEvent = document.body.onclick; var id = this.id; document.body.addEventListener('click', function (e) { originEvent && originEvent(); if (getParentNodeByID(e.target, id)) { return false; } that.opened = false; }); }, methods: { onClick: function onClick() { this.opened = !this.opened; } } }); /**空数据 icon 组件 */ Vue.component("c-empty-data", { template: "\n\n \n \n \n \n \n \n \n \n \n \n \n\n ", props: {}, data: function data() { return {}; }, methods: {} }); /** 图片 img 组件 */ Vue.component("c-img", { template: "\n

\n \"\"\n \n \n \n \n

\n ", props: { src: String }, data: function data() { return { loaded: false, id: "IMG_".concat(Math.floor(Math.random() * 100000)) }; }, computed: { _src: function _src() { return this.src; // return `${this.src}?v=${this.id}` } }, methods: { onImgLoad: function onImgLoad() { console.log('onImgLoad', this._src); this.loaded = true; this.$forceUpdate(); }, onLoadError: function onLoadError() { console.log('onLoadError', this._src); this.loaded = false; this.$forceUpdate(); } } }); /** 弹窗 alert 确认 组件 */ // // var Alert = { template: "\n
\n
\n \n
\n
\n
\n \n

Error

\n
\n
\n \n

Success

\n
\n

\n
\n
OK
\n
Cancel
\n
\n
\n
\n
\n
\n ", data: function data() { return { visible: false, type: 'error', content: '', callbackOk: null, callbackCancel: null }; }, methods: { onConfirm: function onConfirm() { this.visible = false; document.body.style.overflow = ''; this.callbackOk && this.callbackOk(); }, onClose: function onClose() { this.visible = false; document.body.style.overflow = ''; this.callbackCancel && this.callbackCancel(); }, onLeave: function onLeave() { this.$el.parentNode && this.$el.parentNode.removeChild(this.$el); } }, install: function install(Vue) { var alerts = Vue.prototype.$alerts = {}; var createComponent = function createComponent(data) { var Constructor = Vue.extend(Alert); //生成一个Vue子类,子类就是这个组件 var instance = new Constructor({ data: data }); //生成子类的实例 instance.vm = instance.$mount(); //将该实例手动挂载 document.body.appendChild(instance.vm.$el); //将实例挂载到body上 instance.vm.visible = true; document.body.style.overflow = 'hidden'; }; alerts.success = function (msg) { createComponent({ type: 'success', content: msg }); }; alerts.error = function (msg) { createComponent({ type: 'error', content: msg }); }; Vue.prototype.$alert = function (config) { createComponent(config); }; } }; /** 消息提示 组件 */ var Message = { template: "\n
\n \n

\n \n \n \n \n \n \n {{content}}\n

\n
\n
\n ", data: function data() { return { id: "Message_".concat(Math.floor(Math.random() * 100000)), visible: false, type: 'error', content: '', time: 5, timer: null, style: { transform: "translateY(0px)" }, onleave: null }; }, mounted: function mounted() { this.startTimer(); }, methods: { onPause: function onPause() { console.log('paused...'); clearInterval(this.timer); }, onContinue: function onContinue() { console.log('continue...'); this.startTimer(); }, startTimer: function startTimer() { var _this12 = this; this.timer = setInterval(function () { _this12.time--; // console.log(this.time) if (_this12.time <= 0) { _this12.visible = false; clearInterval(_this12.timer); } }, 1000); }, onLeave: function onLeave() { var _this13 = this; this.$destroy(true); this.$el.parentNode && this.$el.parentNode.removeChild(this.$el); this.onleave && this.onleave(); this.$messageInstances.forEach(function (instance, index) { if (instance.id == _this13.id) { _this13.$messageInstances.splice(index, 1); } instance.resetPosition(index); }); }, resetPosition: function resetPosition(index) { this.style = { transform: "translateY(-".concat(50 * index, "px)") }; } }, install: function install(Vue) { var messages = Vue.prototype.$messages = {}; var createComponent = function createComponent(data) { var Constructor = Vue.extend(Message); //生成一个Vue子类,子类就是这个组件 var instance = new Constructor({ data: data }); //生成子类的实例 instance.vm = instance.$mount(); //将该实例手动挂载 document.body.appendChild(instance.vm.$el); //将实例挂载到body上 instance.vm.visible = true; // 保存 message 实例 Vue.prototype.$messageInstances || (Vue.prototype.$messageInstances = []); Vue.prototype.$messageInstances.unshift(instance); Vue.prototype.$messageInstances.forEach(function (instance, index) { instance.resetPosition(index); }); }; messages.success = function (msg, onleave) { createComponent({ type: 'success', content: msg, onleave: onleave }); }; messages.error = function (msg, onleave) { createComponent({ type: 'error', content: msg, onleave: onleave }); }; Vue.prototype.$message = function (config) { createComponent(config); }; } }; /** 消息提示 组件 */ var Loading = { template: "\n\t
\n\t\t
\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t
\n\t
\n ", data: function data() { return { loading: false }; }, methods: { show: function show() { this.loading = true; }, hide: function hide() { this.loading = false; } }, install: function install(Vue) { var Constructor = Vue.extend(Loading); var instance = new Constructor(); instance.vm = instance.$mount(); document.body.appendChild(instance.vm.$el); Vue.prototype.$loading = instance; } }; /** 网络请求 Http 组件 */ var Http = { install: function install(Vue) { var $loading = Vue.prototype.$loading; var $messages = Vue.prototype.$messages; var loadingCounts = 0; Vue.prototype.$ajax = function (config) { if (loadingCounts == 0) { console.log('显示 loading'); $loading.show(); } loadingCounts++; config.type || (config.type = 'get'); $.ajax(_objectSpread(_objectSpread({}, config), {}, { url: config.url, type: config.type, data: config.type.toLowerCase() == 'get' || config.postFormData ? config.data : JSON.stringify(config.data), dataType: config.dataType || 'json', contentType: config.contentType || 'application/json', success: function success(res) { config.success && config.success(res); }, error: function error(err) { $messages.error("ERROR: ".concat(err.status)); config.error && config.error(err); }, complete: function complete() { loadingCounts--; if (loadingCounts <= 0) { console.log('complete 隐藏 loading'); $loading.hide(); } } })); }; } }; /** Tabs 组件 */ Vue.component("c-tabs", (_Vue$component = { template: "\n
\n
\n \n \n
\n
\n \n
\n
\n ", props: { value: [String, Number] }, data: function data() { return { navList: [], activeKey: this.value, barWidth: 0, barOffset: 0 }; } }, _defineProperty(_Vue$component, "props", { value: [String, Number] }), _defineProperty(_Vue$component, "provide", function provide() { return { TabsInstance: this }; }), _defineProperty(_Vue$component, "watch", { activeKey: function activeKey() { this.updateStatus(); this.updateBar(); } }), _defineProperty(_Vue$component, "computed", { barStyle: function barStyle() { var style = { visibility: 'visible', width: "".concat(this.barWidth, "px") }; style.transform = "translate3d(".concat(this.barOffset, "px, 0px, 0px)"); return style; }, contentStyle: function contentStyle() { var index = this.getTabIndex(this.activeKey); return { 'transform': index > 0 ? "translateX(-".concat(index, "00%)") : '' }; return { 'margin-left': index > 0 ? "-".concat(index, "00%") : 0 }; } }), _defineProperty(_Vue$component, "mounted", function mounted() {}), _defineProperty(_Vue$component, "methods", { handleChange: function handleChange(index) { this.activeKey = this.navList[index].name; var nav = this.navList[index]; this.$emit('tab-click', nav.name); }, tabCls: function tabCls(item) { return ["tab-item-title", _defineProperty({}, "tab-actived", item.name === this.activeKey)]; }, getPanels: function getPanels() { var TabPanels = this.$children.filter(function (item) { return item.$options.name === "TabPanel"; }); TabPanels.sort(function (a, b) { if (a.index && b.index) { return a.index > b.index ? 1 : -1; } }); return TabPanels; }, updateNav: function updateNav() { var _this14 = this; this.navList = []; this.getPanels().forEach(function (panel, index) { _this14.navList.push({ label: panel.label, name: panel.name || index }); if (!panel.currentName) panel.currentName = index; if (index === 0) { if (!_this14.activeKey) _this14.activeKey = panel.currentName || index; } }); this.updateStatus(); this.updateBar(); }, updateBar: function updateBar() { var _this15 = this; this.$nextTick(function () { var index = _this15.getTabIndex(_this15.activeKey); if (!_this15.$refs.nav) return; var prevTabs = _this15.$refs.nav.querySelectorAll('.tab-item-title'); var tab = prevTabs[index]; _this15.barWidth = tab ? parseFloat(tab.offsetWidth) : 0; if (index > 0) { var offset = 0; for (var i = 0; i < index; i++) { offset += prevTabs[i].offsetWidth; } _this15.barOffset = offset; } else { _this15.barOffset = 0; } }); }, getTabIndex: function getTabIndex(name) { return this.navList.findIndex(function (nav) { return nav.name === name; }); }, updateStatus: function updateStatus() { var _this16 = this; var navs = this.getPanels(); navs.forEach(function (tab) { return tab.show = tab.currentName === _this16.activeKey; }); } }), _Vue$component)); Vue.component("c-tab-pannel", { template: "\n
\n \n
\n ", data: function data() { return { show: true, currentName: this.name }; }, name: "TabPanel", props: { label: { type: [String, Function], "default": "" }, name: [String, Number] }, watch: { label: function label() { this.updateNav(); }, name: function name(val) { this.currentName = val; this.updateNav(); } }, inject: ["TabsInstance"], computed: {}, methods: { updateNav: function updateNav() { this.TabsInstance.updateNav(); }, panelCls: function panelCls() { return ["tab-panel-content", _defineProperty({}, 'panel-actived', this.show === true)]; } }, mounted: function mounted() { this.updateNav(); } }); /** Paginate 组件 */ Vue.component("c-paginate", { template: "\n
\n \n
\n ", props: { containerClass: { type: String, "default": 'c-paginate_2' }, total: { type: Number, required: true }, pageSize: { type: Number, "default": 10 } }, beforeUpdate: function beforeUpdate() {}, data: function data() { return { // 自定义组件 curPage: 1, showMax: 2, minPage: null, maxPage: null }; }, computed: { _total: function _total() { return this.total; }, totalPage: function totalPage() { return Math.ceil(this._total / this.pageSize); }, showPre: function showPre() { return this.curPage > 1; }, showNext: function showNext() { return this.curPage < this.totalPage; }, pages: function pages() { var _this17 = this; var pages = []; var setItem = function setItem(pageNo) { return { pageNo: pageNo, show: pageNo >= _this17.minPage && pageNo <= _this17.maxPage, selected: pageNo === _this17.curPage }; }; for (var index = 1; index <= this.totalPage; index++) { pages.push(setItem(index)); } return pages; }, pagesShow: function pagesShow() { return this.pages.filter(function (page) { return page.show; }); } }, created: function created() { this.init(); }, mounted: function mounted() { this.appMounted = true; }, methods: { init: function init() { this.curPage = 1; this.minPage = this.curPage; this.maxPage = this.curPage + this.showMax - 1; }, goToPage: function goToPage(pageNo) { if (this.curPage == pageNo) return; this.curPage = pageNo; if (pageNo == 1) { this.minPage = 1; this.maxPage = 1 + this.showMax - 1; } if (pageNo == this.totalPage) { this.minPage = this.totalPage - this.showMax + 1; this.maxPage = this.totalPage; } this.$emit('change', this.curPage); }, onPrev: function onPrev() { if (this.curPage == 1) return; this.curPage--; if (this.curPage < this.minPage) { this.minPage--; this.maxPage--; } this.$emit('change', this.curPage); }, onNext: function onNext() { if (this.curPage == this.totalPage) return; this.curPage++; if (this.curPage > this.maxPage) { this.minPage++; this.maxPage++; } this.$emit('change', this.curPage); }, onSelect: function onSelect(page) { if (this.curPage == page.pageNo) return; this.curPage = page.pageNo; this.$emit('change', this.curPage); } } }); /** Paginate 组件 2 */ Vue.component("c-paginate2", { template: "\n
\n \n 1\"\n @click=\"onFirst\"\n :class=\"{ active: pageNo == 1 }\"\n >\n 1\n \n \n \n \n = startNumAndEndNum.start\"\n @click=\"onClick(page)\"\n :class=\"{ active: pageNo == page }\"\n >\n {{ page }}\n \n \n \n \n {{ totalPage }}\n \n \n \u4E0B\u4E00\u9875\n \n \n \n
\n ", props: { pageNo: { type: Number }, continues: { type: Number }, total: { type: Number }, pageSize: { type: Number, "default": 10 } }, computed: { // *计算总共多少页,也就是最后一页(需要向上取整Math.ceil) totalPage: function totalPage() { return Math.ceil(this.total / this.pageSize); }, // *计算出连续页码的起始数字与结束的数字【连续的页码数字:至少是5】 startNumAndEndNum: function startNumAndEndNum() { var continues = this.continues, pageNo = this.pageNo, totalPage = this.totalPage; // 解构了 // 先定义两个变量存储起始数字与结束数字 var start = 0, end = 0; // *连续页码数字是5【至少5页】,如果出现不正常现象【不够5页,即总页数 < 连续页码5】 if (continues > totalPage) { start = 1; end = totalPage; } else { // 正常现象【连续的页码5,但是你的总页数一定是大于5的】 parseInt()返回一个十进制的整数【一个数字的参数可同Math.floor】 start = pageNo - parseInt(continues / 2); end = pageNo + parseInt(continues / 2); // 把出现不正常的现象【start数字出现0|负数,continues=5,pageNo=1、2的时候】 if (start < 1) { start = 1; end = continues; } // 把出现不正常的现象【end数字大于总页码,continues=5,totalPage=30,pageNo=29、30的时候】 if (end > totalPage) { start = totalPage - continues + 1; end = totalPage; } } return { start: start, end: end }; } }, methods: { onPrev: function onPrev() { this.$emit('change', this.pageNo - 1); }, onFirst: function onFirst() { this.$emit('change', 1); }, onNext: function onNext() { this.$emit('change', this.pageNo + 1); }, onClick: function onClick(page) { this.$emit('change', page); }, onLast: function onLast() { this.$emit('change', this.totalPage); } } }); Vue.use(Alert); Vue.use(Message); Vue.use(Loading); Vue.use(Http);