@fecp/mobile 1.0.59 → 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.
@@ -38,23 +38,51 @@ const _sfc_main = {
38
38
  type: Boolean,
39
39
  default: false
40
40
  },
41
- "is-link": false
41
+ "is-link": false,
42
+ areaType: {
43
+ //1-省市区,2-省市,3-省
44
+ type: String,
45
+ default: "1"
46
+ }
42
47
  },
43
48
  emits: ["update:modelValue"],
44
49
  setup(__props, { emit: __emit }) {
45
50
  const props = __props;
46
- const finalOptions = ref(useCascaderAreaData());
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
+ }
47
80
  const fieldTextValue = ref("");
48
81
  const showPicker = ref(false);
49
82
  const emit = __emit;
50
- const pickerValue = computed({
51
- get: () => {
52
- const value = props.modelValue.split("/");
53
- return value[value.length - 1];
54
- },
55
- set: (val) => {
56
- emit("update:modelValue", val);
57
- }
83
+ const pickerValue = computed(() => {
84
+ const value = props.modelValue.split("/");
85
+ return value[value.length - 1];
58
86
  });
59
87
  function getDisplayValue(options, fieldNames, modelValue) {
60
88
  const { text, value, children } = fieldNames;
@@ -98,7 +126,8 @@ const _sfc_main = {
98
126
  { immediate: true }
99
127
  );
100
128
  const onFinish = ({ selectedOptions }) => {
101
- pickerValue.value = selectedOptions.map((option) => option[props.treeOptionsFieldNames.value]).join("/");
129
+ const value = selectedOptions.map((option) => option[props.treeOptionsFieldNames.value]).join("/");
130
+ emit("update:modelValue", value);
102
131
  showPicker.value = false;
103
132
  };
104
133
  return (_ctx, _cache) => {
@@ -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,23 +40,51 @@ const _sfc_main = {
40
40
  type: Boolean,
41
41
  default: false
42
42
  },
43
- "is-link": false
43
+ "is-link": false,
44
+ areaType: {
45
+ //1-省市区,2-省市,3-省
46
+ type: String,
47
+ default: "1"
48
+ }
44
49
  },
45
50
  emits: ["update:modelValue"],
46
51
  setup(__props, { emit: __emit }) {
47
52
  const props = __props;
48
- const finalOptions = vue.ref(index_esm.useCascaderAreaData());
53
+ const finalOptions = vue.ref([]);
54
+ if (props.areaType == "1") {
55
+ finalOptions.value = index_esm.useCascaderAreaData();
56
+ } else if (props.areaType == "2") {
57
+ finalOptions.value = parseOptionsByLevel(index_esm.useCascaderAreaData(), 1);
58
+ } else if (props.areaType == "3") {
59
+ finalOptions.value = parseOptionsByLevel(index_esm.useCascaderAreaData(), 0);
60
+ }
61
+ function parseOptionsByLevel(data, level) {
62
+ if (level === 0) {
63
+ return data.map((item) => ({
64
+ text: item.text,
65
+ value: item.value
66
+ }));
67
+ }
68
+ function processNode(node, currentLevel) {
69
+ const newNode = {
70
+ text: node.text,
71
+ value: node.value
72
+ };
73
+ if (currentLevel < level && node.children) {
74
+ newNode.children = node.children.map(
75
+ (child) => processNode(child, currentLevel + 1)
76
+ );
77
+ }
78
+ return newNode;
79
+ }
80
+ return data.map((node) => processNode(node, 0));
81
+ }
49
82
  const fieldTextValue = vue.ref("");
50
83
  const showPicker = vue.ref(false);
51
84
  const emit = __emit;
52
- const pickerValue = vue.computed({
53
- get: () => {
54
- const value = props.modelValue.split("/");
55
- return value[value.length - 1];
56
- },
57
- set: (val) => {
58
- emit("update:modelValue", val);
59
- }
85
+ const pickerValue = vue.computed(() => {
86
+ const value = props.modelValue.split("/");
87
+ return value[value.length - 1];
60
88
  });
61
89
  function getDisplayValue(options, fieldNames, modelValue) {
62
90
  const { text, value, children } = fieldNames;
@@ -100,7 +128,8 @@ const _sfc_main = {
100
128
  { immediate: true }
101
129
  );
102
130
  const onFinish = ({ selectedOptions }) => {
103
- pickerValue.value = selectedOptions.map((option) => option[props.treeOptionsFieldNames.value]).join("/");
131
+ const value = selectedOptions.map((option) => option[props.treeOptionsFieldNames.value]).join("/");
132
+ emit("update:modelValue", value);
104
133
  showPicker.value = false;
105
134
  };
106
135
  return (_ctx, _cache) => {
@@ -77,14 +77,9 @@ const _sfc_main = {
77
77
  const fieldTextValue = vue.ref("");
78
78
  const showPicker = vue.ref(false);
79
79
  const emit = __emit;
80
- const pickerValue = vue.computed({
81
- get: () => {
82
- const value = props.modelValue.split("/");
83
- return value[value.length - 1];
84
- },
85
- set: (val) => {
86
- emit("update:modelValue", val);
87
- }
80
+ const pickerValue = vue.computed(() => {
81
+ const value = props.modelValue.split("/");
82
+ return value[value.length - 1];
88
83
  });
89
84
  function getDisplayValue(options, fieldNames, modelValue) {
90
85
  const { text, value, children } = fieldNames;
@@ -128,7 +123,8 @@ const _sfc_main = {
128
123
  { immediate: true }
129
124
  );
130
125
  const onFinish = ({ selectedOptions }) => {
131
- pickerValue.value = selectedOptions.map((option) => option[props.treeOptionsFieldNames.value]).join("/");
126
+ const value = selectedOptions.map((option) => option[props.treeOptionsFieldNames.value]).join("/");
127
+ emit("update:modelValue", value);
132
128
  showPicker.value = false;
133
129
  };
134
130
  return (_ctx, _cache) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fecp/mobile",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
4
4
  "main": "lib/packages/mobile/index.js",
5
5
  "module": "es/packages/mobile/index.mjs",
6
6
  "files": [