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
|
@@ -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
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
173
|
-
|
|
178
|
+
console.log('test',this.model)
|
|
179
|
+
// 继续原有提交逻辑
|
|
174
180
|
this.$refs.form.submit()
|
|
175
181
|
},
|
|
176
182
|
/** 重置 */
|