xrk-components 2.0.0-beta.80 → 2.0.0-beta.82
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/lib/index.esm.js
CHANGED
|
@@ -73215,21 +73215,44 @@ var script$o = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__$m
|
|
|
73215
73215
|
return ctx.render ? ctx.render(Object.freeze(ctx.data)) : '';
|
|
73216
73216
|
}
|
|
73217
73217
|
});
|
|
73218
|
+
/**
|
|
73219
|
+
* @description: 添加远程已选中数据
|
|
73220
|
+
* @params {Array} arr 需要修改的数据源
|
|
73221
|
+
* @return {Array}
|
|
73222
|
+
*/
|
|
73223
|
+
var setRemoteSelected = function (targetArr) {
|
|
73224
|
+
var _a;
|
|
73225
|
+
if (!searchValue.value &&
|
|
73226
|
+
props.remoteMethod &&
|
|
73227
|
+
((_a = props.remoteSelected) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
73228
|
+
props.remoteSelected.forEach(function (select) {
|
|
73229
|
+
var _a;
|
|
73230
|
+
if (select[props.labelKey] !== undefined &&
|
|
73231
|
+
select[props.valueKey] !== undefined) {
|
|
73232
|
+
// 不存在则添加
|
|
73233
|
+
if (!targetArr.some(function (item) { return item[props.valueKey] === select[props.valueKey]; })) {
|
|
73234
|
+
targetArr.push(__assign(__assign({}, select), (_a = {}, _a[props.labelKey] = select[props.labelKey], _a[props.valueKey] = select[props.valueKey], _a)));
|
|
73235
|
+
}
|
|
73236
|
+
}
|
|
73237
|
+
});
|
|
73238
|
+
}
|
|
73239
|
+
};
|
|
73218
73240
|
var setOptionsData = function (val) { return __awaiter(_this, void 0, void 0, function () {
|
|
73219
|
-
var res,
|
|
73220
|
-
var _a
|
|
73221
|
-
return __generator(this, function (
|
|
73222
|
-
switch (
|
|
73241
|
+
var res, data, error_1;
|
|
73242
|
+
var _a;
|
|
73243
|
+
return __generator(this, function (_b) {
|
|
73244
|
+
switch (_b.label) {
|
|
73223
73245
|
case 0:
|
|
73246
|
+
searchValue.value = val || '';
|
|
73224
73247
|
if (!isFunction(props.remoteMethod)) return [3 /*break*/, 4];
|
|
73225
|
-
|
|
73248
|
+
_b.label = 1;
|
|
73226
73249
|
case 1:
|
|
73227
|
-
|
|
73250
|
+
_b.trys.push([1, 3, , 4]);
|
|
73228
73251
|
loading.value = true;
|
|
73229
73252
|
return [4 /*yield*/, ((_a = props.remoteMethod) === null || _a === void 0 ? void 0 : _a.call(props, val))];
|
|
73230
73253
|
case 2:
|
|
73231
|
-
res =
|
|
73232
|
-
|
|
73254
|
+
res = _b.sent();
|
|
73255
|
+
data = check.isObject(res.data)
|
|
73233
73256
|
? Array.isArray(res.data.list)
|
|
73234
73257
|
? res.data.list
|
|
73235
73258
|
: []
|
|
@@ -73237,29 +73260,18 @@ var script$o = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__$m
|
|
|
73237
73260
|
? res.data
|
|
73238
73261
|
: [];
|
|
73239
73262
|
loading.value = false;
|
|
73240
|
-
|
|
73241
|
-
props.remoteSelected.forEach(function (select) {
|
|
73242
|
-
var _a;
|
|
73243
|
-
if (select[props.labelKey] !== undefined &&
|
|
73244
|
-
select[props.valueKey] !== undefined) {
|
|
73245
|
-
// 不存在则添加
|
|
73246
|
-
if (!data_1.some(function (item) { return item[props.valueKey] === select[props.valueKey]; })) {
|
|
73247
|
-
data_1.push(__assign(__assign({}, select), (_a = {}, _a[props.labelKey] = select[props.labelKey], _a[props.valueKey] = select[props.valueKey], _a)));
|
|
73248
|
-
}
|
|
73249
|
-
}
|
|
73250
|
-
});
|
|
73251
|
-
}
|
|
73263
|
+
setRemoteSelected(data);
|
|
73252
73264
|
if (props.notRemoteAutoFilter) {
|
|
73253
|
-
_options.value = Array.isArray(
|
|
73265
|
+
_options.value = Array.isArray(data) ? data : [];
|
|
73254
73266
|
return [2 /*return*/];
|
|
73255
73267
|
}
|
|
73256
73268
|
// 避免多次请求接口 接口响应先后顺序不一致导致数据错乱
|
|
73257
|
-
_options.value = Array.isArray(
|
|
73258
|
-
?
|
|
73269
|
+
_options.value = Array.isArray(data)
|
|
73270
|
+
? data.filter(function (i) { return !val || "".concat(i[props.labelKey || 'label']).indexOf(val) > -1; })
|
|
73259
73271
|
: [];
|
|
73260
73272
|
return [3 /*break*/, 4];
|
|
73261
73273
|
case 3:
|
|
73262
|
-
error_1 =
|
|
73274
|
+
error_1 = _b.sent();
|
|
73263
73275
|
loading.value = false;
|
|
73264
73276
|
console.error(error_1);
|
|
73265
73277
|
return [3 /*break*/, 4];
|
|
@@ -73277,10 +73289,11 @@ var script$o = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__$m
|
|
|
73277
73289
|
: props.filterMethod);
|
|
73278
73290
|
var toolTipDisabled = ref(true);
|
|
73279
73291
|
var loading = ref(false);
|
|
73280
|
-
var _options = ref(props.options);
|
|
73292
|
+
var _options = ref(props.options || []);
|
|
73281
73293
|
var selectValue = ref(props.multiple && props.modelValue && !Array.isArray(props.modelValue)
|
|
73282
73294
|
? [props.modelValue]
|
|
73283
73295
|
: props.modelValue);
|
|
73296
|
+
var searchValue = ref('');
|
|
73284
73297
|
// 父组件值发生改变时,同步selectValue
|
|
73285
73298
|
watch(function () { return props.modelValue; }, function (newV) {
|
|
73286
73299
|
selectValue.value = newV;
|
package/lib/index.umd.js
CHANGED
|
@@ -73218,21 +73218,44 @@ usage: app.provide(ZINDEX_INJECTION_KEY, { current: 0 })`);
|
|
|
73218
73218
|
return ctx.render ? ctx.render(Object.freeze(ctx.data)) : '';
|
|
73219
73219
|
}
|
|
73220
73220
|
});
|
|
73221
|
+
/**
|
|
73222
|
+
* @description: 添加远程已选中数据
|
|
73223
|
+
* @params {Array} arr 需要修改的数据源
|
|
73224
|
+
* @return {Array}
|
|
73225
|
+
*/
|
|
73226
|
+
var setRemoteSelected = function (targetArr) {
|
|
73227
|
+
var _a;
|
|
73228
|
+
if (!searchValue.value &&
|
|
73229
|
+
props.remoteMethod &&
|
|
73230
|
+
((_a = props.remoteSelected) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
73231
|
+
props.remoteSelected.forEach(function (select) {
|
|
73232
|
+
var _a;
|
|
73233
|
+
if (select[props.labelKey] !== undefined &&
|
|
73234
|
+
select[props.valueKey] !== undefined) {
|
|
73235
|
+
// 不存在则添加
|
|
73236
|
+
if (!targetArr.some(function (item) { return item[props.valueKey] === select[props.valueKey]; })) {
|
|
73237
|
+
targetArr.push(__assign(__assign({}, select), (_a = {}, _a[props.labelKey] = select[props.labelKey], _a[props.valueKey] = select[props.valueKey], _a)));
|
|
73238
|
+
}
|
|
73239
|
+
}
|
|
73240
|
+
});
|
|
73241
|
+
}
|
|
73242
|
+
};
|
|
73221
73243
|
var setOptionsData = function (val) { return __awaiter(_this, void 0, void 0, function () {
|
|
73222
|
-
var res,
|
|
73223
|
-
var _a
|
|
73224
|
-
return __generator(this, function (
|
|
73225
|
-
switch (
|
|
73244
|
+
var res, data, error_1;
|
|
73245
|
+
var _a;
|
|
73246
|
+
return __generator(this, function (_b) {
|
|
73247
|
+
switch (_b.label) {
|
|
73226
73248
|
case 0:
|
|
73249
|
+
searchValue.value = val || '';
|
|
73227
73250
|
if (!isFunction(props.remoteMethod)) return [3 /*break*/, 4];
|
|
73228
|
-
|
|
73251
|
+
_b.label = 1;
|
|
73229
73252
|
case 1:
|
|
73230
|
-
|
|
73253
|
+
_b.trys.push([1, 3, , 4]);
|
|
73231
73254
|
loading.value = true;
|
|
73232
73255
|
return [4 /*yield*/, ((_a = props.remoteMethod) === null || _a === void 0 ? void 0 : _a.call(props, val))];
|
|
73233
73256
|
case 2:
|
|
73234
|
-
res =
|
|
73235
|
-
|
|
73257
|
+
res = _b.sent();
|
|
73258
|
+
data = xrkTools.check.isObject(res.data)
|
|
73236
73259
|
? Array.isArray(res.data.list)
|
|
73237
73260
|
? res.data.list
|
|
73238
73261
|
: []
|
|
@@ -73240,29 +73263,18 @@ usage: app.provide(ZINDEX_INJECTION_KEY, { current: 0 })`);
|
|
|
73240
73263
|
? res.data
|
|
73241
73264
|
: [];
|
|
73242
73265
|
loading.value = false;
|
|
73243
|
-
|
|
73244
|
-
props.remoteSelected.forEach(function (select) {
|
|
73245
|
-
var _a;
|
|
73246
|
-
if (select[props.labelKey] !== undefined &&
|
|
73247
|
-
select[props.valueKey] !== undefined) {
|
|
73248
|
-
// 不存在则添加
|
|
73249
|
-
if (!data_1.some(function (item) { return item[props.valueKey] === select[props.valueKey]; })) {
|
|
73250
|
-
data_1.push(__assign(__assign({}, select), (_a = {}, _a[props.labelKey] = select[props.labelKey], _a[props.valueKey] = select[props.valueKey], _a)));
|
|
73251
|
-
}
|
|
73252
|
-
}
|
|
73253
|
-
});
|
|
73254
|
-
}
|
|
73266
|
+
setRemoteSelected(data);
|
|
73255
73267
|
if (props.notRemoteAutoFilter) {
|
|
73256
|
-
_options.value = Array.isArray(
|
|
73268
|
+
_options.value = Array.isArray(data) ? data : [];
|
|
73257
73269
|
return [2 /*return*/];
|
|
73258
73270
|
}
|
|
73259
73271
|
// 避免多次请求接口 接口响应先后顺序不一致导致数据错乱
|
|
73260
|
-
_options.value = Array.isArray(
|
|
73261
|
-
?
|
|
73272
|
+
_options.value = Array.isArray(data)
|
|
73273
|
+
? data.filter(function (i) { return !val || "".concat(i[props.labelKey || 'label']).indexOf(val) > -1; })
|
|
73262
73274
|
: [];
|
|
73263
73275
|
return [3 /*break*/, 4];
|
|
73264
73276
|
case 3:
|
|
73265
|
-
error_1 =
|
|
73277
|
+
error_1 = _b.sent();
|
|
73266
73278
|
loading.value = false;
|
|
73267
73279
|
console.error(error_1);
|
|
73268
73280
|
return [3 /*break*/, 4];
|
|
@@ -73280,10 +73292,11 @@ usage: app.provide(ZINDEX_INJECTION_KEY, { current: 0 })`);
|
|
|
73280
73292
|
: props.filterMethod);
|
|
73281
73293
|
var toolTipDisabled = vue.ref(true);
|
|
73282
73294
|
var loading = vue.ref(false);
|
|
73283
|
-
var _options = vue.ref(props.options);
|
|
73295
|
+
var _options = vue.ref(props.options || []);
|
|
73284
73296
|
var selectValue = vue.ref(props.multiple && props.modelValue && !Array.isArray(props.modelValue)
|
|
73285
73297
|
? [props.modelValue]
|
|
73286
73298
|
: props.modelValue);
|
|
73299
|
+
var searchValue = vue.ref('');
|
|
73287
73300
|
// 父组件值发生改变时,同步selectValue
|
|
73288
73301
|
vue.watch(function () { return props.modelValue; }, function (newV) {
|
|
73289
73302
|
selectValue.value = newV;
|
|
@@ -81,12 +81,12 @@ export interface BaseSelectProps extends BaseSelectListener {
|
|
|
81
81
|
*/
|
|
82
82
|
filterMethod?: (searchVal: string) => Array<SelectValueType>;
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
84
|
+
* 远程方法,只会返回array
|
|
85
85
|
*/
|
|
86
86
|
remoteMethod?: (searchVal?: string) => any;
|
|
87
87
|
/**
|
|
88
88
|
* 远程-已选中数据,解决初始数据时远程搜索数据不包含已选数据,包括多项选择。
|
|
89
|
-
* key必须对应labelKey与valueKey
|
|
89
|
+
* key必须对应labelKey与valueKey,只接受Array<Object>。
|
|
90
90
|
* 对象可添加多个属性不限于label value。
|
|
91
91
|
* 有搜索条件不添加,其他情况都添加。data无数据也要push。
|
|
92
92
|
*/
|
|
@@ -5,9 +5,6 @@ interface ModalInstance {
|
|
|
5
5
|
close(): void;
|
|
6
6
|
$updateProps(props: anyObj): void;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
ctx: ModalInstance;
|
|
10
|
-
}
|
|
11
|
-
export declare const useCreateModal: (component: Component, options?: anyObj, app?: App | InstanceComponent) => ModalInstance;
|
|
8
|
+
export declare const useCreateModal: (component: Component, options?: anyObj, app?: App | ComponentInternalInstance) => ModalInstance;
|
|
12
9
|
declare const install: (app: App, component: Component, options: anyObj) => void;
|
|
13
10
|
export default install;
|