iov-pro-components 0.0.17 → 0.0.18

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.
@@ -5844,6 +5844,13 @@ var script$p = {
5844
5844
  return [];
5845
5845
  }
5846
5846
  },
5847
+ // 已选择的数据过滤字段
5848
+ filterField2: {
5849
+ type: Array,
5850
+ default: function _default() {
5851
+ return [];
5852
+ }
5853
+ },
5847
5854
  // 全部列scheme
5848
5855
  unselectColumns: {
5849
5856
  type: Array,
@@ -5872,6 +5879,18 @@ var script$p = {
5872
5879
  visible: {
5873
5880
  type: Boolean,
5874
5881
  default: false
5882
+ },
5883
+ // 自定义搜索表单项
5884
+ customSearchFormItems: {
5885
+ type: Array,
5886
+ default: function _default() {
5887
+ return [];
5888
+ }
5889
+ },
5890
+ // 自定义搜索请求
5891
+ customSearchRequest: {
5892
+ type: Object,
5893
+ default: null
5875
5894
  }
5876
5895
  },
5877
5896
  data: function data() {
@@ -5879,6 +5898,7 @@ var script$p = {
5879
5898
  showDialog: false,
5880
5899
  activeName: '0',
5881
5900
  filterText: '',
5901
+ filterText2: '',
5882
5902
  selectedData: [],
5883
5903
  tableHeight: 'auto'
5884
5904
  };
@@ -5909,15 +5929,18 @@ var script$p = {
5909
5929
  return this.selectedData;
5910
5930
  }
5911
5931
  // 如果当前没有过滤数据
5912
- if ([null, undefined, ''].includes(this.filterText) || this.filterField.length === 0) {
5932
+ if ([null, undefined, ''].includes(this.filterText2) || this.filterField2.length === 0) {
5913
5933
  return this.selectedData;
5914
5934
  }
5915
5935
  // 返回过滤后的数据
5916
5936
  return this.selectedData.filter(function (item) {
5917
- return _this2.filterField.some(function (name) {
5918
- return item[name].indexOf(_this2.filterText) >= 0;
5937
+ return _this2.filterField2.some(function (name) {
5938
+ return item[name].indexOf(_this2.filterText2) >= 0;
5919
5939
  });
5920
5940
  });
5941
+ },
5942
+ isCustomSearch: function isCustomSearch() {
5943
+ return _typeof$1(this.customSearchFormItems) === 'object' && Object.keys(this.customSearchFormItems).length;
5921
5944
  }
5922
5945
  },
5923
5946
  watch: {
@@ -5927,21 +5950,23 @@ var script$p = {
5927
5950
  if (val) {
5928
5951
  this.$nextTick(function () {
5929
5952
  _this3.selectedData = _this3.value;
5930
- _this3.$refs.unselect.$refs.table.clearSelection();
5953
+ _this3.getElTable().clearSelection();
5931
5954
  _this3.selectedData.forEach(function (row) {
5932
- _this3.$refs.unselect.$refs.table.toggleRowSelection(row);
5955
+ _this3.getElTable().toggleRowSelection(row);
5933
5956
  });
5934
5957
  _this3.initHeight();
5935
5958
  });
5936
5959
  } else {
5937
5960
  this.filterText = '';
5961
+ this.filterText2 = '';
5938
5962
  this.activeName = '0';
5939
5963
  this.selectedData = [];
5940
- this.$refs.unselect.$refs.table.clearSelection();
5964
+ this.getElTable().clearSelection();
5941
5965
  }
5942
5966
  },
5943
5967
  activeName: function activeName() {
5944
5968
  this.filterText = '';
5969
+ this.filterText2 = '';
5945
5970
  }
5946
5971
  },
5947
5972
  methods: {
@@ -5951,6 +5976,9 @@ var script$p = {
5951
5976
  */
5952
5977
  initHeight: function initHeight() {
5953
5978
  var _this4 = this;
5979
+ if (this.isCustomSearch) {
5980
+ return;
5981
+ }
5954
5982
  if (this.timer) {
5955
5983
  clearTimeout(this.timer);
5956
5984
  }
@@ -5964,7 +5992,7 @@ var script$p = {
5964
5992
  _this4.tableHeight = Math.ceil(dialogBodyHeight - tabHeaderHeight - tabFilterHeight) + 'px';
5965
5993
  // 固定弹窗内容高度
5966
5994
  _this4.$refs.content.style.height = dialogBodyHeight + 'px';
5967
- _this4.$refs.unselect.$refs.table.doLayout();
5995
+ _this4.getElTable().doLayout();
5968
5996
  _this4.setDialogFooterShadow();
5969
5997
  } else {
5970
5998
  // 固定弹窗内容高度
@@ -6030,10 +6058,10 @@ var script$p = {
6030
6058
  return item[_this5.rowKey] !== row[_this5.rowKey];
6031
6059
  });
6032
6060
  // 清空表格选择的数据
6033
- this.$refs.unselect.$refs.table.clearSelection();
6061
+ this.getElTable().clearSelection();
6034
6062
  // 重新赋值选择的数据
6035
6063
  selectedData.forEach(function (row) {
6036
- _this5.$refs.unselect.$refs.table.toggleRowSelection(row);
6064
+ _this5.getElTable().toggleRowSelection(row);
6037
6065
  });
6038
6066
  },
6039
6067
  /**
@@ -6059,8 +6087,53 @@ var script$p = {
6059
6087
  }
6060
6088
  return item;
6061
6089
  });
6090
+ // 如果父组件监听了 confirm 事件,则交由父组件处理(传入数据和关闭方法)
6091
+ if (this.$listeners.confirm) {
6092
+ this.$emit('confirm', selectedData, this.onClose);
6093
+ return;
6094
+ }
6062
6095
  this.$emit('input', selectedData);
6063
6096
  this.onClose();
6097
+ },
6098
+ /**
6099
+ * 獲取 el-table 實例
6100
+ */
6101
+ getElTable: function getElTable() {
6102
+ if (this.isCustomSearch) {
6103
+ return this.$refs.unselect.$refs.table.$refs.table;
6104
+ }
6105
+ return this.$refs.unselect.$refs.table;
6106
+ },
6107
+ /**
6108
+ * 计算 search-table 最大高度
6109
+ */
6110
+ getSearchTableMaxHeight: function getSearchTableMaxHeight() {
6111
+ // 获取 dialog body 最大高
6112
+ var dialogBodyHeight = this.getDialogBodyHeight();
6113
+ // 获取 el-tab header 高
6114
+ var tabHeader = this.$refs.content.querySelector('.el-tabs__header');
6115
+ var tabHeaderStyle = window.getComputedStyle(tabHeader);
6116
+ var tabHeaderHeight = Math.ceil(+tabHeaderStyle.height.replace('px', '')) + Math.ceil(+tabHeaderStyle.marginBottom.replace('px', '') + 1);
6117
+ // 获取分页器高度
6118
+ var elPage = this.$refs.unselect.$el.querySelector('.el-pagination');
6119
+ var elPageHeight = elPage ? Math.ceil(elPage.offsetHeight) : 0;
6120
+ var elTable = this.getElTable();
6121
+ // 表格最大高 = dialog body 最大高 - el-tab header 高 - 分页高 - 表格自身至 el-tab panel body的距离
6122
+ return dialogBodyHeight - tabHeaderHeight - elPageHeight - elTable.$el.offsetTop;
6123
+ },
6124
+ /**
6125
+ * 自定义查询成功后,计算表格最大高度
6126
+ */
6127
+ onAfterCustomSearchHandle: function onAfterCustomSearchHandle() {
6128
+ var _this7 = this;
6129
+ if (this.timer) {
6130
+ clearTimeout(this.timer);
6131
+ }
6132
+ this.timer = setTimeout(function () {
6133
+ _this7.tableHeight = _this7.getSearchTableMaxHeight() + 'px';
6134
+ _this7.getElTable().doLayout();
6135
+ _this7.setDialogFooterShadow();
6136
+ }, 50);
6064
6137
  }
6065
6138
  }
6066
6139
  };
@@ -6104,7 +6177,30 @@ var __vue_render__$7 = function __vue_render__() {
6104
6177
  },
6105
6178
  expression: "activeName"
6106
6179
  }
6107
- }, [_c("div", {
6180
+ }, [_c("el-tab-pane", {
6181
+ attrs: {
6182
+ label: "全部",
6183
+ name: "0"
6184
+ }
6185
+ }, [_vm.isCustomSearch ? [_c("iov-pro-search-table", {
6186
+ ref: "unselect",
6187
+ attrs: {
6188
+ request: _vm.customSearchRequest,
6189
+ "form-items": _vm.customSearchFormItems,
6190
+ "table-columns": _vm.unselectColumns,
6191
+ config: {
6192
+ simple: true,
6193
+ table: {
6194
+ rowKey: _vm.rowKey,
6195
+ maxHeight: _vm.tableHeight
6196
+ }
6197
+ }
6198
+ },
6199
+ on: {
6200
+ "after-request": _vm.onAfterCustomSearchHandle,
6201
+ "selection-change": _vm.onChangeSelection
6202
+ }
6203
+ })] : [_c("div", {
6108
6204
  staticClass: "iov-pro-dialog-select__filter"
6109
6205
  }, [_c("el-input", {
6110
6206
  attrs: {
@@ -6119,12 +6215,7 @@ var __vue_render__$7 = function __vue_render__() {
6119
6215
  },
6120
6216
  expression: "filterText"
6121
6217
  }
6122
- })], 1), _vm._v(" "), _c("el-tab-pane", {
6123
- attrs: {
6124
- label: "全部",
6125
- name: "0"
6126
- }
6127
- }, [_c("IovProTable", {
6218
+ })], 1), _vm._v(" "), _c("IovProTable", {
6128
6219
  ref: "unselect",
6129
6220
  attrs: {
6130
6221
  columns: _vm.unselectColumns,
@@ -6142,13 +6233,28 @@ var __vue_render__$7 = function __vue_render__() {
6142
6233
  on: {
6143
6234
  "selection-change": _vm.onChangeSelection
6144
6235
  }
6145
- })], 1), _vm._v(" "), _c("el-tab-pane", {
6236
+ })]], 2), _vm._v(" "), _c("el-tab-pane", {
6146
6237
  attrs: {
6147
6238
  label: "本次已选 (" + _vm.selectedData.length + ")",
6148
6239
  type: "card",
6149
6240
  name: "1"
6150
6241
  }
6151
- }, [_c("IovProTable", {
6242
+ }, [_c("div", {
6243
+ staticClass: "iov-pro-dialog-select__filter"
6244
+ }, [_c("el-input", {
6245
+ attrs: {
6246
+ placeholder: _vm.placeholder,
6247
+ "prefix-icon": "iov-icon-search",
6248
+ size: "small"
6249
+ },
6250
+ model: {
6251
+ value: _vm.filterText2,
6252
+ callback: function callback($$v) {
6253
+ _vm.filterText2 = $$v;
6254
+ },
6255
+ expression: "filterText2"
6256
+ }
6257
+ })], 1), _vm._v(" "), _c("IovProTable", {
6152
6258
  ref: "selected",
6153
6259
  attrs: {
6154
6260
  columns: _vm.selectedColumns,
@@ -19770,7 +19876,7 @@ var install = function install(Vue, componentConfig) {
19770
19876
  };
19771
19877
  var index = {
19772
19878
  install: install,
19773
- version: '0.0.17',
19879
+ version: '0.0.18',
19774
19880
  ColumnTooltip: __vue_component__$t,
19775
19881
  Description: __vue_component__$q,
19776
19882
  DialogSelect: __vue_component__$p,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iov-pro-components",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "IOV Pro Components for Vue.js",
5
5
  "main": "lib/iov-pro-components.min.js",
6
6
  "files": [