haiwei-ui 1.3.4 → 1.3.6

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": "haiwei-ui",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "HaiWei前端组件库",
5
5
  "author": "Eric",
6
6
  "license": "ISC",
@@ -152,25 +152,31 @@ export default {
152
152
  methods: {
153
153
  /** 提交 */
154
154
  async submit() {
155
+ // 设置loading状态
156
+ this.loading_ = true
157
+
155
158
  // 触发 before-submit 钩子
156
159
  if (this.$listeners['before-submit']) {
157
- this.loading_ = true
158
-
159
160
  try {
160
- // 直接传递 this.model,让父组件直接修改它
161
- await new Promise((resolve, reject) => {
162
- this.$emit('before-submit', this.model, resolve, reject)
163
- })
161
+ // 执行 before-submit 钩子并等待结果
162
+ // 注意:这里不传递model参数,父组件应该直接修改this.model
163
+ const result = await this.$emit('before-submit')
164
+
165
+ // 如果返回false,停止提交
166
+ if (result === false) {
167
+ this.loading_ = false
168
+ return
169
+ }
170
+ // 返回true或undefined则继续提交
164
171
  } catch (error) {
165
- // 如果 before-submit 中调用了 reject,会进入这里
166
172
  this.loading_ = false
167
173
  this.$emit('error', error)
168
174
  return
169
175
  }
170
176
  }
171
177
 
172
- // 继续原有提交逻辑(this.model 已经被父组件修改过了)
173
- this.loading_ = true
178
+ console.log('test',this.model)
179
+ // 继续原有提交逻辑
174
180
  this.$refs.form.submit()
175
181
  },
176
182
  /** 重置 */