@ddwl/ddwl-ui 1.1.0 → 1.1.2

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": "@ddwl/ddwl-ui",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "private": false,
5
5
  "main": "src/main.js",
6
6
  "style": "lib/theme/index.css",
@@ -71,9 +71,9 @@ export default {
71
71
  type: String,
72
72
  default: '取消'
73
73
  },
74
- // 需要重置的表单ref
74
+ // 需要重置的表单ref, 支持ref字符串或ref对象或ref字符串|对象数组
75
75
  formRefs: {
76
- type: [String, Array],
76
+ type: [String, Object, Array],
77
77
  default: ''
78
78
  },
79
79
  width: {
@@ -106,14 +106,17 @@ export default {
106
106
  }
107
107
  },
108
108
  methods: {
109
+ getRef (ref) {
110
+ return typeof ref === 'string' ? this.$parent.$refs[ref] : ref
111
+ },
109
112
  async submit () {
110
113
  // 是否需要进行表单校验
111
114
  if (this.formRefs) {
112
115
  // 多表单校验
113
116
  if (Array.isArray(this.formRefs)) {
114
- await Promise.all(this.formRefs.map(ref => this.$parent.$refs[ref] && this.$parent.$refs[ref].validate()))
117
+ await Promise.all(this.formRefs.map(ref => this.getRef(ref)?.validate()))
115
118
  } else {
116
- this.$parent.$refs[this.formRefs] && (await this.$parent.$refs[this.formRefs].validate())
119
+ await this.getRef(this.formRefs)?.validate()
117
120
  }
118
121
  }
119
122
  this.loading = true
@@ -129,16 +132,16 @@ export default {
129
132
  this.visible = false
130
133
  },
131
134
  /**
132
- * @description: 弹窗关闭时清楚表单校验
135
+ * @description: 弹窗关闭时清除表单校验
133
136
  */
134
137
  closed () {
135
138
  this.$emit('closed')
136
139
  if (this.formRefs) {
137
140
  // 多表单校验
138
141
  if (Array.isArray(this.formRefs)) {
139
- this.formRefs.forEach(ref => this.$parent.$refs[ref] && this.$parent.$refs[ref].resetFields())
142
+ this.formRefs.forEach(ref => this.getRef(ref)?.resetFields())
140
143
  } else {
141
- this.$parent.$refs[this.formRefs] && this.$parent.$refs[this.formRefs].resetFields()
144
+ this.getRef(this.formRefs)?.resetFields()
142
145
  }
143
146
  }
144
147
  }
@@ -92,14 +92,17 @@ export default {
92
92
  }
93
93
  },
94
94
  methods: {
95
+ getRef (ref) {
96
+ return typeof ref === 'string' ? this.$parent.$refs[ref] : ref
97
+ },
95
98
  async submit () {
96
99
  // 是否需要进行表单校验
97
100
  if (this.formRefs) {
98
101
  // 多表单校验
99
102
  if (Array.isArray(this.formRefs)) {
100
- await Promise.all(this.formRefs.map(ref => this.$parent.$refs[ref] && this.$parent.$refs[ref].validate()))
103
+ await Promise.all(this.formRefs.map(ref => this.getRef(ref)?.validate()))
101
104
  } else {
102
- this.$parent.$refs[this.formRefs] && (await this.$parent.$refs[this.formRefs].validate())
105
+ await this.getRef(this.formRefs)?.validate()
103
106
  }
104
107
  }
105
108
  this.loading = true
@@ -115,15 +118,16 @@ export default {
115
118
  this.visible = false
116
119
  },
117
120
  /**
118
- * @description: 弹窗关闭时清楚表单校验
121
+ * @description: 弹窗关闭时清除表单校验
119
122
  */
120
123
  closed () {
124
+ this.$emit('closed')
121
125
  if (this.formRefs) {
122
126
  // 多表单校验
123
127
  if (Array.isArray(this.formRefs)) {
124
- this.formRefs.forEach(ref => this.$parent.$refs[ref] && this.$parent.$refs[ref].resetFields())
128
+ this.formRefs.forEach(ref => this.getRef(ref)?.resetFields())
125
129
  } else {
126
- this.$parent.$refs[this.formRefs] && this.$parent.$refs[this.formRefs].resetFields()
130
+ this.getRef(this.formRefs)?.resetFields()
127
131
  }
128
132
  }
129
133
  }
@@ -201,7 +201,7 @@ export default {
201
201
  position: fixed;
202
202
  top: 0;
203
203
  left: 0;
204
- z-index: 1000;
204
+ z-index: 99999;
205
205
 
206
206
  .box {
207
207
  position: fixed;
@@ -1,14 +0,0 @@
1
- import previewVue from './index.vue'
2
-
3
- export default {
4
- install (Vue) {
5
- Vue.prototype.$preview = ({ defaultIndex = 0, list = [] }) => {
6
- const Preview = Vue.extend(previewVue)
7
- const instance = new Preview()
8
- document.body.appendChild(instance.$mount().$el)
9
- instance.value = true
10
- instance.defaultIndex = defaultIndex
11
- instance.list = list
12
- }
13
- }
14
- }