@fecp/mobile 1.0.58 → 1.0.60

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.
@@ -37,6 +37,7 @@ import { MobileFieldTimePicker } from "./src/components/form/fieldTimePicker/ind
37
37
  import { MobileFieldCascaderPicker } from "./src/components/form/fieldCascaderPicker/index.mjs";
38
38
  import { MobileFieldCheckbox } from "./src/components/form/fieldCheckbox/index.mjs";
39
39
  import { MobileFieldRadio } from "./src/components/form/fieldRadio/index.mjs";
40
+ import { MobileFieldArea } from "./src/components/form/fieldArea/index.mjs";
40
41
  import { MobileForm } from "./src/components/form/form/index.mjs";
41
42
  import { MobileFormItem } from "./src/components/form/formItem/index.mjs";
42
43
  import { MobileRadioGroup } from "./src/components/form/radioGroup/index.mjs";
@@ -86,6 +87,7 @@ export {
86
87
  MobileDropdownMenu,
87
88
  MobileEmpty,
88
89
  MobileField,
90
+ MobileFieldArea,
89
91
  MobileFieldCalendarPicker,
90
92
  MobileFieldCascaderPicker,
91
93
  MobileFieldCheckbox,
@@ -34,6 +34,7 @@ import { MobileFieldTimePicker } from "./form/fieldTimePicker/index.mjs";
34
34
  import { MobileFieldCascaderPicker } from "./form/fieldCascaderPicker/index.mjs";
35
35
  import { MobileFieldCheckbox } from "./form/fieldCheckbox/index.mjs";
36
36
  import { MobileFieldRadio } from "./form/fieldRadio/index.mjs";
37
+ import { MobileFieldArea } from "./form/fieldArea/index.mjs";
37
38
  import { MobileForm } from "./form/form/index.mjs";
38
39
  import { MobileFormItem } from "./form/formItem/index.mjs";
39
40
  import { MobileRadioGroup } from "./form/radioGroup/index.mjs";
@@ -72,6 +73,7 @@ export {
72
73
  MobileDropdownMenu,
73
74
  MobileEmpty,
74
75
  MobileField,
76
+ MobileFieldArea,
75
77
  MobileFieldCalendarPicker,
76
78
  MobileFieldCascaderPicker,
77
79
  MobileFieldCheckbox,
@@ -0,0 +1,188 @@
1
+ /* empty css */
2
+ /* empty css */
3
+ /* empty css */
4
+ /* empty css */
5
+ /* empty css */
6
+ /* empty css */
7
+ /* empty css */
8
+ /* empty css */
9
+ /* empty css */
10
+ /* empty css */
11
+ /* empty css */
12
+ import { ref, computed, watch, createBlock, openBlock, unref, mergeProps, isRef, createSlots, withCtx, createVNode, withModifiers } from "vue";
13
+ import { MobileField } from "../field/index.mjs";
14
+ import { useCascaderAreaData } from "../../../../../../node_modules/.pnpm/@vant_area-data@2.0.0/node_modules/@vant/area-data/dist/index.esm.mjs";
15
+ import { Popup } from "../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/popup/index.mjs";
16
+ import { Cascader } from "../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/cascader/index.mjs";
17
+ import { Icon } from "../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/icon/index.mjs";
18
+ const _sfc_main = {
19
+ __name: "FieldArea",
20
+ props: {
21
+ treeOptionsFieldNames: {
22
+ type: Object,
23
+ default: {
24
+ text: "text",
25
+ value: "value",
26
+ children: "children"
27
+ }
28
+ },
29
+ modelValue: {
30
+ type: String,
31
+ default: ""
32
+ },
33
+ disabled: {
34
+ type: Boolean,
35
+ default: false
36
+ },
37
+ readonly: {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+ "is-link": false,
42
+ areaType: {
43
+ //1-省市区,2-省市,3-省
44
+ type: String,
45
+ default: "1"
46
+ }
47
+ },
48
+ emits: ["update:modelValue"],
49
+ setup(__props, { emit: __emit }) {
50
+ const props = __props;
51
+ const finalOptions = ref([]);
52
+ if (props.areaType == "1") {
53
+ finalOptions.value = useCascaderAreaData();
54
+ } else if (props.areaType == "2") {
55
+ finalOptions.value = parseOptionsByLevel(useCascaderAreaData(), 1);
56
+ } else if (props.areaType == "3") {
57
+ finalOptions.value = parseOptionsByLevel(useCascaderAreaData(), 0);
58
+ }
59
+ function parseOptionsByLevel(data, level) {
60
+ if (level === 0) {
61
+ return data.map((item) => ({
62
+ text: item.text,
63
+ value: item.value
64
+ }));
65
+ }
66
+ function processNode(node, currentLevel) {
67
+ const newNode = {
68
+ text: node.text,
69
+ value: node.value
70
+ };
71
+ if (currentLevel < level && node.children) {
72
+ newNode.children = node.children.map(
73
+ (child) => processNode(child, currentLevel + 1)
74
+ );
75
+ }
76
+ return newNode;
77
+ }
78
+ return data.map((node) => processNode(node, 0));
79
+ }
80
+ const fieldTextValue = ref("");
81
+ const showPicker = ref(false);
82
+ const emit = __emit;
83
+ const pickerValue = computed(() => {
84
+ const value = props.modelValue.split("/");
85
+ return value[value.length - 1];
86
+ });
87
+ function getDisplayValue(options, fieldNames, modelValue) {
88
+ const { text, value, children } = fieldNames;
89
+ const values = modelValue.split("/");
90
+ const displayValues = [];
91
+ function findValueInOptions(currentOptions, targetValue) {
92
+ for (const option of currentOptions) {
93
+ if (option[value] === targetValue) {
94
+ return option[text];
95
+ }
96
+ if (option[children] && option[children].length > 0) {
97
+ const result = findValueInOptions(option[children], targetValue);
98
+ if (result) {
99
+ return result;
100
+ }
101
+ }
102
+ }
103
+ return null;
104
+ }
105
+ for (const val of values) {
106
+ const displayValue = findValueInOptions(options, val);
107
+ if (displayValue) {
108
+ displayValues.push(displayValue);
109
+ }
110
+ }
111
+ return displayValues.join("/");
112
+ }
113
+ watch(
114
+ [() => props.modelValue, finalOptions],
115
+ ([value, options]) => {
116
+ if (!value) {
117
+ fieldTextValue.value = "";
118
+ return;
119
+ }
120
+ fieldTextValue.value = getDisplayValue(
121
+ options,
122
+ props.treeOptionsFieldNames,
123
+ value
124
+ );
125
+ },
126
+ { immediate: true }
127
+ );
128
+ const onFinish = ({ selectedOptions }) => {
129
+ const value = selectedOptions.map((option) => option[props.treeOptionsFieldNames.value]).join("/");
130
+ emit("update:modelValue", value);
131
+ showPicker.value = false;
132
+ };
133
+ return (_ctx, _cache) => {
134
+ const _component_van_icon = Icon;
135
+ const _component_van_cascader = Cascader;
136
+ const _component_van_popup = Popup;
137
+ return openBlock(), createBlock(unref(MobileField), mergeProps(_ctx.$attrs, {
138
+ modelValue: unref(fieldTextValue),
139
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => isRef(fieldTextValue) ? fieldTextValue.value = $event : null),
140
+ isLink: __props.readonly ? false : true,
141
+ readonly: "",
142
+ disabled: __props.disabled,
143
+ onClick: _cache[5] || (_cache[5] = () => {
144
+ if (!__props.readonly) {
145
+ showPicker.value = true;
146
+ }
147
+ })
148
+ }), createSlots({
149
+ default: withCtx(() => [
150
+ createVNode(_component_van_popup, {
151
+ show: unref(showPicker),
152
+ "onUpdate:show": _cache[3] || (_cache[3] = ($event) => isRef(showPicker) ? showPicker.value = $event : null),
153
+ "destroy-on-close": "",
154
+ position: "bottom"
155
+ }, {
156
+ default: withCtx(() => [
157
+ createVNode(_component_van_cascader, mergeProps(_ctx.$attrs, {
158
+ modelValue: unref(pickerValue),
159
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(pickerValue) ? pickerValue.value = $event : null),
160
+ options: unref(finalOptions),
161
+ placeholder: "请选择",
162
+ onFinish,
163
+ onClose: _cache[2] || (_cache[2] = ($event) => showPicker.value = false)
164
+ }), null, 16, ["modelValue", "options"])
165
+ ]),
166
+ _: 1
167
+ }, 8, ["show"])
168
+ ]),
169
+ _: 2
170
+ }, [
171
+ !__props.readonly && !__props.disabled && unref(fieldTextValue) ? {
172
+ name: "right-icon",
173
+ fn: withCtx(() => [
174
+ createVNode(_component_van_icon, {
175
+ name: "clear",
176
+ class: "custom-close-icon",
177
+ onClick: _cache[0] || (_cache[0] = withModifiers(($event) => pickerValue.value = null, ["stop"]))
178
+ })
179
+ ]),
180
+ key: "0"
181
+ } : void 0
182
+ ]), 1040, ["modelValue", "isLink", "disabled"]);
183
+ };
184
+ }
185
+ };
186
+ export {
187
+ _sfc_main as default
188
+ };
@@ -0,0 +1,10 @@
1
+ import _sfc_main from "./FieldArea.vue.mjs";
2
+ import install from "../../../utils/install.mjs";
3
+ const MobileFieldArea = install.withInstall(
4
+ "MobileFieldArea",
5
+ _sfc_main
6
+ );
7
+ export {
8
+ MobileFieldArea,
9
+ MobileFieldArea as default
10
+ };
@@ -75,14 +75,9 @@ const _sfc_main = {
75
75
  const fieldTextValue = ref("");
76
76
  const showPicker = ref(false);
77
77
  const emit = __emit;
78
- const pickerValue = computed({
79
- get: () => {
80
- const value = props.modelValue.split("/");
81
- return value[value.length - 1];
82
- },
83
- set: (val) => {
84
- emit("update:modelValue", val);
85
- }
78
+ const pickerValue = computed(() => {
79
+ const value = props.modelValue.split("/");
80
+ return value[value.length - 1];
86
81
  });
87
82
  function getDisplayValue(options, fieldNames, modelValue) {
88
83
  const { text, value, children } = fieldNames;
@@ -126,7 +121,8 @@ const _sfc_main = {
126
121
  { immediate: true }
127
122
  );
128
123
  const onFinish = ({ selectedOptions }) => {
129
- pickerValue.value = selectedOptions.map((option) => option[props.treeOptionsFieldNames.value]).join("/");
124
+ const value = selectedOptions.map((option) => option[props.treeOptionsFieldNames.value]).join("/");
125
+ emit("update:modelValue", value);
130
126
  showPicker.value = false;
131
127
  };
132
128
  return (_ctx, _cache) => {
@@ -40,6 +40,8 @@ const _sfc_main = {
40
40
  return defineAsyncComponent(() => import("../fieldCheckbox/index.mjs"));
41
41
  case "upload":
42
42
  return defineAsyncComponent(() => import("../fieldUploader/index.mjs"));
43
+ case "area":
44
+ return defineAsyncComponent(() => import("../fieldArea/index.mjs"));
43
45
  }
44
46
  });
45
47
  const formData = inject("formData");