el-plus-crud 0.1.21 → 0.1.23

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.
@@ -13,6 +13,7 @@ export default {
13
13
  import { ref, useAttrs, onBeforeMount, inject, reactive, watch } from 'vue'
14
14
  import { getAttrs, getEvents } from '../mixins'
15
15
  import { isEqual } from '../../../util'
16
+ import { useVModel } from '@vueuse/core'
16
17
 
17
18
  const globalData = inject('globalData') as any
18
19
 
@@ -25,8 +26,7 @@ const props = defineProps<{
25
26
  }>()
26
27
 
27
28
  const emits = defineEmits(['update:modelValue'])
28
- const currentValue = ref(props.modelValue)
29
- emits('update:modelValue', currentValue)
29
+ const currentValue = useVModel(props, 'modelValue', emits)
30
30
 
31
31
  const isInit = ref(false)
32
32
  const attrs = ref({} as any)
@@ -62,4 +62,3 @@ watch(
62
62
  display: flex;
63
63
  }
64
64
  </style>
65
- ../util/aaaaa
@@ -17,6 +17,7 @@ export default {
17
17
  import { ref, reactive, watch, useAttrs, onBeforeMount, inject } from 'vue'
18
18
  import { getAttrs, getEvents } from '../mixins'
19
19
  import { isEqual } from '../../../util'
20
+ import { useVModel } from '@vueuse/core'
20
21
 
21
22
  const globalData = inject('globalData') as any
22
23
 
@@ -29,8 +30,7 @@ const props = defineProps<{
29
30
  }>()
30
31
 
31
32
  const emits = defineEmits(['update:modelValue'])
32
- const currentValue = ref([] as any)
33
- emits('update:modelValue', currentValue)
33
+ const currentValue = useVModel(props, 'modelValue', emits)
34
34
 
35
35
  const options = reactive([] as any[])
36
36
  const isInit = ref(false)
@@ -12,6 +12,7 @@ export default {
12
12
  <script lang="ts" setup>
13
13
  import { ref, useAttrs, onBeforeMount } from 'vue'
14
14
  import { getAttrs, getEvents } from '../mixins'
15
+ import { useVModel } from '@vueuse/core'
15
16
 
16
17
  const props = defineProps<{
17
18
  modelValue?: string | number | '' | null
@@ -25,8 +26,7 @@ const emits = defineEmits(['update:modelValue'])
25
26
  const isInit = ref(false)
26
27
  const attrs = ref({} as any)
27
28
  const onEvents = ref(getEvents(props))
28
- const currentValue = ref(props.modelValue)
29
- emits('update:modelValue', currentValue)
29
+ const currentValue = useVModel(props, 'modelValue', emits)
30
30
 
31
31
  onBeforeMount(async () => {
32
32
  attrs.value = await getAttrs(props, { valueFormat: 'YYYY-MM-DD HH:mm:ss', editable: false, ...useAttrs() })
@@ -18,6 +18,7 @@ export default {
18
18
  import { ref, useAttrs, useSlots, onBeforeMount, inject } from 'vue'
19
19
  import { getAttrs, getEvents } from '../mixins'
20
20
  import { ICRUDConfig } from '../../../../types'
21
+ import { useVModel } from '@vueuse/core'
21
22
 
22
23
  const defaultConf = inject('defaultConf') as ICRUDConfig
23
24
 
@@ -30,8 +31,7 @@ const props = defineProps<{
30
31
  disabled?: boolean
31
32
  }>()
32
33
  const emits = defineEmits(['update:modelValue'])
33
- const currentValue = ref(props.modelValue)
34
- emits('update:modelValue', currentValue)
34
+ const currentValue = useVModel(props, 'modelValue', emits)
35
35
 
36
36
  const slots = ref(Object.assign({}, useSlots(), props.desc.slots))
37
37
  const attrs = ref({} as any)
@@ -17,6 +17,7 @@ export default {
17
17
  import { ref, reactive, useAttrs, watch, onBeforeMount, inject } from 'vue'
18
18
  import { getAttrs, getEvents } from '../mixins'
19
19
  import { isEqual } from '../../../util'
20
+ import { useVModel } from '@vueuse/core'
20
21
 
21
22
  const globalData = inject('globalData') as any
22
23
 
@@ -29,8 +30,7 @@ const props = defineProps<{
29
30
  }>()
30
31
 
31
32
  const emits = defineEmits(['update:modelValue'])
32
- const currentValue = ref(props.modelValue)
33
- emits('update:modelValue', currentValue)
33
+ const currentValue = useVModel(props, 'modelValue', emits)
34
34
 
35
35
  const options = reactive([] as any[])
36
36
  const isInit = ref(false)
@@ -12,6 +12,7 @@ export default {
12
12
  <script lang="ts" setup>
13
13
  import { ref, watch, useAttrs, onBeforeMount } from 'vue'
14
14
  import { getAttrs, getEvents } from '../mixins'
15
+ import { useVModel } from '@vueuse/core'
15
16
 
16
17
  const emits = defineEmits(['update:modelValue', 'validateThis'])
17
18
  const props = defineProps<{
@@ -22,8 +23,7 @@ const props = defineProps<{
22
23
  disabled?: boolean
23
24
  }>()
24
25
 
25
- const currentValue = ref(props.modelValue)
26
- emits('update:modelValue', currentValue)
26
+ const currentValue = useVModel(props, 'modelValue', emits)
27
27
 
28
28
  const attrs = ref({} as any)
29
29
  const onEvents = ref(getEvents(props))
@@ -24,6 +24,7 @@ import { ElMessage } from 'element-plus'
24
24
  import { getAttrs } from '../mixins'
25
25
  import { isEqual, isPromiseLike } from '../../../util'
26
26
  import { ICRUDConfig } from '../../../../types'
27
+ import { useVModel } from '@vueuse/core'
27
28
 
28
29
  const defaultConf = inject('defaultConf') as ICRUDConfig
29
30
  const globalData = inject('globalData') as any
@@ -42,9 +43,7 @@ const props = withDefaults(
42
43
  }
43
44
  )
44
45
  const emits = defineEmits(['update:modelValue'])
45
-
46
- const currentValue = ref(props.modelValue || (props.desc.multiple ? [] : ''))
47
- emits('update:modelValue', currentValue)
46
+ const currentValue = useVModel(props, 'modelValue', emits)
48
47
 
49
48
  const attrs = ref({} as any)
50
49
  const options = reactive([] as any[])
@@ -124,6 +123,7 @@ onBeforeMount(async () => {
124
123
  tempAttr.remote = !!props.desc.remote
125
124
  attrs.value = await getAttrs(props, tempAttr)
126
125
  attrs.value.remote = !!props.desc.remote
126
+ delete attrs.value.disabled
127
127
  isInit.value = true
128
128
  })
129
129
 
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <div class="el-plus-form-switch">
3
+ {{ props.modelValue + '-' + currentValue }}
3
4
  <el-switch v-if="isInit" v-bind="attrs" :disabled="disabled" v-on="onEvents" :loading="props.loading || localLoading" v-model="currentValue" :before-change="handelBeforeChange" />
4
5
  </div>
5
6
  </template>
@@ -15,6 +16,7 @@ export default {
15
16
  import { ref, useAttrs, onBeforeMount } from 'vue'
16
17
  import { getAttrs, getEvents } from '../mixins'
17
18
  import { ElMessageBox } from 'element-plus'
19
+ import { useVModel } from '@vueuse/core'
18
20
 
19
21
  const emits = defineEmits(['update:modelValue'])
20
22
  const props = defineProps<{
@@ -27,9 +29,7 @@ const props = defineProps<{
27
29
  }>()
28
30
 
29
31
  const localLoading = ref(false)
30
-
31
- const currentValue = ref(props.modelValue)
32
- emits('update:modelValue', currentValue)
32
+ const currentValue = useVModel(props, 'modelValue', emits)
33
33
 
34
34
  const isInit = ref(false)
35
35
  const attrs = ref({} as any)
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "el-plus-crud",
3
3
  "description": "采用Vue3 + TS,封装的element-plus数据驱动表单、列表组件",
4
4
  "author": "K.D.Jack",
5
- "version": "0.1.21",
5
+ "version": "0.1.23",
6
6
  "license": "MIT",
7
7
  "private": false,
8
8
  "main": "dist/el-plus-crud.mjs",