bri-components 1.4.44 → 1.4.46

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,6 +1,6 @@
1
1
  {
2
2
  "name": "bri-components",
3
- "version": "1.4.44",
3
+ "version": "1.4.46",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -208,7 +208,7 @@
208
208
  this.timer = setTimeout(() => {
209
209
  this.change();
210
210
  this.$emit("inputChange");
211
- }, 1000);
211
+ }, 800);
212
212
 
213
213
  // this.changeStatus = true;
214
214
  },
@@ -9,73 +9,103 @@
9
9
  :render="topSearchRender"
10
10
  ></dsh-render>
11
11
 
12
- <!-- 表单展示模式 -->
13
- <div
14
- v-if="showMode === 'form'"
15
- class="DshFlatTable-form"
16
- >
12
+ <!-- 内容 -->
13
+ <template>
14
+ <!-- 表单展示模式 -->
17
15
  <div
18
- v-for="(row, rowIndex) in showListData"
19
- :key="row._id"
20
- class="item"
16
+ v-if="showMode === 'form'"
17
+ class="DshFlatTable-form"
21
18
  >
22
- <div class="item-index">
23
- <p>第{{ rowIndex + 1 }}条</p>
24
- <span></span>
25
- </div>
19
+ <div
20
+ v-for="(row, rowIndex) in curPageListData"
21
+ :key="row._id"
22
+ class="item"
23
+ >
24
+ <div class="item-index">
25
+ <p>第{{ rowIndex + 1 }}条</p>
26
+ <span></span>
27
+ </div>
26
28
 
27
- <dsh-form
28
- class="item-form"
29
- :canEdit="getRowCanEdit(row, rowIndex)"
30
- :formData="row"
31
- :formList="getRowFormList(row, rowIndex)"
32
- :allFormList="getRowFormList(row, rowIndex)"
33
- :inTableType="inTableType"
34
- :allListRows="allListData"
35
- :rowIndex="rowIndex"
36
- :parentFormList="allFormList"
37
- :parentObj="parentObj"
38
- ></dsh-form>
39
-
40
- <dsh-icons
41
- v-if="$getOperationList(['canInsert', 'canDelete']).length"
42
- class="item-icons"
43
- itemClass="item-icons-item"
44
- :list="$getOperationList(['canInsert', 'canDelete'])"
45
- @click="$dispatchEvent($event, row, rowIndex)"
46
- ></dsh-icons>
29
+ <dsh-form
30
+ class="item-form"
31
+ :canEdit="getRowCanEdit(row, rowIndex)"
32
+ :formData="row"
33
+ :formList="getRowFormList(row, rowIndex)"
34
+ :allFormList="getRowFormList(row, rowIndex)"
35
+ :inTableType="inTableType"
36
+ :allListRows="allListData"
37
+ :rowIndex="rowIndex"
38
+ :parentFormList="allFormList"
39
+ :parentObj="parentObj"
40
+ ></dsh-form>
41
+
42
+ <dsh-icons
43
+ v-if="$getOperationList(['canInsert', 'canDelete']).length"
44
+ class="item-icons"
45
+ itemClass="item-icons-item"
46
+ :list="$getOperationList(['canInsert', 'canDelete'])"
47
+ @click="$dispatchEvent($event, row, rowIndex)"
48
+ ></dsh-icons>
49
+ </div>
47
50
  </div>
48
- </div>
49
51
 
50
- <!-- 表格展示模式 -->
51
- <template v-else>
52
- <bri-table
53
- v-show="showListData.length && !isSearching"
54
- ref="briTable"
55
- class="DshFlatTable-main"
56
- :columns="showColumns"
57
- :data="renderedListData"
58
- :footer-data="footerData"
59
- :propsObj="tablePropsObj"
60
- @changeSelect="changeSelect"
61
- @selectAll="changeSelect"
62
- ></bri-table>
63
- <bri-table
64
- v-show="!showListData.length || isSearching"
65
- ref="briTable"
66
- class="DshFlatTable-main"
67
- :columns="showColumns"
68
- :data="showListData"
69
- :footer-data="footerData"
70
- :propsObj="tablePropsObj"
71
- @changeSelect="changeSelect"
72
- @selectAll="changeSelect"
73
- ></bri-table>
52
+ <!-- 表格展示模式 -->
53
+ <template v-else>
54
+ <bri-table
55
+ v-show="curPageListData.length && !isSearching"
56
+ ref="briTable"
57
+ class="DshFlatTable-main"
58
+ :columns="showColumns"
59
+ :data="renderedShowListData"
60
+ :footer-data="footerData"
61
+ :propsObj="tablePropsObj"
62
+ @changeSelect="changeSelect"
63
+ @selectAll="changeSelect"
64
+ ></bri-table>
65
+ <bri-table
66
+ v-show="!curPageListData.length || isSearching"
67
+ ref="briTable"
68
+ class="DshFlatTable-main"
69
+ :columns="showColumns"
70
+ :data="curPageListData"
71
+ :footer-data="footerData"
72
+ :propsObj="tablePropsObj"
73
+ @changeSelect="changeSelect"
74
+ @selectAll="changeSelect"
75
+ ></bri-table>
76
+ </template>
74
77
  </template>
75
78
 
76
79
  <!-- 添加行 -->
77
80
  <dsh-render :render="createBtnRender"></dsh-render>
78
81
 
82
+ <!-- 分页 -->
83
+ <div class="DshFlatTable-page">
84
+ <dsh-page
85
+ :mode="pageMode"
86
+ :total="total"
87
+ :propsObj="pagePropsObj"
88
+ @changePage="changePage"
89
+ @changePageSize="changePageSize"
90
+ >
91
+ 共 {{ total }} 条
92
+
93
+ <span
94
+ class="DshFlatTable-sort"
95
+ :style="{ color: appColor }"
96
+ @click="changeSort()"
97
+ >
98
+ <dsh-icons
99
+ class="DshFlatTable-sort-icons"
100
+ :list="[{ icon: 'md-swap', size: 14 }]"
101
+ />
102
+ <span class="DshFlatTable-sort-name">
103
+ {{ isUseDescSort ? "使用正序" : "使用倒序" }}
104
+ </span>
105
+ </span>
106
+ </dsh-page>
107
+ </div>
108
+
79
109
  <!-- 各种模态框共用 -->
80
110
  <dsh-render :render="dshRender"></dsh-render>
81
111
 
@@ -99,20 +129,20 @@
99
129
 
100
130
  <!-- 表格 -->
101
131
  <bri-table
102
- v-show="showListData.length && !isSearching"
132
+ v-show="curPageListData.length && !isSearching"
103
133
  class="DshFlatTable-fullscreen-inner-main"
104
134
  :columns="showColumns"
105
- :data="renderedListData"
135
+ :data="renderedShowListData"
106
136
  :footer-data="footerData"
107
137
  :propsObj="tableInModalPropsObj"
108
138
  @changeSelect="changeSelect"
109
139
  @selectAll="changeSelect"
110
140
  ></bri-table>
111
141
  <bri-table
112
- v-show="!showListData.length || isSearching"
142
+ v-show="!curPageListData.length || isSearching"
113
143
  class="DshFlatTable-fullscreen-inner-main"
114
144
  :columns="showColumns"
115
- :data="showListData"
145
+ :data="curPageListData"
116
146
  :footer-data="footerData"
117
147
  :propsObj="tableInModalPropsObj"
118
148
  @changeSelect="changeSelect"
@@ -121,6 +151,33 @@
121
151
 
122
152
  <!-- 添加行 -->
123
153
  <dsh-render :render="createBtnRender"></dsh-render>
154
+
155
+ <!-- 分页 -->
156
+ <div class="DshFlatTable-page">
157
+ <dsh-page
158
+ :mode="pageMode"
159
+ :total="total"
160
+ :propsObj="pagePropsObj"
161
+ @changePage="changePage"
162
+ @changePageSize="changePageSize"
163
+ >
164
+ 共 {{ total }} 条
165
+
166
+ <span
167
+ class="DshFlatTable-sort"
168
+ :style="{ color: appColor }"
169
+ @click="changeSort()"
170
+ >
171
+ <dsh-icons
172
+ class="DshFlatTable-sort-icons"
173
+ :list="[{ icon: 'md-swap', size: 14 }]"
174
+ />
175
+ <span class="DshFlatTable-sort-name">
176
+ {{ isUseDescSort ? "使用正序" : "使用倒序" }}
177
+ </span>
178
+ </span>
179
+ </dsh-page>
180
+ </div>
124
181
  </div>
125
182
  </dsh-modal>
126
183
  </div>
@@ -217,6 +274,24 @@
217
274
  height: auto;
218
275
  }
219
276
 
277
+ &-page {
278
+ padding: 5px 3px;
279
+ }
280
+
281
+ &-sort {
282
+ margin-left: 5px;
283
+ font-weight: 600;
284
+ // color: @themeColor;
285
+ cursor: pointer;
286
+
287
+ &-icons {
288
+
289
+ }
290
+ &-name {
291
+ font-size: 12px;
292
+ }
293
+ }
294
+
220
295
  &-fullscreen {
221
296
  &-inner {
222
297
  width: 100%;
@@ -35,6 +35,10 @@ export default {
35
35
  ...(this.selfPropsObj._showCreateBtnColKeys || [])
36
36
  ];
37
37
  },
38
+ // 顶替tableBaseMixin里的
39
+ rowsNumStr () {
40
+ return `${this.isSearching ? "筛选" : "全部"}数据,共 ${this.total} 条;`;
41
+ },
38
42
 
39
43
  allTreeData () {
40
44
  return this.getCalcuedTree(this.data, this.treeColumns, this.selfColumns);
@@ -3,7 +3,15 @@ export default {
3
3
  components: {},
4
4
  props: {},
5
5
  data () {
6
- return {};
6
+ return {
7
+ isUseDescSort: false,
8
+ pageMode: "small",
9
+ pagePropsObj: {
10
+ page: 1,
11
+ pagesize: 10,
12
+ pagesizeOpts: [10, 20, 30, 50]
13
+ }
14
+ };
7
15
  },
8
16
  computed: {
9
17
  rowspanMap () {
@@ -12,17 +20,26 @@ export default {
12
20
  selfBasePropsObj () {
13
21
  return {
14
22
  _mergeRowColKeys: [] // 合并行的列
23
+ // _isUseDescSort: false // 是否使用使用倒序
15
24
  };
16
25
  },
26
+ // // 是否使用倒序
27
+ // isUseDescSort () {
28
+ // return this.selfPropsObj._isUseDescSort;
29
+ // },
17
30
  mergeRowColKeys () {
18
31
  const mergeRowColKeys = this.selfPropsObj._mergeRowColKeys || []; // 配置端有问题,高级依赖时值成undefined了
19
32
  return this.selfColumns
20
33
  .filter(colItem => mergeRowColKeys.includes(colItem._key))
21
34
  .map(colItem => colItem._key);
22
35
  },
36
+ // 是不是合并行表格
37
+ isMergeRowTable () {
38
+ return this.mergeRowColKeys.length;
39
+ },
23
40
  // 一级合并列keys(一级合并列:左侧第一合并列和右侧和并列)
24
41
  firstMergeRowColKeys () {
25
- if (this.mergeRowColKeys.length) {
42
+ if (this.isMergeRowTable) {
26
43
  const firstNormalIndex = this.selfColumns.findIndex(colItem => !this.mergeRowColKeys.includes(colItem._key));
27
44
 
28
45
  // -1代表无普通单元格,0代表第一列就是普通单元格
@@ -41,21 +58,38 @@ export default {
41
58
  notFirstMergeRowColKeys () {
42
59
  return this.mergeRowColKeys.filter(colKey => !this.firstMergeRowColKeys.includes(colKey));
43
60
  },
61
+ // 顶替tableBaseMixin里的
62
+ rowsNumStr () {
63
+ return `${this.isSearching ? "筛选" : "全部"}数据${this.isMergeRowTable ? `,共 ${this.total}条;` : ";"}`;
64
+ },
44
65
 
45
66
  allListData () {
46
67
  this.data.forEach(rowItem => {
47
68
  this.fixRowItem(rowItem);
48
69
  });
49
-
50
70
  this.initFlag = false;
51
- return this.data;
71
+
72
+ return this.isMergeRowTable
73
+ ? this.data
74
+ : this.isUseDescSort
75
+ ? [...this.data].reverse()
76
+ : this.data;
52
77
  },
53
78
  allListMap () {
54
79
  return this.$arrToMap(this.allListData, "_id");
55
80
  },
56
- // allListIds () {
57
- // return this.allListData.map(rowItem => rowItem._id);
58
- // },
81
+ // 渲染过的行 -但显示当前页
82
+ renderedShowListData () {
83
+ return this.isMergeRowTable
84
+ ? this.renderedListData
85
+ : this.curPageListData;
86
+ },
87
+ // 全部数据或筛选时符合条件的数据
88
+ curPageListData () {
89
+ return this.isMergeRowTable
90
+ ? this.showListData
91
+ : this.showListData.slice((this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize, this.pagePropsObj.page * this.pagePropsObj.pagesize);
92
+ },
59
93
  footerData () {
60
94
  return this.isSearching
61
95
  ? []
@@ -80,6 +114,12 @@ export default {
80
114
  ]
81
115
  : [];
82
116
  },
117
+ // 共多少分页
118
+ PageNum () {
119
+ return this.total % this.pagePropsObj.pagesize > 0
120
+ ? Math.ceil(this.total / this.pagePropsObj.pagesize)
121
+ : Math.floor(this.total / this.pagePropsObj.pagesize);
122
+ },
83
123
 
84
124
  showColumns () {
85
125
  return [
@@ -100,7 +140,7 @@ export default {
100
140
  fixed: "left",
101
141
  renderBodyCell: ({ row, rowIndex, column }, h) => {
102
142
  return [
103
- h("div", rowIndex + 1),
143
+ h("div", this.isMergeRowTable ? rowIndex + 1 : row.__index__),
104
144
 
105
145
  // 添加符
106
146
  ...this.operationIconRender(h, { row, rowIndex, column })
@@ -119,7 +159,7 @@ export default {
119
159
  },
120
160
  // 初始化合并单元格的rowspan
121
161
  initRowspan () {
122
- if (this.mergeRowColKeys.length) {
162
+ if (this.isMergeRowTable) {
123
163
  this.$set(this.tableDataObj, "rowspanMap", this.tableDataObj.rowspanMap || {});
124
164
 
125
165
  // TODO: 待删除
@@ -158,6 +198,20 @@ export default {
158
198
  }
159
199
  },
160
200
 
201
+ // 切换正倒序
202
+ changeSort () {
203
+ this.isUseDescSort = !this.isUseDescSort;
204
+ this.pagePropsObj.page = 1;
205
+ },
206
+ // 切换分页
207
+ changePage (page) {
208
+ this.pagePropsObj.page = page;
209
+ },
210
+ // 切换分页条数
211
+ changePageSize (pagesize) {
212
+ this.pagePropsObj.page = 1;
213
+ this.pagePropsObj.pagesize = pagesize;
214
+ },
161
215
  // 点击 -添加行
162
216
  clickCreate (operationItem, row, rowIndex, column) {
163
217
  const curColKey = column ? column._key : undefined;
@@ -165,7 +219,7 @@ export default {
165
219
  const newRow = this.getNewRowData();
166
220
 
167
221
  // 处理单元格合并相关
168
- if (this.mergeRowColKeys.length) {
222
+ if (this.isMergeRowTable) {
169
223
  // 非底部按钮添加时
170
224
  if (row) {
171
225
  // 寻找对应的行数据 -当前列是合并列会寻找,普通列不用找(就是row)
@@ -230,7 +284,28 @@ export default {
230
284
  const newRowIndex = row
231
285
  ? list.findIndex(rowItem => rowItem._id === row._id) + 1
232
286
  : list.length;
233
- list.splice(newRowIndex, 0, newRow);
287
+
288
+ if (this.isMergeRowTable) {
289
+ list.splice(newRowIndex, 0, newRow);
290
+ } else {
291
+ if (this.isUseDescSort) {
292
+ if (row) {
293
+ list.splice(newRowIndex - 1, 0, newRow);
294
+ rowIndex + 1 === this.pagePropsObj.pagesize && this.changePage(this.pagePropsObj.page + 1);
295
+ } else {
296
+ list.splice(newRowIndex, 0, newRow);
297
+ this.changePage(1);
298
+ }
299
+ } else {
300
+ if (row) {
301
+ list.splice(newRowIndex, 0, newRow);
302
+ rowIndex + 1 === this.pagePropsObj.pagesize && this.changePage(this.pagePropsObj.page + 1);
303
+ } else {
304
+ list.splice(newRowIndex, 0, newRow);
305
+ this.changePage(this.PageNum);
306
+ }
307
+ }
308
+ }
234
309
 
235
310
  this.change("createRow", newRow, newRowIndex, null);
236
311
  },
@@ -243,7 +318,7 @@ export default {
243
318
  const list = this.data;
244
319
 
245
320
  // 处理单元格合并相关
246
- if (this.mergeRowColKeys.length) {
321
+ if (this.isMergeRowTable) {
247
322
  this.mergeRowColKeys.forEach(colKey => {
248
323
  const column = { _key: colKey };
249
324
  const rowIndex = list.findIndex(dataItem => dataItem._id === row._id);
@@ -282,8 +282,8 @@ export default {
282
282
  list: [],
283
283
  tree: []
284
284
  },
285
-
286
285
  ...(this.selfBasePropsObj || {}),
286
+
287
287
  ...this.propsObj
288
288
  };
289
289
  },
@@ -415,14 +415,12 @@ export default {
415
415
  isSearching () {
416
416
  return this.$isAdvSearching(this.finalTableAdvSearch);
417
417
  },
418
- // 当前行数
419
- rowsNum () {
420
- return this.isSearching
421
- ? this.showListData.length
422
- : this.allListData.length;
423
- },
424
418
  rowsNumStr () {
425
- return `当前${this.isSearching ? "筛选" : "全部"}数据, 共 ${this.rowsNum} ${this.showMode === "form" ? "条" : "行"};`;
419
+ return `${this.isSearching ? "筛选" : "全部"}数据;`;
420
+ // return `${this.isSearching ? "筛选" : "全部"}数据;共 ${this.total}条;`;
421
+ },
422
+ controlShowKey () {
423
+ return this.isSearching ? "__isSearchShow__" : "__isShow__";
426
424
  },
427
425
 
428
426
  /* --- 数据 --- */
@@ -446,6 +444,7 @@ export default {
446
444
  .map(rowItem => rowItem._id)
447
445
  .filter(id => !!id);
448
446
  },
447
+ // 渲染过的行
449
448
  renderedListData () {
450
449
  return this.allListData.filter(rowItem => {
451
450
  this.dealSearchShow(rowItem);
@@ -453,13 +452,20 @@ export default {
453
452
  return rowItem.__isRendered__;
454
453
  });
455
454
  },
455
+ // 全部数据或筛选时符合条件的数据 -但显示当前页
456
456
  showListData () {
457
- return this.renderedListData.filter(rowItem =>
458
- this.isSearching
459
- ? !!rowItem.__isSearchShow__
460
- : !!rowItem.__isShow__
461
- );
457
+ return this.renderedListData
458
+ .filter(rowItem => !!rowItem[this.controlShowKey])
459
+ .map((rowItem, rowIndex) => {
460
+ rowItem.__index__ = rowIndex + 1;
461
+ return rowItem;
462
+ });
463
+ },
464
+ // 全部数据或筛选时符合条件的数据 总数
465
+ total () {
466
+ return this.showListData.length;
462
467
  },
468
+
463
469
  parentDataId () {
464
470
  return this.parentObj._id;
465
471
  },
@@ -801,9 +807,11 @@ export default {
801
807
  this.isExpandAction = false;
802
808
  this.dftAdvSearch.conditions = conditions;
803
809
  },
810
+ // 列表选择项改变
804
811
  changeSelect (list) {
805
812
  this.$emit("changeSelect", list);
806
813
  },
814
+
807
815
  // 输入框失去焦点
808
816
  controlBlur (operationItem, row, rowIndex, column, params) {
809
817
  this.$set(this.ruleRecordMap, this.getMixKey(row, column), { showRuleMessage: true });
@@ -1086,7 +1094,7 @@ export default {
1086
1094
  "display": "flex",
1087
1095
  "flex-direction": "row",
1088
1096
  "align-items": "center",
1089
- "margin-left": "16px"
1097
+ "margin-left": "12px"
1090
1098
  }
1091
1099
  }, [
1092
1100
  h("div", {
@@ -168,37 +168,39 @@
168
168
  <style lang="less">
169
169
  .BriCollapseTree {
170
170
  &-collapse {
171
- border: none;
172
-
173
- .ivu-collapse-item>.ivu-collapse-header {
174
- padding: 0px;
175
- height: auto;
176
- min-height: 32px;
177
- line-height: 18px;
178
- display: flex;
179
- align-items: center;
180
-
181
- i {
182
- margin-right: 0px;
171
+ &.ivu-collapse {
172
+ border: none;
173
+
174
+ .ivu-collapse-item > .ivu-collapse-header {
175
+ padding: 0px;
176
+ height: auto;
177
+ min-height: 32px;
178
+ line-height: 18px;
183
179
  display: flex;
184
180
  align-items: center;
185
- justify-content: center;
186
- width: 30px;
187
- height: 30px;
188
- }
189
181
 
190
- &:hover {
191
- background: @bgColor;
182
+ i {
183
+ margin-right: 0px;
184
+ display: flex;
185
+ align-items: center;
186
+ justify-content: center;
187
+ width: 30px;
188
+ height: 30px;
189
+ }
190
+
191
+ &:hover {
192
+ background: @bgColor;
193
+ }
192
194
  }
193
- }
194
195
 
195
- .ivu-collapse-content {
196
- padding: 0px;
197
- }
196
+ .ivu-collapse-content {
197
+ padding: 0px;
198
198
 
199
- .ivu-collapse-content>.ivu-collapse-content-box {
200
- padding: 0px;
201
- padding-left: 18px;
199
+ & > .ivu-collapse-content-box {
200
+ padding: 0px;
201
+ padding-left: 18px;
202
+ }
203
+ }
202
204
  }
203
205
  }
204
206
  }
@@ -43,4 +43,8 @@
43
43
  .ivu-select-dropdown {
44
44
  max-width: 420px;
45
45
  max-height: 300px;
46
+ }
47
+
48
+ .ivu-page-options-sizer {
49
+ margin-right: 0px;
46
50
  }
@@ -29,7 +29,8 @@ const getHeadRender = function (h, column, {
29
29
  style: {
30
30
  display: "inline-block",
31
31
  maxWidth: "100%",
32
- verticalAlign: "middle"
32
+ verticalAlign: "middle",
33
+ whiteSpace: "pre-line"
33
34
  },
34
35
  directives: [
35
36
  headHeightAuto