gyyg-components 0.3.5 → 0.3.7

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,6 +1,6 @@
1
1
  {
2
2
  "name": "gyyg-components",
3
- "version": "0.3.05",
3
+ "version": "0.3.07",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -24,7 +24,7 @@
24
24
  :span="item.span || 1"
25
25
  :contentClassName="direction == 'vertical' ? 'vertical-content' : item.contentClassName || ''"
26
26
  :labelStyle="direction == 'horizontal' ? { width: labelWidth + 'px', textAlign: 'right' } : {}"
27
- :contentStyle="item.contentStyle || {}"
27
+ :contentStyle="direction == 'horizontal' ? { width: 'calc(100% - (' + labelWidth + 'px))' }: {}"
28
28
  :labelClassName="direction == 'vertical' ? 'vertical-label' : item.labelClassName || ''"
29
29
  >
30
30
  <div v-if="item.type === 'img'">
@@ -1,15 +1,43 @@
1
1
  <template>
2
- <div class="btn-group">
2
+ <div :class="showTags ? 'has-tags' : ''">
3
+
3
4
  <div
4
- v-for="btn in btnList"
5
- :key="btn.id"
6
- v-has-permi="btn.hasPermi ? [btn.hasPermi] : undefined"
5
+ class="btn-group"
6
+ ref="btnGroup"
7
7
  >
8
- <template v-if="btn.isDot || btn.number">
9
- <el-badge
10
- :is-dot="btn.isDot"
11
- :value="btn.number"
12
- >
8
+ <div
9
+ v-for="btn in btnList"
10
+ :key="btn.id"
11
+ v-has-permi="btn.hasPermi ? [btn.hasPermi] : undefined"
12
+ >
13
+ <template v-if="btn.isDot || btn.number">
14
+ <el-badge
15
+ :is-dot="btn.isDot"
16
+ :value="btn.number"
17
+ >
18
+ <el-button
19
+ v-if="!btn['componentType']"
20
+ :disabled="btn.disabled"
21
+ :size="btn.size || 'small'"
22
+ :type="btn.type"
23
+ :icon="!btn.rightIcon ? btn.icon : ''"
24
+ :loading="btn.loading"
25
+ @click="btnClick(btn)"
26
+ >{{ btn.text }}
27
+ <i
28
+ v-if="btn.rightIcon"
29
+ :class="btn.icon + ' el-icon--right'"
30
+ ></i>
31
+ </el-button>
32
+ <div v-else>
33
+ <component
34
+ :is="btn['componentType']"
35
+ :btnInfo="btn"
36
+ ></component>
37
+ </div>
38
+ </el-badge>
39
+ </template>
40
+ <template v-else>
13
41
  <el-button
14
42
  v-if="!btn['componentType']"
15
43
  :disabled="btn.disabled"
@@ -30,33 +58,18 @@
30
58
  :btnInfo="btn"
31
59
  ></component>
32
60
  </div>
33
- </el-badge>
34
- </template>
35
- <template v-else>
36
- <el-button
37
- v-if="!btn['componentType']"
38
- :disabled="btn.disabled"
39
- :size="btn.size || 'small'"
40
- :type="btn.type"
41
- :icon="!btn.rightIcon ? btn.icon : ''"
42
- :loading="btn.loading"
43
- @click="btnClick(btn)"
44
- >{{ btn.text }}
45
- <i
46
- v-if="btn.rightIcon"
47
- :class="btn.icon + ' el-icon--right'"
48
- ></i>
49
- </el-button>
50
- <div v-else>
51
- <component
52
- :is="btn['componentType']"
53
- :btnInfo="btn"
54
- ></component>
55
- </div>
56
- </template>
61
+ </template>
57
62
 
58
63
 
64
+ </div>
59
65
  </div>
66
+ <mec-tags
67
+ v-if="showTags"
68
+ :tagsList="tagsData"
69
+ @tagClose="tagClose"
70
+ :btnWidth="btnWidth"
71
+ ></mec-tags>
72
+
60
73
  </div>
61
74
  </template>
62
75
  <script>
@@ -68,7 +81,46 @@ export default {
68
81
  btnList: {
69
82
  required: true,
70
83
  },
84
+ showTags: {
85
+ type: Boolean,
86
+ default: false
87
+ },
88
+ tagsList: {
89
+ type: [Array, Object],
90
+ }
91
+ },
92
+ data() {
93
+ return {
94
+ tagsData: null,
95
+ btnWidth: 0
96
+ }
97
+ },
98
+ watch: {
99
+ tagsList: {
100
+ handler(val) {
101
+ this.tagsData = val
102
+ },
103
+ deep: true,
104
+ immediate: true
105
+ },
106
+ btnList: {
107
+ handler(val) {
108
+ if (this.$refs.btnGroup) {
109
+ this.btnWidth = this.$refs.btnGroup.offsetWidth
110
+
111
+ }
112
+ },
113
+ deep: true,
114
+ immediate: true
115
+ }
71
116
  },
117
+ mounted() {
118
+ this.$nextTick(() => {
119
+ this.btnWidth = this.$refs.btnGroup.offsetWidth
120
+ console.log('width: calc(100% - (' + this.btnWidth + ' px))')
121
+ })
122
+ },
123
+
72
124
  methods: {
73
125
  // 按钮点击事件
74
126
  btnClick(btn) {
@@ -76,20 +128,25 @@ export default {
76
128
  if (btn.trigger) {
77
129
  btn.trigger()
78
130
  }
131
+ },
132
+ tagClose(key, tag) {
133
+ this.$emit('tagClose', key, tag);
79
134
  }
80
135
  },
81
136
  }
82
137
  </script>
83
138
  <style lang="less" scoped>
84
- /deep/ .el-button {
139
+ /deep/ .el-button {
140
+ font-weight: normal;
141
+
85
142
  &:not(:disabled):hover {
86
143
  transform: translateY(-1px);
87
144
  }
88
145
  }
146
+
89
147
  .btn-group {
90
148
  display: flex;
91
149
  align-items: center;
92
- flex-wrap: wrap;
93
150
 
94
151
  &>div {
95
152
  margin-left: 5px;
@@ -99,6 +156,13 @@ export default {
99
156
  margin-left: 0;
100
157
  }
101
158
  }
159
+
160
+
161
+ }
162
+
163
+ .has-tags {
164
+ display: flex;
165
+ align-content: center;
102
166
  }
103
167
 
104
168
  /deep/ .el-badge__content.is-fixed {
@@ -18,6 +18,7 @@
18
18
  @close="closeMethod"
19
19
  :destroy-on-close="destroyOnClose"
20
20
  :modal='modal'
21
+ :style="'height:' + height"
21
22
  >
22
23
  <div slot="title" style="font-size: 16px; color: #303133;">
23
24
  <el-icon :class="titleIcon" style="color: #1890ff; font-size: 18px;margin-right: 5px;"></el-icon>
@@ -90,9 +91,13 @@ export default {
90
91
  default: ""
91
92
  },
92
93
  titleIcon: {
93
- type: Boolean,
94
- default: false,
94
+ type: String,
95
+ default: '',
95
96
  },
97
+ height: {
98
+ type: String,
99
+ default: 'auto'
100
+ }
96
101
  },
97
102
  data() {
98
103
  return {
@@ -135,6 +140,7 @@ export default {
135
140
  display: flex;
136
141
  justify-content: center;
137
142
  align-items: center;
143
+ margin: auto 0;
138
144
  .el-dialog {
139
145
  display: flex;
140
146
  flex-direction: column;
@@ -167,6 +173,7 @@ export default {
167
173
  overflow: auto;
168
174
  padding: 20px;
169
175
  padding-bottom: 52px;
176
+ height: calc(100% - 50px);
170
177
  }
171
178
 
172
179
  .el-dialog__footer {
@@ -222,6 +229,9 @@ export default {
222
229
  }
223
230
  }
224
231
  }
232
+ /deep/ .el-dialog {
233
+ height: 100%;
234
+ }
225
235
  .shan-maintenance-dialog {
226
236
  /deep/ .el-dialog {
227
237
  height: 90%;
@@ -1,28 +1,28 @@
1
1
  <template>
2
- <el-radio-group
3
- v-model="radio"
4
- :value="radio"
5
- @change="handleChange"
6
- v-bind="$attrs"
7
- class="radio-group"
8
- >
9
- <el-radio
10
- v-for="item in options"
11
- :label="item[props.value]"
12
- :key="item[props.value]"
13
- :value="item[props.value]"
14
- :border="border"
15
- >{{ item[props.label] }}</el-radio>
16
- </el-radio-group>
2
+ <el-radio-group
3
+ v-model="radio"
4
+ :value="radio"
5
+ @change="handleChange"
6
+ v-bind="$attrs"
7
+ class="radio-group"
8
+ >
9
+ <el-radio
10
+ v-for="item in option"
11
+ :label="item[props.value]"
12
+ :key="item[props.value]"
13
+ :value="item[props.value]"
14
+ :border="border"
15
+ >{{ item[props.label] }}</el-radio>
16
+ </el-radio-group>
17
17
  </template>
18
18
  <script>
19
19
  export default {
20
- name: 'mec-radio',
21
- props: {
20
+ name: 'mec-radio',
21
+ props: {
22
22
  value: {},
23
23
  border: {
24
- type: Boolean,
25
- default: false,
24
+ type: Boolean,
25
+ default: false,
26
26
  },
27
27
  options: {},
28
28
  props: {
@@ -34,30 +34,53 @@ export default {
34
34
  },
35
35
  },
36
36
  },
37
- data() {
38
- return {
39
- radio: this.value,
40
- }
37
+ data() {
38
+ return {
39
+ radio: this.value,
40
+ option: []
41
+ }
42
+ },
43
+ watch: {
44
+ value: {
45
+ handler(val) {
46
+ this.radio = val
47
+ },
48
+ immediate: true
41
49
  },
42
- watch: {
43
- value: {
44
- handler(val) {
45
- this.radio = val
46
- },
47
- immediate: true
48
- },
49
- radio: {
50
- handler(val) {
51
- this.$emit('input', val)
52
- this.$emit('update:value', val)
53
- },
50
+ radio: {
51
+ handler(val) {
52
+ this.$emit('input', val)
53
+ this.$emit('update:value', val)
54
+ },
55
+ },
56
+ options: {
57
+ handler: function (val) {
58
+ if (!Array.isArray(this.options) && this.options) {
59
+ if (this.options instanceof Promise) {
60
+ this.options.then(val => {
61
+ this.option = val.data || val;
62
+ });
63
+ }
64
+ if (typeof this.options == 'function') {
65
+ this.options().then(val => {
66
+ this.option = val.data || val;
67
+ });
68
+ }
69
+
70
+ } else {
71
+ this.option = this.options;
54
72
  }
73
+ },
74
+ deep: true,
75
+ immediate: true,
55
76
  },
56
- methods: {
57
- handleChange(e) {
58
- this.$emit('change', e)
59
- },
60
- }
77
+ },
78
+ methods: {
79
+ handleChange(val) {
80
+ let info = this.option.filter(item => item[this.props.value] === val)
81
+ this.$emit('change', val, info.length > 0 ? info[0] : {})
82
+ },
83
+ }
61
84
 
62
85
  }
63
86
  </script>
@@ -100,9 +100,10 @@ export default {
100
100
  methods: {
101
101
  handleChange(val) {
102
102
  this.selected = val;
103
+ let info = this.option.filter(item => item[this.props.value] == val)
103
104
  this.$emit("input", this.selected);
104
105
  this.$emit('update:value', val)
105
- this.$emit("change", val);
106
+ this.$emit("change", val, info.length > 0 ? info[0] : {});
106
107
  },
107
108
  clear() {
108
109
  this.selected = '';
@@ -1,9 +1,158 @@
1
1
  <template>
2
- <div>tags列表</div>
2
+ <div
3
+ class="mec-tags"
4
+ :style="{ width: `calc(100% - ${btnWidth}px)` }"
5
+ ref="tagsContainer"
6
+ >
7
+ <el-button
8
+ icon="el-icon-arrow-left"
9
+ circle
10
+ v-show="showArrow"
11
+ @click="scrollLeft"
12
+ ></el-button>
13
+ <div
14
+ class="tags-box"
15
+ ref="tagsBox"
16
+ >
17
+ <el-tag
18
+ v-for="(tag, index) in tagsData"
19
+ :key="index"
20
+ closable
21
+ :type="tag.type || ''"
22
+ @close="handleClose(index, tag)"
23
+ >
24
+ {{ tag.label }}: {{ tag.value }}
25
+ </el-tag>
26
+ </div>
27
+ <el-button
28
+ style="margin-left: 3px"
29
+ icon="el-icon-arrow-right"
30
+ circle
31
+ v-show="showArrow"
32
+ @click="scrollRight"
33
+ ></el-button>
34
+ </div>
3
35
  </template>
4
36
  <script>
5
37
  export default {
6
- name: 'MecTags'
38
+ name: 'MecTags',
39
+ props: {
40
+ tagsList: {
41
+ type: [Array, Object],
42
+ },
43
+ btnWidth: {
44
+ // type: Number,
45
+ },
46
+ },
47
+ data() {
48
+ return {
49
+ tagsData: [],
50
+ tagsContainerWidth: 0,
51
+ showArrow: false,
52
+ }
53
+ },
54
+ watch: {
55
+ tagsList: {
56
+ handler(val) {
57
+ console.log(val)
58
+ this.tagsData = []
59
+ this.tagsData = [...val] ;
60
+ if(this.tagsData.length > 0) {
61
+ this.$nextTick(() => {
62
+ this.updateTagsContainerWidth();
63
+ });
64
+ }
65
+ },
66
+ deep: true,
67
+ immediate: true
68
+ }
69
+ },
70
+ mounted() {
71
+ this.updateTagsContainerWidth();
72
+ window.addEventListener('resize', this.updateTagsContainerWidth);
73
+ },
74
+ beforeDestroy() {
75
+ window.removeEventListener('resize', this.updateTagsContainerWidth);
76
+ },
77
+ methods: {
78
+ handleClose(index, tag) {
79
+ this.tagsData.splice(index, 1);
80
+ this.$emit('tagClose', tag.key, tag);
81
+ },
82
+ scrollLeft() {
83
+ const tagsBox = this.$refs.tagsBox;
84
+ tagsBox.scrollBy({
85
+ left: -150,
86
+ behavior: 'smooth'
87
+ });
88
+ },
89
+ scrollRight() {
90
+ const tagsBox = this.$refs.tagsBox;
91
+ tagsBox.scrollBy({
92
+ left: 150,
93
+ behavior: 'smooth'
94
+ });
95
+ },
96
+
97
+ updateTagsContainerWidth() {
98
+ this.tagsContainerWidth = this.$refs.tagsContainer.offsetWidth;
99
+ const boxWidth = this.$refs.tagsBox.scrollWidth;
100
+ if (boxWidth > this.tagsContainerWidth) {
101
+ this.showArrow = true;
102
+ } else {
103
+ this.showArrow = false;
104
+ }
105
+ }
106
+ }
7
107
  }
8
108
 
9
109
  </script>
110
+ <style lang="less" scoped>
111
+ .mec-tags {
112
+ height: 40px;
113
+ margin-left: 10px;
114
+ display: flex;
115
+ align-items: center;
116
+
117
+ /deep/ .el-tag {
118
+ margin-right: 10px;
119
+ margin-bottom: 10px;
120
+ margin-bottom: 5px;
121
+ margin-top: 5px;
122
+ font-size: 14px;
123
+ height: 30px;
124
+ line-height: 30px;
125
+ padding: 0 5px;
126
+ color: #1890ff;
127
+
128
+ .el-icon-close {
129
+ right: 0;
130
+ }
131
+ }
132
+
133
+ /deep/ .el-button.is-circle {
134
+ padding: 0;
135
+ width: 24px;
136
+ height: 24px;
137
+ line-height: 24px;
138
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
139
+ margin-right: 3px;
140
+ flex-grow: 0;
141
+ flex-shrink: 0;
142
+
143
+ &:hover,
144
+ &:focus {
145
+ background: #1890ff;
146
+ border-color: #1890ff;
147
+ color: #fff;
148
+ }
149
+ }
150
+ }
151
+
152
+ .tags-box {
153
+ display: flex;
154
+ overflow-x: auto;
155
+ scroll-behavior: smooth;
156
+ scrollbar-width: none;
157
+ }
158
+ </style>
@@ -20,9 +20,6 @@ export default {
20
20
 
21
21
  },
22
22
  },
23
- created() {
24
- console.log(this.tableData)
25
- },
26
23
  computed: {
27
24
  statusStyle() {
28
25
  if (this.tableData.statusStyle) return this.tableData.statusStyle(this.scope.row);