@uxda/appkit 1.2.0 → 1.2.2

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/dist/index.js CHANGED
@@ -2169,6 +2169,7 @@ var script$2 = /* @__PURE__ */ defineComponent({
2169
2169
  rightIcon: { type: Boolean, required: false, default: true },
2170
2170
  placeholder: { type: String, required: false, default: "\u8BF7\u9009\u62E9" },
2171
2171
  disabled: { type: Boolean, required: false, default: false },
2172
+ type: { type: String, required: false, default: "region" },
2172
2173
  formatter: { type: Function, required: false, default: (values) => values.map((item) => item.label).join("") }
2173
2174
  },
2174
2175
  emits: ["update:value", "change", "cancel"],
@@ -2223,7 +2224,13 @@ var script$2 = /* @__PURE__ */ defineComponent({
2223
2224
  const selectedItem = ref([]);
2224
2225
  const options = computed(() => {
2225
2226
  const provinceOption = areaFormatOptions.value;
2227
+ if (props.type === "province") {
2228
+ return [provinceOption];
2229
+ }
2226
2230
  const cityOption = provinceOption[tmpSelectedIndex.value[0]].children;
2231
+ if (props.type === "city") {
2232
+ return [provinceOption, cityOption];
2233
+ }
2227
2234
  const regionOption = cityOption[tmpSelectedIndex.value[1]].children;
2228
2235
  return [provinceOption, cityOption, regionOption];
2229
2236
  });
@@ -2232,7 +2239,7 @@ var script$2 = /* @__PURE__ */ defineComponent({
2232
2239
  tmpSelectedIndex.value = [...selectedIndex.value];
2233
2240
  if (props.value) {
2234
2241
  const items = [];
2235
- for (let index = 0; index < selectedIndex.value.length; index++) {
2242
+ for (let index = 0; index < options.value.length; index++) {
2236
2243
  const item = options.value[index][selectedIndex.value[index]];
2237
2244
  if (item) {
2238
2245
  items.push(item);
@@ -2268,7 +2275,7 @@ var script$2 = /* @__PURE__ */ defineComponent({
2268
2275
  return [0, 0, 0];
2269
2276
  }
2270
2277
  function onChange() {
2271
- const lastSelectedIndex = options.value[2].length ? 2 : 1;
2278
+ const lastSelectedIndex = options.value.length - 1;
2272
2279
  const result = {
2273
2280
  values: [],
2274
2281
  labels: []
@@ -2724,6 +2731,7 @@ var script = /* @__PURE__ */ defineComponent({
2724
2731
  createVNode(script$2, {
2725
2732
  value: formState.areaCode,
2726
2733
  "onUpdate:value": _cache[6] || (_cache[6] = ($event) => formState.areaCode = $event),
2734
+ type: "city",
2727
2735
  placeholder: "\u8BF7\u9009\u62E9"
2728
2736
  }, null, 8, ["value"])
2729
2737
  ]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxda/appkit",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "小程序应用开发包",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.ts",
@@ -14,11 +14,14 @@ interface AreaItem {
14
14
  children: AreaItem[]
15
15
  }
16
16
 
17
- interface PropsType {
17
+ export type AreaType = 'province' | 'city' | 'region'
18
+
19
+ export interface PropsType {
18
20
  value?: string // 地址code
19
21
  rightIcon?: boolean
20
22
  placeholder?: string
21
23
  disabled?: boolean
24
+ type?: AreaType
22
25
  formatter?: (values: AreaItem[]) => string
23
26
  }
24
27
 
@@ -27,6 +30,7 @@ const props = withDefaults(defineProps<PropsType>(), {
27
30
  rightIcon: true,
28
31
  placeholder: '请选择',
29
32
  disabled: false,
33
+ type: 'region',
30
34
  formatter: (values: AreaItem[]) => values.map((item:AreaItem) => item.label).join('')
31
35
  })
32
36
  const emit = defineEmits(['update:value', 'change', 'cancel'])
@@ -81,7 +85,13 @@ const selectedItem = ref<AreaItem[]>([])
81
85
 
82
86
  const options = computed<AreaItem[][]>(() => {
83
87
  const provinceOption = areaFormatOptions.value
88
+ if (props.type === 'province') {
89
+ return [provinceOption]
90
+ }
84
91
  const cityOption = provinceOption[tmpSelectedIndex.value[0]].children
92
+ if (props.type === 'city') {
93
+ return [provinceOption, cityOption]
94
+ }
85
95
  const regionOption = cityOption[tmpSelectedIndex.value[1]].children
86
96
  return [provinceOption, cityOption, regionOption]
87
97
  })
@@ -91,7 +101,7 @@ function init() {
91
101
  tmpSelectedIndex.value = [...selectedIndex.value]
92
102
  if (props.value){
93
103
  const items = []
94
- for (let index = 0; index < selectedIndex.value.length; index++) {
104
+ for (let index = 0; index < options.value.length; index++) {
95
105
  const item = options.value[index][selectedIndex.value[index]]
96
106
  if (item){
97
107
  items.push(item)
@@ -129,7 +139,7 @@ function findIndexByValue() {
129
139
  }
130
140
 
131
141
  function onChange() {
132
- const lastSelectedIndex = options.value[2].length ? 2 : 1
142
+ const lastSelectedIndex = options.value.length - 1
133
143
  const result = {
134
144
  values: [],
135
145
  labels: []
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
- import {reactive, ref} from 'vue'
2
+ import { reactive } from 'vue'
3
3
  import OcrId from './../../components/ocr-id/index.vue'
4
- import {OcrResultType} from './../../components/ocr-id/index.vue'
4
+ import { OcrResultType } from '../../components/ocr-id/types'
5
5
  import DdArea from './../../components/dd-area/index.vue'
6
6
  import DdSelector from './../../components/dd-selector/index.vue'
7
7
  import Taro from "@tarojs/taro";
@@ -144,6 +144,7 @@ async function submit() {
144
144
  <nut-form-item label="所在地区" required>
145
145
  <DdArea
146
146
  v-model:value="formState.areaCode"
147
+ type="city"
147
148
  placeholder="请选择"/>
148
149
  </nut-form-item>
149
150
  </template>