@nokecy/qc-ui 0.1.6 → 0.1.8

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,4 @@
1
+ import { SelectProps } from "antd/lib/select";
2
+ import React from "react";
3
+ declare const _default: React.ForwardRefExoticComponent<SelectProps<any, import("rc-select/lib/Select").DefaultOptionType> & React.RefAttributes<unknown>>;
4
+ export default _default;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _ahooks = require("ahooks");
9
+
10
+ var _antd = require("antd");
11
+
12
+ var _react = _interopRequireDefault(require("react"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
+
18
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
19
+
20
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
21
+
22
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
+
24
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
25
+
26
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
27
+
28
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
29
+
30
+ /**
31
+ * bool类型的下拉框
32
+ * @param props
33
+ * @param ref
34
+ * @returns
35
+ */
36
+ var BoolSelect = function BoolSelect(props, ref) {
37
+ var _useControllableValue = (0, _ahooks.useControllableValue)(props),
38
+ _useControllableValue2 = _slicedToArray(_useControllableValue, 2),
39
+ state = _useControllableValue2[0],
40
+ setState = _useControllableValue2[1];
41
+
42
+ return /*#__PURE__*/_react.default.createElement("span", {
43
+ ref: ref
44
+ }, /*#__PURE__*/_react.default.createElement(_antd.Select, _extends({}, props, {
45
+ value: state,
46
+ onChange: function onChange(value, option) {
47
+ var _props$onChange;
48
+
49
+ setState(value);
50
+ props === null || props === void 0 ? void 0 : (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, value, option);
51
+ }
52
+ }), /*#__PURE__*/_react.default.createElement(_antd.Select.Option, {
53
+ value: true
54
+ }, "\u662F"), /*#__PURE__*/_react.default.createElement(_antd.Select.Option, {
55
+ value: false
56
+ }, "\u5426")));
57
+ };
58
+
59
+ var _default = /*#__PURE__*/_react.default.forwardRef(BoolSelect);
60
+
61
+ exports.default = _default;
@@ -31,7 +31,9 @@ var _icons = require("@ant-design/icons");
31
31
 
32
32
  var _utils = require("./utils");
33
33
 
34
- var _excluded = ["style", "params", "request", "dataSource", "gridRef", "headerTitle", "toolBarRender", "search", "hideRedo", "onGridReady", "gridKey", "gridColumnState", "children"];
34
+ var _setting = _interopRequireDefault(require("./setting"));
35
+
36
+ var _excluded = ["style", "params", "request", "dataSource", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideRedo", "onGridReady", "gridKey", "gridColumnState", "children"];
35
37
 
36
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
39
 
@@ -72,6 +74,7 @@ function AgGridPlus(props) {
72
74
  gridParams = props.params,
73
75
  request = props.request,
74
76
  dataSource = props.dataSource,
77
+ propRowData = props.rowData,
75
78
  propsGridRef = props.gridRef,
76
79
  headerTitle = props.headerTitle,
77
80
  toolBarRender = props.toolBarRender,
@@ -99,8 +102,8 @@ function AgGridPlus(props) {
99
102
 
100
103
  var _useState5 = (0, _react.useState)(),
101
104
  _useState6 = _slicedToArray(_useState5, 2),
102
- columnDefs = _useState6[0],
103
- setColumnDefs = _useState6[1];
105
+ columnState = _useState6[0],
106
+ setColumnState = _useState6[1];
104
107
 
105
108
  var _useState7 = (0, _react.useState)([]),
106
109
  _useState8 = _slicedToArray(_useState7, 2),
@@ -162,15 +165,17 @@ function AgGridPlus(props) {
162
165
  }
163
166
  }, [gridColumnState, columnsRef.current]);
164
167
  (0, _react.useEffect)(function () {
165
- setRowData(dataSource || rowData);
166
- }, [dataSource, rowData]);
168
+ setRowData(dataSource || propRowData || []);
169
+ }, [dataSource, propRowData]);
167
170
  var onGridReady = (0, _react.useCallback)(function (params) {
171
+ var _columnsRef$current;
172
+
168
173
  apiRef.current = params.api;
169
174
  columnsRef.current = params.columnApi;
170
175
  onReady && onReady(params); ///@ts-ignore
171
176
 
172
177
  dataSource && setRowData(dataSource);
173
- setColumnDefs(columnsRef.current.getColumns());
178
+ setColumnState((_columnsRef$current = columnsRef.current) === null || _columnsRef$current === void 0 ? void 0 : _columnsRef$current.getColumnState());
174
179
  sortChanged(params.columnApi);
175
180
  setReady(true);
176
181
  }, [dataSource]);
@@ -214,6 +219,8 @@ function AgGridPlus(props) {
214
219
  request && onRequest(queryFilter);
215
220
  };
216
221
 
222
+ var onSaveColumnState = function onSaveColumnState(columnState) {};
223
+
217
224
  (0, _react.useEffect)(function () {
218
225
  gridRef.current = {
219
226
  onRefresh: onRefresh
@@ -231,7 +238,7 @@ function AgGridPlus(props) {
231
238
  height: "100%"
232
239
  }
233
240
  }, search == false ? null : /*#__PURE__*/_react.default.createElement(_queryForm.default, {
234
- columns: columnDefs,
241
+ columnStates: columnState || [],
235
242
  gridApi: apiRef.current,
236
243
  onQuery: function onQuery(formValues) {
237
244
  setQueryFilter(_objectSpread({}, formValues));
@@ -265,9 +272,10 @@ function AgGridPlus(props) {
265
272
  settings: [/*#__PURE__*/_react.default.createElement(_settingItem.default, {
266
273
  onClick: onRefresh,
267
274
  icon: /*#__PURE__*/_react.default.createElement(_icons.RedoOutlined, null)
268
- }), /*#__PURE__*/_react.default.createElement(_settingItem.default, {
269
- onClick: onRefresh,
270
- icon: /*#__PURE__*/_react.default.createElement(_icons.SettingOutlined, null)
275
+ }), /*#__PURE__*/_react.default.createElement(_setting.default, {
276
+ gridApi: apiRef.current,
277
+ columnApi: columnsRef.current,
278
+ onSaveColumnState: onSaveColumnState
271
279
  })]
272
280
  }), /*#__PURE__*/_react.default.createElement(_agGridReact.AgGridReact, _extends({
273
281
  className: "ag-theme-alpine"
@@ -284,8 +292,31 @@ function AgGridPlus(props) {
284
292
  props.onSelectionChanged && props.onSelectionChanged(e);
285
293
  setSelectRows(e.api.getSelectedRows());
286
294
  },
295
+ onDragStopped: function onDragStopped(e) {
296
+ if (columnsRef.current) {
297
+ var _columnsRef$current2;
298
+
299
+ setColumnState((_columnsRef$current2 = columnsRef.current) === null || _columnsRef$current2 === void 0 ? void 0 : _columnsRef$current2.getColumnState());
300
+ }
301
+ },
302
+ onColumnResized: function onColumnResized(e) {
303
+ if (columnsRef.current) {
304
+ var _columnsRef$current3, _columnsRef$current4;
305
+
306
+ console.log((_columnsRef$current3 = columnsRef.current) === null || _columnsRef$current3 === void 0 ? void 0 : _columnsRef$current3.getColumnState());
307
+ setColumnState((_columnsRef$current4 = columnsRef.current) === null || _columnsRef$current4 === void 0 ? void 0 : _columnsRef$current4.getColumnState());
308
+ }
309
+ },
310
+ onColumnMoved: function onColumnMoved() {
311
+ if (columnsRef.current) {
312
+ var _columnsRef$current5;
313
+
314
+ setColumnState((_columnsRef$current5 = columnsRef.current) === null || _columnsRef$current5 === void 0 ? void 0 : _columnsRef$current5.getColumnState());
315
+ }
316
+ },
287
317
  columnTypes: {
288
318
  bool: {
319
+ filter: 'boolFilter',
289
320
  cellRenderer: function cellRenderer(params) {
290
321
  switch (params.value) {
291
322
  case true:
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { GridApi } from 'ag-grid-community';
2
+ import { ColumnState, GridApi } from 'ag-grid-community';
3
3
  import './index.less';
4
4
  declare const FormRender: (props: {
5
5
  className?: any;
6
6
  gridApi?: GridApi<any> | undefined;
7
- columns: any[];
7
+ columnStates: ColumnState[];
8
8
  onQuery: (formValue: any) => void;
9
9
  }) => JSX.Element;
10
10
  export default FormRender;
@@ -21,6 +21,8 @@ var _react2 = _interopRequireWildcard(require("react"));
21
21
 
22
22
  var _queryForm = _interopRequireDefault(require("./queryForm"));
23
23
 
24
+ var _boolSelect = _interopRequireDefault(require("../_utils/boolSelect"));
25
+
24
26
  require("./index.less");
25
27
 
26
28
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -56,7 +58,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
56
58
  var FormRender = function FormRender(props) {
57
59
  var className = props.className,
58
60
  gridApi = props.gridApi,
59
- columns = props.columns,
61
+ columnStates = props.columnStates,
60
62
  onQuery = props.onQuery;
61
63
  var form = (0, _react2.useMemo)(function () {
62
64
  return (0, _core.createForm)();
@@ -71,7 +73,8 @@ var FormRender = function FormRender(props) {
71
73
  FormGrid: _antd.FormGrid,
72
74
  FormButtonGroup: _antd.FormButtonGroup,
73
75
  Submit: _antd.Submit,
74
- Button: _antd2.Button
76
+ Button: _antd2.Button,
77
+ BoolSelect: _boolSelect.default
75
78
  }
76
79
  });
77
80
  }, []);
@@ -113,13 +116,31 @@ var FormRender = function FormRender(props) {
113
116
  schema = _useState2[0],
114
117
  setSchema = _useState2[1];
115
118
 
119
+ var getComponent = function getComponent(colDef) {
120
+ var component = colDef.searchComponent ? colDef.searchComponent : undefined;
121
+
122
+ if (!component) {
123
+ switch (colDef.filter) {
124
+ case "agDateColumnFilter":
125
+ component = "DatePicker.RangePicker";
126
+ break;
127
+
128
+ case "boolFilter":
129
+ component = "BoolSelect";
130
+ break;
131
+ }
132
+
133
+ return component ? component : "Input";
134
+ }
135
+ };
136
+
116
137
  var getSchema = function getSchema() {
117
138
  var rootSchema = {
118
139
  type: 'object',
119
140
  properties: {}
120
141
  };
121
142
 
122
- if (!columns) {
143
+ if (!columnStates) {
123
144
  return rootSchema;
124
145
  }
125
146
 
@@ -131,31 +152,22 @@ var FormRender = function FormRender(props) {
131
152
  },
132
153
  properties: {}
133
154
  };
134
- columns.forEach(function (i, index) {
135
- i.searchSort = i.getColDef().searchSort === 0 ? i.getColDef().searchSort : i.getColDef().searchSort || index;
136
- }); //ag-grid 列 添加属性 searchSort,冒泡排序表单
137
-
138
- for (var i = 0; i < columns.length - 1; i++) {
139
- for (var j = 0; j < columns.length - 1 - i; j++) {
140
- if (columns[j].searchSort > columns[j + 1].searchSort) {
141
- var temp = columns[j];
142
- columns[j] = columns[j + 1];
143
- columns[j + 1] = temp;
144
- }
145
- }
146
- }
147
-
148
- var arr = columns.filter(function (i) {
149
- return (i === null || i === void 0 ? void 0 : i.visible) != false && !i.getColDef().hideInSearch || i.getColDef().hideInTable;
155
+ var columns = columnStates.filter(function (x) {
156
+ return !x.hide;
157
+ }).map(function (columnState) {
158
+ return gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(columnState.colId);
159
+ });
160
+ columns = columns.filter(function (i) {
161
+ return (i === null || i === void 0 ? void 0 : i.visible) != false && !i.hideInSearch || i.hideInTable;
150
162
  });
151
- arr.map(function (col) {
163
+ columns.map(function (col) {
152
164
  var _colDef$queryField;
153
165
 
154
- var colDef = col.getColDef();
166
+ var colDef = col;
155
167
  var name = (_colDef$queryField = colDef.queryField) !== null && _colDef$queryField !== void 0 ? _colDef$queryField : colDef.field;
156
168
  var headerName = colDef.headerName; //表单自定义组件
157
169
 
158
- var component = colDef.searchComponent ? colDef.searchComponent : colDef.filter == "agDateColumnFilter" ? "DatePicker.RangePicker" : "Input";
170
+ var component = getComponent(colDef);
159
171
 
160
172
  if (colDef.filter != false) {
161
173
  var _colDef$searchCompone, _colDef$searchCompone2;
@@ -182,7 +194,7 @@ var FormRender = function FormRender(props) {
182
194
 
183
195
  rootSchema.properties["grid"] = gridSchema;
184
196
 
185
- if (!arr.length) {
197
+ if (!columns.length) {
186
198
  ///@ts-ignore
187
199
  delete rootSchema.properties["grid"];
188
200
  }
@@ -193,7 +205,7 @@ var FormRender = function FormRender(props) {
193
205
  (0, _react2.useEffect)(function () {
194
206
  var new_schema = getSchema();
195
207
  setSchema(new_schema);
196
- }, [columns]);
208
+ }, [JSON.stringify(columnStates)]);
197
209
  return /*#__PURE__*/_react2.default.createElement("div", {
198
210
  className: (0, _classnames.default)(className, "ag-grid-table-search ag-grid-table-search-query-filter")
199
211
  }, /*#__PURE__*/_react2.default.createElement(_antd.Form, {
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { ColumnApi, GridApi } from 'ag-grid-community';
3
+ declare const Setting: (props: {
4
+ gridApi?: GridApi<any> | undefined;
5
+ columnApi: ColumnApi;
6
+ onSaveColumnState: (state: any) => void;
7
+ }) => JSX.Element;
8
+ export default Setting;
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _uniqueId2 = _interopRequireDefault(require("lodash/uniqueId"));
11
+
12
+ var _antd = require("@formily/antd");
13
+
14
+ var _react = require("@formily/react");
15
+
16
+ var _core = require("@formily/core");
17
+
18
+ var _react2 = _interopRequireWildcard(require("react"));
19
+
20
+ var _icons = require("@ant-design/icons");
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+
28
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
29
+
30
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
31
+
32
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
33
+
34
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
35
+
36
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
37
+
38
+ 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; }
39
+
40
+ var Setting = function Setting(props) {
41
+ var gridApi = props.gridApi,
42
+ columnApi = props.columnApi,
43
+ onSaveColumnState = props.onSaveColumnState;
44
+ var SchemaField = (0, _react2.useMemo)(function () {
45
+ return (0, _react.createSchemaField)({
46
+ components: {
47
+ FormTab: _antd.FormTab,
48
+ FormItem: _antd.FormItem,
49
+ FormGrid: _antd.FormGrid,
50
+ Space: _antd.Space,
51
+ Input: _antd.Input,
52
+ Select: _antd.Select,
53
+ ArrayTable: _antd.ArrayTable,
54
+ NumberPicker: _antd.NumberPicker,
55
+ Switch: _antd.Switch
56
+ }
57
+ });
58
+ }, []);
59
+ var formProps = {
60
+ effects: function effects() {
61
+ (0, _core.onFormInit)(function (form) {
62
+ form.setInitialValuesIn('items', getColumnData());
63
+ });
64
+ }
65
+ };
66
+
67
+ var getColumnData = function getColumnData() {
68
+ var columnStates = columnApi.getColumnState();
69
+ var columnRowData = [];
70
+ var columns = columnStates.map(function (columnState) {
71
+ var colDef = gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(columnState.colId);
72
+ columnRowData.push(_objectSpread({
73
+ field: colDef.field,
74
+ headerName: colDef.headerName,
75
+ width: columnState.width,
76
+ hide: columnState.hide
77
+ }, columnState));
78
+ });
79
+ return columnRowData;
80
+ };
81
+
82
+ var portalId = "workProcedure".concat((0, _uniqueId2.default)());
83
+ return /*#__PURE__*/_react2.default.createElement(_antd.FormDialog.Portal, {
84
+ id: portalId
85
+ }, /*#__PURE__*/_react2.default.createElement("div", {
86
+ style: {
87
+ margin: "0 4px",
88
+ color: "#000",
89
+ fontSize: 16,
90
+ cursor: "pointer"
91
+ },
92
+ onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
93
+ var formDialog;
94
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
95
+ while (1) {
96
+ switch (_context.prev = _context.next) {
97
+ case 0:
98
+ formDialog = (0, _antd.FormDialog)({
99
+ title: "个性化设置",
100
+ width: 960
101
+ }, portalId, function () {
102
+ return /*#__PURE__*/_react2.default.createElement(_antd.FormLayout, null, /*#__PURE__*/_react2.default.createElement(SchemaField, null, /*#__PURE__*/_react2.default.createElement(SchemaField.Void, {
103
+ "x-component": "FormGrid",
104
+ "x-component-props": {
105
+ maxColumns: [1, 3],
106
+ strictAutoFit: true
107
+ }
108
+ }, /*#__PURE__*/_react2.default.createElement(SchemaField.Array, {
109
+ name: "items",
110
+ title: "",
111
+ "x-component": "ArrayTable",
112
+ "x-validator": [{
113
+ message: ""
114
+ }],
115
+ "x-decorator": "FormItem",
116
+ "x-decorator-props": {
117
+ gridSpan: 3
118
+ }
119
+ }, /*#__PURE__*/_react2.default.createElement(SchemaField.Object, null, /*#__PURE__*/_react2.default.createElement(SchemaField.Void, {
120
+ "x-component": "ArrayTable.Column",
121
+ "x-component-props": {
122
+ width: 150,
123
+ title: "字段名"
124
+ }
125
+ }, /*#__PURE__*/_react2.default.createElement(SchemaField.String, {
126
+ name: "field",
127
+ "x-decorator": "FormItem",
128
+ "x-component": "Input",
129
+ "x-read-pretty": true
130
+ })), /*#__PURE__*/_react2.default.createElement(SchemaField.Void, {
131
+ "x-component": "ArrayTable.Column",
132
+ "x-component-props": {
133
+ width: 150,
134
+ title: "列名"
135
+ }
136
+ }, /*#__PURE__*/_react2.default.createElement(SchemaField.String, {
137
+ name: "headerName",
138
+ "x-decorator": "FormItem",
139
+ "x-component": "Input",
140
+ "x-read-pretty": true
141
+ })), /*#__PURE__*/_react2.default.createElement(SchemaField.Void, {
142
+ "x-component": "ArrayTable.Column",
143
+ "x-component-props": {
144
+ width: 150,
145
+ title: "宽度"
146
+ }
147
+ }, /*#__PURE__*/_react2.default.createElement(SchemaField.String, {
148
+ name: "width",
149
+ "x-decorator": "FormItem",
150
+ "x-component": "NumberPicker"
151
+ })), /*#__PURE__*/_react2.default.createElement(SchemaField.Void, {
152
+ "x-component": "ArrayTable.Column",
153
+ "x-component-props": {
154
+ width: 150,
155
+ title: "占满"
156
+ }
157
+ }, /*#__PURE__*/_react2.default.createElement(SchemaField.String, {
158
+ name: "flex",
159
+ "x-decorator": "FormItem",
160
+ "x-component": "Switch"
161
+ })), /*#__PURE__*/_react2.default.createElement(SchemaField.Void, {
162
+ "x-component": "ArrayTable.Column",
163
+ "x-component-props": {
164
+ width: 150,
165
+ title: '固定位置'
166
+ }
167
+ }, /*#__PURE__*/_react2.default.createElement(SchemaField.String, {
168
+ name: "pinned",
169
+ "x-decorator": "FormItem",
170
+ "x-component": "Select",
171
+ enum: [{
172
+ value: "left",
173
+ label: "左固定"
174
+ }, {
175
+ value: "right",
176
+ label: "右固定"
177
+ }, {
178
+ value: undefined,
179
+ label: "不固定"
180
+ }]
181
+ })), /*#__PURE__*/_react2.default.createElement(SchemaField.Void, {
182
+ "x-component": "ArrayTable.Column",
183
+ "x-component-props": {
184
+ width: 150,
185
+ title: '隐藏'
186
+ }
187
+ }, /*#__PURE__*/_react2.default.createElement(SchemaField.String, {
188
+ name: "hide",
189
+ "x-decorator": "FormItem",
190
+ "x-component": "Switch"
191
+ })))))));
192
+ });
193
+ formDialog.forConfirm(function (payload, next) {
194
+ var values = payload.values;
195
+ var falg = columnApi.applyColumnState({
196
+ state: values.items,
197
+ applyOrder: true
198
+ });
199
+ onSaveColumnState && onSaveColumnState(values.items);
200
+ next(payload);
201
+ }).open(formProps);
202
+
203
+ case 2:
204
+ case "end":
205
+ return _context.stop();
206
+ }
207
+ }
208
+ }, _callee);
209
+ }))
210
+ }, /*#__PURE__*/_react2.default.createElement(_icons.SettingOutlined, null)));
211
+ };
212
+
213
+ var _default = Setting;
214
+ exports.default = _default;
@@ -0,0 +1,4 @@
1
+ import { SelectProps } from "antd/lib/select";
2
+ import React from "react";
3
+ declare const _default: React.ForwardRefExoticComponent<SelectProps<any, import("rc-select/lib/Select").DefaultOptionType> & React.RefAttributes<unknown>>;
4
+ export default _default;
@@ -0,0 +1,48 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
10
+
11
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
12
+
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+
15
+ import { useControllableValue } from 'ahooks';
16
+ import { Select } from "antd";
17
+ import React from "react";
18
+ /**
19
+ * bool类型的下拉框
20
+ * @param props
21
+ * @param ref
22
+ * @returns
23
+ */
24
+
25
+ var BoolSelect = function BoolSelect(props, ref) {
26
+ var _useControllableValue = useControllableValue(props),
27
+ _useControllableValue2 = _slicedToArray(_useControllableValue, 2),
28
+ state = _useControllableValue2[0],
29
+ setState = _useControllableValue2[1];
30
+
31
+ return /*#__PURE__*/React.createElement("span", {
32
+ ref: ref
33
+ }, /*#__PURE__*/React.createElement(Select, _extends({}, props, {
34
+ value: state,
35
+ onChange: function onChange(value, option) {
36
+ var _props$onChange;
37
+
38
+ setState(value);
39
+ props === null || props === void 0 ? void 0 : (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, value, option);
40
+ }
41
+ }), /*#__PURE__*/React.createElement(Select.Option, {
42
+ value: true
43
+ }, "\u662F"), /*#__PURE__*/React.createElement(Select.Option, {
44
+ value: false
45
+ }, "\u5426")));
46
+ };
47
+
48
+ export default /*#__PURE__*/React.forwardRef(BoolSelect);