haiwei-ui 1.3.7 → 1.3.8

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.7",
3
+ "version": "1.3.8",
4
4
  "description": "HaiWei前端组件库",
5
5
  "author": "Eric",
6
6
  "license": "ISC",
@@ -68,11 +68,8 @@ export default {
68
68
  /** 提交 */
69
69
  submit() {
70
70
  this.validate(() => {
71
- this.openLoading()
72
- console.log('this.model======>', this.model);
73
- // 使用深拷贝确保获取最新数据
74
- const formData = JSON.parse(JSON.stringify(this.model))
75
- console.log('this.model======>formData', formData);
71
+ this.openLoading()
72
+
76
73
  this.action(this.model)
77
74
  .then(data => {
78
75
  if (this.successMsg === true) {
@@ -150,35 +150,39 @@ export default {
150
150
  }
151
151
  },
152
152
  methods: {
153
- /** 提交 */
154
153
  async submit() {
155
154
  // 设置loading状态
156
155
  this.loading_ = true
157
-
158
156
  // 触发 before-submit 钩子
159
157
  if (this.$listeners['before-submit']) {
160
158
  try {
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
159
+ // 执行 before-submit 钩子
160
+ // $emit返回事件处理函数的返回值数组
161
+ const results = this.$emit('before-submit')
162
+ // 如果有返回值且是Promise,等待它
163
+ if (results && results.length > 0) {
164
+ const firstResult = results[0]
165
+ if (firstResult && typeof firstResult.then === 'function') {
166
+ const result = await firstResult
167
+ if (result === false) {
168
+ this.loading_ = false
169
+ return
170
+ }
171
+ } else if (firstResult === false) {
172
+ this.loading_ = false
173
+ return
174
+ }
169
175
  }
170
- // 返回true或undefined则继续提交
171
176
  } catch (error) {
172
177
  this.loading_ = false
173
178
  this.$emit('error', error)
174
179
  return
175
180
  }
176
181
  }
177
-
178
- console.log('test',this.model)
179
- // 继续原有提交逻辑
182
+ console.log('test', this.model)
180
183
  this.$refs.form.submit()
181
184
  },
185
+
182
186
  /** 重置 */
183
187
  reset() {
184
188
  this.$nextTick(() => {