md-iview 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. package/README.md +2 -0
  2. package/package.json +116 -0
  3. package/src/components/libs/util.js +117 -0
  4. package/src/components/md-error-page/403.less +92 -0
  5. package/src/components/md-error-page/403.vue +34 -0
  6. package/src/components/md-error-page/404.less +60 -0
  7. package/src/components/md-error-page/404.vue +34 -0
  8. package/src/components/md-error-page/500.less +73 -0
  9. package/src/components/md-error-page/500.vue +36 -0
  10. package/src/components/md-error-page/demo/index.less +22 -0
  11. package/src/components/md-error-page/demo/index.vue +97 -0
  12. package/src/components/md-form-item/index.js +3 -0
  13. package/src/components/md-icon/icon.vue +77 -0
  14. package/src/components/md-icon/icons.js +5 -0
  15. package/src/components/md-icon/index.js +11 -0
  16. package/src/components/md-icon/style/index.less +1 -0
  17. package/src/components/md-loading/index.js +55 -0
  18. package/src/components/md-loading/index.vue +53 -0
  19. package/src/components/md-loading/md-loading.js +38 -0
  20. package/src/components/md-print/demo/index.vue +260 -0
  21. package/src/components/md-print/index.js +123 -0
  22. package/src/components/md-rich-editor/index.vue +69 -0
  23. package/src/components/md-rich-editor/module/image-extend/index.js +216 -0
  24. package/src/components/md-scroll-bar/demo/index.vue +102 -0
  25. package/src/components/md-scroll-bar/index.js +3 -0
  26. package/src/components/md-scroll-bar/index.less +90 -0
  27. package/src/components/md-scroll-bar/index.vue +250 -0
  28. package/src/components/md-select/index.js +7 -0
  29. package/src/components/md-select/select.vue +841 -0
  30. package/src/components/md-shrinkable-menu/components/sidebarMenu.vue +167 -0
  31. package/src/components/md-shrinkable-menu/components/sidebarMenuShrink.vue +119 -0
  32. package/src/components/md-shrinkable-menu/demo/data/cachePage.js +1 -0
  33. package/src/components/md-shrinkable-menu/demo/data/currentPath.js +9 -0
  34. package/src/components/md-shrinkable-menu/demo/data/menu.js +575 -0
  35. package/src/components/md-shrinkable-menu/demo/data/menu2.js +1017 -0
  36. package/src/components/md-shrinkable-menu/demo/data/pageTagsList.js +153 -0
  37. package/src/components/md-shrinkable-menu/demo/index.less +297 -0
  38. package/src/components/md-shrinkable-menu/demo/index.vue +285 -0
  39. package/src/components/md-shrinkable-menu/index.vue +112 -0
  40. package/src/components/md-shrinkable-menu/sidebar.vue +195 -0
  41. package/src/components/md-shrinkable-menu/styles/menu.less +5 -0
  42. package/src/components/md-shrinkable-menu/styles/sidebar.less +363 -0
  43. package/src/components/md-split-pane/demo/index.vue +101 -0
  44. package/src/components/md-split-pane/index.js +3 -0
  45. package/src/components/md-split-pane/index.less +93 -0
  46. package/src/components/md-split-pane/index.vue +230 -0
  47. package/src/components/md-table/action-tooltip.vue +45 -0
  48. package/src/components/md-table/can-edit-v2.vue +823 -0
  49. package/src/components/md-table/can-edit.vue +723 -0
  50. package/src/components/md-table/custom-cell.vue +71 -0
  51. package/src/components/md-table/date-picker-cell-v2.vue +48 -0
  52. package/src/components/md-table/date-picker-cell.vue +39 -0
  53. package/src/components/md-table/demo/data/search.js +67 -0
  54. package/src/components/md-table/demo/data/table2csv.js +200 -0
  55. package/src/components/md-table/demo/data/table2excel.js +239 -0
  56. package/src/components/md-table/demo/data/table_data.js +251 -0
  57. package/src/components/md-table/demo/editable-table.vue +144 -0
  58. package/src/components/md-table/demo/exportable-table.vue +124 -0
  59. package/src/components/md-table/demo/widgets/header-search.vue +88 -0
  60. package/src/components/md-table/drop-down-cell-v2.vue +87 -0
  61. package/src/components/md-table/drop-down-cell.vue +81 -0
  62. package/src/components/md-table/editable-expand.vue +143 -0
  63. package/src/components/md-table/expand.vue +97 -0
  64. package/src/components/md-table/index.vue +53 -0
  65. package/src/components/md-table/iview-table/cell.vue +99 -0
  66. package/src/components/md-table/iview-table/expand.js +21 -0
  67. package/src/components/md-table/iview-table/export-csv.js +76 -0
  68. package/src/components/md-table/iview-table/header.js +16 -0
  69. package/src/components/md-table/iview-table/index.js +2 -0
  70. package/src/components/md-table/iview-table/mixin.js +31 -0
  71. package/src/components/md-table/iview-table/table-body.vue +101 -0
  72. package/src/components/md-table/iview-table/table-head.vue +311 -0
  73. package/src/components/md-table/iview-table/table-tr.vue +31 -0
  74. package/src/components/md-table/iview-table/table.vue +1026 -0
  75. package/src/components/md-table/iview-table/util.js +93 -0
  76. package/src/components/md-table/libs/table2excel.js +100 -0
  77. package/src/components/md-table/select-cell-v2.vue +64 -0
  78. package/src/components/md-table/select-cell.vue +46 -0
  79. package/src/components/md-table/table.less +76 -0
  80. package/src/components/md-toolbar/index.vue +171 -0
  81. package/src/components/md-tree/index.js +2 -0
  82. package/src/components/md-tree/node.vue +238 -0
  83. package/src/components/md-tree/render.js +17 -0
  84. package/src/components/md-tree/tree.vue +241 -0
  85. package/src/components/utilities/can.js +35 -0
  86. package/src/directives/index.js +34 -0
  87. package/src/directives/resize.js +27 -0
  88. package/src/directives/scroll.js +27 -0
  89. package/src/directives/style/bg-color.js +23 -0
  90. package/src/directives/style/color.js +23 -0
  91. package/src/directives/style/font-size.js +23 -0
  92. package/src/directives/style/height.js +23 -0
  93. package/src/directives/style/lineHeight.js +23 -0
  94. package/src/directives/style/margin.js +48 -0
  95. package/src/directives/style/opacity.js +23 -0
  96. package/src/directives/style/padding.js +48 -0
  97. package/src/directives/style/width.js +24 -0
  98. package/src/index.js +442 -0
  99. package/src/locale/lang.js +5 -0
  100. package/src/mixins/colorable.js +51 -0
  101. package/src/style/color/bezierEasing.less +110 -0
  102. package/src/style/color/colorPalette.less +75 -0
  103. package/src/style/color/colors.less +146 -0
  104. package/src/style/color/tinyColor.less +1184 -0
  105. package/src/style/common.less +72 -0
  106. package/src/style/components/_ripple.less +60 -0
  107. package/src/style/components/_shrinkable-menu.less +46 -0
  108. package/src/style/components/_toolbar.less +96 -0
  109. package/src/style/components/index.less +3 -0
  110. package/src/style/components/rich-editor.less +6 -0
  111. package/src/style/index.less +10 -0
  112. package/src/style/theme.less +155 -0
  113. package/src/utils/color.js +46 -0
  114. package/src/utils/console.js +105 -0
  115. package/src/utils/load.js +79 -0
  116. package/src/utils/mask.js +139 -0
  117. package/src/utils/mixins.js +5 -0
  118. package/src/utils/validate.js +271 -0
@@ -0,0 +1,46 @@
1
+ import { consoleWarn } from './console';
2
+
3
+ // export type RGB = number
4
+ // export type XYZ = [number, number, number]
5
+ // export type LAB = [number, number, number]
6
+
7
+ export function colorToInt(color) {
8
+ let rgb
9
+
10
+ if (typeof color === 'number') {
11
+ rgb = color
12
+ } else if (typeof color === 'string') {
13
+ let c = color[0] === '#' ? color.substring(1) : color
14
+ if (c.length === 3) {
15
+ c = c.split('').map(char => char + char).join('')
16
+ }
17
+ if (c.length !== 6) {
18
+ consoleWarn(`'${color}' is not a valid rgb color`)
19
+ }
20
+ rgb = parseInt(c, 16)
21
+ } else {
22
+ throw new TypeError(`Colors can only be numbers or strings, recieved ${color == null ? color : color.constructor.name} instead`)
23
+ }
24
+
25
+ if (rgb < 0) {
26
+ consoleWarn(`Colors cannot be negative: '${color}'`)
27
+ rgb = 0
28
+ } else if (rgb > 0xffffff || isNaN(rgb)) {
29
+ consoleWarn(`'${color}' is not a valid rgb color`)
30
+ rgb = 0xffffff
31
+ }
32
+
33
+ return rgb
34
+ }
35
+
36
+ export function intToHex(color) {
37
+ let hexColor = color.toString(16)
38
+ if (hexColor.length < 6) hexColor = '0'.repeat(6 - hexColor.length) + hexColor
39
+
40
+ return '#' + hexColor
41
+ }
42
+
43
+
44
+ export function colorToHex(color) {
45
+ return intToHex(colorToInt(color))
46
+ }
@@ -0,0 +1,105 @@
1
+ function createMessage(message, vm, parent) {
2
+ if (parent) {
3
+ vm = {
4
+ _isVue: true,
5
+ $parent: parent,
6
+ $options: vm,
7
+ }
8
+ }
9
+
10
+ if (vm) {
11
+ vm.$_alreadyWarned = vm.$_alreadyWarned || [];
12
+ if (vm.$_alreadyWarned.includes(message)) return;
13
+ vm.$_alreadyWarned.push(message)
14
+ }
15
+
16
+ return `[MdView] ${message}` + (
17
+ vm ? generateComponentTrace(vm) : ''
18
+ )
19
+ }
20
+
21
+
22
+ export function consoleInfo(message, vm, parent) {
23
+ const newMessage = createMessage(message, vm, parent)
24
+ newMessage != null && console.info(newMessage)
25
+ }
26
+
27
+
28
+ export function consoleError(message, vm, parent) {
29
+ const newMessage = createMessage(message, vm, parent)
30
+ newMessage != null && console.warn(newMessage)
31
+ }
32
+
33
+ export function consoleWarn(message, vm, parent) {
34
+ const newMessage = createMessage(message, vm, parent)
35
+ newMessage != null && console.error(newMessage)
36
+ }
37
+
38
+
39
+ export function deprecate(original, replacement, vm, parent) {
40
+ consoleWarn(`'${original}' is deprecated, use '${replacement}' instead`, vm, parent)
41
+ }
42
+
43
+ /**
44
+ * Shamelessly stolen from vuejs/vue/blob/dev/src/core/util/debug.js
45
+ */
46
+
47
+ const classifyRE = /(?:^|[-_])(\w)/g
48
+ const classify = (str) => str
49
+ .replace(classifyRE, c => c.toUpperCase())
50
+ .replace(/[-_]/g, '')
51
+
52
+ function formatComponentName(vm, includeFile) {
53
+ if (vm.$root === vm) {
54
+ return '<Root>'
55
+ }
56
+ const options = typeof vm === 'function' && vm.cid != null ?
57
+ vm.options :
58
+ vm._isVue ?
59
+ vm.$options || vm.constructor.options :
60
+ vm || {}
61
+ let name = options.name || options._componentTag
62
+ const file = options.__file
63
+ if (!name && file) {
64
+ const match = file.match(/([^/\\]+)\.vue$/)
65
+ name = match && match[1]
66
+ }
67
+
68
+ return (
69
+ (name ? `<${classify(name)}>` : `<Anonymous>`) +
70
+ (file && includeFile !== false ? ` at ${file}` : '')
71
+ )
72
+ }
73
+
74
+ function generateComponentTrace(vm) {
75
+ if (vm._isVue && vm.$parent) {
76
+ const tree = []
77
+ let currentRecursiveSequence = 0
78
+ while (vm) {
79
+ if (tree.length > 0) {
80
+ const last = tree[tree.length - 1]
81
+ if (last.constructor === vm.constructor) {
82
+ currentRecursiveSequence++
83
+ vm = vm.$parent
84
+ continue
85
+ } else if (currentRecursiveSequence > 0) {
86
+ tree[tree.length - 1] = [last, currentRecursiveSequence]
87
+ currentRecursiveSequence = 0
88
+ }
89
+ }
90
+ tree.push(vm)
91
+ vm = vm.$parent
92
+ }
93
+ return '\n\nfound in\n\n' + tree
94
+ .map((vm, i) => `${
95
+ i === 0 ? '---> ' : ' '.repeat(5 + i * 2)
96
+ }${
97
+ Array.isArray(vm)
98
+ ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
99
+ : formatComponentName(vm)
100
+ }`)
101
+ .join('\n')
102
+ } else {
103
+ return `\n\n(found in ${formatComponentName(vm)})`
104
+ }
105
+ }
@@ -0,0 +1,79 @@
1
+ var loadCssJS = (function(dom) {
2
+ var cache = {}, /*缓存加载过的css或者js*/
3
+ funct;
4
+ /**
5
+ * HTML动态加载css或者js
6
+ * @path {String} src 或 link 地址必须带有后缀名.js或者.css
7
+ * @callback {Function} 加载成功的回掉函数
8
+ * */
9
+ funct = function(path, callback) {
10
+ if(!path) { /*检查路径是否为空*/
11
+ throw new Error("请输入path路径!");
12
+ };
13
+ var fn=Object.prototype.toString.call(callback)=="[object Function]"?callback:function(){};
14
+ if(".js" == path.substr(-3)) { /*检查路径后缀名是否为.js*/
15
+ addJs(path, fn);
16
+ } else if(".css" == path.substr(-4)) { /*检查路径后缀名是否为.css*/
17
+ addCss(path, fn);
18
+ } else {
19
+ throw new Error('请输入正确的path路径!');
20
+ }
21
+ };
22
+ /**
23
+ * HTML 动态添加 CSS
24
+ * @path {String} link 地址必须带有后缀名.css
25
+ * @callback {Function} 加载成功的回掉函数
26
+ * */
27
+ function addCss(path, callback) {
28
+ if(!checkcache(path)) { /*检查是否加载过*/
29
+ var head = dom.getElementsByTagName('head')[0];
30
+ var link = dom.createElement('link');
31
+ link.href = path;
32
+ link.rel = 'stylesheet';
33
+ link.type = 'text/css';
34
+ head.appendChild(link); /*添加到HTML中*/
35
+ link.onload = link.onreadystatechange = function() { /*判断是否加载成功*/
36
+ if(!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
37
+ link.onload = link.onreadystatechange = null;
38
+ callback();
39
+ }
40
+ };
41
+ cache[path] = 1; /*存储加载过的css路径,值设为1*/
42
+ }
43
+ };
44
+ /**
45
+ * HTML动态加载js
46
+ * @path {String} src 地址必须带有后缀名.js
47
+ * @callback {Function} 加载成功的回掉函数
48
+ * */
49
+ function addJs(path, callback) {
50
+ if(!checkcache(path)) { /*检查是否加载过*/
51
+ var head = dom.getElementsByTagName('head')[0];
52
+ var script = dom.createElement('script');
53
+ script.src = path;
54
+ script.type = 'text/javascript';
55
+ head.appendChild(script); /*添加到HTML中*/
56
+ script.onload = script.onreadystatechange = function() { /*判断是否加载成功*/
57
+ if(!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
58
+ script.onload = script.onreadystatechange = null;
59
+ callback();
60
+ }
61
+ };
62
+ cache[path] = 1; /*存储加载过的js路径,值设为1*/
63
+ }
64
+ };
65
+ /**
66
+ * 检查是否加载
67
+ * @path {String} 路径
68
+ * */
69
+ function checkcache(path) {
70
+ if(cache[path]) { /*判断是否加载过的js路径*/
71
+ return true;
72
+ } else {
73
+ return false;
74
+ }
75
+ };
76
+ return funct;
77
+ }(document));
78
+
79
+ export default loadCssJS;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Default delimiter RegExp
3
+ *
4
+ * @type {RegExp}
5
+ */
6
+ export const defaultDelimiters = /[-!$%^&*()_+|~=`{}[\]:";'<>?,./\\ ]/
7
+
8
+ /**
9
+ *
10
+ * @param {String} char
11
+ *
12
+ * @return {Boolean}
13
+ */
14
+ export const isMaskDelimiter = char => char && defaultDelimiters.test(char)
15
+
16
+ /**
17
+ * Mask keys
18
+ *
19
+ * @type {Object}
20
+ */
21
+ const allowedMasks = {
22
+ '#': {
23
+ test: char => char.match(/[0-9]/)
24
+ },
25
+ 'A': {
26
+ test: char => char.match(/[A-Z]/i),
27
+ convert: char => char.toUpperCase()
28
+ },
29
+ 'a': {
30
+ test: char => char.match(/[a-z]/i),
31
+ convert: char => char.toLowerCase()
32
+ },
33
+ 'N': {
34
+ test: char => char.match(/[0-9A-Z]/i),
35
+ convert: char => char.toUpperCase()
36
+ },
37
+ 'n': {
38
+ test: char => char.match(/[0-9a-z]/i),
39
+ convert: char => char.toLowerCase()
40
+ },
41
+ 'X': {
42
+ test: isMaskDelimiter
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Is Character mask
48
+ *
49
+ * @param {String} char
50
+ *
51
+ * @return {Boolean}
52
+ */
53
+ const isMask = char => allowedMasks.hasOwnProperty(char)
54
+
55
+ /**
56
+ * Automatically convert char case
57
+ *
58
+ * @param {String} mask
59
+ * @param {String} char
60
+ *
61
+ * @return {String}
62
+ */
63
+ const convert = (mask, char) => {
64
+ return allowedMasks[mask].convert ? allowedMasks[mask].convert(char) : char
65
+ }
66
+
67
+ /**
68
+ * Mask Validation
69
+ *
70
+ * @param {String} mask
71
+ * @param {String} char
72
+ *
73
+ * @return {Boolean}
74
+ */
75
+ const maskValidates = (mask, char) => {
76
+ if (char == null || !isMask(mask)) return false
77
+ return allowedMasks[mask].test(char)
78
+ }
79
+
80
+ /**
81
+ * Mask Text
82
+ *
83
+ * Takes a string or an array of characters
84
+ * and returns a masked string
85
+ *
86
+ * @param {*} text
87
+ * @param {Array|String} masked
88
+ * @param {Boolean} [dontFillMaskBlanks]
89
+ *
90
+ * @return {String}
91
+ */
92
+ export const maskText = (text, masked, dontFillMaskBlanks) => {
93
+ if (text == null) return ''
94
+ text = String(text)
95
+ if (!masked.length || !text.length) return text
96
+ if (!Array.isArray(masked)) masked = masked.split('')
97
+
98
+ let textIndex = 0
99
+ let maskIndex = 0
100
+ let newText = ''
101
+
102
+ while (maskIndex < masked.length) {
103
+ const mask = masked[maskIndex]
104
+
105
+ // Assign the next character
106
+ const char = text[textIndex]
107
+
108
+ // Check if mask is delimiter
109
+ // and current char matches
110
+ if (!isMask(mask) && char === mask) {
111
+ newText += mask
112
+ textIndex++
113
+ // Check if not mask
114
+ } else if (!isMask(mask) && !dontFillMaskBlanks) {
115
+ newText += mask
116
+ // Check if is mask and validates
117
+ } else if (maskValidates(mask, char)) {
118
+ newText += convert(mask, char)
119
+ textIndex++
120
+ } else {
121
+ return newText
122
+ }
123
+
124
+ maskIndex++
125
+ }
126
+
127
+ return newText
128
+ }
129
+
130
+ /**
131
+ * Unmask Text
132
+ *
133
+ * @param {String} text
134
+ *
135
+ * @return {String}
136
+ */
137
+ export const unmaskText = text => {
138
+ return text ? String(text).replace(new RegExp(defaultDelimiters, 'g'), '') : text
139
+ }
@@ -0,0 +1,5 @@
1
+ import Vue from 'vue';
2
+
3
+ export default function mixins(...args) {
4
+ return Vue.extend({ mixins: args })
5
+ }
@@ -0,0 +1,271 @@
1
+ /**
2
+ * 是否是闰年
3
+ * @param {*} val
4
+ */
5
+ export function isLeapYear(year) {
6
+ return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)
7
+ }
8
+
9
+ /**
10
+ * 邮箱地址校验
11
+ * @param {*} val
12
+ */
13
+ export function isEmail(val) {
14
+ var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
15
+ return re.test(val)
16
+ }
17
+
18
+ /**
19
+ * 是否是布尔值校验
20
+ * @param {*} val
21
+ */
22
+ export function isBoolean(val) {
23
+ return (
24
+ val === true ||
25
+ val === false ||
26
+ val === 0 ||
27
+ val === 1 ||
28
+ val === '0' ||
29
+ val === '1' ||
30
+ val === 'true' ||
31
+ val === 'false' ||
32
+ val === '是' ||
33
+ val === '否' ||
34
+ val.toLowerCase() === 'yes' ||
35
+ val.toLowerCase() === 'no' ||
36
+ val.toLowerCase() === 'on' ||
37
+ val.toLowerCase() === 'off'
38
+ )
39
+ }
40
+
41
+ /**
42
+ * 是否是数字校验
43
+ * @param {*} val
44
+ */
45
+ export function isNumber(val) {
46
+ var num
47
+
48
+ num = Number(val)
49
+
50
+ if (typeof num === 'number' && !isNaN(num) && typeof val !== 'boolean') {
51
+ return true
52
+ } else {
53
+ return false
54
+ }
55
+ }
56
+
57
+ /**
58
+ * 是否是数组校验
59
+ * @param {*} val
60
+ */
61
+ export function isArray(val) {
62
+ return Object.prototype.toString.call(val) === '[object Array]'
63
+ }
64
+
65
+ /**
66
+ * 是否是字符串校验
67
+ * @param {*} val
68
+ */
69
+ export function isString(val) {
70
+ return Object.prototype.toString.call(val) === '[object String]'
71
+ }
72
+
73
+ /**
74
+ * 是否是对象校验
75
+ * @param {*} val
76
+ */
77
+ export function isObject(val) {
78
+ return Object.prototype.toString.call(val) === '[object Object]'
79
+ }
80
+
81
+ /**
82
+ * 是否是函数校验
83
+ * @param {*} val
84
+ */
85
+ export function isFunction(val) {
86
+ return Object.prototype.toString.call(val) === '[object Function]'
87
+ }
88
+
89
+ /**
90
+ * 是否是URL校验
91
+ * @param {*} val
92
+ */
93
+ export function isUrl(url) {
94
+ return (/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i).test(url)
95
+ }
96
+
97
+ /**
98
+ * 校验val值是true还是false
99
+ * @param {*} val 'on'|'off', 'yes'|'no', '1'|'0', 1|0, true|false, 'true'|'false','是'|'否'
100
+ */
101
+ export function accepted(val) {
102
+ if (val.toLowerCase() === 'on' || val.toLowerCase() === 'yes' || val === 1 || val === '1' || val === true || val === 'true' || val === '是') {
103
+ return true
104
+ }
105
+
106
+ return false
107
+ }
108
+
109
+ /**
110
+ * 字母校验
111
+ * @param {*} val
112
+ */
113
+ export function alpha(val) {
114
+ return (/^[a-zA-Z]+$/).test(val)
115
+ }
116
+
117
+ /**
118
+ * 字母+数字校验
119
+ * @param {*} val
120
+ */
121
+ export function alpha_dash(val) {
122
+ return (/^[a-zA-Z0-9_\-]+$/).test(val)
123
+ }
124
+
125
+ /**
126
+ * 数字校验
127
+ * @param {*} val
128
+ */
129
+ export function alpha_num(val) {
130
+ return (/^[a-zA-Z0-9]+$/).test(val)
131
+ }
132
+ /**
133
+ * 十六进制校验
134
+ * @param {*} val
135
+ */
136
+ export function hex(val) {
137
+ return (/^[0-9a-f]+$/i).test(val)
138
+ }
139
+
140
+ /**
141
+ * 电话号码格式校验
142
+ * @param {*} val
143
+ */
144
+ export function isPhone(val) {
145
+ return (/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/).test(val)
146
+ }
147
+
148
+ /**
149
+ * 手机号码格式校验
150
+ * @param {*} val
151
+ */
152
+ export function isMobile(val) {
153
+ return (/^1(3|4|5|7|8)\d{9}$/).test(val)
154
+ }
155
+
156
+ /**
157
+ * 身份证号码校验(15位,18位,17位加字母X)
158
+ * @param {*} val
159
+ */
160
+ export function isIdCard(val) {
161
+ return (/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/).test(val)
162
+ }
163
+
164
+ /**
165
+ * 中文英文校验
166
+ * @param {*} val
167
+ */
168
+
169
+ export function isChinese(val) {
170
+ return (/^[\Α-\¥]+$/).test(val)
171
+ }
172
+
173
+ /**
174
+ * 英文校验
175
+ * @param {*} val
176
+ */
177
+
178
+ export function isEnglish(val) {
179
+ return (/^[A-Za-z]+$/).test(val)
180
+ }
181
+
182
+ /**
183
+ * QQ号码校验
184
+ * @param {*} val
185
+ */
186
+
187
+ export function isQQ(val) {
188
+ return (/^[1-9]\d{4,8}$/).test(val)
189
+ }
190
+
191
+ /**
192
+ * Zip邮政编码校验
193
+ * @param {*} val
194
+ */
195
+
196
+ export function isZip(val) {
197
+ return (/^[1-9]\d{4,8}$/).test(val)
198
+ }
199
+
200
+ /**
201
+ * ip地址校验
202
+ * @param {*} val
203
+ */
204
+ export function isIp(val) {
205
+ let rex = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/g
206
+ if (rex.test(val)) {
207
+ if (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256) return true
208
+ }
209
+ return false
210
+ }
211
+
212
+ /**
213
+ * 安卓校验
214
+ * @param {*} val
215
+ */
216
+ export function isAndroid() {
217
+ let u = navigator.userAgent
218
+ let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
219
+ return isAndroid
220
+ }
221
+
222
+ /**
223
+ * iOS校验
224
+ * @param {*} val
225
+ */
226
+ export function isIos() {
227
+ let u = navigator.userAgent
228
+ let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
229
+ return isiOS
230
+ }
231
+
232
+ /**
233
+ * 日期校验
234
+ * @param {*} val
235
+ */
236
+ /*export function date(val, format) {
237
+ return isValidDate(val);
238
+ }*/
239
+ export function isValidDate(inDate) {
240
+ var valid = true;
241
+
242
+
243
+ if (!inDate) {
244
+ return false;
245
+ }
246
+ // reformat if supplied as mm.dd.yyyy (period delimiter)
247
+ if (typeof inDate === 'string') {
248
+ var pos = inDate.indexOf('.');
249
+ if ((pos > 0 && pos <= 6)) {
250
+ inDate = inDate.replace(/\./g, '-');
251
+ }
252
+ }
253
+
254
+ var testDate = new Date(inDate);
255
+ if (!testDate) {
256
+ return false;
257
+ }
258
+ var yr = testDate.getFullYear();
259
+ var mo = testDate.getMonth();
260
+ var day = testDate.getDate();
261
+
262
+ var daysInMonth = [31, (isLeapYear(yr) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
263
+
264
+ if (yr < 1000) { return false; }
265
+ if (isNaN(mo)) { return false; }
266
+ if (mo + 1 > 12) { return false; }
267
+ if (isNaN(day)) { return false; }
268
+ if (day > daysInMonth[mo]) { return false; }
269
+
270
+ return valid;
271
+ }