@longhongguo/form-create-ant-design-vue 3.3.20 → 3.3.21
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": "@longhongguo/form-create-ant-design-vue",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.21",
|
|
4
4
|
"description": "AntDesignVue版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。",
|
|
5
5
|
"main": "./dist/form-create.min.js",
|
|
6
6
|
"module": "./dist/form-create.esm.js",
|
|
@@ -80,6 +80,11 @@ export default defineComponent({
|
|
|
80
80
|
fileName: {
|
|
81
81
|
type: String,
|
|
82
82
|
default: ''
|
|
83
|
+
},
|
|
84
|
+
// 请求前置处理函数
|
|
85
|
+
beforeFetch: {
|
|
86
|
+
type: Function,
|
|
87
|
+
default: null
|
|
83
88
|
}
|
|
84
89
|
},
|
|
85
90
|
data() {
|
|
@@ -101,15 +106,40 @@ export default defineComponent({
|
|
|
101
106
|
this.loading = true
|
|
102
107
|
|
|
103
108
|
try {
|
|
104
|
-
//
|
|
105
|
-
|
|
109
|
+
// 构建请求配置
|
|
110
|
+
let config = {
|
|
106
111
|
action: this.action,
|
|
107
112
|
method: this.method,
|
|
108
113
|
data: this.data,
|
|
109
114
|
query: this.query,
|
|
110
115
|
headers: this.headers,
|
|
111
116
|
withCredentials: this.withCredentials
|
|
112
|
-
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 如果有 beforeFetch,先调用它来修改配置
|
|
120
|
+
if (this.beforeFetch && typeof this.beforeFetch === 'function') {
|
|
121
|
+
const formCreateInject = this.formCreateInject || {}
|
|
122
|
+
const api = formCreateInject.api
|
|
123
|
+
const rule = formCreateInject.rule
|
|
124
|
+
|
|
125
|
+
// beforeFetch 的第二个参数是 { api, rule }
|
|
126
|
+
const result = this.beforeFetch(config, { api, rule })
|
|
127
|
+
|
|
128
|
+
// 如果 beforeFetch 返回 Promise,等待它完成
|
|
129
|
+
if (result && typeof result.then === 'function') {
|
|
130
|
+
await result
|
|
131
|
+
} else if (result === false) {
|
|
132
|
+
// 如果返回 false,取消请求
|
|
133
|
+
this.loading = false
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// beforeFetch 可能直接修改了 config,或者返回了新的 config
|
|
138
|
+
// 这里假设它会直接修改传入的 config 对象(符合 form-create 的惯例)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 使用自定义的fetch来处理blob响应
|
|
142
|
+
const result = await this.fetchBlob(config)
|
|
113
143
|
|
|
114
144
|
// 获取文件名
|
|
115
145
|
let fileName =
|