cosey 0.4.46 → 0.4.48

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.
@@ -2,7 +2,7 @@ import { ElSelect, ElOptionGroup, ElOption } from 'element-plus';
2
2
  import { defineComponent, computed, unref, h, mergeProps } from 'vue';
3
3
  import { fieldSelectOmitKeys, flatGroup } from './select.js';
4
4
  import { omit } from 'lodash-es';
5
- import { isFunction } from '../../../../utils/is.js';
5
+ import { isFunction, isObject } from '../../../../utils/is.js';
6
6
  import { useLocale } from '../../../../hooks/useLocale.js';
7
7
  import { addNullablePlaceholder } from '../../../../utils/vue.js';
8
8
  import { getLabelByValue } from '../../../../utils/collection.js';
@@ -43,7 +43,7 @@ var stdin_default = defineComponent((props, {
43
43
  const optionProps = componentProps.value.optionProps;
44
44
  return h(ElOption, {
45
45
  ...option,
46
- key: option.value,
46
+ key: isObject(option.value) && componentProps.value.valueKey ? option.value[componentProps.value.valueKey] : option.value,
47
47
  ...(isFunction(optionProps) ? optionProps(option, index) : optionProps)
48
48
  }, slots.option ? () => slots.option(option, index) : void 0);
49
49
  }
@@ -13,6 +13,7 @@ export interface FieldSelectV2Props extends FieldComponentCommonProps {
13
13
  } & {
14
14
  labelKey?: string;
15
15
  valueKey?: string;
16
+ optionProps?: (props: Record<PropertyKey, any>, index: number) => Record<PropertyKey, any>;
16
17
  };
17
18
  componentSlots?: Partial<FieldSelectV2Slots>;
18
19
  }
@@ -1,5 +1,5 @@
1
1
  import { ElSelectV2 } from 'element-plus';
2
- import { defineComponent, computed, h, mergeProps } from 'vue';
2
+ import { defineComponent, computed, unref, h, mergeProps } from 'vue';
3
3
  import { flatGroup } from './select-v2.js';
4
4
  import { useLocale } from '../../../../hooks/useLocale.js';
5
5
  import { addNullablePlaceholder } from '../../../../utils/vue.js';
@@ -12,6 +12,22 @@ var stdin_default = defineComponent((props, {
12
12
  t
13
13
  } = useLocale();
14
14
  const componentProps = computed(() => props.componentProps || {});
15
+ const childrenKey = computed(() => componentProps.value.props?.options || "children");
16
+ const optionProps = computed(() => componentProps.value.optionProps || (option => option));
17
+ function convertRecur(options) {
18
+ return options.map((option, index) => {
19
+ if (childrenKey.value in option) {
20
+ return {
21
+ ...optionProps.value(option, index),
22
+ [childrenKey.value]: convertRecur(option[childrenKey.value])
23
+ };
24
+ }
25
+ return optionProps.value(option, index);
26
+ });
27
+ }
28
+ const convertedOptions = computed(() => {
29
+ return convertRecur(unref(componentProps.value.options) ?? []);
30
+ });
15
31
  return () => {
16
32
  if (props.readonly) {
17
33
  const value = componentProps.value.modelValue;
@@ -26,7 +42,9 @@ var stdin_default = defineComponent((props, {
26
42
  style: {
27
43
  verticalAlign: "top"
28
44
  }
29
- }, componentProps.value), slots);
45
+ }, componentProps.value, {
46
+ options: convertedOptions.value
47
+ }), slots);
30
48
  };
31
49
  }, {
32
50
  name: "FieldSelectV2",
@@ -109,6 +109,8 @@ const elTableExposeKeys = [
109
109
  const tableExposeKeys = [
110
110
  ...elTableExposeKeys,
111
111
  ...tableQueryExposeKeys,
112
+ "reset",
113
+ "submit",
112
114
  "reload",
113
115
  "expandAll",
114
116
  "collapseAll",
@@ -342,6 +342,20 @@ var stdin_default = /* @__PURE__ */defineComponent({
342
342
  await execute();
343
343
  }
344
344
  };
345
+ const submit = async () => {
346
+ if (props.formProps) {
347
+ return tableQueryRef.value?.submit();
348
+ } else {
349
+ return onSubmit();
350
+ }
351
+ };
352
+ const reset = async () => {
353
+ if (props.formProps) {
354
+ return tableQueryRef.value?.reset();
355
+ } else {
356
+ return onReset();
357
+ }
358
+ };
345
359
  const statsColumns = computed(() => unref(props.statsColumns));
346
360
  const statsData = computed(() => unref(props.statsData));
347
361
  const isStatsVisible = computed(() => statsColumns.value && statsColumns.value.length > 0);
@@ -356,7 +370,9 @@ var stdin_default = /* @__PURE__ */defineComponent({
356
370
  setData,
357
371
  getData,
358
372
  getRootEl,
359
- getPagination
373
+ getPagination,
374
+ submit,
375
+ reset
360
376
  }, () => tableQueryRef.value);
361
377
  watch(() => props.getExpose, () => {
362
378
  props.getExpose?.(expose);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.4.46",
3
+ "version": "0.4.48",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",