vue_zhongyou 1.0.15 → 1.0.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue_zhongyou",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "keywords": [],
@@ -211,6 +211,7 @@
211
211
  <van-area
212
212
  :area-list="areaList"
213
213
  :columns-placeholder="addressPopup.columnsPlaceholder || ['请选择', '请选择', '请选择']"
214
+ :columns-num="addressPopup.columnsNum || 3"
214
215
  v-model="addressPopup.value"
215
216
  @confirm="onAddressConfirm"
216
217
  @cancel="closeAddressPicker"
@@ -295,6 +296,7 @@ const addressPopup = ref({
295
296
  field: null,
296
297
  areaList: null,
297
298
  columnsPlaceholder: null,
299
+ columnsNum: null,
298
300
  value: ''
299
301
  })
300
302
 
@@ -619,16 +621,17 @@ const openAddressPicker = (field) => {
619
621
  visible: true,
620
622
  field,
621
623
  areaList: areaList,
622
- columnsPlaceholder: field.columnsPlaceholder
624
+ columnsPlaceholder: field.columnsPlaceholder,
625
+ columnsNum: field.columnsNum || 3
623
626
  }
624
627
 
625
628
  // 如果表单数据中已有code值,则设置默认选中项
626
629
  const fieldValue = formData[field.field]
627
630
  let code = ''
628
631
 
629
- // 如果fieldValue是一个对象且包含code属性
630
- if (fieldValue && typeof fieldValue === 'object' && fieldValue.code) {
631
- code = fieldValue.code
632
+ // 如果fieldValue是一个对象且包含destinationCode属性
633
+ if (fieldValue && typeof fieldValue === 'object' && fieldValue.destinationCode) {
634
+ code = fieldValue.destinationCode
632
635
  }
633
636
  // 如果fieldValue是一个字符串(直接是code值)
634
637
  else if (fieldValue && typeof fieldValue === 'string') {
@@ -646,6 +649,11 @@ const openAddressPicker = (field) => {
646
649
  const getCodeToAreaValue = (code) => {
647
650
  if (!code) return ''
648
651
 
652
+ // 如果code是一个对象且包含destinationCode属性
653
+ if (typeof code === 'object' && code.destinationCode) {
654
+ code = code.destinationCode
655
+ }
656
+
649
657
  // 确保code是字符串且长度为6
650
658
  const codeStr = String(code).padEnd(6, '0')
651
659
 
@@ -676,7 +684,18 @@ const onAddressConfirm = ({ selectedOptions }) => {
676
684
  }
677
685
  }
678
686
 
679
- updateFieldValue(addressPopup.value.field.field, code)
687
+ // 构造包含destinationCode和destination的对象
688
+ // 过滤掉"请选择"的选项,只保留有效的地址文本
689
+ const addressText = selectedOptions
690
+ .filter(opt => opt && opt.text && opt.text !== '请选择')
691
+ .map(opt => opt.text)
692
+ .join('')
693
+ const addressObject = {
694
+ destinationCode: code,
695
+ destination: addressText
696
+ }
697
+
698
+ updateFieldValue(addressPopup.value.field.field, addressObject)
680
699
 
681
700
  // 触发modelValue更新
682
701
  emit('update:modelValue', snapshot())
@@ -686,9 +705,14 @@ const onAddressConfirm = ({ selectedOptions }) => {
686
705
 
687
706
  const getAddressText = (field) => {
688
707
  const value = formData[field.field]
689
- // 如果value是一个对象且包含code属性
690
- if (value && typeof value === 'object' && value.code) {
691
- return getCodeToAddressText(value.code)
708
+ // 如果value是一个对象且包含destination属性,直接返回destination
709
+ if (value && typeof value === 'object' && value.destination) {
710
+ return value.destination
711
+ }
712
+
713
+ // 如果value是一个对象且包含destinationCode属性
714
+ if (value && typeof value === 'object' && value.destinationCode) {
715
+ return getCodeToAddressText(value.destinationCode)
692
716
  }
693
717
 
694
718
  // 如果value是一个字符串(直接是code值)