mooho-base-admin-plus 0.4.60 → 0.4.61

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.60",
4
+ "version": "0.4.61",
5
5
  "author": "jinyifan <jinyifan@mooho.com.cn>",
6
6
  "dotnetVersion": "1.4.0",
7
7
  "license": "MIT",
@@ -408,6 +408,22 @@
408
408
  custom-icon="fa fa-trash-alt"
409
409
  @click="remove(rowData(row, index), index)"
410
410
  ></Button>
411
+ <Button
412
+ v-if="this.static && tableView.adjustEnable && !readonly"
413
+ size="small"
414
+ :title="$t('Front_Btn_Up')"
415
+ type="primary"
416
+ custom-icon="fa fa-chevron-up"
417
+ @click="up(rowData(row, index), index)"
418
+ ></Button>
419
+ <Button
420
+ v-if="this.static && tableView.adjustEnable && !readonly"
421
+ size="small"
422
+ :title="$t('Front_Btn_Down')"
423
+ type="primary"
424
+ custom-icon="fa fa-chevron-down"
425
+ @click="down(rowData(row, index), index)"
426
+ ></Button>
411
427
  <Button
412
428
  v-for="(item, index) in commandButtons"
413
429
  :key="index"
@@ -2334,6 +2350,26 @@
2334
2350
  return column.name;
2335
2351
  }
2336
2352
  }
2353
+ },
2354
+ // 上移
2355
+ up(row, index) {
2356
+ let data = this.$refs.table.data;
2357
+ if (index > 0) {
2358
+ data.splice(index, 1);
2359
+ data.splice(index - 1, 0, row);
2360
+
2361
+ this.$refs.table.loadData(data);
2362
+ }
2363
+ },
2364
+ // 下移
2365
+ down(row, index) {
2366
+ let data = this.$refs.table.data;
2367
+ if (index < data.length - 1) {
2368
+ data.splice(index, 1);
2369
+ data.splice(index + 1, 0, row);
2370
+
2371
+ this.$refs.table.loadData(data);
2372
+ }
2337
2373
  }
2338
2374
  }
2339
2375
  };
@@ -16,6 +16,8 @@
16
16
  return row.hasChildren;
17
17
  }
18
18
  "
19
+ :before-load-data="beforeLoadData"
20
+ @on-load-data="onLoadData"
19
21
  @create="create()"
20
22
  @edit="({ row, index }) => edit(row)"
21
23
  >
@@ -168,6 +170,61 @@
168
170
  } else {
169
171
  this.$refs.table.loadData();
170
172
  }
173
+ },
174
+ beforeLoadData() {
175
+ if (!(this.filter['keyword'] || '').trim()) {
176
+ // 普通查询,只查询顶层包装
177
+ this.filter['parentID'] = 'null';
178
+ } else {
179
+ // 根据关键词查询,查询所有层级
180
+ this.filter['parentID'] = null;
181
+ }
182
+ },
183
+ async onLoadData() {
184
+ if (!!(this.filter['keyword'] || '').trim()) {
185
+ // 根据关键词查询的结果,递归查找所有上层
186
+ let data = this.$refs.table.data;
187
+ if (data.length > 0) {
188
+ let dataWithParent = [];
189
+ for (let i = 0; i < data.length; i++) {
190
+ await this.loadParentData(data[i], dataWithParent);
191
+ }
192
+
193
+ dataWithParent.forEach(item => {
194
+ if (item.parentID) {
195
+ let parent = dataWithParent.find(p => p.id == item.parentID);
196
+ if (!parent.children) {
197
+ parent.children = [];
198
+ }
199
+
200
+ parent.children.push(item);
201
+ parent._showChildren = true;
202
+ }
203
+ });
204
+
205
+ data.length = 0;
206
+ dataWithParent
207
+ .filter(item => item.parentID == null)
208
+ .forEach(item => {
209
+ data.push(item);
210
+ });
211
+ }
212
+ }
213
+ },
214
+ async loadParentData(data, dataWithParent) {
215
+ dataWithParent.push(data);
216
+
217
+ if (data.parentID && !dataWithParent.some(item => item.id == data.parentID)) {
218
+ let res = await modelApi.query('Permission', {
219
+ id: data.parentID,
220
+ page: 1,
221
+ per: 1
222
+ });
223
+
224
+ await this.loadParentData(res.data[0], dataWithParent);
225
+ } else {
226
+ return;
227
+ }
171
228
  }
172
229
  }
173
230
  };