@wakaka1/adaptive-page 2.0.0 → 2.0.1
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 +433 -2
- package/adaptive-page.common.js +267 -217
- package/adaptive-page.common.js.map +1 -1
- package/adaptive-page.umd.js +267 -217
- package/adaptive-page.umd.js.map +1 -1
- package/adaptive-page.umd.min.js +3 -3
- package/adaptive-page.umd.min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
adaptive-page,
|
2
1
|
表格数组展示控件,
|
3
2
|
在 umy-ui 基础上进行扩展。
|
3
|
+
包括两个页面和一个组件:
|
4
|
+
|
5
|
+
- 主子表页面`main-sub-table`
|
6
|
+
- 简单表格`simple-table`
|
7
|
+
- 表格组件`adaptive-page`
|
4
8
|
|
5
9
|
## 使用
|
6
10
|
|
@@ -44,9 +48,436 @@ Vue.use(AdaptivePage);
|
|
44
48
|
shrink: "收起",
|
45
49
|
unfold: "展开",
|
46
50
|
},
|
51
|
+
global: {
|
52
|
+
add: "新建",
|
53
|
+
edit: "编辑",
|
54
|
+
delete: "删除",
|
55
|
+
import: "导入",
|
56
|
+
export: "导出"
|
57
|
+
}
|
47
58
|
```
|
48
59
|
|
49
|
-
##
|
60
|
+
## simple-table
|
61
|
+
|
62
|
+
简单表格页面提供展示表格数据的页面,
|
63
|
+
以及导入、导出、新增、编辑、删除操作。
|
64
|
+
|
65
|
+
**示例**:
|
66
|
+
|
67
|
+
```
|
68
|
+
<template>
|
69
|
+
<simple-table
|
70
|
+
:tableTitle="tableTitle"
|
71
|
+
:columns="computedColumns"
|
72
|
+
:toolbar-opts="toolbarOpts"
|
73
|
+
:apiList="getList"
|
74
|
+
:importBtn="importBtn"
|
75
|
+
:exportBtn="exportBtn"
|
76
|
+
:addBtn="addBtn"
|
77
|
+
@searchChange="onSearchChange"
|
78
|
+
ref="simpleTable"
|
79
|
+
class="mall-product"
|
80
|
+
>
|
81
|
+
<template #header-operator-pre>
|
82
|
+
<el-button
|
83
|
+
size="mini"
|
84
|
+
class="btn-title"
|
85
|
+
type="primary"
|
86
|
+
@click="navTo(true)"
|
87
|
+
:disabled="!canEdit"
|
88
|
+
v-permission="['accounts:explosion-pile:list:edit']"
|
89
|
+
>{{ $t("global.edit") }}</el-button
|
90
|
+
>
|
91
|
+
</template>
|
92
|
+
</simple-table>
|
93
|
+
</template>
|
94
|
+
<script>
|
95
|
+
import { columns, toolbarOpts } from "./crud";
|
96
|
+
import {
|
97
|
+
getExplosionPileList,
|
98
|
+
exportExplosivePile,
|
99
|
+
} from "@/api/account-explosion";
|
100
|
+
import dayjs from "dayjs";
|
101
|
+
export default {
|
102
|
+
data() {
|
103
|
+
return {
|
104
|
+
dynamicColumns: [],
|
105
|
+
columns,
|
106
|
+
exportBtn: {
|
107
|
+
permission: ["accounts:explosion-pile:list:export"],
|
108
|
+
api: exportExplosivePile,
|
109
|
+
},
|
110
|
+
importBtn: {
|
111
|
+
permission: ["accounts:explosion-pile:list:import"],
|
112
|
+
importType: "explosionPile",
|
113
|
+
},
|
114
|
+
addBtn: {
|
115
|
+
permission: ["accounts:explosion-pile:list:add"],
|
116
|
+
func: () => {
|
117
|
+
this.navTo(false);
|
118
|
+
},
|
119
|
+
},
|
120
|
+
toolbarOpts,
|
121
|
+
canEdit: false,
|
122
|
+
tableTitle: `${this.$t("accounts.explosion.Explosion_Title")} ${this.$t(
|
123
|
+
"accounts.explosion.Current_Check"
|
124
|
+
)} --`,
|
125
|
+
};
|
126
|
+
},
|
127
|
+
computed: {
|
128
|
+
computedColumns() {
|
129
|
+
let cols = this.columns.slice(0);
|
130
|
+
let dynamicColumns = this.dynamicColumns.slice(0);
|
131
|
+
const list = dynamicColumns.map((item) => ({
|
132
|
+
prop: item.prop,
|
133
|
+
label: item.label,
|
134
|
+
}));
|
135
|
+
console.log([...cols, ...list], "computedColumns");
|
136
|
+
return [...cols, ...list];
|
137
|
+
},
|
138
|
+
},
|
139
|
+
methods: {
|
140
|
+
onSearchChange(newVal) {
|
141
|
+
this.tableTitle = `${this.$t(
|
142
|
+
"accounts.explosion.Explosion_Title"
|
143
|
+
)} ${this.$t("accounts.explosion.Current_Check")} ${
|
144
|
+
newVal.explosivePileDate || "--"
|
145
|
+
}`;
|
146
|
+
},
|
147
|
+
navTo(data) {
|
148
|
+
const date = data
|
149
|
+
? this.$refs.simpleTable.search.explosivePileDate
|
150
|
+
: dayjs().format("YYYY-MM-DD");
|
151
|
+
this.$router.push({
|
152
|
+
path: data
|
153
|
+
? "/accounts/explosion-pile/edit"
|
154
|
+
: "/accounts/explosion-pile/add",
|
155
|
+
query: {
|
156
|
+
date,
|
157
|
+
},
|
158
|
+
});
|
159
|
+
},
|
160
|
+
getList(param) {
|
161
|
+
return getExplosionPileList(param).then((res) => {
|
162
|
+
this.canEdit = res.data?.data?.length > 0 || false;
|
163
|
+
this.dynamicColumns = res.data?.dynamicHeaders || [];
|
164
|
+
return res;
|
165
|
+
});
|
166
|
+
},
|
167
|
+
},
|
168
|
+
mounted() {
|
169
|
+
this.$refs.simpleTable.search.explosivePileDate =
|
170
|
+
dayjs().format("YYYY-MM-DD");
|
171
|
+
this.$refs.simpleTable.table.pageShow = false;
|
172
|
+
},
|
173
|
+
};
|
174
|
+
</script>
|
175
|
+
<style lang="scss" scoped>
|
176
|
+
.btn-title {
|
177
|
+
color: #ffffff;
|
178
|
+
background: var(--color-primary);
|
179
|
+
border-color: var(--color-primary);
|
180
|
+
margin-left: 10px;
|
181
|
+
margin-bottom: 1px;
|
182
|
+
padding: 5px 15px;
|
183
|
+
}
|
184
|
+
::v-deep .el-date-editor .el-input__inner {
|
185
|
+
padding-left: 25px !important;
|
186
|
+
}
|
187
|
+
</style>
|
188
|
+
```
|
189
|
+
|
190
|
+
**attributes**:
|
191
|
+
|
192
|
+
```
|
193
|
+
props: {
|
194
|
+
/**
|
195
|
+
* 获取数据的接口
|
196
|
+
*/
|
197
|
+
apiList: {
|
198
|
+
type: Function,
|
199
|
+
},
|
200
|
+
/**
|
201
|
+
* 格式化搜索选项
|
202
|
+
*/
|
203
|
+
formatSearch: {
|
204
|
+
type: Function,
|
205
|
+
},
|
206
|
+
/**
|
207
|
+
* 导入按钮的相关配置,包括hidden(未提供时默认显示),permission, func(提供时优先执行该方法,否则跳转导入页面), importType(默认跳转行为的导入类型)
|
208
|
+
*/
|
209
|
+
importBtn: Object,
|
210
|
+
/**
|
211
|
+
* 导出按钮的相关配置,包括hidden(未提供时默认显示),permission, func(提供时优先执行该方法,否则使用apiExport执行默认导出), api
|
212
|
+
*/
|
213
|
+
exportBtn: Object,
|
214
|
+
/**
|
215
|
+
* 添加按钮的相关配置,包括hidden(未提供时默认显示),permission, func(提供时优先执行该方法,否则跳转添加页面), route(默认跳转的路由)
|
216
|
+
*/
|
217
|
+
addBtn: Object,
|
218
|
+
/**
|
219
|
+
* 编辑按钮的相关配置,包括hidden(未提供时默认显示),permission, func(提供时优先执行该方法,否则用route执行默认跳转), route
|
220
|
+
*/
|
221
|
+
editBtn: Object,
|
222
|
+
/**
|
223
|
+
* 删除按钮的相关配置,包括hidden(未提供时默认显示),permission, func(提供时优先执行该方法,否则用api执行默认删除), api
|
224
|
+
*/
|
225
|
+
deleteBtn: Object,
|
226
|
+
},
|
227
|
+
```
|
228
|
+
|
229
|
+
**Events**:
|
230
|
+
|
231
|
+
- `searchChange`: 查询控件的 Input 事件时触发
|
232
|
+
|
233
|
+
**Slots**:
|
234
|
+
|
235
|
+
- `header-operator-pre`: 标题栏搜索控件后、导入导出按钮前的插槽
|
236
|
+
- `header-operator-post`: 标题栏导入导出按钮后的插槽
|
237
|
+
- `row-operator-pre`: 行操作编辑、删除之前的插槽
|
238
|
+
- `row-operator-post`: 行操作编辑、删除之后的插槽
|
239
|
+
|
240
|
+
## main-sub-table
|
241
|
+
|
242
|
+
主子表格页面提供展示左侧主表概览,右上主数据描述,右下子表的页面。
|
243
|
+
以及导入、导出、新增、编辑、删除操作。
|
244
|
+
|
245
|
+
**示例**:
|
246
|
+
|
247
|
+
```
|
248
|
+
<template>
|
249
|
+
<main-sub-table
|
250
|
+
title="穿孔记录"
|
251
|
+
:mainColumns="mainColumns"
|
252
|
+
:subColumns="subColumns"
|
253
|
+
:apiMainList="apiMainList"
|
254
|
+
:apiSubList="apiSubList"
|
255
|
+
:importBtn="importBtn"
|
256
|
+
:exportBtn="exportBtn"
|
257
|
+
:addBtn="addBtn"
|
258
|
+
:editBtn="editBtn"
|
259
|
+
:deleteBtn="deleteBtn"
|
260
|
+
:formatSearch="formatSearch"
|
261
|
+
>
|
262
|
+
</main-sub-table>
|
263
|
+
</template>
|
264
|
+
|
265
|
+
<script>
|
266
|
+
import { mainColumns, subColumns } from "./adCrud.js";
|
267
|
+
import { getUnit } from "@/utils";
|
268
|
+
import {
|
269
|
+
apiGetPuncherList,
|
270
|
+
apiDeletePuncher,
|
271
|
+
apiExportPuncher,
|
272
|
+
detailPuncherLoadItemList,
|
273
|
+
} from "@/api/account-puncher";
|
274
|
+
import { getDeviceList } from "@/api/auxiliary";
|
275
|
+
|
276
|
+
import { Equipment_Classify_Puncher } from "@/const/index";
|
277
|
+
|
278
|
+
export default {
|
279
|
+
name: "accounts-puncher-list",
|
280
|
+
data() {
|
281
|
+
return {
|
282
|
+
deviceList: [],
|
283
|
+
currentRoute: null,
|
284
|
+
totalDepthLabel: "",
|
285
|
+
totalVolumeLabel: "",
|
286
|
+
itemDepthLabel: "",
|
287
|
+
itemVolumnLabel: "",
|
288
|
+
importBtn: {
|
289
|
+
permission: ["accounts:puncher:list:import"],
|
290
|
+
importType: "puncher",
|
291
|
+
},
|
292
|
+
exportBtn: {
|
293
|
+
permission: ["accounts:puncher:list:export"],
|
294
|
+
api: apiExportPuncher,
|
295
|
+
},
|
296
|
+
addBtn: {
|
297
|
+
permission: ["accounts:puncher:list:add"],
|
298
|
+
route: "/accounts/puncher/add",
|
299
|
+
},
|
300
|
+
apiMainList: apiGetPuncherList,
|
301
|
+
apiSubList: detailPuncherLoadItemList,
|
302
|
+
editBtn: {
|
303
|
+
permission: ["accounts:puncher:list:edit"],
|
304
|
+
route: "/accounts/puncher/edit",
|
305
|
+
},
|
306
|
+
deleteBtn: {
|
307
|
+
permission: ["accounts:puncher:list:delete"],
|
308
|
+
api: apiDeletePuncher,
|
309
|
+
},
|
310
|
+
};
|
311
|
+
},
|
312
|
+
computed: {
|
313
|
+
mainColumns() {
|
314
|
+
let res = [...mainColumns];
|
315
|
+
for (let i = 0, len = res.length; i < len; i++) {
|
316
|
+
let col = res[i];
|
317
|
+
if (col.prop === "deviceName") {
|
318
|
+
col.search.bind.optionSource = this.deviceList;
|
319
|
+
}
|
320
|
+
if (col.prop === "totalPenetrationDepth") {
|
321
|
+
col.label = this.totalDepthLabel;
|
322
|
+
}
|
323
|
+
if (col.prop === "totalPenetrationVolume") {
|
324
|
+
col.label = this.totalVolumeLabel;
|
325
|
+
}
|
326
|
+
}
|
327
|
+
return res;
|
328
|
+
},
|
329
|
+
subColumns() {
|
330
|
+
let res = [...subColumns];
|
331
|
+
for (let i = 0, len = res.length; i < len; i++) {
|
332
|
+
let col = res[i];
|
333
|
+
if (col.prop === "penetrationDepth") {
|
334
|
+
col.label = this.itemDepthLabel;
|
335
|
+
}
|
336
|
+
if (col.prop === "penetrationVolume") {
|
337
|
+
col.label = this.itemVolumnLabel;
|
338
|
+
}
|
339
|
+
}
|
340
|
+
return res;
|
341
|
+
},
|
342
|
+
},
|
343
|
+
methods: {
|
344
|
+
formatSearch(example) {
|
345
|
+
if (!!example.workDate && example.workDate.length > 0) {
|
346
|
+
example.workDateStart = example.workDate[0];
|
347
|
+
example.workDateEnd = example.workDate[1];
|
348
|
+
} else {
|
349
|
+
delete example.workDateStart;
|
350
|
+
delete example.workDateEnd;
|
351
|
+
}
|
352
|
+
return example;
|
353
|
+
},
|
354
|
+
initLabelWithUnit() {
|
355
|
+
this.totalDepthLabel = this.$t("accounts.puncher.Total_Puncher_Depth");
|
356
|
+
this.totalVolumeLabel = this.$t("accounts.puncher.Total_Puncher_Volume");
|
357
|
+
this.itemDepthLabel = this.$t("accounts.puncher.Puncher_Depth");
|
358
|
+
this.itemVolumnLabel = this.$t("accounts.puncher.Puncher_Volume");
|
359
|
+
this.currentRoute = this.$route.path;
|
360
|
+
let tmpData = JSON.parse(localStorage.getItem("unitConfigs"));
|
361
|
+
if (Object.keys(tmpData).length !== 0) {
|
362
|
+
const mainDepthConfig =
|
363
|
+
tmpData[this.currentRoute]["/mmes/punchingBook/list"][
|
364
|
+
"data.totalPenetrationDepth"
|
365
|
+
];
|
366
|
+
const mainVolumeConfig =
|
367
|
+
tmpData[this.currentRoute]["/mmes/punchingBook/list"][
|
368
|
+
"data.totalPenetrationVolume"
|
369
|
+
];
|
370
|
+
if (mainDepthConfig?.category) {
|
371
|
+
this.totalDepthLabel += `(${mainDepthConfig.symbol})`;
|
372
|
+
}
|
373
|
+
if (mainVolumeConfig?.category) {
|
374
|
+
this.totalVolumeLabel += `(${mainVolumeConfig.symbol})`;
|
375
|
+
}
|
376
|
+
const subDepthConfig =
|
377
|
+
tmpData[this.currentRoute]["/mmes/punchingBook/listByParent"][
|
378
|
+
"penetrationDepth"
|
379
|
+
];
|
380
|
+
|
381
|
+
const subVolumeConfig =
|
382
|
+
tmpData[this.currentRoute]["/mmes/punchingBook/listByParent"][
|
383
|
+
"penetrationVolume"
|
384
|
+
];
|
385
|
+
|
386
|
+
if (subDepthConfig?.category) {
|
387
|
+
this.itemDepthLabel += `(${subDepthConfig.symbol})`;
|
388
|
+
this.itemVolumnLabel += `(${subVolumeConfig.symbol})`;
|
389
|
+
}
|
390
|
+
} else {
|
391
|
+
this.totalDepthLabel += `(${getUnit("length")})`;
|
392
|
+
this.totalVolumeLabel += `(${getUnit("volume")})`;
|
393
|
+
this.itemDepthLabel += `(${getUnit("length")})`;
|
394
|
+
this.itemVolumnLabel += `(${getUnit("volume")})`;
|
395
|
+
}
|
396
|
+
},
|
397
|
+
},
|
398
|
+
mounted() {
|
399
|
+
this.initLabelWithUnit();
|
400
|
+
getDeviceList({ deviceClassifyIds: [Equipment_Classify_Puncher] }).then(
|
401
|
+
(res) => {
|
402
|
+
this.deviceList = res.data.map((x) => ({
|
403
|
+
id: x.id,
|
404
|
+
name: x.assetName || x.deviceCode,
|
405
|
+
}));
|
406
|
+
}
|
407
|
+
);
|
408
|
+
},
|
409
|
+
};
|
410
|
+
</script>
|
411
|
+
```
|
412
|
+
|
413
|
+
**attributes**
|
414
|
+
|
415
|
+
```
|
416
|
+
props: {
|
417
|
+
/**
|
418
|
+
* 标题
|
419
|
+
*/
|
420
|
+
title: String,
|
421
|
+
/**
|
422
|
+
* 访问主列表的api
|
423
|
+
*/
|
424
|
+
apiMainList: {
|
425
|
+
type: Function,
|
426
|
+
},
|
427
|
+
/**
|
428
|
+
* 访问子列表的api
|
429
|
+
*/
|
430
|
+
apiSubList: {
|
431
|
+
type: Function,
|
432
|
+
},
|
433
|
+
/**
|
434
|
+
* 导入按钮的相关配置,包括hidden(未提供时默认显示),permission, func(提供时优先执行该方法,否则跳转导入页面), importType(默认跳转的参数)
|
435
|
+
*/
|
436
|
+
importBtn: Object,
|
437
|
+
/**
|
438
|
+
* 导出按钮的相关配置,包括hidden(未提供时默认显示),permission, func(提供时优先执行该方法,否则使用apiExport执行默认导出), api
|
439
|
+
*/
|
440
|
+
exportBtn: Object,
|
441
|
+
/**
|
442
|
+
* 添加按钮的相关配置,包括hidden(未提供时默认显示),permission, func(提供时优先执行该方法,否则跳转添加页面), route(默认跳转的路由)
|
443
|
+
*/
|
444
|
+
addBtn: Object,
|
445
|
+
/**
|
446
|
+
* 格式化搜索选项
|
447
|
+
*/
|
448
|
+
formatSearch: {
|
449
|
+
type: Function,
|
450
|
+
},
|
451
|
+
/**
|
452
|
+
* 主列表的配置
|
453
|
+
*/
|
454
|
+
mainColumns: {
|
455
|
+
type: Array,
|
456
|
+
},
|
457
|
+
/**
|
458
|
+
* 子列表的配置
|
459
|
+
*/
|
460
|
+
subColumns: { type: Array },
|
461
|
+
/**
|
462
|
+
* 编辑按钮的相关配置,包括hidden(未提供时默认显示),permission, func(提供时优先执行该方法,否则用route执行默认跳转), route
|
463
|
+
*/
|
464
|
+
editBtn: Object,
|
465
|
+
/**
|
466
|
+
* 删除按钮的相关配置,包括hidden(未提供时默认显示),permission, func(提供时优先执行该方法,否则用api执行默认删除), api
|
467
|
+
*/
|
468
|
+
deleteBtn: Object,
|
469
|
+
},
|
470
|
+
```
|
471
|
+
|
472
|
+
## adaptive-page
|
473
|
+
|
474
|
+
和之前的 adaptive-page 兼容。
|
475
|
+
|
476
|
+
增加 toolbarOpts 属性,
|
477
|
+
toolbarOpts 中提供的内容与 opts 一致,
|
478
|
+
但 toolbarOpts 提供的搜索会与标题栏出现在同一行。
|
479
|
+
|
480
|
+
### 列设置
|
50
481
|
|
51
482
|
在 adaptive-page 组件上,
|
52
483
|
打开 columnSetting 开关。
|