easybill-ui 0.1.19 → 1.0.1

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.
Files changed (60) hide show
  1. package/components/ConstantStatus/src/ConstantStatus.vue +3 -3
  2. package/components/ConstantStatus/src/types.ts +4 -8
  3. package/components/CurdForm/src/CurdForm.vue +34 -24
  4. package/components/CurdForm/src/FormItem.vue +5 -5
  5. package/components/CurdForm/src/FormTooltip.vue +11 -11
  6. package/components/CurdForm/src/components/index.ts +1 -1
  7. package/components/CurdForm/src/components/schema-form-autocomplete.vue +1 -1
  8. package/components/CurdForm/src/components/schema-form-select.vue +2 -2
  9. package/components/CurdForm/src/components/schema-form-time-picker.vue +3 -3
  10. package/components/CurdForm/src/components/schema-form-value.vue +1 -1
  11. package/components/CurdForm/src/hooks/index.ts +6 -6
  12. package/components/CurdForm/src/types.ts +48 -20
  13. package/components/CurdForm/src/utils/ajax.ts +3 -2
  14. package/components/CurdTable/src/CurdTable.vue +52 -70
  15. package/components/CurdTable/src/STableColumnControl.vue +3 -3
  16. package/components/CurdTable/src/STableDetail.vue +4 -4
  17. package/components/CurdTable/src/STableFilter.vue +5 -4
  18. package/components/CurdTable/src/STableItem.vue +16 -3
  19. package/components/CurdTable/src/STableItemFilter.vue +0 -36
  20. package/components/CurdTable/src/STableItemHeader.vue +36 -48
  21. package/components/CurdTable/src/STableItemHeaderTooltip.vue +35 -35
  22. package/components/CurdTable/src/STableMenu.vue +1 -1
  23. package/components/CurdTable/src/hooks/useColumnHook.ts +1 -1
  24. package/components/CurdTable/src/types.ts +83 -37
  25. package/components/CurdTable/utils/tabelToExcel.ts +73 -0
  26. package/components/DetailInfo/src/DetailInfo.vue +7 -6
  27. package/components/DetailInfo/src/DetailInfoContent.vue +27 -26
  28. package/components/DetailInfo/src/DetailInfoTooltip.vue +36 -36
  29. package/components/DetailInfo/src/types.ts +1 -1
  30. package/components/FormDialog/src/FormDialog.vue +26 -8
  31. package/components/FormDialog/src/types.ts +2 -0
  32. package/components/TableFilter/src/FilterExternal/FilterExternal.vue +14 -14
  33. package/components/TableFilter/src/FilterSearchBox.vue +6 -2
  34. package/components/TableFilter/src/TableFilter.vue +30 -18
  35. package/components/TableFilter/src/components/FilterItem.vue +39 -28
  36. package/components/TableFilter/src/components/FilterTags.vue +7 -6
  37. package/components/TableFilter/src/components/FilterToggle.vue +1 -1
  38. package/components/TableFilter/src/components/FilterType.vue +7 -23
  39. package/components/TableFilter/src/components/containers/TagsSelect.vue +20 -93
  40. package/components/TableFilter/types.ts +4 -43
  41. package/package.json +2 -2
  42. package/theme-chalk/curd-form.css +1 -1
  43. package/theme-chalk/curd-table.css +1 -1
  44. package/theme-chalk/index.css +1 -1
  45. package/theme-chalk/table-filter.css +1 -1
  46. package/utils/hooks/useGlobalConfig.ts +2 -2
  47. package/utils/vue/index.ts +2 -2
  48. package/utils/vue/make-installer.ts +1 -1
  49. package/components/CurdTable/utils/Export2Excel.ts +0 -227
  50. package/components/TableFilter/src/components/containers/BaseCascader.vue +0 -196
  51. package/components/TableFilter/src/components/containers/BaseCheckbox.vue +0 -270
  52. package/components/TableFilter/src/components/containers/BaseInput.vue +0 -73
  53. package/components/TableFilter/src/components/containers/BaseSelect.vue +0 -123
  54. package/components/TableFilter/src/components/containers/BaseTime.vue +0 -65
  55. package/components/TableFilter/src/components/containers/index.ts +0 -13
  56. package/components/TableFilter/src/components/typeComponents/BaseCheckbox.vue +0 -238
  57. package/components/TableFilter/src/components/typeComponents/BaseInput.vue +0 -61
  58. package/components/TableFilter/src/components/typeComponents/BaseSelect.vue +0 -113
  59. package/components/TableFilter/src/components/typeComponents/BaseTime.vue +0 -71
  60. package/components/TableFilter/src/components/typeComponents/index.ts +0 -11
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <el-tag v-if="current" class="constant-status" :class="{ 'dot-status': current.dot }" v-bind="currentProps">
3
3
  <el-icon v-if="(current.icon || current.iconClass) && !current.dot" :class="current.iconClass" style="margin-right: 5px">
4
- <component v-if="current.icon" :is="current.icon" class="icon" :size="14" style="width: 12px; height: 12px" />
4
+ <component :is="current.icon" v-if="current.icon" class="icon" :size="14" style="width: 12px; height: 12px" />
5
5
  </el-icon>
6
6
  <span v-if="current.dot" class="dot"></span>
7
7
  <span v-if="current.html" class="name" v-html="current.label"></span>
@@ -43,7 +43,7 @@ const current = computed(() => {
43
43
  return result && result.find((a) => a.value == props.value)
44
44
  })
45
45
  const currentProps = computed(() => {
46
- const defaults = { type: "", class: [""], style: {} }
46
+ const defaults = { type: "", label: "", value: "", class: [""], style: {} } as OptionItem
47
47
  const result = props.options || []
48
48
  const cur = result.find((a) => a.value == props.value)
49
49
  if (!cur) return {}
@@ -53,7 +53,7 @@ const currentProps = computed(() => {
53
53
  defaults.style = args.color ? { color: args.color, backgroundColor: "transparent" } : {}
54
54
  }
55
55
  // 判断type在不在里面
56
- if (type && ["success", "info", "warning", "danger"].includes(type)) {
56
+ if (type && ["success", "info", "warning", "danger"].includes(String(type))) {
57
57
  defaults.type = type
58
58
  } else {
59
59
  defaults.class.push("el-tag--" + (type || "default"))
@@ -1,22 +1,18 @@
1
- export interface OptionItem {
1
+ export interface OptionItem extends Record<string, any> {
2
2
  label: string
3
3
  value: string | number | boolean
4
4
  disabled?: boolean
5
- type?: "default" | "primary" | "success" | "info" | "warning" | "danger" | "blue" | "blue-dark" | "yellow" | "blueness" | "red-purple" | "error"
5
+ type?: string | "default" | "primary" | "success" | "info" | "warning" | "danger" | "blue" | "blue-dark" | "yellow" | "blueness" | "red-purple" | "error"
6
6
  icon?: any
7
7
  hit?: boolean
8
8
  color?: string
9
- size?: "large" | "default" | "small"
10
- effect?: "dark" | "light" | "plain"
9
+ size?: string | "large" | "default" | "small"
10
+ effect?: string | "dark" | "light" | "plain"
11
11
  round?: boolean
12
12
  border?: boolean
13
13
  className?: string
14
14
  iconClass?: string | string[]
15
15
  dot?: boolean
16
- /**
17
- * 供curd-form的单选或多选,选项上的tooltip
18
- */
19
16
  tooltip?: any
20
17
  html?: string
21
- [key: string]: any
22
18
  }
@@ -24,7 +24,7 @@
24
24
  </template>
25
25
 
26
26
  <script lang="ts">
27
- import { defineComponent, reactive, provide, ref, Ref, computed, watch, PropType, getCurrentInstance } from "vue"
27
+ import { defineComponent, reactive, provide, ref, computed, watch, PropType, Ref, getCurrentInstance, onMounted, triggerRef } from "vue"
28
28
  import { isFunction, isAsyncFunction } from "./utils/is"
29
29
  import { deepClone } from "./utils/common"
30
30
  import components from "./components"
@@ -44,6 +44,7 @@ export default defineComponent({
44
44
  formSchema: {
45
45
  required: true,
46
46
  type: Object as PropType<FormSchema>,
47
+ default: () => ({}),
47
48
  },
48
49
  // 预置字段默认值
49
50
  fields: {
@@ -61,7 +62,7 @@ export default defineComponent({
61
62
  },
62
63
  emits: ["update:modelValue", "change"],
63
64
  setup(props, { emit, attrs }) {
64
- const schemaFormRef: Ref<InstanceType<typeof ElForm> | undefined> = ref()
65
+ const schemaFormRef = ref<InstanceType<typeof ElForm> | undefined>()
65
66
  const sFormSchema: Ref<FormSchema> = ref(props.formSchema)
66
67
  let formModel = reactive<Fields>(props.modelValue || {})
67
68
  const curdFormContext = reactive<FormContext>({} as FormContext)
@@ -74,14 +75,14 @@ export default defineComponent({
74
75
  delete formModel[i]
75
76
  }
76
77
  Object.assign(formModel, value)
77
- }
78
+ },
78
79
  )
79
80
  watch(
80
81
  () => formModel,
81
82
  (val) => {
82
83
  emit("update:modelValue", val)
83
84
  },
84
- { deep: true }
85
+ { deep: true },
85
86
  )
86
87
  // 先从schema中读取默认值
87
88
  const schemaValues = sFormSchema.value.formItem.reduce<Fields>((previousValue, currentValue) => {
@@ -95,19 +96,6 @@ export default defineComponent({
95
96
  props.fields && Object.assign(formModel, props.fields)
96
97
  // Object.assign(formModel, props.modelValue)
97
98
  // props.modelValue && Object.assign(formModel, props.modelValue)
98
- // 异步设置默认数据
99
- sFormSchema.value.formItem.forEach(async (item) => {
100
- // 异步选项
101
- if (item.asyncOptions && (item.autoload || typeof item.autoload == "undefined") && (isFunction(item.asyncOptions) || isAsyncFunction(item.asyncOptions))) {
102
- item.loading = true
103
- item.options = await item.asyncOptions(formModel, item, curdFormContext).finally(() => (item.loading = false))
104
- !instance?.isUnmounted && item.eventObject?.optionLoaded && item.eventObject?.optionLoaded(formModel, item, curdFormContext)
105
- } else if (item.prop && item.asyncValue && (isFunction(item.asyncValue) || isAsyncFunction(item.asyncValue))) {
106
- // 异步默认值
107
- item.loading = true
108
- formModel[item.prop] = await item.asyncValue(formModel, item).finally(() => (item.loading = false))
109
- }
110
- })
111
99
 
112
100
  const schemaItems = computed(() => {
113
101
  return sFormSchema.value.formItem.filter((item) => {
@@ -120,10 +108,21 @@ export default defineComponent({
120
108
  return !item.hidden
121
109
  })
122
110
  })
111
+ // 异步设置默认数据
112
+ sFormSchema.value.formItem.forEach(async (item) => {
113
+ //
114
+ // 异步选项
115
+ if (item.asyncOptions && (item.autoload || typeof item.autoload == "undefined") && (isFunction(item.asyncOptions) || isAsyncFunction(item.asyncOptions))) {
116
+ item.loading = true
117
+ item.options = await item.asyncOptions(formModel, item, curdFormContext).finally(() => (item.loading = false))
118
+ !instance?.isUnmounted && item.eventObject?.optionLoaded && item.eventObject?.optionLoaded(formModel, item, curdFormContext)
119
+ }
120
+ })
121
+
123
122
  // 生成表单验证规则
124
123
  const rules = computed(() => {
125
- if (typeof sFormSchema.value.rules == "function") {
126
- return sFormSchema.value.rules(formModel, curdFormContext)
124
+ if (typeof sFormSchema.value.getRules == "function") {
125
+ return sFormSchema.value.getRules(formModel, curdFormContext)
127
126
  }
128
127
  return sFormSchema.value.rules
129
128
  })
@@ -134,17 +133,19 @@ export default defineComponent({
134
133
  }
135
134
  // 调用某个表单项的异步数据接口
136
135
  const loadOptions = async (prop: string, option?: any) => {
137
- const cur = sFormSchema.value.formItem.find((a) => a.prop == prop)
136
+ const cur: FormItemType | undefined = sFormSchema.value.formItem.find((a) => a.prop == prop)
138
137
  if (cur && cur.asyncOptions && !instance?.isUnmounted) {
139
138
  cur.loading = true
139
+ triggerRef(schemaItems)
140
140
  cur.options =
141
141
  (await cur
142
142
  .asyncOptions(formModel, cur, curdFormContext, option)
143
143
  .catch((err) => console.error("loadOptionError", err))
144
144
  .finally(() => (cur.loading = false))) || []
145
+ triggerRef(schemaItems)
145
146
  !instance?.isUnmounted && cur.eventObject?.optionLoaded && cur.eventObject?.optionLoaded(formModel, cur, curdFormContext, option)
146
147
  }
147
- return cur
148
+ return cur?.options || []
148
149
  }
149
150
  // 给某个item赋值options
150
151
  const setOptions = async (prop: string, options: CurdFormOptionItem[], option?: any) => {
@@ -168,7 +169,7 @@ export default defineComponent({
168
169
  return formItem.formItemProps(formModel, formItem)
169
170
  }
170
171
  const { ...attrs } = formItem.formItemProps
171
- return attrs
172
+ return { ...attrs }
172
173
  }
173
174
  return {}
174
175
  }
@@ -181,7 +182,13 @@ export default defineComponent({
181
182
  return {}
182
183
  }
183
184
  const getFormProps = computed(() => {
184
- const { formItem, rules, ...args } = props.formSchema
185
+ const args: any = {}
186
+ const sm = props.formSchema as any
187
+ for (const i in sm) {
188
+ if (!["formItem", "rules", "getRules"].includes(i)) {
189
+ args[i] = sm[i]
190
+ }
191
+ }
185
192
  return { ...args }
186
193
  })
187
194
 
@@ -189,9 +196,12 @@ export default defineComponent({
189
196
  curdFormContext.setOptions = setOptions
190
197
  curdFormContext.change = onChange
191
198
  curdFormContext.formModel = formModel
192
- curdFormContext.formRef = schemaFormRef
199
+
193
200
  props.extendContext && Object.assign(curdFormContext, props.extendContext)
194
201
  provide("curdFormContext", curdFormContext)
202
+ onMounted(() => {
203
+ curdFormContext.formRef = schemaFormRef.value
204
+ })
195
205
  return {
196
206
  formModel,
197
207
  schemaFormRef,
@@ -1,14 +1,14 @@
1
1
  <template>
2
2
  <div class="form-item">
3
3
  <div v-if="props.formItem.prefix && isString(props.formItem.prefix)" class="form-item-prefix" v-html="props.formItem.prefix"></div>
4
- <component v-for="(item, i) in prefixList" :key="i" :is="item" v-model="modelRef[props.formItem.prop || '']" :form-item="props.formItem" :form-model="modelRef" :props="formItemProps" :event-object="eventObject" />
4
+ <component :is="item" v-for="(item, i) in prefixList" :key="i" v-model="modelRef[props.formItem.prop || '']" :form-item="props.formItem" :form-model="modelRef" :props="formItemProps" :event-object="eventObject" />
5
5
  <slot name="prefix"></slot>
6
6
  <component :is="comp" v-if="comp" v-model="modelRef[props.formItem.prop || '']" :form-item="props.formItem" :form-model="modelRef" :props="formItemProps" :event-object="eventObject" />
7
7
  <component :is="props.formItem.type" v-else v-model="modelRef[props.formItem.prop || '']" v-bind="formItemProps" v-on="eventObject" />
8
8
  <FormTooltip v-if="props.formItem.tooltip" :tooltip="props.formItem.tooltip" :form-item="props.formItem" :form-model="props.formModel" />
9
9
  <slot name="suffix"></slot>
10
10
  <div v-if="props.formItem.suffix && isString(props.formItem.suffix)" class="form-item-suffix" v-html="props.formItem.suffix"></div>
11
- <component v-for="(item, i) in suffixList" :key="i" :is="item" v-model="modelRef[props.formItem.prop || '']" :form-item="props.formItem" :form-model="modelRef" :props="formItemProps" :event-object="eventObject" />
11
+ <component :is="item" v-for="(item, i) in suffixList" :key="i" v-model="modelRef[props.formItem.prop || '']" :form-item="props.formItem" :form-model="modelRef" :props="formItemProps" :event-object="eventObject" />
12
12
  </div>
13
13
  </template>
14
14
  <script lang="ts" setup>
@@ -58,7 +58,7 @@ const eventObject = ref(
58
58
  const changeFun = props.formItem.eventObject.change
59
59
  result.change = (...args: any) => {
60
60
  if (changeFun) {
61
- const flag = changeFun && changeFun(props.formModel, props.formItem, formContext, ...args)
61
+ const flag = changeFun && changeFun.apply(null, [props.formModel, props.formItem, formContext, ...args])
62
62
  if (flag) {
63
63
  emit("change", props.formModel, props.formItem, formContext, ...args)
64
64
  }
@@ -75,9 +75,9 @@ const eventObject = ref(
75
75
  }
76
76
  }
77
77
  return result
78
- })()
78
+ })(),
79
79
  )
80
- const isString = (val) => {
80
+ const isString = (val: any) => {
81
81
  return typeof val === "string"
82
82
  }
83
83
  const prefixList = computed(() => {
@@ -15,7 +15,7 @@ import { ElButton, ElIcon, ElTooltip, ElTooltipProps } from "element-plus"
15
15
  import { FormItem, Fields } from "./types"
16
16
  const props = defineProps({
17
17
  tooltip: {
18
- type: [String, Function],
18
+ type: [String, Function] as PropType<string | ((formModel: Fields, formItem: FormItem) => Partial<ElTooltipProps> | string) | Partial<ElTooltipProps>>,
19
19
  default: null,
20
20
  },
21
21
  formItem: {
@@ -28,28 +28,28 @@ const props = defineProps({
28
28
  },
29
29
  })
30
30
 
31
- const is = (val: any, type: string) => {
32
- return Object.prototype.toString.call(val) === `[object ${type}]`
33
- }
34
31
  const tooltipModel = computed(() => {
35
32
  let tooltip: any = props.tooltip
36
33
  if (!tooltip) {
37
- return {}
34
+ return { content: "" }
38
35
  }
39
- if (is(tooltip, "Function")) {
36
+ if (typeof tooltip == "function") {
40
37
  tooltip = tooltip(props.formModel, props.formItem)
41
38
  return getTooltip(tooltip)
42
39
  }
43
40
  return getTooltip(tooltip)
44
41
  })
45
42
  // 获取组件tooltip内容
46
- const getTooltip = (tooltip: ElTooltipProps | String) => {
43
+ const getTooltip = (tooltip: Partial<ElTooltipProps> | string): Partial<ElTooltipProps> => {
47
44
  if (!tooltip) {
48
- return ""
45
+ return { content: "" }
49
46
  }
50
- if (is(tooltip, "String")) {
51
- return { content: tooltip }
47
+ let t: Partial<ElTooltipProps> = {}
48
+ if (typeof tooltip == "string") {
49
+ t = { content: tooltip }
50
+ } else {
51
+ t = tooltip
52
52
  }
53
- return tooltip
53
+ return t
54
54
  }
55
55
  </script>
@@ -10,7 +10,7 @@ import SchemaFormColorPicker from "./schema-form-color-picker.vue"
10
10
  import SchemaFormValue from "./schema-form-value.vue"
11
11
  import SchemaFormCascader from "./schema-form-cascader.vue"
12
12
  import SchemaFormAutocomplete from "./schema-form-autocomplete.vue"
13
- import { isReactive, isRef, createVNode, isVNode } from "vue"
13
+ import { isReactive, isRef, isVNode } from "vue"
14
14
  interface PresetMap {
15
15
  [key: string]: any
16
16
  }
@@ -8,7 +8,7 @@
8
8
  </template>
9
9
  <script lang="ts" setup>
10
10
  import { computed, PropType } from "vue"
11
- import { ElCascader, CascaderOption, CascaderValue } from "element-plus"
11
+ import { CascaderValue } from "element-plus"
12
12
  import { FormItemProps } from "easybill-ui/components/CurdForm/src/types"
13
13
  const props = defineProps({
14
14
  ...FormItemProps,
@@ -42,7 +42,7 @@ export default defineComponent({
42
42
  },
43
43
  {
44
44
  deep: true,
45
- }
45
+ },
46
46
  )
47
47
  // 有的options是从接口里拿的,掉接口需要时间,初始全选的时候全选的按钮没有勾选上,所以监听options
48
48
  watch(
@@ -56,7 +56,7 @@ export default defineComponent({
56
56
  },
57
57
  {
58
58
  deep: true,
59
- }
59
+ },
60
60
  )
61
61
  const selectAll = () => {
62
62
  if (checked.value) {
@@ -3,11 +3,11 @@
3
3
  </template>
4
4
  <script lang="ts">
5
5
  import { defineComponent, computed, PropType } from "vue"
6
- import { ElDatePicker, ModelValueType } from "element-plus"
6
+ import { ElTimePicker, ModelValueType } from "element-plus"
7
7
  import { FormItemProps } from "../types"
8
8
  export default defineComponent({
9
- name: "SchemaFormDatePicker",
10
- components: { ElDatePicker },
9
+ name: "SchemaFormTimePicker",
10
+ components: { ElTimePicker },
11
11
  props: {
12
12
  ...FormItemProps,
13
13
  modelValue: {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div v-html="model" v-bind="props"></div>
2
+ <div v-bind="props" v-html="model"></div>
3
3
  </template>
4
4
  <script lang="ts">
5
5
  import { defineComponent, computed } from "vue"
@@ -1,6 +1,6 @@
1
- import { inject } from "vue"
2
- import { FormContext } from "../types"
3
- export function useForm() {
4
- const formContext = inject<FormContext>("curdFormContext")
5
- return { formContext }
6
- }
1
+ import { inject } from "vue"
2
+ import { FormContext } from "../types"
3
+ export function useForm() {
4
+ const formContext = inject<FormContext>("curdFormContext") as FormContext
5
+ return { formContext }
6
+ }
@@ -1,12 +1,23 @@
1
- import { FormRules, FormItemRule, FormProps, ElForm, ElTooltipProps } from "element-plus"
2
- import { PropType, Ref } from "vue"
1
+ import { FormRules, FormItemRule, ElForm, TooltipTriggerType } from "element-plus"
2
+ import { PropType } from "vue"
3
3
  import { OptionItem } from "../../ConstantStatus"
4
4
  import { defineComponent } from "vue"
5
- export interface FormSchema extends Partial<FormProps> {
6
- formItem: Array<FormItem>
7
- rules?: FormRules | ((formModel: Fields, context: FormContext) => FormRules)
8
- labelPosition?: "left" | "right" | "top"
5
+ export interface FormSchema {
6
+ formItem: FormItem[]
7
+ rules?: FormRules
8
+ getRules?: (formModel: Fields, context: FormContext) => FormRules
9
+ labelPosition?: "left" | "right" | "top" | string
9
10
  gutter?: number
11
+ labelWidth?: number | string
12
+ inline?: boolean
13
+ inlineMessage?: boolean
14
+ statusIcon?: boolean
15
+ showMessage?: boolean
16
+ size?: "default" | "small" | "large" | string
17
+ disabled?: boolean
18
+ validateOnRuleChange?: boolean
19
+ hideRequiredAsterisk?: boolean
20
+ scrollToError?: boolean
10
21
  }
11
22
  export interface FormItem {
12
23
  prop: string
@@ -15,32 +26,49 @@ export interface FormItem {
15
26
  value?: any
16
27
  eventObject?: EventObject
17
28
  options?: Array<CurdFormOptionItem>
18
- asyncOptions?: (modelRef: Fields, formItem: FormItem, context: FormContext, config?: Fields) => Promise<Array<CurdFormOptionItem>>
19
- asyncValue?: (modelRef: Fields, formItem: FormItem) => Promise<string | number | boolean>
29
+ asyncOptions?: (modelRef: Fields, formItem: any, context: FormContext, config?: any) => Promise<Array<CurdFormOptionItem>>
20
30
  loading?: boolean
21
31
  hidden?: boolean | ((model: Fields) => boolean)
22
- rules?: FormItemRule[] | ((formModel: Fields, formItem: FormItem, context: FormContext) => FormItemRule[])
23
- props?: FormItemPropObject | ((formModel: Fields, formItem: FormItem) => void)
24
- formItemProps?: FormItemPropObject | ((formModel: Fields, formItem: FormItem) => void)
25
- labelWidth?: string
32
+ rules?: FormItemRule[]
33
+ props?: FormItemPropObject | ((formModel: Fields, formItem: any) => FormItemPropObject)
34
+ formItemProps?: FormItemPropObject | ((formModel: Fields, formItem: any) => void)
35
+ labelWidth?: string | number
26
36
  span?: number
27
37
  disabled?: boolean
28
- tooltip?: string | ((formModel: Fields, formItem: FormItem) => Partial<ElTooltipProps> | String) | Partial<ElTooltipProps>
38
+ tooltip?: string | ((formModel: Fields, formItem: any) => Partial<TooltipProps> | string) | Partial<TooltipProps>
29
39
  autoload?: boolean
30
40
  prefix?: string | any
31
41
  suffix?: string | any
42
+ sortIndex?: number
32
43
  }
33
44
  export type FormItemTypeEmun = "input" | "select" | "radio" | "checkbox" | "input-number" | "switch" | "file" | "date-picker" | "time-picker" | "color-picker" | "value"
34
- // type FormItemProps = FormItemPropObject | ((formModel: Fields, formItem: FormItem) => void)
35
45
  export interface FormItemPropObject {
36
46
  [key: string]: any
37
47
  }
48
+ export interface TooltipProps {
49
+ effect: "dark" | "light"
50
+ content: string
51
+ rawContent: boolean
52
+ placement: import("element-plus/es/components/popper").Placement
53
+ disabled: boolean
54
+ offset: number
55
+ transition: string
56
+ popperOptions: any
57
+ showAfter: number
58
+ showArrow: boolean
59
+ hideAfter: number
60
+ autoClose: number
61
+ popperClass: string
62
+ enterable: boolean
63
+ teleported: boolean
64
+ trigger: TooltipTriggerType
65
+ }
38
66
  export interface FormContext {
39
- loadOptions: (prop: string) => void
40
- setOptions: (prop: string, options: CurdFormOptionItem[]) => void
67
+ loadOptions: (prop: string, config?: Fields) => void
68
+ setOptions: (prop: string, options: CurdFormOptionItem[], config?: any) => void
41
69
  change: (formModel: Fields, formItem: FormItem) => void
42
70
  formModel: Fields
43
- formRef: Ref<InstanceType<typeof ElForm> | undefined>
71
+ formRef: InstanceType<typeof ElForm> | undefined
44
72
  setValue: (prop: string, value?: any) => void
45
73
  }
46
74
  export interface Fields {
@@ -53,9 +81,9 @@ export interface CurdFormOptionItem extends OptionItem {
53
81
  // change?: (formModel: Fields, formItem: FormItem, proxy: any) => void
54
82
  // }
55
83
  export interface EventObject {
56
- change?: (formModel: Fields, formItem: FormItem, context: FormContext) => void
57
- optionLoaded?: (formModel: Fields, formItem: FormItem, context: FormContext) => void
58
- [key: string]: ((formModel: Fields, formItem: FormItem, context: FormContext) => void) | undefined
84
+ change?: (formModel: Fields, formItem: FormItem, context: FormContext, ...args: any[]) => void | boolean
85
+ optionLoaded?: (formModel: Fields, formItem: FormItem, context: FormContext, config?: any) => void
86
+ [key: string]: ((formModel: Fields, formItem: FormItem, context: FormContext, config?: any) => void) | undefined
59
87
  }
60
88
  // export interface OptionItem {
61
89
  // label: string
@@ -57,8 +57,9 @@ export const ajaxUpload: UploadRequestHandler = (option) => {
57
57
  const formData = new FormData()
58
58
  if (option.data) {
59
59
  for (const [key, value] of Object.entries(option.data)) {
60
- if (Array.isArray(value)) formData.append(key, ...value)
61
- else formData.append(key, value)
60
+ if (Array.isArray(value)) {
61
+ formData.append(key, value[0])
62
+ } else formData.append(key, value)
62
63
  }
63
64
  }
64
65
  formData.append(option.filename, option.file, option.file.name)