el-plus-crud 0.0.58 → 0.0.60

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.60](https://github.com/KDJack/el-plus-crud/compare/v0.0.59...v0.0.60) (2023-08-28)
6
+
7
+ ### [0.0.59](https://github.com/KDJack/el-plus-crud/compare/v0.0.58...v0.0.59) (2023-08-28)
8
+
5
9
  ### [0.0.58](https://github.com/KDJack/el-plus-crud/compare/v0.0.57...v0.0.58) (2023-08-28)
6
10
 
7
11
  ### [0.0.57](https://github.com/KDJack/el-plus-crud/compare/v0.0.54...v0.0.57) (2023-08-28)
@@ -4368,7 +4368,7 @@ const xi = /* @__PURE__ */ He(cz, [["__scopeId", "data-v-1239a236"]]), Mz = /* @
4368
4368
  },
4369
4369
  emits: ["update:modelValue"],
4370
4370
  setup(d, { emit: s }) {
4371
- const l = d, o = Ce("globalData"), p = _(Array.isArray(l.modelValue) ? l.modelValue : [l.modelValue]);
4371
+ const l = d, o = Ce("globalData"), p = _([]);
4372
4372
  s("update:modelValue", p);
4373
4373
  const g = Je([]), h = _(!1), m = _({}), M = _(Ve(l));
4374
4374
  return Oe(async () => {
@@ -4382,7 +4382,7 @@ const xi = /* @__PURE__ */ He(cz, [["__scopeId", "data-v-1239a236"]]), Mz = /* @
4382
4382
  ), Le(
4383
4383
  () => l.modelValue,
4384
4384
  (a) => {
4385
- p.value = Array.isArray(a) ? a : [a];
4385
+ a ? p.value = Array.isArray(a) ? a : [a] : p.value = [];
4386
4386
  },
4387
4387
  { immediate: !0 }
4388
4388
  ), (a, v) => {
@@ -4411,7 +4411,7 @@ const xi = /* @__PURE__ */ He(cz, [["__scopeId", "data-v-1239a236"]]), Mz = /* @
4411
4411
  };
4412
4412
  }
4413
4413
  });
4414
- const Ci = /* @__PURE__ */ He(dz, [["__scopeId", "data-v-d4f2910b"]]), gz = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: Ci }, Symbol.toStringTag, { value: "Module" })), Nz = {
4414
+ const Ci = /* @__PURE__ */ He(dz, [["__scopeId", "data-v-f6a4bbd1"]]), gz = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: Ci }, Symbol.toStringTag, { value: "Module" })), Nz = {
4415
4415
  name: "ElPlusFormCheckboxButton",
4416
4416
  inheritAttrs: !1,
4417
4417
  typeName: "checkboxButton",
@@ -1,76 +1,80 @@
1
- <template>
2
- <el-checkbox-group v-if="isInit" class="ElPlusFormCheckbox-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue" :disabled="disabled">
3
- <el-checkbox v-for="option of options" :key="option.value" :label="option.value" v-bind="option.attrs">
4
- {{ option.text || option.label }}
5
- </el-checkbox>
6
- </el-checkbox-group>
7
- </template>
8
- <script lang="ts">
9
- export default {
10
- name: 'ElPlusFormCheckbox',
11
- inheritAttrs: false,
12
- typeName: 'checkbox',
13
- customOptions: {}
14
- }
15
- </script>
16
- <script lang="ts" setup>
17
- import { ref, reactive, watch, useAttrs, onBeforeMount, inject } from 'vue'
18
- import { getAttrs, getEvents } from '../mixins'
19
- import { isEqual } from 'lodash'
20
-
21
- const globalData = inject('globalData') as any
22
-
23
- const props = defineProps<{
24
- modelValue?: Array<string | number> | string | number | null
25
- field: string
26
- desc: { [key: string]: any }
27
- formData: { [key: string]: any }
28
- disabled?: boolean
29
- }>()
30
-
31
- const emits = defineEmits(['update:modelValue'])
32
- const currentValue = ref(Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue])
33
- emits('update:modelValue', currentValue)
34
-
35
- const options = reactive([] as any[])
36
- const isInit = ref(false)
37
- const attrs = ref({} as any)
38
- const onEvents = ref(getEvents(props))
39
-
40
- onBeforeMount(async () => {
41
- attrs.value = await getAttrs(props, { ...useAttrs() })
42
- isInit.value = true
43
- })
44
-
45
- watch(
46
- () => props.desc.options,
47
- async (data) => {
48
- if (typeof data === 'string') {
49
- // 从全局数据中获取options
50
- options.splice(0, options.length, ...(globalData[data] || []))
51
- } else if (typeof data === 'function') {
52
- options.splice(0, options.length, ...(await data(props.formData)))
53
- } else if (Array.isArray(data)) {
54
- if (data && options && !isEqual(data, options)) {
55
- options.splice(0, options.length, ...data)
56
- }
57
- } else {
58
- options.splice(0, options.length)
59
- }
60
- },
61
- { immediate: true }
62
- )
63
-
64
- watch(
65
- () => props.modelValue,
66
- (data: Array<string | number> | string | number | null | undefined) => {
67
- currentValue.value = Array.isArray(data) ? data : [data]
68
- },
69
- { immediate: true }
70
- )
71
- </script>
72
- <style lang="scss" scoped>
73
- .ElPlusFormCheckbox-panel {
74
- display: flex;
75
- }
76
- </style>
1
+ <template>
2
+ <el-checkbox-group v-if="isInit" class="ElPlusFormCheckbox-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue" :disabled="disabled">
3
+ <el-checkbox v-for="option of options" :key="option.value" :label="option.value" v-bind="option.attrs">
4
+ {{ option.text || option.label }}
5
+ </el-checkbox>
6
+ </el-checkbox-group>
7
+ </template>
8
+ <script lang="ts">
9
+ export default {
10
+ name: 'ElPlusFormCheckbox',
11
+ inheritAttrs: false,
12
+ typeName: 'checkbox',
13
+ customOptions: {}
14
+ }
15
+ </script>
16
+ <script lang="ts" setup>
17
+ import { ref, reactive, watch, useAttrs, onBeforeMount, inject } from 'vue'
18
+ import { getAttrs, getEvents } from '../mixins'
19
+ import { isEqual } from 'lodash'
20
+
21
+ const globalData = inject('globalData') as any
22
+
23
+ const props = defineProps<{
24
+ modelValue?: Array<string | number> | string | number | null
25
+ field: string
26
+ desc: { [key: string]: any }
27
+ formData: { [key: string]: any }
28
+ disabled?: boolean
29
+ }>()
30
+
31
+ const emits = defineEmits(['update:modelValue'])
32
+ const currentValue = ref([] as any)
33
+ emits('update:modelValue', currentValue)
34
+
35
+ const options = reactive([] as any[])
36
+ const isInit = ref(false)
37
+ const attrs = ref({} as any)
38
+ const onEvents = ref(getEvents(props))
39
+
40
+ onBeforeMount(async () => {
41
+ attrs.value = await getAttrs(props, { ...useAttrs() })
42
+ isInit.value = true
43
+ })
44
+
45
+ watch(
46
+ () => props.desc.options,
47
+ async (data) => {
48
+ if (typeof data === 'string') {
49
+ // 从全局数据中获取options
50
+ options.splice(0, options.length, ...(globalData[data] || []))
51
+ } else if (typeof data === 'function') {
52
+ options.splice(0, options.length, ...(await data(props.formData)))
53
+ } else if (Array.isArray(data)) {
54
+ if (data && options && !isEqual(data, options)) {
55
+ options.splice(0, options.length, ...data)
56
+ }
57
+ } else {
58
+ options.splice(0, options.length)
59
+ }
60
+ },
61
+ { immediate: true }
62
+ )
63
+
64
+ watch(
65
+ () => props.modelValue,
66
+ (data: Array<string | number> | string | number | null | undefined) => {
67
+ if (data) {
68
+ currentValue.value = Array.isArray(data) ? data : [data]
69
+ } else {
70
+ currentValue.value = []
71
+ }
72
+ },
73
+ { immediate: true }
74
+ )
75
+ </script>
76
+ <style lang="scss" scoped>
77
+ .ElPlusFormCheckbox-panel {
78
+ display: flex;
79
+ }
80
+ </style>
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.0.58",
5
+ "version": "0.0.60",
6
6
  "license": "MIT",
7
7
  "private": false,
8
8
  "main": "dist/el-plus-crud.mjs",