@bit-sun/business-component 2.2.0-alpha.1 → 2.2.0-alpha.3

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/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import axios from 'axios';
2
2
  import { message, Menu, Space, Dropdown, Tooltip, Button, Checkbox, Input, Modal, Select, Form, Divider, Spin, Table, TreeSelect, Tag, Popover, Card, Avatar, Image, InputNumber, Typography, Alert, Anchor, Breadcrumb, Drawer as Drawer$1, List, Tree, Row, Col, Tabs, Affix } from 'antd';
3
3
  import _, { omit, debounce, cloneDeep as cloneDeep$1, isEmpty } from 'lodash';
4
- import React, { useState, useEffect, forwardRef, useImperativeHandle, useRef, useMemo, Component, useLayoutEffect, createRef } from 'react';
4
+ import React, { useState, useEffect, forwardRef, useImperativeHandle, useRef, useMemo, Component, useLayoutEffect, createRef, Fragment } from 'react';
5
5
  import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
6
6
  import { UnorderedListOutlined, ProfileTwoTone, ExclamationCircleOutlined, DownOutlined, CopyOutlined, SearchOutlined, CaretLeftOutlined, CloseCircleOutlined, ArrowLeftOutlined, FolderOutlined, EllipsisOutlined, CaretDownOutlined, HomeOutlined, DoubleLeftOutlined, DoubleRightOutlined, MenuUnfoldOutlined, DashOutlined, SettingOutlined, BulbOutlined, PlayCircleOutlined, SaveOutlined, FullscreenExitOutlined } from '@ant-design/icons';
7
7
  import { useDebounceFn, useMount } from 'ahooks';
@@ -17052,8 +17052,10 @@ var SearchItemTable = /*#__PURE__*/function (_React$Component) {
17052
17052
  };
17053
17053
  _this.setInitValue = function () {
17054
17054
  var _this$props = _this.props,
17055
- datasource = _this$props.datasource,
17056
- showSearchFields = _this$props.showSearchFields;
17055
+ _this$props$datasourc = _this$props.datasource,
17056
+ datasource = _this$props$datasourc === void 0 ? [] : _this$props$datasourc,
17057
+ _this$props$showSearc = _this$props.showSearchFields,
17058
+ showSearchFields = _this$props$showSearc === void 0 ? [] : _this$props$showSearc;
17057
17059
  var config = _this.getConfigFromlocalstorage();
17058
17060
  _this.setState({
17059
17061
  isDefaultValue: true,
@@ -17593,7 +17595,8 @@ var BsSulaQueryTable = (function (props) {
17593
17595
  };
17594
17596
  var setInitialSearchFieldsInfo = function setInitialSearchFieldsInfo() {
17595
17597
  //获取搜索字段的缓存配置
17596
- var fields = props.fields;
17598
+ var _props$fields = props.fields,
17599
+ fields = _props$fields === void 0 ? [] : _props$fields;
17597
17600
  var searchFieldsConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION);
17598
17601
  var showSearchFields = searchFieldsConfig.length ? searchFieldsConfig.map(function (item) {
17599
17602
  var inner = fields.filter(function (inneritem) {
@@ -29479,7 +29482,9 @@ var FieldsSettingsTable = (function (props) {
29479
29482
  _props$codeProps = props.codeProps,
29480
29483
  codeProps = _props$codeProps === void 0 ? '' : _props$codeProps,
29481
29484
  moduleType = props.moduleType,
29482
- moduleRelationId = props.moduleRelationId;
29485
+ moduleRelationId = props.moduleRelationId,
29486
+ _props$tableFlag = props.tableFlag,
29487
+ tableFlag = _props$tableFlag === void 0 ? false : _props$tableFlag;
29483
29488
  var ref = useRef(null);
29484
29489
  var _useState = useState({
29485
29490
  visible: false,
@@ -29568,6 +29573,9 @@ var FieldsSettingsTable = (function (props) {
29568
29573
  render: function render(_ref2) {
29569
29574
  var text = _ref2.text,
29570
29575
  record = _ref2.record;
29576
+ if (tableFlag) {
29577
+ return /*#__PURE__*/React.createElement("div", null, " \u5217\u8868\uFF1A", "{\"key\": \"extensionFields,".concat(record.code, "\",\"dataIndex\": \"extensionFields,").concat(record.code, "\",\"title\": \"").concat(record.name, "\"},"));
29578
+ }
29571
29579
  if (!codeProps.columns) {
29572
29580
  return /*#__PURE__*/React.createElement("div", null, "\u8868\u5355\uFF1A", "{\"name\": \"extensionFields,".concat(record.code, "\",\"label\": \"").concat(record.name, "\"},"));
29573
29581
  }
@@ -29803,7 +29811,10 @@ var JsonQueryTable = /*#__PURE__*/React.memo(function (props) {
29803
29811
  codeProps = props.codeProps,
29804
29812
  customerFields = props.customerFields,
29805
29813
  initialSetting = props.initialSetting,
29806
- pageType = props.pageType;
29814
+ pageType = props.pageType,
29815
+ _props$detailTablesSe = props.detailTablesSetting,
29816
+ detailTablesSetting = _props$detailTablesSe === void 0 ? [] : _props$detailTablesSe,
29817
+ saveTableCallBack = props.saveTableCallBack;
29807
29818
  var codeFilter = {};
29808
29819
  if (codeProps.columns) {
29809
29820
  // table
@@ -29827,7 +29838,6 @@ var JsonQueryTable = /*#__PURE__*/React.memo(function (props) {
29827
29838
  fields: codeProps.fields
29828
29839
  }).fields;
29829
29840
  }
29830
- console.log('codeFilter', codeFilter);
29831
29841
  var styleRef = useRef(null);
29832
29842
  var _useState = useState(false),
29833
29843
  _useState2 = _slicedToArray(_useState, 2),
@@ -29849,6 +29859,18 @@ var JsonQueryTable = /*#__PURE__*/React.memo(function (props) {
29849
29859
  _useState10 = _slicedToArray(_useState9, 2),
29850
29860
  moduleParams = _useState10[0],
29851
29861
  setModuleParams = _useState10[1];
29862
+ var _useState11 = useState('main'),
29863
+ _useState12 = _slicedToArray(_useState11, 2),
29864
+ activeKey = _useState12[0],
29865
+ setActiveKey = _useState12[1]; //默认详情页配置
29866
+ var _useState13 = useState({}),
29867
+ _useState14 = _slicedToArray(_useState13, 2),
29868
+ tablesConfigParams = _useState14[0],
29869
+ setTablesConfigParams = _useState14[1];
29870
+ var _useState15 = useState([]),
29871
+ _useState16 = _slicedToArray(_useState15, 2),
29872
+ tableJsonEditorValsArr = _useState16[0],
29873
+ setTableJsonEditorValsArr = _useState16[1];
29852
29874
  useEffect(function () {
29853
29875
  Promise.all([axios.get("/basic/flow/businessFieldGroup/one?moduleType=2&layoutPoint=".concat(pageType))]).then(function (_ref2) {
29854
29876
  var _ref3 = _slicedToArray(_ref2, 1),
@@ -29872,6 +29894,56 @@ var JsonQueryTable = /*#__PURE__*/React.memo(function (props) {
29872
29894
  }
29873
29895
  });
29874
29896
  }, []);
29897
+ useEffect(function () {
29898
+ //明细表的配置数据
29899
+ var axiosArr = detailTablesSetting.map(function (item) {
29900
+ return axios.get("/basic/flow/businessFieldGroup/one?moduleType=2&layoutPoint=".concat(item.tableCode));
29901
+ });
29902
+ Promise.all(axiosArr).then(function (_ref5) {
29903
+ var _ref6 = _toArray(_ref5),
29904
+ resArr = _ref6.slice(0);
29905
+ detailTablesSetting.map(function (item, index) {
29906
+ var _resArr$index;
29907
+ var _ref7 = ((_resArr$index = resArr[index]) === null || _resArr$index === void 0 ? void 0 : _resArr$index.data) || {},
29908
+ code = _ref7.code,
29909
+ data = _ref7.data;
29910
+ if (data) {
29911
+ var businessType = data.businessType,
29912
+ fieldGroup = data.code,
29913
+ moduleType = data.moduleType;
29914
+ setTablesConfigParams(_objectSpread2(_objectSpread2({}, tablesConfigParams), {}, _defineProperty({}, item.tableCode, {
29915
+ businessType: businessType,
29916
+ fieldGroup: fieldGroup,
29917
+ moduleType: moduleType,
29918
+ tableFlag: true
29919
+ })));
29920
+ }
29921
+ });
29922
+ });
29923
+ var detailTableCodeFilter = detailTablesSetting.map(function (item) {
29924
+ if ((item === null || item === void 0 ? void 0 : item.initialSetting) && (item === null || item === void 0 ? void 0 : item.initialSetting.length)) {
29925
+ return _objectSpread2(_objectSpread2({}, item), {}, {
29926
+ columns: item === null || item === void 0 ? void 0 : item.initialSetting
29927
+ });
29928
+ }
29929
+ return _objectSpread2(_objectSpread2({}, item), {}, {
29930
+ columns: item === null || item === void 0 ? void 0 : item.columns.map(function (childItem) {
29931
+ return {
29932
+ key: childItem.key || childItem.dataIndex,
29933
+ dataIndex: childItem.dataIndex || childItem.key,
29934
+ isStaticCode: true,
29935
+ title: childItem.title
29936
+ };
29937
+ })
29938
+ });
29939
+ });
29940
+ setTableJsonEditorValsArr(_toConsumableArray(detailTableCodeFilter));
29941
+ detailTableCodeFilter.map(function (item) {
29942
+ if ((item === null || item === void 0 ? void 0 : item.initialSetting) && (item === null || item === void 0 ? void 0 : item.initialSetting.length)) {
29943
+ onClickRunDetailTables(item.initialSetting, false, item.tableCode, detailTableCodeFilter);
29944
+ }
29945
+ });
29946
+ }, [detailTablesSetting.length]);
29875
29947
  var onClickRun = function onClickRun(value, isSave) {
29876
29948
  setJsonEditorVal(value);
29877
29949
  try {
@@ -29881,6 +29953,40 @@ var JsonQueryTable = /*#__PURE__*/React.memo(function (props) {
29881
29953
  message.error(e);
29882
29954
  }
29883
29955
  };
29956
+ //明细表保存
29957
+ var onClickRunDetailTables = function onClickRunDetailTables(value, isSave, tableCode, tableSouce) {
29958
+ var targetCode = tableCode || activeKey;
29959
+ var targetTableSource = tableSouce || tableJsonEditorValsArr;
29960
+ var newArr = targetTableSource.map(function (item) {
29961
+ if (item.tableCode == targetCode) {
29962
+ return _objectSpread2(_objectSpread2({}, item), {}, {
29963
+ columns: value
29964
+ });
29965
+ }
29966
+ return item;
29967
+ });
29968
+ setTableJsonEditorValsArr(_toConsumableArray(newArr));
29969
+ try {
29970
+ var target = targetTableSource.find(function (item) {
29971
+ return item.tableCode == targetCode;
29972
+ });
29973
+ var _codeProps = {
29974
+ fields: [],
29975
+ columns: target === null || target === void 0 ? void 0 : target.columns
29976
+ };
29977
+ var newValue = {
29978
+ fields: [],
29979
+ columns: value
29980
+ };
29981
+ var result = hanleCallbackValue(_codeProps, newValue, target === null || target === void 0 ? void 0 : target.customerFields);
29982
+ saveTableCallBack({
29983
+ columns: result.columns,
29984
+ tableCode: targetCode
29985
+ }, isSave, value);
29986
+ } catch (e) {
29987
+ message.error(e);
29988
+ }
29989
+ };
29884
29990
  React.useEffect(function () {
29885
29991
  localStorage.setItem('jsonEditorVal', JSON.stringify(jsonEditorVal || {}));
29886
29992
  }, [jsonEditorVal]);
@@ -29902,9 +30008,7 @@ var JsonQueryTable = /*#__PURE__*/React.memo(function (props) {
29902
30008
  return setVisible(false);
29903
30009
  },
29904
30010
  className: 'customFieldsDrawer'
29905
- }, /*#__PURE__*/React.createElement("div", {
29906
- ref: styleRef
29907
- }), isEmpty(moduleParams) ? /*#__PURE__*/React.createElement("div", {
30011
+ }, detailTablesSetting.length == 0 && /*#__PURE__*/React.createElement(Fragment, null, isEmpty(moduleParams) ? /*#__PURE__*/React.createElement("div", {
29908
30012
  style: {
29909
30013
  padding: "10px 0",
29910
30014
  fontSize: "16px",
@@ -29915,7 +30019,42 @@ var JsonQueryTable = /*#__PURE__*/React.memo(function (props) {
29915
30019
  onRun: onClickRun,
29916
30020
  value: jsonEditorVal,
29917
30021
  shallowHeight: height
29918
- })), !visible && isAdmin() && /*#__PURE__*/React.createElement(ConfigButton, {
30022
+ })), detailTablesSetting.length > 0 && /*#__PURE__*/React.createElement(Tabs, {
30023
+ defaultActiveKey: activeKey,
30024
+ onChange: function onChange(v) {
30025
+ return setActiveKey(v);
30026
+ }
30027
+ }, /*#__PURE__*/React.createElement(Tabs.TabPane, {
30028
+ tab: "\u8BE6\u60C5\u9875\u914D\u7F6E",
30029
+ key: "main"
30030
+ }, isEmpty(moduleParams) ? /*#__PURE__*/React.createElement("div", {
30031
+ style: {
30032
+ padding: "10px 0",
30033
+ fontSize: "16px",
30034
+ fontWeight: "bolder"
30035
+ }
30036
+ }, "\u63D0\u793A\uFF1A\u4E1A\u52A1\u5BF9\u8C61\u672A\u7EF4\u62A4\uFF0C\u8BF7\u5728\u901A\u7528\u5355\u636E\u5BF9\u5E94\u4E1A\u52A1\u7C7B\u578B\u4E0B\u7EF4\u62A4\u4E1A\u52A1\u5BF9\u8C61") : /*#__PURE__*/React.createElement(FieldsSettingsTable, _objectSpread2({}, tableParams)), /*#__PURE__*/React.createElement(Editor, {
30037
+ type: "table",
30038
+ onRun: onClickRun,
30039
+ value: jsonEditorVal,
30040
+ shallowHeight: height
30041
+ })), tableJsonEditorValsArr.map(function (k) {
30042
+ return /*#__PURE__*/React.createElement(Tabs.TabPane, {
30043
+ tab: k.title,
30044
+ key: k.tableCode
30045
+ }, !tablesConfigParams[k.tableCode] ? /*#__PURE__*/React.createElement("div", {
30046
+ style: {
30047
+ padding: "10px 0",
30048
+ fontSize: "16px",
30049
+ fontWeight: "bolder"
30050
+ }
30051
+ }, "\u63D0\u793A\uFF1A\u4E1A\u52A1\u5BF9\u8C61\u672A\u7EF4\u62A4\uFF0C\u8BF7\u5728\u901A\u7528\u5355\u636E\u5BF9\u5E94\u4E1A\u52A1\u7C7B\u578B\u4E0B\u7EF4\u62A4\u4E1A\u52A1\u5BF9\u8C61") : /*#__PURE__*/React.createElement(FieldsSettingsTable, _objectSpread2({}, tablesConfigParams[k.tableCode])), /*#__PURE__*/React.createElement(Editor, {
30052
+ type: "table",
30053
+ onRun: onClickRunDetailTables,
30054
+ value: k.columns,
30055
+ shallowHeight: height
30056
+ }));
30057
+ }))), !visible && isAdmin() && /*#__PURE__*/React.createElement(ConfigButton, {
29919
30058
  type: 'primary',
29920
30059
  onClick: function onClick() {
29921
30060
  return setVisible(true);
package/dist/index.js CHANGED
@@ -17070,8 +17070,10 @@ var SearchItemTable = /*#__PURE__*/function (_React$Component) {
17070
17070
  };
17071
17071
  _this.setInitValue = function () {
17072
17072
  var _this$props = _this.props,
17073
- datasource = _this$props.datasource,
17074
- showSearchFields = _this$props.showSearchFields;
17073
+ _this$props$datasourc = _this$props.datasource,
17074
+ datasource = _this$props$datasourc === void 0 ? [] : _this$props$datasourc,
17075
+ _this$props$showSearc = _this$props.showSearchFields,
17076
+ showSearchFields = _this$props$showSearc === void 0 ? [] : _this$props$showSearc;
17075
17077
  var config = _this.getConfigFromlocalstorage();
17076
17078
  _this.setState({
17077
17079
  isDefaultValue: true,
@@ -17611,7 +17613,8 @@ var BsSulaQueryTable = (function (props) {
17611
17613
  };
17612
17614
  var setInitialSearchFieldsInfo = function setInitialSearchFieldsInfo() {
17613
17615
  //获取搜索字段的缓存配置
17614
- var fields = props.fields;
17616
+ var _props$fields = props.fields,
17617
+ fields = _props$fields === void 0 ? [] : _props$fields;
17615
17618
  var searchFieldsConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION);
17616
17619
  var showSearchFields = searchFieldsConfig.length ? searchFieldsConfig.map(function (item) {
17617
17620
  var inner = fields.filter(function (inneritem) {
@@ -29497,7 +29500,9 @@ var FieldsSettingsTable = (function (props) {
29497
29500
  _props$codeProps = props.codeProps,
29498
29501
  codeProps = _props$codeProps === void 0 ? '' : _props$codeProps,
29499
29502
  moduleType = props.moduleType,
29500
- moduleRelationId = props.moduleRelationId;
29503
+ moduleRelationId = props.moduleRelationId,
29504
+ _props$tableFlag = props.tableFlag,
29505
+ tableFlag = _props$tableFlag === void 0 ? false : _props$tableFlag;
29501
29506
  var ref = React.useRef(null);
29502
29507
  var _useState = React.useState({
29503
29508
  visible: false,
@@ -29586,6 +29591,9 @@ var FieldsSettingsTable = (function (props) {
29586
29591
  render: function render(_ref2) {
29587
29592
  var text = _ref2.text,
29588
29593
  record = _ref2.record;
29594
+ if (tableFlag) {
29595
+ return /*#__PURE__*/React__default['default'].createElement("div", null, " \u5217\u8868\uFF1A", "{\"key\": \"extensionFields,".concat(record.code, "\",\"dataIndex\": \"extensionFields,").concat(record.code, "\",\"title\": \"").concat(record.name, "\"},"));
29596
+ }
29589
29597
  if (!codeProps.columns) {
29590
29598
  return /*#__PURE__*/React__default['default'].createElement("div", null, "\u8868\u5355\uFF1A", "{\"name\": \"extensionFields,".concat(record.code, "\",\"label\": \"").concat(record.name, "\"},"));
29591
29599
  }
@@ -29821,7 +29829,10 @@ var JsonQueryTable = /*#__PURE__*/React__default['default'].memo(function (props
29821
29829
  codeProps = props.codeProps,
29822
29830
  customerFields = props.customerFields,
29823
29831
  initialSetting = props.initialSetting,
29824
- pageType = props.pageType;
29832
+ pageType = props.pageType,
29833
+ _props$detailTablesSe = props.detailTablesSetting,
29834
+ detailTablesSetting = _props$detailTablesSe === void 0 ? [] : _props$detailTablesSe,
29835
+ saveTableCallBack = props.saveTableCallBack;
29825
29836
  var codeFilter = {};
29826
29837
  if (codeProps.columns) {
29827
29838
  // table
@@ -29845,7 +29856,6 @@ var JsonQueryTable = /*#__PURE__*/React__default['default'].memo(function (props
29845
29856
  fields: codeProps.fields
29846
29857
  }).fields;
29847
29858
  }
29848
- console.log('codeFilter', codeFilter);
29849
29859
  var styleRef = React.useRef(null);
29850
29860
  var _useState = React.useState(false),
29851
29861
  _useState2 = _slicedToArray(_useState, 2),
@@ -29867,6 +29877,18 @@ var JsonQueryTable = /*#__PURE__*/React__default['default'].memo(function (props
29867
29877
  _useState10 = _slicedToArray(_useState9, 2),
29868
29878
  moduleParams = _useState10[0],
29869
29879
  setModuleParams = _useState10[1];
29880
+ var _useState11 = React.useState('main'),
29881
+ _useState12 = _slicedToArray(_useState11, 2),
29882
+ activeKey = _useState12[0],
29883
+ setActiveKey = _useState12[1]; //默认详情页配置
29884
+ var _useState13 = React.useState({}),
29885
+ _useState14 = _slicedToArray(_useState13, 2),
29886
+ tablesConfigParams = _useState14[0],
29887
+ setTablesConfigParams = _useState14[1];
29888
+ var _useState15 = React.useState([]),
29889
+ _useState16 = _slicedToArray(_useState15, 2),
29890
+ tableJsonEditorValsArr = _useState16[0],
29891
+ setTableJsonEditorValsArr = _useState16[1];
29870
29892
  React.useEffect(function () {
29871
29893
  Promise.all([axios__default['default'].get("/basic/flow/businessFieldGroup/one?moduleType=2&layoutPoint=".concat(pageType))]).then(function (_ref2) {
29872
29894
  var _ref3 = _slicedToArray(_ref2, 1),
@@ -29890,6 +29912,56 @@ var JsonQueryTable = /*#__PURE__*/React__default['default'].memo(function (props
29890
29912
  }
29891
29913
  });
29892
29914
  }, []);
29915
+ React.useEffect(function () {
29916
+ //明细表的配置数据
29917
+ var axiosArr = detailTablesSetting.map(function (item) {
29918
+ return axios__default['default'].get("/basic/flow/businessFieldGroup/one?moduleType=2&layoutPoint=".concat(item.tableCode));
29919
+ });
29920
+ Promise.all(axiosArr).then(function (_ref5) {
29921
+ var _ref6 = _toArray(_ref5),
29922
+ resArr = _ref6.slice(0);
29923
+ detailTablesSetting.map(function (item, index) {
29924
+ var _resArr$index;
29925
+ var _ref7 = ((_resArr$index = resArr[index]) === null || _resArr$index === void 0 ? void 0 : _resArr$index.data) || {},
29926
+ code = _ref7.code,
29927
+ data = _ref7.data;
29928
+ if (data) {
29929
+ var businessType = data.businessType,
29930
+ fieldGroup = data.code,
29931
+ moduleType = data.moduleType;
29932
+ setTablesConfigParams(_objectSpread2(_objectSpread2({}, tablesConfigParams), {}, _defineProperty({}, item.tableCode, {
29933
+ businessType: businessType,
29934
+ fieldGroup: fieldGroup,
29935
+ moduleType: moduleType,
29936
+ tableFlag: true
29937
+ })));
29938
+ }
29939
+ });
29940
+ });
29941
+ var detailTableCodeFilter = detailTablesSetting.map(function (item) {
29942
+ if ((item === null || item === void 0 ? void 0 : item.initialSetting) && (item === null || item === void 0 ? void 0 : item.initialSetting.length)) {
29943
+ return _objectSpread2(_objectSpread2({}, item), {}, {
29944
+ columns: item === null || item === void 0 ? void 0 : item.initialSetting
29945
+ });
29946
+ }
29947
+ return _objectSpread2(_objectSpread2({}, item), {}, {
29948
+ columns: item === null || item === void 0 ? void 0 : item.columns.map(function (childItem) {
29949
+ return {
29950
+ key: childItem.key || childItem.dataIndex,
29951
+ dataIndex: childItem.dataIndex || childItem.key,
29952
+ isStaticCode: true,
29953
+ title: childItem.title
29954
+ };
29955
+ })
29956
+ });
29957
+ });
29958
+ setTableJsonEditorValsArr(_toConsumableArray(detailTableCodeFilter));
29959
+ detailTableCodeFilter.map(function (item) {
29960
+ if ((item === null || item === void 0 ? void 0 : item.initialSetting) && (item === null || item === void 0 ? void 0 : item.initialSetting.length)) {
29961
+ onClickRunDetailTables(item.initialSetting, false, item.tableCode, detailTableCodeFilter);
29962
+ }
29963
+ });
29964
+ }, [detailTablesSetting.length]);
29893
29965
  var onClickRun = function onClickRun(value, isSave) {
29894
29966
  setJsonEditorVal(value);
29895
29967
  try {
@@ -29899,6 +29971,40 @@ var JsonQueryTable = /*#__PURE__*/React__default['default'].memo(function (props
29899
29971
  antd.message.error(e);
29900
29972
  }
29901
29973
  };
29974
+ //明细表保存
29975
+ var onClickRunDetailTables = function onClickRunDetailTables(value, isSave, tableCode, tableSouce) {
29976
+ var targetCode = tableCode || activeKey;
29977
+ var targetTableSource = tableSouce || tableJsonEditorValsArr;
29978
+ var newArr = targetTableSource.map(function (item) {
29979
+ if (item.tableCode == targetCode) {
29980
+ return _objectSpread2(_objectSpread2({}, item), {}, {
29981
+ columns: value
29982
+ });
29983
+ }
29984
+ return item;
29985
+ });
29986
+ setTableJsonEditorValsArr(_toConsumableArray(newArr));
29987
+ try {
29988
+ var target = targetTableSource.find(function (item) {
29989
+ return item.tableCode == targetCode;
29990
+ });
29991
+ var _codeProps = {
29992
+ fields: [],
29993
+ columns: target === null || target === void 0 ? void 0 : target.columns
29994
+ };
29995
+ var newValue = {
29996
+ fields: [],
29997
+ columns: value
29998
+ };
29999
+ var result = hanleCallbackValue(_codeProps, newValue, target === null || target === void 0 ? void 0 : target.customerFields);
30000
+ saveTableCallBack({
30001
+ columns: result.columns,
30002
+ tableCode: targetCode
30003
+ }, isSave, value);
30004
+ } catch (e) {
30005
+ antd.message.error(e);
30006
+ }
30007
+ };
29902
30008
  React__default['default'].useEffect(function () {
29903
30009
  localStorage.setItem('jsonEditorVal', JSON.stringify(jsonEditorVal || {}));
29904
30010
  }, [jsonEditorVal]);
@@ -29920,9 +30026,7 @@ var JsonQueryTable = /*#__PURE__*/React__default['default'].memo(function (props
29920
30026
  return setVisible(false);
29921
30027
  },
29922
30028
  className: 'customFieldsDrawer'
29923
- }, /*#__PURE__*/React__default['default'].createElement("div", {
29924
- ref: styleRef
29925
- }), _.isEmpty(moduleParams) ? /*#__PURE__*/React__default['default'].createElement("div", {
30029
+ }, detailTablesSetting.length == 0 && /*#__PURE__*/React__default['default'].createElement(React.Fragment, null, _.isEmpty(moduleParams) ? /*#__PURE__*/React__default['default'].createElement("div", {
29926
30030
  style: {
29927
30031
  padding: "10px 0",
29928
30032
  fontSize: "16px",
@@ -29933,7 +30037,42 @@ var JsonQueryTable = /*#__PURE__*/React__default['default'].memo(function (props
29933
30037
  onRun: onClickRun,
29934
30038
  value: jsonEditorVal,
29935
30039
  shallowHeight: height
29936
- })), !visible && isAdmin() && /*#__PURE__*/React__default['default'].createElement(ConfigButton, {
30040
+ })), detailTablesSetting.length > 0 && /*#__PURE__*/React__default['default'].createElement(antd.Tabs, {
30041
+ defaultActiveKey: activeKey,
30042
+ onChange: function onChange(v) {
30043
+ return setActiveKey(v);
30044
+ }
30045
+ }, /*#__PURE__*/React__default['default'].createElement(antd.Tabs.TabPane, {
30046
+ tab: "\u8BE6\u60C5\u9875\u914D\u7F6E",
30047
+ key: "main"
30048
+ }, _.isEmpty(moduleParams) ? /*#__PURE__*/React__default['default'].createElement("div", {
30049
+ style: {
30050
+ padding: "10px 0",
30051
+ fontSize: "16px",
30052
+ fontWeight: "bolder"
30053
+ }
30054
+ }, "\u63D0\u793A\uFF1A\u4E1A\u52A1\u5BF9\u8C61\u672A\u7EF4\u62A4\uFF0C\u8BF7\u5728\u901A\u7528\u5355\u636E\u5BF9\u5E94\u4E1A\u52A1\u7C7B\u578B\u4E0B\u7EF4\u62A4\u4E1A\u52A1\u5BF9\u8C61") : /*#__PURE__*/React__default['default'].createElement(FieldsSettingsTable, _objectSpread2({}, tableParams)), /*#__PURE__*/React__default['default'].createElement(Editor, {
30055
+ type: "table",
30056
+ onRun: onClickRun,
30057
+ value: jsonEditorVal,
30058
+ shallowHeight: height
30059
+ })), tableJsonEditorValsArr.map(function (k) {
30060
+ return /*#__PURE__*/React__default['default'].createElement(antd.Tabs.TabPane, {
30061
+ tab: k.title,
30062
+ key: k.tableCode
30063
+ }, !tablesConfigParams[k.tableCode] ? /*#__PURE__*/React__default['default'].createElement("div", {
30064
+ style: {
30065
+ padding: "10px 0",
30066
+ fontSize: "16px",
30067
+ fontWeight: "bolder"
30068
+ }
30069
+ }, "\u63D0\u793A\uFF1A\u4E1A\u52A1\u5BF9\u8C61\u672A\u7EF4\u62A4\uFF0C\u8BF7\u5728\u901A\u7528\u5355\u636E\u5BF9\u5E94\u4E1A\u52A1\u7C7B\u578B\u4E0B\u7EF4\u62A4\u4E1A\u52A1\u5BF9\u8C61") : /*#__PURE__*/React__default['default'].createElement(FieldsSettingsTable, _objectSpread2({}, tablesConfigParams[k.tableCode])), /*#__PURE__*/React__default['default'].createElement(Editor, {
30070
+ type: "table",
30071
+ onRun: onClickRunDetailTables,
30072
+ value: k.columns,
30073
+ shallowHeight: height
30074
+ }));
30075
+ }))), !visible && isAdmin() && /*#__PURE__*/React__default['default'].createElement(ConfigButton, {
29937
30076
  type: 'primary',
29938
30077
  onClick: function onClick() {
29939
30078
  return setVisible(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "2.2.0-alpha.1",
3
+ "version": "2.2.0-alpha.3",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -101,7 +101,7 @@ class SearchItemTable extends React.Component {
101
101
  };
102
102
 
103
103
  setInitValue = (isClick = false) => {
104
- const { datasource, showSearchFields }: any =
104
+ const { datasource = [], showSearchFields =[] }: any =
105
105
  this.props;
106
106
  let config = this.getConfigFromlocalstorage();
107
107
  this.setState({
@@ -195,7 +195,7 @@ export default (props: any) => {
195
195
 
196
196
  const setInitialSearchFieldsInfo = () =>{
197
197
  //获取搜索字段的缓存配置
198
- const { fields } = props;
198
+ const { fields = [] } = props;
199
199
  let searchFieldsConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION);
200
200
  let showSearchFields = searchFieldsConfig.length ? searchFieldsConfig.map((item) => {
201
201
  let inner = fields.filter(
@@ -12,6 +12,7 @@ export default (props:any)=>{
12
12
  codeProps='',
13
13
  moduleType,
14
14
  moduleRelationId,
15
+ tableFlag = false
15
16
  } = props;
16
17
 
17
18
  const ref = useRef(null);
@@ -108,6 +109,9 @@ export default (props:any)=>{
108
109
  key: 'code',
109
110
  title: '代码片段',
110
111
  render: ({text,record}:any) => {
112
+ if(tableFlag){
113
+ return <div> 列表:{`{"key": "extensionFields,${record.code}","dataIndex": "extensionFields,${record.code}","title": "${record.name}"},`}</div>
114
+ }
111
115
  if (!codeProps.columns) {
112
116
  return <div>表单:{`{"name": "extensionFields,${record.code}","label": "${record.name}"},`}</div>
113
117
  }
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
- import React, { useState, useRef, useEffect } from 'react';
3
- import { message, Button, Table } from 'antd';
2
+ import React, { useState, useRef, useEffect, Fragment } from 'react';
3
+ import { message, Button, Table, Tabs } from 'antd';
4
4
  import Drawer from './drawer';
5
5
  import ConfigButton from './configButton';
6
6
  import Editor from './jsonEditor';
@@ -205,11 +205,13 @@ const tableStyleList = [
205
205
  ];
206
206
  const JsonQueryTable = React.memo(props => {
207
207
  const {
208
- callBack,
209
- codeProps,
210
- customerFields,
211
- initialSetting,
212
- pageType
208
+ callBack, // 主保存函数回调
209
+ codeProps, // 整体的配置数据
210
+ customerFields, //可选的配置字段
211
+ initialSetting, //上一次添加自定义字段后保存的数据
212
+ pageType, //页面权限code
213
+ detailTablesSetting = [], //详情明细表格列配置数据
214
+ saveTableCallBack, //详情明细保存函数回调
213
215
  } = props;
214
216
 
215
217
  let codeFilter = {};
@@ -229,7 +231,6 @@ const JsonQueryTable = React.memo(props => {
229
231
  } else {
230
232
  codeFilter.fields = iterFileds({fields: codeProps.fields}).fields
231
233
  }
232
- console.log('codeFilter',codeFilter)
233
234
 
234
235
  const styleRef = useRef(null);
235
236
 
@@ -238,6 +239,9 @@ const JsonQueryTable = React.memo(props => {
238
239
  const [init, setInit] = useState(true);
239
240
  const [jsonEditorVal, setJsonEditorVal] = useState(initialSetting || codeFilter);
240
241
  const [moduleParams, setModuleParams] = useState({});
242
+ const [activeKey, setActiveKey] = useState('main'); //默认详情页配置
243
+ const [tablesConfigParams, setTablesConfigParams] = useState({});
244
+ const [tableJsonEditorValsArr, setTableJsonEditorValsArr] = useState([]);
241
245
 
242
246
  useEffect(()=>{
243
247
  Promise.all([
@@ -258,6 +262,52 @@ const JsonQueryTable = React.memo(props => {
258
262
  })
259
263
  },[]);
260
264
 
265
+ useEffect(()=>{
266
+ //明细表的配置数据
267
+ const axiosArr = detailTablesSetting.map((item:any) => axios.get(`/basic/flow/businessFieldGroup/one?moduleType=2&layoutPoint=${item.tableCode}`));
268
+ Promise.all(axiosArr).then(([...resArr])=> {
269
+ detailTablesSetting.map((item:any, index:number)=>{
270
+ const { code, data } = resArr[index]?.data || {};
271
+ if(data){
272
+ const { businessType, code:fieldGroup, moduleType } = data;
273
+ setTablesConfigParams({
274
+ ...tablesConfigParams,
275
+ [item.tableCode]: {
276
+ businessType,
277
+ fieldGroup,
278
+ moduleType,
279
+ tableFlag: true
280
+ }
281
+ });
282
+ }
283
+ })
284
+ })
285
+
286
+ const detailTableCodeFilter = detailTablesSetting.map(item => {
287
+ if(item?.initialSetting && item?.initialSetting.length){
288
+ return {
289
+ ...item,
290
+ columns: item?.initialSetting
291
+ }
292
+ }
293
+ return {
294
+ ...item,
295
+ columns: item?.columns.map(childItem => ({
296
+ key: childItem.key || childItem.dataIndex,
297
+ dataIndex: childItem.dataIndex || childItem.key,
298
+ isStaticCode: true,
299
+ title: childItem.title
300
+ }))
301
+ }
302
+ });
303
+ setTableJsonEditorValsArr([...detailTableCodeFilter]);
304
+ detailTableCodeFilter.map(item => {
305
+ if(item?.initialSetting && item?.initialSetting.length){
306
+ onClickRunDetailTables(item.initialSetting, false, item.tableCode, detailTableCodeFilter);
307
+ }
308
+ })
309
+ },[detailTablesSetting.length]);
310
+
261
311
  const onClickRun = (value, isSave) => {
262
312
  setJsonEditorVal(value);
263
313
 
@@ -269,6 +319,38 @@ const JsonQueryTable = React.memo(props => {
269
319
  }
270
320
  };
271
321
 
322
+ //明细表保存
323
+ const onClickRunDetailTables = (value, isSave, tableCode, tableSouce) =>{
324
+ const targetCode = tableCode || activeKey;
325
+ const targetTableSource = tableSouce || tableJsonEditorValsArr;
326
+ const newArr = targetTableSource.map(item => {
327
+ if(item.tableCode == targetCode){
328
+ return {
329
+ ...item,
330
+ columns: value
331
+ }
332
+ }
333
+ return item
334
+ });
335
+ setTableJsonEditorValsArr([...newArr]);
336
+
337
+ try {
338
+ const target = targetTableSource.find(item=>item.tableCode == targetCode);
339
+ const codeProps = {
340
+ fields: [],
341
+ columns: target?.columns,
342
+ };
343
+ const newValue = {
344
+ fields: [],
345
+ columns: value
346
+ };
347
+ const result = hanleCallbackValue(codeProps, newValue, target?.customerFields);
348
+ saveTableCallBack({ columns: result.columns, tableCode: targetCode }, isSave, value);
349
+ } catch (e) {
350
+ message.error(e);
351
+ }
352
+ }
353
+
272
354
  React.useEffect(() => {
273
355
  localStorage.setItem('jsonEditorVal',JSON.stringify(jsonEditorVal||{}))
274
356
  }, [jsonEditorVal]);
@@ -292,24 +374,71 @@ const JsonQueryTable = React.memo(props => {
292
374
  return (
293
375
  <div>
294
376
  <Drawer visible={visible} width={800} onClose={() => setVisible(false)} className={'customFieldsDrawer'}>
295
- <div ref={styleRef}>
296
-
297
- </div>
377
+ {
378
+ detailTablesSetting.length == 0 &&(
379
+ <Fragment>
380
+ {
381
+ isEmpty(moduleParams)?(
382
+ <div style={{padding:"10px 0", fontSize:"16px", fontWeight:"bolder"}}>
383
+ 提示:业务对象未维护,请在通用单据对应业务类型下维护业务对象
384
+ </div>
385
+ ):(
386
+ <FieldsSettingsTable {...tableParams}/>
387
+ )
388
+ }
389
+ <Editor
390
+ type="table"
391
+ onRun={onClickRun}
392
+ value={jsonEditorVal}
393
+ shallowHeight={height}
394
+ />
395
+ </Fragment>
396
+ )
397
+ }
298
398
  {
299
- isEmpty(moduleParams)?(
300
- <div style={{padding:"10px 0", fontSize:"16px", fontWeight:"bolder"}}>
301
- 提示:业务对象未维护,请在通用单据对应业务类型下维护业务对象
302
- </div>
303
- ):(
304
- <FieldsSettingsTable {...tableParams}/>
399
+ detailTablesSetting.length > 0 && (
400
+ <Tabs defaultActiveKey={activeKey} onChange={(v: any) => setActiveKey(v)}>
401
+ <Tabs.TabPane tab="详情页配置" key="main">
402
+ {
403
+ isEmpty(moduleParams)?(
404
+ <div style={{padding:"10px 0", fontSize:"16px", fontWeight:"bolder"}}>
405
+ 提示:业务对象未维护,请在通用单据对应业务类型下维护业务对象
406
+ </div>
407
+ ):(
408
+ <FieldsSettingsTable {...tableParams}/>
409
+ )
410
+ }
411
+ <Editor
412
+ type="table"
413
+ onRun={onClickRun}
414
+ value={jsonEditorVal}
415
+ shallowHeight={height}
416
+ />
417
+ </Tabs.TabPane>
418
+ {
419
+ tableJsonEditorValsArr.map((k:any)=>(
420
+ <Tabs.TabPane tab={k.title} key={k.tableCode}>
421
+ {
422
+ !tablesConfigParams[k.tableCode]?(
423
+ <div style={{padding:"10px 0", fontSize:"16px", fontWeight:"bolder"}}>
424
+ 提示:业务对象未维护,请在通用单据对应业务类型下维护业务对象
425
+ </div>
426
+ ):(
427
+ <FieldsSettingsTable {...tablesConfigParams[k.tableCode]}/>
428
+ )
429
+ }
430
+ <Editor
431
+ type="table"
432
+ onRun={onClickRunDetailTables}
433
+ value={k.columns}
434
+ shallowHeight={height}
435
+ />
436
+ </Tabs.TabPane>
437
+ ))
438
+ }
439
+ </Tabs>
305
440
  )
306
441
  }
307
- <Editor
308
- type="table"
309
- onRun={onClickRun}
310
- value={jsonEditorVal}
311
- shallowHeight={height}
312
- />
313
442
  </Drawer>
314
443
 
315
444
  {!visible && isAdmin() && <ConfigButton type='primary' onClick={() => setVisible(true)}>setting</ConfigButton>}