@cloudbase/weda-ui-mp 3.15.8 → 3.17.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.
Files changed (29) hide show
  1. package/components/chart/ec-canvas/ec-canvas.js +1 -25
  2. package/components/form/select/dropdown-select/index.js +8 -0
  3. package/components/form/select/dropdown-select/index.wxml +1 -1
  4. package/components/form/selectMultiple/dropdown-select/index.js +15 -17
  5. package/components/form/selectMultiple/dropdown-select/index.wxml +1 -1
  6. package/components/form/selectMultiple/index.js +29 -7
  7. package/components/form/selectMultiple/index.wxml +2 -1
  8. package/components/form/uploaderFile/index.js +23 -220
  9. package/components/form/uploaderFile/upload.js +283 -0
  10. package/components/richText/copy/index.wxss +45 -48
  11. package/components/wd-ad/index.js +101 -5
  12. package/components/wd-ad/index.wxml +2 -0
  13. package/components/wd-select/index.js +18 -14
  14. package/components/wd-select/index.wxml +7 -3
  15. package/components/wd-select/select/dropdown-select/index.js +192 -0
  16. package/components/wd-select/select/dropdown-select/index.json +4 -0
  17. package/components/wd-select/select/dropdown-select/index.wxml +37 -0
  18. package/components/wd-select/select/dropdown-select/index.wxss +329 -0
  19. package/components/wd-select/select/formats-util.js +12 -1
  20. package/components/wd-select/select/index.js +208 -344
  21. package/components/wd-select/select/index.json +1 -1
  22. package/components/wd-select/select/index.wxml +16 -16
  23. package/components/wd-select-multiple/index.js +16 -8
  24. package/components/wd-select-multiple/index.json +1 -1
  25. package/components/wd-select-multiple/index.wxml +6 -2
  26. package/components/wd-upload-image/index.js +148 -4
  27. package/components/wd-upload-image/index.wxml +5 -0
  28. package/package.json +1 -1
  29. package/utils/platform.js +27 -8
@@ -0,0 +1,283 @@
1
+ import { transSize, randomStr } from '../../../utils/platform';
2
+ import { getCloudInstance, getDefaultUploadPath } from '../../../utils/tcb';
3
+
4
+ const ACTION = { CHOOSE_MEDIA: 'chooseMedia', CHOOSE_MESSAGE_FILE: 'chooseMessageFile' };
5
+
6
+ // 选择文件
7
+ const chooseFile = ({ action = 'CHOOSE_MEDIA', config, success, fail }) => {
8
+ let _config = { count: 9, maxDuration: 60 };
9
+
10
+ switch (action) {
11
+ case ACTION['CHOOSE_MEDIA']:
12
+ _config = {
13
+ mediaType: ['image'],
14
+ sourceType: ['album'],
15
+ ...config,
16
+ };
17
+ break;
18
+ case ACTION['CHOOSE_MESSAGE_FILE']:
19
+ _config = {
20
+ type: 'all',
21
+ ...config,
22
+ };
23
+ break;
24
+ default:
25
+ _config = { ...config };
26
+ break;
27
+ }
28
+
29
+ wx[ACTION[action]]({
30
+ ..._config,
31
+ success,
32
+ fail,
33
+ });
34
+ };
35
+
36
+ export const getName = (hf) => {
37
+ const uuidReg = /[0-9a-f]{8}([0-9a-f]{4}){3}[0-9a-f]{12}-/;
38
+ const lastIndex = String(hf).lastIndexOf('/');
39
+ const name = String(hf).slice(lastIndex + 1);
40
+ const label = name.replace(uuidReg, '');
41
+ return label;
42
+ };
43
+
44
+ // 批量上传文件前置事件
45
+ const handleBefore = (files, uploadInstance) => {
46
+ const { count: maxCount, maxSize } = uploadInstance.config;
47
+ const previewFile = uploadInstance.getPreviewFile();
48
+ if (previewFile.length + files.length > maxCount) {
49
+ wx.showToast({
50
+ title: `上传文件总数不能超过${maxCount}个`,
51
+ icon: 'none',
52
+ duration: 2000,
53
+ });
54
+ return false;
55
+ }
56
+ if (maxSize && files.some((f) => f.size > maxSize * 1024 * 1024)) {
57
+ wx.showToast({
58
+ title: `上传文件大小不能超过${maxSize}M`,
59
+ icon: 'none',
60
+ duration: 2000,
61
+ });
62
+ return false;
63
+ }
64
+ return true;
65
+ };
66
+
67
+ // 上传
68
+ export const handleUpload = async (files, uploadInstance, reload = false) => {
69
+ if (!handleBefore(files, uploadInstance)) return;
70
+
71
+ let shouldUploadToCos = true;
72
+ if (typeof uploadInstance?.beforeUpload === 'function') {
73
+ try {
74
+ const mgr = wx.getFileSystemManager();
75
+ const ret = await uploadInstance.beforeUpload({
76
+ tempFilePaths: files.map((f) => f.path || f.tempFilePath),
77
+ base64Uri: files.map((f) => {
78
+ const content = mgr.readFileSync(f.path || f.tempFilePath);
79
+ return `data:;base64,${wx.arrayBufferToBase64(content)}`;
80
+ }),
81
+ });
82
+ if (typeof ret === 'boolean') {
83
+ shouldUploadToCos = ret;
84
+ } else if (Array.isArray(ret) && ret.every((i) => typeof i === 'string')) {
85
+ files = ret.map((path, idx) => {
86
+ files[idx].path = path;
87
+ });
88
+ }
89
+ } catch (err) {
90
+ console.error('上传前处理函数抛错', err);
91
+ shouldUploadToCos = false;
92
+ }
93
+ }
94
+ if (!shouldUploadToCos) {
95
+ return;
96
+ }
97
+
98
+ const initFiles = files.map((i) => ({
99
+ ...i,
100
+ percent: '0',
101
+ cloudPath: null,
102
+ name: i?.name || getName(i?.tempFilePath),
103
+ filePath: i?.path || i?.tempFilePath || null,
104
+ size: transSize(i?.size),
105
+ status: 'pending',
106
+ }));
107
+ const previewFile = uploadInstance.getPreviewFile();
108
+ let filelsList = reload ? previewFile : [...previewFile, ...initFiles];
109
+ // 更新预览文件
110
+ uploadInstance.updatePreviewFile(filelsList);
111
+ return Promise.all(
112
+ initFiles.map(async (tempFile) => {
113
+ return new Promise(function (resolve) {
114
+ handleUploadFile({
115
+ uploadPath: uploadInstance.config.uploadPath,
116
+ customUploadPath: uploadInstance.config.customUploadPath,
117
+ _tempFile: tempFile,
118
+ onSuccess: (res) => {
119
+ filelsList = filelsList.map((i) => (i.filePath === res.filePath ? res : i));
120
+ uploadInstance.updatePreviewFile(filelsList);
121
+ uploadInstance.onSuccess(res);
122
+ resolve(res);
123
+ },
124
+ onProgressUpdate: (res) => {
125
+ filelsList = filelsList.map((i) => (i.filePath === res.filePath ? res : i));
126
+ uploadInstance.updatePreviewFile(filelsList);
127
+ },
128
+ onFail: (res, error) => {
129
+ filelsList = filelsList.map((i) => (i.filePath === res.filePath ? res : i));
130
+ uploadInstance.updatePreviewFile(filelsList);
131
+ uploadInstance.onFail(res, error);
132
+ resolve(res);
133
+ },
134
+ });
135
+ });
136
+ }),
137
+ ).then((res) => {
138
+ const result = filelsList.map((i) => res.find((j) => j.filePath === i.filePath) || i);
139
+
140
+ uploadInstance.onComplete(result);
141
+ });
142
+ };
143
+
144
+ //
145
+ const sanitizeFilename = (filename, replacement = '') => {
146
+ return (
147
+ filename
148
+ // 移除非法字符
149
+ // eslint-disable-next-line no-control-regex
150
+ .replace(/[<>.:"\\|?*\x00-\x1F]/g, replacement)
151
+ // 处理Windows保留文件名(CON, PRN等)
152
+ .replace(/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\..*)?$/i, replacement)
153
+ // 移除开头和结尾的点,空格,反斜杠(Windows不允许)
154
+ .replace(/^[. /]+/, '')
155
+ .replace(/[. /]+$/, '')
156
+ // 可选:限制长度
157
+ .slice(0, 255)
158
+ );
159
+ };
160
+ // 上传到云存储
161
+ const handleUploadFile = async ({
162
+ uploadPath = 'weda-uploader',
163
+ _tempFile,
164
+ onSuccess,
165
+ onProgressUpdate,
166
+ onFail,
167
+ customUploadPath,
168
+ }) => {
169
+ const tempFile = {
170
+ ..._tempFile,
171
+ };
172
+ let _uploadPath = await getDefaultUploadPath(uploadPath);
173
+ if (customUploadPath) {
174
+ _uploadPath = `${_uploadPath}/${sanitizeFilename(customUploadPath, '')}`;
175
+ }
176
+ const filenameRegex = /[^a-zA-Z0-9\u4e00-\u9fff-*!_.]/g;
177
+ const cloudPath = `${_uploadPath}/${randomStr()}-${tempFile.name?.replace(filenameRegex, '-')}`;
178
+ try {
179
+ const tcb = await getCloudInstance();
180
+ const uploadTask = await tcb.uploadFile({
181
+ cloudPath: cloudPath,
182
+ filePath: tempFile.path || tempFile.tempFilePath,
183
+ success(res) {
184
+ tempFile.cloudPath = res.fileID;
185
+ tempFile.percent = 100;
186
+ tempFile.status = 'success';
187
+ if (onSuccess) {
188
+ onSuccess(tempFile);
189
+ }
190
+ },
191
+ fail(e) {
192
+ tempFile.status = 'fail';
193
+ wx.showModal({
194
+ title: '上传失败,请重试',
195
+ content: e.message,
196
+ showCancel: false,
197
+ });
198
+ onFail(tempFile, e);
199
+ },
200
+ });
201
+ if (typeof uploadTask.onProgressUpdate === 'function') {
202
+ uploadTask.onProgressUpdate((res) => {
203
+ tempFile.percent = String(res.progress);
204
+ tempFile.status = res.progress == 100 ? 'success' : 'uploading';
205
+ tempFile.uploaded = transSize(res.totalBytesSent);
206
+ if (onProgressUpdate) {
207
+ onProgressUpdate(tempFile);
208
+ }
209
+ });
210
+ } else {
211
+ tempFile.percent = '100';
212
+ tempFile.status = 'success';
213
+ tempFile.cloudPath = uploadTask.fileID;
214
+ onSuccess(tempFile);
215
+ }
216
+ } catch (e) {
217
+ tempFile.status = 'fail';
218
+ wx.showModal({
219
+ title: '上传失败,请重试',
220
+ content: e.message,
221
+ showCancel: false,
222
+ });
223
+ if (onFail) {
224
+ onFail(tempFile, e);
225
+ }
226
+ }
227
+ };
228
+
229
+ export const upload = (uploadInstance) => {
230
+ const { config, onSuccess, onFail } = uploadInstance;
231
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
232
+ const { action, disabled, maxSize, ..._config } = config;
233
+ if (disabled) return;
234
+ const success = (res) => {
235
+ const result = handleUpload(res.tempFiles, uploadInstance);
236
+ onSuccess(result);
237
+ };
238
+ const fail = (e) => {
239
+ onFail(e);
240
+ };
241
+
242
+ chooseFile({ action, config: _config, success, fail });
243
+ };
244
+
245
+ export const initUploadInstance = ({ action, config, previewFile }, _this) => {
246
+ let uploadInstance = {
247
+ action,
248
+ config: { disabled: false, maxSize: 500, count: 9, maxDuration: 60, ...config },
249
+ previewFile,
250
+ updatePreviewFile(files) {
251
+ _this.setData({ files });
252
+ },
253
+ getPreviewFile() {
254
+ const { files } = _this.data;
255
+ return files;
256
+ },
257
+ onComplete(result) {
258
+ const cloudPathList = result.filter((i) => i.cloudPath).map((j) => j.cloudPath);
259
+ _this.setData({
260
+ files: result,
261
+ urls: cloudPathList,
262
+ cloudFile: cloudPathList,
263
+ });
264
+ let _value = cloudPathList;
265
+ if (_this.data.single) {
266
+ _value = cloudPathList[0] ?? '';
267
+ }
268
+ _this.handleChange(_value);
269
+ },
270
+ onSuccess(res) {
271
+ _this.triggerEvent('success', {
272
+ value: res.cloudPath,
273
+ file: res,
274
+ });
275
+ },
276
+ onFail(e) {
277
+ _this.triggerEvent('error', e);
278
+ },
279
+ beforeUpload: _this.data.callbacks?.beforeUpload,
280
+ };
281
+
282
+ return uploadInstance;
283
+ };
@@ -1,49 +1,46 @@
1
1
  @font-face {
2
- font-family: WdTd;
3
- src: url("t.eot"), url("t_iefix.eot") format("embedded-opentype"),
4
- url("t.woff") format("woff"), url("t.ttf") format("truetype"),
5
- url("t.svg") format("svg"),
6
- url("https://comp-public-replace-1303824488-cos.weda.tencent.com/icon/0.0.7/t.eot"),
7
- url("https://comp-public-replace-1303824488-cos.weda.tencent.com/icon/0.0.7/t_iefix.eot")
8
- format("embedded-opentype"),
9
- url("https://comp-public-replace-1303824488-cos.weda.tencent.com/icon/0.0.7/t.woff")
10
- format("woff"),
11
- url("https://comp-public-replace-1303824488-cos.weda.tencent.com/icon/0.0.7/t.ttf")
12
- format("truetype"),
13
- url("https://comp-public-replace-1303824488-cos.weda.tencent.com/icon/0.0.7/t.svg")
14
- format("svg");
15
- font-weight: 400;
16
- font-style: normal;
17
- }
18
- .wd-markdown {
19
- padding: 1rem;
20
- }
21
- .markdown-it-code-wrap {
22
- position: relative;
23
- }
24
- .markdown-it-code-copy {
25
- font-family: WdTd !important;
26
- vertical-align: middle;
27
- font-size: 14px;
28
- border: none;
29
- background: transparent;
30
- position: absolute; top: 7.5px; right: 6px; cursor: pointer; outline: none;
31
- }
32
- i.markdown-it-code-copy {
33
- font-style: normal;
34
- }
35
- .markdown-it-code-copy::before {
36
- content: '\E1AC';
37
- position: absolute;
38
- top: 0;
39
- right: 0;
40
- cursor: pointer;
41
- width: 20px;
42
- height: 20px;
43
- display: inline-block;
44
- text-align: center;
45
- }
46
- .markdown-it-code-copy:hover::before {
47
- background: #eef1f4;
48
- }
49
-
2
+ font-family: WdTd;
3
+ src: url('t.eot'), url('t_iefix.eot') format('embedded-opentype'), url('t.woff') format('woff'),
4
+ url('t.ttf') format('truetype'), url('t.svg') format('svg'),
5
+ url('https://comp-public-replace-1303824488-cos.weda.tencent.com/icon/0.0.7/t.eot'),
6
+ url('https://comp-public-replace-1303824488-cos.weda.tencent.com/icon/0.0.7/t_iefix.eot')
7
+ format('embedded-opentype'),
8
+ url('https://comp-public-replace-1303824488-cos.weda.tencent.com/icon/0.0.7/t.woff') format('woff'),
9
+ url('https://comp-public-replace-1303824488-cos.weda.tencent.com/icon/0.0.7/t.ttf') format('truetype'),
10
+ url('https://comp-public-replace-1303824488-cos.weda.tencent.com/icon/0.0.7/t.svg') format('svg');
11
+ font-weight: 400;
12
+ font-style: normal;
13
+ }
14
+ .wd-markdown {
15
+ padding: 1rem;
16
+ }
17
+ .markdown-it-code-wrap {
18
+ position: relative;
19
+ }
20
+ .markdown-it-code-copy {
21
+ font-family: WdTd !important;
22
+ vertical-align: middle;
23
+ font-size: 14px;
24
+ border: none;
25
+ background: transparent;
26
+ position: absolute;
27
+ top: 7.5px;
28
+ right: 6px;
29
+ outline: none;
30
+ }
31
+ i.markdown-it-code-copy {
32
+ font-style: normal;
33
+ }
34
+ .markdown-it-code-copy::before {
35
+ content: '\E1AC';
36
+ position: absolute;
37
+ top: 0;
38
+ right: 0;
39
+ width: 20px;
40
+ height: 20px;
41
+ display: inline-block;
42
+ text-align: center;
43
+ }
44
+ .markdown-it-code-copy:hover::before {
45
+ background: #eef1f4;
46
+ }
@@ -2,6 +2,8 @@
2
2
  import handleEvents from '../../utils/handleEvents';
3
3
  import { commonCompBehavior } from '../../utils/common-behavior';
4
4
  import { WD_PREFIX } from '../../utils/constant';
5
+ import { compareVersion } from '../../utils/platform';
6
+ import { errorHandler } from '../../utils/error';
5
7
 
6
8
  Component({
7
9
  options: { virtualHost: true },
@@ -37,12 +39,21 @@ Component({
37
39
  type: Number,
38
40
  value: 5,
39
41
  },
42
+ multiton: {
43
+ type: Boolean,
44
+ value: false,
45
+ },
46
+ disableFallbackSharePage: {
47
+ type: Boolean,
48
+ value: false,
49
+ },
40
50
  },
41
51
  data: {
42
52
  _adType: 'banner',
43
53
  _gridCount: 5,
44
54
  _adIntervals: null,
45
55
  classPrefix: WD_PREFIX,
56
+ rewardedVideoAd: null,
46
57
  },
47
58
  methods: {
48
59
  ...handleEvents([
@@ -50,17 +61,102 @@ Component({
50
61
  { name: 'error', title: '广告加载失败' },
51
62
  { name: 'close', title: '广告被关闭' },
52
63
  ]),
64
+ checkSdkVersion() {
65
+ let canUseRewardedVideoAd = true;
66
+ if (wx.canIUse('getAppBaseInfo')) {
67
+ const appBaseInfo = wx.getAppBaseInfo();
68
+ canUseRewardedVideoAd = compareVersion(appBaseInfo.SDKVersion, '2.8.1') >= 0;
69
+ } else {
70
+ const version = wx.getSystemInfoSync().SDKVersion;
71
+ canUseRewardedVideoAd = compareVersion(version, '2.8.1') >= 0;
72
+ }
73
+ return canUseRewardedVideoAd;
74
+ },
75
+ createRewardedVideoAd() {
76
+ if (this.data.rewardedVideoAd) {
77
+ this.destroy();
78
+ }
79
+ const canUseRewardedVideoAd = this.checkSdkVersion();
80
+
81
+ if (wx.createRewardedVideoAd && canUseRewardedVideoAd) {
82
+ const { unitId, multiton, disableFallbackSharePage } = this.data;
83
+ const rewardedVideoAd = wx.createRewardedVideoAd({ adUnitId: unitId, multiton, disableFallbackSharePage });
84
+ rewardedVideoAd.onLoad(() => {
85
+ this.triggerEvent('load');
86
+ });
87
+ rewardedVideoAd.onError((error) => {
88
+ const { comErrorInfo } = errorHandler({
89
+ id: this.id,
90
+ code: 'WdAd.createRewardedVideoAd',
91
+ error: error,
92
+ });
93
+ this.triggerEvent('error', { error: comErrorInfo });
94
+ });
95
+ rewardedVideoAd.onClose((res) => {
96
+ this.triggerEvent('close', res);
97
+ });
98
+ this.setData({ rewardedVideoAd });
99
+ } else {
100
+ const { comErrorInfo } = errorHandler({
101
+ id: this.id,
102
+ code: 'WdAd.createRewardedVideoAd',
103
+ message: '当前基础库版本低于2.8.1,不支持激励视频广告功能',
104
+ });
105
+ this.triggerEvent('error', { error: comErrorInfo });
106
+ }
107
+ },
108
+ destroy() {
109
+ this.data.rewardedVideoAd?.destroy();
110
+ this.setData({
111
+ rewardedVideoAd: null,
112
+ });
113
+ },
114
+ show() {
115
+ const { rewardedVideoAd } = this.data;
116
+ rewardedVideoAd?.show().catch(() => {
117
+ rewardedVideoAd
118
+ .load()
119
+ .then(() => rewardedVideoAd.show())
120
+ .catch((error) => {
121
+ const { comErrorInfo } = errorHandler({
122
+ id: this.id,
123
+ code: 'WdAd.showRewardedVideoAd',
124
+ error: error,
125
+ });
126
+ this.triggerEvent('error', { error: comErrorInfo });
127
+ });
128
+ });
129
+ },
130
+ updateWidgetAPI() {
131
+ this.setReadonlyAttributes?.({
132
+ rewardedVideoAd: this.data.rewardedVideoAd,
133
+ show: this.show.bind(this),
134
+ });
135
+ },
53
136
  },
54
137
  observers: {
55
138
  // 规范取值
56
139
  'adType,adIntervals,gridCount': function (adType, adIntervals, gridCount) {
57
- const _adType = ['banner', 'video', 'grid'].includes(adType)
58
- ? adType
59
- : 'banner';
60
- const _adIntervals =
61
- Number(adIntervals) >= 30 ? Number(adIntervals) : null;
140
+ const _adType = ['banner', 'video', 'grid', 'rewardedVideoAd'].includes(adType) ? adType : 'banner';
141
+ const _adIntervals = Number(adIntervals) >= 30 ? Number(adIntervals) : null;
62
142
  const _gridCount = gridCount == 8 ? 8 : 5;
63
143
  this.setData({ _adType, _gridCount, _adIntervals });
64
144
  },
145
+ rewardedVideoAd: function () {
146
+ this.updateWidgetAPI();
147
+ },
148
+ 'adType,unitId,multiton,disableFallbackSharePage': function () {
149
+ this.createRewardedVideoAd();
150
+ },
151
+ },
152
+ lifetimes: {
153
+ attached() {
154
+ if (this.data.adType === 'rewardedVideoAd') {
155
+ this.createRewardedVideoAd();
156
+ }
157
+ },
158
+ detached() {
159
+ this.destroy();
160
+ },
65
161
  },
66
162
  });
@@ -1,3 +1,5 @@
1
1
  <view id="{{id}}" style="{{style}}" class="{{classPrefix}}-ad {{classPrefix}}-mp-ad {{classPrefix}}-ad--{{_adType}} {{className}} ">
2
+ <block wx:if="{{_adType!=='rewardedVideoAd'}}">
2
3
  <ad unit-id="{{unitId}}" ad-intervals="{{_adIntervals}}" ad-type="{{_adType}}" ad-theme="{{adTheme}}" grid-count="{{_gridCount}}" bindload="load" binderror="error" bindclose="close"></ad>
4
+ </block>
3
5
  </view>
@@ -3,10 +3,10 @@ import formFieldBehavior from '../form-field-behavior/form-field-behavior';
3
3
  import itemBehavior from '../form-field-behavior/item-behavior';
4
4
  import { convertFixedIcon, SELECT_ICON_H5 } from '../../utils/getFormLegacy';
5
5
  import debounce from '../../utils/debounce';
6
- import { safeObj, arrayToMap, getSelected } from '../../utils/tool';
6
+ import { arrayToMap, getSelected } from '../../utils/tool';
7
7
 
8
8
  Component({
9
- options: { virtualHost: true },
9
+ options: { virtualHost: true, styleIsolation: 'shared' },
10
10
  behaviors: [itemBehavior, commonCompBehavior, formFieldBehavior],
11
11
  properties: {
12
12
  classRoot: {
@@ -25,9 +25,16 @@ Component({
25
25
  type: Array,
26
26
  value: [],
27
27
  },
28
+ searchable: {
29
+ type: Boolean,
30
+ value: true,
31
+ },
32
+ filterable: {
33
+ type: Boolean,
34
+ value: false,
35
+ },
28
36
  },
29
37
  data: {
30
- options: [],
31
38
  itemMap: {},
32
39
  selectedLabel: null,
33
40
  selectedItem: null,
@@ -45,16 +52,18 @@ Component({
45
52
  });
46
53
  this.updateWidgetAPI();
47
54
  },
48
- changeOptions: function (e) {
49
- const { options } = safeObj(e.detail.value);
50
- this.setData({ options });
51
- },
52
55
  search: function (e) {
53
56
  this.debouncedTriggerSearchEvent(e.detail.value);
54
57
  },
55
58
  debouncedTriggerSearchEvent: debounce(function (value) {
56
59
  this.triggerEvent('search', { value });
57
60
  }),
61
+ updateSelect: function (e) {
62
+ const { value, option } = e.detail;
63
+ const itemMap = arrayToMap(option, 'value');
64
+ const { selectedLabel, selectedItem } = getSelected(itemMap, value, false);
65
+ this.setData({ selectedLabel, selectedItem });
66
+ },
58
67
  },
59
68
  observers: {
60
69
  'name, value, label, required, visible, disabled, readOnly, before, after, primaryField, selectedLabel, selectedItem':
@@ -65,13 +74,8 @@ Component({
65
74
  const [_suffixType, _suffixIcon] = convertFixedIcon(suffixType, suffixIcon, SELECT_ICON_H5);
66
75
  this.setData({ _suffixType, _suffixIcon });
67
76
  },
68
- options: function (options) {
69
- const itemMap = arrayToMap(options, 'value');
70
- this.setData({ itemMap });
71
- },
72
- 'itemMap, value': function (itemMap, value) {
73
- const { selectedLabel, selectedItem } = getSelected(itemMap, value, false);
74
- this.setData({ selectedLabel, selectedItem });
77
+ range: function (range) {
78
+ this.updateSelect({ detail: { value: this.data.value, option: range } });
75
79
  },
76
80
  },
77
81
  lifetimes: {
@@ -22,6 +22,9 @@
22
22
  <wd-input-group before="{{before}}" after="{{after}}" block="{{true}}" size="{{_size}}" classRoot="{{classRoot}}" readOnly="{{readOnly}}">
23
23
  <wd-input-wrap block="{{block}}" classRoot="{{classRoot}}" before="{{before}}" after="{{after}}" disabled="{{disabled}}" prefixType="{{prefixType}}" prefixIcon="{{prefixIcon}}" prefixSrc="{{prefixSrc}}" suffixType="{{_suffixType}}" suffixIcon="{{_suffixIcon}}" suffixSrc="{{suffixSrc}}" hasClearIcon="{{hasClearIcon}}" bind:onClear="handleClear" readOnly="{{readOnly}}">
24
24
  <old-select
25
+ multiple="{{false}}"
26
+ searchable="{{searchable}}"
27
+ filterable="{{filterable}}"
25
28
  supportManyRelated="{{supportManyRelated}}"
26
29
  queryCondition="{{queryCondition}}"
27
30
  sorter="{{sorter}}"
@@ -30,7 +33,7 @@
30
33
  label=""
31
34
  defaultValue="{{value}}"
32
35
  enumName="{{enumName}}"
33
- format="{{format === 'many-one' ? 'father-son' : format}}"
36
+ format="{{format}}"
34
37
  placeholder="{{placeholder}}"
35
38
  primaryField="{{primaryField}}"
36
39
  range="{{range}}"
@@ -44,10 +47,11 @@
44
47
  version="wd"
45
48
  mode="selector"
46
49
  ignoreCase="{{ignoreCase}}"
47
- staticSearchable="{{staticSearchable}}"
48
50
  bind:change="handleChange"
49
- bind:changeOptions="changeOptions"
51
+ bind:updateSelect="updateSelect"
50
52
  bind:search="search"
53
+ bind:focus="handleEvent"
54
+ bind:blur="handleEvent"
51
55
  />
52
56
  </wd-input-wrap>
53
57
  </wd-input-group>