easybill-ui 0.0.13 → 0.0.14

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.
@@ -17,4 +17,5 @@ export interface OptionItem {
17
17
  * 供curd-form的单选或多选,选项上的tooltip
18
18
  */
19
19
  tooltip?: any
20
+ html?: string
20
21
  }
@@ -3,7 +3,10 @@
3
3
  <el-option v-if="props.all && !props.multiple" value="" label="全部"></el-option>
4
4
  <el-checkbox v-if="props.all && props.multiple" v-model="checked" label="全选" class="schema-form-select-check" @change="selectAll" />
5
5
  <template v-for="option in formItem.options" :key="option.value">
6
- <el-option :value="option.value" :label="option.label" :disabled="option.disabled"></el-option>
6
+ <el-option :value="option.value" :label="option.label" :disabled="option.disabled">
7
+ <div v-if="option.html" v-html="option.html"></div>
8
+ <template v-else>{{ option.label }}</template>
9
+ </el-option>
7
10
  </template>
8
11
  </el-select>
9
12
  </template>
@@ -18,7 +18,7 @@ export default {
18
18
  }
19
19
  </script>
20
20
  <script lang="ts" setup>
21
- import { PropType, provide, Ref, ref } from "vue"
21
+ import { PropType, provide, Ref, ref, reactive } from "vue"
22
22
  import * as I from "../types"
23
23
  import FilterExternal from "./FilterExternal/FilterExternal.vue"
24
24
  import FilterSearchBox from "./FilterSearchBox.vue"
@@ -65,20 +65,6 @@ const onChange = (d: any) => {
65
65
  emit("search", listQuery.value, selectList.value)
66
66
  return
67
67
  }
68
- // selectParams.value.forEach((a) => {
69
- // let i = selectList.value.findIndex((j) => a.prop == j.prop)
70
- // // selectList.value.splice(i, 1)
71
-
72
- // if (listQuery.value[a.prop] && !a.external) {
73
- // if (i > -1) {
74
- // selectList.value[i] = a
75
- // } else {
76
- // selectList.value.push(a)
77
- // }
78
- // }
79
- // })
80
- // console.log("selectList", selectList)
81
- // console.log("listQuery.value", listQuery.value)
82
68
  emit("search", listQuery.value, selectList.value)
83
69
  }
84
70
  const onRemove = () => {
@@ -150,6 +136,11 @@ const setItem = (prop: string, paramsItem?: any) => {
150
136
  }
151
137
  })
152
138
  }
139
+ //主动赋值
140
+ const setValue = (prop: string, value: any) => {
141
+ listQuery.value[prop] = value
142
+ setItem(prop)
143
+ }
153
144
  const state = ref({
154
145
  isFocus: false,
155
146
  })
@@ -187,7 +178,11 @@ const onTagClick = (item: I.ParamsItem) => {
187
178
  const i = selectParams.value.findIndex((a) => a.prop == item.prop && a.label == item.label)
188
179
  searchRef.value.setIndex(i)
189
180
  }
190
-
181
+ const tableFilterContext = reactive<I.TableFilterContext>({
182
+ loadOptions,
183
+ setValue,
184
+ })
185
+ provide("tableFilter", tableFilterContext)
191
186
  provide("state", state)
192
187
  provide("selectList", selectList)
193
188
  defineExpose({ setItem, selectList, loadOptions, clear, refreshSelectParams, getCurrentIndex })
@@ -4,7 +4,7 @@
4
4
  </div>
5
5
  </template>
6
6
  <script lang="ts" setup>
7
- import { ref, watch, Ref, PropType } from "vue"
7
+ import { ref, watch, inject, reactive, Ref, PropType } from "vue"
8
8
  import * as I from "../../types"
9
9
  import container from "./containers"
10
10
  import * as Utils from "../../../../utils/common"
@@ -23,27 +23,10 @@ const props = defineProps({
23
23
  },
24
24
  })
25
25
  const emit = defineEmits(["change", "search"])
26
- const listQuery: Ref<ListQuery> = ref(props.listQuery)
26
+ const listQuery = reactive<ListQuery>(props.listQuery)
27
27
  const query: Ref<ListQuery> = ref(Utils.deepClone(props.listQuery))
28
28
  const typeList = container
29
- // 两个watch导致循环无限调用问题,去掉了query的watch,该由change主动触发listQuery的改变
30
- // watch(
31
- // () => query.value,
32
- // (val) => {
33
- // let q = val as I.ListQuery
34
- // if (props.paramsItem.tableKey && props.paramsItem.tableKey.length) {
35
- // props.paramsItem.tableKey.forEach((a, i) => {
36
- // q[a] = val[props.paramsItem.prop][i]
37
- // })
38
- // }
39
- // for (let i in q) {
40
- // let item = q[i]
41
- // listQuery.value[i] = item
42
- // }
43
- // console.log("query监听里面", JSON.stringify(listQuery.value))
44
- // },
45
- // { immediate: true }
46
- // )
29
+ const tableFilter = inject("tableFilter")
47
30
  watch(
48
31
  () => props.listQuery,
49
32
  (val) => {
@@ -51,7 +34,7 @@ watch(
51
34
  let arr: Array<string> = []
52
35
  if (props.paramsItem.tableKey && props.paramsItem.tableKey.length) {
53
36
  props.paramsItem.tableKey.forEach((a) => {
54
- arr.push(listQuery.value[a] + "")
37
+ arr.push(listQuery[a] + "")
55
38
  })
56
39
  q[props.paramsItem.prop] = arr
57
40
  }
@@ -74,17 +57,19 @@ const wrapperRef = ref()
74
57
  const onChange = (option: ChangeOption) => {
75
58
  if (props.paramsItem.tableKey && props.paramsItem.tableKey.length) {
76
59
  props.paramsItem.tableKey.forEach((a, i) => {
77
- listQuery.value[a] = option.value[i]
60
+ listQuery[a] = option.value[i]
78
61
  })
79
62
  } else {
80
- listQuery.value[option.prop] = option.value
63
+ listQuery[option.prop] = option.value
64
+ }
65
+ if (props.paramsItem.eventObject?.change) {
66
+ props.paramsItem.eventObject?.change(listQuery, props.paramsItem, tableFilter)
81
67
  }
82
- // emit("change", option, props.paramsItem)
83
68
  emit("search", props.paramsItem)
84
69
  // close()
85
70
  }
86
- const setValue = (prop) => {
87
- listQuery.value[prop] = query.value[prop]
71
+ const setValue = (prop: string) => {
72
+ listQuery[prop] = query.value[prop]
88
73
  }
89
74
  const focus = () => {
90
75
  comRef.value && comRef.value.focus && comRef.value.focus()
@@ -11,8 +11,14 @@ export interface ParamsItem {
11
11
  sortIndex?: number // 排序,数字越大越靠前
12
12
  tagNames?: string
13
13
  props?: ParamsItemProps
14
+ eventObject?: {
15
+ change?: (query: ListQuery, paramsItem: ParamsItem, context: TableFilterContext) => void
16
+ }
17
+ }
18
+ export interface TableFilterContext {
19
+ loadOptions: (prop: string) => void
20
+ setValue: (prop: string, value: any) => void
14
21
  }
15
-
16
22
  export interface ListQuery {
17
23
  [key: string]: any //string | boolean | number | Array<string> | Array<number>
18
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easybill-ui",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
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": "f41aee744b7b9a741e40e2558fdb7486438b8f7a"
17
+ "gitHead": "17b80d6553dbd2a383f87a831afd57a1b50af101"
18
18
  }