kts-component-invoice-operate 3.2.18 → 3.2.19

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/d.dio ADDED
File without changes
@@ -0,0 +1,6 @@
1
+ import IGood from "../GoodsListState/IGood";
2
+ /** 自动补全 */
3
+ export default class AutoComplete {
4
+ /** 商品名称自动补全 */
5
+ onItemNameSearch?: (searchText: string) => Promise<IGood[]>;
6
+ }
@@ -2,6 +2,7 @@ import GoodsListState from './GoodsListState';
2
2
  import BuyerState from './BuyerState';
3
3
  import Stakeholder from './Stakeholder';
4
4
  import { IInvoiceTypeModalProps } from '../../../InvoiceTypeModal';
5
+ import AutoComplete from './AutoComplete';
5
6
  export default class InvoiceControllerState {
6
7
  /**
7
8
  * 组件模式
@@ -41,4 +42,6 @@ export default class InvoiceControllerState {
41
42
  rootElement?: HTMLDivElement | null;
42
43
  /** 发票类型选择窗口 */
43
44
  typeModalProps?: IInvoiceTypeModalProps;
45
+ /** 自动补全 */
46
+ autoComplete: AutoComplete;
44
47
  }
package/dist/index.esm.js CHANGED
@@ -2,9 +2,9 @@ import 'kts-components-antd-x3/dist/kts-components-antd-x3.css';
2
2
  import React, { createElement, createContext, useContext, useEffect, forwardRef, Children, isValidElement } from 'react';
3
3
  import GreyReactBox, { decorator } from 'grey-react-box';
4
4
  import { chain as chain$1, bignumber, create, all } from 'mathjs';
5
- import { message, Form, Input, Icon as Icon$1, Tag as Tag$1, Select, Button, Tooltip, Switch as Switch$1, Typography, Menu, Dropdown, AutoComplete, Spin, Checkbox, Drawer, Descriptions, Empty, Divider, Popover, Table as Table$1, Tree, Modal as Modal$1, Row as Row$1, Col as Col$1 } from 'kts-components-antd-x3';
5
+ import { message, Form, Input, Icon as Icon$1, Tag as Tag$1, Select, Button, Tooltip, Switch as Switch$1, Typography, Menu, Dropdown, AutoComplete as AutoComplete$2, Spin, Checkbox, Drawer, Descriptions, Empty, Divider, Popover, Table as Table$1, Tree, Modal as Modal$1, Row as Row$1, Col as Col$1 } from 'kts-components-antd-x3';
6
6
  import { v4 } from 'uuid';
7
- import { message as message$1, TableManual, Switch, Row, Col, Button as Button$1, Tooltip as Tooltip$1, Input as Input$1, AutoComplete as AutoComplete$1, Select as Select$1, Spin as Spin$1, Menu as Menu$1, Form as Form$1, Drawer as Drawer$1, Space, Radio, InputNumber, Popconfirm, Modal } from 'kts-xui';
7
+ import { message as message$1, TableManual, Switch, AutoComplete as AutoComplete$1, Row, Col, Button as Button$1, Tooltip as Tooltip$1, Input as Input$1, Select as Select$1, Spin as Spin$1, Menu as Menu$1, Form as Form$1, Drawer as Drawer$1, Space, Radio, InputNumber, Popconfirm, Modal } from 'kts-xui';
8
8
  import classnames from 'classnames';
9
9
  import { Table } from 'kts-components-antd-x4-v4';
10
10
  import { Input as Input$2, NumberPicker } from '@formily/antd-components';
@@ -1080,6 +1080,13 @@ var Stakeholder = /*#__PURE__*/_createClass(function Stakeholder() {
1080
1080
  this.rulesMap = void 0;
1081
1081
  });
1082
1082
 
1083
+ /** 自动补全 */
1084
+ var AutoComplete = /*#__PURE__*/_createClass(function AutoComplete() {
1085
+ _classCallCheck(this, AutoComplete);
1086
+
1087
+ this.onItemNameSearch = void 0;
1088
+ });
1089
+
1083
1090
  var InvoiceControllerState = /*#__PURE__*/_createClass(function InvoiceControllerState() {
1084
1091
  _classCallCheck(this, InvoiceControllerState);
1085
1092
 
@@ -1094,6 +1101,7 @@ var InvoiceControllerState = /*#__PURE__*/_createClass(function InvoiceControlle
1094
1101
  this.priceIntegerDigit = void 0;
1095
1102
  this.rootElement = null;
1096
1103
  this.typeModalProps = void 0;
1104
+ this.autoComplete = new AutoComplete();
1097
1105
  });
1098
1106
 
1099
1107
  /**
@@ -10145,15 +10153,76 @@ var TitleText = (function (props) {
10145
10153
  }, "*") : React.createElement(React.Fragment, null), children);
10146
10154
  });
10147
10155
 
10148
- var css_248z$6 = ".kts-invoice-operate-goods-list-itemName-input {\n display: flex;\n flex: 1;\n padding-left: 10px;\n height: 31px;\n}\n.has-error .kts-invoice-operate-goods-list-itemName-input {\n border: 1px solid #f5222d;\n}\n";
10156
+ var css_248z$6 = ".kts-invoice-operate-goods-list-itemName-input {\n display: flex;\n flex: 1;\n padding-left: 10px;\n height: 31px;\n}\n.kts-invoice-operate-goods-list-itemName-input .ktsAntX-select {\n width: 100%;\n}\n.kts-invoice-operate-goods-list-itemName-input .ktsAntX-select .ktsAntX-select-selector {\n height: 100%;\n}\n.has-error .kts-invoice-operate-goods-list-itemName-input {\n border: 1px solid #f5222d;\n}\n";
10149
10157
  styleInject(css_248z$6);
10150
10158
 
10151
10159
  function ItemNameInput(props) {
10160
+ var controller = Invoice.useInvoiceController();
10161
+ var autoComplete = controller.useMemo(function (s) {
10162
+ return s.autoComplete;
10163
+ }, []);
10164
+
10165
+ var _React$useState = React.useState([]),
10166
+ _React$useState2 = _slicedToArray(_React$useState, 2),
10167
+ options = _React$useState2[0],
10168
+ setOptions = _React$useState2[1];
10169
+
10152
10170
  var onChange = React.useCallback(function (e) {
10153
10171
  var event = _objectSpread2({}, e);
10154
10172
 
10155
10173
  props.onChange && props.onChange(event);
10156
10174
  }, []);
10175
+ var onSearch = React.useCallback( /*#__PURE__*/function () {
10176
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchText) {
10177
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
10178
+ while (1) {
10179
+ switch (_context.prev = _context.next) {
10180
+ case 0:
10181
+ _context.prev = 0;
10182
+
10183
+ if (!autoComplete.onItemNameSearch) {
10184
+ _context.next = 7;
10185
+ break;
10186
+ }
10187
+
10188
+ _context.t0 = setOptions;
10189
+ _context.next = 5;
10190
+ return autoComplete.onItemNameSearch(searchText);
10191
+
10192
+ case 5:
10193
+ _context.t1 = _context.sent;
10194
+ (0, _context.t0)(_context.t1);
10195
+
10196
+ case 7:
10197
+ _context.next = 13;
10198
+ break;
10199
+
10200
+ case 9:
10201
+ _context.prev = 9;
10202
+ _context.t2 = _context["catch"](0);
10203
+ setOptions([]);
10204
+ throw _context.t2;
10205
+
10206
+ case 13:
10207
+ case "end":
10208
+ return _context.stop();
10209
+ }
10210
+ }
10211
+ }, _callee, null, [[0, 9]]);
10212
+ }));
10213
+
10214
+ return function (_x) {
10215
+ return _ref.apply(this, arguments);
10216
+ };
10217
+ }(), [autoComplete.onItemNameSearch]);
10218
+ var onChangeAutoComplete = React.useCallback(function (itemName) {
10219
+ var _controller$state$goo;
10220
+
10221
+ var good = options.filter(function (e) {
10222
+ return e.itemName === itemName;
10223
+ });
10224
+ (_controller$state$goo = controller.state.goodsListState.form) === null || _controller$state$goo === void 0 ? void 0 : _controller$state$goo.setFieldsValue(good);
10225
+ }, [options, controller]);
10157
10226
  return React.createElement("div", {
10158
10227
  className: 'kts-invoice-operate-goods-list-itemName-input'
10159
10228
  }, props.shorthand && React.createElement("span", {
@@ -10161,14 +10230,22 @@ function ItemNameInput(props) {
10161
10230
  alignSelf: 'center',
10162
10231
  fontSize: 12
10163
10232
  }
10164
- }, "*", props.shorthand, "*"), React.createElement(Input, {
10233
+ }, "*", props.shorthand, "*"), React.createElement(AutoComplete$1, {
10234
+ onSearch: onSearch,
10235
+ options: options.map(function (e) {
10236
+ return {
10237
+ value: e.itemName
10238
+ };
10239
+ }),
10240
+ onChange: onChangeAutoComplete
10241
+ }, React.createElement(Input, {
10165
10242
  style: {
10166
10243
  height: '100%',
10167
10244
  border: 'none'
10168
10245
  },
10169
10246
  value: props.value,
10170
10247
  onChange: onChange
10171
- }));
10248
+ })));
10172
10249
  }
10173
10250
 
10174
10251
  /** 拆分全称加简称 */
@@ -10475,7 +10552,7 @@ var useColumns = (function (form) {
10475
10552
  return React.createElement(Form.Item, null, getFieldDecorator('unit', {
10476
10553
  initialValue: editGood.unit,
10477
10554
  rules: getReplenishRules('unit')
10478
- })(React.createElement(AutoComplete, {
10555
+ })(React.createElement(AutoComplete$2, {
10479
10556
  style: {
10480
10557
  width: '100%'
10481
10558
  },
@@ -19438,7 +19515,6 @@ var ImportGoodsDrawer = (function () {
19438
19515
  return s.goodsListState.importGoods.topExpand;
19439
19516
  }, []);
19440
19517
  var onClose = React.useCallback(function () {
19441
- console.log('===> 关闭抽屉');
19442
19518
  controller.pipeline( /*#__PURE__*/function () {
19443
19519
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
19444
19520
  return _regeneratorRuntime().wrap(function _callee$(_context) {
package/dist/index.js CHANGED
@@ -1090,6 +1090,13 @@ var Stakeholder = /*#__PURE__*/_createClass(function Stakeholder() {
1090
1090
  this.rulesMap = void 0;
1091
1091
  });
1092
1092
 
1093
+ /** 自动补全 */
1094
+ var AutoComplete = /*#__PURE__*/_createClass(function AutoComplete() {
1095
+ _classCallCheck(this, AutoComplete);
1096
+
1097
+ this.onItemNameSearch = void 0;
1098
+ });
1099
+
1093
1100
  var InvoiceControllerState = /*#__PURE__*/_createClass(function InvoiceControllerState() {
1094
1101
  _classCallCheck(this, InvoiceControllerState);
1095
1102
 
@@ -1104,6 +1111,7 @@ var InvoiceControllerState = /*#__PURE__*/_createClass(function InvoiceControlle
1104
1111
  this.priceIntegerDigit = void 0;
1105
1112
  this.rootElement = null;
1106
1113
  this.typeModalProps = void 0;
1114
+ this.autoComplete = new AutoComplete();
1107
1115
  });
1108
1116
 
1109
1117
  /**
@@ -10155,15 +10163,76 @@ var TitleText = (function (props) {
10155
10163
  }, "*") : React__default['default'].createElement(React__default['default'].Fragment, null), children);
10156
10164
  });
10157
10165
 
10158
- var css_248z$6 = ".kts-invoice-operate-goods-list-itemName-input {\n display: flex;\n flex: 1;\n padding-left: 10px;\n height: 31px;\n}\n.has-error .kts-invoice-operate-goods-list-itemName-input {\n border: 1px solid #f5222d;\n}\n";
10166
+ var css_248z$6 = ".kts-invoice-operate-goods-list-itemName-input {\n display: flex;\n flex: 1;\n padding-left: 10px;\n height: 31px;\n}\n.kts-invoice-operate-goods-list-itemName-input .ktsAntX-select {\n width: 100%;\n}\n.kts-invoice-operate-goods-list-itemName-input .ktsAntX-select .ktsAntX-select-selector {\n height: 100%;\n}\n.has-error .kts-invoice-operate-goods-list-itemName-input {\n border: 1px solid #f5222d;\n}\n";
10159
10167
  styleInject(css_248z$6);
10160
10168
 
10161
10169
  function ItemNameInput(props) {
10170
+ var controller = Invoice.useInvoiceController();
10171
+ var autoComplete = controller.useMemo(function (s) {
10172
+ return s.autoComplete;
10173
+ }, []);
10174
+
10175
+ var _React$useState = React__default['default'].useState([]),
10176
+ _React$useState2 = _slicedToArray(_React$useState, 2),
10177
+ options = _React$useState2[0],
10178
+ setOptions = _React$useState2[1];
10179
+
10162
10180
  var onChange = React__default['default'].useCallback(function (e) {
10163
10181
  var event = _objectSpread2({}, e);
10164
10182
 
10165
10183
  props.onChange && props.onChange(event);
10166
10184
  }, []);
10185
+ var onSearch = React__default['default'].useCallback( /*#__PURE__*/function () {
10186
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchText) {
10187
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
10188
+ while (1) {
10189
+ switch (_context.prev = _context.next) {
10190
+ case 0:
10191
+ _context.prev = 0;
10192
+
10193
+ if (!autoComplete.onItemNameSearch) {
10194
+ _context.next = 7;
10195
+ break;
10196
+ }
10197
+
10198
+ _context.t0 = setOptions;
10199
+ _context.next = 5;
10200
+ return autoComplete.onItemNameSearch(searchText);
10201
+
10202
+ case 5:
10203
+ _context.t1 = _context.sent;
10204
+ (0, _context.t0)(_context.t1);
10205
+
10206
+ case 7:
10207
+ _context.next = 13;
10208
+ break;
10209
+
10210
+ case 9:
10211
+ _context.prev = 9;
10212
+ _context.t2 = _context["catch"](0);
10213
+ setOptions([]);
10214
+ throw _context.t2;
10215
+
10216
+ case 13:
10217
+ case "end":
10218
+ return _context.stop();
10219
+ }
10220
+ }
10221
+ }, _callee, null, [[0, 9]]);
10222
+ }));
10223
+
10224
+ return function (_x) {
10225
+ return _ref.apply(this, arguments);
10226
+ };
10227
+ }(), [autoComplete.onItemNameSearch]);
10228
+ var onChangeAutoComplete = React__default['default'].useCallback(function (itemName) {
10229
+ var _controller$state$goo;
10230
+
10231
+ var good = options.filter(function (e) {
10232
+ return e.itemName === itemName;
10233
+ });
10234
+ (_controller$state$goo = controller.state.goodsListState.form) === null || _controller$state$goo === void 0 ? void 0 : _controller$state$goo.setFieldsValue(good);
10235
+ }, [options, controller]);
10167
10236
  return React__default['default'].createElement("div", {
10168
10237
  className: 'kts-invoice-operate-goods-list-itemName-input'
10169
10238
  }, props.shorthand && React__default['default'].createElement("span", {
@@ -10171,14 +10240,22 @@ function ItemNameInput(props) {
10171
10240
  alignSelf: 'center',
10172
10241
  fontSize: 12
10173
10242
  }
10174
- }, "*", props.shorthand, "*"), React__default['default'].createElement(ktsComponentsAntdX3.Input, {
10243
+ }, "*", props.shorthand, "*"), React__default['default'].createElement(ktsXui.AutoComplete, {
10244
+ onSearch: onSearch,
10245
+ options: options.map(function (e) {
10246
+ return {
10247
+ value: e.itemName
10248
+ };
10249
+ }),
10250
+ onChange: onChangeAutoComplete
10251
+ }, React__default['default'].createElement(ktsComponentsAntdX3.Input, {
10175
10252
  style: {
10176
10253
  height: '100%',
10177
10254
  border: 'none'
10178
10255
  },
10179
10256
  value: props.value,
10180
10257
  onChange: onChange
10181
- }));
10258
+ })));
10182
10259
  }
10183
10260
 
10184
10261
  /** 拆分全称加简称 */
@@ -19448,7 +19525,6 @@ var ImportGoodsDrawer = (function () {
19448
19525
  return s.goodsListState.importGoods.topExpand;
19449
19526
  }, []);
19450
19527
  var onClose = React__default['default'].useCallback(function () {
19451
- console.log('===> 关闭抽屉');
19452
19528
  controller.pipeline( /*#__PURE__*/function () {
19453
19529
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
19454
19530
  return _regeneratorRuntime().wrap(function _callee$(_context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.18",
3
+ "version": "3.2.19",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -0,0 +1,8 @@
1
+ import IGood from "../GoodsListState/IGood";
2
+
3
+ /** 自动补全 */
4
+ export default class AutoComplete {
5
+
6
+ /** 商品名称自动补全 */
7
+ onItemNameSearch?: (searchText: string) => Promise<IGood[]>
8
+ }
@@ -2,6 +2,7 @@ import GoodsListState from './GoodsListState';
2
2
  import BuyerState from './BuyerState';
3
3
  import Stakeholder from './Stakeholder';
4
4
  import { IInvoiceTypeModalProps } from '../../../InvoiceTypeModal';
5
+ import AutoComplete from './AutoComplete';
5
6
 
6
7
  export default class InvoiceControllerState {
7
8
 
@@ -53,4 +54,7 @@ export default class InvoiceControllerState {
53
54
 
54
55
  /** 发票类型选择窗口 */
55
56
  typeModalProps?: IInvoiceTypeModalProps;
57
+
58
+ /** 自动补全 */
59
+ autoComplete = new AutoComplete();
56
60
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Invoice } from '../../../..';
2
+ import Invoice from '../..';
3
3
 
4
4
  const InvoiceController = Invoice.InvoiceController;
5
5
 
@@ -16,6 +16,18 @@ export default () => {
16
16
  * 继承 InvoiceController 并重写需要重写的方法
17
17
  */
18
18
  class MyInvoiceController extends InvoiceController {
19
+
20
+ constructor() {
21
+ super();
22
+ this.state.autoComplete.onItemNameSearch = async text => {
23
+ const sum: { value: string }[] = []
24
+ for (let index = 0; index < 10; index++) {
25
+ sum.push({ value: `xxxx${index}` })
26
+ }
27
+ return sum;
28
+ }
29
+ }
30
+
19
31
  updateInvoiceNo = this.pipeline(async s => {
20
32
  return '--';
21
33
  })
@@ -3,8 +3,16 @@
3
3
  flex : 1;
4
4
  padding-left: 10px;
5
5
  height : 31px;
6
+
7
+ .ktsAntX-select {
8
+ width: 100%;
9
+
10
+ .ktsAntX-select-selector{
11
+ height: 100%;
12
+ }
13
+ }
6
14
  }
7
15
 
8
- .has-error .kts-invoice-operate-goods-list-itemName-input{
16
+ .has-error .kts-invoice-operate-goods-list-itemName-input {
9
17
  border: 1px solid #f5222d;
10
18
  }
@@ -1,19 +1,45 @@
1
1
 
2
2
  import { Input } from 'kts-components-antd-x3';
3
3
  import React, { ChangeEvent } from 'react';
4
+ import { AutoComplete } from 'kts-xui';
5
+ import { IGood, Invoice } from '../../../../../../../..';
4
6
  import './index.less';
5
7
 
6
8
  export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLInputElement>) => void, value?: string, shorthand?: string }) {
7
9
 
10
+ const controller = Invoice.useInvoiceController();
11
+
12
+ const autoComplete = controller.useMemo(s => s.autoComplete, [])
13
+
14
+ const [options, setOptions] = React.useState<IGood[]>([])
15
+
8
16
  const onChange = React.useCallback((e: ChangeEvent<HTMLInputElement>) => {
9
17
  const event = { ...e };
10
18
  props.onChange && props.onChange(event);
11
19
  }, [])
12
20
 
21
+ const onSearch = React.useCallback(async (searchText: string) => {
22
+ try {
23
+ if (autoComplete.onItemNameSearch) {
24
+ setOptions(await autoComplete.onItemNameSearch(searchText))
25
+ }
26
+ } catch (error) {
27
+ setOptions([])
28
+ throw error;
29
+ }
30
+ }, [autoComplete.onItemNameSearch])
31
+
32
+ const onChangeAutoComplete = React.useCallback(itemName => {
33
+ const good = options.filter(e=>e.itemName === itemName);
34
+ controller.state.goodsListState.form?.setFieldsValue(good);
35
+ }, [options, controller])
36
+
13
37
  return (
14
38
  <div className='kts-invoice-operate-goods-list-itemName-input'>
15
39
  {props.shorthand && <span style={{ alignSelf: 'center', fontSize: 12 }} >*{props.shorthand}*</span>}
16
- <Input style={{ height: '100%', border: 'none' }} value={props.value} onChange={onChange} />
40
+ <AutoComplete onSearch={onSearch} options={options.map(e => ({ value: e.itemName }))} onChange={onChangeAutoComplete} >
41
+ <Input style={{ height: '100%', border: 'none' }} value={props.value} onChange={onChange} />
42
+ </AutoComplete>
17
43
  </div>
18
44
  )
19
45
  }
@@ -14,7 +14,6 @@ export default () => {
14
14
  const topExpand = controller.useMemo(s => s.goodsListState.importGoods.topExpand, []);
15
15
 
16
16
  const onClose = React.useCallback(() => {
17
- console.log('===> 关闭抽屉');
18
17
  controller.pipeline(async s => { s.goodsListState.importGoods.isVisibleDrawer = false })();
19
18
  }, [controller]);
20
19