@cloudbase/weda-ui-mp 3.14.2 → 3.15.0
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/components/chart/bar/index.js +4 -20
- package/components/chart/bar/index.wxml +1 -1
- package/components/chart/common/data-transform.js +6 -16
- package/components/chart/ec-canvas/ec-canvas.js +35 -37
- package/components/chart/ec-canvas/ec-canvas.wxml +1 -1
- package/components/chart/line/index.js +4 -20
- package/components/chart/line/index.wxml +1 -1
- package/components/chart/pie/index.js +4 -20
- package/components/chart/pie/index.wxml +1 -1
- package/components/form/form/wd-form.wxss +15 -0
- package/components/form/select/dropdown-select/index.js +41 -58
- package/components/form/select/dropdown-select/index.wxml +1 -1
- package/components/form/select/dropdown-select/index.wxss +1 -2
- package/components/form/select/index.js +1 -1
- package/components/form/selectMultiple/dropdown-select/index.js +10 -20
- package/components/form/selectMultiple/dropdown-select/index.wxss +2 -6
- package/components/form/selectMultiple/index.js +94 -45
- package/components/form/uploader/index.js +7 -15
- package/components/form/uploaderFile/index.js +3 -2
- package/components/formdetail/index.js +9 -28
- package/components/listView/index.js +1 -1
- package/components/listView/index.wxml +5 -5
- package/components/listView/index.wxss +20 -67
- package/components/qrcode/index.js +3 -4
- package/components/wd-form/index.js +72 -163
- package/components/wd-form/wd-form.wxss +15 -0
- package/components/wd-form-item/wd-form-item.wxss +15 -0
- package/components/wd-form-item-obj/wd-form-item.wxss +15 -0
- package/components/wd-input/inner-input/index.js +22 -56
- package/components/wd-input/inner-input/index.wxml +6 -2
- package/components/wd-input/inner-input/wd-input.wxss +15 -0
- package/components/wd-progress/wd-progress.wxss +15 -0
- package/components/wd-rating/wd-rating.wxss +15 -0
- package/components/wd-select/index.js +14 -10
- package/components/wd-select/index.json +1 -1
- package/components/wd-select/index.wxml +3 -0
- package/components/wd-select/select/formats-util.js +9 -0
- package/components/wd-select/select/index.js +545 -0
- package/components/wd-select/select/index.json +8 -0
- package/components/wd-select/select/index.wxml +26 -0
- package/components/wd-select/select/index.wxss +5 -0
- package/components/wd-select-multiple/index.js +13 -5
- package/components/wd-select-multiple/index.wxml +3 -0
- package/components/wd-switch/wd-switch.wxss +15 -0
- package/components/wd-tag-select/wd-tag-select.wxss +15 -0
- package/package.json +1 -1
- package/utils/getModelParams.js +27 -1
- package/utils/tcb.js +11 -2
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
/* eslint max-lines: [error, 800] */
|
|
2
2
|
import { commonCompBehavior } from '../../utils/common-behavior';
|
|
3
|
-
import {
|
|
4
|
-
getDataSourceByName,
|
|
5
|
-
callDataSource,
|
|
6
|
-
callConnector,
|
|
7
|
-
} from '../../utils/tcb';
|
|
3
|
+
import { getDataSourceByName, callDataSource, callConnector } from '../../utils/tcb';
|
|
8
4
|
import equal from '../../utils/deepEqual';
|
|
9
5
|
import { emptyArray, noop } from '../../utils/constant';
|
|
10
6
|
import { isNil } from '../../utils/lodash';
|
|
11
|
-
import {
|
|
12
|
-
convertFormDataToSubmitParams,
|
|
13
|
-
convertRemoteValueToFormData,
|
|
14
|
-
} from './remote-value';
|
|
7
|
+
import { convertFormDataToSubmitParams, convertRemoteValueToFormData } from './remote-value';
|
|
15
8
|
import { WdCompError } from '../../utils/error';
|
|
16
|
-
import {
|
|
17
|
-
getErrorObjectFromValidateResult,
|
|
18
|
-
getFormDataFromItemMap,
|
|
19
|
-
} from './form-utils';
|
|
9
|
+
import { getErrorObjectFromValidateResult, getFormDataFromItemMap } from './form-utils';
|
|
20
10
|
import lodashGet from 'lodash.get';
|
|
21
11
|
import debounce from '../../utils/debounce';
|
|
22
12
|
|
|
@@ -173,15 +163,9 @@ Component({
|
|
|
173
163
|
const errorObj = await this.validate();
|
|
174
164
|
if (Object.keys(errorObj ?? {}).length === 0) {
|
|
175
165
|
this.triggerEvent('validateSuccess', { errors: {} });
|
|
176
|
-
const formData = getFormDataFromItemMap(
|
|
177
|
-
this.data._formItemMap,
|
|
178
|
-
formType
|
|
179
|
-
);
|
|
166
|
+
const formData = getFormDataFromItemMap(this.data._formItemMap, formType);
|
|
180
167
|
const extra = ['read', 'edit'].includes(formType) && _id ? { _id } : {};
|
|
181
|
-
this.triggerEvent(
|
|
182
|
-
'submit',
|
|
183
|
-
JSON.parse(JSON.stringify({ ...extra, ...formData }))
|
|
184
|
-
);
|
|
168
|
+
this.triggerEvent('submit', JSON.parse(JSON.stringify({ ...extra, ...formData })));
|
|
185
169
|
// 流程用了
|
|
186
170
|
return formData;
|
|
187
171
|
} else {
|
|
@@ -212,7 +196,7 @@ Component({
|
|
|
212
196
|
},
|
|
213
197
|
// 获取子表单初始值
|
|
214
198
|
_initValueFormDetail: function () {
|
|
215
|
-
console.log(this.data._formItemMap);
|
|
199
|
+
// console.log(this.data._formItemMap);
|
|
216
200
|
const { _formItemMap } = this.data;
|
|
217
201
|
const formDetailInitValue = {};
|
|
218
202
|
Object.keys(_formItemMap ?? {}).forEach((name) => {
|
|
@@ -227,21 +211,10 @@ Component({
|
|
|
227
211
|
},
|
|
228
212
|
// 获取表单初始值
|
|
229
213
|
_initValue: async function () {
|
|
230
|
-
console.log('_initValue');
|
|
214
|
+
// console.log('_initValue');
|
|
231
215
|
const fetchVersion = (this.data._delayRef.current.version = Date.now());
|
|
232
|
-
const {
|
|
233
|
-
|
|
234
|
-
datasourceType,
|
|
235
|
-
dataSourceName,
|
|
236
|
-
_id,
|
|
237
|
-
methodGetItem,
|
|
238
|
-
paramGetItem,
|
|
239
|
-
} = this.properties;
|
|
240
|
-
const isDataModel = ![
|
|
241
|
-
'connector',
|
|
242
|
-
'custom-connector',
|
|
243
|
-
'expression',
|
|
244
|
-
].includes(datasourceType);
|
|
216
|
+
const { formType, datasourceType, dataSourceName, _id, methodGetItem, paramGetItem } = this.properties;
|
|
217
|
+
const isDataModel = !['connector', 'custom-connector', 'expression'].includes(datasourceType);
|
|
245
218
|
try {
|
|
246
219
|
const allSelectFields = this.getSelectFields();
|
|
247
220
|
let callDb = callDataSource;
|
|
@@ -261,10 +234,7 @@ Component({
|
|
|
261
234
|
|
|
262
235
|
if (
|
|
263
236
|
(datasourceType === 'expression' ||
|
|
264
|
-
(formTypeWithInitValue.includes(formType) &&
|
|
265
|
-
dataSourceName &&
|
|
266
|
-
methodName &&
|
|
267
|
-
params)) &&
|
|
237
|
+
(formTypeWithInitValue.includes(formType) && dataSourceName && methodName && params)) &&
|
|
268
238
|
callDb
|
|
269
239
|
) {
|
|
270
240
|
let initValue;
|
|
@@ -284,17 +254,10 @@ Component({
|
|
|
284
254
|
this.setReadonlyAttributes({ remoteValue: cleanInitValue });
|
|
285
255
|
}
|
|
286
256
|
this.setData({ isLoadingData: false });
|
|
287
|
-
if (
|
|
288
|
-
Object.keys(initValue).length !== 0 &&
|
|
289
|
-
fetchVersion === this.data._delayRef.current.version
|
|
290
|
-
) {
|
|
257
|
+
if (Object.keys(initValue).length !== 0 && fetchVersion === this.data._delayRef.current.version) {
|
|
291
258
|
const dataSourceProfile = await this.getDataSourceProfile();
|
|
292
259
|
|
|
293
|
-
const initFormData = convertRemoteValueToFormData(
|
|
294
|
-
datasourceType,
|
|
295
|
-
dataSourceProfile,
|
|
296
|
-
cleanInitValue
|
|
297
|
-
);
|
|
260
|
+
const initFormData = convertRemoteValueToFormData(datasourceType, dataSourceProfile, cleanInitValue);
|
|
298
261
|
const formDetailInitValue = this._initValueFormDetail();
|
|
299
262
|
const initValues = { ...formDetailInitValue, ...initFormData };
|
|
300
263
|
this.setValue(initValues);
|
|
@@ -374,11 +337,7 @@ Component({
|
|
|
374
337
|
// 获取表单字段权限
|
|
375
338
|
_initDataSourceFieldsWithAuth: async function () {
|
|
376
339
|
const { datasourceType, dataSourceName } = this.properties;
|
|
377
|
-
const isDataModel = ![
|
|
378
|
-
'connector',
|
|
379
|
-
'custom-connector',
|
|
380
|
-
'expression',
|
|
381
|
-
].includes(datasourceType);
|
|
340
|
+
const isDataModel = !['connector', 'custom-connector', 'expression'].includes(datasourceType);
|
|
382
341
|
const authValue = {
|
|
383
342
|
isDataModel,
|
|
384
343
|
dataSourceFields: undefined,
|
|
@@ -388,31 +347,23 @@ Component({
|
|
|
388
347
|
if (isDataModel && dataSourceName) {
|
|
389
348
|
const datasource = await getDataSourceByName(dataSourceName);
|
|
390
349
|
// 判断是否是预览区,编辑器编辑区 dataSourceName 查询的返回一致,编辑区用的本地的数据源数据返回固定
|
|
391
|
-
authValue.dataSourceFieldsWidthAuthList =
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
authValue.dataSourceFields = Object.keys(
|
|
396
|
-
datasource?.schema?.properties || {}
|
|
397
|
-
);
|
|
350
|
+
authValue.dataSourceFieldsWidthAuthList = datasource?.resourceCheckInfos
|
|
351
|
+
?.filter((item) => !item?.RelationField)
|
|
352
|
+
?.map((item) => item.ReadWrite);
|
|
353
|
+
authValue.dataSourceFields = Object.keys(datasource?.schema?.properties || {});
|
|
398
354
|
this.setData({ authValue, dataSourceProfile: datasource });
|
|
399
355
|
// this.triggerEvent('onInitDataSourceFieldsWithAuth', authValue);
|
|
400
356
|
}
|
|
401
357
|
} catch (err) {
|
|
402
358
|
console.error('getDataSourceFieldsWithAuth err', err);
|
|
403
|
-
this._alertError(
|
|
404
|
-
`获取数据源字段权限信息失败,字段权限可能无法正确展示,错误信息:${err}`
|
|
405
|
-
);
|
|
359
|
+
this._alertError(`获取数据源字段权限信息失败,字段权限可能无法正确展示,错误信息:${err}`);
|
|
406
360
|
}
|
|
407
361
|
},
|
|
408
362
|
updateFormContext: function () {
|
|
409
363
|
if (this._attached !== true) {
|
|
410
364
|
return;
|
|
411
365
|
}
|
|
412
|
-
const formData = getFormDataFromItemMap(
|
|
413
|
-
this.data._formItemMap,
|
|
414
|
-
this.data.formType
|
|
415
|
-
);
|
|
366
|
+
const formData = getFormDataFromItemMap(this.data._formItemMap, this.data.formType);
|
|
416
367
|
this.setData({ formData });
|
|
417
368
|
this.triggerEvent('onDataChange', {
|
|
418
369
|
data: JSON.parse(JSON.stringify(formData)),
|
|
@@ -420,11 +371,7 @@ Component({
|
|
|
420
371
|
},
|
|
421
372
|
getDataSourceProfile: async function () {
|
|
422
373
|
const { datasourceType, dataSourceName } = this.properties;
|
|
423
|
-
const isDataModel = ![
|
|
424
|
-
'connector',
|
|
425
|
-
'custom-connector',
|
|
426
|
-
'expression',
|
|
427
|
-
].includes(datasourceType);
|
|
374
|
+
const isDataModel = !['connector', 'custom-connector', 'expression'].includes(datasourceType);
|
|
428
375
|
if (isDataModel && dataSourceName) {
|
|
429
376
|
if (!isNil(this.data.dataSourceProfile)) {
|
|
430
377
|
// datasourceName 不能绑变量的,所以组件级别缓存
|
|
@@ -432,8 +379,7 @@ Component({
|
|
|
432
379
|
}
|
|
433
380
|
const datasource = await getDataSourceByName(dataSourceName);
|
|
434
381
|
this.setData({ dataSourceProfile: datasource });
|
|
435
|
-
this.setReadonlyAttributes &&
|
|
436
|
-
this.setReadonlyAttributes({ dataSourceProfile: datasource });
|
|
382
|
+
this.setReadonlyAttributes && this.setReadonlyAttributes({ dataSourceProfile: datasource });
|
|
437
383
|
return datasource;
|
|
438
384
|
}
|
|
439
385
|
return null;
|
|
@@ -506,22 +452,12 @@ Component({
|
|
|
506
452
|
},
|
|
507
453
|
initialValues: that.data.initialValues,
|
|
508
454
|
addFormItem(name, w) {
|
|
509
|
-
if (
|
|
510
|
-
isNil(name) ||
|
|
511
|
-
(typeof name === 'string' && name.length === 0)
|
|
512
|
-
) {
|
|
455
|
+
if (isNil(name) || (typeof name === 'string' && name.length === 0)) {
|
|
513
456
|
// name 没设置或为空串的时候不受表单容器控制
|
|
514
|
-
console.warn(
|
|
515
|
-
`组件 #${w?.id} 表单key(表单输入类组件 name 属性)没设置或为空串的时候不受表单容器控制`
|
|
516
|
-
);
|
|
457
|
+
console.warn(`组件 #${w?.id} 表单key(表单输入类组件 name 属性)没设置或为空串的时候不受表单容器控制`);
|
|
517
458
|
return noop;
|
|
518
459
|
}
|
|
519
|
-
if (
|
|
520
|
-
Object.prototype.hasOwnProperty.call(
|
|
521
|
-
that.data._formItemMap ?? {},
|
|
522
|
-
name
|
|
523
|
-
)
|
|
524
|
-
) {
|
|
460
|
+
if (Object.prototype.hasOwnProperty.call(that.data._formItemMap ?? {}, name)) {
|
|
525
461
|
that.data._formItemMap[name].push(w);
|
|
526
462
|
} else {
|
|
527
463
|
that.data._formItemMap[name] = [w];
|
|
@@ -530,9 +466,7 @@ Component({
|
|
|
530
466
|
_formItemMap: that.data._formItemMap,
|
|
531
467
|
});
|
|
532
468
|
return () => {
|
|
533
|
-
const removedArr = that.data._formItemMap[name].filter(
|
|
534
|
-
(item) => item !== w
|
|
535
|
-
);
|
|
469
|
+
const removedArr = that.data._formItemMap[name].filter((item) => item !== w);
|
|
536
470
|
if (removedArr.length <= 0) {
|
|
537
471
|
delete that.data._formItemMap[name];
|
|
538
472
|
} else {
|
|
@@ -551,10 +485,7 @@ Component({
|
|
|
551
485
|
} else {
|
|
552
486
|
this.setData({ errors: errorObj });
|
|
553
487
|
this.triggerEvent('validateFail', {
|
|
554
|
-
errors: getErrorObjectFromValidateResult(
|
|
555
|
-
errorObj,
|
|
556
|
-
this.data._formItemMap
|
|
557
|
-
),
|
|
488
|
+
errors: getErrorObjectFromValidateResult(errorObj, this.data._formItemMap),
|
|
558
489
|
});
|
|
559
490
|
throw errorObj;
|
|
560
491
|
}
|
|
@@ -620,77 +551,60 @@ Component({
|
|
|
620
551
|
this.setData({ _previousFormType: formType });
|
|
621
552
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
622
553
|
}, 1000),
|
|
623
|
-
'formType,datasourceType,dataSourceName,_id,methodGetItem,paramGetItem,value':
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
)
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
this.setData({ isLoadingData: true });
|
|
554
|
+
'formType,datasourceType,dataSourceName,_id,methodGetItem,paramGetItem,value': function (
|
|
555
|
+
formType,
|
|
556
|
+
datasourceType,
|
|
557
|
+
dataSourceName,
|
|
558
|
+
_id,
|
|
559
|
+
methodGetItem,
|
|
560
|
+
paramGetItem,
|
|
561
|
+
value,
|
|
562
|
+
) {
|
|
563
|
+
const isDataModel = !['connector', 'custom-connector', 'expression'].includes(datasourceType);
|
|
564
|
+
if (isDataModel && formTypeWithInitValue && _id && !equal(_id, this.data._preDataId)) {
|
|
565
|
+
this.setData({ isLoadingData: true });
|
|
566
|
+
}
|
|
567
|
+
clearTimeout(this.data._delayRef.current.initTimer);
|
|
568
|
+
// eslint-disable-next-line rulesdir/no-timer
|
|
569
|
+
this.data._delayRef.current.initTimer = setTimeout(() => {
|
|
570
|
+
if (!dataSourceName) {
|
|
571
|
+
this.setData({ loadingStatus: 'done' });
|
|
572
|
+
if (datasourceType !== 'expression') {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
645
575
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
this.setData({ loadingStatus: 'done' });
|
|
651
|
-
if (datasourceType !== 'expression') {
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
576
|
+
if (isDataModel) {
|
|
577
|
+
if (_id && !equal(_id, this.data._preDataId)) {
|
|
578
|
+
this.setData({ _preDataId: _id });
|
|
579
|
+
this._initValue();
|
|
654
580
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
if (
|
|
662
|
-
|
|
663
|
-
paramGetItem &&
|
|
664
|
-
!equal(paramGetItem, this.data.preParamGetItem)
|
|
665
|
-
) {
|
|
666
|
-
this.setData({ preParamGetItem: paramGetItem });
|
|
581
|
+
} else {
|
|
582
|
+
if (methodGetItem && paramGetItem && !equal(paramGetItem, this.data.preParamGetItem)) {
|
|
583
|
+
this.setData({ preParamGetItem: paramGetItem });
|
|
584
|
+
this._initValue();
|
|
585
|
+
}
|
|
586
|
+
if (datasourceType === 'expression') {
|
|
587
|
+
if (!isNil(value) && !equal(value, this.data.preValue)) {
|
|
588
|
+
this.setData({ preValue: value });
|
|
667
589
|
this._initValue();
|
|
668
590
|
}
|
|
669
|
-
if (datasourceType === 'expression') {
|
|
670
|
-
if (!isNil(value) && !equal(value, this.data.preValue)) {
|
|
671
|
-
this.setData({ preValue: value });
|
|
672
|
-
this._initValue();
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
591
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
},
|
|
592
|
+
}
|
|
593
|
+
// if (formType === 'create') {
|
|
594
|
+
// this._initValueFormDetail();
|
|
595
|
+
// }
|
|
596
|
+
// this._initDataSourceFieldsWithAuth();
|
|
597
|
+
}, debounceMs);
|
|
598
|
+
},
|
|
682
599
|
'_formItemMap, authValue': function (formItemMap, authValue) {
|
|
683
600
|
if (typeof authValue !== 'object') return;
|
|
684
|
-
const { isDataModel, dataSourceFieldsWidthAuthList = emptyArray } =
|
|
685
|
-
authValue;
|
|
601
|
+
const { isDataModel, dataSourceFieldsWidthAuthList = emptyArray } = authValue;
|
|
686
602
|
if (isDataModel) {
|
|
687
603
|
Object.keys(formItemMap).forEach((name) => {
|
|
688
604
|
const item = formItemMap[name];
|
|
689
|
-
const fieldPermissions = dataSourceFieldsWidthAuthList.filter(
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
}
|
|
693
|
-
);
|
|
605
|
+
const fieldPermissions = dataSourceFieldsWidthAuthList.filter((fieldPermission) => {
|
|
606
|
+
return fieldPermission[name];
|
|
607
|
+
});
|
|
694
608
|
if (fieldPermissions.length > 0) {
|
|
695
609
|
const fieldPermission = fieldPermissions[0][name];
|
|
696
610
|
if (fieldPermission === 'rw') {
|
|
@@ -725,18 +639,13 @@ Component({
|
|
|
725
639
|
authValue,
|
|
726
640
|
});
|
|
727
641
|
},
|
|
728
|
-
'dataSourceProfile, formData, formType, _id': function (
|
|
729
|
-
dataSourceProfile,
|
|
730
|
-
formData,
|
|
731
|
-
formType,
|
|
732
|
-
_id
|
|
733
|
-
) {
|
|
642
|
+
'dataSourceProfile, formData, formType, _id': function (dataSourceProfile, formData, formType, _id) {
|
|
734
643
|
const submitParams = convertFormDataToSubmitParams(
|
|
735
644
|
dataSourceProfile,
|
|
736
645
|
formData,
|
|
737
646
|
formType,
|
|
738
647
|
_id,
|
|
739
|
-
Object.keys(this.data._formItemMap)
|
|
648
|
+
Object.keys(this.data._formItemMap),
|
|
740
649
|
);
|
|
741
650
|
if (this.setReadonlyAttributes) {
|
|
742
651
|
this.setReadonlyAttributes({ submitParams });
|
|
@@ -1109,4 +1109,19 @@ textarea {
|
|
|
1109
1109
|
}
|
|
1110
1110
|
.wd-mp-form-item-obj .wd-form-item--weui.wd-form-item {
|
|
1111
1111
|
width: 100%;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
.wd-input-password-icon {
|
|
1115
|
+
padding: 0 5px;
|
|
1116
|
+
display: flex;
|
|
1117
|
+
cursor: pointer;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
.wd-pc-input-password-icon {
|
|
1121
|
+
position: absolute;
|
|
1122
|
+
right: -30px;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
.password-input .wd-form-item-wrap__control-wrap {
|
|
1126
|
+
position: relative;
|
|
1112
1127
|
}
|
|
@@ -1109,4 +1109,19 @@ textarea {
|
|
|
1109
1109
|
}
|
|
1110
1110
|
.wd-mp-form-item-obj .wd-form-item--weui.wd-form-item {
|
|
1111
1111
|
width: 100%;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
.wd-input-password-icon {
|
|
1115
|
+
padding: 0 5px;
|
|
1116
|
+
display: flex;
|
|
1117
|
+
cursor: pointer;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
.wd-pc-input-password-icon {
|
|
1121
|
+
position: absolute;
|
|
1122
|
+
right: -30px;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
.password-input .wd-form-item-wrap__control-wrap {
|
|
1126
|
+
position: relative;
|
|
1112
1127
|
}
|
|
@@ -1109,4 +1109,19 @@ textarea {
|
|
|
1109
1109
|
}
|
|
1110
1110
|
.wd-mp-form-item-obj .wd-form-item--weui.wd-form-item {
|
|
1111
1111
|
width: 100%;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
.wd-input-password-icon {
|
|
1115
|
+
padding: 0 5px;
|
|
1116
|
+
display: flex;
|
|
1117
|
+
cursor: pointer;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
.wd-pc-input-password-icon {
|
|
1121
|
+
position: absolute;
|
|
1122
|
+
right: -30px;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
.password-input .wd-form-item-wrap__control-wrap {
|
|
1126
|
+
position: relative;
|
|
1112
1127
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import itemBehavior from '../../form-field-behavior/item-behavior';
|
|
2
2
|
import { WD_PREFIX } from '../../../utils/constant';
|
|
3
|
-
import {
|
|
4
|
-
converValueFix,
|
|
5
|
-
convertSize,
|
|
6
|
-
converInputValue,
|
|
7
|
-
convertIconSize,
|
|
8
|
-
} from '../../../utils/getFormLegacy';
|
|
3
|
+
import { converValueFix, convertSize, converInputValue, convertIconSize } from '../../../utils/getFormLegacy';
|
|
9
4
|
import classNames from '../../../utils/classnames';
|
|
10
5
|
import equal from '../../../utils/deepEqual';
|
|
11
6
|
|
|
@@ -48,24 +43,13 @@ Component({
|
|
|
48
43
|
_size: 'md',
|
|
49
44
|
_oldValue: null,
|
|
50
45
|
_oldInputValue: null,
|
|
46
|
+
|
|
47
|
+
_password: false,
|
|
51
48
|
},
|
|
52
49
|
methods: {
|
|
53
50
|
convertDetail: function (e) {
|
|
54
|
-
const {
|
|
55
|
-
|
|
56
|
-
after,
|
|
57
|
-
type,
|
|
58
|
-
isUnionValue,
|
|
59
|
-
isConvert = true,
|
|
60
|
-
} = this.properties;
|
|
61
|
-
const value = converValueFix(
|
|
62
|
-
e.detail.value,
|
|
63
|
-
before,
|
|
64
|
-
after,
|
|
65
|
-
type,
|
|
66
|
-
isUnionValue,
|
|
67
|
-
isConvert
|
|
68
|
-
);
|
|
51
|
+
const { before, after, type, isUnionValue, isConvert = true } = this.properties;
|
|
52
|
+
const value = converValueFix(e.detail.value, before, after, type, isUnionValue, isConvert);
|
|
69
53
|
return { ...e.detail, value };
|
|
70
54
|
},
|
|
71
55
|
handleFocus: function (e) {
|
|
@@ -106,38 +90,20 @@ Component({
|
|
|
106
90
|
this.triggerEvent('changeForm', detail);
|
|
107
91
|
},
|
|
108
92
|
changeInput: function () {
|
|
109
|
-
const {
|
|
110
|
-
|
|
111
|
-
before,
|
|
112
|
-
after,
|
|
113
|
-
type,
|
|
114
|
-
isUnionValue,
|
|
115
|
-
isConvert = true,
|
|
116
|
-
} = this.properties;
|
|
117
|
-
const value = converValueFix(
|
|
118
|
-
inputValue,
|
|
119
|
-
before,
|
|
120
|
-
after,
|
|
121
|
-
type,
|
|
122
|
-
isUnionValue,
|
|
123
|
-
isConvert
|
|
124
|
-
);
|
|
93
|
+
const { inputValue, before, after, type, isUnionValue, isConvert = true } = this.properties;
|
|
94
|
+
const value = converValueFix(inputValue, before, after, type, isUnionValue, isConvert);
|
|
125
95
|
this.setData({ currentInputValue: inputValue });
|
|
126
96
|
this.changeForm({ value });
|
|
127
97
|
this.data._oldInputValue = inputValue;
|
|
128
98
|
},
|
|
99
|
+
changePasswordIcon: function () {
|
|
100
|
+
this.setData({ _password: !this.data._password });
|
|
101
|
+
},
|
|
129
102
|
},
|
|
130
103
|
observers: {
|
|
131
|
-
'disabled,clearable,isFocus,currentInputValue': function (
|
|
132
|
-
disabled
|
|
133
|
-
|
|
134
|
-
isFocus,
|
|
135
|
-
currentInputValue
|
|
136
|
-
) {
|
|
137
|
-
const hasClearIcon =
|
|
138
|
-
clearable && isFocus && !disabled && currentInputValue?.length > 0;
|
|
139
|
-
const counter =
|
|
140
|
-
typeof currentInputValue === 'string' ? currentInputValue.length : 0;
|
|
104
|
+
'disabled,clearable,isFocus,currentInputValue': function (disabled, clearable, isFocus, currentInputValue) {
|
|
105
|
+
const hasClearIcon = clearable && isFocus && !disabled && currentInputValue?.length > 0;
|
|
106
|
+
const counter = typeof currentInputValue === 'string' ? currentInputValue.length : 0;
|
|
141
107
|
this.setData({ hasClearIcon, counter });
|
|
142
108
|
},
|
|
143
109
|
'disabled,size,classRoot,wrapClassName,before,after': function (
|
|
@@ -146,7 +112,7 @@ Component({
|
|
|
146
112
|
classRoot,
|
|
147
113
|
wrapClassName,
|
|
148
114
|
before,
|
|
149
|
-
after
|
|
115
|
+
after,
|
|
150
116
|
) {
|
|
151
117
|
const _size = convertSize(size);
|
|
152
118
|
const iconSize = convertIconSize(_size);
|
|
@@ -166,7 +132,7 @@ Component({
|
|
|
166
132
|
[`${inputWrap}--no-radius-left`]: before,
|
|
167
133
|
[`${inputWrap}--no-radius-right`]: after,
|
|
168
134
|
[`${inputWrap}--no-radius`]: before && after,
|
|
169
|
-
}
|
|
135
|
+
},
|
|
170
136
|
);
|
|
171
137
|
const countCls = `${classPrefix}-input__limit-number`;
|
|
172
138
|
|
|
@@ -183,7 +149,7 @@ Component({
|
|
|
183
149
|
after,
|
|
184
150
|
this.properties.type,
|
|
185
151
|
isUnionValue,
|
|
186
|
-
this.properties.isConvert
|
|
152
|
+
this.properties.isConvert,
|
|
187
153
|
);
|
|
188
154
|
this.changeForm({ value });
|
|
189
155
|
},
|
|
@@ -191,15 +157,15 @@ Component({
|
|
|
191
157
|
value: function (value) {
|
|
192
158
|
if (equal(this.data._oldValue, value)) return;
|
|
193
159
|
const { before, after, isUnionValue } = this.properties;
|
|
194
|
-
const currentInputValue = converInputValue(
|
|
195
|
-
value,
|
|
196
|
-
before,
|
|
197
|
-
after,
|
|
198
|
-
isUnionValue
|
|
199
|
-
);
|
|
160
|
+
const currentInputValue = converInputValue(value, before, after, isUnionValue);
|
|
200
161
|
this.setData({ currentInputValue });
|
|
201
162
|
this.data._oldValue = value;
|
|
202
163
|
},
|
|
164
|
+
password: function (password) {
|
|
165
|
+
this.setData({
|
|
166
|
+
_password: password,
|
|
167
|
+
});
|
|
168
|
+
},
|
|
203
169
|
},
|
|
204
170
|
lifetimes: {
|
|
205
171
|
attached: function () {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
name="{{name}}"
|
|
46
46
|
auto-focus="{{focus}}"
|
|
47
47
|
focus="{{focus}}"
|
|
48
|
-
password="{{
|
|
48
|
+
password="{{_password}}"
|
|
49
49
|
maxlength="{{maxLength}}"
|
|
50
50
|
cursor-spacing="{{cursorSpacing}}"
|
|
51
51
|
bind:input="handleChange"
|
|
@@ -74,6 +74,10 @@
|
|
|
74
74
|
<label class="{{countCls}}">{{counter}}/{{maxLength}}</label>
|
|
75
75
|
</block>
|
|
76
76
|
</view>
|
|
77
|
-
|
|
77
|
+
</wd-input-group>
|
|
78
|
+
<view wx:if="{{password}}" class="{{classPrefix}}-input-password-icon">
|
|
79
|
+
<wd-icon name="{{_password?'td:browse-off':'td:browse'}}" size="{{iconSize}}" bind:tap="changePasswordIcon"></wd-icon>
|
|
80
|
+
</view>
|
|
81
|
+
|
|
78
82
|
</wd-form-item>
|
|
79
83
|
</block>
|
|
@@ -1273,6 +1273,21 @@ textarea {
|
|
|
1273
1273
|
width: 100%;
|
|
1274
1274
|
}
|
|
1275
1275
|
|
|
1276
|
+
.wd-input-password-icon {
|
|
1277
|
+
padding: 0 5px;
|
|
1278
|
+
display: flex;
|
|
1279
|
+
cursor: pointer;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
.wd-pc-input-password-icon {
|
|
1283
|
+
position: absolute;
|
|
1284
|
+
right: -30px;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
.password-input .wd-form-item-wrap__control-wrap {
|
|
1288
|
+
position: relative;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1276
1291
|
.wd-form-input-wrap {
|
|
1277
1292
|
--wd-form-input-wrap-border-radius: var(--wd-border-radius);
|
|
1278
1293
|
--wd-form-input-wrap-text-default: var(--wd-color-text-form-default);
|
|
@@ -1144,4 +1144,19 @@ textarea {
|
|
|
1144
1144
|
}
|
|
1145
1145
|
.wd-mp-form-item-obj .wd-form-item--weui.wd-form-item {
|
|
1146
1146
|
width: 100%;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
.wd-input-password-icon {
|
|
1150
|
+
padding: 0 5px;
|
|
1151
|
+
display: flex;
|
|
1152
|
+
cursor: pointer;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
.wd-pc-input-password-icon {
|
|
1156
|
+
position: absolute;
|
|
1157
|
+
right: -30px;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
.password-input .wd-form-item-wrap__control-wrap {
|
|
1161
|
+
position: relative;
|
|
1147
1162
|
}
|
|
@@ -1134,4 +1134,19 @@ textarea {
|
|
|
1134
1134
|
}
|
|
1135
1135
|
.wd-mp-form-item-obj .wd-form-item--weui.wd-form-item {
|
|
1136
1136
|
width: 100%;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
.wd-input-password-icon {
|
|
1140
|
+
padding: 0 5px;
|
|
1141
|
+
display: flex;
|
|
1142
|
+
cursor: pointer;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
.wd-pc-input-password-icon {
|
|
1146
|
+
position: absolute;
|
|
1147
|
+
right: -30px;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
.password-input .wd-form-item-wrap__control-wrap {
|
|
1151
|
+
position: relative;
|
|
1137
1152
|
}
|