kts-component-invoice-operate 1.0.98 → 1.0.99
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/Invoice/tools/coolingFn/index.d.ts +8 -0
- package/dist/Invoice/tools/strringFn/index.d.ts +7 -0
- package/dist/index.esm.js +120 -14
- package/dist/index.js +119 -13
- package/package.json +1 -1
- package/src/Invoice/tools/coolingFn/index.ts +18 -0
- package/src/Invoice/tools/strringFn/index.ts +41 -0
- package/src/Invoice/ui/EndowCodeDrawer/index.tsx +35 -13
- package/src/Invoice/ui/GoodsList/ui/EndowCodeButton/index.tsx +3 -8
- package/src/Invoice/ui/ImportBuyerDrawer/index.tsx +1 -1
- package/src/Invoice/ui/ImportGoodsDrawer/index.tsx +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -2,11 +2,11 @@ import 'kts-components-antd-x3/dist/kts-components-antd-x3.css';
|
|
|
2
2
|
import React, { createElement } 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, Tag, Select, Row, Col, Table, Button, Switch, Typography, Drawer, Menu, Dropdown, AutoComplete, Spin, Checkbox, Descriptions } from 'kts-components-antd-x3';
|
|
5
|
+
import { message, Form, Input, Icon, Tag, Select, Row, Col, Table, Button, Switch, Typography, Drawer, Menu, Dropdown, AutoComplete, Spin, Checkbox, Descriptions, Modal } from 'kts-components-antd-x3';
|
|
6
6
|
import { v4 } from 'uuid';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
-
import { createAsyncFormActions, FormEffectHooks, SchemaForm, FormButtonGroup, SchemaMarkupField } from '@formily/antd';
|
|
9
8
|
import { Input as Input$1, NumberPicker } from '@formily/antd-components';
|
|
9
|
+
import { createAsyncFormActions, FormEffectHooks, SchemaForm, FormButtonGroup, SchemaMarkupField } from '@formily/antd';
|
|
10
10
|
|
|
11
11
|
function ownKeys(object, enumerableOnly) {
|
|
12
12
|
var keys = Object.keys(object);
|
|
@@ -2091,6 +2091,29 @@ var DrawerBody = decorator(Form.create())(function (props) {
|
|
|
2091
2091
|
}, "\u4FDD\u5B58")));
|
|
2092
2092
|
});
|
|
2093
2093
|
|
|
2094
|
+
var keys = {};
|
|
2095
|
+
/**
|
|
2096
|
+
* 有冷却时间的函数
|
|
2097
|
+
* @param fn 方法
|
|
2098
|
+
* @param key 方法key
|
|
2099
|
+
* @param delayed 冷却时间
|
|
2100
|
+
*/
|
|
2101
|
+
|
|
2102
|
+
var coolingFn = (function () {
|
|
2103
|
+
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
|
2104
|
+
var delayed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
|
|
2105
|
+
var fn = arguments.length > 2 ? arguments[2] : undefined;
|
|
2106
|
+
|
|
2107
|
+
if (keys[key]) {
|
|
2108
|
+
return;
|
|
2109
|
+
} else {
|
|
2110
|
+
fn();
|
|
2111
|
+
keys[key] = setTimeout(function () {
|
|
2112
|
+
delete keys[key];
|
|
2113
|
+
}, delayed);
|
|
2114
|
+
}
|
|
2115
|
+
});
|
|
2116
|
+
|
|
2094
2117
|
var EndowCodeButton = (function () {
|
|
2095
2118
|
var controller = default_1.useInvoiceController();
|
|
2096
2119
|
/** 是否禁用 */
|
|
@@ -2123,9 +2146,8 @@ var EndowCodeButton = (function () {
|
|
|
2123
2146
|
break;
|
|
2124
2147
|
}
|
|
2125
2148
|
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
key: '不能给正在编辑的货物赋码'
|
|
2149
|
+
coolingFn('不能给正在编辑的货物赋码', 3000, function () {
|
|
2150
|
+
message.error('不能给正在编辑的货物赋码');
|
|
2129
2151
|
});
|
|
2130
2152
|
return _context.abrupt("return");
|
|
2131
2153
|
|
|
@@ -2141,9 +2163,8 @@ var EndowCodeButton = (function () {
|
|
|
2141
2163
|
break;
|
|
2142
2164
|
}
|
|
2143
2165
|
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
key: '商品税率不一致不能操作批量赋码'
|
|
2166
|
+
coolingFn('商品税率不一致不能操作批量赋码', 3000, function () {
|
|
2167
|
+
message.error('商品税率不一致不能操作批量赋码');
|
|
2147
2168
|
});
|
|
2148
2169
|
return _context.abrupt("return");
|
|
2149
2170
|
|
|
@@ -4932,7 +4953,7 @@ var ImportBuyerDrawer = (function () {
|
|
|
4932
4953
|
return /*#__PURE__*/React.createElement(Drawer, {
|
|
4933
4954
|
title: "\u8D2D\u65B9\u5217\u8868",
|
|
4934
4955
|
placement: "right",
|
|
4935
|
-
closable
|
|
4956
|
+
// closable={false}
|
|
4936
4957
|
destroyOnClose: true,
|
|
4937
4958
|
width: 983,
|
|
4938
4959
|
onClose: onClose,
|
|
@@ -5064,7 +5085,6 @@ var ImportGoodsDrawer = (function () {
|
|
|
5064
5085
|
placement: "right",
|
|
5065
5086
|
// closable={false}
|
|
5066
5087
|
destroyOnClose: true,
|
|
5067
|
-
maskClosable: true,
|
|
5068
5088
|
width: 983,
|
|
5069
5089
|
onClose: onClose,
|
|
5070
5090
|
visible: visible
|
|
@@ -5203,9 +5223,61 @@ var getPriceExcludeTax = function getPriceExcludeTax(s, record) {
|
|
|
5203
5223
|
return format15(evaluate("".concat(record.priceIncludeTax, " / (1+").concat(s.taxRate, "/100)")));
|
|
5204
5224
|
};
|
|
5205
5225
|
|
|
5226
|
+
/**
|
|
5227
|
+
* 判断一个字符串得字节长度
|
|
5228
|
+
* @param str
|
|
5229
|
+
* @returns
|
|
5230
|
+
*/
|
|
5231
|
+
function bytesLnegth(str) {
|
|
5232
|
+
var count = str.length;
|
|
5233
|
+
|
|
5234
|
+
for (var i = 0; i < str.length; i++) {
|
|
5235
|
+
if (str.charCodeAt(i) > 255) {
|
|
5236
|
+
count++;
|
|
5237
|
+
}
|
|
5238
|
+
}
|
|
5239
|
+
|
|
5240
|
+
return count;
|
|
5241
|
+
}
|
|
5242
|
+
/*
|
|
5243
|
+
* param str 要截取的字符串
|
|
5244
|
+
* param L 要截取的字节长度,注意是字节不是字符,一个汉字两个字节
|
|
5245
|
+
* return 截取后的字符串
|
|
5246
|
+
*/
|
|
5247
|
+
|
|
5248
|
+
function cutStr(str, L) {
|
|
5249
|
+
var result = '',
|
|
5250
|
+
strlen = str.length,
|
|
5251
|
+
// 字符串长度
|
|
5252
|
+
chrlen = str.replace(/[^\x00-\xff]/g, '**').length; // 字节长度
|
|
5253
|
+
|
|
5254
|
+
if (chrlen <= L) {
|
|
5255
|
+
return str;
|
|
5256
|
+
}
|
|
5257
|
+
|
|
5258
|
+
for (var i = 0, j = 0; i < strlen; i++) {
|
|
5259
|
+
var chr = str.charAt(i);
|
|
5260
|
+
|
|
5261
|
+
if (/[\x00-\xff]/.test(chr)) {
|
|
5262
|
+
j++; // ascii码为0-255,一个字符就是一个字节的长度
|
|
5263
|
+
} else {
|
|
5264
|
+
j += 2; // ascii码为0-255以外,一个字符就是两个字节的长度
|
|
5265
|
+
}
|
|
5266
|
+
|
|
5267
|
+
if (j <= L) {
|
|
5268
|
+
// 当加上当前字符以后,如果总字节长度小于等于L,则将当前字符真实的+在result后
|
|
5269
|
+
result += chr;
|
|
5270
|
+
} else {
|
|
5271
|
+
// 反之则说明result已经是不拆分字符的情况下最接近L的值了,直接返回
|
|
5272
|
+
return result;
|
|
5273
|
+
}
|
|
5274
|
+
}
|
|
5275
|
+
}
|
|
5276
|
+
|
|
5206
5277
|
var css_248z$a = ".kts-invoice-operate-goods-endow-code-button-list {\n display: flex;\n flex-direction: column;\n}\n.kts-invoice-operate-goods-endow-code-button-list > button {\n margin-bottom: 10px;\n}\n";
|
|
5207
5278
|
styleInject(css_248z$a);
|
|
5208
5279
|
|
|
5280
|
+
var confirm = Modal.confirm;
|
|
5209
5281
|
var EndowCodeDrawer = (function () {
|
|
5210
5282
|
var controller = default_1.useInvoiceController();
|
|
5211
5283
|
var visible = controller.useMemo(function (s) {
|
|
@@ -5475,12 +5547,16 @@ var DrawerBody$3 = function DrawerBody(props) {
|
|
|
5475
5547
|
var onSubmit = React.useCallback(function (values) {
|
|
5476
5548
|
controller.pipeline( /*#__PURE__*/function () {
|
|
5477
5549
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(s) {
|
|
5550
|
+
var endowCodeGood;
|
|
5478
5551
|
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
5479
5552
|
while (1) {
|
|
5480
5553
|
switch (_context6.prev = _context6.next) {
|
|
5481
5554
|
case 0:
|
|
5482
|
-
s.goodsListState.endowCode.endowcodeGoodIndex.
|
|
5483
|
-
|
|
5555
|
+
endowCodeGood = s.goodsListState.endowCode.endowcodeGoodIndex.map(function (e) {
|
|
5556
|
+
return s.goodsListState.goodsMap.get(e);
|
|
5557
|
+
}); // 赋码
|
|
5558
|
+
|
|
5559
|
+
endowCodeGood.forEach(function (good) {
|
|
5484
5560
|
if (!good) return; // const name = getItemName(good.itemName, values.shorthand);
|
|
5485
5561
|
|
|
5486
5562
|
good.itemName = getItemName$1(good.itemName, values.shorthand); // `*${values.shorthand}*${name}`;
|
|
@@ -5505,11 +5581,41 @@ var DrawerBody$3 = function DrawerBody(props) {
|
|
|
5505
5581
|
}
|
|
5506
5582
|
|
|
5507
5583
|
good.taxAmount = chain$1(bignumber(good.lineAmountIncludeTax)).subtract(bignumber(good.lineAmountExcludeTax)).done().toNumber();
|
|
5508
|
-
});
|
|
5584
|
+
}); //截取名称
|
|
5585
|
+
|
|
5586
|
+
if (!endowCodeGood.some(function (e) {
|
|
5587
|
+
return bytesLnegth((e === null || e === void 0 ? void 0 : e.itemName) || '') > 100;
|
|
5588
|
+
})) {
|
|
5589
|
+
_context6.next = 5;
|
|
5590
|
+
break;
|
|
5591
|
+
}
|
|
5592
|
+
|
|
5593
|
+
_context6.next = 5;
|
|
5594
|
+
return function () {
|
|
5595
|
+
return new Promise(function (resolve) {
|
|
5596
|
+
confirm({
|
|
5597
|
+
title: '温馨提示',
|
|
5598
|
+
content: '商品名称长度过长,是否截取名称',
|
|
5599
|
+
onOk: function onOk() {
|
|
5600
|
+
endowCodeGood.forEach(function (e) {
|
|
5601
|
+
if (e && e.itemName) {
|
|
5602
|
+
e.itemName = cutStr(e.itemName, 99);
|
|
5603
|
+
}
|
|
5604
|
+
});
|
|
5605
|
+
resolve();
|
|
5606
|
+
},
|
|
5607
|
+
onCancel: function onCancel() {
|
|
5608
|
+
resolve();
|
|
5609
|
+
}
|
|
5610
|
+
});
|
|
5611
|
+
});
|
|
5612
|
+
}();
|
|
5613
|
+
|
|
5614
|
+
case 5:
|
|
5509
5615
|
s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
|
|
5510
5616
|
s.goodsListState.endowCode.endowcodeGoodIndex = [];
|
|
5511
5617
|
|
|
5512
|
-
case
|
|
5618
|
+
case 7:
|
|
5513
5619
|
case "end":
|
|
5514
5620
|
return _context6.stop();
|
|
5515
5621
|
}
|
package/dist/index.js
CHANGED
|
@@ -9,8 +9,8 @@ var mathjs = require('mathjs');
|
|
|
9
9
|
var ktsComponentsAntdX3 = require('kts-components-antd-x3');
|
|
10
10
|
var uuid = require('uuid');
|
|
11
11
|
var classnames = require('classnames');
|
|
12
|
-
var antd = require('@formily/antd');
|
|
13
12
|
var antdComponents = require('@formily/antd-components');
|
|
13
|
+
var antd = require('@formily/antd');
|
|
14
14
|
|
|
15
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
16
|
|
|
@@ -2101,6 +2101,29 @@ var DrawerBody = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(funct
|
|
|
2101
2101
|
}, "\u4FDD\u5B58")));
|
|
2102
2102
|
});
|
|
2103
2103
|
|
|
2104
|
+
var keys = {};
|
|
2105
|
+
/**
|
|
2106
|
+
* 有冷却时间的函数
|
|
2107
|
+
* @param fn 方法
|
|
2108
|
+
* @param key 方法key
|
|
2109
|
+
* @param delayed 冷却时间
|
|
2110
|
+
*/
|
|
2111
|
+
|
|
2112
|
+
var coolingFn = (function () {
|
|
2113
|
+
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
|
2114
|
+
var delayed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
|
|
2115
|
+
var fn = arguments.length > 2 ? arguments[2] : undefined;
|
|
2116
|
+
|
|
2117
|
+
if (keys[key]) {
|
|
2118
|
+
return;
|
|
2119
|
+
} else {
|
|
2120
|
+
fn();
|
|
2121
|
+
keys[key] = setTimeout(function () {
|
|
2122
|
+
delete keys[key];
|
|
2123
|
+
}, delayed);
|
|
2124
|
+
}
|
|
2125
|
+
});
|
|
2126
|
+
|
|
2104
2127
|
var EndowCodeButton = (function () {
|
|
2105
2128
|
var controller = default_1.useInvoiceController();
|
|
2106
2129
|
/** 是否禁用 */
|
|
@@ -2133,9 +2156,8 @@ var EndowCodeButton = (function () {
|
|
|
2133
2156
|
break;
|
|
2134
2157
|
}
|
|
2135
2158
|
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
key: '不能给正在编辑的货物赋码'
|
|
2159
|
+
coolingFn('不能给正在编辑的货物赋码', 3000, function () {
|
|
2160
|
+
ktsComponentsAntdX3.message.error('不能给正在编辑的货物赋码');
|
|
2139
2161
|
});
|
|
2140
2162
|
return _context.abrupt("return");
|
|
2141
2163
|
|
|
@@ -2151,9 +2173,8 @@ var EndowCodeButton = (function () {
|
|
|
2151
2173
|
break;
|
|
2152
2174
|
}
|
|
2153
2175
|
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
key: '商品税率不一致不能操作批量赋码'
|
|
2176
|
+
coolingFn('商品税率不一致不能操作批量赋码', 3000, function () {
|
|
2177
|
+
ktsComponentsAntdX3.message.error('商品税率不一致不能操作批量赋码');
|
|
2157
2178
|
});
|
|
2158
2179
|
return _context.abrupt("return");
|
|
2159
2180
|
|
|
@@ -4942,7 +4963,7 @@ var ImportBuyerDrawer = (function () {
|
|
|
4942
4963
|
return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Drawer, {
|
|
4943
4964
|
title: "\u8D2D\u65B9\u5217\u8868",
|
|
4944
4965
|
placement: "right",
|
|
4945
|
-
closable
|
|
4966
|
+
// closable={false}
|
|
4946
4967
|
destroyOnClose: true,
|
|
4947
4968
|
width: 983,
|
|
4948
4969
|
onClose: onClose,
|
|
@@ -5074,7 +5095,6 @@ var ImportGoodsDrawer = (function () {
|
|
|
5074
5095
|
placement: "right",
|
|
5075
5096
|
// closable={false}
|
|
5076
5097
|
destroyOnClose: true,
|
|
5077
|
-
maskClosable: true,
|
|
5078
5098
|
width: 983,
|
|
5079
5099
|
onClose: onClose,
|
|
5080
5100
|
visible: visible
|
|
@@ -5213,9 +5233,61 @@ var getPriceExcludeTax = function getPriceExcludeTax(s, record) {
|
|
|
5213
5233
|
return format15(evaluate("".concat(record.priceIncludeTax, " / (1+").concat(s.taxRate, "/100)")));
|
|
5214
5234
|
};
|
|
5215
5235
|
|
|
5236
|
+
/**
|
|
5237
|
+
* 判断一个字符串得字节长度
|
|
5238
|
+
* @param str
|
|
5239
|
+
* @returns
|
|
5240
|
+
*/
|
|
5241
|
+
function bytesLnegth(str) {
|
|
5242
|
+
var count = str.length;
|
|
5243
|
+
|
|
5244
|
+
for (var i = 0; i < str.length; i++) {
|
|
5245
|
+
if (str.charCodeAt(i) > 255) {
|
|
5246
|
+
count++;
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
|
|
5250
|
+
return count;
|
|
5251
|
+
}
|
|
5252
|
+
/*
|
|
5253
|
+
* param str 要截取的字符串
|
|
5254
|
+
* param L 要截取的字节长度,注意是字节不是字符,一个汉字两个字节
|
|
5255
|
+
* return 截取后的字符串
|
|
5256
|
+
*/
|
|
5257
|
+
|
|
5258
|
+
function cutStr(str, L) {
|
|
5259
|
+
var result = '',
|
|
5260
|
+
strlen = str.length,
|
|
5261
|
+
// 字符串长度
|
|
5262
|
+
chrlen = str.replace(/[^\x00-\xff]/g, '**').length; // 字节长度
|
|
5263
|
+
|
|
5264
|
+
if (chrlen <= L) {
|
|
5265
|
+
return str;
|
|
5266
|
+
}
|
|
5267
|
+
|
|
5268
|
+
for (var i = 0, j = 0; i < strlen; i++) {
|
|
5269
|
+
var chr = str.charAt(i);
|
|
5270
|
+
|
|
5271
|
+
if (/[\x00-\xff]/.test(chr)) {
|
|
5272
|
+
j++; // ascii码为0-255,一个字符就是一个字节的长度
|
|
5273
|
+
} else {
|
|
5274
|
+
j += 2; // ascii码为0-255以外,一个字符就是两个字节的长度
|
|
5275
|
+
}
|
|
5276
|
+
|
|
5277
|
+
if (j <= L) {
|
|
5278
|
+
// 当加上当前字符以后,如果总字节长度小于等于L,则将当前字符真实的+在result后
|
|
5279
|
+
result += chr;
|
|
5280
|
+
} else {
|
|
5281
|
+
// 反之则说明result已经是不拆分字符的情况下最接近L的值了,直接返回
|
|
5282
|
+
return result;
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
|
|
5216
5287
|
var css_248z$a = ".kts-invoice-operate-goods-endow-code-button-list {\n display: flex;\n flex-direction: column;\n}\n.kts-invoice-operate-goods-endow-code-button-list > button {\n margin-bottom: 10px;\n}\n";
|
|
5217
5288
|
styleInject(css_248z$a);
|
|
5218
5289
|
|
|
5290
|
+
var confirm = ktsComponentsAntdX3.Modal.confirm;
|
|
5219
5291
|
var EndowCodeDrawer = (function () {
|
|
5220
5292
|
var controller = default_1.useInvoiceController();
|
|
5221
5293
|
var visible = controller.useMemo(function (s) {
|
|
@@ -5485,12 +5557,16 @@ var DrawerBody$3 = function DrawerBody(props) {
|
|
|
5485
5557
|
var onSubmit = React__default['default'].useCallback(function (values) {
|
|
5486
5558
|
controller.pipeline( /*#__PURE__*/function () {
|
|
5487
5559
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(s) {
|
|
5560
|
+
var endowCodeGood;
|
|
5488
5561
|
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
5489
5562
|
while (1) {
|
|
5490
5563
|
switch (_context6.prev = _context6.next) {
|
|
5491
5564
|
case 0:
|
|
5492
|
-
s.goodsListState.endowCode.endowcodeGoodIndex.
|
|
5493
|
-
|
|
5565
|
+
endowCodeGood = s.goodsListState.endowCode.endowcodeGoodIndex.map(function (e) {
|
|
5566
|
+
return s.goodsListState.goodsMap.get(e);
|
|
5567
|
+
}); // 赋码
|
|
5568
|
+
|
|
5569
|
+
endowCodeGood.forEach(function (good) {
|
|
5494
5570
|
if (!good) return; // const name = getItemName(good.itemName, values.shorthand);
|
|
5495
5571
|
|
|
5496
5572
|
good.itemName = getItemName$1(good.itemName, values.shorthand); // `*${values.shorthand}*${name}`;
|
|
@@ -5515,11 +5591,41 @@ var DrawerBody$3 = function DrawerBody(props) {
|
|
|
5515
5591
|
}
|
|
5516
5592
|
|
|
5517
5593
|
good.taxAmount = mathjs.chain(mathjs.bignumber(good.lineAmountIncludeTax)).subtract(mathjs.bignumber(good.lineAmountExcludeTax)).done().toNumber();
|
|
5518
|
-
});
|
|
5594
|
+
}); //截取名称
|
|
5595
|
+
|
|
5596
|
+
if (!endowCodeGood.some(function (e) {
|
|
5597
|
+
return bytesLnegth((e === null || e === void 0 ? void 0 : e.itemName) || '') > 100;
|
|
5598
|
+
})) {
|
|
5599
|
+
_context6.next = 5;
|
|
5600
|
+
break;
|
|
5601
|
+
}
|
|
5602
|
+
|
|
5603
|
+
_context6.next = 5;
|
|
5604
|
+
return function () {
|
|
5605
|
+
return new Promise(function (resolve) {
|
|
5606
|
+
confirm({
|
|
5607
|
+
title: '温馨提示',
|
|
5608
|
+
content: '商品名称长度过长,是否截取名称',
|
|
5609
|
+
onOk: function onOk() {
|
|
5610
|
+
endowCodeGood.forEach(function (e) {
|
|
5611
|
+
if (e && e.itemName) {
|
|
5612
|
+
e.itemName = cutStr(e.itemName, 99);
|
|
5613
|
+
}
|
|
5614
|
+
});
|
|
5615
|
+
resolve();
|
|
5616
|
+
},
|
|
5617
|
+
onCancel: function onCancel() {
|
|
5618
|
+
resolve();
|
|
5619
|
+
}
|
|
5620
|
+
});
|
|
5621
|
+
});
|
|
5622
|
+
}();
|
|
5623
|
+
|
|
5624
|
+
case 5:
|
|
5519
5625
|
s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
|
|
5520
5626
|
s.goodsListState.endowCode.endowcodeGoodIndex = [];
|
|
5521
5627
|
|
|
5522
|
-
case
|
|
5628
|
+
case 7:
|
|
5523
5629
|
case "end":
|
|
5524
5630
|
return _context6.stop();
|
|
5525
5631
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
const keys: { [key: string]: any } = {}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 有冷却时间的函数
|
|
7
|
+
* @param fn 方法
|
|
8
|
+
* @param key 方法key
|
|
9
|
+
* @param delayed 冷却时间
|
|
10
|
+
*/
|
|
11
|
+
export default (key: string = 'default', delayed: number = 200, fn: Function) => {
|
|
12
|
+
if (keys[key]) {
|
|
13
|
+
return;
|
|
14
|
+
} else {
|
|
15
|
+
fn();
|
|
16
|
+
keys[key] = setTimeout(() => { delete keys[key] }, delayed);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断一个字符串得字节长度
|
|
3
|
+
* @param str
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
export function bytesLnegth(str: string) {
|
|
7
|
+
var count = str.length;
|
|
8
|
+
for (var i = 0; i < str.length; i++) {
|
|
9
|
+
if (str.charCodeAt(i) > 255) {
|
|
10
|
+
count++;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return count;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* param str 要截取的字符串
|
|
18
|
+
* param L 要截取的字节长度,注意是字节不是字符,一个汉字两个字节
|
|
19
|
+
* return 截取后的字符串
|
|
20
|
+
*/
|
|
21
|
+
export function cutStr(str: string, L: number) {
|
|
22
|
+
var result = '',
|
|
23
|
+
strlen = str.length, // 字符串长度
|
|
24
|
+
chrlen = str.replace(/[^\x00-\xff]/g, '**').length; // 字节长度
|
|
25
|
+
|
|
26
|
+
if (chrlen <= L) { return str; }
|
|
27
|
+
|
|
28
|
+
for (var i = 0, j = 0; i < strlen; i++) {
|
|
29
|
+
var chr = str.charAt(i);
|
|
30
|
+
if (/[\x00-\xff]/.test(chr)) {
|
|
31
|
+
j++; // ascii码为0-255,一个字符就是一个字节的长度
|
|
32
|
+
} else {
|
|
33
|
+
j += 2; // ascii码为0-255以外,一个字符就是两个字节的长度
|
|
34
|
+
}
|
|
35
|
+
if (j <= L) { // 当加上当前字符以后,如果总字节长度小于等于L,则将当前字符真实的+在result后
|
|
36
|
+
result += chr;
|
|
37
|
+
} else { // 反之则说明result已经是不拆分字符的情况下最接近L的值了,直接返回
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import Invoice from '../../';
|
|
3
|
+
import { Button, Drawer, Select, Modal } from 'kts-components-antd-x3';
|
|
3
4
|
import { chain, bignumber } from 'mathjs';
|
|
5
|
+
import { Input, NumberPicker } from '@formily/antd-components';
|
|
6
|
+
import { format15 } from '../GoodsList/hook/useColumns/autoFillFn';
|
|
7
|
+
import { LineAttributeType } from '../../InvoiceController';
|
|
8
|
+
import IGood from '../../InvoiceController/InvoiceControllerState/GoodsListState/IGood';
|
|
9
|
+
import { bytesLnegth, cutStr } from '../../tools/strringFn';
|
|
4
10
|
import {
|
|
5
11
|
SchemaForm,
|
|
6
12
|
FormButtonGroup,
|
|
@@ -8,13 +14,10 @@ import {
|
|
|
8
14
|
SchemaMarkupField as Field,
|
|
9
15
|
FormEffectHooks,
|
|
10
16
|
} from '@formily/antd';
|
|
11
|
-
import { Input, NumberPicker } from '@formily/antd-components';
|
|
12
|
-
import { format15 } from '../GoodsList/hook/useColumns/autoFillFn';
|
|
13
|
-
import Invoice from '../../';
|
|
14
|
-
import { LineAttributeType } from '../../InvoiceController';
|
|
15
|
-
import IGood from '../../InvoiceController/InvoiceControllerState/GoodsListState/IGood';
|
|
16
17
|
import './index.less';
|
|
17
18
|
|
|
19
|
+
const { confirm } = Modal;
|
|
20
|
+
|
|
18
21
|
export default () => {
|
|
19
22
|
const controller = Invoice.useInvoiceController();
|
|
20
23
|
|
|
@@ -153,10 +156,12 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
|
|
|
153
156
|
|
|
154
157
|
// 确定
|
|
155
158
|
const onSubmit = React.useCallback(values => {
|
|
156
|
-
controller.pipeline(async
|
|
157
|
-
s.goodsListState.endowCode.endowcodeGoodIndex.forEach(e => {
|
|
159
|
+
controller.pipeline(async s => {
|
|
158
160
|
|
|
159
|
-
|
|
161
|
+
const endowCodeGood = s.goodsListState.endowCode.endowcodeGoodIndex.map(e => s.goodsListState.goodsMap.get(e));
|
|
162
|
+
|
|
163
|
+
// 赋码
|
|
164
|
+
endowCodeGood.forEach(good => {
|
|
160
165
|
if (!good) return;
|
|
161
166
|
|
|
162
167
|
// const name = getItemName(good.itemName, values.shorthand);
|
|
@@ -186,12 +191,29 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
|
|
|
186
191
|
good.taxAmount = chain(bignumber(good.lineAmountIncludeTax)).subtract(bignumber(good.lineAmountExcludeTax)).done().toNumber();
|
|
187
192
|
});
|
|
188
193
|
|
|
194
|
+
//截取名称
|
|
195
|
+
if (endowCodeGood.some(e => bytesLnegth(e?.itemName || '') > 100)) {
|
|
196
|
+
await (() => new Promise<void>(resolve => {
|
|
197
|
+
confirm({
|
|
198
|
+
title: '温馨提示',
|
|
199
|
+
content: '商品名称长度过长,是否截取名称',
|
|
200
|
+
onOk() {
|
|
201
|
+
endowCodeGood.forEach(e => {
|
|
202
|
+
if (e && e.itemName) { e.itemName = cutStr(e.itemName, 99) }
|
|
203
|
+
})
|
|
204
|
+
resolve()
|
|
205
|
+
},
|
|
206
|
+
onCancel() {
|
|
207
|
+
resolve()
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
}))()
|
|
211
|
+
}
|
|
212
|
+
|
|
189
213
|
s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
|
|
190
214
|
s.goodsListState.endowCode.endowcodeGoodIndex = [];
|
|
191
215
|
})();
|
|
192
|
-
},
|
|
193
|
-
[controller],
|
|
194
|
-
);
|
|
216
|
+
}, [controller]);
|
|
195
217
|
|
|
196
218
|
const effects = React.useCallback(() => {
|
|
197
219
|
// 税率变化
|
|
@@ -251,7 +273,7 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
|
|
|
251
273
|
title="免税类型"
|
|
252
274
|
default={defaultValue?.taxFreeType}
|
|
253
275
|
enum={taxFreeTypeList}
|
|
254
|
-
|
|
276
|
+
|
|
255
277
|
x-rules={[{ message: '请选择免税类型', required: true }]}
|
|
256
278
|
/>
|
|
257
279
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Invoice from '../../../../';
|
|
3
3
|
import { Button, message } from 'kts-components-antd-x3';
|
|
4
|
+
import coolingFn from '../../../../tools/coolingFn'
|
|
4
5
|
// import { LineAttributeType } from '../../../../InvoiceController';
|
|
5
6
|
|
|
6
7
|
export default () => {
|
|
@@ -18,19 +19,13 @@ export default () => {
|
|
|
18
19
|
|
|
19
20
|
// 不能给正在编辑的货物赋码
|
|
20
21
|
if (s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0) {
|
|
21
|
-
message.error(
|
|
22
|
-
content: '不能给正在编辑的货物赋码',
|
|
23
|
-
key: '不能给正在编辑的货物赋码',
|
|
24
|
-
});
|
|
22
|
+
coolingFn('不能给正在编辑的货物赋码', 3000, () => { message.error('不能给正在编辑的货物赋码') });
|
|
25
23
|
return;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
// 税率不一样不能批量赋码
|
|
29
27
|
if (s.goodsListState.selectedGoodIndex.map(e => s.goodsListState.goodsMap.get(e)).some((e, _, arr) => e?.taxRate !== arr[0]?.taxRate)) {
|
|
30
|
-
message.error(
|
|
31
|
-
content: '商品税率不一致不能操作批量赋码',
|
|
32
|
-
key: '商品税率不一致不能操作批量赋码',
|
|
33
|
-
});
|
|
28
|
+
coolingFn('商品税率不一致不能操作批量赋码', 3000, () => { message.error('商品税率不一致不能操作批量赋码') });
|
|
34
29
|
return;
|
|
35
30
|
}
|
|
36
31
|
|