@vtj/materials 0.10.6 → 0.10.7
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/dist/assets/antdv/index.umd.js +2 -2
- package/dist/assets/charts/index.umd.js +2 -2
- package/dist/assets/element/index.umd.js +2 -2
- package/dist/assets/ui/index.umd.js +2 -2
- package/dist/assets/uni-h5/index.umd.js +3 -3
- package/dist/assets/uni-ui/index.umd.js +3 -3
- package/dist/assets/vant/index.umd.js +2 -2
- package/dist/deps/@vtj/charts/index.umd.js +2 -2
- package/dist/deps/@vtj/icons/index.umd.js +2 -2
- package/dist/deps/@vtj/ui/index.umd.js +3 -3
- package/dist/deps/@vtj/utils/index.umd.js +20 -20
- package/dist/deps/@vueuse/core/index.iife.min.js +1 -1
- package/dist/deps/uni-ui/index.umd.js +1 -1
- package/dist/deps/uni-ui/style.css +1 -1
- package/package.json +7 -7
- package/src/uni-h5/components/input.ts +2 -2
- package/src/uni-h5/components/scrollView.ts +3 -3
- package/src/uni-h5/components/video.ts +1 -1
- package/src/uni-ui/components/badge.ts +1 -5
- package/src/uni-ui/components/breadcrumb.ts +1 -20
- package/src/uni-ui/components/collapse.ts +22 -23
- package/src/uni-ui/components/grid.ts +0 -9
- package/src/uni-ui/components/group.ts +1 -10
- package/src/uni-ui/components/index.ts +4 -4
- package/src/uni-ui/components/popup.ts +10 -2
- package/src/uni-ui/components/swiperDot.ts +21 -7
- package/src/uni-ui/components/table.ts +9 -3
- package/src/uni-ui/components/transition.ts +10 -1
- package/src/uni-ui/index.ts +19 -44
- package/src/uni-ui/lib/uni-collapse/uni-collapse.vue +153 -0
- package/src/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +425 -0
- package/src/uni-ui/lib/uni-data-picker/keypress.js +45 -0
- package/src/uni-ui/lib/uni-data-picker/uni-data-picker.vue +604 -0
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +622 -0
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.css +76 -0
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +335 -0
- package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +181 -170
- package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +977 -939
- package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +1024 -932
- package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +15 -17
- package/src/uni-ui/lib/uni-datetime-picker/util.js +419 -392
- package/src/uni-ui/lib/uni-fav/i18n/en.json +4 -0
- package/src/uni-ui/lib/uni-fav/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-fav/i18n/zh-Hans.json +4 -0
- package/src/uni-ui/lib/uni-fav/i18n/zh-Hant.json +4 -0
- package/src/uni-ui/lib/uni-fav/uni-fav.vue +170 -0
- package/src/uni-ui/lib/uni-file-picker/choose-and-upload-file.js +280 -0
- package/src/uni-ui/lib/uni-file-picker/uni-file-picker.vue +668 -0
- package/src/uni-ui/lib/uni-file-picker/upload-file.vue +325 -0
- package/src/uni-ui/lib/uni-file-picker/upload-image.vue +292 -0
- package/src/uni-ui/lib/uni-file-picker/utils.js +110 -0
- package/src/uni-ui/lib/uni-grid/uni-grid.vue +148 -0
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +152 -128
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +50 -50
- package/src/uni-ui/lib/uni-load-more/i18n/en.json +5 -0
- package/src/uni-ui/lib/uni-load-more/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-load-more/i18n/zh-Hans.json +5 -0
- package/src/uni-ui/lib/uni-load-more/i18n/zh-Hant.json +5 -0
- package/src/uni-ui/lib/uni-load-more/uni-load-more.vue +456 -0
- package/src/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +484 -0
- package/src/uni-ui/lib/uni-popup/uni-popup.vue +4 -4
- package/src/uni-ui/lib/uni-popup-message/uni-popup-message.vue +149 -0
- package/src/uni-ui/lib/uni-rate/uni-rate.vue +362 -343
- package/src/uni-ui/lib/uni-row/uni-row.vue +193 -0
- package/src/uni-ui/lib/uni-search-bar/i18n/en.json +4 -0
- package/src/uni-ui/lib/uni-search-bar/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hans.json +4 -0
- package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hant.json +4 -0
- package/src/uni-ui/lib/uni-search-bar/uni-search-bar.vue +339 -0
- package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +294 -285
- package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +8 -9
- package/src/uni-ui/lib/uni-th/filter-dropdown.vue +551 -503
- package/src/uni-ui/lib/uni-tr/table-checkbox.vue +165 -163
- package/src/uni-ui/lib/uni-tr/uni-tr.vue +6 -6
- package/src/uni-ui/lib/uni-transition/createAnimation.js +131 -0
- package/src/uni-ui/lib/uni-transition/uni-transition.vue +310 -0
- package/src/version.ts +2 -2
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
localdata: {
|
|
4
|
+
type: [Array, Object],
|
|
5
|
+
default () {
|
|
6
|
+
return []
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
spaceInfo: {
|
|
10
|
+
type: Object,
|
|
11
|
+
default () {
|
|
12
|
+
return {}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
collection: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: ''
|
|
18
|
+
},
|
|
19
|
+
action: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: ''
|
|
22
|
+
},
|
|
23
|
+
field: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: ''
|
|
26
|
+
},
|
|
27
|
+
orderby: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: ''
|
|
30
|
+
},
|
|
31
|
+
where: {
|
|
32
|
+
type: [String, Object],
|
|
33
|
+
default: ''
|
|
34
|
+
},
|
|
35
|
+
pageData: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: 'add'
|
|
38
|
+
},
|
|
39
|
+
pageCurrent: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 1
|
|
42
|
+
},
|
|
43
|
+
pageSize: {
|
|
44
|
+
type: Number,
|
|
45
|
+
default: 500
|
|
46
|
+
},
|
|
47
|
+
getcount: {
|
|
48
|
+
type: [Boolean, String],
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
getone: {
|
|
52
|
+
type: [Boolean, String],
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
55
|
+
gettree: {
|
|
56
|
+
type: [Boolean, String],
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
manual: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: false
|
|
62
|
+
},
|
|
63
|
+
value: {
|
|
64
|
+
type: [Array, String, Number],
|
|
65
|
+
default () {
|
|
66
|
+
return []
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
modelValue: {
|
|
70
|
+
type: [Array, String, Number],
|
|
71
|
+
default () {
|
|
72
|
+
return []
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
preload: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
79
|
+
stepSearh: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: true
|
|
82
|
+
},
|
|
83
|
+
selfField: {
|
|
84
|
+
type: String,
|
|
85
|
+
default: ''
|
|
86
|
+
},
|
|
87
|
+
parentField: {
|
|
88
|
+
type: String,
|
|
89
|
+
default: ''
|
|
90
|
+
},
|
|
91
|
+
multiple: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false
|
|
94
|
+
},
|
|
95
|
+
map: {
|
|
96
|
+
type: Object,
|
|
97
|
+
default () {
|
|
98
|
+
return {
|
|
99
|
+
text: "text",
|
|
100
|
+
value: "value"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
data() {
|
|
106
|
+
return {
|
|
107
|
+
loading: false,
|
|
108
|
+
errorMessage: '',
|
|
109
|
+
loadMore: {
|
|
110
|
+
contentdown: '',
|
|
111
|
+
contentrefresh: '',
|
|
112
|
+
contentnomore: ''
|
|
113
|
+
},
|
|
114
|
+
dataList: [],
|
|
115
|
+
selected: [],
|
|
116
|
+
selectedIndex: 0,
|
|
117
|
+
page: {
|
|
118
|
+
current: this.pageCurrent,
|
|
119
|
+
size: this.pageSize,
|
|
120
|
+
count: 0
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
computed: {
|
|
125
|
+
isLocalData() {
|
|
126
|
+
return !this.collection.length;
|
|
127
|
+
},
|
|
128
|
+
isCloudData() {
|
|
129
|
+
return this.collection.length > 0;
|
|
130
|
+
},
|
|
131
|
+
isCloudDataList() {
|
|
132
|
+
return (this.isCloudData && (!this.parentField && !this.selfField));
|
|
133
|
+
},
|
|
134
|
+
isCloudDataTree() {
|
|
135
|
+
return (this.isCloudData && this.parentField && this.selfField);
|
|
136
|
+
},
|
|
137
|
+
dataValue() {
|
|
138
|
+
let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null ||
|
|
139
|
+
this.modelValue !== undefined);
|
|
140
|
+
return isModelValue ? this.modelValue : this.value;
|
|
141
|
+
},
|
|
142
|
+
hasValue() {
|
|
143
|
+
if (typeof this.dataValue === 'number') {
|
|
144
|
+
return true
|
|
145
|
+
}
|
|
146
|
+
return (this.dataValue != null) && (this.dataValue.length > 0)
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
created() {
|
|
150
|
+
this.$watch(() => {
|
|
151
|
+
var al = [];
|
|
152
|
+
['pageCurrent',
|
|
153
|
+
'pageSize',
|
|
154
|
+
'spaceInfo',
|
|
155
|
+
'value',
|
|
156
|
+
'modelValue',
|
|
157
|
+
'localdata',
|
|
158
|
+
'collection',
|
|
159
|
+
'action',
|
|
160
|
+
'field',
|
|
161
|
+
'orderby',
|
|
162
|
+
'where',
|
|
163
|
+
'getont',
|
|
164
|
+
'getcount',
|
|
165
|
+
'gettree'
|
|
166
|
+
].forEach(key => {
|
|
167
|
+
al.push(this[key])
|
|
168
|
+
});
|
|
169
|
+
return al
|
|
170
|
+
}, (newValue, oldValue) => {
|
|
171
|
+
let needReset = false
|
|
172
|
+
for (let i = 2; i < newValue.length; i++) {
|
|
173
|
+
if (newValue[i] != oldValue[i]) {
|
|
174
|
+
needReset = true
|
|
175
|
+
break
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (newValue[0] != oldValue[0]) {
|
|
179
|
+
this.page.current = this.pageCurrent
|
|
180
|
+
}
|
|
181
|
+
this.page.size = this.pageSize
|
|
182
|
+
|
|
183
|
+
this.onPropsChange()
|
|
184
|
+
})
|
|
185
|
+
this._treeData = []
|
|
186
|
+
},
|
|
187
|
+
methods: {
|
|
188
|
+
onPropsChange() {
|
|
189
|
+
this._treeData = [];
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
// 填充 pickview 数据
|
|
193
|
+
async loadData() {
|
|
194
|
+
if (this.isLocalData) {
|
|
195
|
+
this.loadLocalData();
|
|
196
|
+
} else if (this.isCloudDataList) {
|
|
197
|
+
this.loadCloudDataList();
|
|
198
|
+
} else if (this.isCloudDataTree) {
|
|
199
|
+
this.loadCloudDataTree();
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
// 加载本地数据
|
|
204
|
+
async loadLocalData() {
|
|
205
|
+
this._treeData = [];
|
|
206
|
+
this._extractTree(this.localdata, this._treeData);
|
|
207
|
+
|
|
208
|
+
let inputValue = this.dataValue;
|
|
209
|
+
if (inputValue === undefined) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (Array.isArray(inputValue)) {
|
|
214
|
+
inputValue = inputValue[inputValue.length - 1];
|
|
215
|
+
if (typeof inputValue === 'object' && inputValue[this.map.value]) {
|
|
216
|
+
inputValue = inputValue[this.map.value];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this.selected = this._findNodePath(inputValue, this.localdata);
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
// 加载 Cloud 数据 (单列)
|
|
224
|
+
async loadCloudDataList() {
|
|
225
|
+
if (this.loading) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
this.loading = true;
|
|
229
|
+
|
|
230
|
+
try {
|
|
231
|
+
let response = await this.getCommand();
|
|
232
|
+
let responseData = response.result.data;
|
|
233
|
+
|
|
234
|
+
this._treeData = responseData;
|
|
235
|
+
|
|
236
|
+
this._updateBindData();
|
|
237
|
+
this._updateSelected();
|
|
238
|
+
|
|
239
|
+
this.onDataChange();
|
|
240
|
+
} catch (e) {
|
|
241
|
+
this.errorMessage = e;
|
|
242
|
+
} finally {
|
|
243
|
+
this.loading = false;
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
// 加载 Cloud 数据 (树形)
|
|
248
|
+
async loadCloudDataTree() {
|
|
249
|
+
if (this.loading) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
this.loading = true;
|
|
253
|
+
|
|
254
|
+
try {
|
|
255
|
+
let commandOptions = {
|
|
256
|
+
field: this._cloudDataPostField(),
|
|
257
|
+
where: this._cloudDataTreeWhere()
|
|
258
|
+
};
|
|
259
|
+
if (this.gettree) {
|
|
260
|
+
commandOptions.startwith = `${this.selfField}=='${this.dataValue}'`;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
let response = await this.getCommand(commandOptions);
|
|
264
|
+
let responseData = response.result.data;
|
|
265
|
+
|
|
266
|
+
this._treeData = responseData;
|
|
267
|
+
this._updateBindData();
|
|
268
|
+
this._updateSelected();
|
|
269
|
+
|
|
270
|
+
this.onDataChange();
|
|
271
|
+
} catch (e) {
|
|
272
|
+
this.errorMessage = e;
|
|
273
|
+
} finally {
|
|
274
|
+
this.loading = false;
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
// 加载 Cloud 数据 (节点)
|
|
279
|
+
async loadCloudDataNode(callback) {
|
|
280
|
+
if (this.loading) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
this.loading = true;
|
|
284
|
+
|
|
285
|
+
try {
|
|
286
|
+
let commandOptions = {
|
|
287
|
+
field: this._cloudDataPostField(),
|
|
288
|
+
where: this._cloudDataNodeWhere()
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
let response = await this.getCommand(commandOptions);
|
|
292
|
+
let responseData = response.result.data;
|
|
293
|
+
|
|
294
|
+
callback(responseData);
|
|
295
|
+
} catch (e) {
|
|
296
|
+
this.errorMessage = e;
|
|
297
|
+
} finally {
|
|
298
|
+
this.loading = false;
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
// 回显 Cloud 数据
|
|
303
|
+
getCloudDataValue() {
|
|
304
|
+
if (this.isCloudDataList) {
|
|
305
|
+
return this.getCloudDataListValue();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (this.isCloudDataTree) {
|
|
309
|
+
return this.getCloudDataTreeValue();
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
|
|
313
|
+
// 回显 Cloud 数据 (单列)
|
|
314
|
+
getCloudDataListValue() {
|
|
315
|
+
// 根据 field's as value标识匹配 where 条件
|
|
316
|
+
let where = [];
|
|
317
|
+
let whereField = this._getForeignKeyByField();
|
|
318
|
+
if (whereField) {
|
|
319
|
+
where.push(`${whereField} == '${this.dataValue}'`)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
where = where.join(' || ');
|
|
323
|
+
|
|
324
|
+
if (this.where) {
|
|
325
|
+
where = `(${this.where}) && (${where})`
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return this.getCommand({
|
|
329
|
+
field: this._cloudDataPostField(),
|
|
330
|
+
where
|
|
331
|
+
}).then((res) => {
|
|
332
|
+
this.selected = res.result.data;
|
|
333
|
+
return res.result.data;
|
|
334
|
+
});
|
|
335
|
+
},
|
|
336
|
+
|
|
337
|
+
// 回显 Cloud 数据 (树形)
|
|
338
|
+
getCloudDataTreeValue() {
|
|
339
|
+
return this.getCommand({
|
|
340
|
+
field: this._cloudDataPostField(),
|
|
341
|
+
getTreePath: {
|
|
342
|
+
startWith: `${this.selfField}=='${this.dataValue}'`
|
|
343
|
+
}
|
|
344
|
+
}).then((res) => {
|
|
345
|
+
let treePath = [];
|
|
346
|
+
this._extractTreePath(res.result.data, treePath);
|
|
347
|
+
this.selected = treePath;
|
|
348
|
+
return treePath;
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
|
|
352
|
+
getCommand(options = {}) {
|
|
353
|
+
/* eslint-disable no-undef */
|
|
354
|
+
let db = uniCloud.database(this.spaceInfo)
|
|
355
|
+
|
|
356
|
+
const action = options.action || this.action
|
|
357
|
+
if (action) {
|
|
358
|
+
db = db.action(action)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const collection = options.collection || this.collection
|
|
362
|
+
db = db.collection(collection)
|
|
363
|
+
|
|
364
|
+
const where = options.where || this.where
|
|
365
|
+
if (!(!where || !Object.keys(where).length)) {
|
|
366
|
+
db = db.where(where)
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const field = options.field || this.field
|
|
370
|
+
if (field) {
|
|
371
|
+
db = db.field(field)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const orderby = options.orderby || this.orderby
|
|
375
|
+
if (orderby) {
|
|
376
|
+
db = db.orderBy(orderby)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const current = options.pageCurrent !== undefined ? options.pageCurrent : this.page.current
|
|
380
|
+
const size = options.pageSize !== undefined ? options.pageSize : this.page.size
|
|
381
|
+
const getCount = options.getcount !== undefined ? options.getcount : this.getcount
|
|
382
|
+
const getTree = options.gettree !== undefined ? options.gettree : this.gettree
|
|
383
|
+
|
|
384
|
+
const getOptions = {
|
|
385
|
+
getCount,
|
|
386
|
+
getTree
|
|
387
|
+
}
|
|
388
|
+
if (options.getTreePath) {
|
|
389
|
+
getOptions.getTreePath = options.getTreePath
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
db = db.skip(size * (current - 1)).limit(size).get(getOptions)
|
|
393
|
+
|
|
394
|
+
return db
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
_cloudDataPostField() {
|
|
398
|
+
let fields = [this.field];
|
|
399
|
+
if (this.parentField) {
|
|
400
|
+
fields.push(`${this.parentField} as parent_value`);
|
|
401
|
+
}
|
|
402
|
+
return fields.join(',');
|
|
403
|
+
},
|
|
404
|
+
|
|
405
|
+
_cloudDataTreeWhere() {
|
|
406
|
+
let result = []
|
|
407
|
+
let selected = this.selected
|
|
408
|
+
let parentField = this.parentField
|
|
409
|
+
if (parentField) {
|
|
410
|
+
result.push(`${parentField} == null || ${parentField} == ""`)
|
|
411
|
+
}
|
|
412
|
+
if (selected.length) {
|
|
413
|
+
for (var i = 0; i < selected.length - 1; i++) {
|
|
414
|
+
result.push(`${parentField} == '${selected[i].value}'`)
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
let where = []
|
|
419
|
+
if (this.where) {
|
|
420
|
+
where.push(`(${this.where})`)
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (result.length) {
|
|
424
|
+
where.push(`(${result.join(' || ')})`)
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return where.join(' && ')
|
|
428
|
+
},
|
|
429
|
+
|
|
430
|
+
_cloudDataNodeWhere() {
|
|
431
|
+
let where = []
|
|
432
|
+
let selected = this.selected;
|
|
433
|
+
if (selected.length) {
|
|
434
|
+
where.push(`${this.parentField} == '${selected[selected.length - 1].value}'`);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
where = where.join(' || ');
|
|
438
|
+
|
|
439
|
+
if (this.where) {
|
|
440
|
+
return `(${this.where}) && (${where})`
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return where
|
|
444
|
+
},
|
|
445
|
+
|
|
446
|
+
_getWhereByForeignKey() {
|
|
447
|
+
let result = []
|
|
448
|
+
let whereField = this._getForeignKeyByField();
|
|
449
|
+
if (whereField) {
|
|
450
|
+
result.push(`${whereField} == '${this.dataValue}'`)
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (this.where) {
|
|
454
|
+
return `(${this.where}) && (${result.join(' || ')})`
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return result.join(' || ')
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
_getForeignKeyByField() {
|
|
461
|
+
let fields = this.field.split(',');
|
|
462
|
+
let whereField = null;
|
|
463
|
+
for (let i = 0; i < fields.length; i++) {
|
|
464
|
+
const items = fields[i].split('as');
|
|
465
|
+
if (items.length < 2) {
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (items[1].trim() === 'value') {
|
|
469
|
+
whereField = items[0].trim();
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return whereField;
|
|
474
|
+
},
|
|
475
|
+
|
|
476
|
+
_updateBindData(node) {
|
|
477
|
+
const {
|
|
478
|
+
dataList,
|
|
479
|
+
hasNodes
|
|
480
|
+
} = this._filterData(this._treeData, this.selected)
|
|
481
|
+
|
|
482
|
+
let isleaf = this._stepSearh === false && !hasNodes
|
|
483
|
+
|
|
484
|
+
if (node) {
|
|
485
|
+
node.isleaf = isleaf
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
this.dataList = dataList
|
|
489
|
+
this.selectedIndex = dataList.length - 1
|
|
490
|
+
|
|
491
|
+
if (!isleaf && this.selected.length < dataList.length) {
|
|
492
|
+
this.selected.push({
|
|
493
|
+
value: null,
|
|
494
|
+
text: "请选择"
|
|
495
|
+
})
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
return {
|
|
499
|
+
isleaf,
|
|
500
|
+
hasNodes
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
|
|
504
|
+
_updateSelected() {
|
|
505
|
+
let dl = this.dataList
|
|
506
|
+
let sl = this.selected
|
|
507
|
+
let textField = this.map.text
|
|
508
|
+
let valueField = this.map.value
|
|
509
|
+
for (let i = 0; i < sl.length; i++) {
|
|
510
|
+
let value = sl[i].value
|
|
511
|
+
let dl2 = dl[i]
|
|
512
|
+
for (let j = 0; j < dl2.length; j++) {
|
|
513
|
+
let item2 = dl2[j]
|
|
514
|
+
if (item2[valueField] === value) {
|
|
515
|
+
sl[i].text = item2[textField]
|
|
516
|
+
break
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
|
|
522
|
+
_filterData(data, paths) {
|
|
523
|
+
let dataList = []
|
|
524
|
+
let hasNodes = true
|
|
525
|
+
|
|
526
|
+
dataList.push(data.filter((item) => {
|
|
527
|
+
return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
|
|
528
|
+
}))
|
|
529
|
+
for (let i = 0; i < paths.length; i++) {
|
|
530
|
+
let value = paths[i].value
|
|
531
|
+
let nodes = data.filter((item) => {
|
|
532
|
+
return item.parent_value === value
|
|
533
|
+
})
|
|
534
|
+
|
|
535
|
+
if (nodes.length) {
|
|
536
|
+
dataList.push(nodes)
|
|
537
|
+
} else {
|
|
538
|
+
hasNodes = false
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
return {
|
|
543
|
+
dataList,
|
|
544
|
+
hasNodes
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
|
|
548
|
+
_extractTree(nodes, result, parent_value) {
|
|
549
|
+
let list = result || []
|
|
550
|
+
let valueField = this.map.value
|
|
551
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
552
|
+
let node = nodes[i]
|
|
553
|
+
|
|
554
|
+
let child = {}
|
|
555
|
+
for (let key in node) {
|
|
556
|
+
if (key !== 'children') {
|
|
557
|
+
child[key] = node[key]
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (parent_value !== null && parent_value !== undefined && parent_value !== '') {
|
|
561
|
+
child.parent_value = parent_value
|
|
562
|
+
}
|
|
563
|
+
result.push(child)
|
|
564
|
+
|
|
565
|
+
let children = node.children
|
|
566
|
+
if (children) {
|
|
567
|
+
this._extractTree(children, result, node[valueField])
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
|
|
572
|
+
_extractTreePath(nodes, result) {
|
|
573
|
+
let list = result || []
|
|
574
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
575
|
+
let node = nodes[i]
|
|
576
|
+
|
|
577
|
+
let child = {}
|
|
578
|
+
for (let key in node) {
|
|
579
|
+
if (key !== 'children') {
|
|
580
|
+
child[key] = node[key]
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
result.push(child)
|
|
584
|
+
|
|
585
|
+
let children = node.children
|
|
586
|
+
if (children) {
|
|
587
|
+
this._extractTreePath(children, result)
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
|
|
592
|
+
_findNodePath(key, nodes, path = []) {
|
|
593
|
+
let textField = this.map.text
|
|
594
|
+
let valueField = this.map.value
|
|
595
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
596
|
+
let node = nodes[i]
|
|
597
|
+
let children = node.children
|
|
598
|
+
let text = node[textField]
|
|
599
|
+
let value = node[valueField]
|
|
600
|
+
|
|
601
|
+
path.push({
|
|
602
|
+
value,
|
|
603
|
+
text
|
|
604
|
+
})
|
|
605
|
+
|
|
606
|
+
if (value === key) {
|
|
607
|
+
return path
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (children) {
|
|
611
|
+
const p = this._findNodePath(key, children, path)
|
|
612
|
+
if (p.length) {
|
|
613
|
+
return p
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
path.pop()
|
|
618
|
+
}
|
|
619
|
+
return []
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.uni-data-pickerview {
|
|
2
|
+
position: relative;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.loading-cover {
|
|
8
|
+
position: absolute;
|
|
9
|
+
left: 0;
|
|
10
|
+
top: 0;
|
|
11
|
+
right: 0;
|
|
12
|
+
bottom: 0;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
background-color: rgba(150, 150, 150, .1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.error {
|
|
19
|
+
background-color: #fff;
|
|
20
|
+
padding: 15px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.error-text {
|
|
24
|
+
color: #DD524D;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.selected-node-list {
|
|
28
|
+
flex-direction: row;
|
|
29
|
+
flex-wrap: nowrap;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.selected-node-item {
|
|
33
|
+
margin-left: 10px;
|
|
34
|
+
margin-right: 10px;
|
|
35
|
+
padding: 8px 10px 8px 10px;
|
|
36
|
+
border-bottom: 2px solid transparent;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.selected-node-item-active {
|
|
40
|
+
color: #007aff;
|
|
41
|
+
border-bottom-color: #007aff;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.list-view {
|
|
45
|
+
flex: 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.list-item {
|
|
49
|
+
flex-direction: row;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
padding: 12px 15px;
|
|
52
|
+
border-bottom: 1px solid #f0f0f0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.item-text {
|
|
56
|
+
color: #333333;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.item-text-disabled {
|
|
60
|
+
opacity: .5;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.item-text-overflow {
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.check {
|
|
68
|
+
margin-right: 5px;
|
|
69
|
+
border: 2px solid #007aff;
|
|
70
|
+
border-left: 0;
|
|
71
|
+
border-top: 0;
|
|
72
|
+
height: 12px;
|
|
73
|
+
width: 6px;
|
|
74
|
+
transform-origin: center;
|
|
75
|
+
transform: rotate(45deg);
|
|
76
|
+
}
|