n20-common-lib 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +24 -0
  2. package/package.json +120 -0
  3. package/src/assets/css/_coreLib.scss +26 -0
  4. package/src/assets/css/cl-approve-card.scss +66 -0
  5. package/src/assets/css/cl-drag-list.scss +22 -0
  6. package/src/assets/css/cl-empty.scss +10 -0
  7. package/src/assets/css/cl-expandable.scss +31 -0
  8. package/src/assets/css/cl-file-upload-table.scss +11 -0
  9. package/src/assets/css/cl-filter.scss +20 -0
  10. package/src/assets/css/cl-foldedpanel.scss +35 -0
  11. package/src/assets/css/cl-footer-box.scss +8 -0
  12. package/src/assets/css/cl-form-item.scss +281 -0
  13. package/src/assets/css/cl-more-tab.scss +98 -0
  14. package/src/assets/css/cl-nav-menu.scss +5 -0
  15. package/src/assets/css/cl-pagination.scss +71 -0
  16. package/src/assets/css/cl-secondary-tab.scss +30 -0
  17. package/src/assets/css/cl-sifting.scss +51 -0
  18. package/src/assets/css/cl-statis.scss +14 -0
  19. package/src/assets/css/cl-step.scss +164 -0
  20. package/src/assets/css/cl-suspend.scss +25 -0
  21. package/src/assets/css/cl-tertiary-tab.scss +37 -0
  22. package/src/assets/css/cl-upload.scss +41 -0
  23. package/src/assets/css/cl-worn-pagination.scss +50 -0
  24. package/src/assets/css/element-variables.scss +1053 -0
  25. package/src/assets/css/element.dev.scss +5 -0
  26. package/src/assets/css/font-icon.scss +22 -0
  27. package/src/assets/css/index.dev.scss +3 -0
  28. package/src/assets/css/index.scss +8 -0
  29. package/src/assets/css/normalize.scss +243 -0
  30. package/src/assets/css/rootvar.scss +66 -0
  31. package/src/assets/css/title-pop.scss +4 -0
  32. package/src/assets/getJsonc.js +51 -0
  33. package/src/assets/postMessage.js +2 -0
  34. package/src/assets/postMessageC.js +37 -0
  35. package/src/components/ApproveCard/index.vue +83 -0
  36. package/src/components/DatePicker/index.vue +22 -0
  37. package/src/components/Dialog/index.vue +115 -0
  38. package/src/components/DragList/index.vue +64 -0
  39. package/src/components/Empty/img/404.png +0 -0
  40. package/src/components/Empty/img/abnormal.svg +109 -0
  41. package/src/components/Empty/img/dispose.svg +72 -0
  42. package/src/components/Empty/img/empty.svg +58 -0
  43. package/src/components/Empty/img/general.svg +59 -0
  44. package/src/components/Empty/img/lock.svg +58 -0
  45. package/src/components/Empty/img/network.svg +60 -0
  46. package/src/components/Empty/img/relevant.svg +69 -0
  47. package/src/components/Empty/img/search.svg +73 -0
  48. package/src/components/Empty/index.vue +92 -0
  49. package/src/components/Expandable/index.vue +47 -0
  50. package/src/components/FileUploadTable/index.vue +456 -0
  51. package/src/components/Filters/index.vue +77 -0
  52. package/src/components/FoldedPanel/index.vue +64 -0
  53. package/src/components/FooterBox/index.vue +18 -0
  54. package/src/components/InputNumber/index.vue +126 -0
  55. package/src/components/MoreTab/index.vue +232 -0
  56. package/src/components/NavMenu/index.vue +90 -0
  57. package/src/components/Pagination/index.vue +126 -0
  58. package/src/components/SecondaryTab/index.vue +75 -0
  59. package/src/components/Select/index.vue +51 -0
  60. package/src/components/Sifting/index.vue +97 -0
  61. package/src/components/Statis/index.vue +55 -0
  62. package/src/components/Step/index.vue +65 -0
  63. package/src/components/Suspend/index.vue +63 -0
  64. package/src/components/Suspend/suspensionBtn.png +0 -0
  65. package/src/components/TertiaryTab/index.vue +49 -0
  66. package/src/components/TimePicker/index.vue +22 -0
  67. package/src/components/Upload/index.vue +237 -0
  68. package/src/components/WornPagination/index.vue +202 -0
  69. package/src/directives/VMove/index.js +42 -0
  70. package/src/directives/VTitle/index.js +55 -0
  71. package/src/directives/VTitle/tooltip.vue +21 -0
  72. package/src/directives/vDrag/index.js +72 -0
  73. package/src/index.js +111 -0
  74. package/src/utils/auth.js +41 -0
  75. package/src/utils/axios.js +180 -0
  76. package/src/utils/print.js +156 -0
  77. package/src/utils/pushLink.js +5 -0
  78. package/style/css/normalize.scss +243 -0
  79. package/style/fonts/element-icons.535877f5.woff +0 -0
  80. package/style/fonts/element-icons.732389de.ttf +0 -0
  81. package/style/index.css +3 -0
  82. package/style/index.css.map +1 -0
  83. package/style/index.umd.min.js +2 -0
  84. package/style/index.umd.min.js.map +1 -0
  85. package/style/server-config.jsonc +212 -0
@@ -0,0 +1,180 @@
1
+ import _axios from 'axios'
2
+ import ElementUI from 'element-ui'
3
+ import auth from './auth'
4
+ const _Loading = ElementUI.Loading
5
+ const _Message = ElementUI.Message
6
+
7
+ /* 添加msg */
8
+ function showMsg(msg, single = true) {
9
+ if (!single || !document.querySelector('xhr-msg-top')) {
10
+ _Message({
11
+ showClose: true,
12
+ message: msg,
13
+ type: 'error',
14
+ customClass: 'xhr-msg-top'
15
+ })
16
+ }
17
+ }
18
+ /* 添加loading */
19
+ let loadingBox
20
+ let loadingCount = 0
21
+ function showLoading(opt) {
22
+ let loading = opt.loading
23
+ if (loading === true) {
24
+ if (loadingCount === 0 && !document.querySelector('xhr-loading-top')) {
25
+ loadingBox = _Loading.service({
26
+ lock: true,
27
+ text: '加载中',
28
+ spinner: 'el-icon-loading',
29
+ background: 'rgba(0, 0, 0, 0.3)',
30
+ customClass: 'xhr-loading-top'
31
+ })
32
+ }
33
+ loadingCount++
34
+ }
35
+ }
36
+ function closeLoading(opt) {
37
+ let loading = opt.loading
38
+ if (loading === true) {
39
+ loadingCount--
40
+ if (loadingCount === 0) {
41
+ if (loadingBox) loadingBox.close()
42
+ }
43
+ } else if (typeof loading === 'function') {
44
+ loading()
45
+ }
46
+ }
47
+ /* 请求防抖 */
48
+ let debounceObj = {}
49
+
50
+ const config = {
51
+ baseURL: process.env.VUE_APP_BASE_API || '',
52
+ crossDomain: true, // 允许跨域
53
+ // withCredentials: true, // 跨域携带cookie
54
+ timeout: 120000,
55
+ validateStatus(status) {
56
+ return status >= 200 && status < 500
57
+ }
58
+ }
59
+ const axios = _axios.create(config)
60
+
61
+ axios.interceptors.request.use((opt) => {
62
+ opt.headers || (opt.headers = {})
63
+
64
+ let headers = {
65
+ Authorization: auth.getToken() ? 'Bearer ' + auth.getToken() : null,
66
+ timestamp: Date.now(),
67
+ OperationDesc: opt.OperationDesc ? encodeURI(opt.OperationDesc) : 'default'
68
+ }
69
+ Object.assign(opt.headers, headers)
70
+
71
+ return opt
72
+ })
73
+
74
+ axios.interceptors.response.use(
75
+ (res) => {
76
+ let status, msg
77
+ if (res.data) {
78
+ status = res.data.code || res.status
79
+ }
80
+ if (status === 200) {
81
+ return res
82
+ } else {
83
+ if (res.data) {
84
+ msg = res.data.msg || res.data.message
85
+ }
86
+ let noMsg = res.config.noMsg
87
+
88
+ if (status === 401 || msg.includes('401')) {
89
+ noMsg || showMsg('超时未操作,请重新登录!')
90
+ setTimeout(() => {
91
+ auth.removeToken()
92
+ }, 1000)
93
+ } else {
94
+ if (status >= 900) {
95
+ noMsg || showMsg(msg)
96
+ } else if (status === 400) {
97
+ noMsg || showMsg(msg)
98
+ } else if (msg.includes('400')) {
99
+ noMsg || showMsg('400,参数错误!')
100
+ } else if (msg.includes('404')) {
101
+ noMsg || showMsg('404,网络连接失败!')
102
+ } else if (msg.includes('500')) {
103
+ noMsg || showMsg('500,服务器链接失败!')
104
+ }
105
+
106
+ throw { code: status, msg: msg }
107
+ }
108
+ }
109
+ },
110
+ (err) => {
111
+ let status = err.status
112
+ let msg = err.message
113
+ let noMsg = err.config.noMsg
114
+
115
+ if (status === 'ECONNABORTED' && msg.includes('timeout')) {
116
+ noMsg || showMsg('请求超时')
117
+ } else if (status === 400) {
118
+ noMsg || showMsg(msg)
119
+ } else if (msg.includes('400')) {
120
+ noMsg || showMsg('400,参数错误!')
121
+ } else if (msg.includes('404')) {
122
+ noMsg || showMsg('404,网络连接失败!')
123
+ } else if (msg.includes('500')) {
124
+ noMsg || showMsg('500,服务器链接失败!')
125
+ } else {
126
+ noMsg || showMsg(msg)
127
+ }
128
+ throw { code: status, msg: msg }
129
+ }
130
+ )
131
+
132
+ function request(opt) {
133
+ if (debounceObj[opt.method + opt.url]) {
134
+ return debounceObj[opt.method + opt.url] // 短时间多次请求,均返回第一次请求结果
135
+ }
136
+ let loading = opt.loading === undefined ? true : opt.loading
137
+ showLoading({ loading })
138
+
139
+ let resPro = new Promise((resolve, reject) => {
140
+ axios
141
+ .request(opt)
142
+ .then((res) => {
143
+ if (opt.responseType !== 'blob' && typeof res.data === 'object' && res.data.data === undefined) {
144
+ res.data.data = {}
145
+ }
146
+ resolve(res.data)
147
+ })
148
+ .catch((error) => {
149
+ reject(error)
150
+ })
151
+ })
152
+
153
+ resPro.finally(() => {
154
+ delete debounceObj[opt.method + opt.url]
155
+
156
+ closeLoading({ loading })
157
+ })
158
+ debounceObj[opt.method + opt.url] = resPro
159
+ return resPro
160
+ }
161
+
162
+ // 自定义axios
163
+ function customAxios(opt) {
164
+ return request(opt)
165
+ }
166
+ customAxios.request = request
167
+ customAxios.get = function(url, params = {}, opt = {}) {
168
+ return request(Object.assign({ method: 'get', url, params }, opt))
169
+ }
170
+ customAxios.post = function(url, data = {}, opt = {}) {
171
+ return request(Object.assign({ method: 'post', url, data }, opt))
172
+ }
173
+ customAxios.put = function(url, data = {}, params = {}, opt = {}) {
174
+ return this.request(Object.assign({ method: 'put', url, data, params }, opt))
175
+ }
176
+ customAxios.delete = function(url, params = {}, opt = {}) {
177
+ return this.request(Object.assign({ method: 'delete', url, params }, opt))
178
+ }
179
+
180
+ export default customAxios
@@ -0,0 +1,156 @@
1
+ // 打印类属性、方法定义
2
+ /* eslint-disable */
3
+ const Print = function (dom, options) {
4
+ if (!(this instanceof Print)) return new Print(dom, options);
5
+
6
+ this.options = this.extend({
7
+ 'noPrint': '.no-print'
8
+ }, options);
9
+
10
+ if ((typeof dom) === "string") {
11
+ this.dom = document.querySelector(dom);
12
+ } else {
13
+ this.isDOM(dom)
14
+ this.dom = this.isDOM(dom) ? dom : dom.$el;
15
+ }
16
+ this.init();
17
+ };
18
+ Print.prototype = {
19
+ init: function () {
20
+ var content = this.getStyle() + this.getHtml();
21
+ this.writeIframe(content);
22
+ },
23
+ extend: function (obj, obj2) {
24
+ for (var k in obj2) {
25
+ obj[k] = obj2[k];
26
+ }
27
+ return obj;
28
+ },
29
+
30
+ getStyle: function () {
31
+ var str = "",
32
+ styles = document.querySelectorAll('style,link');
33
+ for (var i = 0; i < styles.length; i++) {
34
+ str += styles[i].outerHTML;
35
+ }
36
+ str += "<style>" + (this.options.noPrint ? this.options.noPrint : '.no-print') + "{display:none;}</style>";
37
+
38
+ return str;
39
+ },
40
+
41
+ getHtml: function () {
42
+ var inputs = document.querySelectorAll('input');
43
+ var textareas = document.querySelectorAll('textarea');
44
+ var selects = document.querySelectorAll('select');
45
+
46
+ for (var k = 0; k < inputs.length; k++) {
47
+ if (inputs[k].type == "checkbox" || inputs[k].type == "radio") {
48
+ if (inputs[k].checked == true) {
49
+ inputs[k].setAttribute('checked', "checked")
50
+ } else {
51
+ inputs[k].removeAttribute('checked')
52
+ }
53
+ } else if (inputs[k].type == "text") {
54
+ inputs[k].setAttribute('value', inputs[k].value)
55
+ } else {
56
+ inputs[k].setAttribute('value', inputs[k].value)
57
+ }
58
+ }
59
+
60
+ for (var k2 = 0; k2 < textareas.length; k2++) {
61
+ if (textareas[k2].type == 'textarea') {
62
+ textareas[k2].innerHTML = textareas[k2].value
63
+ }
64
+ }
65
+
66
+ for (var k3 = 0; k3 < selects.length; k3++) {
67
+ if (selects[k3].type == 'select-one') {
68
+ var child = selects[k3].children;
69
+ for (var i in child) {
70
+ if (child[i].tagName == 'OPTION') {
71
+ if (child[i].selected == true) {
72
+ child[i].setAttribute('selected', "selected")
73
+ } else {
74
+ child[i].removeAttribute('selected')
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ // 包裹要打印的元素
81
+ let outerHTML = this.wrapperRefDom(this.dom).outerHTML
82
+ return outerHTML;
83
+ },
84
+ // 向父级元素循环,包裹当前需要打印的元素
85
+ // 防止根级别开头的 css 选择器不生效
86
+ wrapperRefDom: function (refDom) {
87
+ let prevDom = null
88
+ let currDom = refDom
89
+ // 判断当前元素是否在 body 中,不在文档中则直接返回该节点
90
+ if (!this.isInBody(currDom)) return currDom
91
+
92
+ while (currDom) {
93
+ if (prevDom) {
94
+ let element = currDom.cloneNode(false)
95
+ element.appendChild(prevDom)
96
+ prevDom = element
97
+ } else {
98
+ prevDom = currDom.cloneNode(true)
99
+ }
100
+
101
+ currDom = currDom.parentElement
102
+ }
103
+
104
+ return prevDom
105
+ },
106
+
107
+ writeIframe: function (content) {
108
+ var w, doc, iframe = document.createElement('iframe'),
109
+ f = document.body.appendChild(iframe);
110
+ iframe.id = "myIframe";
111
+ //iframe.style = "position:absolute;width:0;height:0;top:-10px;left:-10px;";
112
+ iframe.setAttribute('style', 'position:absolute;width:0;height:0;top:-10px;left:-10px;');
113
+ w = f.contentWindow || f.contentDocument;
114
+ doc = f.contentDocument || f.contentWindow.document;
115
+ doc.open();
116
+ doc.write(content);
117
+ doc.close();
118
+ var _this = this
119
+ iframe.onload = function () {
120
+ _this.toPrint(w);
121
+ setTimeout(function () {
122
+ document.body.removeChild(iframe)
123
+ }, 100)
124
+ }
125
+ },
126
+
127
+ toPrint: function (frameWindow) {
128
+ try {
129
+ setTimeout(function () {
130
+ frameWindow.focus();
131
+ try {
132
+ if (!frameWindow.document.execCommand('print', false, null)) {
133
+ frameWindow.print();
134
+ }
135
+ } catch (e) {
136
+ frameWindow.print();
137
+ }
138
+ frameWindow.close();
139
+ }, 10);
140
+ } catch (err) {
141
+ console.log('err', err);
142
+ }
143
+ },
144
+ // 检查一个元素是否是 body 元素的后代元素且非 body 元素本身
145
+ isInBody: function (node) {
146
+ return (node === document.body) ? false : document.body.contains(node);
147
+ },
148
+ isDOM: (typeof HTMLElement === 'object') ?
149
+ function (obj) {
150
+ return obj instanceof HTMLElement;
151
+ } :
152
+ function (obj) {
153
+ return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';
154
+ }
155
+ };
156
+ export default Print;
@@ -0,0 +1,5 @@
1
+ export default function pushLink(el) {
2
+ let href = el.currentTarget.getAttribute('href')
3
+ history.pushState('', '', href)
4
+ el.preventDefault()
5
+ }
@@ -0,0 +1,243 @@
1
+ $--font-size-base: 14px !default;
2
+ $--border-color-base: #dcdfe6 !default;
3
+
4
+ body {
5
+ font-size: $--font-size-base;
6
+ }
7
+ li {
8
+ list-style: none;
9
+ }
10
+ iframe {
11
+ border: 0;
12
+ outline: none;
13
+ }
14
+
15
+ /* 菜单滚动条 */
16
+ ::-webkit-scrollbar {
17
+ width: 6px;
18
+ height: 8px;
19
+ }
20
+
21
+ ::-webkit-scrollbar-track,
22
+ ::-webkit-scrollbar-corner {
23
+ background: transparent;
24
+ }
25
+
26
+ ::-webkit-scrollbar-thumb {
27
+ border-radius: 5px;
28
+ width: 6px;
29
+ background-color: #d3d9e6;
30
+ }
31
+
32
+ ::-webkit-scrollbar-track-piece {
33
+ width: 6px;
34
+ }
35
+
36
+ @mixin set-pm($m, $p) {
37
+ .p-a#{$m} {
38
+ padding: $p;
39
+ }
40
+
41
+ .p-t#{$m} {
42
+ padding-top: $p;
43
+ }
44
+
45
+ .p-b#{$m} {
46
+ padding-bottom: $p;
47
+ }
48
+
49
+ .p-l#{$m} {
50
+ padding-left: $p;
51
+ }
52
+
53
+ .p-r#{$m} {
54
+ padding-right: $p;
55
+ }
56
+
57
+ .m-a#{$m} {
58
+ margin: $p;
59
+ }
60
+
61
+ .m-t#{$m} {
62
+ margin-top: $p;
63
+ }
64
+
65
+ .m-b#{$m} {
66
+ margin-bottom: $p;
67
+ }
68
+
69
+ .m-l#{$m} {
70
+ margin-left: $p;
71
+ }
72
+
73
+ .m-r#{$m} {
74
+ margin-right: $p;
75
+ }
76
+ }
77
+
78
+ /* 内外边距 */
79
+ @include set-pm('', 16px !important);
80
+ @include set-pm('-xl', 32px !important);
81
+ @include set-pm('-lg', 24px !important);
82
+ @include set-pm('-m', 16px !important);
83
+ @include set-pm('-s', 8px !important);
84
+ @include set-pm('-0', 0 !important);
85
+
86
+ /* 浮动布局 */
87
+ .left,
88
+ .float-left {
89
+ float: left;
90
+ }
91
+
92
+ .right,
93
+ .float-right {
94
+ float: right;
95
+ }
96
+
97
+ .overflow {
98
+ height: auto;
99
+ overflow: hidden;
100
+ }
101
+
102
+ .overflow-clear {
103
+ &:after {
104
+ content: '';
105
+ display: block;
106
+ clear: both;
107
+ }
108
+ }
109
+
110
+ /* 行内块元素水平垂直对齐方式 */
111
+ .b-center {
112
+ text-align: center;
113
+ & > * {
114
+ display: inline-block;
115
+ vertical-align: bottom;
116
+ }
117
+ }
118
+
119
+ .b-vertical {
120
+ font-size: 0;
121
+ & > * {
122
+ vertical-align: middle;
123
+ display: inline-block;
124
+ font-size: 14px;
125
+ }
126
+ &:before {
127
+ content: '';
128
+ vertical-align: middle;
129
+ display: inline-block;
130
+ width: 0px;
131
+ height: 100%;
132
+ }
133
+ }
134
+
135
+ /* 文字居中 */
136
+ .text {
137
+ &-c {
138
+ text-align: center !important;
139
+ }
140
+ &-l {
141
+ text-align: left !important;
142
+ }
143
+ &-r {
144
+ text-align: right !important;
145
+ }
146
+ &-lr {
147
+ text-align: justify;
148
+ text-justify: inter-word;
149
+ }
150
+ }
151
+
152
+ /* 弹性盒模型 */
153
+ .flex {
154
+ &-box {
155
+ display: flex;
156
+ }
157
+ &-column {
158
+ display: flex;
159
+ flex-direction: column;
160
+ }
161
+ > * {
162
+ flex: none;
163
+ }
164
+ &-v {
165
+ align-items: center;
166
+ }
167
+ &-l {
168
+ justify-content: flex-start;
169
+ }
170
+ &-r {
171
+ justify-content: flex-start;
172
+ }
173
+ &-c {
174
+ justify-content: center;
175
+ }
176
+ &-lr {
177
+ justify-content: space-between;
178
+ }
179
+ }
180
+
181
+ .flex-item {
182
+ flex: auto;
183
+ }
184
+ @for $n from 0 to 10 {
185
+ .flex-#{$n} {
186
+ flex: $n $n auto;
187
+ }
188
+ }
189
+
190
+ /* 旋转图标90度 */
191
+ .rotate90 {
192
+ display: inline-block;
193
+ transform: rotate(90deg);
194
+ cursor: pointer;
195
+ }
196
+
197
+ /* 清除背景色 */
198
+ .bg {
199
+ &-none {
200
+ background: none !important;
201
+ }
202
+ }
203
+
204
+ /* 边框 */
205
+ .bd {
206
+ &-none {
207
+ border: none !important;
208
+ }
209
+ &-a {
210
+ border: 1px solid $--border-color-base;
211
+ }
212
+ &-t {
213
+ border-top: 1px solid $--border-color-base;
214
+ }
215
+ &-l {
216
+ border-left: 1px solid $--border-color-base;
217
+ }
218
+ &-r {
219
+ border-right: 1px solid $--border-color-base;
220
+ }
221
+ &-b {
222
+ border-bottom: 1px solid $--border-color-base;
223
+ }
224
+ }
225
+
226
+ /* 设置弹窗内容区内边距 */
227
+ .el-dialog__wrapper {
228
+ &.p-a-0 {
229
+ .el-dialog__body {
230
+ padding: 0;
231
+ }
232
+ }
233
+ &.p-t-0 {
234
+ .el-dialog__body {
235
+ padding-top: 0;
236
+ }
237
+ }
238
+ &.p-b-0 {
239
+ .el-dialog__body {
240
+ padding-bottom: 0;
241
+ }
242
+ }
243
+ }