easybill-ui 0.1.18 → 0.1.19
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.
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script lang="ts">
|
|
27
|
-
import { defineComponent, reactive, provide, ref, Ref, computed, watch, PropType } from "vue"
|
|
27
|
+
import { defineComponent, reactive, provide, ref, Ref, computed, watch, PropType, getCurrentInstance } from "vue"
|
|
28
28
|
import { isFunction, isAsyncFunction } from "./utils/is"
|
|
29
29
|
import { deepClone } from "./utils/common"
|
|
30
30
|
import components from "./components"
|
|
@@ -65,6 +65,7 @@ export default defineComponent({
|
|
|
65
65
|
const sFormSchema: Ref<FormSchema> = ref(props.formSchema)
|
|
66
66
|
let formModel = reactive<Fields>(props.modelValue || {})
|
|
67
67
|
const curdFormContext = reactive<FormContext>({} as FormContext)
|
|
68
|
+
const instance = getCurrentInstance()
|
|
68
69
|
watch(
|
|
69
70
|
() => props.modelValue,
|
|
70
71
|
(val) => {
|
|
@@ -100,7 +101,7 @@ export default defineComponent({
|
|
|
100
101
|
if (item.asyncOptions && (item.autoload || typeof item.autoload == "undefined") && (isFunction(item.asyncOptions) || isAsyncFunction(item.asyncOptions))) {
|
|
101
102
|
item.loading = true
|
|
102
103
|
item.options = await item.asyncOptions(formModel, item, curdFormContext).finally(() => (item.loading = false))
|
|
103
|
-
item.eventObject?.optionLoaded && item.eventObject?.optionLoaded(formModel, item, curdFormContext)
|
|
104
|
+
!instance?.isUnmounted && item.eventObject?.optionLoaded && item.eventObject?.optionLoaded(formModel, item, curdFormContext)
|
|
104
105
|
} else if (item.prop && item.asyncValue && (isFunction(item.asyncValue) || isAsyncFunction(item.asyncValue))) {
|
|
105
106
|
// 异步默认值
|
|
106
107
|
item.loading = true
|
|
@@ -134,23 +135,23 @@ export default defineComponent({
|
|
|
134
135
|
// 调用某个表单项的异步数据接口
|
|
135
136
|
const loadOptions = async (prop: string, option?: any) => {
|
|
136
137
|
const cur = sFormSchema.value.formItem.find((a) => a.prop == prop)
|
|
137
|
-
if (cur && cur.asyncOptions) {
|
|
138
|
+
if (cur && cur.asyncOptions && !instance?.isUnmounted) {
|
|
138
139
|
cur.loading = true
|
|
139
140
|
cur.options =
|
|
140
141
|
(await cur
|
|
141
142
|
.asyncOptions(formModel, cur, curdFormContext, option)
|
|
142
143
|
.catch((err) => console.error("loadOptionError", err))
|
|
143
144
|
.finally(() => (cur.loading = false))) || []
|
|
144
|
-
cur.eventObject?.optionLoaded && cur.eventObject?.optionLoaded(formModel, cur, curdFormContext, option)
|
|
145
|
+
!instance?.isUnmounted && cur.eventObject?.optionLoaded && cur.eventObject?.optionLoaded(formModel, cur, curdFormContext, option)
|
|
145
146
|
}
|
|
146
147
|
return cur
|
|
147
148
|
}
|
|
148
149
|
// 给某个item赋值options
|
|
149
|
-
const setOptions = async (prop: string, options: CurdFormOptionItem[]) => {
|
|
150
|
+
const setOptions = async (prop: string, options: CurdFormOptionItem[], option?: any) => {
|
|
150
151
|
const cur = sFormSchema.value.formItem.find((a) => a.prop == prop)
|
|
151
152
|
if (cur) {
|
|
152
153
|
cur.options = options
|
|
153
|
-
cur.eventObject?.optionLoaded && cur.eventObject?.optionLoaded(formModel, cur, curdFormContext)
|
|
154
|
+
!instance?.isUnmounted && cur.eventObject?.optionLoaded && cur.eventObject?.optionLoaded(formModel, cur, curdFormContext, option)
|
|
154
155
|
}
|
|
155
156
|
// return cur
|
|
156
157
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easybill-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "A component library for easybill",
|
|
5
5
|
"author": "tuchongyang <779311998@qq.com>",
|
|
6
6
|
"private": false,
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "e4c25822f2d7360b65b9d5721415af2ee8e1a6a2"
|
|
18
18
|
}
|