cc11442b by yuanbo

增加注释

1 parent 90e804ce
......@@ -32,6 +32,10 @@ export default {
this.getBreadcrumb();
},
methods: {
/**
* @description: getBreadcrumb
* @author: renchao
*/
getBreadcrumb () {
// only show routes with meta.title
this.levelList = this.$route.matched.filter(
......@@ -41,6 +45,11 @@ export default {
this.levelList = this.levelList.slice(-1)
}
},
/**
* @description: isDashboard
* @param {*} route
* @author: renchao
*/
isDashboard (route) {
const name = route && route.name;
if (!name) {
......@@ -50,6 +59,11 @@ export default {
name.trim().toLocaleLowerCase() === "Dashboard".toLocaleLowerCase()
);
},
/**
* @description: pathCompile
* @param {*} path
* @author: renchao
*/
pathCompile (path) {
const { params } = this.$route;
var toPath = pathToRegexp.compile(path);
......
......@@ -25,6 +25,11 @@
}
},
methods: {
/**
* @description: handleClick
* @param {*} evt
* @author: renchao
*/
handleClick (evt) {
this.$emit('click', evt);
}
......
......@@ -52,6 +52,10 @@ export default {
LbRender
},
methods: {
/**
* @description: setColumn
* @author: renchao
*/
setColumn () {
if (this.column.type) {
this.column.renderHeader = forced[this.column.type].renderHeader
......
import service from './src/index';
export default {
/**
* @description: install
* @param {*} Vue
* @author: renchao
*/
install (Vue) {
Vue.prototype.$loading = service;
},
......
......@@ -20,6 +20,10 @@ let fullscreenLoading;
LoadingConstructor.prototype.originalPosition = '';
LoadingConstructor.prototype.originalOverflow = '';
/**
* @description: close
* @author: renchao
*/
LoadingConstructor.prototype.close = function() {
if (this.fullscreen) {
fullscreenLoading = undefined;
......@@ -38,6 +42,13 @@ LoadingConstructor.prototype.close = function() {
this.visible = false;
};
/**
* @description: addStyle
* @param {*} options
* @param {*} parent
* @param {*} instance
* @author: renchao
*/
const addStyle = (options, parent, instance) => {
let maskStyle = {};
if (options.fullscreen) {
......@@ -64,6 +75,11 @@ const addStyle = (options, parent, instance) => {
});
};
/**
* @description: Loading
* @param {*} options
* @author: renchao
*/
const Loading = (options = {}) => {
if (Vue.prototype.$isServer) return;
options = merge({}, defaults, options);
......
......@@ -28,9 +28,18 @@ export default {
},
methods: {
/**
* @description: handleAfterLeave
* @author: renchao
*/
handleAfterLeave () {
this.$emit('after-leave');
},
/**
* @description: setText
* @param {*} text
* @author: renchao
*/
setText (text) {
this.text = text;
}
......
......@@ -43,6 +43,10 @@ const MessageBoxConstructor = Vue.extend(msgboxVue);
let currentMsg, instance;
let msgQueue = [];
/**
* @description: defaultCallback
* @author: renchao
*/
const defaultCallback = action => {
if (currentMsg) {
let callback = currentMsg.callback;
......@@ -56,6 +60,10 @@ const defaultCallback = action => {
}
};
/**
* @description: initInstance
* @author: renchao
*/
const initInstance = () => {
instance = new MessageBoxConstructor({
el: document.createElement('div')
......@@ -64,6 +72,10 @@ const initInstance = () => {
instance.callback = defaultCallback;
};
/**
* @description: showNextMsg
* @author: renchao
*/
const showNextMsg = () => {
if (!instance) {
initInstance();
......@@ -109,6 +121,12 @@ const showNextMsg = () => {
}
};
/**
* @description: MessageBox
* @param {*} options
* @param {*} callback
* @author: renchao
*/
const MessageBox = function (options, callback) {
if (Vue.prototype.$isServer) return;
if (typeof options === 'string' || isVNode(options)) {
......@@ -143,10 +161,21 @@ const MessageBox = function (options, callback) {
}
};
/**
* @description: setDefaults
* @author: renchao
*/
MessageBox.setDefaults = defaults => {
MessageBox.defaults = defaults;
};
/**
* @description: alert
* @param {*} title
* @param {*} message
* @param {*} options
* @author: renchao
*/
MessageBox.alert = (title, message, options) => {
if (typeof title === 'object') {
options = title;
......@@ -163,6 +192,10 @@ MessageBox.alert = (title, message, options) => {
}, options));
};
/**
* @description: close
* @author: renchao
*/
MessageBox.close = () => {
instance.doClose();
instance.visible = false;
......
......@@ -97,6 +97,10 @@ export default {
},
methods: {
/**
* @description: getSafeClose
* @author: renchao
*/
getSafeClose () {
const currentId = this.uid;
return () => {
......@@ -105,6 +109,10 @@ export default {
});
};
},
/**
* @description: doClose
* @author: renchao
*/
doClose () {
if (!this.visible) return;
this.visible = false;
......@@ -122,18 +130,31 @@ export default {
});
},
/**
* @description: handleWrapperClick
* @author: renchao
*/
handleWrapperClick () {
if (this.closeOnClickModal) {
this.handleAction(this.distinguishCancelAndClose ? 'close' : 'cancel');
}
},
/**
* @description: handleInputEnter
* @author: renchao
*/
handleInputEnter () {
if (this.inputType !== 'textarea') {
return this.handleAction('confirm');
}
},
/**
* @description: handleAction
* @param {*} action
* @author: renchao
*/
handleAction (action) {
if (this.$type === 'prompt' && action === 'confirm' && !this.validate()) {
return;
......@@ -147,6 +168,10 @@ export default {
}
},
/**
* @description: validate
* @author: renchao
*/
validate () {
if (this.$type === 'prompt') {
const inputPattern = this.inputPattern;
......@@ -174,15 +199,27 @@ export default {
removeClass(this.getInputElement(), 'invalid');
return true;
},
/**
* @description: getFirstFocus
* @author: renchao
*/
getFirstFocus () {
const btn = this.$el.querySelector('.el-message-box__btns .el-button');
const title = this.$el.querySelector('.el-message-box__btns .el-message-box__title');
return btn || title;
},
/**
* @description: getInputElement
* @author: renchao
*/
getInputElement () {
const inputRefs = this.$refs.input.$refs;
return inputRefs.input || inputRefs.textarea;
},
/**
* @description: handleClose
* @author: renchao
*/
handleClose () {
this.handleAction('close');
}
......
......@@ -3,6 +3,10 @@ import Popup from './index.vue'
const PopupBox = Vue.extend(Popup)
let popuping = undefined
/**
* @description: close
* @author: renchao
*/
PopupBox.prototype.close = function () {
// 如果Popup 有引用,则去掉引用
if (popuping) {
......@@ -19,6 +23,14 @@ PopupBox.prototype.close = function () {
}, 300)
}
/**
* @description: Popup1
* @param {*} title
* @param {*} editItem
* @param {*} data
* @param {*} formData
* @author: renchao
*/
const Popup1 = (title, editItem, data, formData) => {
// 如果组件已渲染,则返回即可
if (popuping) {
......
......@@ -74,9 +74,17 @@
}, 300)
},
methods: {
/**
* @description: onCancel
* @author: renchao
*/
onCancel () {
Popup1().close()
},
/**
* @description: onConfirm
* @author: renchao
*/
onConfirm () {
this.loading = true
let res = new Promise((resolve, reject) => {
......@@ -87,9 +95,19 @@
this.isShow = false
}
},
/**
* @description: loadingFn
* @param {*} e
* @author: renchao
*/
loadingFn (e) { //加载状态
this.loading = e
},
/**
* @description: loadViewFn
* @param {*} view
* @author: renchao
*/
loadViewFn (view) {
return (r) =>
require.ensure([], () =>
......
......@@ -66,6 +66,10 @@
},
methods: {
// 初始化值
/**
* @description: 初始化值
* @author: renchao
*/
initHandle () {
if (this.valueId && this.options.length!=0) {
this.valueTitle = this.$refs.selectTree.getNode(this.valueId).data[
......@@ -77,6 +81,10 @@
this.initScroll()
},
// 初始化滚动条
/**
* @description: 初始化滚动条
* @author: renchao
*/
initScroll () {
this.$nextTick(() => {
let scrollWrap = document.querySelectorAll(
......@@ -91,6 +99,11 @@
})
},
// 切换选项
/**
* @description: 切换选项
* @param {*} node
* @author: renchao
*/
handleNodeClick (node) {
this.valueId = node[this.props.value]
this.valueTitle = node[this.props.label]
......@@ -122,6 +135,10 @@
// return temp
// },
// 清除选中
/**
* @description: 清除选中
* @author: renchao
*/
clearHandle () {
this.valueTitle = ''
this.valueId = null
......@@ -130,10 +147,20 @@
this.$emit('getValue', null)
},
/* 清空选中样式 */
/**
* @description: 清空选中样式
* @author: renchao
*/
clearSelected () {
let allNode = document.querySelectorAll('#tree-option .el-tree-node')
allNode.forEach((element) => element.classList.remove('is-current'))
},
/**
* @description: filterNode
* @param {*} value
* @param {*} data
* @author: renchao
*/
filterNode (value, data) {
if (!value) return true
return data.name.indexOf(value) !== -1
......