bri-components 1.3.23 → 1.3.25

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.
@@ -0,0 +1,217 @@
1
+ <template>
2
+ <div class="DshTreeTable">
3
+ <bri-table
4
+ class="DshTreeTable-main"
5
+ :columns="showColumns"
6
+ :data="listData"
7
+ :footer-data="footerData"
8
+ :propsObj="tablePropsObj"
9
+ @changeSelect="changeSelect"
10
+ @selectAll="changeSelect"
11
+ ></bri-table>
12
+ </div>
13
+ </template>
14
+
15
+ <script>
16
+ import DshFlatTableMixin from "./mixins/DshFlatTableMixin.js";
17
+ import tableMixin from "./mixins/tableMixin.js";
18
+ import DshListUnit from "../unit/DshListUnit.vue";
19
+
20
+ export default {
21
+ name: "DshTreeTable",
22
+ mixins: [
23
+ DshFlatTableMixin,
24
+ tableMixin
25
+ ],
26
+ components: {
27
+ DshListUnit
28
+ },
29
+ props: {},
30
+ data () {
31
+ return {};
32
+ },
33
+ computed: {
34
+ listData () {
35
+ return this.$getTreeFlatArr(this.data, "__isExpand__");
36
+ },
37
+
38
+ selfPropsObj () {
39
+ return {
40
+ ...this.commonPropsObj,
41
+
42
+ _maxLevel: this.commonPropsObj._maxLevel || 3
43
+ };
44
+ },
45
+ maxLevel () {
46
+ return this.selfPropsObj._maxLevel;
47
+ },
48
+ tablePropsObj () {
49
+ return {
50
+ maxHeight: this.contentHeight,
51
+ // rowStyleOption: {
52
+ // hoverHighlight: true,
53
+ // clickHighlight: true,
54
+ // stripe: true // 斑马纹
55
+ // },
56
+ cellStyleOption: {
57
+ bodyCellClass: ({ row, column, rowIndex }) => {
58
+ return "bri-table-td" +
59
+ `${
60
+ this.canEdit
61
+ ? " bri-table-td-edit"
62
+ : " bri-table-td-show"
63
+ }` +
64
+ `${
65
+ ["__isExpand__"].includes(column._key)
66
+ ? " bri-table-td-normal"
67
+ : ["__index__"].includes(column._key)
68
+ ? " bri-table-td-index"
69
+ : ""
70
+ }`;
71
+ }
72
+ },
73
+ // 通过实例方法 hideColumnsByKeys(keys)将列隐藏,通过实例方法 showColumnsByKeys(keys)将隐藏的列显示
74
+ columnHiddenOption: {
75
+ defaultHiddenColumnKeys: []
76
+ }
77
+ };
78
+ },
79
+ showColumns () {
80
+ return [
81
+ ...(this.useSelection === true ? [this.selectionColumn] : []),
82
+ this.expandColumn,
83
+ ...(this.useIndex === true ? [this.indexColumn] : []),
84
+ ...this.$transformToColumns(this.contentColumns),
85
+ ...(this.$getOperationList(["canDelete"]).length ? [this.operationColumn] : [])
86
+ ];
87
+ },
88
+ expandColumn () {
89
+ return {
90
+ // title: "开/合",
91
+ _key: "__isExpand__",
92
+ key: "__isExpand__",
93
+ field: "__isExpand__",
94
+ width: 46,
95
+ align: "center",
96
+ fixed: "left",
97
+ renderBodyCell: ({ row, column, rowIndex }, h) => {
98
+ return row.children && row.children.length
99
+ ? h("Icon", {
100
+ style: {
101
+ width: "14px",
102
+ height: "14px",
103
+ cursor: "pointer",
104
+ transform: row.__isExpand__ ? "rotate(90deg)" : "rotate(0deg)",
105
+ transition: "transform 0.4s"
106
+ },
107
+ props: {
108
+ type: "ios-arrow-forward",
109
+ size: "14"
110
+ },
111
+ on: {
112
+ click: () => {
113
+ this.toggleExpand(row, !row.__isExpand__);
114
+ }
115
+ }
116
+ })
117
+ : h("span", "");
118
+ }
119
+ };
120
+ },
121
+ indexColumn () {
122
+ return {
123
+ title: "序号",
124
+ _key: "__index__",
125
+ key: "__index__",
126
+ field: "__index__",
127
+ width: 28 + 16 + (this.maxLevel - 1) * 36,
128
+ align: "left",
129
+ fixed: "left",
130
+ renderBodyCell: ({ row, column, rowIndex }, h) => {
131
+ return [
132
+ h("div", {
133
+ style: {
134
+ paddingLeft: `${(row.level - 1) * 16}px`,
135
+ fontWeight: "500"
136
+ }
137
+ }, row.__treeIndex__),
138
+
139
+ // 添加符
140
+ row.level < this.maxLevel
141
+ ? h("div", {
142
+ style: {
143
+ position: "absolute",
144
+ bottom: "0px",
145
+ right: "0px",
146
+ display: "inline-block",
147
+ width: "16px",
148
+ height: " 16px",
149
+ border: "1px solid #dcdee2",
150
+ backgroundColor: "#ffffff",
151
+ lineHeight: "12px",
152
+ cursor: "pointer",
153
+ verticalAlign: "middle",
154
+ transition: "color .2s ease-in-out,border-color .2s ease-in-out"
155
+ }
156
+ }, [
157
+ h("Icon", {
158
+ style: {
159
+ fontWeight: "500"
160
+ },
161
+ props: {
162
+ type: "ios-add", // "md-add-circle"
163
+ size: "14"
164
+ },
165
+ on: {
166
+ click: () => {
167
+ // 新增行里的输入框,第一次输入会失去光标的bug,需要$set
168
+ const rowDefault = this.$deepCopy(this.rowDefault);
169
+ this.columns.forEach(column => {
170
+ // 用$set也可以
171
+ rowDefault[column._key] = rowDefault[column._key];
172
+ });
173
+
174
+ row.children.push({
175
+ _id: this.$ObjectID().str,
176
+ level: row.level + 1,
177
+ children: [],
178
+ ...rowDefault
179
+ });
180
+
181
+ this.toggleExpand(row, true);
182
+ }
183
+ }
184
+ })
185
+ ])
186
+ : h("span", "")
187
+ ];
188
+ }
189
+ };
190
+ }
191
+ },
192
+ created () {},
193
+ methods: {
194
+ toggleExpand (row, bool = true) {
195
+ this.$set(row, "__isExpand__", bool);
196
+
197
+ // this.$set(row, "__isRendered__", true);
198
+ // row.children.forEach(subRow => {
199
+ // this.$set(subRow, "__isShow__", bool);
200
+ // });
201
+ }
202
+ }
203
+ };
204
+ </script>
205
+
206
+ <style lang="less" scoped>
207
+ .DshTreeTable {
208
+ &-main {
209
+ width: 100%;
210
+ height: auto;
211
+ }
212
+
213
+ &-create {
214
+ margin-top: 8px;
215
+ }
216
+ }
217
+ </style>
@@ -30,13 +30,20 @@ export default {
30
30
  return {};
31
31
  }
32
32
  },
33
- parentObj: {
33
+ propsObj: {
34
34
  type: Object,
35
35
  default () {
36
36
  return {};
37
37
  }
38
38
  },
39
- propsObj: {
39
+
40
+ parentFormList: {
41
+ type: Array,
42
+ default () {
43
+ return [];
44
+ }
45
+ },
46
+ parentObj: {
40
47
  type: Object,
41
48
  default () {
42
49
  return {};
@@ -80,7 +87,7 @@ export default {
80
87
  _heightAuto: false, // 单元格高度自适应
81
88
  _useSelection: false, // 使用选择列
82
89
  _useIndex: true, // 使用序号列
83
- _useSummary: false, // 使用汇总行
90
+ _useSummary: true, // 使用汇总行
84
91
  _disabledBtns: false, // 禁用增删按钮
85
92
  _disabledCreateBtn: false, // 置灰新增按钮,目前只内部使用,comp_web数据表配置页那块
86
93
  _disabledOldDataRow: false, // 置灰老数据行包含删除
@@ -115,6 +122,7 @@ export default {
115
122
  },
116
123
 
117
124
  filterColumns () {
125
+ console.log(this.listData);
118
126
  return this.columns.filter(col => this.$isAdvRelyShow(col, this.listData, this.parentObj, true));
119
127
  },
120
128
  selfRowDefault () {
@@ -174,10 +182,15 @@ export default {
174
182
  /* --------------- 工具方法 ------------- */
175
183
  getRowCanEdit (row) {
176
184
  return this.canEdit && // 是否是编辑状态
177
- (!this.disabledOldDataRow || !!row.__isCreate__); // 是否让老数据行置灰
185
+ (this.disabledOldDataRow ? !!row.__isCreate__ : true); // 是否让老数据行置灰
178
186
  },
179
187
  getColCanEdit (col, row) {
180
- return (!col.dependRowCanEdit || row.canEdit !== false);// 在老数据行里某些列不可编辑
188
+ return col.dependRowCanEdit ? row.canEdit !== false : true;// 在老数据行里某些列不可编辑
189
+ },
190
+ getUnitCanEdit (col, row) {
191
+ return this.getRowCanEdit(row) &&
192
+ this.getColCanEdit(col, row) &&
193
+ this.$isAdvRelyShow(col, row, this.parentObj, true);
181
194
  },
182
195
  isShowCompare (col, row, oldRow = {}) {
183
196
  return this.useCampare && ["number"].includes(col._type) &&
@@ -0,0 +1,279 @@
1
+ export default {
2
+ mixins: [],
3
+ components: {},
4
+ props: {},
5
+ data () {
6
+ return {};
7
+ },
8
+ computed: {
9
+ footerData () {
10
+ if (this.useSummary && this.listData.length) {
11
+ return [
12
+ this.filterColumns.reduce((obj, col) => {
13
+ return {
14
+ ...obj,
15
+ [col._key]: col._type === "number"
16
+ ? this.$calNumList(this.listData.map(item => item[col._key]), col._summaryType, { ...col, _defaultDigit: 2 })
17
+ : (obj[col._key] || "--")
18
+ };
19
+ }, {
20
+ _id: this.$ObjectID().str,
21
+ __index__: "汇总",
22
+ __isExpand__: "-",
23
+ __operation__: "——"
24
+ })
25
+ ];
26
+ } else {
27
+ return [];
28
+ }
29
+ },
30
+
31
+ tablePropsObj () {
32
+ return {
33
+ maxHeight: this.contentHeight,
34
+ cellStyleOption: {
35
+ bodyCellClass: ({ row, column, rowIndex }) => {
36
+ return "bri-table-td" +
37
+ `${this.canEdit
38
+ ? " bri-table-td-edit"
39
+ : " bri-table-td-show"
40
+ }`;
41
+ }
42
+ }
43
+ };
44
+ },
45
+ selfPropsObj () {
46
+ return {
47
+ ...this.commonPropsObj
48
+ };
49
+ },
50
+ showRequired () {
51
+ return this.selfPropsObj._showRequired;
52
+ },
53
+ showDescription () {
54
+ return this.selfPropsObj._showDescription;
55
+ },
56
+ headHeightAuto () {
57
+ return this.selfPropsObj._headHeightAuto;
58
+ },
59
+ heightAuto () {
60
+ return this.selfPropsObj._heightAuto;
61
+ },
62
+
63
+ showColumns () {
64
+ return [
65
+ ...(this.useSelection === true ? [this.selectionColumn] : []),
66
+ ...(this.useIndex === true ? [this.indexColumn] : []),
67
+ ...this.$transformToColumns(this.contentColumns),
68
+ ...(this.$getOperationList(["canDelete"]).length ? [this.operationColumn] : [])
69
+ ];
70
+ },
71
+ selectionColumn () {
72
+ return {
73
+ _key: "__selection__",
74
+ key: "__selection__",
75
+ field: "__selection__",
76
+ type: "checkbox",
77
+ width: 66,
78
+ align: "center",
79
+ fixed: "left"
80
+ };
81
+ },
82
+ indexColumn () {
83
+ return {
84
+ title: "序号",
85
+ _key: "__index__",
86
+ key: "__index__",
87
+ field: "__index__",
88
+ width: 76,
89
+ align: "center",
90
+ fixed: "left",
91
+ renderBodyCell: ({ row, column, rowIndex }) => ++rowIndex
92
+ };
93
+ },
94
+ operationColumn () {
95
+ return {
96
+ title: "操作",
97
+ _key: "__operation__",
98
+ key: "__operation__",
99
+ field: "__operation__",
100
+ align: "center",
101
+ fixed: "right",
102
+ width: 100,
103
+ renderBodyCell: ({ row, column, rowIndex }, h) => {
104
+ const operationList = this.$getOperationList(["canDelete"]);
105
+
106
+ return h("dsh-buttons", {
107
+ props: {
108
+ list: operationList.map(btnItem => ({
109
+ ...btnItem,
110
+ disabled: this.disabledOldDataRow && !row.__isCreate__
111
+ }))
112
+ },
113
+ on: {
114
+ click: (operationItem) => {
115
+ this.$dispatchEvent(operationItem, row, rowIndex, this.listData);
116
+ }
117
+ }
118
+ });
119
+ }
120
+ };
121
+ },
122
+ contentColumns () {
123
+ return this.filterColumns.map(colItem => ({
124
+ filter: undefined,
125
+ sortBy: undefined,
126
+ renderBodyCell: ({ row, column, rowIndex }, h) => {
127
+ column = this.$transformFieldProperty(column, row, this.parentObj);
128
+ column = this.resetCol(column, row);
129
+ const unitCanEdit = this.getUnitCanEdit(column, row);
130
+
131
+ return [
132
+ this.isShowCompare(column, row, this.oldListData[rowIndex])
133
+ ? h("Tooltip", {
134
+ style: {
135
+ width: "100%"
136
+ },
137
+ props: {
138
+ content: this.$isEmptyData(this.oldListData[rowIndex][column._key])
139
+ ? ""
140
+ : this.oldListData[rowIndex][column._key],
141
+ transfer: true,
142
+ maxWidth: 200,
143
+ placement: "top"
144
+ },
145
+ scopedSlots: {
146
+ default: props => h("dsh-list-unit", {
147
+ props: {
148
+ canEdit: unitCanEdit,
149
+ formData: row,
150
+ formItem: column,
151
+ rowIndex: rowIndex,
152
+ allFormList: this.columns,
153
+ parentListData: this.listData,
154
+ parentFormList: this.parentFormList,
155
+ parentObj: this.parentObj
156
+ },
157
+ on: {
158
+ blur: () => this.controlBlur(null, column, row, arguments),
159
+ change: () => this.$dispatchEvent(this.operationMap.changeVal, column, row, rowIndex, arguments)
160
+ }
161
+ })
162
+ }
163
+ })
164
+ : h("dsh-list-unit", {
165
+ props: {
166
+ canEdit: unitCanEdit,
167
+ formData: row,
168
+ formItem: column,
169
+ rowIndex: rowIndex,
170
+ allFormList: this.columns,
171
+ parentListData: this.listData,
172
+ parentFormList: this.parentFormList,
173
+ parentObj: this.parentObj
174
+ },
175
+ on: {
176
+ blur: () => this.controlBlur(null, column, row, arguments),
177
+ change: () => this.$dispatchEvent(this.operationMap.changeVal, column, row, rowIndex, arguments)
178
+ }
179
+ }),
180
+
181
+ !this.getColRuleResult(column, row).bool
182
+ ? h("span", {
183
+ class: "bri-table-td-tip"
184
+ }, this.getColRuleResult(column, row).message)
185
+ : undefined
186
+ ];
187
+ },
188
+ renderHeaderCell: ({ column }, h) => {
189
+ column = this.$transformFieldProperty(column, undefined, this.parentObj);
190
+
191
+ return this.$getHeadRender(h, column, {
192
+ showRequired: this.showRequired,
193
+ showDescription: this.showDescription,
194
+ headHeightAuto: this.headHeightAuto
195
+ });
196
+ },
197
+ ...colItem
198
+ }));
199
+ },
200
+
201
+ allOperationMap () {
202
+ return {
203
+ canCreate: {
204
+ name: "添加一行",
205
+ type: "canCreate",
206
+ size: "default",
207
+ long: true,
208
+ disabled: !!this.disabledCreateBtn,
209
+ event: "clickCreate",
210
+ btnType: "default"
211
+ },
212
+ canDelete: {
213
+ name: "删除",
214
+ type: "canDelete",
215
+ btnType: "errorText",
216
+ icon: "ios-trash-outline",
217
+ size: "small",
218
+ disabled: false,
219
+ event: "clickDelete"
220
+ },
221
+ // expand: {
222
+ // name: "展开",
223
+ // type: "expand",
224
+ // event: "clickExpand"
225
+ // },
226
+ changeVal: {
227
+ name: "改变输入框值",
228
+ type: "changeVal",
229
+ event: "changeVal"
230
+ }
231
+ };
232
+ }
233
+ },
234
+ created () { },
235
+ methods: {
236
+ // 点击 -添加行
237
+ clickCreate (operationItem, row, index, list) {
238
+ const newRow = {
239
+ ...this.$deepCopy(this.selfRowDefault),
240
+ __isCreate__: true,
241
+ _id: this.$ObjectID().str
242
+ };
243
+ const newRowIndex = index == null ? list.length : index + 1;
244
+ list.splice(newRowIndex, 0, newRow);
245
+ this.$forceUpdate(); // 自定义页中点击添加一行没有更新页面
246
+
247
+ this.change("createRow", null, newRow, newRowIndex);
248
+ },
249
+ changeSelect (list) {
250
+ this.$emit("changeSelect", list);
251
+ },
252
+ // 表单控件值改变
253
+ changeVal (operationItem, col, row, rowIndex, params) {
254
+ this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
255
+ this.change("changeVal", col, row, rowIndex, ...params);
256
+ },
257
+ // 表单控件失去焦点
258
+ controlBlur (operationItem, col, row, params) {
259
+ this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
260
+ },
261
+
262
+ resetCol (col, row) {
263
+ let resetMap = {
264
+ select: {
265
+ _optionKind: "dropdown"
266
+ },
267
+ checkbox: {
268
+ _optionKind: "dropdown"
269
+ }
270
+ };
271
+ return {
272
+ ...col,
273
+ ...(resetMap[col._type] || {}),
274
+ // isShare: this.isShare,
275
+ _heightAuto: this.heightAuto
276
+ };
277
+ }
278
+ }
279
+ };
@@ -77,6 +77,10 @@
77
77
  :value="formData"
78
78
  :propsObj="formItem"
79
79
  :allFormList="allFormList"
80
+ :rowIndex="rowIndex"
81
+ :parentListData="parentListData"
82
+ :parentFormList="parentFormList"
83
+ :parentObj="parentObj"
80
84
  @change="change"
81
85
  @refChange="refChange"
82
86
  @changeField="changeField"
@@ -23,9 +23,11 @@
23
23
  size: 'default',
24
24
  inTable: true
25
25
  }"
26
- :rowIndex="rowIndex"
27
26
  :allFormList="allFormList"
27
+ :rowIndex="rowIndex"
28
28
  :parentListData="parentListData"
29
+ :parentFormList="parentFormList"
30
+ :parentObj="parentObj"
29
31
  @blur="blur"
30
32
  @change="change"
31
33
  ></component>
@@ -47,14 +49,7 @@
47
49
  default: false
48
50
  },
49
51
 
50
- indexStr: String,
51
- rowIndex: Number,
52
- parentListData: {
53
- type: Array,
54
- default () {
55
- return [];
56
- }
57
- }
52
+ indexStr: String
58
53
  },
59
54
  data () {
60
55
  return {};
@@ -24,6 +24,26 @@ export default {
24
24
  default () {
25
25
  return [];
26
26
  }
27
+ },
28
+
29
+ rowIndex: Number,
30
+ parentListData: {
31
+ type: Array,
32
+ default () {
33
+ return [];
34
+ }
35
+ },
36
+ parentFormList: {
37
+ type: Array,
38
+ default () {
39
+ return [];
40
+ }
41
+ },
42
+ parentObj: {
43
+ type: Object,
44
+ default () {
45
+ return {};
46
+ }
27
47
  }
28
48
  },
29
49
  data () {
package/src/index.js CHANGED
@@ -16,6 +16,7 @@ import DshTable from "./components/list/DshBox/DshTable.vue";
16
16
  import DshPage from "./components/list/DshPage.vue";
17
17
  import DshCrossTable from "./components/list/DshBox/DshCrossTable.vue";
18
18
  // import DshCascaderTable from "./components/list/DshCascaderTable.vue";
19
+ // import DshTreeTable from "./components/list/DshTreeTable.vue";
19
20
 
20
21
  // form
21
22
  import DshForm from "./components/form/DshForm.vue";
@@ -230,6 +231,7 @@ export {
230
231
 
231
232
  DshFlatTable,
232
233
  // DshCascaderTable,
234
+ // DshTreeTable,
233
235
 
234
236
  BriCard,
235
237
  BriTree,
@@ -63,7 +63,7 @@
63
63
  }
64
64
 
65
65
  // tbody.ve-table-body tr.ve-table-body-tr td.ve-table-body-td {
66
- // padding: 4px 20px;
66
+ // padding: 4px 12px;
67
67
  // }
68
68
  }
69
69
  }
@@ -120,7 +120,7 @@
120
120
  line-height: 1;
121
121
  color: #ed4014;
122
122
  position: absolute;
123
- top: calc(100% -15px);
123
+ top: calc(100% - 13px);
124
124
  left: 0px;
125
125
  }
126
126
 
@@ -146,6 +146,14 @@
146
146
  }
147
147
  &-show {
148
148
  padding: 4px 20px!important;
149
+ // padding: 4px 12px!important;
150
+ }
151
+ &-normal {
152
+ padding: 4px 8px!important;
153
+ // padding: 4px 12px!important;
154
+ }
155
+ &-index {
156
+ padding: 4px 16px 4px 12px!important;
149
157
  }
150
158
  }
151
159
  }
@@ -34,7 +34,7 @@
34
34
  color: @textColor;
35
35
  }
36
36
  .dsh-hide {
37
- display: none;;
37
+ display: none!important;
38
38
  }
39
39
  .dsh-subtip {
40
40
  width: 100%;