imeik-bizui 2.2.1 → 2.2.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.
@@ -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,25 @@ export default {
185
167
  }
186
168
  },
187
169
  methods: {
170
+ /**
171
+ * 检查默认选中模式
172
+ */
173
+ checkDefault() {
174
+ const defaultType = this.attrs.default
175
+ let tempValue
176
+ // 如果默认选中“我的部门”,且无初始值,则设为默认部门
177
+ if (defaultType === '2') {
178
+ tempValue = this.defaultDepartment
179
+ } else if (defaultType === '3') {
180
+ tempValue = this.attrs.defaultValue
181
+ }
182
+ // 设置默认值并触发change事件
183
+ if (tempValue && !this.value) {
184
+ this.myValue = tempValue
185
+ this.onChange()
186
+ }
187
+ },
188
+
188
189
  /**
189
190
  * 查找目标value在树节点中的完整路径name
190
191
  */
@@ -285,6 +286,7 @@ export default {
285
286
  console.log('resData', resData)
286
287
  this.options = this.formatData(resData.tagBudgetDeptLists) || []
287
288
  this.defaultDepartment = resData.userBudgetDepartment || undefined
289
+ this.checkDefault()
288
290
  callback && callback()
289
291
  } else {
290
292
  this.$message.error(res.message)
@@ -316,7 +318,6 @@ export default {
316
318
  detailName: this.myValueName,
317
319
  detailOrgCode: this.myValueOrgCode
318
320
  }
319
- console.log('emitEvents', value, eventData)
320
321
  this.$emit('input', value, eventData)
321
322
  this.$emit('change', value, eventData)
322
323
  },