@tplc/business 0.4.145 → 0.4.146

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.4.146](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.1.88...v0.4.146) (2025-06-27)
6
+
5
7
  ### [0.4.145](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.4.137...v0.4.145) (2025-06-26)
6
8
 
7
9
 
@@ -1,58 +1,15 @@
1
1
  <template>
2
2
  <lcb-block v-bind="$props">
3
- <wd-form custom-class="lcb-form" ref="formRef" :model="form">
3
+ <wd-form :custom-class="`lcb-form ${vertical ? 'vertical' : ''}`" ref="formRef" :model="form">
4
4
  <wd-cell-group border>
5
5
  <block v-for="field in fields" :key="field.entryFormFieldConfigId">
6
- <wd-input
7
- v-if="field.frontInputType === 'input'"
8
- :placeholder="field.frontPlaceholder || t('请输入') + field.fieldCustomName"
9
- v-model="form[field.field]"
10
- :label="field.fieldCustomName"
11
- :required="field.requiredFlag"
12
- :prop="field.field"
13
- :rules="field.requiredFlag ? [{ required: true, message: t('内容不能为空') }] : []"
14
- v-bind="field.props"
15
- />
16
- <wd-textarea
17
- v-else-if="field.frontInputType === 'inputArea'"
18
- :placeholder="field.frontPlaceholder || t('请输入') + field.fieldCustomName"
19
- v-model="form[field.field]"
20
- :label="field.fieldCustomName"
21
- :required="field.requiredFlag"
22
- :prop="field.field"
23
- :rules="field.requiredFlag ? [{ required: true, message: t('内容不能为空') }] : []"
24
- v-bind="field.props"
25
- />
26
- <wd-picker
27
- v-else-if="field.frontInputType === 'selector'"
28
- :columns="getColumns(field.frontInputContent)"
29
- :label="field.fieldCustomName"
30
- v-model="form[field.field]"
31
- :required="field.requiredFlag"
32
- :prop="field.field"
33
- :rules="field.requiredFlag ? [{ required: true, message: t('内容不能为空') }] : []"
34
- v-bind="field.props"
35
- />
36
- <wd-datetime-picker
37
- v-else-if="field.frontInputType === 'date'"
38
- :label="field.fieldCustomName"
39
- v-model="form[field.field]"
40
- :required="field.requiredFlag"
41
- :prop="field.field"
42
- :type="getDateType(field.frontInputTypeValue)"
43
- :rules="field.requiredFlag ? [{ required: true, message: t('内容不能为空') }] : []"
44
- v-bind="{
45
- ...field.props,
46
- ...getDateOptions(field.frontInputContent),
47
- }"
48
- />
49
6
  <!-- radio -->
50
7
  <wd-cell
51
- v-else
52
8
  :title="field.fieldCustomName"
53
9
  :required="field.requiredFlag"
54
10
  :prop="field.field"
55
- title-width="230rpx"
11
+ :title-width="!vertical ? '230rpx' : '100%'"
12
+ :vertical="vertical"
56
13
  :rules="
57
14
  field.requiredFlag
58
15
  ? [
@@ -64,11 +21,40 @@
64
21
  : []
65
22
  "
66
23
  >
24
+ <wd-input
25
+ v-if="field.frontInputType === 'input'"
26
+ :placeholder="field.frontPlaceholder || t('请输入') + field.fieldCustomName"
27
+ v-model="form[field.field]"
28
+ v-bind="field.props"
29
+ no-border
30
+ />
31
+ <wd-textarea
32
+ v-else-if="field.frontInputType === 'inputArea'"
33
+ :placeholder="field.frontPlaceholder || t('请输入') + field.fieldCustomName"
34
+ v-model="form[field.field]"
35
+ v-bind="field.props"
36
+ />
37
+
38
+ <wd-picker
39
+ v-else-if="field.frontInputType === 'selector'"
40
+ :columns="getColumns(field.frontInputContent)"
41
+ v-model="form[field.field]"
42
+ v-bind="field.props"
43
+ />
44
+ <wd-datetime-picker
45
+ v-else-if="field.frontInputType === 'date'"
46
+ v-model="form[field.field]"
47
+ :type="getDateType(field.frontInputTypeValue)"
48
+ v-bind="{
49
+ ...field.props,
50
+ ...getDateOptions(field.frontInputContent),
51
+ }"
52
+ />
67
53
  <wd-radio-group
68
- v-if="field.frontInputType === 'radio'"
54
+ v-else-if="field.frontInputType === 'radio'"
69
55
  v-model="form[field.field]"
70
56
  v-bind="field.props"
71
- inline
57
+ :inline="!vertical"
72
58
  shape="dot"
73
59
  >
74
60
  <wd-radio
@@ -78,6 +64,17 @@
78
64
  >
79
65
  {{ item }}
80
66
  </wd-radio>
67
+ <template v-if="field.frontInputTypeValue === '1'">
68
+ <wd-radio :value="customField" key="custom">其他</wd-radio>
69
+ <view class="custom-input" v-if="form[field.field] === customField">
70
+ <wd-input
71
+ :placeholder="`请输入自定义内容`"
72
+ v-model="customInputs[field.field]"
73
+ size="small"
74
+ :no-border="true"
75
+ />
76
+ </view>
77
+ </template>
81
78
  </wd-radio-group>
82
79
  <wd-radio-group
83
80
  v-else-if="field.frontInputType === 'radioTag'"
@@ -92,6 +89,17 @@
92
89
  >
93
90
  {{ item }}
94
91
  </wd-radio>
92
+ <template v-if="field.frontInputTypeValue === '1'">
93
+ <wd-radio :value="customField" key="custom">其他</wd-radio>
94
+ <view class="custom-input" v-if="form[field.field] === customField">
95
+ <wd-input
96
+ :placeholder="`请输入自定义内容`"
97
+ v-model="customInputs[field.field]"
98
+ size="small"
99
+ :no-border="true"
100
+ />
101
+ </view>
102
+ </template>
95
103
  </wd-radio-group>
96
104
  <!-- checkbox -->
97
105
  <wd-checkbox-group
@@ -106,6 +114,17 @@
106
114
  >
107
115
  {{ item }}
108
116
  </wd-checkbox>
117
+ <template v-if="field.frontInputTypeValue === '1'">
118
+ <wd-checkbox :modelValue="customField" key="custom">其他</wd-checkbox>
119
+ <view class="custom-input" v-if="form[field.field]?.includes(customField)">
120
+ <wd-input
121
+ :placeholder="`请输入自定义内容`"
122
+ v-model="customInputs[field.field]"
123
+ size="small"
124
+ :no-border="true"
125
+ />
126
+ </view>
127
+ </template>
109
128
  </wd-checkbox-group>
110
129
  <!-- checkboxTag -->
111
130
  <wd-checkbox-group
@@ -121,6 +140,17 @@
121
140
  >
122
141
  {{ item }}
123
142
  </wd-checkbox>
143
+ <template v-if="field.frontInputTypeValue === '1'">
144
+ <wd-checkbox :modelValue="customField" key="custom">其他</wd-checkbox>
145
+ <view class="custom-input" v-if="form[field.field]?.includes(customField)">
146
+ <wd-input
147
+ :placeholder="`请输入自定义内容`"
148
+ v-model="customInputs[field.field]"
149
+ size="small"
150
+ :no-border="true"
151
+ />
152
+ </view>
153
+ </template>
124
154
  </wd-checkbox-group>
125
155
  <wd-upload
126
156
  v-else-if="field.frontInputType === 'img'"
@@ -191,23 +221,34 @@ const props = withDefaults(defineProps<LcbFormProps>(), {
191
221
  submitText: '提交',
192
222
  affirmText: '同意',
193
223
  bottomFixed: true,
224
+ vertical: false,
194
225
  })
195
226
  const fields = ref<LcbFormField[]>()
227
+ const customInputs = ref<Record<string, string>>({})
228
+ const customField = 'custom'
196
229
  watch(
197
230
  () => props.formType,
198
231
  async (newVal) => {
199
232
  if (newVal) {
200
233
  const {
201
- data: { entryFormFieldConfigList },
234
+ data: { entryFormFieldConfigList = [], extra = '{}' },
202
235
  } = await uni.$lcb.http.post<any>('/entryFormCustom/detail', {
203
236
  entryFormConfigId: newVal,
204
237
  })
238
+ const extraData = JSON.parse(extra)
239
+ customInputs.value = extraData
240
+
205
241
  entryFormFieldConfigList.forEach((item) => {
206
242
  if (item.value) {
207
243
  if (item.frontInputType === 'img') {
208
244
  imgList.value[item.field] = [{ url: item.value }]
209
245
  } else if (item.frontInputType === 'checkboxTag' || item.frontInputType === 'checkbox') {
210
- form.value[item.field] = JSON.parse(item.value)
246
+ const values = JSON.parse(item.value)
247
+ form.value[item.field] = values.map((val) =>
248
+ val === extraData[item.field] ? customField : val,
249
+ )
250
+ } else if (item.frontInputType === 'radioTag' || item.frontInputType === 'radio') {
251
+ form.value[item.field] = extraData[item.field] === item.value ? customField : item.value
211
252
  } else if (item.frontInputType === 'date') {
212
253
  switch (item.frontInputTypeValue) {
213
254
  case 'day':
@@ -244,7 +285,10 @@ const submit = () => {
244
285
  }
245
286
  formRef.value.validate().then(async ({ valid }) => {
246
287
  if (!valid) return
288
+
247
289
  if (props.submitUrl) {
290
+ // 用户自定义内容集合
291
+ const extra = {}
248
292
  const values = fields.value?.reduce((acc, cur) => {
249
293
  if (cur.frontInputType === 'date') {
250
294
  switch (cur.frontInputTypeValue) {
@@ -259,13 +303,34 @@ const submit = () => {
259
303
  break
260
304
  }
261
305
  } else {
262
- acc[cur.field] = form.value[cur.field]
306
+ const customValue = customInputs.value[cur.field] || ''
307
+ let fieldValue = form.value[cur.field]
308
+
309
+ // 处理自定义输入值
310
+ if (['radio', 'radioTag'].includes(cur.frontInputType) && fieldValue === customField) {
311
+ fieldValue = customValue
312
+ extra[cur.field] = customValue
313
+ } else if (
314
+ ['checkbox', 'checkboxTag'].includes(cur.frontInputType) &&
315
+ Array.isArray(fieldValue)
316
+ ) {
317
+ const haveCustom = fieldValue.includes(customField)
318
+ if (haveCustom) {
319
+ extra[cur.field] = customValue
320
+ }
321
+ fieldValue = [...fieldValue, haveCustom ? customValue : '']
322
+ .map((val) => (val === customField ? '' : val))
323
+ .filter((val) => val !== '')
324
+ }
325
+
326
+ acc[cur.field] = fieldValue
263
327
  }
264
328
  return acc
265
329
  }, {})
266
330
  await uni.$lcb.http.post(props.submitUrl, {
267
331
  entryFormConfigId: props.formType,
268
332
  allField: JSON.stringify(values),
333
+ extra: JSON.stringify(extra),
269
334
  })
270
335
  }
271
336
  })
@@ -308,6 +373,7 @@ watch(
308
373
  display: flex;
309
374
  flex-wrap: wrap;
310
375
  gap: 8rpx;
376
+ // flex-direction: column;
311
377
  }
312
378
  :deep(.wd-checkbox) {
313
379
  line-height: inherit !important;
@@ -319,8 +385,40 @@ watch(
319
385
  display: flex;
320
386
  flex-wrap: wrap;
321
387
  gap: 8rpx;
388
+ // flex-direction: column;
389
+ }
390
+ :deep(.wd-picker) {
391
+ .wd-picker__cell {
392
+ padding: 0;
393
+ &:after {
394
+ display: none !important;
395
+ }
396
+ }
397
+ }
398
+ :deep(.wd-textarea) {
399
+ padding: 0;
400
+ }
401
+ }
402
+
403
+ .vertical {
404
+ :deep(.wd-radio-group) {
405
+ flex-direction: column !important;
406
+ }
407
+ :deep(.wd-checkbox-group) {
408
+ flex-direction: column !important;
409
+ .is-button-box {
410
+ width: 100%;
411
+ box-sizing: border-box;
412
+ }
413
+ .wd-checkbox__txt {
414
+ white-space: break-spaces;
415
+ }
416
+ .wd-checkbox__label {
417
+ height: auto !important;
418
+ }
322
419
  }
323
420
  }
421
+
324
422
  .bottom-fixed {
325
423
  position: fixed;
326
424
  bottom: 0;
@@ -330,4 +428,12 @@ watch(
330
428
  z-index: 5;
331
429
  box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
332
430
  }
431
+ .custom-input {
432
+ margin-top: 8rpx;
433
+ width: 100%;
434
+ border: 1rpx solid #e5e5e5;
435
+ border-radius: 4rpx;
436
+ padding: 8rpx;
437
+ box-sizing: border-box;
438
+ }
333
439
  </style>
@@ -80,4 +80,5 @@ export interface LcbFormProps extends LcbBlockProps {
80
80
  affirmText?: string
81
81
  // 底部悬浮
82
82
  bottomFixed?: boolean
83
+ vertical?: boolean
83
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tplc/business",
3
- "version": "0.4.145",
3
+ "version": "0.4.146",
4
4
  "keywords": [
5
5
  "业务组件"
6
6
  ],
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "peerDependencies": {
13
13
  "vue": ">=3.2.47",
14
- "@tplc/wot": "0.1.87"
14
+ "@tplc/wot": "0.1.88"
15
15
  },
16
16
  "engines": {
17
17
  "node": ">=18",
@@ -6,6 +6,7 @@ declare const _default: import('vue').DefineComponent<
6
6
  submitText: string
7
7
  affirmText: string
8
8
  bottomFixed: boolean
9
+ vertical: boolean
9
10
  }
10
11
  >,
11
12
  {},
@@ -25,11 +26,13 @@ declare const _default: import('vue').DefineComponent<
25
26
  submitText: string
26
27
  affirmText: string
27
28
  bottomFixed: boolean
29
+ vertical: boolean
28
30
  }
29
31
  >
30
32
  >
31
33
  >,
32
34
  {
35
+ vertical: boolean
33
36
  submitText: string
34
37
  affirmText: string
35
38
  bottomFixed: boolean
@@ -78,4 +78,5 @@ export interface LcbFormProps extends LcbBlockProps {
78
78
  agreementType?: string
79
79
  affirmText?: string
80
80
  bottomFixed?: boolean
81
+ vertical?: boolean
81
82
  }