imeik-bizui 2.2.1 → 2.2.2

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.
@@ -150,32 +150,14 @@ export default {
150
150
  },
151
151
  // 监听默认选中模式
152
152
  'attrs.default': {
153
- immediate: true,
154
- handler(newVal, oldVal) {
155
- // 如果默认选中“我的部门”,且无初始值,则设为默认部门
156
- if (newVal) {
157
- if (newVal !== oldVal && newVal === '2' && !this.value) {
158
- this.myValue = this.defaultDepartment
159
- } else {
160
- !this.isView && (this.myValue = undefined)
161
- }
162
- this.getOptions(() => {
163
- this.onChange()
164
- })
165
- }
153
+ handler() {
154
+ this.checkDefault()
166
155
  }
167
156
  },
168
157
  // 监听特定默认值触发
169
158
  'attrs.defaultValue': {
170
- immediate: true,
171
- handler(newVal, oldVal) {
172
- // 若启用“指定部门”并且当前没值,则设为该默认
173
- if (newVal && newVal !== oldVal && this.attrs.default === '3' && !this.value) {
174
- this.myValue = newVal
175
- this.getOptions(() => {
176
- this.onChange()
177
- })
178
- }
159
+ handler() {
160
+ this.checkDefault()
179
161
  }
180
162
  }
181
163
  },
@@ -185,6 +167,29 @@ export default {
185
167
  }
186
168
  },
187
169
  methods: {
170
+ /**
171
+ * 检查默认选中模式
172
+ */
173
+ checkDefault() {
174
+ // 如果是查看模式,则不设置默认值
175
+ if(this.isView) {
176
+ return
177
+ }
178
+ let defaultType = this.attrs.default
179
+ let tempValue = undefined
180
+ // 如果默认选中“我的部门”,且无初始值,则设为默认部门
181
+ if (defaultType === '2') {
182
+ tempValue = this.defaultDepartment
183
+ } else if (defaultType === '3') {
184
+ tempValue = this.attrs.defaultValue
185
+ }
186
+ // 设置默认值并触发change事件
187
+ if (tempValue && !this.value) {
188
+ this.myValue = tempValue
189
+ this.onChange()
190
+ }
191
+ },
192
+
188
193
  /**
189
194
  * 查找目标value在树节点中的完整路径name
190
195
  */
@@ -285,6 +290,7 @@ export default {
285
290
  console.log('resData', resData)
286
291
  this.options = this.formatData(resData.tagBudgetDeptLists) || []
287
292
  this.defaultDepartment = resData.userBudgetDepartment || undefined
293
+ this.checkDefault()
288
294
  callback && callback()
289
295
  } else {
290
296
  this.$message.error(res.message)
@@ -316,7 +322,6 @@ export default {
316
322
  detailName: this.myValueName,
317
323
  detailOrgCode: this.myValueOrgCode
318
324
  }
319
- console.log('emitEvents', value, eventData)
320
325
  this.$emit('input', value, eventData)
321
326
  this.$emit('change', value, eventData)
322
327
  },