@tplc/business 0.3.99 → 0.3.100

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,8 @@
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.3.100](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.3.99...v0.3.100) (2025-03-22)
6
+
5
7
  ### [0.3.99](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.3.98...v0.3.99) (2025-03-22)
6
8
 
7
9
 
@@ -49,7 +49,6 @@ watchEffect(() => {
49
49
  watch(
50
50
  () => [props.url, props.baseParam, form?.value],
51
51
  async () => {
52
- console.log('props.url', props)
53
52
  paging.value?.reload()
54
53
  },
55
54
  {
@@ -34,9 +34,11 @@
34
34
  <TreeSelect
35
35
  v-else-if="item.component === 'treeSelect'"
36
36
  v-bind="item.componentProps"
37
- v-model="filter[item.valueName]"
38
- v-model:title="titleObj[item.valueName]"
39
- @submit="onSubmit(index)"
37
+ :value="filter[item.valueName]"
38
+ :value-name="item.valueName"
39
+ v-model:count="titleCount[item.valueName]"
40
+ :filter-value="filter"
41
+ @submit="onSubmit(index, $event)"
40
42
  />
41
43
  <ComponentGroup
42
44
  v-else-if="item.component === 'componentGroup'"
@@ -4,5 +4,6 @@ import { LcbListProps } from '../../types'
4
4
  export interface FilterViewProps extends LcbListProps {
5
5
  info: LcbFilterResult
6
6
  titleObj: Record<string, any>
7
+ titleCount: Record<string, number>
7
8
  sticky: boolean
8
9
  }
@@ -16,12 +16,18 @@
16
16
  <view
17
17
  v-for="item in options[currentCategory].children"
18
18
  :key="item.label"
19
- @click="onItemClick(item)"
19
+ @click="onItemClick(item, options[currentCategory].valueName)"
20
20
  class="filter-select flex justify-between items-center !px-36rpx !py-30rpx"
21
- :class="getChecked(item) ? 'filter-select__choose' : ''"
21
+ :class="
22
+ getChecked(item, options[currentCategory].valueName) ? 'filter-select__choose' : ''
23
+ "
22
24
  >
23
25
  {{ item.label }}
24
- <wd-icon name="check" custom-class="choose_icon" v-if="innerValue === item.value" />
26
+ <wd-icon
27
+ name="check"
28
+ custom-class="choose_icon"
29
+ v-if="getChecked(item, options[currentCategory].valueName)"
30
+ />
25
31
  </view>
26
32
  </view>
27
33
  <scroll-view
@@ -42,23 +48,19 @@
42
48
  v-for="child in item.children"
43
49
  :key="child.label"
44
50
  :title="child.label"
45
- :checked="getChecked(child)"
46
- @click="onItemClick(child)"
51
+ :checked="getChecked(child, item.valueName)"
52
+ @click="onItemClick(child, item.valueName)"
47
53
  />
48
54
  </view>
49
55
  </view>
50
56
  </scroll-view>
51
57
  </view>
52
- <ActionView
53
- :disabled="!Boolean(innerValue)"
54
- @cancel="innerValue = undefined"
55
- @submit="onSubmit"
56
- />
58
+ <ActionView :disabled="!Boolean(innerValue)" @cancel="onCancel" @submit="onSubmit" />
57
59
  </view>
58
60
  </template>
59
61
 
60
62
  <script setup lang="ts">
61
- import { computed, getCurrentInstance, nextTick, watch, ref, watchEffect } from 'vue'
63
+ import { getCurrentInstance, nextTick, watch, ref } from 'vue'
62
64
  import { TreeSelectProps } from './type'
63
65
  import useSelect from '../../hooks/useSelect'
64
66
  import SelectTagView from '../SelectTagView/index.vue'
@@ -72,36 +74,34 @@ defineOptions({
72
74
  },
73
75
  })
74
76
  const props = defineProps<TreeSelectProps>()
75
- const model = defineModel<string | string[]>()
76
- const modelTitle = defineModel<string>('title')
77
- const innerValue = ref(model.value)
77
+ const modelCount = defineModel<number>('count')
78
+ const innerValue = ref(props.value)
78
79
  const toView = ref('')
80
+ const extraModel = ref({
81
+ ...props.filterValue,
82
+ })
79
83
  const itemTopPositions = ref<{ top: number; bottom: number }[]>([])
80
84
  const emits = defineEmits(['submit'])
81
- const { onItemClick, options, getChecked } = useSelect(props, { model: innerValue })
85
+ const { onItemClick, options, getChecked } = useSelect(props, { model: innerValue, extraModel })
82
86
  const currentCategory = ref(0)
83
- const treeObj = computed(() => {
84
- return options.value.reduce(
85
- (prev, next) => {
86
- next?.children?.forEach((item) => {
87
- prev[item.value as string] = item.label
88
- })
89
- return prev
90
- },
91
- {} as Record<string, string>,
92
- )
93
- })
94
87
  const onSubmit = () => {
95
- model.value = innerValue.value
96
- nextTick(() => {
97
- emits('submit')
88
+ let count = 0
89
+ options.value.forEach((item) => {
90
+ if (item.valueName) {
91
+ count += extraModel.value[item.valueName]
92
+ ? props.mode !== 'multiple'
93
+ ? 1
94
+ : extraModel.value[item.valueName].length
95
+ : 0
96
+ }
97
+ })
98
+ count += innerValue.value ? (props.mode !== 'multiple' ? 1 : innerValue.value.length) : 0
99
+ modelCount.value = count
100
+ emits('submit', {
101
+ ...extraModel.value,
102
+ [props.valueName]: innerValue.value,
98
103
  })
99
104
  }
100
- watchEffect(() => {
101
- if (props.mode !== 'multiple') {
102
- modelTitle.value = treeObj.value[innerValue.value as string]
103
- }
104
- })
105
105
  const onCategoryClick = (index: number) => {
106
106
  currentCategory.value = index
107
107
  toView.value = `grid_${index}`
@@ -134,6 +134,10 @@ const onGridScroll = (e) => {
134
134
  }
135
135
  })
136
136
  }
137
+ const onCancel = () => {
138
+ innerValue.value = undefined
139
+ extraModel.value = {}
140
+ }
137
141
  </script>
138
142
  <style lang="scss" scoped>
139
143
  @import '@tplc/wot/components/common/abstracts/variable';
@@ -1,3 +1,7 @@
1
1
  import { FilterItemProps } from '../../types'
2
2
 
3
- export interface TreeSelectProps extends FilterItemProps {}
3
+ export interface TreeSelectProps extends FilterItemProps {
4
+ filterValue?: Record<string, any>
5
+ value?: string | string[]
6
+ valueName: string
7
+ }
@@ -4,22 +4,31 @@ const useSelect = (
4
4
  props: FilterItemProps,
5
5
  {
6
6
  model,
7
+ extraModel,
7
8
  }: {
8
9
  model: Ref<string | string[] | undefined>
10
+ extraModel?: Ref<Record<string, any>>
9
11
  },
10
12
  ) => {
11
13
  const options = ref<Option[]>(props.options || [])
12
- const onItemClick = (item: Option) => {
14
+ const onItemClick = (item: Option, valueName?: string) => {
15
+ let val: string[] | string | undefined
16
+ const currentValue = valueName ? extraModel?.value[valueName] : model.value
13
17
  if (props.mode === 'multiple') {
14
- if (typeof model.value === 'object' && model.value.includes(item.value as string)) {
15
- model.value = model.value.filter((v) => v !== item.value)
18
+ if (typeof currentValue === 'object' && currentValue.includes(item.value as string)) {
19
+ val = currentValue.filter((v) => v !== item.value)
16
20
  } else {
17
- model.value = [...(model.value || []), item.value as string]
21
+ val = [...(currentValue || []), item.value as string]
18
22
  }
19
- } else if (model.value === item.value) {
20
- model.value = undefined
23
+ } else if (currentValue === item.value) {
24
+ val = undefined
21
25
  } else {
22
- model.value = item.value
26
+ val = item.value
27
+ }
28
+ if (valueName && extraModel) {
29
+ extraModel.value[valueName] = val
30
+ } else {
31
+ model.value = val
23
32
  }
24
33
  }
25
34
 
@@ -30,11 +39,12 @@ const useSelect = (
30
39
  options.value = data
31
40
  }
32
41
  })
33
- const getChecked = (item: Option) => {
34
- if (Array.isArray(model.value)) {
35
- return model.value.includes(`${item.value}`)
42
+ const getChecked = (item: Option, valueName?: string) => {
43
+ const currentValue = valueName ? extraModel?.value[valueName] : model.value
44
+ if (Array.isArray(currentValue)) {
45
+ return currentValue.includes(`${item.value}`)
36
46
  } else {
37
- return Boolean(model.value && model.value === item.value)
47
+ return Boolean(currentValue && currentValue === item.value)
38
48
  }
39
49
  }
40
50
  return {
@@ -11,6 +11,7 @@
11
11
  :info="info"
12
12
  v-model="form"
13
13
  :titleObj="titleObj"
14
+ :titleCount="titleCount"
14
15
  :sticky="sticky"
15
16
  />
16
17
  </wd-sticky>
@@ -20,6 +21,7 @@
20
21
  :info="info"
21
22
  v-model="form"
22
23
  :titleObj="titleObj"
24
+ :titleCount="titleCount"
23
25
  :sticky="sticky"
24
26
  />
25
27
  </template>
@@ -79,6 +81,7 @@ defineOptions({
79
81
  },
80
82
  })
81
83
  const titleObj = ref<Record<string, any>>({})
84
+ const titleCount = ref<Record<string, number>>({})
82
85
  const form = inject<Ref<Record<string, any>>>(FORM_KEY)
83
86
  const props = withDefaults(defineProps<LcbListProps>(), {
84
87
  borderRadius: 12,
@@ -26,6 +26,7 @@ export interface Option {
26
26
  min?: number
27
27
  children?: Option[]
28
28
  unit?: string
29
+ valueName?: string
29
30
  }
30
31
 
31
32
  export interface FilterItemProps {
@@ -126,7 +126,6 @@ async function link({ item }: { item: IPageBtn }) {
126
126
  const { data: logisticInfo } = await uni.$lcb.http.post<any>(item.requestUrl, {
127
127
  ...item.requestParam,
128
128
  })
129
- console.log(logisticInfo)
130
129
  logistic.data = logisticInfo
131
130
  logistic.show = true
132
131
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tplc/business",
3
- "version": "0.3.99",
3
+ "version": "0.3.100",
4
4
  "keywords": [
5
5
  "业务组件"
6
6
  ],
@@ -3,5 +3,6 @@ import { LcbListProps } from '../../types'
3
3
  export interface FilterViewProps extends LcbListProps {
4
4
  info: LcbFilterResult
5
5
  titleObj: Record<string, any>
6
+ titleCount: Record<string, number>
6
7
  sticky: boolean
7
8
  }
@@ -1,8 +1,7 @@
1
1
  import { TreeSelectProps } from './type'
2
2
  declare let __VLS_typeProps: TreeSelectProps
3
3
  type __VLS_PublicProps = {
4
- modelValue?: string | string[]
5
- title?: string
4
+ count?: number
6
5
  } & typeof __VLS_typeProps
7
6
  declare const _default: import('vue').DefineComponent<
8
7
  __VLS_TypePropsToOption<__VLS_PublicProps>,
@@ -13,16 +12,14 @@ declare const _default: import('vue').DefineComponent<
13
12
  import('vue').ComponentOptionsMixin,
14
13
  import('vue').ComponentOptionsMixin,
15
14
  {
16
- 'update:modelValue': (modelValue: string | string[]) => void
17
- 'update:title': (title: string) => void
15
+ 'update:count': (count: number) => void
18
16
  submit: (...args: any[]) => void
19
17
  },
20
18
  string,
21
19
  import('vue').PublicProps,
22
20
  Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToOption<__VLS_PublicProps>>> & {
23
- 'onUpdate:modelValue'?: ((modelValue: string | string[]) => any) | undefined
24
21
  onSubmit?: ((...args: any[]) => any) | undefined
25
- 'onUpdate:title'?: ((title: string) => any) | undefined
22
+ 'onUpdate:count'?: ((count: number) => any) | undefined
26
23
  },
27
24
  {},
28
25
  {}
@@ -1,2 +1,6 @@
1
1
  import { FilterItemProps } from '../../types'
2
- export interface TreeSelectProps extends FilterItemProps {}
2
+ export interface TreeSelectProps extends FilterItemProps {
3
+ filterValue?: Record<string, any>
4
+ value?: string | string[]
5
+ valueName: string
6
+ }
@@ -4,8 +4,10 @@ declare const useSelect: (
4
4
  props: FilterItemProps,
5
5
  {
6
6
  model,
7
+ extraModel,
7
8
  }: {
8
9
  model: Ref<string | string[] | undefined>
10
+ extraModel?: Ref<Record<string, any>>
9
11
  },
10
12
  ) => {
11
13
  options: Ref<
@@ -17,9 +19,10 @@ declare const useSelect: (
17
19
  min?: number | undefined
18
20
  children?: any[] | undefined
19
21
  unit?: string | undefined
22
+ valueName?: string | undefined
20
23
  }[]
21
24
  >
22
- getChecked: (item: Option) => boolean
23
- onItemClick: (item: Option) => void
25
+ getChecked: (item: Option, valueName?: string) => boolean
26
+ onItemClick: (item: Option, valueName?: string) => void
24
27
  }
25
28
  export default useSelect
@@ -25,6 +25,7 @@ export interface Option {
25
25
  min?: number
26
26
  children?: Option[]
27
27
  unit?: string
28
+ valueName?: string
28
29
  }
29
30
  export interface FilterItemProps {
30
31
  mode?: 'multiple' | 'single'