@kengic/uni 0.3.2-beta.10
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/README.md +1 -0
- package/dist/index.css +1 -0
- package/dist/kengic-uni.js +5 -0
- package/dist/src/consts/i18n/en.d.ts +45 -0
- package/dist/src/consts/i18n/index.d.ts +90 -0
- package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
- package/dist/src/consts/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/kg.util.d.ts +5 -0
- package/dist/uni-ui/index.ts +11 -0
- package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
- package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
- package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
- package/dist/uni-ui/uni-calendar/calendar.js +546 -0
- package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
- package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
- package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
- package/dist/uni-ui/uni-calendar/util.js +360 -0
- package/dist/uni-ui/uni-card/uni-card.vue +281 -0
- package/dist/uni-ui/uni-col/uni-col.vue +317 -0
- package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
- package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
- package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
- package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
- package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
- package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
- package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
- package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
- package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
- package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
- package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
- package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
- package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
- package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
- package/dist/uni-ui/uni-drawer/keypress.js +45 -0
- package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
- package/dist/uni-ui/uni-easyinput/common.js +56 -0
- package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
- package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
- package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
- package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
- package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
- package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
- package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
- package/dist/uni-ui/uni-file-picker/utils.js +109 -0
- package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
- package/dist/uni-ui/uni-forms/utils.js +293 -0
- package/dist/uni-ui/uni-forms/validate.js +486 -0
- package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
- package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
- package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
- package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
- package/dist/uni-ui/uni-group/uni-group.vue +134 -0
- package/dist/uni-ui/uni-icons/icons.js +1169 -0
- package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
- package/dist/uni-ui/uni-icons/uniicons.css +663 -0
- package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
- package/dist/uni-ui/uni-link/uni-link.vue +128 -0
- package/dist/uni-ui/uni-list/uni-list.vue +123 -0
- package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
- package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
- package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
- package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
- package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
- package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
- package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
- package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
- package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
- package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
- package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
- package/dist/uni-ui/uni-popup/keypress.js +45 -0
- package/dist/uni-ui/uni-popup/popup.js +23 -0
- package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
- package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
- package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
- package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
- package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
- package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
- package/dist/uni-ui/uni-row/uni-row.vue +190 -0
- package/dist/uni-ui/uni-scss/changelog.md +8 -0
- package/dist/uni-ui/uni-scss/index.scss +1 -0
- package/dist/uni-ui/uni-scss/package.json +82 -0
- package/dist/uni-ui/uni-scss/readme.md +4 -0
- package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
- package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
- package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
- package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
- package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
- package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
- package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
- package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
- package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
- package/dist/uni-ui/uni-scss/theme.scss +31 -0
- package/dist/uni-ui/uni-scss/variables.scss +62 -0
- package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
- package/dist/uni-ui/uni-section/uni-section.vue +167 -0
- package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
- package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
- package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
- package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
- package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
- package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
- package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
- package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
- package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
- package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
- package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
- package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
- package/dist/uni-ui/uni-table/uni-table.vue +455 -0
- package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
- package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
- package/dist/uni-ui/uni-td/uni-td.vue +90 -0
- package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
- package/dist/uni-ui/uni-th/uni-th.vue +285 -0
- package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
- package/dist/uni-ui/uni-title/uni-title.vue +171 -0
- package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
- package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
- package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
- package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
- package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
- package/package.json +90 -0
|
@@ -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
|
+
}
|