@kmkf-fe-packages/basic-components 0.7.15-alpha.56 → 0.7.15-alpha.58

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
@@ -9632,10 +9632,12 @@ var ItemList = function ItemList(props) {
9632
9632
  var columns = [{
9633
9633
  dataIndex: 'index',
9634
9634
  title: '序号',
9635
- // with: 70,
9636
- ellipsis: true,
9637
9635
  render: function render(val, record, index) {
9638
- return /*#__PURE__*/React.createElement("span", null, index + 1);
9636
+ return /*#__PURE__*/React.createElement("div", {
9637
+ style: {
9638
+ width: '50px'
9639
+ }
9640
+ }, index + 1);
9639
9641
  }
9640
9642
  }, {
9641
9643
  dataIndex: 'name',
@@ -9656,7 +9658,14 @@ var columns = [{
9656
9658
  dataIndex: 'code',
9657
9659
  title: '商品编码',
9658
9660
  with: 200,
9659
- ellipsis: true
9661
+ // ellipsis: true,
9662
+ render: function render(val) {
9663
+ return /*#__PURE__*/React.createElement("div", {
9664
+ style: {
9665
+ width: '100px'
9666
+ }
9667
+ }, val);
9668
+ }
9660
9669
  }, {
9661
9670
  dataIndex: 'skuCode',
9662
9671
  title: '商品sku编码',
@@ -9665,8 +9674,15 @@ var columns = [{
9665
9674
  }, {
9666
9675
  dataIndex: 'marketPrice',
9667
9676
  title: '市场价',
9668
- with: 200,
9669
- ellipsis: true
9677
+ // with: 200,
9678
+ // ellipsis: true,
9679
+ render: function render(val) {
9680
+ return /*#__PURE__*/React.createElement("div", {
9681
+ style: {
9682
+ width: '70px'
9683
+ }
9684
+ }, val);
9685
+ }
9670
9686
  }];
9671
9687
  var GoodsModal$1 = function GoodsModal(props, ref) {
9672
9688
  useImperativeHandle(ref, function () {
@@ -9924,7 +9940,7 @@ var GoodItem = function GoodItem(props) {
9924
9940
  var handleDelete = function handleDelete(record, index) {
9925
9941
  onDelete === null || onDelete === void 0 ? void 0 : onDelete(value[index]);
9926
9942
  var newList = _toConsumableArray(value).filter(function (item, i) {
9927
- return record.uuid !== item.uuid;
9943
+ return index !== i;
9928
9944
  });
9929
9945
  onChange === null || onChange === void 0 ? void 0 : onChange(_toConsumableArray(newList));
9930
9946
  };
@@ -9991,6 +10007,8 @@ var GoodItem = function GoodItem(props) {
9991
10007
  render: function render(val, record, index) {
9992
10008
  return record.canUpdateNumber && !disabled ? /*#__PURE__*/React.createElement(InputNumber, {
9993
10009
  value: val,
10010
+ min: 0,
10011
+ precision: 0,
9994
10012
  onChange: function onChange(num) {
9995
10013
  return updateHandle(num, index, 'number');
9996
10014
  }
@@ -10056,7 +10074,7 @@ var GoodItem = function GoodItem(props) {
10056
10074
  code: code,
10057
10075
  sku: skuCode,
10058
10076
  money: marketPrice || 0,
10059
- share: '',
10077
+ share: marketPrice || 0,
10060
10078
  number: 1,
10061
10079
  type: '',
10062
10080
  uuid: uuid(),
@@ -10125,73 +10143,54 @@ var BsGoods = function BsGoods(props) {
10125
10143
  _useState2 = _slicedToArray(_useState, 2),
10126
10144
  tableSelect = _useState2[0],
10127
10145
  setTableSelect = _useState2[1];
10128
- var _useState3 = useState({
10129
- type: '',
10130
- val: ''
10131
- }),
10146
+ // const [withInfo, setWithInfo] = useState({ type: '', val: '' });
10147
+ var _useState3 = useState(''),
10132
10148
  _useState4 = _slicedToArray(_useState3, 2),
10133
- withInfo = _useState4[0],
10134
- setWithInfo = _useState4[1];
10135
- var ref = useRef();
10136
- var reissueRef = useRef();
10149
+ withType = _useState4[0],
10150
+ setWithType = _useState4[1];
10151
+ var _useState5 = useState(''),
10152
+ _useState6 = _slicedToArray(_useState5, 2),
10153
+ withValue = _useState6[0],
10154
+ setWithValue = _useState6[1];
10137
10155
  useEffect(function () {
10138
- ref.current = pubsub.subscribeOnce('type', function (type, val) {
10139
- var _value$bsGoods;
10140
- console.log(value);
10156
+ pubsub.subscribe('type', function (type, val) {
10141
10157
  if (disabled) return;
10142
- setWithInfo({
10143
- type: type,
10144
- val: val
10145
- });
10158
+ console.log('type', type, val);
10159
+ // setWithInfo({ type, val });
10160
+ setWithType(type);
10161
+ setWithValue(val);
10146
10162
  setTableSelect(['2', '4'].includes(val));
10147
- if (['1', '3'].includes(val) && (value === null || value === void 0 ? void 0 : (_value$bsGoods = value.bsGoods) === null || _value$bsGoods === void 0 ? void 0 : _value$bsGoods.length)) {
10148
- var newGoods = cloneDeep(value === null || value === void 0 ? void 0 : value.bsGoods);
10149
- pubsub.publish('selectList', {
10150
- type: val,
10151
- list: (newGoods || []).map(function (item) {
10152
- item.canDelete = false;
10153
- return item;
10154
- })
10155
- });
10156
- }
10157
10163
  });
10158
10164
  //补发
10159
- reissueRef.current = pubsub.subscribeOnce('reissueType', function (type, val) {
10160
- var _value$bsGoods2;
10165
+ pubsub.subscribe('reissueType', function (type, val) {
10161
10166
  if (disabled) return;
10162
- setWithInfo({
10163
- type: type,
10164
- val: val
10165
- });
10167
+ console.log('reissueType', type, val);
10168
+ // setWithInfo({ type, val });
10169
+ setWithType(type);
10170
+ setWithValue(val);
10166
10171
  setTableSelect(['2', '4'].includes(val));
10167
- if (['1', '3'].includes(val) && (value === null || value === void 0 ? void 0 : (_value$bsGoods2 = value.bsGoods) === null || _value$bsGoods2 === void 0 ? void 0 : _value$bsGoods2.length)) {
10168
- var newGoods = cloneDeep(value === null || value === void 0 ? void 0 : value.bsGoods);
10169
- pubsub.publish('reissueSelectList', {
10170
- type: val,
10171
- list: (newGoods || []).map(function (item) {
10172
- item.canDelete = false;
10173
- return item;
10174
- })
10175
- });
10176
- }
10177
10172
  });
10178
- return function () {
10179
- pubsub.unsubscribe(ref.current);
10180
- pubsub.unsubscribe(reissueRef.current);
10181
- };
10182
- }, [value, withInfo, disabled]);
10183
- var _onSelect = useCallback(function (list) {
10173
+ }, [disabled, withType, withValue, setWithType, setWithValue, setTableSelect]);
10174
+ useEffect(function () {
10175
+ if (!disabled) {
10176
+ pubsub.publish('goodList', {
10177
+ list: cloneDeep((value === null || value === void 0 ? void 0 : value.bsGoods) || [])
10178
+ });
10179
+ }
10180
+ }, [value, disabled]);
10181
+ var onSelect = function onSelect(list) {
10184
10182
  if (disabled) return;
10185
- console.log('withInfo', withInfo, list);
10186
10183
  var newList = cloneDeep(list);
10187
- pubsub.publish(withInfo.type === 'reissueType' ? 'reissueSelectList' : 'selectList', {
10188
- type: withInfo.val,
10184
+ var type = withType === 'reissueType' ? 'reissueSelectList' : 'selectList';
10185
+ console.log(withType, withValue, type);
10186
+ pubsub.publish(type, {
10187
+ type: withValue,
10189
10188
  list: newList.map(function (item) {
10190
10189
  item.canDelete = true;
10191
10190
  return item;
10192
10191
  })
10193
10192
  });
10194
- }, [withInfo]);
10193
+ };
10195
10194
  var _onDelete = function onDelete(item) {
10196
10195
  var deleteId = item === null || item === void 0 ? void 0 : item.sku;
10197
10196
  pubsub.publish('deleteGood', deleteId);
@@ -10209,9 +10208,7 @@ var BsGoods = function BsGoods(props) {
10209
10208
  value: value === null || value === void 0 ? void 0 : value.bsGoods,
10210
10209
  shopCode: value === null || value === void 0 ? void 0 : value.shopCode,
10211
10210
  tableSelect: tableSelect,
10212
- onSelect: function onSelect(list) {
10213
- return _onSelect(list);
10214
- },
10211
+ onSelect: onSelect,
10215
10212
  onDelete: function onDelete(item) {
10216
10213
  return _onDelete(item);
10217
10214
  },
@@ -10230,6 +10227,15 @@ var BsExchange = function BsExchange(props) {
10230
10227
  reasonList = _props$reasonList === void 0 ? [] : _props$reasonList,
10231
10228
  disabled = props.disabled,
10232
10229
  other = _objectWithoutProperties(props, _excluded$b);
10230
+ var _useState = useState([]),
10231
+ _useState2 = _slicedToArray(_useState, 2),
10232
+ bsGoods = _useState2[0],
10233
+ setBsGoods = _useState2[1];
10234
+ useEffect(function () {
10235
+ pubsub.subscribe('goodList', function (_, data) {
10236
+ setBsGoods(data.list);
10237
+ });
10238
+ }, []);
10233
10239
  useEffect(function () {
10234
10240
  pubsub.subscribeOnce('deleteGood', function (_, data) {
10235
10241
  if (disabled) return;
@@ -10251,6 +10257,16 @@ var BsExchange = function BsExchange(props) {
10251
10257
  onChange(newValue);
10252
10258
  }
10253
10259
  });
10260
+ pubsub.subscribeOnce('selectList', function (_, data) {
10261
+ if (disabled) return;
10262
+ if (value) {
10263
+ var newData = cloneDeep(data);
10264
+ console.log(getListHandle(_toConsumableArray(newData.list), value));
10265
+ onChange(_objectSpread2(_objectSpread2({}, value), {}, {
10266
+ bsExchangeReturnGoods: getListHandle(_toConsumableArray(newData.list), value)
10267
+ }));
10268
+ }
10269
+ });
10254
10270
  }, [value]);
10255
10271
  var getListHandle = function getListHandle(list, val) {
10256
10272
  var _val$bsExchangeType, _val$bsExchangeType2;
@@ -10260,10 +10276,12 @@ var BsExchange = function BsExchange(props) {
10260
10276
  next.canDelete = false;
10261
10277
  //数量大于1 拆开
10262
10278
  if (next.number > 1) {
10263
- var newList = Array(next.number).fill(_objectSpread2({}, next)).map(function (t) {
10264
- t.number = 1;
10265
- t.uuid = uuid();
10266
- return t;
10279
+ var newList = Array(next.number).fill({}).map(function () {
10280
+ var newNext = _objectSpread2({}, next);
10281
+ newNext.money = newNext.share;
10282
+ newNext.number = 1;
10283
+ newNext.uuid = uuid();
10284
+ return newNext;
10267
10285
  });
10268
10286
  prv.push.apply(prv, _toConsumableArray(newList));
10269
10287
  } else {
@@ -10278,10 +10296,12 @@ var BsExchange = function BsExchange(props) {
10278
10296
  next.index = index;
10279
10297
  //数量大于1 拆开
10280
10298
  if (next.number > 1) {
10281
- var newList = Array(next.number).fill(_objectSpread2({}, next)).map(function (t) {
10282
- t.number = 1;
10283
- t.uuid = uuid();
10284
- return t;
10299
+ var newList = Array(next.number).fill({}).map(function () {
10300
+ var newNext = _objectSpread2({}, next);
10301
+ newNext.money = newNext.share;
10302
+ newNext.number = 1;
10303
+ newNext.uuid = uuid();
10304
+ return newNext;
10285
10305
  });
10286
10306
  prv.push({
10287
10307
  bsExchangeReturnGoods: _toConsumableArray(newList),
@@ -10302,17 +10322,11 @@ var BsExchange = function BsExchange(props) {
10302
10322
  newValue.bsExchangeType = val;
10303
10323
  newValue.bsExchangeReturnGoods = [];
10304
10324
  newValue.bsExchangeGiftGoods = [];
10325
+ if (['1', '3'].includes(val[0])) {
10326
+ newValue.bsExchangeReturnGoods = getListHandle(bsGoods, newValue);
10327
+ }
10305
10328
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
10306
10329
  pubsub.publish('type', val[0]);
10307
- pubsub.subscribe('selectList', function (_, data) {
10308
- if (disabled) return;
10309
- if (newValue) {
10310
- var newData = cloneDeep(data);
10311
- onChange(_objectSpread2(_objectSpread2({}, newValue), {}, {
10312
- bsExchangeReturnGoods: getListHandle(_toConsumableArray(newData.list), newValue)
10313
- }));
10314
- }
10315
- });
10316
10330
  };
10317
10331
  var changeHandle = function changeHandle(val, key) {
10318
10332
  var newValue = _objectSpread2({}, value);
@@ -10330,7 +10344,7 @@ var BsExchange = function BsExchange(props) {
10330
10344
  }
10331
10345
  };
10332
10346
  var changeReturnHandle = function changeReturnHandle(val, index, key) {
10333
- // console.log('changeReturnHandle', val, index, key);
10347
+ console.log('changeReturnHandle', val, index, key);
10334
10348
  var newValue = _objectSpread2({}, value);
10335
10349
  newValue.bsExchangeReturnGoods[index][key] = (val || []).map(function (t) {
10336
10350
  t.index = index;
@@ -10432,6 +10446,15 @@ var BsReissue = function BsReissue(props) {
10432
10446
  reasonList = _props$reasonList === void 0 ? [] : _props$reasonList,
10433
10447
  disabled = props.disabled,
10434
10448
  other = _objectWithoutProperties(props, _excluded$c);
10449
+ var _useState = useState([]),
10450
+ _useState2 = _slicedToArray(_useState, 2),
10451
+ bsGoods = _useState2[0],
10452
+ setBsGoods = _useState2[1];
10453
+ useEffect(function () {
10454
+ pubsub.subscribe('goodList', function (_, data) {
10455
+ setBsGoods(data.list);
10456
+ });
10457
+ }, []);
10435
10458
  useEffect(function () {
10436
10459
  pubsub.subscribeOnce('reissueDeleteGood', function (_, data) {
10437
10460
  if (disabled) return;
@@ -10443,36 +10466,43 @@ var BsReissue = function BsReissue(props) {
10443
10466
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
10444
10467
  }
10445
10468
  });
10469
+ pubsub.subscribeOnce('reissueSelectList', function (_, data) {
10470
+ if (disabled) return;
10471
+ if (value) {
10472
+ var newValue = _objectSpread2({}, value);
10473
+ newValue.bsReissueGoods = data === null || data === void 0 ? void 0 : data.list.map(function (item) {
10474
+ item.money = 0;
10475
+ item.share = 0;
10476
+ item.canUpdateNumber = true;
10477
+ return item;
10478
+ });
10479
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
10480
+ }
10481
+ });
10446
10482
  }, [value, disabled]);
10447
10483
  var changeHandle = function changeHandle(val, key) {
10448
10484
  var newValue = _objectSpread2({}, value);
10449
10485
  if (key === 'bsReissueGoods') {
10450
10486
  val = (val || []).map(function (item) {
10451
10487
  item.money = 0;
10488
+ item.share = 0;
10452
10489
  return item;
10453
10490
  });
10454
10491
  }
10455
10492
  newValue[key] = val;
10456
10493
  if (key === 'bsReissueType') {
10457
10494
  newValue.bsReissueGoods = [];
10495
+ if (['1', '3'].includes(val[0])) {
10496
+ newValue.bsReissueGoods = (bsGoods || []).map(function (item) {
10497
+ item.money = 0;
10498
+ item.share = 0;
10499
+ item.canUpdateNumber = false;
10500
+ return item;
10501
+ });
10502
+ }
10458
10503
  }
10459
10504
  onChange === null || onChange === void 0 ? void 0 : onChange(_objectSpread2({}, newValue));
10460
- if (key === 'bsReissueType') {
10461
- pubsub.publish('reissueType', val[0]);
10462
- pubsub.subscribe('reissueSelectList', function (_, data) {
10463
- if (disabled) return;
10464
- if (value) {
10465
- var newData = cloneDeep(data);
10466
- onChange === null || onChange === void 0 ? void 0 : onChange(_objectSpread2(_objectSpread2({}, newValue), {}, {
10467
- bsReissueGoods: ((newData === null || newData === void 0 ? void 0 : newData.list) || []).map(function (item) {
10468
- item.money = 0;
10469
- item.canUpdateNumber = ['2', '4'].includes(newData === null || newData === void 0 ? void 0 : newData.type);
10470
- return item;
10471
- })
10472
- }));
10473
- }
10474
- });
10475
- }
10505
+ pubsub.publish('reissueType', val[0]);
10476
10506
  };
10477
10507
  //显示选择商品按钮 原单换不显示选择商品
10478
10508
  var showChangeBtn = useMemo(function () {
@@ -10490,7 +10520,7 @@ var BsReissue = function BsReissue(props) {
10490
10520
  onChange: function onChange(val) {
10491
10521
  return changeHandle(val, 'bsReissueType');
10492
10522
  }
10493
- }), /*#__PURE__*/React.createElement("div", null, "\u9000\u56DE\u5546\u54C1"), /*#__PURE__*/React.createElement(GoodItem, _objectSpread2(_objectSpread2({
10523
+ }), /*#__PURE__*/React.createElement(GoodItem, _objectSpread2(_objectSpread2({
10494
10524
  key: 'reissueGoods'
10495
10525
  }, other), {}, {
10496
10526
  disabled: disabled,
package/dist/index.js CHANGED
@@ -9643,10 +9643,12 @@ var ItemList = function ItemList(props) {
9643
9643
  var columns = [{
9644
9644
  dataIndex: 'index',
9645
9645
  title: '序号',
9646
- // with: 70,
9647
- ellipsis: true,
9648
9646
  render: function render(val, record, index) {
9649
- return /*#__PURE__*/React__default['default'].createElement("span", null, index + 1);
9647
+ return /*#__PURE__*/React__default['default'].createElement("div", {
9648
+ style: {
9649
+ width: '50px'
9650
+ }
9651
+ }, index + 1);
9650
9652
  }
9651
9653
  }, {
9652
9654
  dataIndex: 'name',
@@ -9667,7 +9669,14 @@ var columns = [{
9667
9669
  dataIndex: 'code',
9668
9670
  title: '商品编码',
9669
9671
  with: 200,
9670
- ellipsis: true
9672
+ // ellipsis: true,
9673
+ render: function render(val) {
9674
+ return /*#__PURE__*/React__default['default'].createElement("div", {
9675
+ style: {
9676
+ width: '100px'
9677
+ }
9678
+ }, val);
9679
+ }
9671
9680
  }, {
9672
9681
  dataIndex: 'skuCode',
9673
9682
  title: '商品sku编码',
@@ -9676,8 +9685,15 @@ var columns = [{
9676
9685
  }, {
9677
9686
  dataIndex: 'marketPrice',
9678
9687
  title: '市场价',
9679
- with: 200,
9680
- ellipsis: true
9688
+ // with: 200,
9689
+ // ellipsis: true,
9690
+ render: function render(val) {
9691
+ return /*#__PURE__*/React__default['default'].createElement("div", {
9692
+ style: {
9693
+ width: '70px'
9694
+ }
9695
+ }, val);
9696
+ }
9681
9697
  }];
9682
9698
  var GoodsModal$1 = function GoodsModal(props, ref) {
9683
9699
  React.useImperativeHandle(ref, function () {
@@ -9935,7 +9951,7 @@ var GoodItem = function GoodItem(props) {
9935
9951
  var handleDelete = function handleDelete(record, index) {
9936
9952
  onDelete === null || onDelete === void 0 ? void 0 : onDelete(value[index]);
9937
9953
  var newList = _toConsumableArray(value).filter(function (item, i) {
9938
- return record.uuid !== item.uuid;
9954
+ return index !== i;
9939
9955
  });
9940
9956
  onChange === null || onChange === void 0 ? void 0 : onChange(_toConsumableArray(newList));
9941
9957
  };
@@ -10002,6 +10018,8 @@ var GoodItem = function GoodItem(props) {
10002
10018
  render: function render(val, record, index) {
10003
10019
  return record.canUpdateNumber && !disabled ? /*#__PURE__*/React__default['default'].createElement(antd.InputNumber, {
10004
10020
  value: val,
10021
+ min: 0,
10022
+ precision: 0,
10005
10023
  onChange: function onChange(num) {
10006
10024
  return updateHandle(num, index, 'number');
10007
10025
  }
@@ -10067,7 +10085,7 @@ var GoodItem = function GoodItem(props) {
10067
10085
  code: code,
10068
10086
  sku: skuCode,
10069
10087
  money: marketPrice || 0,
10070
- share: '',
10088
+ share: marketPrice || 0,
10071
10089
  number: 1,
10072
10090
  type: '',
10073
10091
  uuid: kmkfUtils.uuid(),
@@ -10136,73 +10154,54 @@ var BsGoods = function BsGoods(props) {
10136
10154
  _useState2 = _slicedToArray(_useState, 2),
10137
10155
  tableSelect = _useState2[0],
10138
10156
  setTableSelect = _useState2[1];
10139
- var _useState3 = React.useState({
10140
- type: '',
10141
- val: ''
10142
- }),
10157
+ // const [withInfo, setWithInfo] = useState({ type: '', val: '' });
10158
+ var _useState3 = React.useState(''),
10143
10159
  _useState4 = _slicedToArray(_useState3, 2),
10144
- withInfo = _useState4[0],
10145
- setWithInfo = _useState4[1];
10146
- var ref = React.useRef();
10147
- var reissueRef = React.useRef();
10160
+ withType = _useState4[0],
10161
+ setWithType = _useState4[1];
10162
+ var _useState5 = React.useState(''),
10163
+ _useState6 = _slicedToArray(_useState5, 2),
10164
+ withValue = _useState6[0],
10165
+ setWithValue = _useState6[1];
10148
10166
  React.useEffect(function () {
10149
- ref.current = pubsub__default['default'].subscribeOnce('type', function (type, val) {
10150
- var _value$bsGoods;
10151
- console.log(value);
10167
+ pubsub__default['default'].subscribe('type', function (type, val) {
10152
10168
  if (disabled) return;
10153
- setWithInfo({
10154
- type: type,
10155
- val: val
10156
- });
10169
+ console.log('type', type, val);
10170
+ // setWithInfo({ type, val });
10171
+ setWithType(type);
10172
+ setWithValue(val);
10157
10173
  setTableSelect(['2', '4'].includes(val));
10158
- if (['1', '3'].includes(val) && (value === null || value === void 0 ? void 0 : (_value$bsGoods = value.bsGoods) === null || _value$bsGoods === void 0 ? void 0 : _value$bsGoods.length)) {
10159
- var newGoods = lodash.cloneDeep(value === null || value === void 0 ? void 0 : value.bsGoods);
10160
- pubsub__default['default'].publish('selectList', {
10161
- type: val,
10162
- list: (newGoods || []).map(function (item) {
10163
- item.canDelete = false;
10164
- return item;
10165
- })
10166
- });
10167
- }
10168
10174
  });
10169
10175
  //补发
10170
- reissueRef.current = pubsub__default['default'].subscribeOnce('reissueType', function (type, val) {
10171
- var _value$bsGoods2;
10176
+ pubsub__default['default'].subscribe('reissueType', function (type, val) {
10172
10177
  if (disabled) return;
10173
- setWithInfo({
10174
- type: type,
10175
- val: val
10176
- });
10178
+ console.log('reissueType', type, val);
10179
+ // setWithInfo({ type, val });
10180
+ setWithType(type);
10181
+ setWithValue(val);
10177
10182
  setTableSelect(['2', '4'].includes(val));
10178
- if (['1', '3'].includes(val) && (value === null || value === void 0 ? void 0 : (_value$bsGoods2 = value.bsGoods) === null || _value$bsGoods2 === void 0 ? void 0 : _value$bsGoods2.length)) {
10179
- var newGoods = lodash.cloneDeep(value === null || value === void 0 ? void 0 : value.bsGoods);
10180
- pubsub__default['default'].publish('reissueSelectList', {
10181
- type: val,
10182
- list: (newGoods || []).map(function (item) {
10183
- item.canDelete = false;
10184
- return item;
10185
- })
10186
- });
10187
- }
10188
10183
  });
10189
- return function () {
10190
- pubsub__default['default'].unsubscribe(ref.current);
10191
- pubsub__default['default'].unsubscribe(reissueRef.current);
10192
- };
10193
- }, [value, withInfo, disabled]);
10194
- var _onSelect = React.useCallback(function (list) {
10184
+ }, [disabled, withType, withValue, setWithType, setWithValue, setTableSelect]);
10185
+ React.useEffect(function () {
10186
+ if (!disabled) {
10187
+ pubsub__default['default'].publish('goodList', {
10188
+ list: lodash.cloneDeep((value === null || value === void 0 ? void 0 : value.bsGoods) || [])
10189
+ });
10190
+ }
10191
+ }, [value, disabled]);
10192
+ var onSelect = function onSelect(list) {
10195
10193
  if (disabled) return;
10196
- console.log('withInfo', withInfo, list);
10197
10194
  var newList = lodash.cloneDeep(list);
10198
- pubsub__default['default'].publish(withInfo.type === 'reissueType' ? 'reissueSelectList' : 'selectList', {
10199
- type: withInfo.val,
10195
+ var type = withType === 'reissueType' ? 'reissueSelectList' : 'selectList';
10196
+ console.log(withType, withValue, type);
10197
+ pubsub__default['default'].publish(type, {
10198
+ type: withValue,
10200
10199
  list: newList.map(function (item) {
10201
10200
  item.canDelete = true;
10202
10201
  return item;
10203
10202
  })
10204
10203
  });
10205
- }, [withInfo]);
10204
+ };
10206
10205
  var _onDelete = function onDelete(item) {
10207
10206
  var deleteId = item === null || item === void 0 ? void 0 : item.sku;
10208
10207
  pubsub__default['default'].publish('deleteGood', deleteId);
@@ -10220,9 +10219,7 @@ var BsGoods = function BsGoods(props) {
10220
10219
  value: value === null || value === void 0 ? void 0 : value.bsGoods,
10221
10220
  shopCode: value === null || value === void 0 ? void 0 : value.shopCode,
10222
10221
  tableSelect: tableSelect,
10223
- onSelect: function onSelect(list) {
10224
- return _onSelect(list);
10225
- },
10222
+ onSelect: onSelect,
10226
10223
  onDelete: function onDelete(item) {
10227
10224
  return _onDelete(item);
10228
10225
  },
@@ -10241,6 +10238,15 @@ var BsExchange = function BsExchange(props) {
10241
10238
  reasonList = _props$reasonList === void 0 ? [] : _props$reasonList,
10242
10239
  disabled = props.disabled,
10243
10240
  other = _objectWithoutProperties(props, _excluded$b);
10241
+ var _useState = React.useState([]),
10242
+ _useState2 = _slicedToArray(_useState, 2),
10243
+ bsGoods = _useState2[0],
10244
+ setBsGoods = _useState2[1];
10245
+ React.useEffect(function () {
10246
+ pubsub__default['default'].subscribe('goodList', function (_, data) {
10247
+ setBsGoods(data.list);
10248
+ });
10249
+ }, []);
10244
10250
  React.useEffect(function () {
10245
10251
  pubsub__default['default'].subscribeOnce('deleteGood', function (_, data) {
10246
10252
  if (disabled) return;
@@ -10262,6 +10268,16 @@ var BsExchange = function BsExchange(props) {
10262
10268
  onChange(newValue);
10263
10269
  }
10264
10270
  });
10271
+ pubsub__default['default'].subscribeOnce('selectList', function (_, data) {
10272
+ if (disabled) return;
10273
+ if (value) {
10274
+ var newData = lodash.cloneDeep(data);
10275
+ console.log(getListHandle(_toConsumableArray(newData.list), value));
10276
+ onChange(_objectSpread2(_objectSpread2({}, value), {}, {
10277
+ bsExchangeReturnGoods: getListHandle(_toConsumableArray(newData.list), value)
10278
+ }));
10279
+ }
10280
+ });
10265
10281
  }, [value]);
10266
10282
  var getListHandle = function getListHandle(list, val) {
10267
10283
  var _val$bsExchangeType, _val$bsExchangeType2;
@@ -10271,10 +10287,12 @@ var BsExchange = function BsExchange(props) {
10271
10287
  next.canDelete = false;
10272
10288
  //数量大于1 拆开
10273
10289
  if (next.number > 1) {
10274
- var newList = Array(next.number).fill(_objectSpread2({}, next)).map(function (t) {
10275
- t.number = 1;
10276
- t.uuid = kmkfUtils.uuid();
10277
- return t;
10290
+ var newList = Array(next.number).fill({}).map(function () {
10291
+ var newNext = _objectSpread2({}, next);
10292
+ newNext.money = newNext.share;
10293
+ newNext.number = 1;
10294
+ newNext.uuid = kmkfUtils.uuid();
10295
+ return newNext;
10278
10296
  });
10279
10297
  prv.push.apply(prv, _toConsumableArray(newList));
10280
10298
  } else {
@@ -10289,10 +10307,12 @@ var BsExchange = function BsExchange(props) {
10289
10307
  next.index = index;
10290
10308
  //数量大于1 拆开
10291
10309
  if (next.number > 1) {
10292
- var newList = Array(next.number).fill(_objectSpread2({}, next)).map(function (t) {
10293
- t.number = 1;
10294
- t.uuid = kmkfUtils.uuid();
10295
- return t;
10310
+ var newList = Array(next.number).fill({}).map(function () {
10311
+ var newNext = _objectSpread2({}, next);
10312
+ newNext.money = newNext.share;
10313
+ newNext.number = 1;
10314
+ newNext.uuid = kmkfUtils.uuid();
10315
+ return newNext;
10296
10316
  });
10297
10317
  prv.push({
10298
10318
  bsExchangeReturnGoods: _toConsumableArray(newList),
@@ -10313,17 +10333,11 @@ var BsExchange = function BsExchange(props) {
10313
10333
  newValue.bsExchangeType = val;
10314
10334
  newValue.bsExchangeReturnGoods = [];
10315
10335
  newValue.bsExchangeGiftGoods = [];
10336
+ if (['1', '3'].includes(val[0])) {
10337
+ newValue.bsExchangeReturnGoods = getListHandle(bsGoods, newValue);
10338
+ }
10316
10339
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
10317
10340
  pubsub__default['default'].publish('type', val[0]);
10318
- pubsub__default['default'].subscribe('selectList', function (_, data) {
10319
- if (disabled) return;
10320
- if (newValue) {
10321
- var newData = lodash.cloneDeep(data);
10322
- onChange(_objectSpread2(_objectSpread2({}, newValue), {}, {
10323
- bsExchangeReturnGoods: getListHandle(_toConsumableArray(newData.list), newValue)
10324
- }));
10325
- }
10326
- });
10327
10341
  };
10328
10342
  var changeHandle = function changeHandle(val, key) {
10329
10343
  var newValue = _objectSpread2({}, value);
@@ -10341,7 +10355,7 @@ var BsExchange = function BsExchange(props) {
10341
10355
  }
10342
10356
  };
10343
10357
  var changeReturnHandle = function changeReturnHandle(val, index, key) {
10344
- // console.log('changeReturnHandle', val, index, key);
10358
+ console.log('changeReturnHandle', val, index, key);
10345
10359
  var newValue = _objectSpread2({}, value);
10346
10360
  newValue.bsExchangeReturnGoods[index][key] = (val || []).map(function (t) {
10347
10361
  t.index = index;
@@ -10443,6 +10457,15 @@ var BsReissue = function BsReissue(props) {
10443
10457
  reasonList = _props$reasonList === void 0 ? [] : _props$reasonList,
10444
10458
  disabled = props.disabled,
10445
10459
  other = _objectWithoutProperties(props, _excluded$c);
10460
+ var _useState = React.useState([]),
10461
+ _useState2 = _slicedToArray(_useState, 2),
10462
+ bsGoods = _useState2[0],
10463
+ setBsGoods = _useState2[1];
10464
+ React.useEffect(function () {
10465
+ pubsub__default['default'].subscribe('goodList', function (_, data) {
10466
+ setBsGoods(data.list);
10467
+ });
10468
+ }, []);
10446
10469
  React.useEffect(function () {
10447
10470
  pubsub__default['default'].subscribeOnce('reissueDeleteGood', function (_, data) {
10448
10471
  if (disabled) return;
@@ -10454,36 +10477,43 @@ var BsReissue = function BsReissue(props) {
10454
10477
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
10455
10478
  }
10456
10479
  });
10480
+ pubsub__default['default'].subscribeOnce('reissueSelectList', function (_, data) {
10481
+ if (disabled) return;
10482
+ if (value) {
10483
+ var newValue = _objectSpread2({}, value);
10484
+ newValue.bsReissueGoods = data === null || data === void 0 ? void 0 : data.list.map(function (item) {
10485
+ item.money = 0;
10486
+ item.share = 0;
10487
+ item.canUpdateNumber = true;
10488
+ return item;
10489
+ });
10490
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
10491
+ }
10492
+ });
10457
10493
  }, [value, disabled]);
10458
10494
  var changeHandle = function changeHandle(val, key) {
10459
10495
  var newValue = _objectSpread2({}, value);
10460
10496
  if (key === 'bsReissueGoods') {
10461
10497
  val = (val || []).map(function (item) {
10462
10498
  item.money = 0;
10499
+ item.share = 0;
10463
10500
  return item;
10464
10501
  });
10465
10502
  }
10466
10503
  newValue[key] = val;
10467
10504
  if (key === 'bsReissueType') {
10468
10505
  newValue.bsReissueGoods = [];
10506
+ if (['1', '3'].includes(val[0])) {
10507
+ newValue.bsReissueGoods = (bsGoods || []).map(function (item) {
10508
+ item.money = 0;
10509
+ item.share = 0;
10510
+ item.canUpdateNumber = false;
10511
+ return item;
10512
+ });
10513
+ }
10469
10514
  }
10470
10515
  onChange === null || onChange === void 0 ? void 0 : onChange(_objectSpread2({}, newValue));
10471
- if (key === 'bsReissueType') {
10472
- pubsub__default['default'].publish('reissueType', val[0]);
10473
- pubsub__default['default'].subscribe('reissueSelectList', function (_, data) {
10474
- if (disabled) return;
10475
- if (value) {
10476
- var newData = lodash.cloneDeep(data);
10477
- onChange === null || onChange === void 0 ? void 0 : onChange(_objectSpread2(_objectSpread2({}, newValue), {}, {
10478
- bsReissueGoods: ((newData === null || newData === void 0 ? void 0 : newData.list) || []).map(function (item) {
10479
- item.money = 0;
10480
- item.canUpdateNumber = ['2', '4'].includes(newData === null || newData === void 0 ? void 0 : newData.type);
10481
- return item;
10482
- })
10483
- }));
10484
- }
10485
- });
10486
- }
10516
+ pubsub__default['default'].publish('reissueType', val[0]);
10487
10517
  };
10488
10518
  //显示选择商品按钮 原单换不显示选择商品
10489
10519
  var showChangeBtn = React.useMemo(function () {
@@ -10501,7 +10531,7 @@ var BsReissue = function BsReissue(props) {
10501
10531
  onChange: function onChange(val) {
10502
10532
  return changeHandle(val, 'bsReissueType');
10503
10533
  }
10504
- }), /*#__PURE__*/React__default['default'].createElement("div", null, "\u9000\u56DE\u5546\u54C1"), /*#__PURE__*/React__default['default'].createElement(GoodItem, _objectSpread2(_objectSpread2({
10534
+ }), /*#__PURE__*/React__default['default'].createElement(GoodItem, _objectSpread2(_objectSpread2({
10505
10535
  key: 'reissueGoods'
10506
10536
  }, other), {}, {
10507
10537
  disabled: disabled,
@@ -10,7 +10,8 @@ interface BsGoodsProps {
10
10
  shopId: string | number;
11
11
  maxLength: number;
12
12
  showChangeBtn: boolean;
13
- tableSelect: boolean;
13
+ tableSelect?: boolean;
14
+ selectType?: string;
14
15
  otherOperations: any;
15
16
  canUpdateNumber: boolean;
16
17
  shopCode: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmkf-fe-packages/basic-components",
3
- "version": "0.7.15-alpha.56",
3
+ "version": "0.7.15-alpha.58",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -20,7 +20,7 @@
20
20
  "watch": "nodemon --ignore dist/ --ignore node_modules/ --watch src/ -C -e ts,tsx,less --debug -x 'yarn async'"
21
21
  },
22
22
  "dependencies": {
23
- "@kmkf-fe-packages/kmkf-utils": "^0.7.15-alpha.56",
23
+ "@kmkf-fe-packages/kmkf-utils": "^0.7.15-alpha.57",
24
24
  "lodash": "^4.17.21",
25
25
  "pubsub-js": "^1.9.4",
26
26
  "umi-request": "^1.4.0"
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  },
61
- "gitHead": "87c92d90ef4c8365b2ed9b0f3689ac76cd972261"
61
+ "gitHead": "4a61916bb9e43996cd0bb1b0350f51ae8c32501b"
62
62
  }
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- declare const eventEmitter: EventEmitter;
4
- export default eventEmitter;