el-plus-crud 0.1.37 → 0.1.38
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.38](https://github.com/KDJack/el-plus-crud/compare/v0.1.37...v0.1.38) (2024-04-26)
|
|
6
|
+
|
|
5
7
|
### [0.1.37](https://github.com/KDJack/el-plus-crud/compare/v0.1.36...v0.1.37) (2024-04-26)
|
|
6
8
|
|
|
7
9
|
### [0.1.36](https://github.com/KDJack/el-plus-crud/compare/v0.1.35...v0.1.36) (2024-04-26)
|
package/dist/el-plus-crud.mjs
CHANGED
|
@@ -5987,16 +5987,18 @@ const pi = /* @__PURE__ */ lt(Kz, [["__scopeId", "data-v-45863775"]]), Hz = /* @
|
|
|
5987
5987
|
d.value !== Y && (d.value = Y, M.splice(0, M.length, ...await c.desc.remote(Y)), Y === "" && (T.value || L()));
|
|
5988
5988
|
}
|
|
5989
5989
|
function L() {
|
|
5990
|
-
if (c.desc.defaultKey) {
|
|
5990
|
+
if (d.value === null && c.desc.defaultKey) {
|
|
5991
5991
|
let Y = c.formData[c.desc.defaultKey.value];
|
|
5992
5992
|
Array.isArray(Y) || (Y = [Y]);
|
|
5993
5993
|
let E = c.formData[c.desc.defaultKey.label];
|
|
5994
5994
|
if (Array.isArray(E) || (E = [E]), Y.length <= 0 || Y.length !== E.length)
|
|
5995
5995
|
return;
|
|
5996
5996
|
Y.map((U, ee) => {
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
5997
|
+
if (U) {
|
|
5998
|
+
const Z = M.findIndex((ge) => ge.value === U);
|
|
5999
|
+
Z >= 0 && M.splice(Z, 1), M.unshift({ value: U, label: E[ee], dataItem: Lt.cloneDeep(c.formData) });
|
|
6000
|
+
}
|
|
6001
|
+
});
|
|
6000
6002
|
}
|
|
6001
6003
|
}
|
|
6002
6004
|
function V() {
|
|
@@ -6004,7 +6006,7 @@ const pi = /* @__PURE__ */ lt(Kz, [["__scopeId", "data-v-45863775"]]), Hz = /* @
|
|
|
6004
6006
|
T.value = !0, (E = (Y = c.desc) == null ? void 0 : Y.on) != null && E.clear && typeof ((ee = (U = c.desc) == null ? void 0 : U.on) == null ? void 0 : ee.clear) == "function" && c.desc.on.clear(), d.value = null, c.desc.remote && M.splice(0, M.length);
|
|
6005
6007
|
}
|
|
6006
6008
|
return Qe(async () => {
|
|
6007
|
-
_.remote = !!c.desc.remote, p.value = await Fe(c, _), p.value.remote = !!c.desc.remote, delete p.value.disabled,
|
|
6009
|
+
_.remote = !!c.desc.remote, p.value = await Fe(c, _), p.value.remote = !!c.desc.remote, delete p.value.disabled, v.value = !0;
|
|
6008
6010
|
}), Pe(
|
|
6009
6011
|
() => c.desc.options,
|
|
6010
6012
|
async (Y) => {
|
|
@@ -6027,9 +6029,9 @@ const pi = /* @__PURE__ */ lt(Kz, [["__scopeId", "data-v-45863775"]]), Hz = /* @
|
|
|
6027
6029
|
}) && (dn.warning("最大长度为: " + (((U = (E = g.form) == null ? void 0 : E.leng) == null ? void 0 : U.input) || 20)), m.value = Y.filter((ee) => {
|
|
6028
6030
|
var Z, ge;
|
|
6029
6031
|
return typeof ee != "string" || ee.length <= (((ge = (Z = g.form) == null ? void 0 : Z.leng) == null ? void 0 : ge.input) || 20);
|
|
6030
|
-
}));
|
|
6032
|
+
})), L();
|
|
6031
6033
|
},
|
|
6032
|
-
{ immediate: !0
|
|
6034
|
+
{ immediate: !0 }
|
|
6033
6035
|
), a({ field: c.field, clear: V }), (Y, E) => {
|
|
6034
6036
|
const U = K("el-option"), ee = K("el-select");
|
|
6035
6037
|
return v.value ? (I(), H(ee, ie({
|
|
@@ -131,7 +131,7 @@ async function queryOptionsFn(query: string) {
|
|
|
131
131
|
* 初始化默认项
|
|
132
132
|
*/
|
|
133
133
|
function initDefault() {
|
|
134
|
-
if (props.desc.defaultKey) {
|
|
134
|
+
if (oldQuery.value === null && props.desc.defaultKey) {
|
|
135
135
|
let defaultValue = props.formData[props.desc.defaultKey.value]
|
|
136
136
|
if (!Array.isArray(defaultValue)) defaultValue = [defaultValue]
|
|
137
137
|
let defaultLabel = props.formData[props.desc.defaultKey.label]
|
|
@@ -140,12 +140,15 @@ function initDefault() {
|
|
|
140
140
|
if (defaultValue.length <= 0 || defaultValue.length !== defaultLabel.length) return
|
|
141
141
|
// 遍历
|
|
142
142
|
defaultValue.map((val: any, i: number) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
if (val) {
|
|
144
|
+
// 这里需要判断下默认值是否已经出现在了options中,如果存在,则需要删除
|
|
145
|
+
const index = options.findIndex((item) => item.value === val)
|
|
146
|
+
if (index >= 0) {
|
|
147
|
+
options.splice(index, 1)
|
|
148
|
+
}
|
|
149
|
+
options.unshift({ value: val, label: defaultLabel[i], dataItem: cloneDeep(props.formData) })
|
|
150
|
+
}
|
|
147
151
|
})
|
|
148
|
-
console.log('options: ', options)
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
154
|
|
|
@@ -164,7 +167,6 @@ onBeforeMount(async () => {
|
|
|
164
167
|
attrs.value = await getAttrs(props, tempAttr)
|
|
165
168
|
attrs.value.remote = !!props.desc.remote
|
|
166
169
|
delete attrs.value.disabled
|
|
167
|
-
initDefault()
|
|
168
170
|
isInit.value = true
|
|
169
171
|
})
|
|
170
172
|
|
|
@@ -201,8 +203,10 @@ watch(
|
|
|
201
203
|
currentValue.value = (val as Array<string>).filter((item) => typeof item !== 'string' || item.length <= (defaultConf.form?.leng?.input || 20))
|
|
202
204
|
}
|
|
203
205
|
}
|
|
206
|
+
// 处理一下默认值
|
|
207
|
+
initDefault()
|
|
204
208
|
},
|
|
205
|
-
{ immediate: true
|
|
209
|
+
{ immediate: true }
|
|
206
210
|
)
|
|
207
211
|
|
|
208
212
|
defineExpose({ field: props.field, clear })
|