@teamix/pro 1.2.34 → 1.2.35

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.
@@ -9,12 +9,12 @@ var _utils = require("@teamix/utils");
9
9
 
10
10
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
11
 
12
- var initializeDataSource = function initializeDataSource(dataSource, suffix) {
12
+ var initializeDataSource = function initializeDataSource(dataSource, suffix, readPretty) {
13
13
  if ((0, _utils.isPlainObj)(dataSource)) {
14
14
  var requestConfig = dataSource;
15
15
  var requestConfigName = "$requestConfig_".concat(suffix);
16
16
  return {
17
- reactions: ["{{$dataSource($request,".concat(requestConfigName, ",context)}}")],
17
+ reactions: ["{{$dataSource($request,".concat(requestConfigName, ",context,").concat(readPretty, ")}}")],
18
18
  scope: _defineProperty({}, requestConfigName, requestConfig)
19
19
  };
20
20
  }
@@ -2,5 +2,5 @@ import type { ProFormRequestConfig } from '../typing';
2
2
  declare const $request: (field: any, requestConfig: ProFormRequestConfig, context: any, type: string | number) => Promise<unknown>;
3
3
  declare const $common: (services: any, requestConfig: ProFormRequestConfig, context: any, index: string) => (field: any) => any;
4
4
  declare const $validator: (services: any, requestConfig: ProFormRequestConfig, context: any) => (value: any, rules: any, { field }: any) => any;
5
- declare const $dataSource: (services: any, requestConfig: ProFormRequestConfig, context: any) => (field: any) => any;
5
+ declare const $dataSource: (services: any, requestConfig: ProFormRequestConfig, context: any, readPretty: any) => (field: any) => any;
6
6
  export { $request, $common, $dataSource, $validator };
@@ -66,28 +66,41 @@ var $validator = function $validator(services, requestConfig, context) {
66
66
 
67
67
  exports.$validator = $validator;
68
68
 
69
- var $dataSource = function $dataSource(services, requestConfig, context) {
69
+ var $dataSource = function $dataSource(services, requestConfig, context, readPretty) {
70
70
  return function (field) {
71
- field.setState({
72
- loading: true,
73
- readOnly: true
74
- });
75
- return services(field, requestConfig, context, 'dataSource').then(function (res) {
71
+ if (!readPretty) {
72
+ field.setState({
73
+ loading: true,
74
+ readOnly: true
75
+ });
76
+ }
77
+
78
+ return services(field, requestConfig, context).then(function (res) {
76
79
  var isValueInDataSource = (0, _utils.getValueByValue)(res, field.value);
77
80
  var clearValue = isValueInDataSource ? {} : {
78
81
  value: undefined
79
82
  };
80
- field.setState(_objectSpread({
81
- dataSource: res,
82
- loading: false,
83
- readOnly: false
84
- }, clearValue));
83
+
84
+ if (!readPretty) {
85
+ field.setState(_objectSpread({
86
+ dataSource: res,
87
+ loading: false,
88
+ readOnly: false
89
+ }, clearValue));
90
+ } else {
91
+ field.setState({
92
+ dataSource: res
93
+ });
94
+ }
95
+
85
96
  return requestConfig.onComplete && requestConfig.onComplete(res, field, context);
86
97
  }).catch(function () {
87
- field.setState({
88
- loading: false,
89
- readOnly: false
90
- });
98
+ if (!readPretty) {
99
+ field.setState({
100
+ loading: false,
101
+ readOnly: false
102
+ });
103
+ }
91
104
  });
92
105
  };
93
106
  };
package/lib/index.d.ts CHANGED
@@ -24,5 +24,5 @@ export * from './skeleton';
24
24
  export * from './table';
25
25
  export * from './utils';
26
26
  export * from './step';
27
- declare const version = "1.2.34";
27
+ declare const version = "1.2.35";
28
28
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProStep, hooks, nocode, templates, utils, };
package/lib/index.js CHANGED
@@ -285,5 +285,5 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
285
285
  // 设置图标源
286
286
  _icon.default.setConfig(_utils.default.getTeamixIconConfig());
287
287
 
288
- var version = '1.2.34';
288
+ var version = '1.2.35';
289
289
  exports.version = version;
@@ -88,8 +88,8 @@ var getColorAndStyle = function getColorAndStyle(color, backgroundColor, backgro
88
88
  var isColorPresetColor = (0, _utils.isPresetColor)(color);
89
89
  var isBgColorPresetColor = (0, _utils.isPresetColor)(backgroundColor);
90
90
  var className = (0, _classnames2.default)((_classnames = {}, _defineProperty(_classnames, "".concat((0, _utils.getColorClassName)(color)), isColorPresetColor), _defineProperty(_classnames, "".concat((0, _utils.getBackgroundColorClassName)(backgroundColor)), isBgColorPresetColor), _defineProperty(_classnames, "".concat(cls("bg-type-".concat(backgroundType))), !!backgroundType), _classnames));
91
- var styleColor = isColorPresetColor ? undefined : color;
92
- var styleBgColor = isBgColorPresetColor ? undefined : backgroundColor;
91
+ var styleColor = isColorPresetColor ? (0, _utils.getColor)(color) : color;
92
+ var styleBgColor = isBgColorPresetColor ? (0, _utils.getColor)(color) : backgroundColor;
93
93
  var style = {
94
94
  color: styleColor,
95
95
  backgroundColor: styleBgColor
@@ -344,8 +344,8 @@ var ProTable = function ProTable(props) {
344
344
  var normalDataFilterForm = normalDataFilterFormRef.current;
345
345
  var fullscreenDataFilterForm = fullscreenDataFilterFormRef.current; // 传给 QueryFilter 的 formRef
346
346
 
347
- var dataFilterFormRef = !fullscreenState ? normalDataFilterFormRef : fullscreenDataFilterFormRef;
348
- var dataFilterForm = dataFilterFormRef.current; // 整个内容区是否超过一屏。用于表格在非全屏模式下的吸底
347
+ var dataFilterFormRef = !fullscreenState ? normalDataFilterFormRef : fullscreenDataFilterFormRef; // let dataFilterForm = dataFilterFormRef.current;
348
+ // 整个内容区是否超过一屏。用于表格在非全屏模式下的吸底
349
349
 
350
350
  var _useState29 = (0, _react.useState)(false),
351
351
  _useState30 = _slicedToArray(_useState29, 2),
@@ -554,12 +554,12 @@ var ProTable = function ProTable(props) {
554
554
  _request(params);
555
555
  },
556
556
  reset: function reset() {
557
- var _actionRef$current4, _actionRef$current4$s;
557
+ var _actionRef$current4, _actionRef$current4$s, _dataFilterFormRef$cu;
558
558
 
559
559
  (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset()); // 清空列过滤参数
560
560
 
561
561
  (_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$s = _actionRef$current4.setFilterRules) === null || _actionRef$current4$s === void 0 ? void 0 : _actionRef$current4$s.call(_actionRef$current4, {});
562
- dataFilterForm === null || dataFilterForm === void 0 ? void 0 : dataFilterForm.reset();
562
+ (_dataFilterFormRef$cu = dataFilterFormRef.current) === null || _dataFilterFormRef$cu === void 0 ? void 0 : _dataFilterFormRef$cu.reset();
563
563
  setCurrentPage(1);
564
564
 
565
565
  _request(_defineProperty({}, targetPageKey, 1));
@@ -581,7 +581,8 @@ var ProTable = function ProTable(props) {
581
581
  pageSize: pageSize
582
582
  },
583
583
  data: data,
584
- dataFilterForm: dataFilterForm,
584
+ dataFilterForm: dataFilterFormRef.current,
585
+ dataFilterFormRef: dataFilterFormRef,
585
586
  normalDataFilterForm: normalDataFilterForm,
586
587
  fullscreenDataFilterForm: fullscreenDataFilterForm,
587
588
  filterEnableRef: filterEnableRef,
@@ -674,7 +675,7 @@ var ProTable = function ProTable(props) {
674
675
  }); // 请求函数
675
676
 
676
677
  function _request(params, noLoading, filterParams) {
677
- var _actionRef$current$ge, _actionRef$current5, _actionRef$current5$g, _objectSpread2;
678
+ var _dataFilterFormRef$cu2, _actionRef$current$ge, _actionRef$current5, _actionRef$current5$g, _objectSpread2;
678
679
 
679
680
  // 如果没有传 url 且没有 customRequest,直接返回
680
681
  if (!url && !customRequest) {
@@ -687,7 +688,7 @@ var ProTable = function ProTable(props) {
687
688
 
688
689
  var sortParams = targetFormatSort(sort); // 筛选区请求参数
689
690
 
690
- var dataFilterParams = filterParams !== null && filterParams !== void 0 ? filterParams : dataFilterForm === null || dataFilterForm === void 0 ? void 0 : dataFilterForm.values; // 列过滤请求参数
691
+ var dataFilterParams = filterParams !== null && filterParams !== void 0 ? filterParams : (_dataFilterFormRef$cu2 = dataFilterFormRef.current) === null || _dataFilterFormRef$cu2 === void 0 ? void 0 : _dataFilterFormRef$cu2.values; // 列过滤请求参数
691
692
 
692
693
  var columnsFilterParams = (_actionRef$current$ge = (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$g = _actionRef$current5.getFilterRules) === null || _actionRef$current5$g === void 0 ? void 0 : _actionRef$current5$g.call(_actionRef$current5)) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {}; // 格式化后的请求参数
693
694
 
@@ -785,6 +786,7 @@ var ProTable = function ProTable(props) {
785
786
  }, propsDataFilter), {}, {
786
787
  onInit: function onInit(values) {
787
788
  // 表单初始化请求处理
789
+ console.log('onInit');
788
790
  (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onInit) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onInit(values));
789
791
  !fullscreenState && _request({}, false, values);
790
792
  return true;
@@ -792,7 +794,8 @@ var ProTable = function ProTable(props) {
792
794
  onFilter: function onFilter(values) {
793
795
  var _actionRef$current6, _actionRef$current6$c;
794
796
 
795
- // 全屏状态,判断全屏表单onFilter是否禁用
797
+ console.log('onFilter'); // 全屏状态,判断全屏表单onFilter是否禁用
798
+
796
799
  if (fullscreenState && !filterEnableRef.current.fullscreen) {
797
800
  filterEnableRef.current.fullscreen = true;
798
801
  return;
@@ -812,8 +815,10 @@ var ProTable = function ProTable(props) {
812
815
  _request(_defineProperty({}, targetPageKey, 1), false, values);
813
816
  },
814
817
  onReset: function onReset(values) {
818
+ var _dataFilterFormRef$cu3;
819
+
815
820
  (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset());
816
- dataFilterForm === null || dataFilterForm === void 0 ? void 0 : dataFilterForm.reset();
821
+ (_dataFilterFormRef$cu3 = dataFilterFormRef.current) === null || _dataFilterFormRef$cu3 === void 0 ? void 0 : _dataFilterFormRef$cu3.reset();
817
822
  setCurrentPage(1);
818
823
 
819
824
  _request(_defineProperty({}, targetPageKey, 1), false, values);
@@ -190,6 +190,8 @@ export declare type ProTableActionType = {
190
190
  resetPage?: () => void;
191
191
  /** 获取数据过滤区表单实例 */
192
192
  dataFilterForm?: FormType;
193
+ /** 用于在 mount 的时候获取到表单 ref */
194
+ dataFilterFormRef?: React.MutableRefObject<FormType>;
193
195
  normalDataFilterForm?: FormType;
194
196
  fullscreenDataFilterForm?: FormType;
195
197
  filterEnableRef?: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamix/pro",
3
- "version": "1.2.34",
3
+ "version": "1.2.35",
4
4
  "description": "TeamixPro大包",
5
5
  "repository": "http://gitlab.alibaba-inc.com/teamix/pro",
6
6
  "author": "Velociraptor(迅猛龙)",