cc11442b by yuanbo

增加注释

1 parent 90e804ce
1 <!-- 1 <!--
2 * @Description: 2 * @Description:
3 * @Autor: renchao 3 * @Autor: renchao
4 * @LastEditTime: 2023-03-20 16:36:51 4 * @LastEditTime: 2023-03-20 16:36:51
5 --> 5 -->
...@@ -32,6 +32,10 @@ export default { ...@@ -32,6 +32,10 @@ export default {
32 this.getBreadcrumb(); 32 this.getBreadcrumb();
33 }, 33 },
34 methods: { 34 methods: {
35 /**
36 * @description: getBreadcrumb
37 * @author: renchao
38 */
35 getBreadcrumb () { 39 getBreadcrumb () {
36 // only show routes with meta.title 40 // only show routes with meta.title
37 this.levelList = this.$route.matched.filter( 41 this.levelList = this.$route.matched.filter(
...@@ -41,6 +45,11 @@ export default { ...@@ -41,6 +45,11 @@ export default {
41 this.levelList = this.levelList.slice(-1) 45 this.levelList = this.levelList.slice(-1)
42 } 46 }
43 }, 47 },
48 /**
49 * @description: isDashboard
50 * @param {*} route
51 * @author: renchao
52 */
44 isDashboard (route) { 53 isDashboard (route) {
45 const name = route && route.name; 54 const name = route && route.name;
46 if (!name) { 55 if (!name) {
...@@ -50,6 +59,11 @@ export default { ...@@ -50,6 +59,11 @@ export default {
50 name.trim().toLocaleLowerCase() === "Dashboard".toLocaleLowerCase() 59 name.trim().toLocaleLowerCase() === "Dashboard".toLocaleLowerCase()
51 ); 60 );
52 }, 61 },
62 /**
63 * @description: pathCompile
64 * @param {*} path
65 * @author: renchao
66 */
53 pathCompile (path) { 67 pathCompile (path) {
54 const { params } = this.$route; 68 const { params } = this.$route;
55 var toPath = pathToRegexp.compile(path); 69 var toPath = pathToRegexp.compile(path);
...@@ -57,4 +71,4 @@ export default { ...@@ -57,4 +71,4 @@ export default {
57 } 71 }
58 } 72 }
59 } 73 }
60 </script>
...\ No newline at end of file ...\ No newline at end of file
74 </script>
......
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
25 } 25 }
26 }, 26 },
27 methods: { 27 methods: {
28 /**
29 * @description: handleClick
30 * @param {*} evt
31 * @author: renchao
32 */
28 handleClick (evt) { 33 handleClick (evt) {
29 this.$emit('click', evt); 34 this.$emit('click', evt);
30 } 35 }
......
...@@ -52,6 +52,10 @@ export default { ...@@ -52,6 +52,10 @@ export default {
52 LbRender 52 LbRender
53 }, 53 },
54 methods: { 54 methods: {
55 /**
56 * @description: setColumn
57 * @author: renchao
58 */
55 setColumn () { 59 setColumn () {
56 if (this.column.type) { 60 if (this.column.type) {
57 this.column.renderHeader = forced[this.column.type].renderHeader 61 this.column.renderHeader = forced[this.column.type].renderHeader
......
1 import service from './src/index'; 1 import service from './src/index';
2 2
3 export default { 3 export default {
4 /**
5 * @description: install
6 * @param {*} Vue
7 * @author: renchao
8 */
4 install (Vue) { 9 install (Vue) {
5 Vue.prototype.$loading = service; 10 Vue.prototype.$loading = service;
6 }, 11 },
......
...@@ -20,6 +20,10 @@ let fullscreenLoading; ...@@ -20,6 +20,10 @@ let fullscreenLoading;
20 LoadingConstructor.prototype.originalPosition = ''; 20 LoadingConstructor.prototype.originalPosition = '';
21 LoadingConstructor.prototype.originalOverflow = ''; 21 LoadingConstructor.prototype.originalOverflow = '';
22 22
23 /**
24 * @description: close
25 * @author: renchao
26 */
23 LoadingConstructor.prototype.close = function() { 27 LoadingConstructor.prototype.close = function() {
24 if (this.fullscreen) { 28 if (this.fullscreen) {
25 fullscreenLoading = undefined; 29 fullscreenLoading = undefined;
...@@ -38,6 +42,13 @@ LoadingConstructor.prototype.close = function() { ...@@ -38,6 +42,13 @@ LoadingConstructor.prototype.close = function() {
38 this.visible = false; 42 this.visible = false;
39 }; 43 };
40 44
45 /**
46 * @description: addStyle
47 * @param {*} options
48 * @param {*} parent
49 * @param {*} instance
50 * @author: renchao
51 */
41 const addStyle = (options, parent, instance) => { 52 const addStyle = (options, parent, instance) => {
42 let maskStyle = {}; 53 let maskStyle = {};
43 if (options.fullscreen) { 54 if (options.fullscreen) {
...@@ -64,6 +75,11 @@ const addStyle = (options, parent, instance) => { ...@@ -64,6 +75,11 @@ const addStyle = (options, parent, instance) => {
64 }); 75 });
65 }; 76 };
66 77
78 /**
79 * @description: Loading
80 * @param {*} options
81 * @author: renchao
82 */
67 const Loading = (options = {}) => { 83 const Loading = (options = {}) => {
68 if (Vue.prototype.$isServer) return; 84 if (Vue.prototype.$isServer) return;
69 options = merge({}, defaults, options); 85 options = merge({}, defaults, options);
......
...@@ -28,9 +28,18 @@ export default { ...@@ -28,9 +28,18 @@ export default {
28 }, 28 },
29 29
30 methods: { 30 methods: {
31 /**
32 * @description: handleAfterLeave
33 * @author: renchao
34 */
31 handleAfterLeave () { 35 handleAfterLeave () {
32 this.$emit('after-leave'); 36 this.$emit('after-leave');
33 }, 37 },
38 /**
39 * @description: setText
40 * @param {*} text
41 * @author: renchao
42 */
34 setText (text) { 43 setText (text) {
35 this.text = text; 44 this.text = text;
36 } 45 }
...@@ -46,4 +55,4 @@ export default { ...@@ -46,4 +55,4 @@ export default {
46 height: 80px; 55 height: 80px;
47 } 56 }
48 } 57 }
49 </style>
...\ No newline at end of file ...\ No newline at end of file
58 </style>
......
...@@ -43,6 +43,10 @@ const MessageBoxConstructor = Vue.extend(msgboxVue); ...@@ -43,6 +43,10 @@ const MessageBoxConstructor = Vue.extend(msgboxVue);
43 let currentMsg, instance; 43 let currentMsg, instance;
44 let msgQueue = []; 44 let msgQueue = [];
45 45
46 /**
47 * @description: defaultCallback
48 * @author: renchao
49 */
46 const defaultCallback = action => { 50 const defaultCallback = action => {
47 if (currentMsg) { 51 if (currentMsg) {
48 let callback = currentMsg.callback; 52 let callback = currentMsg.callback;
...@@ -56,6 +60,10 @@ const defaultCallback = action => { ...@@ -56,6 +60,10 @@ const defaultCallback = action => {
56 } 60 }
57 }; 61 };
58 62
63 /**
64 * @description: initInstance
65 * @author: renchao
66 */
59 const initInstance = () => { 67 const initInstance = () => {
60 instance = new MessageBoxConstructor({ 68 instance = new MessageBoxConstructor({
61 el: document.createElement('div') 69 el: document.createElement('div')
...@@ -64,6 +72,10 @@ const initInstance = () => { ...@@ -64,6 +72,10 @@ const initInstance = () => {
64 instance.callback = defaultCallback; 72 instance.callback = defaultCallback;
65 }; 73 };
66 74
75 /**
76 * @description: showNextMsg
77 * @author: renchao
78 */
67 const showNextMsg = () => { 79 const showNextMsg = () => {
68 if (!instance) { 80 if (!instance) {
69 initInstance(); 81 initInstance();
...@@ -109,6 +121,12 @@ const showNextMsg = () => { ...@@ -109,6 +121,12 @@ const showNextMsg = () => {
109 } 121 }
110 }; 122 };
111 123
124 /**
125 * @description: MessageBox
126 * @param {*} options
127 * @param {*} callback
128 * @author: renchao
129 */
112 const MessageBox = function (options, callback) { 130 const MessageBox = function (options, callback) {
113 if (Vue.prototype.$isServer) return; 131 if (Vue.prototype.$isServer) return;
114 if (typeof options === 'string' || isVNode(options)) { 132 if (typeof options === 'string' || isVNode(options)) {
...@@ -143,10 +161,21 @@ const MessageBox = function (options, callback) { ...@@ -143,10 +161,21 @@ const MessageBox = function (options, callback) {
143 } 161 }
144 }; 162 };
145 163
164 /**
165 * @description: setDefaults
166 * @author: renchao
167 */
146 MessageBox.setDefaults = defaults => { 168 MessageBox.setDefaults = defaults => {
147 MessageBox.defaults = defaults; 169 MessageBox.defaults = defaults;
148 }; 170 };
149 171
172 /**
173 * @description: alert
174 * @param {*} title
175 * @param {*} message
176 * @param {*} options
177 * @author: renchao
178 */
150 MessageBox.alert = (title, message, options) => { 179 MessageBox.alert = (title, message, options) => {
151 if (typeof title === 'object') { 180 if (typeof title === 'object') {
152 options = title; 181 options = title;
...@@ -163,6 +192,10 @@ MessageBox.alert = (title, message, options) => { ...@@ -163,6 +192,10 @@ MessageBox.alert = (title, message, options) => {
163 }, options)); 192 }, options));
164 }; 193 };
165 194
195 /**
196 * @description: close
197 * @author: renchao
198 */
166 MessageBox.close = () => { 199 MessageBox.close = () => {
167 instance.doClose(); 200 instance.doClose();
168 instance.visible = false; 201 instance.visible = false;
......
...@@ -97,6 +97,10 @@ export default { ...@@ -97,6 +97,10 @@ export default {
97 }, 97 },
98 98
99 methods: { 99 methods: {
100 /**
101 * @description: getSafeClose
102 * @author: renchao
103 */
100 getSafeClose () { 104 getSafeClose () {
101 const currentId = this.uid; 105 const currentId = this.uid;
102 return () => { 106 return () => {
...@@ -105,6 +109,10 @@ export default { ...@@ -105,6 +109,10 @@ export default {
105 }); 109 });
106 }; 110 };
107 }, 111 },
112 /**
113 * @description: doClose
114 * @author: renchao
115 */
108 doClose () { 116 doClose () {
109 if (!this.visible) return; 117 if (!this.visible) return;
110 this.visible = false; 118 this.visible = false;
...@@ -122,18 +130,31 @@ export default { ...@@ -122,18 +130,31 @@ export default {
122 }); 130 });
123 }, 131 },
124 132
133 /**
134 * @description: handleWrapperClick
135 * @author: renchao
136 */
125 handleWrapperClick () { 137 handleWrapperClick () {
126 if (this.closeOnClickModal) { 138 if (this.closeOnClickModal) {
127 this.handleAction(this.distinguishCancelAndClose ? 'close' : 'cancel'); 139 this.handleAction(this.distinguishCancelAndClose ? 'close' : 'cancel');
128 } 140 }
129 }, 141 },
130 142
143 /**
144 * @description: handleInputEnter
145 * @author: renchao
146 */
131 handleInputEnter () { 147 handleInputEnter () {
132 if (this.inputType !== 'textarea') { 148 if (this.inputType !== 'textarea') {
133 return this.handleAction('confirm'); 149 return this.handleAction('confirm');
134 } 150 }
135 }, 151 },
136 152
153 /**
154 * @description: handleAction
155 * @param {*} action
156 * @author: renchao
157 */
137 handleAction (action) { 158 handleAction (action) {
138 if (this.$type === 'prompt' && action === 'confirm' && !this.validate()) { 159 if (this.$type === 'prompt' && action === 'confirm' && !this.validate()) {
139 return; 160 return;
...@@ -147,6 +168,10 @@ export default { ...@@ -147,6 +168,10 @@ export default {
147 } 168 }
148 }, 169 },
149 170
171 /**
172 * @description: validate
173 * @author: renchao
174 */
150 validate () { 175 validate () {
151 if (this.$type === 'prompt') { 176 if (this.$type === 'prompt') {
152 const inputPattern = this.inputPattern; 177 const inputPattern = this.inputPattern;
...@@ -174,15 +199,27 @@ export default { ...@@ -174,15 +199,27 @@ export default {
174 removeClass(this.getInputElement(), 'invalid'); 199 removeClass(this.getInputElement(), 'invalid');
175 return true; 200 return true;
176 }, 201 },
202 /**
203 * @description: getFirstFocus
204 * @author: renchao
205 */
177 getFirstFocus () { 206 getFirstFocus () {
178 const btn = this.$el.querySelector('.el-message-box__btns .el-button'); 207 const btn = this.$el.querySelector('.el-message-box__btns .el-button');
179 const title = this.$el.querySelector('.el-message-box__btns .el-message-box__title'); 208 const title = this.$el.querySelector('.el-message-box__btns .el-message-box__title');
180 return btn || title; 209 return btn || title;
181 }, 210 },
211 /**
212 * @description: getInputElement
213 * @author: renchao
214 */
182 getInputElement () { 215 getInputElement () {
183 const inputRefs = this.$refs.input.$refs; 216 const inputRefs = this.$refs.input.$refs;
184 return inputRefs.input || inputRefs.textarea; 217 return inputRefs.input || inputRefs.textarea;
185 }, 218 },
219 /**
220 * @description: handleClose
221 * @author: renchao
222 */
186 handleClose () { 223 handleClose () {
187 this.handleAction('close'); 224 this.handleAction('close');
188 } 225 }
...@@ -294,4 +331,4 @@ export default { ...@@ -294,4 +331,4 @@ export default {
294 /deep/.el-message-box__content { 331 /deep/.el-message-box__content {
295 padding-top: 0; 332 padding-top: 0;
296 } 333 }
297 </style>
...\ No newline at end of file ...\ No newline at end of file
334 </style>
......
...@@ -3,6 +3,10 @@ import Popup from './index.vue' ...@@ -3,6 +3,10 @@ import Popup from './index.vue'
3 const PopupBox = Vue.extend(Popup) 3 const PopupBox = Vue.extend(Popup)
4 let popuping = undefined 4 let popuping = undefined
5 5
6 /**
7 * @description: close
8 * @author: renchao
9 */
6 PopupBox.prototype.close = function () { 10 PopupBox.prototype.close = function () {
7 // 如果Popup 有引用,则去掉引用 11 // 如果Popup 有引用,则去掉引用
8 if (popuping) { 12 if (popuping) {
...@@ -19,6 +23,14 @@ PopupBox.prototype.close = function () { ...@@ -19,6 +23,14 @@ PopupBox.prototype.close = function () {
19 }, 300) 23 }, 300)
20 } 24 }
21 25
26 /**
27 * @description: Popup1
28 * @param {*} title
29 * @param {*} editItem
30 * @param {*} data
31 * @param {*} formData
32 * @author: renchao
33 */
22 const Popup1 = (title, editItem, data, formData) => { 34 const Popup1 = (title, editItem, data, formData) => {
23 // 如果组件已渲染,则返回即可 35 // 如果组件已渲染,则返回即可
24 if (popuping) { 36 if (popuping) {
......
...@@ -74,9 +74,17 @@ ...@@ -74,9 +74,17 @@
74 }, 300) 74 }, 300)
75 }, 75 },
76 methods: { 76 methods: {
77 /**
78 * @description: onCancel
79 * @author: renchao
80 */
77 onCancel () { 81 onCancel () {
78 Popup1().close() 82 Popup1().close()
79 }, 83 },
84 /**
85 * @description: onConfirm
86 * @author: renchao
87 */
80 onConfirm () { 88 onConfirm () {
81 this.loading = true 89 this.loading = true
82 let res = new Promise((resolve, reject) => { 90 let res = new Promise((resolve, reject) => {
...@@ -87,9 +95,19 @@ ...@@ -87,9 +95,19 @@
87 this.isShow = false 95 this.isShow = false
88 } 96 }
89 }, 97 },
98 /**
99 * @description: loadingFn
100 * @param {*} e
101 * @author: renchao
102 */
90 loadingFn (e) { //加载状态 103 loadingFn (e) { //加载状态
91 this.loading = e 104 this.loading = e
92 }, 105 },
106 /**
107 * @description: loadViewFn
108 * @param {*} view
109 * @author: renchao
110 */
93 loadViewFn (view) { 111 loadViewFn (view) {
94 return (r) => 112 return (r) =>
95 require.ensure([], () => 113 require.ensure([], () =>
......
...@@ -62,10 +62,14 @@ ...@@ -62,10 +62,14 @@
62 } 62 }
63 }, 63 },
64 mounted () { 64 mounted () {
65 this.initHandle() 65 this.initHandle()
66 }, 66 },
67 methods: { 67 methods: {
68 // 初始化值 68 // 初始化值
69 /**
70 * @description: 初始化值
71 * @author: renchao
72 */
69 initHandle () { 73 initHandle () {
70 if (this.valueId && this.options.length!=0) { 74 if (this.valueId && this.options.length!=0) {
71 this.valueTitle = this.$refs.selectTree.getNode(this.valueId).data[ 75 this.valueTitle = this.$refs.selectTree.getNode(this.valueId).data[
...@@ -77,6 +81,10 @@ ...@@ -77,6 +81,10 @@
77 this.initScroll() 81 this.initScroll()
78 }, 82 },
79 // 初始化滚动条 83 // 初始化滚动条
84 /**
85 * @description: 初始化滚动条
86 * @author: renchao
87 */
80 initScroll () { 88 initScroll () {
81 this.$nextTick(() => { 89 this.$nextTick(() => {
82 let scrollWrap = document.querySelectorAll( 90 let scrollWrap = document.querySelectorAll(
...@@ -91,6 +99,11 @@ ...@@ -91,6 +99,11 @@
91 }) 99 })
92 }, 100 },
93 // 切换选项 101 // 切换选项
102 /**
103 * @description: 切换选项
104 * @param {*} node
105 * @author: renchao
106 */
94 handleNodeClick (node) { 107 handleNodeClick (node) {
95 this.valueId = node[this.props.value] 108 this.valueId = node[this.props.value]
96 this.valueTitle = node[this.props.label] 109 this.valueTitle = node[this.props.label]
...@@ -122,6 +135,10 @@ ...@@ -122,6 +135,10 @@
122 // return temp 135 // return temp
123 // }, 136 // },
124 // 清除选中 137 // 清除选中
138 /**
139 * @description: 清除选中
140 * @author: renchao
141 */
125 clearHandle () { 142 clearHandle () {
126 this.valueTitle = '' 143 this.valueTitle = ''
127 this.valueId = null 144 this.valueId = null
...@@ -130,10 +147,20 @@ ...@@ -130,10 +147,20 @@
130 this.$emit('getValue', null) 147 this.$emit('getValue', null)
131 }, 148 },
132 /* 清空选中样式 */ 149 /* 清空选中样式 */
150 /**
151 * @description: 清空选中样式
152 * @author: renchao
153 */
133 clearSelected () { 154 clearSelected () {
134 let allNode = document.querySelectorAll('#tree-option .el-tree-node') 155 let allNode = document.querySelectorAll('#tree-option .el-tree-node')
135 allNode.forEach((element) => element.classList.remove('is-current')) 156 allNode.forEach((element) => element.classList.remove('is-current'))
136 }, 157 },
158 /**
159 * @description: filterNode
160 * @param {*} value
161 * @param {*} data
162 * @author: renchao
163 */
137 filterNode (value, data) { 164 filterNode (value, data) {
138 if (!value) return true 165 if (!value) return true
139 return data.name.indexOf(value) !== -1 166 return data.name.indexOf(value) !== -1
...@@ -181,4 +208,4 @@ ...@@ -181,4 +208,4 @@
181 padding: 0 5px; 208 padding: 0 5px;
182 box-sizing: border-box; 209 box-sizing: border-box;
183 } 210 }
184 </style>
...\ No newline at end of file ...\ No newline at end of file
211 </style>
......