meixioacomponent 0.3.85 → 0.3.86

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": "meixioacomponent",
3
- "version": "0.3.85",
3
+ "version": "0.3.86",
4
4
  "private": false,
5
5
  "author": "YuRi",
6
6
  "main": "lib/meixioacomponent.umd.min.js",
@@ -6,8 +6,9 @@
6
6
  size="mini"
7
7
  @visible-change="visibleChange"
8
8
  clearable
9
+ :disabled="disabled"
9
10
  :multiple="multiple"
10
- style="width: 100%"
11
+ style="width: 100%;"
11
12
  @clear="clear"
12
13
  @remove-tag="removeTag"
13
14
  >
@@ -19,7 +20,7 @@
19
20
  :value="item[`${nodeKey}`]"
20
21
  :label="item[`${label}`]"
21
22
  >
22
- <div style="display: none"></div>
23
+ <div style="display: none;"></div>
23
24
  </el-option>
24
25
  <el-tree
25
26
  ref="tree"
@@ -39,47 +40,47 @@
39
40
 
40
41
  <script>
41
42
  export default {
42
- name: "baseTreeSelect",
43
+ name: 'baseTreeSelect',
43
44
 
44
45
  data() {
45
46
  return {
46
47
  optionData: null,
47
- };
48
+ }
48
49
  },
49
50
  created() {
50
- this.setOptionData();
51
+ this.setOptionData()
51
52
  },
52
53
  mounted() {
53
54
  if (!this.isEmpty(this.data)) {
54
- this.init(this.value);
55
+ this.init(this.value)
55
56
  }
56
57
  },
57
58
  props: {
58
59
  // v-model绑定
59
60
  value: {
60
61
  type: [String, Number, Array],
61
- default: "",
62
+ default: '',
62
63
  },
63
64
  // 树形的数据
64
65
  data: {
65
66
  type: Array,
66
67
  default: function () {
67
- return [];
68
+ return []
68
69
  },
69
70
  },
70
71
  // 每个树节点用来作为唯一标识的属性
71
72
  nodeKey: {
72
73
  type: [String, Number],
73
- default: "id",
74
+ default: 'id',
74
75
  },
75
76
  // tree的props配置
76
77
  props: {
77
78
  type: Object,
78
79
  default: function () {
79
80
  return {
80
- label: "label",
81
- children: "children",
82
- };
81
+ label: 'label',
82
+ children: 'children',
83
+ }
83
84
  },
84
85
  },
85
86
 
@@ -92,83 +93,88 @@ export default {
92
93
  type: Boolean,
93
94
  default: false,
94
95
  },
96
+
97
+ disabled: {
98
+ type: Boolean,
99
+ default: false,
100
+ },
95
101
  },
96
102
  computed: {
97
103
  label() {
98
- return this.$props.props.label;
104
+ return this.$props.props.label
99
105
  },
100
106
  },
101
107
  methods: {
102
108
  // 设置optionsData
103
109
  setOptionData() {
104
- this.optionData = [];
105
- let obj = {};
106
- this.$set(obj, `${this.label}`, "");
107
- this.$set(obj, `${this.$props.nodeKey}`, "");
108
- this.optionData.push(obj);
110
+ this.optionData = []
111
+ let obj = {}
112
+ this.$set(obj, `${this.label}`, '')
113
+ this.$set(obj, `${this.$props.nodeKey}`, '')
114
+ this.optionData.push(obj)
109
115
  },
110
116
  // 是否为空
111
117
  isEmpty(val) {
112
118
  for (let key in val) {
113
- return false;
119
+ return false
114
120
  }
115
- return true;
121
+ return true
116
122
  },
117
123
  // 当选择器为单选时调用该方法
118
124
  handleNodeClick(data) {
119
- if (this.$props.multiple) return;
120
- let props = this.$props.props;
125
+ if (this.$props.multiple) return
126
+ let props = this.$props.props
121
127
  if (data[`${props.children}`]) {
122
128
  if (this.$props.checkFather) {
123
- this.$emit("input", data[this.nodeKey]);
124
- this.$refs.select.visible = false;
129
+ this.$emit('input', data[this.nodeKey])
130
+ this.$refs.select.visible = false
125
131
  } else {
126
132
  // 当父节点不能点击时,不让它高亮
127
- this.$refs.tree.setCurrentKey(this.value);
133
+ this.$refs.tree.setCurrentKey(this.value)
128
134
  }
129
135
  } else {
130
- this.$emit("input", data[this.nodeKey]);
131
- this.$refs.select.visible = false;
136
+ this.$emit('input', data[this.nodeKey])
137
+ this.$refs.select.visible = false
132
138
  }
133
139
  },
134
140
  // 初始化并且赋值
135
141
  init(val) {
136
142
  // 是否是多选
137
143
  if (this.multiple) {
138
- this.setMultipleValue(val);
144
+ this.setMultipleValue(val)
139
145
  } else {
140
- this.setSingleValue(val);
146
+ this.setSingleValue(val)
141
147
  }
142
148
  },
143
149
  // 当选择框出现时
144
150
  visibleChange(e) {
145
151
  if (e) {
146
- let selectDom = document.querySelector(".is-current");
152
+ let selectDom = document.querySelector('.is-current')
147
153
  this.$nextTick(() => {
148
- this.$refs.select.scrollToOption({ $el: selectDom });
149
- });
154
+ this.$refs.select.scrollToOption({ $el: selectDom })
155
+ })
150
156
  }
151
157
  },
152
158
  // 清空值
153
159
  clear() {
154
- this.$emit("input", "");
160
+ this.$emit('input', '')
155
161
  },
156
162
  // 多选被选择时
157
163
  handleNodeMultiplyClick(
158
164
  checkedNodes,
159
165
  checkedKeys,
160
166
  halfCheckedNodes,
161
- halfCheckedKeys
167
+ halfCheckedKeys,
162
168
  ) {
163
- this.$emit("input", checkedKeys.checkedKeys);
169
+ this.$emit('input', checkedKeys.checkedKeys)
164
170
  },
165
171
  // 移除tag时
166
172
  removeTag(e) {
167
173
  let index = this.value.findIndex((item) => {
168
- return item == e;
169
- });
174
+ return item == e
175
+ })
170
176
  if (index > -1) {
171
- this.value.splice(index, 1);
177
+ this.value.splice(index, 1)
172
178
  }
173
179
  },
174
180
 
@@ -176,21 +182,21 @@ export default {
176
182
  setMultipleValue(val) {
177
183
  if (val.length > 0) {
178
184
  this.$nextTick(() => {
179
- let nodeKey = this.$props.nodeKey;
180
- let label = this.label;
181
- this.$refs.tree.setCheckedKeys(val, false);
182
- let nodes = this.$refs.tree.getCheckedNodes();
183
- this.optionData = [];
185
+ let nodeKey = this.$props.nodeKey
186
+ let label = this.label
187
+ this.$refs.tree.setCheckedKeys(val, false)
188
+ let nodes = this.$refs.tree.getCheckedNodes()
189
+ this.optionData = []
184
190
  nodes.forEach((item) => {
185
- let obj = {};
186
- this.$set(obj, `${nodeKey}`, item[`${nodeKey}`]);
187
- this.$set(obj, `${label}`, item[`${label}`]);
188
- this.optionData.push(obj);
189
- });
190
- });
191
+ let obj = {}
192
+ this.$set(obj, `${nodeKey}`, item[`${nodeKey}`])
193
+ this.$set(obj, `${label}`, item[`${label}`])
194
+ this.optionData.push(obj)
195
+ })
196
+ })
191
197
  } else {
192
- this.setOptionData();
193
- this.$refs.tree.setCheckedKeys([]);
198
+ this.setOptionData()
199
+ this.$refs.tree.setCheckedKeys([])
194
200
  }
195
201
  },
196
202
 
@@ -198,29 +204,29 @@ export default {
198
204
  setSingleValue(val) {
199
205
  if (val) {
200
206
  this.$nextTick(() => {
201
- this.$refs.tree.setCurrentKey(val);
202
- let node = this.$refs.tree.getNode(val);
203
- this.optionData[0][`${this.$props.nodeKey}`] = val;
204
- this.optionData[0][`${this.label}`] = node[`${this.label}`];
205
- });
207
+ this.$refs.tree.setCurrentKey(val)
208
+ let node = this.$refs.tree.getNode(val)
209
+ this.optionData[0][`${this.$props.nodeKey}`] = val
210
+ this.optionData[0][`${this.label}`] = node[`${this.label}`]
211
+ })
206
212
  } else {
207
- this.$refs.tree.setCurrentKey(null);
213
+ this.$refs.tree.setCurrentKey(null)
208
214
  }
209
215
  },
210
216
  },
211
217
  watch: {
212
218
  value: function (val) {
213
219
  if (!this.isEmpty(this.data)) {
214
- this.init(val);
220
+ this.init(val)
215
221
  }
216
222
  },
217
223
  data: function (val) {
218
224
  if (!this.isEmpty(val)) {
219
- this.init(this.value);
225
+ this.init(this.value)
220
226
  }
221
227
  },
222
228
  },
223
- };
229
+ }
224
230
  </script>
225
231
 
226
232
  <style lang="less" scoped>