gyyg-components 0.3.20 → 0.3.21

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.20",
3
+ "version": "0.3.21",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -117,7 +117,6 @@ export default {
117
117
  mounted() {
118
118
  this.$nextTick(() => {
119
119
  this.btnWidth = this.$refs.btnGroup.offsetWidth
120
- console.log('width: calc(100% - (' + this.btnWidth + ' px))')
121
120
  })
122
121
  },
123
122
 
@@ -1,175 +1,225 @@
1
1
  <template>
2
- <div class="checkbox-group">
3
- <el-checkbox
4
- :indeterminate="isIndeterminate"
5
- v-if="isCheckAll"
6
- v-model="checkAll"
7
- @change="handleCheckAllChange">全选</el-checkbox>
8
- <div style="margin: 15px 0;" v-if="isCheckAll" ></div>
9
- <el-checkbox-group v-model="checkbox" @change="handleCheckedCitiesChange" :disabled="disabled">
10
- <el-checkbox v-for="(item, index) in option"
11
- :label="item[props.value]"
12
- :disabled="item.disabled"
13
- :key="index"
14
- >{{ item[props.label] }}</el-checkbox>
15
- <el-input
16
- v-if="showOther"
17
- v-model="inputValue"
18
- :disabled="inputDisabled"
19
- placeholder="请输入其他"
20
- @input="inputChange"
21
- style="display: inline-block; margin-left: 10px;" />
22
- </el-checkbox-group>
23
-
24
- </div>
2
+ <div class="checkbox-group">
3
+ <el-checkbox
4
+ :indeterminate="isIndeterminate"
5
+ v-if="isCheckAll"
6
+ v-model="checkAll"
7
+ @change="handleCheckAllChange"
8
+ >全选</el-checkbox
9
+ >
10
+ <div style="margin: 15px 0" v-if="isCheckAll"></div>
11
+ <el-checkbox-group
12
+ v-model="checkbox"
13
+ @change="handleCheckedCitiesChange"
14
+ :disabled="disabled"
15
+ >
16
+ <div v-if="isHover">
17
+ <el-tooltip
18
+ v-for="(item, index) in option"
19
+ :key="index"
20
+ class="item"
21
+ effect="dark"
22
+ :content="item[contentFileld]"
23
+ placement="top-start"
24
+ >
25
+ <el-checkbox
26
+ :label="item[props.value]"
27
+ :disabled="item.disabled"
28
+ @change="(val) => checkBoxChange(val, item)"
29
+ >{{ item[props.label] }}</el-checkbox
30
+ >
31
+ </el-tooltip>
32
+ </div>
33
+ <div v-else>
34
+ <el-checkbox
35
+ v-for="(item, index) in option"
36
+ :label="item[props.value]"
37
+ :disabled="item.disabled"
38
+ :key="index"
39
+ @change="(val) => checkBoxChange(val, item)"
40
+ >{{ item[props.label] }}</el-checkbox
41
+ >
42
+ </div>
43
+ <el-input
44
+ v-if="showOther"
45
+ v-model="inputValue"
46
+ :disabled="inputDisabled"
47
+ placeholder="请输入其他"
48
+ @input="inputChange"
49
+ style="display: inline-block; margin-left: 10px"
50
+ />
51
+ </el-checkbox-group>
52
+ </div>
25
53
  </template>
26
54
  <script>
27
55
  export default {
28
- name: 'mec-checkbox',
56
+ name: "mec-checkbox",
57
+ props: {
58
+ value: {},
59
+ options: {},
29
60
  props: {
30
- value: {},
31
- options: {},
32
- props: {
33
- default() {
34
- return {
35
- label: 'name',
36
- value: 'id'
37
- }
38
- }
39
- },
40
- isCheckAll: {
41
- default() {
42
- return false;
43
- }
44
- },
45
- showOther: {
46
- default() {
47
- return false;
48
- }
49
- },
50
- otherValue: {
51
- default() {
52
- return '';
53
- }
54
- },
55
- checkText: {
56
- default() {
57
- return '其他'
58
- }
59
- },
60
- disabled: {
61
- default() {
62
- return false;
63
- }
64
- }
65
- },
66
- data() {
61
+ default() {
67
62
  return {
68
- checkAll: false,
69
- checkbox: [],
70
- isIndeterminate: true,
71
- option: [],
72
- inputValue: '',
73
- inputDisabled: true
63
+ label: "name",
64
+ value: "id",
74
65
  };
66
+ },
75
67
  },
76
- watch: {
77
- value: {
78
- handler (val) {
79
- this.checkbox = [].concat(val)
80
- },
81
- immediate: true
82
- },
83
- options: {
84
- handler: function (val) {
85
- //判断options是否为promise
86
- if (typeof val !== 'function' && val && !val.then) {
87
- this.option = this.options;
88
- let nameList = this.getNameListByIds(this.value, this.option)
89
- this.inputDisabled = nameList.filter(item => {
90
- return item.includes(this.checkText)
91
- }).length == 0
92
- }
93
- },
94
- deep: true,
95
- immediate: true,
96
- },
97
- otherValue: {
98
- handler(val) {
99
- this.inputValue = val;
100
- console.log(val, 'otherValue')
101
- },
102
- immediate: true
103
- }
68
+ isCheckAll: {
69
+ default() {
70
+ return false;
71
+ },
104
72
  },
105
- mounted() {
106
- if (!Array.isArray(this.options) && this.options) {
107
- if(this.options instanceof Promise) {
108
- this.options.then(val => {
109
- this.option = val.data || val;
110
- let nameList = this.getNameListByIds(this.value, this.option)
111
- this.inputDisabled = nameList.filter(item => {
112
- return item.includes(this.checkText)
113
- }).length == 0
114
- });
115
- }
116
- if(typeof this.options == 'function') {
117
- this.options().then(val => {
118
- this.option = val.data || val;
119
- let nameList = this.getNameListByIds(this.value, this.option)
120
- this.inputDisabled = nameList.filter(item => {
121
- return item.includes(this.checkText)
122
- }).length == 0
123
- });
124
- }
125
-
126
- } else {
127
- this.option = this.options;
128
- }
129
-
73
+ showOther: {
74
+ default() {
75
+ return false;
76
+ },
77
+ },
78
+ otherValue: {
79
+ default() {
80
+ return "";
81
+ },
82
+ },
83
+ checkText: {
84
+ default() {
85
+ return "其他";
86
+ },
87
+ },
88
+ disabled: {
89
+ default() {
90
+ return false;
91
+ },
92
+ },
93
+ isHover: {
94
+ default() {
95
+ return false;
96
+ },
97
+ },
98
+ contentFileld: {
99
+ default() {
100
+ return "content";
101
+ },
130
102
  },
131
- computed: {
132
- checkboxAll () {
133
- return this.option.map(item => {
134
- return item[this.props.value]
135
- })
103
+ },
104
+ data() {
105
+ return {
106
+ checkAll: false,
107
+ checkbox: [],
108
+ isIndeterminate: true,
109
+ option: [],
110
+ inputValue: "",
111
+ inputDisabled: true,
112
+ };
113
+ },
114
+ watch: {
115
+ value: {
116
+ handler(val) {
117
+ this.checkbox = [].concat(val);
118
+ },
119
+ immediate: true,
120
+ },
121
+ options: {
122
+ handler: function (val) {
123
+ //判断options是否为promise
124
+ if (typeof val !== "function" && val && !val.then) {
125
+ this.option = this.options;
126
+ let nameList = this.getNameListByIds(this.value, this.option);
127
+ this.inputDisabled =
128
+ nameList.filter((item) => {
129
+ return item.includes(this.checkText);
130
+ }).length == 0;
136
131
  }
132
+ },
133
+ deep: true,
134
+ immediate: true,
135
+ },
136
+ otherValue: {
137
+ handler(val) {
138
+ this.inputValue = val;
139
+ console.log(val, "otherValue");
140
+ },
141
+ immediate: true,
137
142
  },
138
- methods: {
139
- handleCheckAllChange(val) {
140
- this.checkbox = val ? this.checkboxAll : [];
141
- this.isIndeterminate = false;
142
- },
143
- handleCheckedCitiesChange(value) {
144
- let checkedCount = value.length;
145
- this.checkAll = checkedCount === this.checkboxAll.length;
146
- this.isIndeterminate = checkedCount > 0 && checkedCount < this.checkboxAll.length;
147
- this.$emit('input', value)
148
- this.$emit('update:value', value)
149
- let nameList = this.getNameListByIds(value, this.option)
150
- this.inputDisabled = nameList.filter(item => {
151
- return item.includes(this.checkText)
152
- }).length == 0
153
- console.log(this.inputDisabled, 'this.inputDisabledthis.inputDisabledthis.inputDisabled')
154
- },
155
- // 根据 id 数组获取对应的 name 列表
156
- getNameListByIds(ids, array) {
157
- return ids.map(id => {
158
- const reason = array.find(item => item[this.props.value] === id);
159
- return reason ? reason[this.props.label] : '';
160
- }).filter(name => name); // 过滤掉空值
161
- },
162
- // 其他输入框输入
163
- inputChange(val) {
164
- this.$emit('update:otherValue', val)
165
- },
143
+ },
144
+ mounted() {
145
+ if (!Array.isArray(this.options) && this.options) {
146
+ if (this.options instanceof Promise) {
147
+ this.options.then((val) => {
148
+ this.option = val.data || val;
149
+ let nameList = this.getNameListByIds(this.value, this.option);
150
+ this.inputDisabled =
151
+ nameList.filter((item) => {
152
+ return item.includes(this.checkText);
153
+ }).length == 0;
154
+ });
155
+ }
156
+ if (typeof this.options == "function") {
157
+ this.options().then((val) => {
158
+ this.option = val.data || val;
159
+ let nameList = this.getNameListByIds(this.value, this.option);
160
+ this.inputDisabled =
161
+ nameList.filter((item) => {
162
+ return item.includes(this.checkText);
163
+ }).length == 0;
164
+ });
165
+ }
166
+ } else {
167
+ this.option = this.options;
166
168
  }
169
+ },
170
+ computed: {
171
+ checkboxAll() {
172
+ return this.option.map((item) => {
173
+ return item[this.props.value];
174
+ });
175
+ },
176
+ },
177
+ methods: {
178
+ handleCheckAllChange(val) {
179
+ this.checkbox = val ? this.checkboxAll : [];
180
+ this.isIndeterminate = false;
181
+ },
182
+ handleCheckedCitiesChange(value) {
183
+ let checkedCount = value.length;
184
+ this.checkAll = checkedCount === this.checkboxAll.length;
185
+ this.isIndeterminate =
186
+ checkedCount > 0 && checkedCount < this.checkboxAll.length;
187
+
188
+ this.$emit("input", value);
189
+ this.$emit("update:value", value);
190
+ let nameList = this.getNameListByIds(value, this.option);
191
+ this.inputDisabled =
192
+ nameList.filter((item) => {
193
+ return item.includes(this.checkText);
194
+ }).length == 0;
195
+ },
196
+ // 根据 id 数组获取对应的 name 列表
197
+ getNameListByIds(ids, array) {
198
+ return ids
199
+ .map((id) => {
200
+ const reason = array.find((item) => item[this.props.value] === id);
201
+ return reason ? reason[this.props.label] : "";
202
+ })
203
+ .filter((name) => name); // 过滤掉空值
204
+ },
205
+ // 其他输入框输入
206
+ inputChange(val) {
207
+ this.$emit("update:otherValue", val);
208
+ },
209
+ checkBoxChange(val, item) {
210
+ if (val) {
211
+ this.$emit("checkBoxSelect", item);
212
+ } else {
213
+ this.$emit("checkBoxSelect", {});
214
+ }
215
+ },
216
+ },
167
217
  };
168
218
  </script>
169
219
  <style lang="less" scoped>
170
220
  .checkbox-group {
171
- /deep/ .el-checkbox__label {
172
- font-weight: normal;
173
- }
174
- }
221
+ /deep/ .el-checkbox__label {
222
+ font-weight: normal;
223
+ }
224
+ }
175
225
  </style>
@@ -22,7 +22,10 @@
22
22
  export default {
23
23
  name: 'mec-date-picker',
24
24
  props: {
25
- value: {},
25
+ value: {
26
+ type: [String, Array],
27
+ default: ''
28
+ },
26
29
  dateType: {
27
30
  type: String,
28
31
  default: 'date'
@@ -12,20 +12,21 @@
12
12
  :key="item[props.value]"
13
13
  :value="item[props.value]"
14
14
  :border="border"
15
- >{{ item[props.label] }}
16
- </el-radio>
17
- <el-input
15
+ >{{ item[props.label] }}
16
+ </el-radio>
17
+ <el-input
18
18
  v-if="showOther"
19
- v-model="inputValue"
20
- :disabled="inputDisabled"
21
- placeholder="请输入"
22
- style="display: inline-block; margin-top: 10px;" />
23
- <!-- @input="inputChange" -->
19
+ v-model="inputValue"
20
+ :disabled="inputDisabled"
21
+ placeholder="请输入"
22
+ style="display: inline-block; margin-top: 10px"
23
+ />
24
+ <!-- @input="inputChange" -->
24
25
  </el-radio-group>
25
26
  </template>
26
27
  <script>
27
28
  export default {
28
- name: 'mec-radio',
29
+ name: "mec-radio",
29
30
  props: {
30
31
  value: {},
31
32
  border: {
@@ -36,100 +37,112 @@ export default {
36
37
  props: {
37
38
  default() {
38
39
  return {
39
- label: 'label',
40
- value: 'value',
41
- }
40
+ label: "label",
41
+ value: "value",
42
+ };
42
43
  },
43
44
  },
44
45
  showOther: {
45
46
  type: Boolean,
46
- default: false
47
+ default: false,
47
48
  },
48
49
  checkText: {
49
- default() {
50
- return '其他'
51
- }
50
+ default() {
51
+ return "其他";
52
+ },
52
53
  },
53
54
  otherValue: {
54
- default: ""
55
- }
55
+ default: "",
56
+ },
56
57
  },
57
58
  data() {
58
59
  return {
59
60
  radio: this.value,
60
61
  option: [],
61
- inputValue: '',
62
- inputDisabled: true
63
- }
62
+ inputValue: "",
63
+ inputDisabled: true,
64
+ };
64
65
  },
65
66
  watch: {
66
67
  value: {
67
68
  handler(val) {
68
- this.radio = val
69
+ this.radio = val;
69
70
  },
70
- immediate: true
71
+ immediate: true,
71
72
  },
72
73
  radio: {
73
74
  handler(val) {
74
- this.$emit('input', val)
75
- this.$emit('update:value', val)
75
+ this.$emit("input", val);
76
+ this.$emit("update:value", val);
76
77
  },
77
78
  },
78
79
  options: {
79
80
  handler: function (val) {
80
81
  if (!Array.isArray(this.options) && this.options) {
81
82
  if (this.options instanceof Promise) {
82
- this.options.then(val => {
83
+ this.options.then((val) => {
83
84
  this.option = val.data || val;
85
+ let name = this.getNameById(this.value, this.option);
86
+ if (name.includes(this.checkText)) {
87
+ this.inputDisabled = false;
88
+ } else {
89
+ this.inputDisabled = true;
90
+ }
84
91
  });
85
92
  }
86
- if (typeof this.options == 'function') {
87
- this.options().then(val => {
93
+ if (typeof this.options == "function") {
94
+ this.options().then((val) => {
88
95
  this.option = val.data || val;
96
+ let name = this.getNameById(this.value, this.option);
97
+ if (name.includes(this.checkText)) {
98
+ this.inputDisabled = false;
99
+ } else {
100
+ this.inputDisabled = true;
101
+ }
89
102
  });
90
103
  }
91
-
92
104
  } else {
93
105
  this.option = val;
94
- }
95
- let name = this.getNameById(this.value, this.option)
96
- if(name.includes(this.checkText)) {
97
- this.inputDisabled = false
98
- } else {
99
- this.inputDisabled = true
106
+ let name = this.getNameById(this.value, this.option);
107
+ if (name.includes(this.checkText)) {
108
+ this.inputDisabled = false;
109
+ } else {
110
+ this.inputDisabled = true;
111
+ }
100
112
  }
101
113
  },
102
114
  deep: true,
103
115
  immediate: true,
104
116
  },
105
117
  otherValue: {
106
- handler(val) {
107
- this.inputValue = val;
108
- console.log(val, 'otherValue')
109
- },
110
- immediate: true
111
- }
118
+ handler(val) {
119
+ this.inputValue = val;
120
+ console.log(val, "otherValue");
121
+ },
122
+ immediate: true,
123
+ },
112
124
  },
113
125
  methods: {
114
126
  handleChange(val) {
115
- let info = this.option.filter(item => item[this.props.value] === val)
116
- console.log(info, 'info')
117
- let name = this.getNameById(val, this.option)
118
- if(name.includes(this.checkText)) {
119
- this.inputDisabled = false
127
+ let info = this.option.filter((item) => item[this.props.value] === val);
128
+ console.log(info, "info");
129
+ let name = this.getNameById(val, this.option);
130
+ if (name.includes(this.checkText)) {
131
+ this.inputDisabled = false;
120
132
  } else {
121
- this.inputDisabled = true
122
- this.inputValue = ''
133
+ this.inputDisabled = true;
134
+ this.inputValue = "";
123
135
  }
124
- this.$emit('change', val, info.length > 0 ? info[0] : {})
136
+ this.$emit("change", val, info.length > 0 ? info[0] : {});
125
137
  },
126
- // 根据 id 数组获取对应的 name 列表
127
- getNameById(id, array) {
128
- console.log(id, array)
129
- if(!id) return ''
130
- return array[array.findIndex(item => item[this.props.value] === id)][this.props.label]
131
- },
132
- }
133
-
134
- }
138
+ // 根据 id 数组获取对应的 name 列表
139
+ getNameById(id, array) {
140
+ console.log(id, array);
141
+ if (!id) return "";
142
+ return array[array.findIndex((item) => item[this.props.value] === id)][
143
+ this.props.label
144
+ ];
145
+ },
146
+ },
147
+ };
135
148
  </script>
@@ -330,7 +330,6 @@ export default {
330
330
  watch: {
331
331
  columns: {
332
332
  handler: function (val) {
333
- console.log(val);
334
333
  this.column = [...val];
335
334
  },
336
335
  immediate: true,