@tplc/business 0.3.99 → 0.3.101

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,15 @@
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.101](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.3.100...v0.3.101) (2025-03-22)
6
+
7
+
8
+ ### ✨ Features | 新功能
9
+
10
+ * 还差数据统一 ([4f87b06](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/4f87b06331726ae4bf505c4ebae62076688ee9dc))
11
+
12
+ ### [0.3.100](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.3.99...v0.3.100) (2025-03-22)
13
+
5
14
  ### [0.3.99](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.3.98...v0.3.99) (2025-03-22)
6
15
 
7
16
 
@@ -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,44 @@ 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 })
82
- 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
- )
85
+ const onOpen = () => {
86
+ innerValue.value = props.value
87
+ extraModel.value = {
88
+ ...props.filterValue,
89
+ }
90
+ }
91
+ const { onItemClick, options, getChecked } = useSelect(props, {
92
+ model: innerValue,
93
+ extraModel,
94
+ onOpen,
93
95
  })
96
+ const currentCategory = ref(0)
94
97
  const onSubmit = () => {
95
- model.value = innerValue.value
96
- nextTick(() => {
97
- emits('submit')
98
+ let count = 0
99
+ options.value.forEach((item) => {
100
+ if (item.valueName) {
101
+ count += extraModel.value[item.valueName]
102
+ ? props.mode !== 'multiple'
103
+ ? 1
104
+ : extraModel.value[item.valueName].length
105
+ : 0
106
+ }
107
+ })
108
+ count += innerValue.value ? (props.mode !== 'multiple' ? 1 : innerValue.value.length) : 0
109
+ modelCount.value = count
110
+ emits('submit', {
111
+ ...extraModel.value,
112
+ [props.valueName]: innerValue.value,
98
113
  })
99
114
  }
100
- watchEffect(() => {
101
- if (props.mode !== 'multiple') {
102
- modelTitle.value = treeObj.value[innerValue.value as string]
103
- }
104
- })
105
115
  const onCategoryClick = (index: number) => {
106
116
  currentCategory.value = index
107
117
  toView.value = `grid_${index}`
@@ -134,6 +144,10 @@ const onGridScroll = (e) => {
134
144
  }
135
145
  })
136
146
  }
147
+ const onCancel = () => {
148
+ innerValue.value = undefined
149
+ extraModel.value = {}
150
+ }
137
151
  </script>
138
152
  <style lang="scss" scoped>
139
153
  @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
+ }
@@ -1,25 +1,36 @@
1
- import { onMounted, ref, Ref } from 'vue'
1
+ import { onMounted, onUnmounted, ref, Ref } from 'vue'
2
2
  import { FilterItemProps, Option } from '../types'
3
3
  const useSelect = (
4
4
  props: FilterItemProps,
5
5
  {
6
6
  model,
7
+ extraModel,
8
+ onOpen,
7
9
  }: {
8
10
  model: Ref<string | string[] | undefined>
11
+ extraModel?: Ref<Record<string, any>>
12
+ onOpen?: () => void
9
13
  },
10
14
  ) => {
11
15
  const options = ref<Option[]>(props.options || [])
12
- const onItemClick = (item: Option) => {
16
+ const onItemClick = (item: Option, valueName?: string) => {
17
+ let val: string[] | string | undefined
18
+ const currentValue = valueName ? extraModel?.value[valueName] : model.value
13
19
  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)
20
+ if (typeof currentValue === 'object' && currentValue.includes(item.value as string)) {
21
+ val = currentValue.filter((v) => v !== item.value)
16
22
  } else {
17
- model.value = [...(model.value || []), item.value as string]
23
+ val = [...(currentValue || []), item.value as string]
18
24
  }
19
- } else if (model.value === item.value) {
20
- model.value = undefined
25
+ } else if (currentValue === item.value) {
26
+ val = undefined
21
27
  } else {
22
- model.value = item.value
28
+ val = item.value
29
+ }
30
+ if (valueName && extraModel) {
31
+ extraModel.value[valueName] = val
32
+ } else {
33
+ model.value = val
23
34
  }
24
35
  }
25
36
 
@@ -29,12 +40,17 @@ const useSelect = (
29
40
  const { data } = await uni.$lcb.http.post<Option[]>(props.apiPath, props.apiParams || {})
30
41
  options.value = data
31
42
  }
43
+ if (onOpen) uni.$on('drop-opened', onOpen)
44
+ })
45
+ onUnmounted(() => {
46
+ if (onOpen) uni.$off('drop-opened', onOpen)
32
47
  })
33
- const getChecked = (item: Option) => {
34
- if (Array.isArray(model.value)) {
35
- return model.value.includes(`${item.value}`)
48
+ const getChecked = (item: Option, valueName?: string) => {
49
+ const currentValue = valueName ? extraModel?.value[valueName] : model.value
50
+ if (Array.isArray(currentValue)) {
51
+ return currentValue.includes(`${item.value}`)
36
52
  } else {
37
- return Boolean(model.value && model.value === item.value)
53
+ return Boolean(currentValue && currentValue === item.value)
38
54
  }
39
55
  }
40
56
  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.101",
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,12 @@ declare const useSelect: (
4
4
  props: FilterItemProps,
5
5
  {
6
6
  model,
7
+ extraModel,
8
+ onOpen,
7
9
  }: {
8
10
  model: Ref<string | string[] | undefined>
11
+ extraModel?: Ref<Record<string, any>>
12
+ onOpen?: () => void
9
13
  },
10
14
  ) => {
11
15
  options: Ref<
@@ -17,9 +21,10 @@ declare const useSelect: (
17
21
  min?: number | undefined
18
22
  children?: any[] | undefined
19
23
  unit?: string | undefined
24
+ valueName?: string | undefined
20
25
  }[]
21
26
  >
22
- getChecked: (item: Option) => boolean
23
- onItemClick: (item: Option) => void
27
+ getChecked: (item: Option, valueName?: string) => boolean
28
+ onItemClick: (item: Option, valueName?: string) => void
24
29
  }
25
30
  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'