haiwei-ui 1.3.4 → 1.3.5

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.5",
4
4
  "description": "HaiWei前端组件库",
5
5
  "author": "Eric",
6
6
  "license": "ISC",
@@ -152,25 +152,29 @@ 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
+ const result = await this.$emit('before-submit', this.model)
163
+
164
+ // 如果返回false,停止提交
165
+ if (result === false) {
166
+ this.loading_ = false
167
+ return
168
+ }
169
+ // 返回true或undefined则继续提交
164
170
  } catch (error) {
165
- // 如果 before-submit 中调用了 reject,会进入这里
166
171
  this.loading_ = false
167
172
  this.$emit('error', error)
168
173
  return
169
174
  }
170
175
  }
171
176
 
172
- // 继续原有提交逻辑(this.model 已经被父组件修改过了)
173
- this.loading_ = true
177
+ // 继续原有提交逻辑
174
178
  this.$refs.form.submit()
175
179
  },
176
180
  /** 重置 */