af-mobile-client-vue3 1.4.27 → 1.4.29

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.
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
- import { Icon as VanIcon } from 'vant'
2
+ import { Field as VanField, Icon as VanIcon } from 'vant'
3
+ import { computed, ref, watch } from 'vue'
3
4
 
4
5
  interface ChargeItem {
5
6
  id: number
@@ -7,24 +8,101 @@ interface ChargeItem {
7
8
  workOrderId?: string
8
9
  type: string
9
10
  item: string
11
+ model?: string
10
12
  unitPrice: number
11
13
  quantity: number
12
14
  total: string
13
15
  }
14
16
 
15
- defineProps<{
17
+ const props = defineProps<{
16
18
  item: ChargeItem
17
19
  index: number
18
20
  isWorkOrder?: boolean
19
21
  workOrderData?: any
20
22
  }>()
21
23
 
22
- defineEmits<{
24
+ const emit = defineEmits<{
23
25
  (e: 'remove', id: number): void
26
+ (e: 'update', item: ChargeItem): void
24
27
  }>()
25
28
 
26
- function formatPrice(price: number): string {
27
- return price.toFixed(2)
29
+ // 本地状态,用于双向绑定
30
+ const localUnitPrice = ref(props.item.unitPrice.toString())
31
+ const localQuantity = ref(props.item.quantity.toString())
32
+ const item = computed(() => props.item)
33
+
34
+ // 监听 props 变化,同步本地状态
35
+ watch(() => props.item.unitPrice, (newVal) => {
36
+ localUnitPrice.value = newVal.toString()
37
+ })
38
+
39
+ watch(() => props.item.quantity, (newVal) => {
40
+ localQuantity.value = newVal.toString()
41
+ })
42
+
43
+ // 计算小计
44
+ const total = computed(() => {
45
+ const price = Number.parseFloat(localUnitPrice.value) || 0
46
+ const qty = Number.parseInt(localQuantity.value) || 0
47
+ return (price * qty).toFixed(2)
48
+ })
49
+
50
+ // 处理单价变化 - 限制9位整数2位小数
51
+ function handleUnitPriceChange(value: string) {
52
+ // 移除非数字和小数点的字符
53
+ let cleaned = value.replace(/[^\d.]/g, '')
54
+
55
+ // 限制小数点后最多2位
56
+ const parts = cleaned.split('.')
57
+ if (parts.length > 2) {
58
+ cleaned = `${parts[0]}.${parts.slice(1).join('')}`
59
+ }
60
+ if (parts[1] && parts[1].length > 2) {
61
+ cleaned = `${parts[0]}.${parts[1].slice(0, 2)}`
62
+ }
63
+
64
+ // 限制整数部分最多9位
65
+ if (parts[0] && parts[0].length > 9) {
66
+ cleaned = parts[0].slice(0, 9) + (parts[1] ? `.${parts[1]}` : '')
67
+ }
68
+
69
+ // 更新值
70
+ localUnitPrice.value = cleaned
71
+ updateItem()
72
+ }
73
+
74
+ // 处理数量变化 - 限制5位整数
75
+ function handleQuantityChange(value: string) {
76
+ // 只允许数字,限制最多5位
77
+ let cleaned = value.replace(/\D/g, '')
78
+ if (cleaned.length > 5) {
79
+ cleaned = cleaned.slice(0, 5)
80
+ }
81
+
82
+ // 更新值
83
+ localQuantity.value = cleaned
84
+ updateItem()
85
+ }
86
+
87
+ // 更新费用项
88
+ function updateItem() {
89
+ const price = Number.parseFloat(localUnitPrice.value) || 0
90
+ const qty = Number.parseInt(localQuantity.value) || 0
91
+
92
+ // 只有当价格和数量都大于0时才更新
93
+ if (price > 0 && qty > 0) {
94
+ const updatedItem: ChargeItem = {
95
+ ...props.item,
96
+ unitPrice: price,
97
+ quantity: qty,
98
+ total: total.value,
99
+ }
100
+ emit('update', updatedItem)
101
+ }
102
+ else if (localUnitPrice.value === '' || localQuantity.value === '') {
103
+ // 如果输入为空,不更新,保持原值
104
+
105
+ }
28
106
  }
29
107
  </script>
30
108
 
@@ -50,6 +128,14 @@ function formatPrice(price: number): string {
50
128
  {{ item.workOrderCode }}
51
129
  </p>
52
130
  </div>
131
+ <div class="other-charge-item__field">
132
+ <p class="other-charge-item__label">
133
+ 小计
134
+ </p>
135
+ <p class="other-charge-item__value--info">
136
+ ¥{{ total }}
137
+ </p>
138
+ </div>
53
139
  <div class="other-charge-item__field">
54
140
  <p class="other-charge-item__label">
55
141
  收费类型
@@ -73,25 +159,27 @@ function formatPrice(price: number): string {
73
159
  <p class="other-charge-item__label">
74
160
  单价
75
161
  </p>
76
- <p class="other-charge-item__value">
77
- ¥{{ formatPrice(item.unitPrice) }}
78
- </p>
162
+ <VanField
163
+ :model-value="localUnitPrice"
164
+ type="number"
165
+ placeholder="限制9位整数2位小数"
166
+ @update:model-value="handleUnitPriceChange"
167
+ >
168
+ <template #prefix>
169
+ <span class="other-charge-item__prefix">¥</span>
170
+ </template>
171
+ </VanField>
79
172
  </div>
80
173
  <div class="other-charge-item__field">
81
174
  <p class="other-charge-item__label">
82
175
  数量
83
176
  </p>
84
- <p class="other-charge-item__value">
85
- {{ item.quantity }}
86
- </p>
87
- </div>
88
- <div class="other-charge-item__field">
89
- <p class="other-charge-item__label">
90
- 小计
91
- </p>
92
- <p class="other-charge-item__value--highlight">
93
- ¥{{ item.total }}
94
- </p>
177
+ <VanField
178
+ :model-value="localQuantity"
179
+ type="number"
180
+ placeholder="限制5位整数"
181
+ @update:model-value="handleQuantityChange"
182
+ />
95
183
  </div>
96
184
  </div>
97
185
  </div>
@@ -108,8 +196,9 @@ function formatPrice(price: number): string {
108
196
  &__header {
109
197
  display: flex;
110
198
  justify-content: space-between;
111
- align-items: flex-start;
199
+ align-items: center;
112
200
  margin-bottom: 8px;
201
+ gap: 8px;
113
202
  }
114
203
 
115
204
  &__title {
@@ -117,17 +206,40 @@ function formatPrice(price: number): string {
117
206
  font-weight: 500;
118
207
  color: #374151;
119
208
  margin: 0;
209
+ flex-shrink: 0;
210
+ }
211
+ &__value--info {
212
+ font-size: 14px;
213
+ font-weight: 500;
214
+ color: #2563eb;
120
215
  }
121
-
122
216
  &__delete {
123
217
  color: #ef4444;
124
218
  font-size: 16px;
219
+ flex-shrink: 0;
220
+ cursor: pointer;
125
221
 
126
222
  &:active {
127
223
  color: #b91c1c;
128
224
  }
129
225
  }
130
226
 
227
+ :deep(.van-field) {
228
+ background-color: #ffffff;
229
+ border-radius: 4px;
230
+ padding: 8px 12px;
231
+ }
232
+
233
+ :deep(.van-field__control) {
234
+ background-color: #ffffff;
235
+ color: #1f2937;
236
+ font-size: 14px;
237
+ }
238
+
239
+ :deep(.van-field__label) {
240
+ display: none;
241
+ }
242
+
131
243
  &__info {
132
244
  display: grid;
133
245
  grid-template-columns: 1fr 1fr;
@@ -137,18 +249,14 @@ function formatPrice(price: number): string {
137
249
 
138
250
  &__details {
139
251
  display: grid;
140
- grid-template-columns: 1fr 1fr 1fr;
252
+ grid-template-columns: 1fr 1fr;
141
253
  gap: 12px;
142
254
  }
143
255
 
144
- &__field {
145
- margin-bottom: 0;
146
- }
147
-
148
256
  &__label {
149
257
  font-size: 12px;
150
258
  color: #6b7280;
151
- margin: 0 0 2px 0;
259
+ margin: 0 0 4px 0;
152
260
  }
153
261
 
154
262
  &__value {
@@ -156,13 +264,12 @@ function formatPrice(price: number): string {
156
264
  font-weight: 500;
157
265
  color: #1f2937;
158
266
  margin: 0;
267
+ }
159
268
 
160
- &--highlight {
161
- font-size: 14px;
162
- font-weight: 500;
163
- color: #2563eb;
164
- margin: 0;
165
- }
269
+ &__prefix {
270
+ color: #6b7280;
271
+ font-size: 14px;
272
+ margin-right: 4px;
166
273
  }
167
274
  }
168
275
  </style>
@@ -188,4 +188,4 @@ export interface PolygonLayerConfig {
188
188
  onClick?: (polygon: PolygonData, event: any) => void
189
189
  /** 多边形数据提供者 */
190
190
  dataProvider?: () => PolygonData[] | Promise<PolygonData[]>
191
- }
191
+ }
@@ -13,83 +13,7 @@ const router = useRouter()
13
13
 
14
14
  // 简易crud表单测试
15
15
  const configName = ref('ceshiCRUD')
16
- const serviceName = ref('af-safecheck')
17
-
18
- // 资源权限测试
19
- // const configName = ref('crud_sources_test')
20
- // const serviceName = ref('af-system')
21
-
22
- // 实际业务测试
23
- // const configName = ref('lngChargeAuditMobileCRUD')
24
- // const serviceName = ref('af-gaslink')
25
-
26
- // 跳转到详情页面
27
- // function toDetail(item) {
28
- // router.push({
29
- // name: 'XCellDetailView',
30
- // params: { id: item[idKey.value] }, // 如果使用命名路由,推荐使用路由参数而不是直接构建 URL
31
- // query: {
32
- // operName: item[operNameKey.value],
33
- // method:item[methodKey.value],
34
- // requestMethod:item[requestMethodKey.value],
35
- // operatorType:item[operatorTypeKey.value],
36
- // operUrl:item[operUrlKey.value],
37
- // operIp:item[operIpKey.value],
38
- // costTime:item[costTimeKey.value],
39
- // operTime:item[operTimeKey.value],
40
- //
41
- // title: item[titleKey.value],
42
- // businessType: item[businessTypeKey.value],
43
- // status:item[statusKey.value]
44
- // }
45
- // })
46
- // }
47
-
48
- // 跳转到表单——以表单组来渲染纯表单
49
- // function toDetail(item) {
50
- // router.push({
51
- // name: 'XFormGroupView',
52
- // query: {
53
- // id: item[idKey.value],
54
- // // id: item.rr_id,
55
- // // o_id: item.o_id,
56
- // },
57
- // })
58
- // }
59
-
60
- // 新增功能
61
- // function addOption(totalCount) {
62
- // router.push({
63
- // name: 'XFormView',
64
- // params: { id: totalCount, openid: totalCount },
65
- // query: {
66
- // configName: configName.value,
67
- // serviceName: serviceName.value,
68
- // mode: '新增',
69
- // },
70
- // })
71
- // }
72
-
73
- // 修改功能
74
- // function updateRow(result) {
75
- // router.push({
76
- // name: 'XFormView',
77
- // params: { id: result.o_id, openid: result.o_id },
78
- // query: {
79
- // configName: configName.value,
80
- // serviceName: serviceName.value,
81
- // mode: '修改',
82
- // },
83
- // })
84
- // }
85
-
86
- // 删除功能
87
- // function deleteRow(result) {
88
- // emit('deleteRow', result.o_id)
89
- // }
90
- // const fixQueryForm = ref({
91
- // f_operator_id: '487184754014158848',
92
- // })
16
+ const serviceName = ref('af-linepatrol')
93
17
  </script>
94
18
 
95
19
  <template>
@@ -97,7 +21,6 @@ const serviceName = ref('af-safecheck')
97
21
  <template #layout_content>
98
22
  <XCellList
99
23
  :config-name="configName"
100
- :service-name="serviceName"
101
24
  />
102
25
  </template>
103
26
  </NormalDataLayout>
@@ -28,7 +28,6 @@ function onSubmit(data: any) {
28
28
  ref="formGroupAddConstruction"
29
29
  mode="修改"
30
30
  :config-name="configName"
31
- :service-name="serviceName"
32
31
  :form-data="formData"
33
32
  @on-submit="onSubmit"
34
33
  />
@@ -1,118 +1,118 @@
1
- <script setup lang="ts">
2
- import type { LocationResult } from '@af-mobile-client-vue3/components/data/XOlMap/types'
3
- import LocationPicker from '@af-mobile-client-vue3/components/data/XOlMap/XLocationPicker/index.vue'
4
- import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
5
- import { showNotify } from 'vant'
6
- import { ref } from 'vue'
7
-
8
- const selectedLocation = ref<LocationResult>()
9
-
10
- // 处理位置选择
11
- function handleLocationConfirm(location: LocationResult) {
12
- // console.log('选择的位置:', location)
13
- // selectedLocation.value = location
14
- showNotify({ type: 'success', message: '位置已选择' })
15
- }
16
- </script>
17
-
18
- <template>
19
- <NormalDataLayout id="XLocationPicker" title="XOlMap地址选择器">
20
- <template #layout_content>
21
- <div class="location-picker-demo">
22
- <!-- 页面标题 -->
23
- <div class="page-header">
24
- <div class="title">
25
- 位置选择
26
- </div>
27
- </div>
28
-
29
- <!-- 选择结果展示 -->
30
- <div v-if="selectedLocation" class="location-result">
31
- <div class="label">
32
- 已选位置:
33
- </div>
34
- <div class="value">
35
- {{ selectedLocation.address }}
36
- </div>
37
- <div class="coordinates">
38
- 经度: {{ selectedLocation.longitude.toFixed(6) }},
39
- 纬度: {{ selectedLocation.latitude.toFixed(6) }}
40
- </div>
41
- </div>
42
-
43
- <!-- 地图组件 -->
44
- <div class="map-container">
45
- <LocationPicker
46
- v-model="selectedLocation"
47
- :default-center="[108.948024, 34.263161]"
48
- :default-zoom="12"
49
- @confirm="handleLocationConfirm"
50
- />
51
- </div>
52
- </div>
53
- </template>
54
- </NormalDataLayout>
55
- </template>
56
-
57
- <style scoped lang="less">
58
- .location-picker-demo {
59
- width: 100%;
60
- height: 100%;
61
- position: relative;
62
- display: flex;
63
- flex-direction: column;
64
- background-color: #f7f8fa;
65
- }
66
-
67
- .page-header {
68
- height: 44px;
69
- display: flex;
70
- align-items: center;
71
- justify-content: center;
72
- background: white;
73
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
74
- position: relative;
75
- z-index: 1;
76
-
77
- .title {
78
- font-size: 16px;
79
- color: #333;
80
- font-weight: 500;
81
- }
82
- }
83
-
84
- .location-result {
85
- background: white;
86
- padding: 12px 16px;
87
- margin: 10px;
88
- border-radius: 8px;
89
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
90
-
91
- .label {
92
- font-size: 14px;
93
- color: #666;
94
- margin-bottom: 4px;
95
- }
96
-
97
- .value {
98
- font-size: 16px;
99
- color: #333;
100
- margin-bottom: 8px;
101
- word-break: break-all;
102
- }
103
-
104
- .coordinates {
105
- font-size: 12px;
106
- color: #999;
107
- }
108
- }
109
-
110
- .map-container {
111
- flex: 1;
112
- position: relative;
113
- margin: 0 10px 10px 10px;
114
- border-radius: 8px;
115
- overflow: hidden;
116
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
117
- }
118
- </style>
1
+ <script setup lang="ts">
2
+ import type { LocationResult } from '@af-mobile-client-vue3/components/data/XOlMap/types'
3
+ import LocationPicker from '@af-mobile-client-vue3/components/data/XOlMap/XLocationPicker/index.vue'
4
+ import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
5
+ import { showNotify } from 'vant'
6
+ import { ref } from 'vue'
7
+
8
+ const selectedLocation = ref<LocationResult>()
9
+
10
+ // 处理位置选择
11
+ function handleLocationConfirm(location: LocationResult) {
12
+ // console.log('选择的位置:', location)
13
+ // selectedLocation.value = location
14
+ showNotify({ type: 'success', message: '位置已选择' })
15
+ }
16
+ </script>
17
+
18
+ <template>
19
+ <NormalDataLayout id="XLocationPicker" title="XOlMap地址选择器">
20
+ <template #layout_content>
21
+ <div class="location-picker-demo">
22
+ <!-- 页面标题 -->
23
+ <div class="page-header">
24
+ <div class="title">
25
+ 位置选择
26
+ </div>
27
+ </div>
28
+
29
+ <!-- 选择结果展示 -->
30
+ <div v-if="selectedLocation" class="location-result">
31
+ <div class="label">
32
+ 已选位置:
33
+ </div>
34
+ <div class="value">
35
+ {{ selectedLocation.address }}
36
+ </div>
37
+ <div class="coordinates">
38
+ 经度: {{ selectedLocation.longitude.toFixed(6) }},
39
+ 纬度: {{ selectedLocation.latitude.toFixed(6) }}
40
+ </div>
41
+ </div>
42
+
43
+ <!-- 地图组件 -->
44
+ <div class="map-container">
45
+ <LocationPicker
46
+ v-model="selectedLocation"
47
+ :default-center="[108.948024, 34.263161]"
48
+ :default-zoom="12"
49
+ @confirm="handleLocationConfirm"
50
+ />
51
+ </div>
52
+ </div>
53
+ </template>
54
+ </NormalDataLayout>
55
+ </template>
56
+
57
+ <style scoped lang="less">
58
+ .location-picker-demo {
59
+ width: 100%;
60
+ height: 100%;
61
+ position: relative;
62
+ display: flex;
63
+ flex-direction: column;
64
+ background-color: #f7f8fa;
65
+ }
66
+
67
+ .page-header {
68
+ height: 44px;
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: center;
72
+ background: white;
73
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
74
+ position: relative;
75
+ z-index: 1;
76
+
77
+ .title {
78
+ font-size: 16px;
79
+ color: #333;
80
+ font-weight: 500;
81
+ }
82
+ }
83
+
84
+ .location-result {
85
+ background: white;
86
+ padding: 12px 16px;
87
+ margin: 10px;
88
+ border-radius: 8px;
89
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
90
+
91
+ .label {
92
+ font-size: 14px;
93
+ color: #666;
94
+ margin-bottom: 4px;
95
+ }
96
+
97
+ .value {
98
+ font-size: 16px;
99
+ color: #333;
100
+ margin-bottom: 8px;
101
+ word-break: break-all;
102
+ }
103
+
104
+ .coordinates {
105
+ font-size: 12px;
106
+ color: #999;
107
+ }
108
+ }
109
+
110
+ .map-container {
111
+ flex: 1;
112
+ position: relative;
113
+ margin: 0 10px 10px 10px;
114
+ border-radius: 8px;
115
+ overflow: hidden;
116
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
117
+ }
118
+ </style>