mooho-base-admin-plus 0.4.52 → 0.4.54

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mooho-base-admin-plus",
3
3
  "description": "MOOHO basic framework for admin by Vue3",
4
- "version": "0.4.52",
4
+ "version": "0.4.54",
5
5
  "author": "jinyifan <jinyifan@mooho.com.cn>",
6
6
  "dotnetVersion": "1.4.0",
7
7
  "license": "MIT",
@@ -71,6 +71,15 @@
71
71
  static: {
72
72
  type: Boolean,
73
73
  default: false
74
+ },
75
+ /**
76
+ * 筛选
77
+ */
78
+ filter: {
79
+ type: Object,
80
+ default() {
81
+ return {};
82
+ }
74
83
  }
75
84
  },
76
85
  computed: {},
@@ -140,7 +149,7 @@
140
149
  /**
141
150
  * 加载数据
142
151
  *
143
- * @param {array} staticData 静态数据
152
+ * @param {array} staticData 静态数据或筛选条件
144
153
  * @public
145
154
  */
146
155
  async loadData(staticData) {
@@ -148,32 +157,56 @@
148
157
  this.data = staticData;
149
158
  } else {
150
159
  let filter = {};
160
+
161
+ // 默认筛选条件
151
162
  if (this.tableView.filtering) {
152
163
  filter = JSON.parse(this.tableView.filtering);
153
164
  }
154
165
 
155
- let data = {
156
- ...filter
157
- };
166
+ // 属性筛选条件
167
+ for (let key in this.filter) {
168
+ filter[key] = this.filter[key];
169
+ }
170
+
171
+ // 传入筛选条件
172
+ for (let key in staticData) {
173
+ filter[key] = staticData[key];
174
+ }
175
+
176
+ // 排序
177
+ if (this.tableView.sorting) {
178
+ // 排序
179
+ let obj = JSON.parse(this.tableView.sorting);
180
+ let arr = [];
181
+ for (let key in obj) {
182
+ if (obj[key] === 'desc') {
183
+ arr.push('-' + key);
184
+ } else {
185
+ arr.push('+' + key);
186
+ }
187
+ }
188
+
189
+ filter.orderBy = arr.join(',');
190
+ }
158
191
 
159
192
  if (this.tableView.isGroupBy) {
160
- data.isGroupBy = true;
161
- data.groupColumn = JSON.parse(this.tableView.groupColumn);
162
- data.groupMethod = JSON.parse(this.tableView.groupMethod);
193
+ filter.isGroupBy = true;
194
+ filter.groupColumn = JSON.parse(this.tableView.groupColumn);
195
+ filter.groupMethod = JSON.parse(this.tableView.groupMethod);
163
196
  }
164
197
 
165
198
  if (this.tableView.isCustom) {
166
- let res = await customModelApi.query(this.tableView.model, data);
199
+ let res = await customModelApi.query(this.tableView.model, filter);
167
200
 
168
201
  this.total = res.totalCount;
169
202
  this.data = res.data;
170
203
  } else if (this.tableView.isDataSource) {
171
- let res = await dataSourceApi.query(this.tableView.dataSource, data);
204
+ let res = await dataSourceApi.query(this.tableView.dataSource, filter);
172
205
 
173
206
  this.total = res.totalCount;
174
207
  this.data = res.table;
175
208
  } else {
176
- let res = await modelApi.query(this.tableView.model, data, this.tableView.functionName, this.tableView.functionType);
209
+ let res = await modelApi.query(this.tableView.model, filter, this.tableView.functionName, this.tableView.functionType);
177
210
 
178
211
  this.total = res.totalCount;
179
212
  this.data = res.data;