easybill-ui 0.1.2 → 0.1.3

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,8 +24,9 @@
24
24
  </template>
25
25
 
26
26
  <script lang="ts">
27
- import { defineComponent, reactive, provide, ref, Ref, getCurrentInstance, computed, watch, PropType } from "vue"
28
- import { isFunction, isAsyncFunction, isObject } from "./utils/is"
27
+ import { defineComponent, reactive, provide, ref, Ref, computed, watch, PropType } from "vue"
28
+ import { isFunction, isAsyncFunction } from "./utils/is"
29
+ import { deepClone } from "./utils/common"
29
30
  import components from "./components"
30
31
  import { ElForm, ElFormItem } from "element-plus"
31
32
  import { FormSchema, Fields, FormItem as FormItemType, CurdFormOptionItem, FormContext } from "./types"
@@ -58,22 +59,24 @@ export default defineComponent({
58
59
  setup(props, { emit, attrs }) {
59
60
  const schemaFormRef: Ref<InstanceType<typeof ElForm> | undefined> = ref()
60
61
  const sFormSchema: Ref<FormSchema> = ref(props.formSchema)
61
- const formModel = reactive<Fields>(props.modelValue || {})
62
+ const formModel = reactive<Fields>((props.modelValue && deepClone(props.modelValue)) || {})
62
63
  const curdFormContext = reactive<FormContext>({} as FormContext)
63
64
  watch(
64
65
  () => props.modelValue,
65
- () => {
66
+ (val) => {
67
+ const value = deepClone(val)
66
68
  for (let i in formModel) {
67
69
  delete formModel[i]
68
70
  }
69
- Object.assign(formModel, props.modelValue)
71
+ Object.assign(formModel, value)
70
72
  }
71
73
  )
72
74
  watch(
73
75
  () => formModel,
74
76
  (val) => {
75
77
  emit("update:modelValue", val)
76
- }
78
+ },
79
+ { deep: true }
77
80
  )
78
81
 
79
82
  // 先从schema中读取默认值
@@ -88,7 +91,6 @@ export default defineComponent({
88
91
  props.fields && Object.assign(formModel, props.fields)
89
92
  Object.assign(formModel, props.modelValue)
90
93
  // props.modelValue && Object.assign(formModel, props.modelValue)
91
- const instance = getCurrentInstance()
92
94
  // 异步设置默认数据
93
95
  sFormSchema.value.formItem.forEach(async (item) => {
94
96
  // 异步选项
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easybill-ui",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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": "d7fedb90ece256b251f72e382263813efc61e668"
17
+ "gitHead": "a96d70414fb9c2400aa51acf574240fb28381f41"
18
18
  }