verce-vue-test 0.0.121 → 0.0.122

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.
@@ -12823,7 +12823,7 @@ POST /TAM/0001/140000001
12823
12823
  > 200 Response
12824
12824
 
12825
12825
  ```
12826
- {"body":{"resultList":[{"custBelongOrg":"string","custCnName":"string","custNum":"string","custSts":"string","orgCode":"string"}]},"head":{"adminUserId":"string","agentBranchId":"string","apprUserId":"string","areaCode":"string","batch":true,"branchId":"string","consumerId":"string","consumerSeqNo":"string","ctrlBits":"string","digitalSign":"string","extra":{},"fileFlag":"string","filePath":"string","isBatch":true,"msgId":"string","origSender":"string","pageIndex":"string","pageSize":"string","retCode":"string","retMsg":"string","retMsg2":"string","retStatus":"string","spanId":"string","traceId":"string","tranCode":"string","tranDate":"string","tranTimestamp":"string","userId":"string","verifyUserId":"string","versionId":"string"}}
12826
+ {"body":{"resultList":[{"custCnName":"string","custNum":"string"}]},"head":{"adminUserId":"string","agentBranchId":"string","apprUserId":"string","areaCode":"string","batch":true,"branchId":"string","consumerId":"string","consumerSeqNo":"string","ctrlBits":"string","digitalSign":"string","extra":{},"fileFlag":"string","filePath":"string","isBatch":true,"msgId":"string","origSender":"string","pageIndex":"string","pageSize":"string","retCode":"string","retMsg":"string","retMsg2":"string","retStatus":"string","spanId":"string","traceId":"string","tranCode":"string","tranDate":"string","tranTimestamp":"string","userId":"string","verifyUserId":"string","versionId":"string"}}
12827
12827
  ```
12828
12828
 
12829
12829
  ### 返回结果
@@ -30365,11 +30365,8 @@ Tam140000001In.Body
30365
30365
  "body": {
30366
30366
  "resultList": [
30367
30367
  {
30368
- "custBelongOrg": "string",
30369
30368
  "custCnName": "string",
30370
- "custNum": "string",
30371
- "custSts": "string",
30372
- "orgCode": "string"
30369
+ "custNum": "string"
30373
30370
  }
30374
30371
  ]
30375
30372
  },
@@ -30429,11 +30426,8 @@ Tam140000001Out
30429
30426
  {
30430
30427
  "resultList": [
30431
30428
  {
30432
- "custBelongOrg": "string",
30433
30429
  "custCnName": "string",
30434
- "custNum": "string",
30435
- "custSts": "string",
30436
- "orgCode": "string"
30430
+ "custNum": "string"
30437
30431
  }
30438
30432
  ]
30439
30433
  }
@@ -30457,11 +30451,8 @@ Tam140000001Out.Body
30457
30451
 
30458
30452
  ```json
30459
30453
  {
30460
- "custBelongOrg": "string",
30461
30454
  "custCnName": "string",
30462
- "custNum": "string",
30463
- "custSts": "string",
30464
- "orgCode": "string"
30455
+ "custNum": "string"
30465
30456
  }
30466
30457
 
30467
30458
  ```
@@ -30472,11 +30463,8 @@ Tam140000001Out.Body.Result
30472
30463
 
30473
30464
  |名称|类型|必选|约束|中文名|说明|
30474
30465
  |---|---|---|---|---|---|
30475
- |custBelongOrg|string|false|none||客户归属网点|
30476
30466
  |custCnName|string|false|none||客户名称(中文全称)|
30477
30467
  |custNum|string|false|none||客户编号|
30478
- |custSts|string|false|none||客户状态|
30479
- |orgCode|string|false|none||组织机构代码|
30480
30468
 
30481
30469
  <h2 id="tocS_Tam140000002In">Tam140000002In</h2>
30482
30470
 
package/env.d.ts CHANGED
@@ -5,7 +5,11 @@ declare global {
5
5
  readonly VITE_API_BASE_URL?: string
6
6
  readonly VITE_SYSTEM_WORK_DATE?: string
7
7
  readonly VITE_TAM_BRANCH_ID?: string
8
+ readonly VITE_TAM_BRANCH_NAME?: string
8
9
  readonly VITE_TAM_USER_ID?: string
10
+ readonly VITE_TAM_USER_NAME?: string
11
+ readonly VITE_TAM_USER_PHONE?: string
12
+ readonly VITE_TAM_USER_ROLES?: string
9
13
  readonly VITE_TAM_CLIENT_IP?: string
10
14
  }
11
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verce-vue-test",
3
- "version": "0.0.121",
3
+ "version": "0.0.122",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -0,0 +1,290 @@
1
+ <script setup lang="ts">
2
+ import { computed, nextTick, onBeforeUnmount, ref } from 'vue'
3
+ import { Search } from '@element-plus/icons-vue'
4
+ import baseHttpClient from '@/utils/baseHttpClient'
5
+
6
+ /** 对公客户名称模糊查询交易码。 */
7
+ const CORPORATE_CUSTOMER_SEARCH_TRAN_CODE = '/TAM/0001/140000001'
8
+
9
+ /** 组件对外统一使用的客户数据结构。 */
10
+ type CorporateCustomer = {
11
+ /** 客户编号,对应接口返回的 custNum。 */
12
+ customerNumber: string
13
+ /** 客户中文名称,对应接口返回的 custCnName。 */
14
+ customerName: string
15
+ }
16
+
17
+ /** 对公客户查询参数,分页信息用于生成 TAM 请求头。 */
18
+ type CorporateCustomerSearchParams = {
19
+ custCnName: string
20
+ pageIndex: number
21
+ pageSize: number
22
+ }
23
+
24
+ /**
25
+ * 按客户中文名称查询对公客户。
26
+ * 请求公共头由 baseHttpClient 自动补齐,分页参数写入 TAM head。
27
+ */
28
+ async function searchCorporateCustomers(params: CorporateCustomerSearchParams) {
29
+ const custCnName = params.custCnName.trim()
30
+ if (!custCnName) throw new Error('客户名称不能为空')
31
+
32
+ const response = await baseHttpClient.post<any>(
33
+ CORPORATE_CUSTOMER_SEARCH_TRAN_CODE,
34
+ { custCnName },
35
+ {
36
+ tamHead: {
37
+ pageIndex: params.pageIndex,
38
+ pageSize: params.pageSize,
39
+ },
40
+ },
41
+ )
42
+
43
+ const resultList = Array.isArray(response.body.resultList)
44
+ ? response.body.resultList
45
+ : []
46
+
47
+ return resultList
48
+ .map((row: any): CorporateCustomer => ({
49
+ customerNumber: String(row.custNum ?? '').trim(),
50
+ customerName: String(row.custCnName ?? '').trim(),
51
+ }))
52
+ .filter((row:any) => row.customerNumber && row.customerName)
53
+ }
54
+
55
+ const props = withDefaults(
56
+ defineProps<{
57
+ modelValue?: string
58
+ customerNumber?: string
59
+ disabled?: boolean
60
+ placeholder?: string
61
+ dialogTitle?: string
62
+ }>(),
63
+ {
64
+ modelValue: '',
65
+ customerNumber: '',
66
+ disabled: false,
67
+ placeholder: '点击选择对公客户',
68
+ dialogTitle: '选择对公客户',
69
+ },
70
+ )
71
+
72
+ const emit = defineEmits<{
73
+ 'update:modelValue': [value: string]
74
+ 'update:customerNumber': [value: string]
75
+ select: [customer: CorporateCustomer]
76
+ }>()
77
+
78
+ const dialogVisible = ref(false)
79
+ const searchKeyword = ref('')
80
+ const searchLoading = ref(false)
81
+ const hasSearched = ref(false)
82
+ const searchError = ref('')
83
+ const customerOptions = ref<CorporateCustomer[]>([])
84
+ const searchInputRef = ref<{ focus: () => void }>()
85
+ /** 用于忽略已被后续搜索覆盖的过期响应。 */
86
+ let searchRequestId = 0
87
+
88
+ const emptyDescription = computed(() => {
89
+ if (!hasSearched.value) return '请输入客户名称后查询'
90
+ return '未查询到匹配的对公客户'
91
+ })
92
+
93
+ function resetSearchState() {
94
+ // 关闭弹窗或重新打开时让旧请求失效,避免旧结果污染新一轮搜索。
95
+ searchRequestId += 1
96
+ searchLoading.value = false
97
+ hasSearched.value = false
98
+ searchError.value = ''
99
+ customerOptions.value = []
100
+ }
101
+
102
+ function openDialog() {
103
+ if (props.disabled) return
104
+ resetSearchState()
105
+ searchKeyword.value = props.modelValue.trim()
106
+ dialogVisible.value = true
107
+ nextTick(() => searchInputRef.value?.focus())
108
+ }
109
+
110
+ function closeDialog() {
111
+ dialogVisible.value = false
112
+ }
113
+
114
+ async function handleSearch() {
115
+ const keyword = searchKeyword.value.trim()
116
+ if (!keyword) {
117
+ searchError.value = '请输入客户名称'
118
+ customerOptions.value = []
119
+ hasSearched.value = false
120
+ return
121
+ }
122
+
123
+ const requestId = ++searchRequestId
124
+ searchLoading.value = true
125
+ hasSearched.value = true
126
+ searchError.value = ''
127
+ customerOptions.value = []
128
+
129
+ try {
130
+ const options = await searchCorporateCustomers({
131
+ custCnName: keyword,
132
+ pageIndex: 1,
133
+ pageSize: 10,
134
+ })
135
+ // 只有当前最后一次请求可以更新列表。
136
+ if (searchRequestId !== requestId) return
137
+
138
+ customerOptions.value = options
139
+ } catch (error) {
140
+ if (searchRequestId !== requestId) return
141
+ searchError.value = error instanceof Error ? error.message : '客户名称查询失败'
142
+ } finally {
143
+ if (searchRequestId === requestId) searchLoading.value = false
144
+ }
145
+ }
146
+
147
+ function selectCustomer(customer: CorporateCustomer) {
148
+ emit('update:modelValue', customer.customerName)
149
+ emit('update:customerNumber', customer.customerNumber)
150
+ emit('select', customer)
151
+ dialogVisible.value = false
152
+ }
153
+
154
+ function handleDialogClosed() {
155
+ resetSearchState()
156
+ }
157
+
158
+ onBeforeUnmount(() => {
159
+ searchRequestId += 1
160
+ })
161
+ </script>
162
+
163
+ <template>
164
+ <div
165
+ class="corporate-customer-select"
166
+ :class="{ 'is-disabled': disabled }"
167
+ :tabindex="disabled ? -1 : 0"
168
+ role="button"
169
+ :aria-disabled="disabled"
170
+ :aria-label="modelValue ? `已选择对公客户:${modelValue}` : placeholder"
171
+ @click="openDialog"
172
+ @keydown.enter.prevent="openDialog"
173
+ @keydown.space.prevent="openDialog"
174
+ >
175
+ <el-input
176
+ :model-value="modelValue"
177
+ :placeholder="placeholder"
178
+ :disabled="disabled"
179
+ :suffix-icon="Search"
180
+ readonly
181
+ tabindex="-1"
182
+ />
183
+ </div>
184
+
185
+ <el-dialog
186
+ v-model="dialogVisible"
187
+ :title="dialogTitle"
188
+ width="min(680px, calc(100vw - 32px))"
189
+ append-to-body
190
+ destroy-on-close
191
+ class="corporate-customer-dialog"
192
+ @closed="handleDialogClosed"
193
+ >
194
+ <div class="customer-search-bar">
195
+ <el-input
196
+ ref="searchInputRef"
197
+ v-model="searchKeyword"
198
+ maxlength="80"
199
+ clearable
200
+ placeholder="请输入客户名称"
201
+ @input="resetSearchState"
202
+ @keyup.enter="handleSearch"
203
+ />
204
+ <el-button type="primary" :icon="Search" :loading="searchLoading" @click="handleSearch">
205
+ 搜索
206
+ </el-button>
207
+ </div>
208
+
209
+ <el-alert
210
+ v-if="searchError"
211
+ class="customer-search-error"
212
+ :title="searchError"
213
+ type="error"
214
+ :closable="false"
215
+ show-icon
216
+ />
217
+
218
+ <el-table
219
+ v-loading="searchLoading"
220
+ :data="customerOptions"
221
+ border
222
+ stripe
223
+ max-height="360"
224
+ class="customer-result-table"
225
+ >
226
+ <el-table-column prop="customerName" label="客户名称" min-width="360" show-overflow-tooltip />
227
+ <el-table-column prop="customerNumber" label="客户编号" width="180" show-overflow-tooltip />
228
+ <el-table-column label="操作" width="78" fixed="right" align="center">
229
+ <template #default="{ row }">
230
+ <el-button link type="primary" size="small" @click="selectCustomer(row)">选择</el-button>
231
+ </template>
232
+ </el-table-column>
233
+
234
+ <template #empty>
235
+ <el-empty :description="emptyDescription" :image-size="72" />
236
+ </template>
237
+ </el-table>
238
+
239
+ <template #footer>
240
+ <el-button @click="closeDialog">关闭</el-button>
241
+ </template>
242
+ </el-dialog>
243
+ </template>
244
+
245
+ <style scoped>
246
+ .corporate-customer-select {
247
+ width: 100%;
248
+ cursor: pointer;
249
+ outline: none;
250
+ }
251
+
252
+ .corporate-customer-select :deep(.el-input__wrapper) {
253
+ cursor: pointer;
254
+ }
255
+
256
+ .corporate-customer-select :deep(.el-input__inner) {
257
+ cursor: pointer;
258
+ }
259
+
260
+ .corporate-customer-select:focus-visible :deep(.el-input__wrapper) {
261
+ box-shadow: 0 0 0 1px var(--el-color-primary) inset;
262
+ }
263
+
264
+ .corporate-customer-select.is-disabled,
265
+ .corporate-customer-select.is-disabled :deep(.el-input__wrapper),
266
+ .corporate-customer-select.is-disabled :deep(.el-input__inner) {
267
+ cursor: not-allowed;
268
+ }
269
+
270
+ .customer-search-bar {
271
+ display: grid;
272
+ grid-template-columns: minmax(0, 1fr) auto;
273
+ gap: 12px;
274
+ margin-bottom: 16px;
275
+ }
276
+
277
+ .customer-search-error {
278
+ margin-bottom: 12px;
279
+ }
280
+
281
+ .customer-result-table {
282
+ width: 100%;
283
+ }
284
+
285
+ @media (max-width: 720px) {
286
+ .customer-search-bar {
287
+ grid-template-columns: 1fr;
288
+ }
289
+ }
290
+ </style>
@@ -8,6 +8,7 @@ const props = withDefaults(
8
8
  modelValue?: number | string
9
9
  placeholder?: string
10
10
  disabled?: boolean
11
+ decimalPlaces?: number
11
12
  }>(),
12
13
  {
13
14
  modelValue: undefined,
@@ -24,11 +25,18 @@ const isFocused = ref(false)
24
25
  const displayValue = ref('')
25
26
  const inputRef = ref<InstanceType<typeof import('element-plus')['ElInput']>>()
26
27
 
28
+ function resolveDecimalPlaces(fallback?: number) {
29
+ return typeof props.decimalPlaces === 'number' && Number.isInteger(props.decimalPlaces)
30
+ ? Math.min(20, Math.max(0, props.decimalPlaces))
31
+ : fallback
32
+ }
33
+
27
34
  function formatThousandth(val: string | number | undefined): string {
28
35
  if (val === undefined || val === null || val === '') return ''
29
- const str = String(val)
30
- const num = Number(str)
36
+ const num = Number(val)
31
37
  if (isNaN(num)) return ''
38
+ const decimalPlaces = resolveDecimalPlaces()
39
+ const str = decimalPlaces === undefined ? String(val) : num.toFixed(decimalPlaces)
32
40
  const [integerPart = '', decimalPart] = str.split('.')
33
41
  const intPart = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
34
42
  if (decimalPart !== undefined) {
@@ -45,8 +53,9 @@ function stripNonNumeric(val: string): string {
45
53
  }
46
54
  if (dotIndex !== -1) {
47
55
  const [integerPart = '', decimalPart = ''] = result.split('.')
48
- if (decimalPart.length > 2) {
49
- result = integerPart + '.' + decimalPart.slice(0, 2)
56
+ const maxDecimalPlaces = resolveDecimalPlaces(2) ?? 2
57
+ if (decimalPart.length > maxDecimalPlaces) {
58
+ result = integerPart + '.' + decimalPart.slice(0, maxDecimalPlaces)
50
59
  }
51
60
  }
52
61
  return result
@@ -1,5 +1,6 @@
1
1
  import type { App, Component } from 'vue'
2
2
 
3
+ import CorporateCustomerSelect from './business/Public/CorporateCustomerSelect.vue'
3
4
  import BusinessType from './business/Public/BusinessType.vue'
4
5
  import TokenTag from './business/Public/TokenTag.vue'
5
6
  import DateRange from './element-rewrite/DateRange.vue'
@@ -21,6 +22,13 @@ type GlobalComponentDefinition = {
21
22
  }
22
23
 
23
24
  const globalComponentDefinitions: GlobalComponentDefinition[] = [
25
+ {
26
+ name: 'CorporateCustomerSelect',
27
+ component: CorporateCustomerSelect,
28
+ category: '表单组件',
29
+ description: '通过 TAM 140000001 查询并选择对公客户,回填客户名称和客户编号。',
30
+ filePath: 'src/components/business/Public/CorporateCustomerSelect.vue',
31
+ },
24
32
  {
25
33
  name: 'BusinessType',
26
34
  component: BusinessType,