@fmdeui/fmui 1.0.110 → 1.0.112

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.
@@ -0,0 +1,207 @@
1
+ import { defineComponent, useModel, reactive, onMounted, resolveComponent, openBlock, createBlock, normalizeStyle, withCtx, createCommentVNode, createElementBlock, Fragment, renderList, createElementVNode, createVNode, unref, mergeModels } from 'vue';
2
+ import { RefreshLeft } from '@element-plus/icons-vue';
3
+ import '../../stores/index.mjs';
4
+ import { usefminputdropdownstore } from '../../stores/ainputdropdow.mjs';
5
+
6
+ const _hoisted_1 = { style: { "display": "flex", "justify-content": "end", "align-items": "right", "cursor": "pointer" } };
7
+ var _sfc_main = /* @__PURE__ */ defineComponent({
8
+ ...{
9
+ name: "FmSelect"
10
+ },
11
+ __name: "index",
12
+ props: /* @__PURE__ */ mergeModels({
13
+ //数据
14
+ optionData: {
15
+ type: Array,
16
+ default: []
17
+ },
18
+ /**
19
+ * 值的属性值
20
+ */
21
+ bvalue: {
22
+ type: String,
23
+ default: "id"
24
+ },
25
+ /**
26
+ * 值的属性标签
27
+ */
28
+ blabel: {
29
+ type: String,
30
+ default: "name"
31
+ },
32
+ placeholder: {
33
+ type: String,
34
+ default: "\u8BF7\u9009\u62E9"
35
+ },
36
+ inputWidth: {
37
+ type: String,
38
+ default: "40%"
39
+ },
40
+ dropWidth: {
41
+ type: String,
42
+ default: "90px"
43
+ },
44
+ dropHeight: {
45
+ type: String,
46
+ default: "180px"
47
+ },
48
+ /**
49
+ * api service name
50
+ */
51
+ apiService: {
52
+ type: String,
53
+ default: "baseData"
54
+ },
55
+ /**
56
+ * api service 下的方法
57
+ */
58
+ apiAction: {
59
+ type: String,
60
+ default: "baseDataList"
61
+ },
62
+ /**
63
+ * 基础编码 自动获取数据
64
+ */
65
+ basecode: {
66
+ type: String,
67
+ default: ""
68
+ },
69
+ /**
70
+ * 基础编码 多个编码合在一起调用
71
+ */
72
+ multibasecode: {
73
+ type: Array,
74
+ default: []
75
+ },
76
+ freshSize: {
77
+ type: [Number, String],
78
+ default: 20
79
+ },
80
+ /**
81
+ * 是否默认加载数据
82
+ */
83
+ autoLoadData: {
84
+ type: Boolean,
85
+ default: true
86
+ },
87
+ /**
88
+ * 是否添加空选项
89
+ */
90
+ addEmptyOption: {
91
+ type: Boolean,
92
+ default: false
93
+ },
94
+ /**
95
+ * 空选项的标签
96
+ */
97
+ emptyOptionLabel: {
98
+ type: String,
99
+ default: "\u5168\u90E8"
100
+ },
101
+ /**
102
+ * 空选项的值
103
+ */
104
+ emptyOptionValue: {
105
+ type: Number,
106
+ default: 0
107
+ }
108
+ }, {
109
+ "id": { default: 0, required: false },
110
+ "idModifiers": {},
111
+ "name": { default: "", required: false },
112
+ "nameModifiers": {}
113
+ }),
114
+ emits: /* @__PURE__ */ mergeModels(["change"], ["update:id", "update:name"]),
115
+ setup(__props, { emit: __emit }) {
116
+ const modeValueId = useModel(__props, "id");
117
+ const modeValueName = useModel(__props, "name");
118
+ const props = __props;
119
+ const state = reactive({
120
+ optionData: props.optionData
121
+ });
122
+ const emit = __emit;
123
+ const handelChange = (val) => {
124
+ if (props.addEmptyOption && val == props.emptyOptionValue) {
125
+ modeValueId.value = props.emptyOptionValue;
126
+ return;
127
+ }
128
+ const fitem = state.optionData.find((item) => item[props.blabel] === val);
129
+ modeValueId.value = fitem != null ? fitem[props.bvalue] : 0;
130
+ modeValueName.value = fitem != null ? fitem[props.blabel] : "";
131
+ emit("change", val);
132
+ };
133
+ const handelClear = () => {
134
+ modeValueId.value = 0;
135
+ modeValueName.value = "";
136
+ emit("change", "");
137
+ };
138
+ onMounted(async () => {
139
+ if (props.optionData.length > 0) {
140
+ state.optionData = props.optionData;
141
+ }
142
+ if (props.autoLoadData && props.basecode && props.basecode != "") {
143
+ const useBaseApi = usefminputdropdownstore();
144
+ state.optionData = await useBaseApi.getOptionsData(props.apiService, props.apiAction, props.basecode, false, props.multibasecode);
145
+ }
146
+ });
147
+ const handRestdata = async () => {
148
+ if (props.basecode && props.basecode != "") {
149
+ const useBaseApi = usefminputdropdownstore();
150
+ state.optionData = await useBaseApi.getOptionsData(props.apiService, props.apiAction, props.basecode, true, []);
151
+ }
152
+ };
153
+ return (_ctx, _cache) => {
154
+ const _component_el_icon = resolveComponent("el-icon");
155
+ const _component_el_option = resolveComponent("el-option");
156
+ const _component_el_select = resolveComponent("el-select");
157
+ return openBlock(), createBlock(_component_el_select, {
158
+ modelValue: modeValueName.value,
159
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modeValueName.value = $event),
160
+ placeholder: props.placeholder,
161
+ style: normalizeStyle({ width: __props.inputWidth }),
162
+ onChange: handelChange,
163
+ onClear: handelClear
164
+ }, {
165
+ header: withCtx(() => [
166
+ createElementVNode("div", _hoisted_1, [
167
+ createVNode(_component_el_icon, {
168
+ color: "#13c2c2",
169
+ size: __props.freshSize,
170
+ onClick: handRestdata
171
+ }, {
172
+ default: withCtx(() => [
173
+ createVNode(unref(RefreshLeft))
174
+ ]),
175
+ _: 1
176
+ /* STABLE */
177
+ }, 8, ["size"])
178
+ ])
179
+ ]),
180
+ default: withCtx(() => [
181
+ __props.addEmptyOption ? (openBlock(), createBlock(_component_el_option, {
182
+ key: 0,
183
+ label: __props.emptyOptionLabel,
184
+ value: __props.emptyOptionLabel
185
+ }, null, 8, ["label", "value"])) : createCommentVNode("v-if", true),
186
+ (openBlock(true), createElementBlock(
187
+ Fragment,
188
+ null,
189
+ renderList(state.optionData, (item, index) => {
190
+ return openBlock(), createBlock(_component_el_option, {
191
+ key: index,
192
+ label: item[__props.blabel],
193
+ value: item[__props.blabel]
194
+ }, null, 8, ["label", "value"]);
195
+ }),
196
+ 128
197
+ /* KEYED_FRAGMENT */
198
+ ))
199
+ ]),
200
+ _: 1
201
+ /* STABLE */
202
+ }, 8, ["modelValue", "placeholder", "style"]);
203
+ };
204
+ }
205
+ });
206
+
207
+ export { _sfc_main as default };
@@ -11,6 +11,7 @@ export { elSvg } from './svgIcon/index.mjs';
11
11
  export { FLayout } from './fm-layout/index.mjs';
12
12
  export { FSettings } from './fm-settings/index.mjs';
13
13
  export { FModifyRecord } from './modifyRecord/index.mjs';
14
+ export { FmSelect } from './fm-select/index.mjs';
14
15
  export { Fminputdropdown } from './fm-inputdropdown/index.mjs';
15
16
  export { FmInputNumber } from './fm-inputnumber/index.mjs';
16
17
  export { FmAutocomplete } from './fm-autocomplete/index.mjs';