easybill-ui 1.0.0 → 1.0.2

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.
@@ -121,6 +121,9 @@ export default defineComponent({
121
121
 
122
122
  // 生成表单验证规则
123
123
  const rules = computed(() => {
124
+ if (typeof sFormSchema.value.rules == "function") {
125
+ return sFormSchema.value.rules(formModel, curdFormContext)
126
+ }
124
127
  if (typeof sFormSchema.value.getRules == "function") {
125
128
  return sFormSchema.value.getRules(formModel, curdFormContext)
126
129
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <el-input v-model="model" v-trim :disabled="formItem.disabled || false" v-bind="props" :placeholder="(props.placeholder && String(props.placeholder)) || '请输入' + formItem.label" autocomplete="new-password" v-on="eventObject" />
2
+ <el-input v-model="model" v-trim :disabled="formItem.disabled || false" v-bind="props" :placeholder="(props.placeholder && String(props.placeholder)) || '请输入' + (props.label || formItem.label)" autocomplete="new-password" v-on="eventObject" />
3
3
  </template>
4
4
  <script lang="ts">
5
5
  import { defineComponent, computed } from "vue"
@@ -1,18 +1,24 @@
1
- import { FormRules, FormItemRule, FormProps, ElForm, TooltipTriggerType } from "element-plus"
1
+ import { FormRules, FormItemRule, ElForm, TooltipTriggerType } from "element-plus"
2
+ import type { Arrayable } from "element-plus/es/utils"
2
3
  import { PropType } from "vue"
3
4
  import { OptionItem } from "../../ConstantStatus"
4
5
  import { defineComponent } from "vue"
5
- export interface FormSchema extends Partial<FormProps> {
6
+ export interface FormSchema {
6
7
  formItem: FormItem[]
7
- rules?: FormRules
8
+ rules?: FormRules | ((formModel: Fields, context: FormContext) => FormRules)
8
9
  getRules?: (formModel: Fields, context: FormContext) => FormRules
9
- labelPosition?: LabelPosition
10
+ labelPosition?: "left" | "right" | "top" | string
10
11
  gutter?: number
11
- }
12
- export enum LabelPosition {
13
- LEFT = "left",
14
- RIGHT = "right",
15
- TOP = "top",
12
+ labelWidth?: number | string
13
+ inline?: boolean
14
+ inlineMessage?: boolean
15
+ statusIcon?: boolean
16
+ showMessage?: boolean
17
+ size?: "default" | "small" | "large" | string
18
+ disabled?: boolean
19
+ validateOnRuleChange?: boolean
20
+ hideRequiredAsterisk?: boolean
21
+ scrollToError?: boolean
16
22
  }
17
23
  export interface FormItem {
18
24
  prop: string
@@ -24,7 +30,7 @@ export interface FormItem {
24
30
  asyncOptions?: (modelRef: Fields, formItem: any, context: FormContext, config?: any) => Promise<Array<CurdFormOptionItem>>
25
31
  loading?: boolean
26
32
  hidden?: boolean | ((model: Fields) => boolean)
27
- rules?: FormItemRule[]
33
+ rules?: Arrayable<FormItemRule>
28
34
  props?: FormItemPropObject | ((formModel: Fields, formItem: any) => FormItemPropObject)
29
35
  formItemProps?: FormItemPropObject | ((formModel: Fields, formItem: any) => void)
30
36
  labelWidth?: string | number
@@ -366,7 +366,9 @@ const create = (row?: any) => {
366
366
  if (rules) {
367
367
  let rulesItem: FormItemRule[] = []
368
368
  if (!formSchema.rules) formSchema.rules = {}
369
- formSchema.rules[item.prop] = rules
369
+ if (typeof formSchema.rules !== "function") {
370
+ formSchema.rules[item.prop] = rules
371
+ }
370
372
  }
371
373
  }
372
374
  columns.value.map((a) => {
@@ -112,7 +112,7 @@ export interface PropOption {
112
112
  customActivatedFetch: boolean // 自定义执行onActivated内部的fetch执行,完全交由父组件控制
113
113
  autoload: boolean
114
114
  menuEvent: Partial<Record<MenuEventKey, () => void>>
115
- filterAttrs: Partial<FormProps>
115
+ filterAttrs: Partial<FormSchema>
116
116
  formAttrs: FormAttrs
117
117
  editOptions: FormDialogOptions
118
118
  createOptions: FormDialogOptions
@@ -4,7 +4,7 @@ import { defineComponent } from "vue"
4
4
 
5
5
  export interface DetailDataItem extends Record<string, any> {
6
6
  label?: string
7
- value?: string | number | boolean
7
+ value?: any
8
8
  /** 当前项占的宽度,最大24, 默认24 */
9
9
  span?: number
10
10
  /** 当前数据的选项,里面包含的图标、颜色信息会自动显示 */
@@ -1,14 +1,14 @@
1
1
  <template>
2
- <CurdForm ref="formRef" v-model="query" inline class="filter-external" :form-schema="formSchema" @change="onChange">
2
+ <CurdForm ref="formRef" v-model="query" inline class="filter-external" :form-schema="formSchema" v-bind="option?.formProps" @change="onChange">
3
3
  <template #defaultFilter>
4
4
  <slot></slot>
5
5
  </template>
6
6
  </CurdForm>
7
7
  </template>
8
8
  <script lang="ts" setup>
9
- import { ref, watch, PropType } from "vue"
9
+ import { ref, watch, PropType, inject } from "vue"
10
10
  import CurdForm from "../../../CurdForm"
11
- import { ParamsItem, ListQuery } from "../../types"
11
+ import { ParamsItem, ListQuery, FilterOption } from "../../types"
12
12
  import { Fields, FormSchema, FormItem } from "../../../CurdForm"
13
13
  const props = defineProps({
14
14
  selectParams: {
@@ -28,6 +28,7 @@ const props = defineProps({
28
28
  default: false,
29
29
  },
30
30
  })
31
+ const option = inject<FilterOption>("option")
31
32
  const query = ref<any>({})
32
33
  // 特殊处理数组
33
34
  const formItemLeft = props.selectParams.filter((a) => a.external === true || a.external === "left").sort((a, b) => parseInt(String(b.sortIndex || 0)) - parseInt(String(a.sortIndex || 0))) as FormItem[]
@@ -51,6 +51,10 @@ const props = defineProps({
51
51
  type: Object as PropType<I.ListQuery>,
52
52
  default: undefined,
53
53
  },
54
+ option: {
55
+ type: Object as PropType<Partial<I.FilterOption>>,
56
+ default: undefined,
57
+ },
54
58
  })
55
59
  const emit = defineEmits(["search"])
56
60
  const searchRef = ref()
@@ -174,7 +178,9 @@ const clear = () => {
174
178
  }
175
179
  // 重新调用selectParams
176
180
  const refreshSelectParams = () => {
177
- selectParams.value = deepClone(props.schema)
181
+ if (props.schema) {
182
+ selectParams.value = deepClone(props.schema)
183
+ }
178
184
  }
179
185
  const getCurrentIndex = () => {
180
186
  return searchRef.value && searchRef.value.currentIndex
@@ -195,6 +201,7 @@ provide("tableFilter", tableFilterContext)
195
201
  provide("state", state)
196
202
  provide("selectList", selectList)
197
203
  provide("selectParams", selectParams)
204
+ provide("option", props.option)
198
205
  defineExpose({ setItem, selectList, loadOptions, clear, refreshSelectParams, getCurrentIndex, listQuery, selectParams })
199
206
  onMounted(() => {
200
207
  getTags()
@@ -17,3 +17,9 @@ export interface TableFilterContext {
17
17
  export interface ListQuery {
18
18
  [key: string]: any //string | boolean | number | Array<string> | Array<number>
19
19
  }
20
+ export interface FilterOption {
21
+ formProps: {
22
+ labelWidth?: string | number
23
+ labelPosition?: "left" | "right" | "center" | string
24
+ }
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easybill-ui",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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": "4ea4d1bac2d11c24f74945c3cb559724be417a9d"
17
+ "gitHead": "6dc20c198be9f3d1c7fde6c788e141eca4146c17"
18
18
  }