@bit-sun/business-component 2.2.25 → 2.2.27
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
|
@@ -9881,6 +9881,22 @@ var loadSelectSource = function loadSelectSource(url, params) {
|
|
|
9881
9881
|
});
|
|
9882
9882
|
});
|
|
9883
9883
|
};
|
|
9884
|
+
var checkSpuMatchCode = function checkSpuMatchCode(data) {
|
|
9885
|
+
return new Promise(function (resolve, reject) {
|
|
9886
|
+
axios.post("/stock/rwFrontRecordSkcDetail/checkSpuMatchCode", data).then(function (result) {
|
|
9887
|
+
var _result3, _result4;
|
|
9888
|
+
result = result.data;
|
|
9889
|
+
if (((_result3 = result) === null || _result3 === void 0 ? void 0 : _result3.status) && result.status !== '0' || ((_result4 = result) === null || _result4 === void 0 ? void 0 : _result4.code) && result.code !== '000000') {
|
|
9890
|
+
message.error(result.msg);
|
|
9891
|
+
reject(false);
|
|
9892
|
+
return;
|
|
9893
|
+
}
|
|
9894
|
+
resolve(result);
|
|
9895
|
+
}).catch(function (err) {
|
|
9896
|
+
reject(err);
|
|
9897
|
+
});
|
|
9898
|
+
});
|
|
9899
|
+
};
|
|
9884
9900
|
var ResizeableTitle = function ResizeableTitle(props) {
|
|
9885
9901
|
var onResize = props.onResize,
|
|
9886
9902
|
width = props.width,
|
|
@@ -10121,6 +10137,101 @@ var AddSelect = function AddSelect(props) {
|
|
|
10121
10137
|
setShowToChooseColumns = _useState46[1];
|
|
10122
10138
|
var codeToChoose = tableCodeList[0] || initTableCode[businessType][0];
|
|
10123
10139
|
var codeSelected = tableCodeList[1] || initTableCode[businessType][1];
|
|
10140
|
+
var checkSelectChange = /*#__PURE__*/function () {
|
|
10141
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(bType, tList, recordKey, recordItem, selectItem, changeValue) {
|
|
10142
|
+
var result;
|
|
10143
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10144
|
+
while (1) {
|
|
10145
|
+
switch (_context.prev = _context.next) {
|
|
10146
|
+
case 0:
|
|
10147
|
+
if (!(bType == 'skc' && tList.some(function (i) {
|
|
10148
|
+
return i[recordKey] == recordItem[recordKey] && i[selectItem.dataIndex] == changeValue;
|
|
10149
|
+
}))) {
|
|
10150
|
+
_context.next = 3;
|
|
10151
|
+
break;
|
|
10152
|
+
}
|
|
10153
|
+
message.warning('相同skc配码不可设置相同哦');
|
|
10154
|
+
return _context.abrupt("return", false);
|
|
10155
|
+
case 3:
|
|
10156
|
+
if (!(bType == 'spu')) {
|
|
10157
|
+
_context.next = 26;
|
|
10158
|
+
break;
|
|
10159
|
+
}
|
|
10160
|
+
if (!(selectItem.dataIndex == 'colorName' && tList.some(function (i) {
|
|
10161
|
+
return i[recordKey] == recordItem[recordKey] && i.selectPropertyGroupCode == recordItem.selectPropertyGroupCode && i[selectItem.dataIndex] == changeValue;
|
|
10162
|
+
}))) {
|
|
10163
|
+
_context.next = 7;
|
|
10164
|
+
break;
|
|
10165
|
+
}
|
|
10166
|
+
message.warning('相同商品相同配码颜色不可设置相同哦');
|
|
10167
|
+
return _context.abrupt("return", false);
|
|
10168
|
+
case 7:
|
|
10169
|
+
if (!(selectItem.dataIndex == 'selectPropertyGroupCode' && !recordItem.colorName)) {
|
|
10170
|
+
_context.next = 10;
|
|
10171
|
+
break;
|
|
10172
|
+
}
|
|
10173
|
+
message.warning('请先选择颜色!');
|
|
10174
|
+
return _context.abrupt("return", false);
|
|
10175
|
+
case 10:
|
|
10176
|
+
if (!(selectItem.dataIndex == 'selectPropertyGroupCode' && tList.some(function (i) {
|
|
10177
|
+
return i[recordKey] == recordItem[recordKey] && i.colorName == recordItem.colorName && i[selectItem.dataIndex] == changeValue;
|
|
10178
|
+
}))) {
|
|
10179
|
+
_context.next = 13;
|
|
10180
|
+
break;
|
|
10181
|
+
}
|
|
10182
|
+
message.warning('相同商品相同颜色配码不可设置相同哦');
|
|
10183
|
+
return _context.abrupt("return", false);
|
|
10184
|
+
case 13:
|
|
10185
|
+
if (!(selectItem.dataIndex == 'selectPropertyGroupCode')) {
|
|
10186
|
+
_context.next = 26;
|
|
10187
|
+
break;
|
|
10188
|
+
}
|
|
10189
|
+
result = true;
|
|
10190
|
+
_context.prev = 15;
|
|
10191
|
+
_context.next = 18;
|
|
10192
|
+
return checkSpuMatchCode({
|
|
10193
|
+
skcCode: recordItem[recordKey],
|
|
10194
|
+
matchingCode: changeValue,
|
|
10195
|
+
ext1: recordItem.colorName
|
|
10196
|
+
});
|
|
10197
|
+
case 18:
|
|
10198
|
+
result = _context.sent;
|
|
10199
|
+
result = true;
|
|
10200
|
+
_context.next = 25;
|
|
10201
|
+
break;
|
|
10202
|
+
case 22:
|
|
10203
|
+
_context.prev = 22;
|
|
10204
|
+
_context.t0 = _context["catch"](15);
|
|
10205
|
+
result = typeof _context.t0 == 'boolean' ? _context.t0 : false;
|
|
10206
|
+
case 25:
|
|
10207
|
+
return _context.abrupt("return", result);
|
|
10208
|
+
case 26:
|
|
10209
|
+
return _context.abrupt("return", true);
|
|
10210
|
+
case 27:
|
|
10211
|
+
case "end":
|
|
10212
|
+
return _context.stop();
|
|
10213
|
+
}
|
|
10214
|
+
}
|
|
10215
|
+
}, _callee, null, [[15, 22]]);
|
|
10216
|
+
}));
|
|
10217
|
+
return function checkSelectChange(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
10218
|
+
return _ref4.apply(this, arguments);
|
|
10219
|
+
};
|
|
10220
|
+
}();
|
|
10221
|
+
var setBusinessDefaultValue = function setBusinessDefaultValue(list, record) {
|
|
10222
|
+
var _record$colorValues;
|
|
10223
|
+
var result = list;
|
|
10224
|
+
if (businessType == 'spu' && (record === null || record === void 0 ? void 0 : (_record$colorValues = record.colorValues) === null || _record$colorValues === void 0 ? void 0 : _record$colorValues.length) == 1) {
|
|
10225
|
+
result = list.map(function (i) {
|
|
10226
|
+
if (i.uuid == (record === null || record === void 0 ? void 0 : record.uuid)) {
|
|
10227
|
+
var _record$colorValues$;
|
|
10228
|
+
i.colorName = (_record$colorValues$ = record.colorValues[0]) === null || _record$colorValues$ === void 0 ? void 0 : _record$colorValues$.value;
|
|
10229
|
+
}
|
|
10230
|
+
return i;
|
|
10231
|
+
});
|
|
10232
|
+
}
|
|
10233
|
+
return result;
|
|
10234
|
+
};
|
|
10124
10235
|
useEffect(function () {
|
|
10125
10236
|
setTableColumns(modalTableProps === null || modalTableProps === void 0 ? void 0 : modalTableProps.tableColumns);
|
|
10126
10237
|
}, [modalTableProps === null || modalTableProps === void 0 ? void 0 : modalTableProps.tableColumns]);
|
|
@@ -10270,40 +10381,55 @@ var AddSelect = function AddSelect(props) {
|
|
|
10270
10381
|
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
10271
10382
|
render: function render(text, record, index) {
|
|
10272
10383
|
var _item$dataSource;
|
|
10273
|
-
if ((_item$dataSource = item.dataSource) === null || _item$dataSource === void 0 ? void 0 : _item$dataSource.length) {
|
|
10384
|
+
if ((item === null || item === void 0 ? void 0 : (_item$dataSource = item.dataSource) === null || _item$dataSource === void 0 ? void 0 : _item$dataSource.length) || (item === null || item === void 0 ? void 0 : item.dataSourceCode)) {
|
|
10385
|
+
var _item$dataSourceMappi, _item$dataSourceMappi2;
|
|
10386
|
+
var dataSourceList = item.dataSource || (record === null || record === void 0 ? void 0 : record[item === null || item === void 0 ? void 0 : item.dataSourceCode]) || [];
|
|
10387
|
+
var selectKey = (item === null || item === void 0 ? void 0 : (_item$dataSourceMappi = item.dataSourceMapping) === null || _item$dataSourceMappi === void 0 ? void 0 : _item$dataSourceMappi[0]) || 'code';
|
|
10388
|
+
var selectText = (item === null || item === void 0 ? void 0 : (_item$dataSourceMappi2 = item.dataSourceMapping) === null || _item$dataSourceMappi2 === void 0 ? void 0 : _item$dataSourceMappi2[1]) || 'name';
|
|
10274
10389
|
return /*#__PURE__*/React.createElement(Select, {
|
|
10275
10390
|
value: text || null,
|
|
10276
|
-
onChange: function
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10391
|
+
onChange: function () {
|
|
10392
|
+
var _onChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(value) {
|
|
10393
|
+
var isConformToTheRules, newPopValue;
|
|
10394
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
10395
|
+
while (1) {
|
|
10396
|
+
switch (_context2.prev = _context2.next) {
|
|
10397
|
+
case 0:
|
|
10398
|
+
_context2.next = 2;
|
|
10399
|
+
return checkSelectChange(businessType, popvalue, mappingValueField, record, item, value);
|
|
10400
|
+
case 2:
|
|
10401
|
+
isConformToTheRules = _context2.sent;
|
|
10402
|
+
if (isConformToTheRules) {
|
|
10403
|
+
record[item.dataIndex] = value;
|
|
10404
|
+
} else {
|
|
10405
|
+
record[item.dataIndex] = null;
|
|
10406
|
+
}
|
|
10407
|
+
newPopValue = popvalue.map(function (i, innerIndex) {
|
|
10408
|
+
if (innerIndex == index) {
|
|
10409
|
+
i[item.dataIndex] = record[item.dataIndex];
|
|
10410
|
+
}
|
|
10411
|
+
return i;
|
|
10412
|
+
});
|
|
10413
|
+
setPopValue(newPopValue);
|
|
10414
|
+
case 6:
|
|
10415
|
+
case "end":
|
|
10416
|
+
return _context2.stop();
|
|
10417
|
+
}
|
|
10285
10418
|
}
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
return
|
|
10419
|
+
}, _callee2);
|
|
10420
|
+
}));
|
|
10421
|
+
function onChange(_x7) {
|
|
10422
|
+
return _onChange.apply(this, arguments);
|
|
10290
10423
|
}
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
if (innerIndex == index) {
|
|
10294
|
-
i[item.dataIndex] = record[item.dataIndex];
|
|
10295
|
-
}
|
|
10296
|
-
return i;
|
|
10297
|
-
});
|
|
10298
|
-
setPopValue(newPopValue);
|
|
10299
|
-
},
|
|
10424
|
+
return onChange;
|
|
10425
|
+
}(),
|
|
10300
10426
|
style: {
|
|
10301
10427
|
width: '160px'
|
|
10302
10428
|
}
|
|
10303
|
-
},
|
|
10429
|
+
}, dataSourceList.map(function (item) {
|
|
10304
10430
|
return /*#__PURE__*/React.createElement(Select.Option, {
|
|
10305
|
-
value: item
|
|
10306
|
-
}, item
|
|
10431
|
+
value: item[selectKey]
|
|
10432
|
+
}, item[selectText]);
|
|
10307
10433
|
}));
|
|
10308
10434
|
}
|
|
10309
10435
|
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
@@ -10432,10 +10558,10 @@ var AddSelect = function AddSelect(props) {
|
|
|
10432
10558
|
currentPage: currentPage
|
|
10433
10559
|
}, otherParams), fixedParam), params);
|
|
10434
10560
|
axios.get("".concat(url, "?").concat(stringify(queryParams))).then(function (result) {
|
|
10435
|
-
var
|
|
10561
|
+
var _result5, _result6;
|
|
10436
10562
|
setFetching(false);
|
|
10437
10563
|
result = result.data;
|
|
10438
|
-
if (((
|
|
10564
|
+
if (((_result5 = result) === null || _result5 === void 0 ? void 0 : _result5.status) && result.status !== '0' || ((_result6 = result) === null || _result6 === void 0 ? void 0 : _result6.code) && result.code !== '000000') {
|
|
10439
10565
|
message.error(result.msg);
|
|
10440
10566
|
return;
|
|
10441
10567
|
}
|
|
@@ -10680,10 +10806,11 @@ var AddSelect = function AddSelect(props) {
|
|
|
10680
10806
|
getData(_objectSpread2(_objectSpread2({}, params), {}, {
|
|
10681
10807
|
pageSize: tableInitPageSize
|
|
10682
10808
|
}), 2);
|
|
10683
|
-
if (selectMode) {
|
|
10684
|
-
|
|
10685
|
-
}
|
|
10809
|
+
// if (selectMode) {
|
|
10810
|
+
// getData(params)
|
|
10811
|
+
// }
|
|
10686
10812
|
};
|
|
10813
|
+
|
|
10687
10814
|
var onResetTable = function onResetTable() {
|
|
10688
10815
|
form.resetFields();
|
|
10689
10816
|
setTableFormParams({});
|
|
@@ -10708,12 +10835,16 @@ var AddSelect = function AddSelect(props) {
|
|
|
10708
10835
|
}
|
|
10709
10836
|
}
|
|
10710
10837
|
if (isAllowRepeatedSelect) {
|
|
10838
|
+
var newUuid = uuid();
|
|
10711
10839
|
var list = popvalue.concat(selectRows).map(function (i) {
|
|
10712
10840
|
return _objectSpread2(_objectSpread2({}, i), {}, {
|
|
10713
|
-
uuid: i.uuid ||
|
|
10841
|
+
uuid: i.uuid || newUuid
|
|
10714
10842
|
});
|
|
10715
10843
|
});
|
|
10716
|
-
|
|
10844
|
+
var recordItem = _objectSpread2(_objectSpread2({}, selectRows[0]), {}, {
|
|
10845
|
+
uuid: newUuid
|
|
10846
|
+
});
|
|
10847
|
+
setPopValue(setBusinessDefaultValue(list, recordItem));
|
|
10717
10848
|
setSelectedRowKeys([]);
|
|
10718
10849
|
} else {
|
|
10719
10850
|
setPopValue(selectRows);
|
|
@@ -10861,8 +10992,8 @@ var AddSelect = function AddSelect(props) {
|
|
|
10861
10992
|
});
|
|
10862
10993
|
}, [tableColumns]);
|
|
10863
10994
|
var handleResize = function handleResize(arr, index, callback) {
|
|
10864
|
-
return function (_,
|
|
10865
|
-
var size =
|
|
10995
|
+
return function (_, _ref5) {
|
|
10996
|
+
var size = _ref5.size;
|
|
10866
10997
|
var newColumns = arr.map(function (col) {
|
|
10867
10998
|
return _objectSpread2({}, col);
|
|
10868
10999
|
});
|
|
@@ -14221,14 +14352,9 @@ var AddSkuSelect = function AddSkuSelect(parProps) {
|
|
|
14221
14352
|
},
|
|
14222
14353
|
beforeShowModal: parProps === null || parProps === void 0 ? void 0 : parProps.beforeShowModal,
|
|
14223
14354
|
onSaveCallback: parProps.onSaveCallback,
|
|
14224
|
-
businessType: 'sku'
|
|
14225
|
-
|
|
14226
|
-
// console.log('save call', rows);
|
|
14227
|
-
// // return Promise.resolve(true);
|
|
14228
|
-
// // return Promise.reject('FAILE')
|
|
14229
|
-
// }
|
|
14355
|
+
businessType: 'sku',
|
|
14356
|
+
isAllowRepeatedSelect: !!(parProps === null || parProps === void 0 ? void 0 : parProps.isAllowRepeatedSelect)
|
|
14230
14357
|
};
|
|
14231
|
-
|
|
14232
14358
|
var modalTableProps = {
|
|
14233
14359
|
modalTableTitle: '选择商品',
|
|
14234
14360
|
tableSearchForm: [{
|
|
@@ -14519,8 +14645,9 @@ var AddSkcSelect = function AddSkcSelect(parProps) {
|
|
|
14519
14645
|
beforeShowModal: parProps === null || parProps === void 0 ? void 0 : parProps.beforeShowModal,
|
|
14520
14646
|
onSaveCallback: parProps.onSaveCallback,
|
|
14521
14647
|
businessType: 'skc',
|
|
14522
|
-
isAllowRepeatedSelect: true
|
|
14648
|
+
isAllowRepeatedSelect: (parProps === null || parProps === void 0 ? void 0 : parProps.isAllowRepeatedSelect) !== undefined ? !!(parProps === null || parProps === void 0 ? void 0 : parProps.isAllowRepeatedSelect) : true // 默认开启一行选多次
|
|
14523
14649
|
};
|
|
14650
|
+
|
|
14524
14651
|
var modalTableProps = {
|
|
14525
14652
|
modalTableTitle: '选择商品',
|
|
14526
14653
|
tableSearchForm: [{
|
|
@@ -14713,6 +14840,25 @@ var AddSpuSelect = function AddSpuSelect(parProps) {
|
|
|
14713
14840
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
14714
14841
|
value = _useState8[0],
|
|
14715
14842
|
setValue = _useState8[1];
|
|
14843
|
+
var _useState9 = useState([]),
|
|
14844
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
14845
|
+
propertyList = _useState10[0],
|
|
14846
|
+
setPropertyList = _useState10[1];
|
|
14847
|
+
useEffect(function () {
|
|
14848
|
+
if (parProps === null || parProps === void 0 ? void 0 : parProps.isSingleColor) {
|
|
14849
|
+
// type: 1 尺码组; 2 配码组
|
|
14850
|
+
axios.get("/items/itemPropertyValueGroup/listNoPage?qp-type-eq=2&qp-status-eq=1").then(function (result) {
|
|
14851
|
+
var _result3, _result4;
|
|
14852
|
+
result = result.data;
|
|
14853
|
+
if (((_result3 = result) === null || _result3 === void 0 ? void 0 : _result3.status) && result.status !== '0' || ((_result4 = result) === null || _result4 === void 0 ? void 0 : _result4.code) && result.code !== '000000') {
|
|
14854
|
+
message.error(result.msg);
|
|
14855
|
+
return;
|
|
14856
|
+
}
|
|
14857
|
+
var data = result.data || [];
|
|
14858
|
+
setPropertyList(data);
|
|
14859
|
+
}).catch(function (err) {});
|
|
14860
|
+
}
|
|
14861
|
+
}, []);
|
|
14716
14862
|
//注⚠️:自定义过表头的请记得传tableCodeList参数
|
|
14717
14863
|
var initialSelectColumn = [{
|
|
14718
14864
|
title: '商品编码',
|
|
@@ -14731,6 +14877,19 @@ var AddSpuSelect = function AddSpuSelect(parProps) {
|
|
|
14731
14877
|
}, text);
|
|
14732
14878
|
},
|
|
14733
14879
|
dataIndex: 'name'
|
|
14880
|
+
}, {
|
|
14881
|
+
title: '颜色',
|
|
14882
|
+
dataIndex: 'colorName',
|
|
14883
|
+
width: 200,
|
|
14884
|
+
isSelectItem: true,
|
|
14885
|
+
dataSourceCode: 'colorValues',
|
|
14886
|
+
dataSourceMapping: ['value', 'value']
|
|
14887
|
+
}, {
|
|
14888
|
+
title: '配码',
|
|
14889
|
+
dataIndex: 'selectPropertyGroupCode',
|
|
14890
|
+
width: 160,
|
|
14891
|
+
isSelectItem: true,
|
|
14892
|
+
dataSource: propertyList
|
|
14734
14893
|
}, {
|
|
14735
14894
|
title: '数量',
|
|
14736
14895
|
width: 100,
|
|
@@ -14773,14 +14932,9 @@ var AddSpuSelect = function AddSpuSelect(parProps) {
|
|
|
14773
14932
|
},
|
|
14774
14933
|
beforeShowModal: parProps === null || parProps === void 0 ? void 0 : parProps.beforeShowModal,
|
|
14775
14934
|
onSaveCallback: parProps.onSaveCallback,
|
|
14776
|
-
businessType: 'spu'
|
|
14777
|
-
|
|
14778
|
-
// console.log('save call', rows);
|
|
14779
|
-
// // return Promise.resolve(true);
|
|
14780
|
-
// // return Promise.reject('FAILE')
|
|
14781
|
-
// }
|
|
14935
|
+
businessType: 'spu',
|
|
14936
|
+
isAllowRepeatedSelect: !!(parProps === null || parProps === void 0 ? void 0 : parProps.isAllowRepeatedSelect)
|
|
14782
14937
|
};
|
|
14783
|
-
|
|
14784
14938
|
var modalTableProps = {
|
|
14785
14939
|
modalTableTitle: '选择商品',
|
|
14786
14940
|
tableSearchForm: [{
|
package/dist/index.js
CHANGED
|
@@ -9899,6 +9899,22 @@ var loadSelectSource = function loadSelectSource(url, params) {
|
|
|
9899
9899
|
});
|
|
9900
9900
|
});
|
|
9901
9901
|
};
|
|
9902
|
+
var checkSpuMatchCode = function checkSpuMatchCode(data) {
|
|
9903
|
+
return new Promise(function (resolve, reject) {
|
|
9904
|
+
axios__default['default'].post("/stock/rwFrontRecordSkcDetail/checkSpuMatchCode", data).then(function (result) {
|
|
9905
|
+
var _result3, _result4;
|
|
9906
|
+
result = result.data;
|
|
9907
|
+
if (((_result3 = result) === null || _result3 === void 0 ? void 0 : _result3.status) && result.status !== '0' || ((_result4 = result) === null || _result4 === void 0 ? void 0 : _result4.code) && result.code !== '000000') {
|
|
9908
|
+
antd.message.error(result.msg);
|
|
9909
|
+
reject(false);
|
|
9910
|
+
return;
|
|
9911
|
+
}
|
|
9912
|
+
resolve(result);
|
|
9913
|
+
}).catch(function (err) {
|
|
9914
|
+
reject(err);
|
|
9915
|
+
});
|
|
9916
|
+
});
|
|
9917
|
+
};
|
|
9902
9918
|
var ResizeableTitle = function ResizeableTitle(props) {
|
|
9903
9919
|
var onResize = props.onResize,
|
|
9904
9920
|
width = props.width,
|
|
@@ -10139,6 +10155,101 @@ var AddSelect = function AddSelect(props) {
|
|
|
10139
10155
|
setShowToChooseColumns = _useState46[1];
|
|
10140
10156
|
var codeToChoose = tableCodeList[0] || initTableCode[businessType][0];
|
|
10141
10157
|
var codeSelected = tableCodeList[1] || initTableCode[businessType][1];
|
|
10158
|
+
var checkSelectChange = /*#__PURE__*/function () {
|
|
10159
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(bType, tList, recordKey, recordItem, selectItem, changeValue) {
|
|
10160
|
+
var result;
|
|
10161
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10162
|
+
while (1) {
|
|
10163
|
+
switch (_context.prev = _context.next) {
|
|
10164
|
+
case 0:
|
|
10165
|
+
if (!(bType == 'skc' && tList.some(function (i) {
|
|
10166
|
+
return i[recordKey] == recordItem[recordKey] && i[selectItem.dataIndex] == changeValue;
|
|
10167
|
+
}))) {
|
|
10168
|
+
_context.next = 3;
|
|
10169
|
+
break;
|
|
10170
|
+
}
|
|
10171
|
+
antd.message.warning('相同skc配码不可设置相同哦');
|
|
10172
|
+
return _context.abrupt("return", false);
|
|
10173
|
+
case 3:
|
|
10174
|
+
if (!(bType == 'spu')) {
|
|
10175
|
+
_context.next = 26;
|
|
10176
|
+
break;
|
|
10177
|
+
}
|
|
10178
|
+
if (!(selectItem.dataIndex == 'colorName' && tList.some(function (i) {
|
|
10179
|
+
return i[recordKey] == recordItem[recordKey] && i.selectPropertyGroupCode == recordItem.selectPropertyGroupCode && i[selectItem.dataIndex] == changeValue;
|
|
10180
|
+
}))) {
|
|
10181
|
+
_context.next = 7;
|
|
10182
|
+
break;
|
|
10183
|
+
}
|
|
10184
|
+
antd.message.warning('相同商品相同配码颜色不可设置相同哦');
|
|
10185
|
+
return _context.abrupt("return", false);
|
|
10186
|
+
case 7:
|
|
10187
|
+
if (!(selectItem.dataIndex == 'selectPropertyGroupCode' && !recordItem.colorName)) {
|
|
10188
|
+
_context.next = 10;
|
|
10189
|
+
break;
|
|
10190
|
+
}
|
|
10191
|
+
antd.message.warning('请先选择颜色!');
|
|
10192
|
+
return _context.abrupt("return", false);
|
|
10193
|
+
case 10:
|
|
10194
|
+
if (!(selectItem.dataIndex == 'selectPropertyGroupCode' && tList.some(function (i) {
|
|
10195
|
+
return i[recordKey] == recordItem[recordKey] && i.colorName == recordItem.colorName && i[selectItem.dataIndex] == changeValue;
|
|
10196
|
+
}))) {
|
|
10197
|
+
_context.next = 13;
|
|
10198
|
+
break;
|
|
10199
|
+
}
|
|
10200
|
+
antd.message.warning('相同商品相同颜色配码不可设置相同哦');
|
|
10201
|
+
return _context.abrupt("return", false);
|
|
10202
|
+
case 13:
|
|
10203
|
+
if (!(selectItem.dataIndex == 'selectPropertyGroupCode')) {
|
|
10204
|
+
_context.next = 26;
|
|
10205
|
+
break;
|
|
10206
|
+
}
|
|
10207
|
+
result = true;
|
|
10208
|
+
_context.prev = 15;
|
|
10209
|
+
_context.next = 18;
|
|
10210
|
+
return checkSpuMatchCode({
|
|
10211
|
+
skcCode: recordItem[recordKey],
|
|
10212
|
+
matchingCode: changeValue,
|
|
10213
|
+
ext1: recordItem.colorName
|
|
10214
|
+
});
|
|
10215
|
+
case 18:
|
|
10216
|
+
result = _context.sent;
|
|
10217
|
+
result = true;
|
|
10218
|
+
_context.next = 25;
|
|
10219
|
+
break;
|
|
10220
|
+
case 22:
|
|
10221
|
+
_context.prev = 22;
|
|
10222
|
+
_context.t0 = _context["catch"](15);
|
|
10223
|
+
result = typeof _context.t0 == 'boolean' ? _context.t0 : false;
|
|
10224
|
+
case 25:
|
|
10225
|
+
return _context.abrupt("return", result);
|
|
10226
|
+
case 26:
|
|
10227
|
+
return _context.abrupt("return", true);
|
|
10228
|
+
case 27:
|
|
10229
|
+
case "end":
|
|
10230
|
+
return _context.stop();
|
|
10231
|
+
}
|
|
10232
|
+
}
|
|
10233
|
+
}, _callee, null, [[15, 22]]);
|
|
10234
|
+
}));
|
|
10235
|
+
return function checkSelectChange(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
10236
|
+
return _ref4.apply(this, arguments);
|
|
10237
|
+
};
|
|
10238
|
+
}();
|
|
10239
|
+
var setBusinessDefaultValue = function setBusinessDefaultValue(list, record) {
|
|
10240
|
+
var _record$colorValues;
|
|
10241
|
+
var result = list;
|
|
10242
|
+
if (businessType == 'spu' && (record === null || record === void 0 ? void 0 : (_record$colorValues = record.colorValues) === null || _record$colorValues === void 0 ? void 0 : _record$colorValues.length) == 1) {
|
|
10243
|
+
result = list.map(function (i) {
|
|
10244
|
+
if (i.uuid == (record === null || record === void 0 ? void 0 : record.uuid)) {
|
|
10245
|
+
var _record$colorValues$;
|
|
10246
|
+
i.colorName = (_record$colorValues$ = record.colorValues[0]) === null || _record$colorValues$ === void 0 ? void 0 : _record$colorValues$.value;
|
|
10247
|
+
}
|
|
10248
|
+
return i;
|
|
10249
|
+
});
|
|
10250
|
+
}
|
|
10251
|
+
return result;
|
|
10252
|
+
};
|
|
10142
10253
|
React.useEffect(function () {
|
|
10143
10254
|
setTableColumns(modalTableProps === null || modalTableProps === void 0 ? void 0 : modalTableProps.tableColumns);
|
|
10144
10255
|
}, [modalTableProps === null || modalTableProps === void 0 ? void 0 : modalTableProps.tableColumns]);
|
|
@@ -10288,40 +10399,55 @@ var AddSelect = function AddSelect(props) {
|
|
|
10288
10399
|
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
10289
10400
|
render: function render(text, record, index) {
|
|
10290
10401
|
var _item$dataSource;
|
|
10291
|
-
if ((_item$dataSource = item.dataSource) === null || _item$dataSource === void 0 ? void 0 : _item$dataSource.length) {
|
|
10402
|
+
if ((item === null || item === void 0 ? void 0 : (_item$dataSource = item.dataSource) === null || _item$dataSource === void 0 ? void 0 : _item$dataSource.length) || (item === null || item === void 0 ? void 0 : item.dataSourceCode)) {
|
|
10403
|
+
var _item$dataSourceMappi, _item$dataSourceMappi2;
|
|
10404
|
+
var dataSourceList = item.dataSource || (record === null || record === void 0 ? void 0 : record[item === null || item === void 0 ? void 0 : item.dataSourceCode]) || [];
|
|
10405
|
+
var selectKey = (item === null || item === void 0 ? void 0 : (_item$dataSourceMappi = item.dataSourceMapping) === null || _item$dataSourceMappi === void 0 ? void 0 : _item$dataSourceMappi[0]) || 'code';
|
|
10406
|
+
var selectText = (item === null || item === void 0 ? void 0 : (_item$dataSourceMappi2 = item.dataSourceMapping) === null || _item$dataSourceMappi2 === void 0 ? void 0 : _item$dataSourceMappi2[1]) || 'name';
|
|
10292
10407
|
return /*#__PURE__*/React__default['default'].createElement(antd.Select, {
|
|
10293
10408
|
value: text || null,
|
|
10294
|
-
onChange: function
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10409
|
+
onChange: function () {
|
|
10410
|
+
var _onChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(value) {
|
|
10411
|
+
var isConformToTheRules, newPopValue;
|
|
10412
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
10413
|
+
while (1) {
|
|
10414
|
+
switch (_context2.prev = _context2.next) {
|
|
10415
|
+
case 0:
|
|
10416
|
+
_context2.next = 2;
|
|
10417
|
+
return checkSelectChange(businessType, popvalue, mappingValueField, record, item, value);
|
|
10418
|
+
case 2:
|
|
10419
|
+
isConformToTheRules = _context2.sent;
|
|
10420
|
+
if (isConformToTheRules) {
|
|
10421
|
+
record[item.dataIndex] = value;
|
|
10422
|
+
} else {
|
|
10423
|
+
record[item.dataIndex] = null;
|
|
10424
|
+
}
|
|
10425
|
+
newPopValue = popvalue.map(function (i, innerIndex) {
|
|
10426
|
+
if (innerIndex == index) {
|
|
10427
|
+
i[item.dataIndex] = record[item.dataIndex];
|
|
10428
|
+
}
|
|
10429
|
+
return i;
|
|
10430
|
+
});
|
|
10431
|
+
setPopValue(newPopValue);
|
|
10432
|
+
case 6:
|
|
10433
|
+
case "end":
|
|
10434
|
+
return _context2.stop();
|
|
10435
|
+
}
|
|
10303
10436
|
}
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
return
|
|
10437
|
+
}, _callee2);
|
|
10438
|
+
}));
|
|
10439
|
+
function onChange(_x7) {
|
|
10440
|
+
return _onChange.apply(this, arguments);
|
|
10308
10441
|
}
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
if (innerIndex == index) {
|
|
10312
|
-
i[item.dataIndex] = record[item.dataIndex];
|
|
10313
|
-
}
|
|
10314
|
-
return i;
|
|
10315
|
-
});
|
|
10316
|
-
setPopValue(newPopValue);
|
|
10317
|
-
},
|
|
10442
|
+
return onChange;
|
|
10443
|
+
}(),
|
|
10318
10444
|
style: {
|
|
10319
10445
|
width: '160px'
|
|
10320
10446
|
}
|
|
10321
|
-
},
|
|
10447
|
+
}, dataSourceList.map(function (item) {
|
|
10322
10448
|
return /*#__PURE__*/React__default['default'].createElement(antd.Select.Option, {
|
|
10323
|
-
value: item
|
|
10324
|
-
}, item
|
|
10449
|
+
value: item[selectKey]
|
|
10450
|
+
}, item[selectText]);
|
|
10325
10451
|
}));
|
|
10326
10452
|
}
|
|
10327
10453
|
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null);
|
|
@@ -10450,10 +10576,10 @@ var AddSelect = function AddSelect(props) {
|
|
|
10450
10576
|
currentPage: currentPage
|
|
10451
10577
|
}, otherParams), fixedParam), params);
|
|
10452
10578
|
axios__default['default'].get("".concat(url, "?").concat(querystring.stringify(queryParams))).then(function (result) {
|
|
10453
|
-
var
|
|
10579
|
+
var _result5, _result6;
|
|
10454
10580
|
setFetching(false);
|
|
10455
10581
|
result = result.data;
|
|
10456
|
-
if (((
|
|
10582
|
+
if (((_result5 = result) === null || _result5 === void 0 ? void 0 : _result5.status) && result.status !== '0' || ((_result6 = result) === null || _result6 === void 0 ? void 0 : _result6.code) && result.code !== '000000') {
|
|
10457
10583
|
antd.message.error(result.msg);
|
|
10458
10584
|
return;
|
|
10459
10585
|
}
|
|
@@ -10698,10 +10824,11 @@ var AddSelect = function AddSelect(props) {
|
|
|
10698
10824
|
getData(_objectSpread2(_objectSpread2({}, params), {}, {
|
|
10699
10825
|
pageSize: tableInitPageSize
|
|
10700
10826
|
}), 2);
|
|
10701
|
-
if (selectMode) {
|
|
10702
|
-
|
|
10703
|
-
}
|
|
10827
|
+
// if (selectMode) {
|
|
10828
|
+
// getData(params)
|
|
10829
|
+
// }
|
|
10704
10830
|
};
|
|
10831
|
+
|
|
10705
10832
|
var onResetTable = function onResetTable() {
|
|
10706
10833
|
form.resetFields();
|
|
10707
10834
|
setTableFormParams({});
|
|
@@ -10726,12 +10853,16 @@ var AddSelect = function AddSelect(props) {
|
|
|
10726
10853
|
}
|
|
10727
10854
|
}
|
|
10728
10855
|
if (isAllowRepeatedSelect) {
|
|
10856
|
+
var newUuid = uuid();
|
|
10729
10857
|
var list = popvalue.concat(selectRows).map(function (i) {
|
|
10730
10858
|
return _objectSpread2(_objectSpread2({}, i), {}, {
|
|
10731
|
-
uuid: i.uuid ||
|
|
10859
|
+
uuid: i.uuid || newUuid
|
|
10732
10860
|
});
|
|
10733
10861
|
});
|
|
10734
|
-
|
|
10862
|
+
var recordItem = _objectSpread2(_objectSpread2({}, selectRows[0]), {}, {
|
|
10863
|
+
uuid: newUuid
|
|
10864
|
+
});
|
|
10865
|
+
setPopValue(setBusinessDefaultValue(list, recordItem));
|
|
10735
10866
|
setSelectedRowKeys([]);
|
|
10736
10867
|
} else {
|
|
10737
10868
|
setPopValue(selectRows);
|
|
@@ -10879,8 +11010,8 @@ var AddSelect = function AddSelect(props) {
|
|
|
10879
11010
|
});
|
|
10880
11011
|
}, [tableColumns]);
|
|
10881
11012
|
var handleResize = function handleResize(arr, index, callback) {
|
|
10882
|
-
return function (_,
|
|
10883
|
-
var size =
|
|
11013
|
+
return function (_, _ref5) {
|
|
11014
|
+
var size = _ref5.size;
|
|
10884
11015
|
var newColumns = arr.map(function (col) {
|
|
10885
11016
|
return _objectSpread2({}, col);
|
|
10886
11017
|
});
|
|
@@ -14239,14 +14370,9 @@ var AddSkuSelect = function AddSkuSelect(parProps) {
|
|
|
14239
14370
|
},
|
|
14240
14371
|
beforeShowModal: parProps === null || parProps === void 0 ? void 0 : parProps.beforeShowModal,
|
|
14241
14372
|
onSaveCallback: parProps.onSaveCallback,
|
|
14242
|
-
businessType: 'sku'
|
|
14243
|
-
|
|
14244
|
-
// console.log('save call', rows);
|
|
14245
|
-
// // return Promise.resolve(true);
|
|
14246
|
-
// // return Promise.reject('FAILE')
|
|
14247
|
-
// }
|
|
14373
|
+
businessType: 'sku',
|
|
14374
|
+
isAllowRepeatedSelect: !!(parProps === null || parProps === void 0 ? void 0 : parProps.isAllowRepeatedSelect)
|
|
14248
14375
|
};
|
|
14249
|
-
|
|
14250
14376
|
var modalTableProps = {
|
|
14251
14377
|
modalTableTitle: '选择商品',
|
|
14252
14378
|
tableSearchForm: [{
|
|
@@ -14537,8 +14663,9 @@ var AddSkcSelect = function AddSkcSelect(parProps) {
|
|
|
14537
14663
|
beforeShowModal: parProps === null || parProps === void 0 ? void 0 : parProps.beforeShowModal,
|
|
14538
14664
|
onSaveCallback: parProps.onSaveCallback,
|
|
14539
14665
|
businessType: 'skc',
|
|
14540
|
-
isAllowRepeatedSelect: true
|
|
14666
|
+
isAllowRepeatedSelect: (parProps === null || parProps === void 0 ? void 0 : parProps.isAllowRepeatedSelect) !== undefined ? !!(parProps === null || parProps === void 0 ? void 0 : parProps.isAllowRepeatedSelect) : true // 默认开启一行选多次
|
|
14541
14667
|
};
|
|
14668
|
+
|
|
14542
14669
|
var modalTableProps = {
|
|
14543
14670
|
modalTableTitle: '选择商品',
|
|
14544
14671
|
tableSearchForm: [{
|
|
@@ -14731,6 +14858,25 @@ var AddSpuSelect = function AddSpuSelect(parProps) {
|
|
|
14731
14858
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
14732
14859
|
value = _useState8[0],
|
|
14733
14860
|
setValue = _useState8[1];
|
|
14861
|
+
var _useState9 = React.useState([]),
|
|
14862
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
14863
|
+
propertyList = _useState10[0],
|
|
14864
|
+
setPropertyList = _useState10[1];
|
|
14865
|
+
React.useEffect(function () {
|
|
14866
|
+
if (parProps === null || parProps === void 0 ? void 0 : parProps.isSingleColor) {
|
|
14867
|
+
// type: 1 尺码组; 2 配码组
|
|
14868
|
+
axios__default['default'].get("/items/itemPropertyValueGroup/listNoPage?qp-type-eq=2&qp-status-eq=1").then(function (result) {
|
|
14869
|
+
var _result3, _result4;
|
|
14870
|
+
result = result.data;
|
|
14871
|
+
if (((_result3 = result) === null || _result3 === void 0 ? void 0 : _result3.status) && result.status !== '0' || ((_result4 = result) === null || _result4 === void 0 ? void 0 : _result4.code) && result.code !== '000000') {
|
|
14872
|
+
antd.message.error(result.msg);
|
|
14873
|
+
return;
|
|
14874
|
+
}
|
|
14875
|
+
var data = result.data || [];
|
|
14876
|
+
setPropertyList(data);
|
|
14877
|
+
}).catch(function (err) {});
|
|
14878
|
+
}
|
|
14879
|
+
}, []);
|
|
14734
14880
|
//注⚠️:自定义过表头的请记得传tableCodeList参数
|
|
14735
14881
|
var initialSelectColumn = [{
|
|
14736
14882
|
title: '商品编码',
|
|
@@ -14749,6 +14895,19 @@ var AddSpuSelect = function AddSpuSelect(parProps) {
|
|
|
14749
14895
|
}, text);
|
|
14750
14896
|
},
|
|
14751
14897
|
dataIndex: 'name'
|
|
14898
|
+
}, {
|
|
14899
|
+
title: '颜色',
|
|
14900
|
+
dataIndex: 'colorName',
|
|
14901
|
+
width: 200,
|
|
14902
|
+
isSelectItem: true,
|
|
14903
|
+
dataSourceCode: 'colorValues',
|
|
14904
|
+
dataSourceMapping: ['value', 'value']
|
|
14905
|
+
}, {
|
|
14906
|
+
title: '配码',
|
|
14907
|
+
dataIndex: 'selectPropertyGroupCode',
|
|
14908
|
+
width: 160,
|
|
14909
|
+
isSelectItem: true,
|
|
14910
|
+
dataSource: propertyList
|
|
14752
14911
|
}, {
|
|
14753
14912
|
title: '数量',
|
|
14754
14913
|
width: 100,
|
|
@@ -14791,14 +14950,9 @@ var AddSpuSelect = function AddSpuSelect(parProps) {
|
|
|
14791
14950
|
},
|
|
14792
14951
|
beforeShowModal: parProps === null || parProps === void 0 ? void 0 : parProps.beforeShowModal,
|
|
14793
14952
|
onSaveCallback: parProps.onSaveCallback,
|
|
14794
|
-
businessType: 'spu'
|
|
14795
|
-
|
|
14796
|
-
// console.log('save call', rows);
|
|
14797
|
-
// // return Promise.resolve(true);
|
|
14798
|
-
// // return Promise.reject('FAILE')
|
|
14799
|
-
// }
|
|
14953
|
+
businessType: 'spu',
|
|
14954
|
+
isAllowRepeatedSelect: !!(parProps === null || parProps === void 0 ? void 0 : parProps.isAllowRepeatedSelect)
|
|
14800
14955
|
};
|
|
14801
|
-
|
|
14802
14956
|
var modalTableProps = {
|
|
14803
14957
|
modalTableTitle: '选择商品',
|
|
14804
14958
|
tableSearchForm: [{
|
package/package.json
CHANGED
|
@@ -76,6 +76,7 @@ export default () => {
|
|
|
76
76
|
const config = {
|
|
77
77
|
buttonText: 'context',
|
|
78
78
|
buttonProps: { disabled: false },
|
|
79
|
+
// isAllowRepeatedSelect: false,
|
|
79
80
|
beforeShowModal: () => {
|
|
80
81
|
return Promise.resolve(true);
|
|
81
82
|
// return Promise.reject('校验有误');
|
|
@@ -108,7 +109,7 @@ export default () => {
|
|
|
108
109
|
const config = {
|
|
109
110
|
buttonText: 'context',
|
|
110
111
|
buttonProps: { disabled: false },
|
|
111
|
-
exceptColumns: ['count', 'categoryText', 'className'],
|
|
112
|
+
exceptColumns: ['colorName','selectPropertyGroupCode','count', 'categoryText', 'className'],
|
|
112
113
|
tableCodeList: [null,'spuSelect-tableSelectedItemPartCode_ItemLabel'],
|
|
113
114
|
beforeShowModal: () => {
|
|
114
115
|
return Promise.resolve(true);
|
|
@@ -127,3 +128,34 @@ export default () => {
|
|
|
127
128
|
);
|
|
128
129
|
};
|
|
129
130
|
```
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import React, { useState } from 'react';
|
|
134
|
+
import { Tabs } from 'antd';
|
|
135
|
+
import { AddSpuSelect } from '../../../index.ts';
|
|
136
|
+
|
|
137
|
+
export default () => {
|
|
138
|
+
const config = {
|
|
139
|
+
buttonText: '添加商品(单色配码)',
|
|
140
|
+
buttonProps: { disabled: false },
|
|
141
|
+
isSingleColor: true,
|
|
142
|
+
isAllowRepeatedSelect: true,
|
|
143
|
+
exceptColumns: ['ownOrgSignName', 'brandName', 'categoryText', 'className'],
|
|
144
|
+
tableCodeList: [null,'spuSelect-tableSelectedItemPartCode_ItemMatchingColor'],
|
|
145
|
+
beforeShowModal: () => {
|
|
146
|
+
return Promise.resolve(true);
|
|
147
|
+
// return Promise.reject('校验有误');
|
|
148
|
+
},
|
|
149
|
+
onSaveCallback: (rows) => {
|
|
150
|
+
console.log('save call', rows);
|
|
151
|
+
return Promise.resolve(true);
|
|
152
|
+
// return Promise.reject('FAILE')
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return (
|
|
156
|
+
<div>
|
|
157
|
+
<AddSpuSelect {...config} />
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
```
|
|
@@ -149,12 +149,8 @@ export const AddSkuSelect = (parProps: any) => {
|
|
|
149
149
|
},
|
|
150
150
|
beforeShowModal: parProps?.beforeShowModal,
|
|
151
151
|
onSaveCallback: parProps.onSaveCallback,
|
|
152
|
-
businessType: 'sku'
|
|
153
|
-
|
|
154
|
-
// console.log('save call', rows);
|
|
155
|
-
// // return Promise.resolve(true);
|
|
156
|
-
// // return Promise.reject('FAILE')
|
|
157
|
-
// }
|
|
152
|
+
businessType: 'sku',
|
|
153
|
+
isAllowRepeatedSelect: !!parProps?.isAllowRepeatedSelect,
|
|
158
154
|
};
|
|
159
155
|
const modalTableProps = {
|
|
160
156
|
modalTableTitle: '选择商品',
|
|
@@ -436,7 +432,7 @@ export const AddSkcSelect = (parProps: any) => {
|
|
|
436
432
|
beforeShowModal: parProps?.beforeShowModal,
|
|
437
433
|
onSaveCallback: parProps.onSaveCallback,
|
|
438
434
|
businessType: 'skc',
|
|
439
|
-
isAllowRepeatedSelect: true
|
|
435
|
+
isAllowRepeatedSelect: parProps?.isAllowRepeatedSelect!==undefined ? !!parProps?.isAllowRepeatedSelect : true, // 默认开启一行选多次
|
|
440
436
|
};
|
|
441
437
|
const modalTableProps = {
|
|
442
438
|
modalTableTitle: '选择商品',
|
|
@@ -608,6 +604,23 @@ export const AddSpuSelect = (parProps: any) => {
|
|
|
608
604
|
mode: 'multiple',
|
|
609
605
|
}
|
|
610
606
|
const [value, setValue] = useState(selectProps?.mode ? [] : null);
|
|
607
|
+
const [propertyList, setPropertyList] = useState([]);
|
|
608
|
+
|
|
609
|
+
useEffect(() => {
|
|
610
|
+
if(parProps?.isSingleColor) {
|
|
611
|
+
// type: 1 尺码组; 2 配码组
|
|
612
|
+
axios.get(`/items/itemPropertyValueGroup/listNoPage?qp-type-eq=2&qp-status-eq=1`).then((result: any) => {
|
|
613
|
+
result = result.data;
|
|
614
|
+
if ((result?.status && result.status !== '0') || (result?.code && result.code !== '000000')) {
|
|
615
|
+
message.error(result.msg);
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
const data = result.data || [];
|
|
619
|
+
setPropertyList(data)
|
|
620
|
+
}).catch((err) => {});
|
|
621
|
+
}
|
|
622
|
+
},[])
|
|
623
|
+
|
|
611
624
|
//注⚠️:自定义过表头的请记得传tableCodeList参数
|
|
612
625
|
const initialSelectColumn = [
|
|
613
626
|
{
|
|
@@ -628,6 +641,21 @@ export const AddSpuSelect = (parProps: any) => {
|
|
|
628
641
|
),
|
|
629
642
|
dataIndex: 'name',
|
|
630
643
|
},
|
|
644
|
+
{
|
|
645
|
+
title: '颜色',
|
|
646
|
+
dataIndex: 'colorName',
|
|
647
|
+
width: 200,
|
|
648
|
+
isSelectItem: true,
|
|
649
|
+
dataSourceCode: 'colorValues',
|
|
650
|
+
dataSourceMapping: ['value', 'value']
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
title: '配码',
|
|
654
|
+
dataIndex: 'selectPropertyGroupCode',
|
|
655
|
+
width: 160,
|
|
656
|
+
isSelectItem: true,
|
|
657
|
+
dataSource: propertyList,
|
|
658
|
+
},
|
|
631
659
|
{
|
|
632
660
|
title: '数量',
|
|
633
661
|
width: 100,
|
|
@@ -677,11 +705,7 @@ export const AddSpuSelect = (parProps: any) => {
|
|
|
677
705
|
beforeShowModal: parProps?.beforeShowModal,
|
|
678
706
|
onSaveCallback: parProps.onSaveCallback,
|
|
679
707
|
businessType: 'spu',
|
|
680
|
-
|
|
681
|
-
// console.log('save call', rows);
|
|
682
|
-
// // return Promise.resolve(true);
|
|
683
|
-
// // return Promise.reject('FAILE')
|
|
684
|
-
// }
|
|
708
|
+
isAllowRepeatedSelect: !!parProps?.isAllowRepeatedSelect,
|
|
685
709
|
};
|
|
686
710
|
const modalTableProps = {
|
|
687
711
|
modalTableTitle: '选择商品',
|
|
@@ -34,6 +34,24 @@ const loadSelectSource = (url: string, params?: any) => {
|
|
|
34
34
|
})
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
const checkSpuMatchCode = (data: any) => {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
axios.post(`/stock/rwFrontRecordSkcDetail/checkSpuMatchCode`,data)
|
|
40
|
+
.then((result: any) => {
|
|
41
|
+
result = result.data;
|
|
42
|
+
if ((result?.status && result.status !== '0') || (result?.code && result.code !== '000000')) {
|
|
43
|
+
message.error(result.msg);
|
|
44
|
+
reject(false);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
resolve(result);
|
|
48
|
+
})
|
|
49
|
+
.catch((err) => {
|
|
50
|
+
reject(err);
|
|
51
|
+
});
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
37
55
|
const ResizeableTitle = (props) => {
|
|
38
56
|
const { onResize, width, ...restProps } = props;
|
|
39
57
|
|
|
@@ -180,6 +198,50 @@ const AddSelect = (props: any) => {
|
|
|
180
198
|
const codeToChoose = tableCodeList[0] || initTableCode[businessType][0];
|
|
181
199
|
const codeSelected = tableCodeList[1] || initTableCode[businessType][1];
|
|
182
200
|
|
|
201
|
+
const checkSelectChange = async (bType: string, tList: any, recordKey: string, recordItem: any, selectItem: any, changeValue: string) => {
|
|
202
|
+
if(bType == 'skc' && tList.some((i: any) => i[recordKey] == recordItem[recordKey] && i[selectItem.dataIndex] == changeValue)) {
|
|
203
|
+
message.warning('相同skc配码不可设置相同哦')
|
|
204
|
+
return false
|
|
205
|
+
}
|
|
206
|
+
if(bType == 'spu') {
|
|
207
|
+
if(selectItem.dataIndex == 'colorName' && tList.some((i: any) => i[recordKey] == recordItem[recordKey] && i.selectPropertyGroupCode == recordItem.selectPropertyGroupCode && i[selectItem.dataIndex] == changeValue)){
|
|
208
|
+
message.warning('相同商品相同配码颜色不可设置相同哦')
|
|
209
|
+
return false
|
|
210
|
+
}
|
|
211
|
+
if(selectItem.dataIndex == 'selectPropertyGroupCode' && !recordItem.colorName) {
|
|
212
|
+
message.warning('请先选择颜色!')
|
|
213
|
+
return false
|
|
214
|
+
}
|
|
215
|
+
if(selectItem.dataIndex == 'selectPropertyGroupCode'&& tList.some((i: any) => i[recordKey] == recordItem[recordKey] && i.colorName == recordItem.colorName && i[selectItem.dataIndex] == changeValue)){
|
|
216
|
+
message.warning('相同商品相同颜色配码不可设置相同哦')
|
|
217
|
+
return false
|
|
218
|
+
}
|
|
219
|
+
if(selectItem.dataIndex == 'selectPropertyGroupCode') {
|
|
220
|
+
let result = true
|
|
221
|
+
try {
|
|
222
|
+
result = await checkSpuMatchCode({ skcCode: recordItem[recordKey], matchingCode: changeValue, ext1: recordItem.colorName });
|
|
223
|
+
result = true
|
|
224
|
+
} catch (e) {
|
|
225
|
+
result = typeof e == 'boolean' ? e : false
|
|
226
|
+
}
|
|
227
|
+
return result
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return true
|
|
231
|
+
}
|
|
232
|
+
const setBusinessDefaultValue = (list: any, record: any) => {
|
|
233
|
+
let result = list;
|
|
234
|
+
if(businessType == 'spu' && record?.colorValues?.length == 1) {
|
|
235
|
+
result = list.map((i: any) => {
|
|
236
|
+
if(i.uuid == record?.uuid) {
|
|
237
|
+
i.colorName = record.colorValues[0]?.value
|
|
238
|
+
}
|
|
239
|
+
return i
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
return result
|
|
243
|
+
}
|
|
244
|
+
|
|
183
245
|
useEffect(() => {
|
|
184
246
|
setTableColumns(modalTableProps?.tableColumns)
|
|
185
247
|
}, [modalTableProps?.tableColumns])
|
|
@@ -324,24 +386,20 @@ const AddSelect = (props: any) => {
|
|
|
324
386
|
return {
|
|
325
387
|
...item,
|
|
326
388
|
render: (text, record, index) => {
|
|
327
|
-
if (item
|
|
389
|
+
if (item?.dataSource?.length || item?.dataSourceCode) {
|
|
390
|
+
const dataSourceList = item.dataSource || record?.[item?.dataSourceCode] || [];
|
|
391
|
+
const selectKey = item?.dataSourceMapping?.[0] || 'code';
|
|
392
|
+
const selectText = item?.dataSourceMapping?.[1] || 'name';
|
|
328
393
|
return (
|
|
329
394
|
<Select
|
|
330
395
|
value={text || null}
|
|
331
|
-
onChange={(value) => {
|
|
332
|
-
|
|
333
|
-
|
|
396
|
+
onChange={async (value) => {
|
|
397
|
+
const isConformToTheRules = await checkSelectChange(businessType,popvalue,mappingValueField,record,item,value)
|
|
398
|
+
if(isConformToTheRules) {
|
|
399
|
+
record[item.dataIndex] = value
|
|
400
|
+
} else {
|
|
334
401
|
record[item.dataIndex] = null;
|
|
335
|
-
const newPopValue = popvalue.map((i: any, innerIndex: number) => {
|
|
336
|
-
if(innerIndex == index) {
|
|
337
|
-
i[item.dataIndex] = record[item.dataIndex]
|
|
338
|
-
}
|
|
339
|
-
return i
|
|
340
|
-
})
|
|
341
|
-
setPopValue(newPopValue)
|
|
342
|
-
return false
|
|
343
402
|
}
|
|
344
|
-
record[item.dataIndex] = value
|
|
345
403
|
const newPopValue = popvalue.map((i: any, innerIndex: number) => {
|
|
346
404
|
if(innerIndex == index) {
|
|
347
405
|
i[item.dataIndex] = record[item.dataIndex]
|
|
@@ -352,8 +410,8 @@ const AddSelect = (props: any) => {
|
|
|
352
410
|
}}
|
|
353
411
|
style={{width: '160px'}}
|
|
354
412
|
>
|
|
355
|
-
{
|
|
356
|
-
return <Select.Option value={item
|
|
413
|
+
{dataSourceList.map((item: any) => {
|
|
414
|
+
return <Select.Option value={item[selectKey]}>{item[selectText]}</Select.Option>
|
|
357
415
|
})}
|
|
358
416
|
</Select>
|
|
359
417
|
)
|
|
@@ -798,9 +856,9 @@ const AddSelect = (props: any) => {
|
|
|
798
856
|
const params = form.getFieldsValue();
|
|
799
857
|
setTableFormParams(params);
|
|
800
858
|
getData({ ...params, pageSize: tableInitPageSize }, 2)
|
|
801
|
-
if (selectMode) {
|
|
802
|
-
|
|
803
|
-
}
|
|
859
|
+
// if (selectMode) {
|
|
860
|
+
// getData(params)
|
|
861
|
+
// }
|
|
804
862
|
}
|
|
805
863
|
|
|
806
864
|
const onResetTable = () => {
|
|
@@ -838,8 +896,10 @@ const AddSelect = (props: any) => {
|
|
|
838
896
|
}
|
|
839
897
|
}
|
|
840
898
|
if(isAllowRepeatedSelect) {
|
|
841
|
-
const
|
|
842
|
-
|
|
899
|
+
const newUuid = uuid();
|
|
900
|
+
const list = popvalue.concat(selectRows).map((i: any) => ({...i, uuid: i.uuid || newUuid}));
|
|
901
|
+
const recordItem = {...selectRows[0], uuid: newUuid }
|
|
902
|
+
setPopValue(setBusinessDefaultValue(list,recordItem));
|
|
843
903
|
setSelectedRowKeys([])
|
|
844
904
|
} else {
|
|
845
905
|
setPopValue(selectRows);
|