bri-components 1.5.8 → 1.5.10

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.5.8",
3
+ "version": "1.5.10",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -203,6 +203,11 @@
203
203
 
204
204
  clearTimeout(this.timer);
205
205
  this.timer = setTimeout(() => {
206
+ // 对文本框进行前后空格处理(鞋写在上面不行,虽然input会早于onChange事件,但还是不行;值会更新,界面不更新)
207
+ if (["text"].includes(this.controlType) && this.value[this.controlKey]) {
208
+ this.value[this.controlKey] = this.value[this.controlKey].trim();
209
+ }
210
+
206
211
  this.change();
207
212
  this.$emit("inputChange");
208
213
  }, 800);
@@ -90,7 +90,7 @@ export default {
90
90
  : this.selfPropsObj._data;
91
91
  },
92
92
  cascaderAllData () {
93
- const loop = (arr = [], level, parentKeys = [], filterVals = [], cascaderVals = [], reverseFilter = false, isMobile = false, saveKey = "_key", valueKey = "code", nameKey = "name") => {
93
+ const loop = (arr = [], level, parentKeys = [], filterVals = [], cascaderVals = [], reverseFilter = false, isMb = false, saveKey = "_key", valueKey = "code", nameKey = "name") => {
94
94
  arr = cascaderVals.length
95
95
  ? arr.filter(item => {
96
96
  const itemKey = item[saveKey];
@@ -134,17 +134,17 @@ export default {
134
134
  (!level || level > newItem.level) &&
135
135
  (newItem.children && newItem.children.length)
136
136
  ) {
137
- newItem.children = loop(newItem.children, level, newItem.keys, [], cascaderVals, reverseFilter, isMobile, saveKey, valueKey, nameKey);
137
+ newItem.children = loop(newItem.children, level, newItem.keys, [], cascaderVals, reverseFilter, isMb, saveKey, valueKey, nameKey);
138
138
 
139
139
  if (newItem.children.length) {
140
140
  newItem.loading = false; // 此代码pc端在用:为了所请求的级,出现继续加载的箭头图标
141
141
  newItem.isLeaf = false;
142
142
  } else {
143
- newItem.children = isMobile ? undefined : [];
143
+ newItem.children = isMb ? undefined : [];
144
144
  newItem.isLeaf = true;
145
145
  }
146
146
  } else {
147
- newItem.children = isMobile ? undefined : [];
147
+ newItem.children = isMb ? undefined : [];
148
148
  newItem.isLeaf = true;
149
149
  }
150
150
 
@@ -155,10 +155,10 @@ export default {
155
155
  }, []);
156
156
  };
157
157
 
158
- return loop(this.originData, this.cascaderLevel, [], this.filterVals, this.cascaderVals, this.reverseFilter, this.isMobile, this.saveKey, this.valueKey, this.nameKey);
158
+ return loop(this.originData, this.cascaderLevel, [], this.filterVals, this.cascaderVals, this.reverseFilter, this.isMb, this.saveKey, this.valueKey, this.nameKey);
159
159
  },
160
160
  cascaderData () {
161
- const loop = (arr = [], isMobile) => {
161
+ const loop = (arr = [], isMb) => {
162
162
  return arr
163
163
  ? arr.reduce((newArr, item) => {
164
164
  if (item.rm !== 1) {
@@ -167,15 +167,15 @@ export default {
167
167
  };
168
168
 
169
169
  if (newItem.children && newItem.children.length) {
170
- newItem.children = loop(newItem.children, isMobile);
170
+ newItem.children = loop(newItem.children, isMb);
171
171
 
172
172
  if (newItem.children.length) {
173
173
  // 无需处理
174
174
  } else {
175
- newItem.children = isMobile ? undefined : [];
175
+ newItem.children = isMb ? undefined : [];
176
176
  }
177
177
  } else {
178
- newItem.children = isMobile ? undefined : [];
178
+ newItem.children = isMb ? undefined : [];
179
179
  }
180
180
 
181
181
  newArr.push(newItem);
@@ -139,10 +139,10 @@ export default {
139
139
  isTagShow () {
140
140
  return ["switch", "select", "checkbox", "regions", "cascaders", "users", "departments", "labels", "refSelect", "refCheckbox"].includes(this.controlType);
141
141
  },
142
- // 点击行或单元格查看详细内容 -"flatTable", "cascaderTable", "reference", "referenceBy"在用
143
- showDetailOnCR () {
144
- return !!this.selfPropsObj && [true, false].includes(this.selfPropsObj._showDetailOnCR)
145
- ? this.selfPropsObj._showDetailOnCR
142
+ // 全称showDetailOnClickUnitContent,点击行或单元格查看详细内容 -"flatTable", "cascaderTable", "reference", "referenceBy"在用
143
+ showDetailOnCUC () {
144
+ return !!this.selfPropsObj && [true, false].includes(this.selfPropsObj._showDetailOnCUC)
145
+ ? this.selfPropsObj._showDetailOnCUC
146
146
  : true;
147
147
  },
148
148
 
@@ -190,10 +190,6 @@ export default {
190
190
  isInTable () {
191
191
  return !!this.propsObj.inTable;
192
192
  },
193
- // 单条关联内 使用详情模式的
194
- isInRefDetail () {
195
- return !!this.propsObj.inRefDetail;
196
- },
197
193
  // 在高级搜索下
198
194
  isInSearch () {
199
195
  return !!this.propsObj.inSearch;
@@ -220,15 +216,18 @@ export default {
220
216
  },
221
217
 
222
218
  /* ----- 部分控件下 才使用的属性 ----- */
219
+ isMobile () {
220
+ return this.propsObj.isMobile;
221
+ },
222
+ controlThemeColor () {
223
+ return this.propsObj.controlThemeColor;
224
+ },
223
225
  compKey () {
224
226
  return this.propsObj.compKey;
225
227
  },
226
228
  appKey () {
227
229
  return this.propsObj.appKey;
228
230
  },
229
- controlThemeColor () {
230
- return this.propsObj.controlThemeColor;
231
- },
232
231
  entityKey () {
233
232
  return this.propsObj.entityKey;
234
233
  },
@@ -241,6 +240,10 @@ export default {
241
240
  allScreenKey () {
242
241
  return this.propsObj.allScreenKey;
243
242
  },
243
+ // 单条关联内 使用详情模式的
244
+ isInRefDetail () {
245
+ return !!this.propsObj.inRefDetail;
246
+ },
244
247
 
245
248
  /* ----- 移动端在用 ----- */
246
249
  // 只做校验而隐藏的的field框,所用的propsObj
@@ -372,12 +375,19 @@ export default {
372
375
  this.showModal = false;
373
376
  },
374
377
 
375
- // 单元格展示 -打开列表模态框
376
- openUnitModal (event) {
377
- if (this.showDetailOnCR) {
378
- this.showUnitModal = true;
378
+ // 点击外层dom(主要针对单元格空白处)
379
+ clickControlWrapper (event) {
380
+ // 点击行是选择数据效果时,点击单元格空白和点击行效果一样(啥也不做);点击表格行进的是详情的话,点某列单元格空白处,显示谁都有争议,没有效果最好
381
+ if ((this.isUnitShow && this.showDetailOnCUC) || !this.isUnitShow) {
379
382
  event.stopPropagation();
380
383
  }
384
+ },
385
+ // 点击单元格里的内容 -打开详情模态框
386
+ clickUnitContent (event) {
387
+ if ((this.isUnitShow && this.showDetailOnCUC) || this.isUnitUpdate) {
388
+ // event.stopPropagation(); // 可有可无,最外层已经阻止冒泡
389
+ this.showUnitModal = true;
390
+ }
381
391
  }
382
392
  }
383
393
  };
@@ -1,10 +1,13 @@
1
1
  <template>
2
- <div class="cascaderTable">
2
+ <div
3
+ class="cascaderTable"
4
+ @click="clickControlWrapper"
5
+ >
3
6
  <!-- 查看 单元格内 -->
4
7
  <template v-if="isUnitShow">
5
8
  <span
6
9
  class="cascaderTable-unit"
7
- @click="openUnitModal"
10
+ @click="clickUnitContent"
8
11
  >
9
12
  <dsh-icons :list="[{
10
13
  customIcon: 'bico-Cascadetable'
@@ -1,10 +1,13 @@
1
1
  <template>
2
- <div class="flatTable">
2
+ <div
3
+ class="flatTable"
4
+ @click="clickControlWrapper"
5
+ >
3
6
  <!-- 查看 单元格内 -->
4
7
  <template v-if="isUnitShow">
5
8
  <span
6
9
  class="flatTable-unit"
7
- @click="openUnitModal"
10
+ @click="clickUnitContent"
8
11
  >
9
12
  <dsh-icons :list="[{
10
13
  customIcon: 'bico-internaltable'
@@ -164,21 +164,17 @@ export default {
164
164
  },
165
165
  // 全部数据 或 筛选时符合条件的数据 -当前页的
166
166
  curPageShowListData () {
167
- return this.pagePropsObj.page >= 1
168
- ? (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize >= this.showListData.length
169
- ? this.showListData.slice(-(
170
- this.showListData.length % this.pagePropsObj.pagesize === 0
171
- ? this.pagePropsObj.pagesize
172
- : this.showListData.length % this.pagePropsObj.pagesize
173
- ))
174
- : this.showListData.slice(
175
- (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize,
176
- this.pagePropsObj.page * this.pagePropsObj.pagesize
177
- )
167
+ const page = this.pagePropsObj.page;
168
+ const pagesize = this.pagePropsObj.pagesize;
169
+
170
+ return page >= 1
171
+ ? (page - 1) * pagesize >= this.showListData.length
172
+ ? this.showListData.slice(-(this.showListData.length % pagesize || pagesize))
173
+ : this.showListData.slice((page - 1) * pagesize, page * pagesize)
178
174
  : [];
179
175
  },
180
176
  // 全部数据 或 筛选时符合条件的数据 -共多少分(!!!最小为1)
181
- PageNum () {
177
+ pageNum () {
182
178
  return (
183
179
  this.selfTotal % this.pagePropsObj.pagesize > 0
184
180
  ? Math.ceil(this.selfTotal / this.pagePropsObj.pagesize)
@@ -187,27 +183,41 @@ export default {
187
183
  }
188
184
  },
189
185
  created () {
190
- this.selfInit();
186
+ this.flatTableMixinInit();
191
187
  },
192
188
  methods: {
193
- selfInit () {
189
+ flatTableMixinInit () {
190
+ this.selfReset();
191
+ },
192
+ // 自身的重置
193
+ selfReset () {
194
194
  this.isUseDescSort = this.selfPropsObj._isUseDescSort;
195
195
  this.pagePropsObj.pagesize = this.selfPropsObj._pagesize || this.selfBasePropsObj._pagesize;
196
196
  this.initRowspan();
197
197
  },
198
- // 本身的初始化
199
- selfReset () {
200
- this.selfInit();
198
+
199
+ // 也供外部使用 -转到最后一条数据所在的分页
200
+ goLastDataPage () {
201
+ if (this.isUseDescSort) {
202
+ if (this.pagePropsObj.page !== 1) {
203
+ this.changePage(1);
204
+ }
205
+ } else {
206
+ if (this.pagePropsObj.page !== this.pageNum) {
207
+ this.changePage(this.pageNum);
208
+ }
209
+ }
201
210
  },
202
- fixSelfRowData (row) {
203
- if (this.initFlag) {
204
- // 每条数据都补充全所有字段值(赋一个默认的空值)
205
- this.selfColumns.forEach((colItem) => {
206
- // 不用row[colItem._key] === undefined判断,是因为后端给的空值不可靠,多选的有时候都能给null
207
- if (!Object.prototype.hasOwnProperty.call(row, colItem._key) && this.$isEmptyData(row[colItem._key])) {
208
- this.$set(row, colItem._key, this.$deepCopy(this.dftInitValMap[colItem._type]));
209
- }
210
- });
211
+ // 也供外部使用 -删除数据时,更正this.pagePropsObj.page
212
+ fixCurPage () {
213
+ if (this.pagePropsObj.page > this.pageNum) {
214
+ this.changePage(this.pageNum);
215
+ }
216
+ },
217
+ // 暂未供外部使用 -判断是否要转到下一页(在本页最后一条上插入一行时,要转到下一页)
218
+ goNextPage (rowIndex) {
219
+ if (rowIndex + 1 === this.pagePropsObj.pagesize) {
220
+ this.changePage(this.pagePropsObj.page + 1);
211
221
  }
212
222
  },
213
223
 
@@ -218,7 +228,7 @@ export default {
218
228
  },
219
229
  // 切换分页
220
230
  changePage (page) {
221
- this.pagePropsObj.page = page;
231
+ this.pagePropsObj.page = page || 1;
222
232
  this.loadingFunc();
223
233
  },
224
234
  // 切换分页条数
@@ -307,26 +317,18 @@ export default {
307
317
  if (this.isUseDescSort) {
308
318
  if (row) {
309
319
  list.splice(newRowIndex - 1, 0, newRow);
310
- if (rowIndex + 1 === this.pagePropsObj.pagesize) {
311
- this.changePage(this.pagePropsObj.page + 1); // 一定翻页了
312
- }
320
+ this.goNextPage(rowIndex);
313
321
  } else {
314
322
  list.splice(newRowIndex, 0, newRow);
315
- if (this.pagePropsObj.page !== 1) {
316
- this.changePage(1);
317
- }
323
+ this.goLastDataPage();
318
324
  }
319
325
  } else {
320
326
  if (row) {
321
327
  list.splice(newRowIndex, 0, newRow);
322
- if (rowIndex + 1 === this.pagePropsObj.pagesize) {
323
- this.changePage(this.pagePropsObj.page + 1); // 一定翻页了
324
- }
328
+ this.goNextPage(rowIndex);
325
329
  } else {
326
330
  list.splice(newRowIndex, 0, newRow);
327
- if (this.pagePropsObj.page !== this.PageNum) {
328
- this.changePage(this.PageNum);
329
- }
331
+ this.goLastDataPage();
330
332
  }
331
333
  }
332
334
  }
@@ -370,6 +372,7 @@ export default {
370
372
 
371
373
  const listIndex = list.findIndex(rowItem => rowItem._id === row._id);
372
374
  list.splice(listIndex, 1);
375
+ this.fixCurPage();
373
376
 
374
377
  this.change("deleteRow", row, rowIndex, null);
375
378
  }
@@ -412,6 +415,17 @@ export default {
412
415
  },
413
416
 
414
417
  /* ----------- 方法 ---------- */
418
+ fixSelfRowData (row) {
419
+ if (this.initFlag) {
420
+ // 每条数据都补充全所有字段值(赋一个默认的空值)
421
+ this.selfColumns.forEach((colItem) => {
422
+ // 不用row[colItem._key] === undefined判断,是因为后端给的空值不可靠,多选的有时候都能给null
423
+ if (!Object.prototype.hasOwnProperty.call(row, colItem._key) && this.$isEmptyData(row[colItem._key])) {
424
+ this.$set(row, colItem._key, this.$deepCopy(this.dftInitValMap[colItem._type]));
425
+ }
426
+ });
427
+ }
428
+ },
415
429
  // 初始化合并单元格的rowspan
416
430
  initRowspan () {
417
431
  if (this.isMergeRowTable) {
@@ -85,7 +85,7 @@ export default {
85
85
  },
86
86
  created () { },
87
87
  methods: {
88
- // 本身的初始化
88
+ // 自身的重置
89
89
  selfReset () {
90
90
  this.searchMode = "flat";
91
91
  },