haiwei-ui 1.3.1 → 1.3.3

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.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "haiwei-ui",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "HaiWei前端组件库",
5
5
  "author": "Eric",
6
6
  "license": "ISC",
7
7
  "main": "packages/index.js",
8
8
  "scripts": {
9
- "serve": "vue-cli-service lint && vue-cli-service serve",
9
+ "serve": "vue-cli-service lint --fit && vue-cli-service serve",
10
10
  "build": "vue-cli-service lint && vue-cli-service build",
11
11
  "lint": "vue-cli-service lint --fit",
12
12
  "cm": "rimraf node_modules && rimraf dist",
@@ -17,48 +17,48 @@
17
17
  </div>
18
18
  </template>
19
19
  <script>
20
- export default {
21
- name: 'BoxSmall',
22
- props: {
23
- /** 文本 */
24
- label: String,
25
- /** 值 */
26
- value: [String, Number],
27
- /** 单位 */
28
- unit: String,
29
- /** 图标 */
30
- icon: String,
31
- /** 显示更多 */
32
- more: Boolean,
33
- /** 背景色 */
34
- bgColor: {
35
- type: String,
36
- default: 'success'
20
+ export default {
21
+ name: 'BoxSmall',
22
+ props: {
23
+ /** 文本 */
24
+ label: String,
25
+ /** 值 */
26
+ value: [String, Number],
27
+ /** 单位 */
28
+ unit: String,
29
+ /** 图标 */
30
+ icon: String,
31
+ /** 显示更多 */
32
+ more: Boolean,
33
+ /** 背景色 */
34
+ bgColor: {
35
+ type: String,
36
+ default: 'success'
37
+ }
38
+ },
39
+ computed: {
40
+ class_() {
41
+ let classArr = ['nm-box-small']
42
+ if (this.includeBgColor) {
43
+ classArr.push(`nm-bg-${this.bgColor}`)
37
44
  }
45
+ return classArr
38
46
  },
39
- computed: {
40
- class_() {
41
- let classArr = ['nm-box-small']
42
- if (this.includeBgColor) {
43
- classArr.push(`nm-bg-${this.bgColor}`)
44
- }
45
- return classArr
46
- },
47
- style_() {
48
- let style = {}
49
- if (!this.includeBgColor) {
50
- style.backgroundColor = this.bgColor
51
- }
52
- return style
53
- },
54
- includeBgColor() {
55
- return ['success', 'primary', 'info', 'warning', 'danger'].includes(this.bgColor)
47
+ style_() {
48
+ let style = {}
49
+ if (!this.includeBgColor) {
50
+ style.backgroundColor = this.bgColor
56
51
  }
52
+ return style
57
53
  },
58
- methods: {
59
- onMore() {
60
- this.$emit('more')
61
- }
54
+ includeBgColor() {
55
+ return ['success', 'primary', 'info', 'warning', 'danger'].includes(this.bgColor)
56
+ }
57
+ },
58
+ methods: {
59
+ onMore() {
60
+ this.$emit('more')
62
61
  }
63
62
  }
63
+ }
64
64
  </script>
@@ -1,5 +1,7 @@
1
1
  <template>
2
- <el-button class="nm-button" :type="type" :size="size || fontSize" :plain="plain" :round="round" :circle="circle" :loading="loading" :disabled="disabled" :autofocus="autofocus" :native-type="nativeType" v-nm-has="code" v-clipboard:copy="copy" v-clipboard:success="onSuccess" v-clipboard:error="onError" @click="$emit('click')">
2
+ <el-button class="nm-button" :type="type" :size="size || fontSize" :plain="plain" :round="round" :circle="circle"
3
+ :loading="loading" :disabled="disabled" :autofocus="autofocus" :native-type="nativeType" v-nm-has="code"
4
+ v-clipboard:copy="copy" v-clipboard:success="onSuccess" v-clipboard:error="onError" @click="$emit('click')">
3
5
  <nm-icon v-if="!loading && icon" :name="icon" />
4
6
  <slot>
5
7
  <span v-if="!circle && text" class="nm-button-text" v-html="text" />
@@ -7,52 +9,52 @@
7
9
  </el-button>
8
10
  </template>
9
11
  <script>
10
- export default {
11
- name: 'ButtonCopy',
12
- props: {
13
- /** 尺寸,默认按照框架的字号设置 */
14
- size: String,
15
- /** 类型 primary/success/warning/danger/info/text */
16
- type: {
17
- type: String,
18
- default: 'text'
19
- },
20
- /** 是否朴素按钮 */
21
- plain: Boolean,
22
- /** 是否圆角按钮 */
23
- round: Boolean,
24
- /** 是否圆形按钮 */
25
- circle: Boolean,
26
- /** 是否加载中状态 */
27
- loading: Boolean,
28
- /** 是否禁用状态 */
29
- disabled: Boolean,
30
- /** 是否默认聚焦 */
31
- autofocus: Boolean,
32
- /** 原生 type 属性 button/submit/reset */
33
- nativeType: String,
34
- /** 图标 */
35
- icon: {
36
- type: String,
37
- default: 'max'
38
- },
39
- // 文本
40
- text: {
41
- type: String,
42
- default: '复制'
43
- },
44
- // 按钮编码,用于按钮权限控制
45
- code: String,
46
- // 拷贝内容
47
- copy: String
12
+ export default {
13
+ name: 'ButtonCopy',
14
+ props: {
15
+ /** 尺寸,默认按照框架的字号设置 */
16
+ size: String,
17
+ /** 类型 primary/success/warning/danger/info/text */
18
+ type: {
19
+ type: String,
20
+ default: 'text'
48
21
  },
49
- methods: {
50
- onSuccess() {
51
- this._success('复制成功')
52
- },
53
- onError() {
54
- this._error('复制失败')
55
- }
22
+ /** 是否朴素按钮 */
23
+ plain: Boolean,
24
+ /** 是否圆角按钮 */
25
+ round: Boolean,
26
+ /** 是否圆形按钮 */
27
+ circle: Boolean,
28
+ /** 是否加载中状态 */
29
+ loading: Boolean,
30
+ /** 是否禁用状态 */
31
+ disabled: Boolean,
32
+ /** 是否默认聚焦 */
33
+ autofocus: Boolean,
34
+ /** 原生 type 属性 button/submit/reset */
35
+ nativeType: String,
36
+ /** 图标 */
37
+ icon: {
38
+ type: String,
39
+ default: 'max'
40
+ },
41
+ // 文本
42
+ text: {
43
+ type: String,
44
+ default: '复制'
45
+ },
46
+ // 按钮编码,用于按钮权限控制
47
+ code: String,
48
+ // 拷贝内容
49
+ copy: String
50
+ },
51
+ methods: {
52
+ onSuccess() {
53
+ this._success('复制成功')
54
+ },
55
+ onError() {
56
+ this._error('复制失败')
56
57
  }
57
58
  }
59
+ }
58
60
  </script>
@@ -1,95 +1,97 @@
1
1
  <template>
2
- <el-button class="nm-button" :type="type" :size="size || fontSize" :plain="plain" :round="round" :circle="circle" :loading="loading" :disabled="disabled" :autofocus="autofocus" :native-type="nativeType" v-nm-has="code" @click="remove">
2
+ <el-button class="nm-button" :type="type" :size="size || fontSize" :plain="plain" :round="round" :circle="circle"
3
+ :loading="loading" :disabled="disabled" :autofocus="autofocus" :native-type="nativeType" v-nm-has="code"
4
+ @click="remove">
3
5
  <nm-icon v-if="!noIcon" :name="icon" />
4
6
  <span v-if="!circle && text" class="nm-button-text">{{ text }}</span>
5
7
  </el-button>
6
8
  </template>
7
9
  <script>
8
- export default {
9
- name: 'ButtonDeleteBatch',
10
- props: {
11
- /** 尺寸,默认或者为空时,按照皮肤的字号设置 */
12
- size: String,
13
- /** 类型 primary/success/warning/danger/info/text */
14
- type: {
15
- type: String,
16
- default: 'danger'
17
- },
18
- /** 是否朴素按钮 */
19
- plain: Boolean,
20
- /** 是否圆角按钮 */
21
- round: Boolean,
22
- /** 是否圆形按钮 */
23
- circle: Boolean,
24
- /** 是否加载中状态 */
25
- loading: Boolean,
26
- /** 是否禁用状态 */
27
- disabled: Boolean,
28
- /** 是否默认聚焦 */
29
- autofocus: Boolean,
30
- /** 原生 type 属性 button/submit/reset */
31
- nativeType: String,
32
- /** 图标 */
33
- icon: {
34
- type: String,
35
- default: 'batch-delete'
36
- },
37
- // 文本
38
- text: {
39
- type: String,
40
- default: '批量删除'
41
- },
42
- // 按钮编码,用于按钮权限控制
43
- code: String,
44
- // 已选择的数据列表
45
- selection: Array,
46
- // 要显示的属性名称
47
- showProperty: String,
48
- // 不显示图标
49
- noIcon: Boolean,
50
- // 删除方法
51
- action: {
52
- type: Function,
53
- required: true
54
- }
10
+ export default {
11
+ name: 'ButtonDeleteBatch',
12
+ props: {
13
+ /** 尺寸,默认或者为空时,按照皮肤的字号设置 */
14
+ size: String,
15
+ /** 类型 primary/success/warning/danger/info/text */
16
+ type: {
17
+ type: String,
18
+ default: 'danger'
19
+ },
20
+ /** 是否朴素按钮 */
21
+ plain: Boolean,
22
+ /** 是否圆角按钮 */
23
+ round: Boolean,
24
+ /** 是否圆形按钮 */
25
+ circle: Boolean,
26
+ /** 是否加载中状态 */
27
+ loading: Boolean,
28
+ /** 是否禁用状态 */
29
+ disabled: Boolean,
30
+ /** 是否默认聚焦 */
31
+ autofocus: Boolean,
32
+ /** 原生 type 属性 button/submit/reset */
33
+ nativeType: String,
34
+ /** 图标 */
35
+ icon: {
36
+ type: String,
37
+ default: 'batch-delete'
38
+ },
39
+ // 文本
40
+ text: {
41
+ type: String,
42
+ default: '批量删除'
55
43
  },
56
- methods: {
57
- async remove() {
58
- if (!this.selection || this.selection.length < 1) {
59
- this._error('请选择要删除的数据~')
60
- return
61
- }
44
+ // 按钮编码,用于按钮权限控制
45
+ code: String,
46
+ // 已选择的数据列表
47
+ selection: Array,
48
+ // 要显示的属性名称
49
+ showProperty: String,
50
+ // 不显示图标
51
+ noIcon: Boolean,
52
+ // 删除方法
53
+ action: {
54
+ type: Function,
55
+ required: true
56
+ }
57
+ },
58
+ methods: {
59
+ async remove() {
60
+ if (!this.selection || this.selection.length < 1) {
61
+ this._error('请选择要删除的数据~')
62
+ return
63
+ }
62
64
 
63
- let msg = '您确认要删除以下数据吗?'
64
- if (this.showProperty) {
65
- msg += '<br/>已选择:' + this.selection.map(item => item[this.showProperty]).join('、')
66
- }
65
+ let msg = '您确认要删除以下数据吗?'
66
+ if (this.showProperty) {
67
+ msg += '<br/>已选择:' + this.selection.map(item => item[this.showProperty]).join('、')
68
+ }
67
69
 
68
- this.$confirm(msg, '提示', {
69
- confirmButtonText: '确定',
70
- cancelButtonText: '取消',
71
- dangerouslyUseHTMLString: true,
72
- type: 'warning'
73
- })
74
- .then(async () => {
75
- if (this.action || typeof action === 'function') {
76
- this._openLoading('正在删除,请稍后...')
70
+ this.$confirm(msg, '提示', {
71
+ confirmButtonText: '确定',
72
+ cancelButtonText: '取消',
73
+ dangerouslyUseHTMLString: true,
74
+ type: 'warning'
75
+ })
76
+ .then(async () => {
77
+ if (this.action || typeof action === 'function') {
78
+ this._openLoading('正在删除,请稍后...')
77
79
 
78
- this.action(this.selection.map(item => item.id))
79
- .then(() => {
80
- this._closeLoading()
81
- this._success('删除成功~')
82
- this.$emit('success')
83
- })
84
- .catch(() => {
85
- this._closeLoading()
86
- this.$emit('error')
87
- }, this.msg)
88
- .catch(() => {})
89
- }
90
- })
91
- .catch(() => {})
92
- }
80
+ this.action(this.selection.map(item => item.id))
81
+ .then(() => {
82
+ this._closeLoading()
83
+ this._success('删除成功~')
84
+ this.$emit('success')
85
+ })
86
+ .catch(() => {
87
+ this._closeLoading()
88
+ this.$emit('error')
89
+ }, this.msg)
90
+ .catch(() => { })
91
+ }
92
+ })
93
+ .catch(() => { })
93
94
  }
94
95
  }
96
+ }
95
97
  </script>
@@ -1,111 +1,113 @@
1
1
  <template>
2
2
  <nm-box header class="nm-checkbox-group">
3
3
  <template v-slot:header>
4
- <el-checkbox v-model="checkAll" :size="size || fontSize" :indeterminate="isIndeterminate" :disabled="disabledCheckAll" @change="onCheckAllChange">全选</el-checkbox>
4
+ <el-checkbox v-model="checkAll" :size="size || fontSize" :indeterminate="isIndeterminate"
5
+ :disabled="disabledCheckAll" @change="onCheckAllChange">全选</el-checkbox>
5
6
  </template>
6
7
  <el-checkbox-group v-model="value_" :size="size || fontSize" @change="onCheckedChange">
7
- <el-checkbox v-for="item in options" :key="item.value" :label="item.value" :disabled="item.disabled" :border="border">
8
+ <el-checkbox v-for="item in options" :key="item.value" :label="item.value" :disabled="item.disabled"
9
+ :border="border">
8
10
  <slot :option="item">{{ item.label }}</slot>
9
11
  </el-checkbox>
10
12
  </el-checkbox-group>
11
13
  </nm-box>
12
14
  </template>
13
15
  <script>
14
- export default {
15
- name: 'CheckboxGroup',
16
- data() {
17
- return {
18
- value_: this.value,
19
- checkAll: false,
20
- isIndeterminate: true,
21
- options: []
16
+ export default {
17
+ name: 'CheckboxGroup',
18
+ data() {
19
+ return {
20
+ value_: this.value,
21
+ checkAll: false,
22
+ isIndeterminate: true,
23
+ options: []
24
+ }
25
+ },
26
+ props: {
27
+ value: {
28
+ type: Array,
29
+ default() {
30
+ return []
22
31
  }
23
32
  },
24
- props: {
25
- value: {
26
- type: Array,
27
- default() {
28
- return []
29
- }
30
- },
31
- size: String,
32
- disabled: Boolean,
33
- min: Number,
34
- max: Number,
35
- border: {
36
- type: Boolean,
37
- default: true
38
- },
39
- action: Function
33
+ size: String,
34
+ disabled: Boolean,
35
+ min: Number,
36
+ max: Number,
37
+ border: {
38
+ type: Boolean,
39
+ default: true
40
+ },
41
+ action: Function
42
+ },
43
+ computed: {
44
+ disabledCheckAll() {
45
+ return !this.options || this.options.length < 1 || !this.options.every(o => !o.disabled)
40
46
  },
41
- computed: {
42
- disabledCheckAll() {
43
- return !this.options || this.options.length < 1 || !this.options.every(o => !o.disabled)
44
- },
45
- selection() {
46
- let list = []
47
- if (this.value_) {
48
- this.value_.forEach(item => {
49
- for (var i = 0; i < this.options.length; i++) {
50
- const opt = this.options[i]
51
- if (opt.value === item) {
52
- list.push(opt)
53
- break
54
- }
47
+ selection() {
48
+ let list = []
49
+ if (this.value_) {
50
+ this.value_.forEach(item => {
51
+ for (var i = 0; i < this.options.length; i++) {
52
+ const opt = this.options[i]
53
+ if (opt.value === item) {
54
+ list.push(opt)
55
+ break
55
56
  }
56
- })
57
- }
58
-
59
- return list
57
+ }
58
+ })
60
59
  }
60
+
61
+ return list
62
+ }
63
+ },
64
+ methods: {
65
+ refresh() {
66
+ this.action().then(options => {
67
+ this.options = options
68
+ this.setCheckAll()
69
+ })
61
70
  },
62
- methods: {
63
- refresh() {
64
- this.action().then(options => {
65
- this.options = options
66
- this.setCheckAll()
67
- })
68
- },
69
- // 设置全选状态
70
- setCheckAll() {
71
- if (this.value_) {
72
- let selectionCount = this.value_.length
73
- this.checkAll = selectionCount === this.options.length
74
- this.isIndeterminate = selectionCount > 0 && selectionCount < this.options.length
75
- } else {
76
- this.isIndeterminate = false
77
- }
78
- },
79
- // 处理全选按钮事件
80
- onCheckAllChange(val) {
81
- this.value_ = val ? this.options.map(m => m.value) : []
71
+ // 设置全选状态
72
+ setCheckAll() {
73
+ if (this.value_) {
74
+ let selectionCount = this.value_.length
75
+ this.checkAll = selectionCount === this.options.length
76
+ this.isIndeterminate = selectionCount > 0 && selectionCount < this.options.length
77
+ } else {
82
78
  this.isIndeterminate = false
83
- this.onChange()
84
- },
85
- onCheckedChange(value) {
86
- let checkedCount = value.length
87
- this.checkAll = checkedCount === this.options.length
88
- this.isIndeterminate = checkedCount > 0 && checkedCount < this.options.length
89
- this.onChange()
90
- },
91
- // 清楚已选项
92
- clear() {
93
- this.value_ = this.value
94
- this.onChange()
95
- },
96
- onChange() {
97
- this.$emit('input', this.value_)
98
- this.$emit('change', this.value_, this.selection, this.options)
99
79
  }
100
80
  },
101
- created() {
102
- this.refresh()
81
+ // 处理全选按钮事件
82
+ onCheckAllChange(val) {
83
+ this.value_ = val ? this.options.map(m => m.value) : []
84
+ this.isIndeterminate = false
85
+ this.onChange()
103
86
  },
104
- watch: {
105
- value(val) {
106
- this.value_ = val
107
- this.setCheckAll()
108
- }
87
+ onCheckedChange(value) {
88
+ let checkedCount = value.length
89
+ this.checkAll = checkedCount === this.options.length
90
+ this.isIndeterminate = checkedCount > 0 && checkedCount < this.options.length
91
+ this.onChange()
92
+ },
93
+ // 清楚已选项
94
+ clear() {
95
+ this.value_ = this.value
96
+ this.onChange()
97
+ },
98
+ onChange() {
99
+ this.$emit('input', this.value_)
100
+ this.$emit('change', this.value_, this.selection, this.options)
101
+ }
102
+ },
103
+ created() {
104
+ this.refresh()
105
+ },
106
+ watch: {
107
+ value(val) {
108
+ this.value_ = val
109
+ this.setCheckAll()
109
110
  }
110
111
  }
112
+ }
111
113
  </script>