ftdsy-attr 2.1.7 → 2.1.9
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/ftdsy-attr.cjs.js +16 -161
- package/dist/ftdsy-attr.cjs.js.map +1 -1
- package/dist/ftdsy-attr.d.ts +3 -8
- package/dist/ftdsy-attr.esm.mjs +9 -161
- package/dist/ftdsy-attr.esm.mjs.map +1 -1
- package/package.json +4 -3
package/dist/ftdsy-attr.cjs.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var axios = require('axios');
|
|
6
|
+
require('@/env');
|
|
7
|
+
var globalThisUtils = require('@/globalThis-utils');
|
|
6
8
|
|
|
7
9
|
function _arrayLikeToArray(r, a) {
|
|
8
10
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -327,7 +329,6 @@ var getPropertyType$9 = function getPropertyType(item) {
|
|
|
327
329
|
return 'input';
|
|
328
330
|
}
|
|
329
331
|
};
|
|
330
|
-
|
|
331
332
|
/**
|
|
332
333
|
* 根据拼多多分类规则与属性,生成自定义 上货属性
|
|
333
334
|
* */
|
|
@@ -342,7 +343,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
342
343
|
property_required: item.required,
|
|
343
344
|
property_name: item.name,
|
|
344
345
|
// 属性名称
|
|
345
|
-
|
|
346
346
|
property_type: getPropertyType$9(item),
|
|
347
347
|
// 控件类型
|
|
348
348
|
property_values: ((_item$values = item.values) === null || _item$values === void 0 ? void 0 : _item$values.map(function (option) {
|
|
@@ -373,7 +373,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
373
373
|
allParentId.push(conditionItem.parent_id);
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
|
-
|
|
377
376
|
// 当前为必填项,添加必填规则
|
|
378
377
|
if (result.property_required) {
|
|
379
378
|
result.rules.push({
|
|
@@ -381,7 +380,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
381
380
|
value: 'true'
|
|
382
381
|
});
|
|
383
382
|
}
|
|
384
|
-
|
|
385
383
|
// 当前为纯文本,添加文本输入最大字符数
|
|
386
384
|
if (result.property_type === 'input' && Number(item.max_value)) {
|
|
387
385
|
result.rules.push({
|
|
@@ -389,7 +387,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
389
387
|
value: item.max_value
|
|
390
388
|
});
|
|
391
389
|
}
|
|
392
|
-
|
|
393
390
|
// 当前为多选,添加多选选项数量规则
|
|
394
391
|
if (result.property_type === 'multiSelect' && item.choose_max_num) {
|
|
395
392
|
result.rules.push({
|
|
@@ -397,7 +394,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
397
394
|
value: String(item.choose_max_num)
|
|
398
395
|
});
|
|
399
396
|
}
|
|
400
|
-
|
|
401
397
|
// 当前为日期,添加日期格式规则 (拼多多日期格式为‘yyyy-MM-dd’, 目前仅发现”生产日期“)
|
|
402
398
|
if (result.property_type === 'date') {
|
|
403
399
|
result.rules.push({
|
|
@@ -405,7 +401,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
405
401
|
value: 'yyyy-MM-dd'
|
|
406
402
|
});
|
|
407
403
|
}
|
|
408
|
-
|
|
409
404
|
// 带单位
|
|
410
405
|
if (result.property_type === 'inputComponent' && item.value_unit && item.value_unit.length > 0) {
|
|
411
406
|
var units = item.value_unit.filter(function (unit) {
|
|
@@ -435,7 +430,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
435
430
|
}
|
|
436
431
|
return result;
|
|
437
432
|
});
|
|
438
|
-
|
|
439
433
|
// 遍历属性列表,根据属性值再检验一遍父属性是否为必填项
|
|
440
434
|
// 拼多多,'男装-短裤-短裤'中‘面料俗称’未非必填,但子项‘材质’为必填,提交数据的时候'面料俗称'也是必填项
|
|
441
435
|
attr.forEach(function (item) {
|
|
@@ -468,7 +462,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
468
462
|
});
|
|
469
463
|
});
|
|
470
464
|
}
|
|
471
|
-
|
|
472
465
|
/* 旧版 */
|
|
473
466
|
// function createCategoryProperties(categoryProperties: any[]): DsyAttr[] {
|
|
474
467
|
//
|
|
@@ -697,7 +690,6 @@ function createCategoryProperties$9(categoryProperties) {
|
|
|
697
690
|
result.property_required = rules.some(function (i) {
|
|
698
691
|
return i.name === 'requiredRule';
|
|
699
692
|
}) || false;
|
|
700
|
-
|
|
701
693
|
// 自定义输入
|
|
702
694
|
result.select_custom = rules.some(function (i) {
|
|
703
695
|
return i.name === 'valueAttributeRule';
|
|
@@ -756,7 +748,6 @@ function createCategoryProperties$9(categoryProperties) {
|
|
|
756
748
|
precision: i.type === 'input' && precision ? Number(precision) : undefined
|
|
757
749
|
});
|
|
758
750
|
});
|
|
759
|
-
|
|
760
751
|
// if (precision && precision !== '') {
|
|
761
752
|
// // 添加精度规则
|
|
762
753
|
// const txt = result.property_component.map(item => {
|
|
@@ -796,7 +787,6 @@ function createCategoryProperties$9(categoryProperties) {
|
|
|
796
787
|
return result;
|
|
797
788
|
});
|
|
798
789
|
}
|
|
799
|
-
|
|
800
790
|
// /* 旧版 */
|
|
801
791
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
802
792
|
//
|
|
@@ -1123,7 +1113,6 @@ function createCategoryProperties$8(categoryProperties) {
|
|
|
1123
1113
|
property_required: item.isRequired,
|
|
1124
1114
|
property_name: item.name,
|
|
1125
1115
|
// 属性名称
|
|
1126
|
-
|
|
1127
1116
|
property_type: getPropertyType$7(item.inputType),
|
|
1128
1117
|
// 控件类型
|
|
1129
1118
|
property_values: item.attrValueList.map(function (i) {
|
|
@@ -1151,7 +1140,6 @@ function createCategoryProperties$8(categoryProperties) {
|
|
|
1151
1140
|
value: 'true'
|
|
1152
1141
|
});
|
|
1153
1142
|
}
|
|
1154
|
-
|
|
1155
1143
|
// 部分类目属性在C店的情况下必填 部分属性则不能使用
|
|
1156
1144
|
if (item.features.findIndex(function (rule) {
|
|
1157
1145
|
return rule.key === 'isCStore' && rule.fvalue === '1';
|
|
@@ -1163,7 +1151,6 @@ function createCategoryProperties$8(categoryProperties) {
|
|
|
1163
1151
|
result.property_required = true;
|
|
1164
1152
|
}
|
|
1165
1153
|
}
|
|
1166
|
-
|
|
1167
1154
|
// 级联选择器需要过滤一遍可选值
|
|
1168
1155
|
if (result.property_type == 'treeSingleSelect') {
|
|
1169
1156
|
// 存在二级属性
|
|
@@ -1268,7 +1255,6 @@ function createCategoryProperties$8(categoryProperties) {
|
|
|
1268
1255
|
return result;
|
|
1269
1256
|
});
|
|
1270
1257
|
}
|
|
1271
|
-
|
|
1272
1258
|
// /* 旧版 */
|
|
1273
1259
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
1274
1260
|
//
|
|
@@ -1526,7 +1512,6 @@ function createCategoryProperties$7(categoryProperties) {
|
|
|
1526
1512
|
select_custom: Boolean(item.diy_type),
|
|
1527
1513
|
has_children: false
|
|
1528
1514
|
};
|
|
1529
|
-
|
|
1530
1515
|
// 必填时 添加规则
|
|
1531
1516
|
if (item.required === 1) result.rules.push({
|
|
1532
1517
|
name: 'requiredRule',
|
|
@@ -1536,7 +1521,6 @@ function createCategoryProperties$7(categoryProperties) {
|
|
|
1536
1521
|
name: 'maxItemsRule',
|
|
1537
1522
|
value: String(item.multi_select_max)
|
|
1538
1523
|
});
|
|
1539
|
-
|
|
1540
1524
|
// 材质(多集合)
|
|
1541
1525
|
if (result.property_type === 'multiComplex') {
|
|
1542
1526
|
result.measure_templates = item.measure_templates;
|
|
@@ -1553,7 +1537,6 @@ function createCategoryProperties$7(categoryProperties) {
|
|
|
1553
1537
|
options: []
|
|
1554
1538
|
}];
|
|
1555
1539
|
}
|
|
1556
|
-
|
|
1557
1540
|
// 输入控件
|
|
1558
1541
|
if (result.property_type === 'inputComponent') {
|
|
1559
1542
|
var _item$measure_templat;
|
|
@@ -1584,7 +1567,6 @@ function createCategoryProperties$7(categoryProperties) {
|
|
|
1584
1567
|
return result;
|
|
1585
1568
|
});
|
|
1586
1569
|
}
|
|
1587
|
-
|
|
1588
1570
|
// /* 旧版 */
|
|
1589
1571
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
1590
1572
|
//
|
|
@@ -1765,7 +1747,6 @@ function createCategoryProperties$6(categoryProperties) {
|
|
|
1765
1747
|
property_required: item.required,
|
|
1766
1748
|
property_name: item.propName,
|
|
1767
1749
|
// 属性名称
|
|
1768
|
-
|
|
1769
1750
|
property_type: getPropertyType$5(item.propInputType),
|
|
1770
1751
|
// 控件类型
|
|
1771
1752
|
select_custom: item.customInput,
|
|
@@ -1783,7 +1764,6 @@ function createCategoryProperties$6(categoryProperties) {
|
|
|
1783
1764
|
name: 'requiredRule',
|
|
1784
1765
|
value: 'true'
|
|
1785
1766
|
});
|
|
1786
|
-
|
|
1787
1767
|
// 携带单位
|
|
1788
1768
|
if ((_item$unitProp = item.unitProp) !== null && _item$unitProp !== void 0 && _item$unitProp.length) {
|
|
1789
1769
|
result.property_type = 'inputComponent';
|
|
@@ -1797,7 +1777,6 @@ function createCategoryProperties$6(categoryProperties) {
|
|
|
1797
1777
|
})
|
|
1798
1778
|
}];
|
|
1799
1779
|
}
|
|
1800
|
-
|
|
1801
1780
|
// 多选框 携带有最大选项数
|
|
1802
1781
|
if (result.property_type === 'multiSelect' && item.propValueMaximum) {
|
|
1803
1782
|
result.rules.push({
|
|
@@ -1808,7 +1787,6 @@ function createCategoryProperties$6(categoryProperties) {
|
|
|
1808
1787
|
return result;
|
|
1809
1788
|
});
|
|
1810
1789
|
}
|
|
1811
|
-
|
|
1812
1790
|
/* 旧版 */
|
|
1813
1791
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
1814
1792
|
//
|
|
@@ -2038,7 +2016,6 @@ function createCategoryProperties$5(categoryProperties) {
|
|
|
2038
2016
|
var result = createCategoryPropertyItem(item);
|
|
2039
2017
|
// 添加属性到属性列表
|
|
2040
2018
|
attrs.push(result);
|
|
2041
|
-
|
|
2042
2019
|
// 检测子属性
|
|
2043
2020
|
if (item.attribute_value_list) {
|
|
2044
2021
|
var _item$attribute_value;
|
|
@@ -2076,7 +2053,6 @@ function createCategoryProperties$5(categoryProperties) {
|
|
|
2076
2053
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2077
2054
|
_loop();
|
|
2078
2055
|
}
|
|
2079
|
-
|
|
2080
2056
|
// console.log(attrs)
|
|
2081
2057
|
} catch (err) {
|
|
2082
2058
|
_iterator.e(err);
|
|
@@ -2095,7 +2071,6 @@ function createCategoryPropertyItem(item) {
|
|
|
2095
2071
|
property_required: item.mandatory,
|
|
2096
2072
|
property_name: (lang === null || lang === void 0 ? void 0 : lang.value) || item.name,
|
|
2097
2073
|
// 属性名称
|
|
2098
|
-
|
|
2099
2074
|
property_type: getPropertyType$4(item.attribute_info.input_type),
|
|
2100
2075
|
// 控件类型
|
|
2101
2076
|
property_values: ((_item$attribute_value2 = item.attribute_value_list) === null || _item$attribute_value2 === void 0 ? void 0 : _item$attribute_value2.map(function (i) {
|
|
@@ -2131,7 +2106,6 @@ function createCategoryPropertyItem(item) {
|
|
|
2131
2106
|
})
|
|
2132
2107
|
});
|
|
2133
2108
|
}
|
|
2134
|
-
|
|
2135
2109
|
// 多选,添加选择数量限制
|
|
2136
2110
|
if (result.property_type === 'multiSelect' && item.attribute_info.max_value_count) {
|
|
2137
2111
|
result.rules.push({
|
|
@@ -2141,7 +2115,6 @@ function createCategoryPropertyItem(item) {
|
|
|
2141
2115
|
}
|
|
2142
2116
|
return result;
|
|
2143
2117
|
}
|
|
2144
|
-
|
|
2145
2118
|
// /* 旧版 */
|
|
2146
2119
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
2147
2120
|
//
|
|
@@ -2277,7 +2250,6 @@ function createCategoryProperties$4(categoryProperties) {
|
|
|
2277
2250
|
property_required: item.isRequired,
|
|
2278
2251
|
property_name: item.name,
|
|
2279
2252
|
// 属性名称
|
|
2280
|
-
|
|
2281
2253
|
property_type: getPropertyType$3(item.inputType),
|
|
2282
2254
|
// 控件类型
|
|
2283
2255
|
select_custom: item.customizable,
|
|
@@ -2291,7 +2263,6 @@ function createCategoryProperties$4(categoryProperties) {
|
|
|
2291
2263
|
rules: [],
|
|
2292
2264
|
has_children: false
|
|
2293
2265
|
};
|
|
2294
|
-
|
|
2295
2266
|
// 官方没给 但提交时只能3个
|
|
2296
2267
|
if (result.property_type === 'multiComplex') result.rules.push({
|
|
2297
2268
|
name: 'maxItemsRule',
|
|
@@ -2300,7 +2271,6 @@ function createCategoryProperties$4(categoryProperties) {
|
|
|
2300
2271
|
return result;
|
|
2301
2272
|
});
|
|
2302
2273
|
}
|
|
2303
|
-
|
|
2304
2274
|
// /* 旧版 */
|
|
2305
2275
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
2306
2276
|
//
|
|
@@ -2485,7 +2455,6 @@ function createCategoryProperties$3(categoryProperties) {
|
|
|
2485
2455
|
return result;
|
|
2486
2456
|
});
|
|
2487
2457
|
}
|
|
2488
|
-
|
|
2489
2458
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
2490
2459
|
//
|
|
2491
2460
|
// const properties: PropertyItem[] = categoryProperties.map(item => {
|
|
@@ -2630,7 +2599,6 @@ function createCategoryProperties$2(categoryProperties) {
|
|
|
2630
2599
|
property_required: item._required,
|
|
2631
2600
|
property_name: item.name,
|
|
2632
2601
|
// 属性名称
|
|
2633
|
-
|
|
2634
2602
|
property_type: getPropertyType$1(item.type_v2),
|
|
2635
2603
|
// 控件类型
|
|
2636
2604
|
property_values: item.value ? item.value.split(';').map(function (i) {
|
|
@@ -2668,7 +2636,6 @@ function createCategoryProperties$2(categoryProperties) {
|
|
|
2668
2636
|
return result;
|
|
2669
2637
|
});
|
|
2670
2638
|
}
|
|
2671
|
-
|
|
2672
2639
|
// /* 旧版 */
|
|
2673
2640
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
2674
2641
|
//
|
|
@@ -2819,7 +2786,6 @@ function getOriginProperty$1(type) {
|
|
|
2819
2786
|
return 'unknown';
|
|
2820
2787
|
}
|
|
2821
2788
|
}
|
|
2822
|
-
|
|
2823
2789
|
/**
|
|
2824
2790
|
* 将Tiktok属性列表 转换自定义属性列表,
|
|
2825
2791
|
* */
|
|
@@ -5671,7 +5637,6 @@ var clothing_children = [{
|
|
|
5671
5637
|
tiktok: '',
|
|
5672
5638
|
tiktokUs: ''
|
|
5673
5639
|
}
|
|
5674
|
-
|
|
5675
5640
|
// {
|
|
5676
5641
|
// title: '童装/婴儿装/亲子装-',
|
|
5677
5642
|
// pdd: '',
|
|
@@ -6911,7 +6876,6 @@ var clothing_underwear = [{
|
|
|
6911
6876
|
}];
|
|
6912
6877
|
|
|
6913
6878
|
// 服饰配件
|
|
6914
|
-
|
|
6915
6879
|
var clothing_accessory = [{
|
|
6916
6880
|
title: '服饰配件-手帕',
|
|
6917
6881
|
pdd: '8699',
|
|
@@ -10311,7 +10275,6 @@ var shoes_women = [{
|
|
|
10311
10275
|
tiktok: '',
|
|
10312
10276
|
tiktokUs: ''
|
|
10313
10277
|
}
|
|
10314
|
-
|
|
10315
10278
|
// {
|
|
10316
10279
|
// title: '',
|
|
10317
10280
|
// pdd: '',
|
|
@@ -11186,7 +11149,6 @@ var shoes_motion = [{
|
|
|
11186
11149
|
tiktok: '',
|
|
11187
11150
|
tiktokUs: ''
|
|
11188
11151
|
}
|
|
11189
|
-
|
|
11190
11152
|
// {
|
|
11191
11153
|
// title: '运动鞋-',
|
|
11192
11154
|
// pdd: '',
|
|
@@ -64693,7 +64655,6 @@ var vehicle_motorcycle = [{
|
|
|
64693
64655
|
* 分类模型,用于匹配分类
|
|
64694
64656
|
* */
|
|
64695
64657
|
var categoryMap = [].concat(_toConsumableArray(clothing_men), _toConsumableArray(clothing_women), _toConsumableArray(clothing_children), _toConsumableArray(clothing_underwear), _toConsumableArray(clothing_accessory), _toConsumableArray(clothing_motion), _toConsumableArray(clothing_jewelry), _toConsumableArray(shoes_men), _toConsumableArray(shoes_women), _toConsumableArray(shoes_children), _toConsumableArray(shoes_motion), _toConsumableArray(bags_leather), _toConsumableArray(bags_motion), _toConsumableArray(motherBaby_gravida), _toConsumableArray(motherBaby_bady), _toConsumableArray(numeral_accessory), _toConsumableArray(numeral_camera), _toConsumableArray(numeral_computer), _toConsumableArray(numeral_smart), _toConsumableArray(numeral_game), _toConsumableArray(sportsOutdoor_outdoors), _toConsumableArray(sportsOutdoor_sports), _toConsumableArray(departmentStore_bedding), _toConsumableArray(departmentStore_flower), _toConsumableArray(departmentStore_homefabric), _toConsumableArray(departmentStore_petanimal), _toConsumableArray(departmentStoreStorage), _toConsumableArray(departmentStoreTableware), _toConsumableArray(departmentStore_holidaysupplies), _toConsumableArray(departmentStore_commodity), _toConsumableArray(vehicle_cycling), _toConsumableArray(vehicle_electricvehicle), _toConsumableArray(vehicle_motorcycle));
|
|
64696
|
-
|
|
64697
64658
|
/**
|
|
64698
64659
|
* 检测获取具体分类,用于判断处理
|
|
64699
64660
|
* @param platform 平台编码
|
|
@@ -64729,7 +64690,6 @@ function perparePropertyGroup(properties) {
|
|
|
64729
64690
|
var propertiesData = {
|
|
64730
64691
|
list: [],
|
|
64731
64692
|
// 正常属性列表(不包含‘品牌’属性)
|
|
64732
|
-
|
|
64733
64693
|
require_total: 0,
|
|
64734
64694
|
// 必填属性总数
|
|
64735
64695
|
require_count: 0,
|
|
@@ -64740,12 +64700,10 @@ function perparePropertyGroup(properties) {
|
|
|
64740
64700
|
// 非必填属性列表
|
|
64741
64701
|
children_list: [],
|
|
64742
64702
|
// 子属性列表
|
|
64743
|
-
|
|
64744
64703
|
brand_property: {},
|
|
64745
64704
|
// '品牌'属性
|
|
64746
64705
|
material_quality_property: {} // ‘材料成分’属性
|
|
64747
64706
|
};
|
|
64748
|
-
|
|
64749
64707
|
//// 第一步,进行数据分组拆分, 拆分出:“品牌”属性,必填属性,非必填属性,子属性, 其中‘材料成分’属性外部登记(方便后期进行检测)
|
|
64750
64708
|
properties.forEach(function (item) {
|
|
64751
64709
|
var attrItem = _objectSpread2(_objectSpread2({}, item), {}, {
|
|
@@ -64780,17 +64738,14 @@ function perparePropertyGroup(properties) {
|
|
|
64780
64738
|
}
|
|
64781
64739
|
}
|
|
64782
64740
|
});
|
|
64783
|
-
|
|
64784
64741
|
//// 第二步,检测是否有子属性,有子属性需添加到 必填列表 与 非必填列表 中
|
|
64785
64742
|
if (propertiesData.children_list.length > 0) {
|
|
64786
64743
|
// 检测到当前有子属性,注意子属性可能存在多条件显示,或者 次级子属性的情况
|
|
64787
|
-
|
|
64788
64744
|
var required_list = [];
|
|
64789
64745
|
var other_list = [];
|
|
64790
64746
|
var children_list = _toConsumableArray(propertiesData.children_list).sort(function (a, b) {
|
|
64791
64747
|
return Number(b.has_children) - Number(a.has_children);
|
|
64792
64748
|
}); // 排序有子属性的排前
|
|
64793
|
-
|
|
64794
64749
|
propertiesData.required_list.forEach(function (item) {
|
|
64795
64750
|
// 遍历,按顺序添加到新列表中
|
|
64796
64751
|
required_list.push(item);
|
|
@@ -64807,7 +64762,6 @@ function perparePropertyGroup(properties) {
|
|
|
64807
64762
|
getChildrenProperty(other_list, item, children_list);
|
|
64808
64763
|
}
|
|
64809
64764
|
});
|
|
64810
|
-
|
|
64811
64765
|
// 将剩余的子属性分别添加到两个列表中
|
|
64812
64766
|
children_list.forEach(function (item) {
|
|
64813
64767
|
if (item.property_required) {
|
|
@@ -64819,12 +64773,10 @@ function perparePropertyGroup(properties) {
|
|
|
64819
64773
|
propertiesData.required_list = required_list;
|
|
64820
64774
|
propertiesData.other_list = other_list;
|
|
64821
64775
|
}
|
|
64822
|
-
|
|
64823
64776
|
//// 第三步,合成完整的列表
|
|
64824
64777
|
propertiesData.list = [].concat(_toConsumableArray(propertiesData.required_list), _toConsumableArray(propertiesData.other_list));
|
|
64825
64778
|
return propertiesData;
|
|
64826
64779
|
}
|
|
64827
|
-
|
|
64828
64780
|
/**
|
|
64829
64781
|
* 第二步,重新将子属性编排入 必填项列表 与 非必填项列表
|
|
64830
64782
|
* */
|
|
@@ -64839,7 +64791,6 @@ function getChildrenProperty(list, parentItem, children_list) {
|
|
|
64839
64791
|
if (childrenItem.show_condition.length === 1) {
|
|
64840
64792
|
// 子属性只有一个显示条件,直接添加
|
|
64841
64793
|
children_list.splice(index, 1); // 移除属性列表
|
|
64842
|
-
|
|
64843
64794
|
childrenItem.property_required = parentItem.property_required; // 子属性设置必选标识
|
|
64844
64795
|
list.push(childrenItem);
|
|
64845
64796
|
// 检测当时子属性是否有再下级子属性
|
|
@@ -65059,7 +65010,6 @@ var model = {
|
|
|
65059
65010
|
},
|
|
65060
65011
|
// {value: ['铜氨丝','铜氨丝(铜氨纤维)'], similarity: 1},
|
|
65061
65012
|
// {value: ['铜氨纤维(铜氨丝)','铜氨丝(铜氨纤维)'], similarity: 1},
|
|
65062
|
-
|
|
65063
65013
|
{
|
|
65064
65014
|
value: ['氨纶', '聚氨酯弹性纤维(氨纶)'],
|
|
65065
65015
|
similarity: 1
|
|
@@ -72686,7 +72636,6 @@ var map = [{
|
|
|
72686
72636
|
}];
|
|
72687
72637
|
var defaultModel = {
|
|
72688
72638
|
map: map
|
|
72689
|
-
|
|
72690
72639
|
// getAttrValue(matchInfo: object, propertyItem) {
|
|
72691
72640
|
//
|
|
72692
72641
|
// let attrDatas = map.find(item => item.attr.includes(propertyItem.property_name))
|
|
@@ -72800,17 +72749,14 @@ function checkValue(value) {
|
|
|
72800
72749
|
if (value === null || value === undefined || value === "") {
|
|
72801
72750
|
return false;
|
|
72802
72751
|
}
|
|
72803
|
-
|
|
72804
72752
|
// 数组类型
|
|
72805
72753
|
if (Array.isArray(value)) {
|
|
72806
72754
|
return value.length > 0;
|
|
72807
72755
|
}
|
|
72808
|
-
|
|
72809
72756
|
// 对象类型
|
|
72810
72757
|
if (_typeof(value) === "object" && value !== null) {
|
|
72811
72758
|
return Object.keys(value).length > 0;
|
|
72812
72759
|
}
|
|
72813
|
-
|
|
72814
72760
|
// 其他类型(数字、布尔值等)视为有效
|
|
72815
72761
|
return true;
|
|
72816
72762
|
} catch (error) {
|
|
@@ -72818,7 +72764,6 @@ function checkValue(value) {
|
|
|
72818
72764
|
return false;
|
|
72819
72765
|
}
|
|
72820
72766
|
}
|
|
72821
|
-
|
|
72822
72767
|
/**
|
|
72823
72768
|
* 获取2个字符串的相似度
|
|
72824
72769
|
* @param {string} str1 字符串1
|
|
@@ -72829,20 +72774,18 @@ function getStringSimilarity(str1, str2) {
|
|
|
72829
72774
|
// 优化点1:避免重复计数
|
|
72830
72775
|
var arr2 = str2.split(''); // 将字符串转为数组便于操作
|
|
72831
72776
|
var sameNum = 0;
|
|
72832
|
-
|
|
72833
72777
|
// 遍历时删除已匹配字符避免重复计数
|
|
72834
72778
|
var _iterator = _createForOfIteratorHelper(str1),
|
|
72835
72779
|
_step;
|
|
72836
72780
|
try {
|
|
72837
72781
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
72838
|
-
var
|
|
72839
|
-
var index = arr2.indexOf(
|
|
72782
|
+
var char = _step.value;
|
|
72783
|
+
var index = arr2.indexOf(char);
|
|
72840
72784
|
if (index !== -1) {
|
|
72841
72785
|
sameNum++;
|
|
72842
72786
|
arr2.splice(index, 1); // 移除已匹配字符
|
|
72843
72787
|
}
|
|
72844
72788
|
}
|
|
72845
|
-
|
|
72846
72789
|
// 优化点2:引入Dice系数计算相似度
|
|
72847
72790
|
} catch (err) {
|
|
72848
72791
|
_iterator.e(err);
|
|
@@ -72850,17 +72793,15 @@ function getStringSimilarity(str1, str2) {
|
|
|
72850
72793
|
_iterator.f();
|
|
72851
72794
|
}
|
|
72852
72795
|
var diceCoefficient = 2 * sameNum / (str1.length + str2.length);
|
|
72853
|
-
|
|
72854
72796
|
// 优化点3:短字符串完全包含时的加权处理
|
|
72855
72797
|
var _ref = str1.length > str2.length ? [str1, str2] : [str2, str1],
|
|
72856
72798
|
_ref2 = _slicedToArray(_ref, 2),
|
|
72857
72799
|
longer = _ref2[0],
|
|
72858
72800
|
shorter = _ref2[1];
|
|
72859
72801
|
var inclusionBonus = 0;
|
|
72860
|
-
|
|
72861
72802
|
// 如果短串是长串的子集则增加匹配度(字符全部包含权重增加)
|
|
72862
|
-
if (shorter.split('').every(function (
|
|
72863
|
-
return longer.includes(
|
|
72803
|
+
if (shorter.split('').every(function (char) {
|
|
72804
|
+
return longer.includes(char);
|
|
72864
72805
|
})) {
|
|
72865
72806
|
inclusionBonus = 0.3 * (shorter.length / longer.length);
|
|
72866
72807
|
// 判断是否字符串完成包含,增加权重
|
|
@@ -72868,16 +72809,13 @@ function getStringSimilarity(str1, str2) {
|
|
|
72868
72809
|
inclusionBonus += 0.2;
|
|
72869
72810
|
}
|
|
72870
72811
|
}
|
|
72871
|
-
|
|
72872
72812
|
// 优化点4:长度差异补偿(短串越接近长串得分越高)
|
|
72873
72813
|
var lengthRatio = shorter.length / longer.length;
|
|
72874
72814
|
var lengthCompensation = 0.2 * lengthRatio;
|
|
72875
|
-
|
|
72876
72815
|
// 最终相似度 = Dice系数 + 包含奖励 + 长度补偿
|
|
72877
72816
|
// 最终相似度不能大于1,方便多选时优先使用完全匹配和模型匹配
|
|
72878
72817
|
return Math.min(diceCoefficient + inclusionBonus + lengthCompensation, 0.99);
|
|
72879
72818
|
}
|
|
72880
|
-
|
|
72881
72819
|
/**
|
|
72882
72820
|
* 判断字符串中是否包含某些字符
|
|
72883
72821
|
*
|
|
@@ -72901,7 +72839,6 @@ function isTextInclude(text, arr) {
|
|
|
72901
72839
|
throw new Error('type 参数错误有误,只能是includeOne或includeAll');
|
|
72902
72840
|
}
|
|
72903
72841
|
}
|
|
72904
|
-
|
|
72905
72842
|
/* 获取当前时间节点 */
|
|
72906
72843
|
function getCurrentTime() {
|
|
72907
72844
|
var date = new Date();
|
|
@@ -72931,7 +72868,6 @@ function getCurrentTime() {
|
|
|
72931
72868
|
lastSeason: lastSeason
|
|
72932
72869
|
};
|
|
72933
72870
|
}
|
|
72934
|
-
|
|
72935
72871
|
/* 数值取随机数,获取指定数字内的随机数 */
|
|
72936
72872
|
function mathRandomNumber(num) {
|
|
72937
72873
|
if (num === 0 || !num) {
|
|
@@ -72980,7 +72916,6 @@ function getAttrDefaultValue(matchInfo, propertyItem) {
|
|
|
72980
72916
|
return undefined;
|
|
72981
72917
|
}
|
|
72982
72918
|
}
|
|
72983
|
-
|
|
72984
72919
|
// 根据属性选项进行预测筛选
|
|
72985
72920
|
var property_values = _toConsumableArray(propertyItem.select_values);
|
|
72986
72921
|
var _loop = function _loop() {
|
|
@@ -72993,7 +72928,6 @@ function getAttrDefaultValue(matchInfo, propertyItem) {
|
|
|
72993
72928
|
// console.log('跳过')
|
|
72994
72929
|
return 0; // continue
|
|
72995
72930
|
}
|
|
72996
|
-
|
|
72997
72931
|
// console.log(fieldValues)
|
|
72998
72932
|
// console.log(property_values)
|
|
72999
72933
|
if (propertyItem.property_type == 'input' || propertyItem.property_type == 'date' || propertyItem.property_type == 'inputComponent') {
|
|
@@ -73027,7 +72961,6 @@ function getAttrDefaultValue(matchInfo, propertyItem) {
|
|
|
73027
72961
|
}
|
|
73028
72962
|
} else {
|
|
73029
72963
|
// 选择单选
|
|
73030
|
-
|
|
73031
72964
|
// 先进行全匹配,匹配成功则直接返回
|
|
73032
72965
|
var valueItem = property_values.find(function (item) {
|
|
73033
72966
|
var result = fieldValues.findIndex(function (fieldValue) {
|
|
@@ -73036,7 +72969,6 @@ function getAttrDefaultValue(matchInfo, propertyItem) {
|
|
|
73036
72969
|
// console.log(item.name, result)
|
|
73037
72970
|
return result !== -1;
|
|
73038
72971
|
});
|
|
73039
|
-
|
|
73040
72972
|
// 如全内容匹配失败,进行内容包含匹配
|
|
73041
72973
|
if (!valueItem) {
|
|
73042
72974
|
valueItem = property_values.find(function (item) {
|
|
@@ -73064,7 +72996,6 @@ function getAttrDefaultValue(matchInfo, propertyItem) {
|
|
|
73064
72996
|
}
|
|
73065
72997
|
return undefined;
|
|
73066
72998
|
}
|
|
73067
|
-
|
|
73068
72999
|
/*
|
|
73069
73000
|
* 获取属性名匹配
|
|
73070
73001
|
* */
|
|
@@ -73073,7 +73004,6 @@ function attrSimilarity(attr_name1, attr_name2) {
|
|
|
73073
73004
|
if (attr_name1 === attr_name2) {
|
|
73074
73005
|
return 1;
|
|
73075
73006
|
}
|
|
73076
|
-
|
|
73077
73007
|
// 属性值互相包含,判断相似度相似
|
|
73078
73008
|
if (attr_name1.includes(attr_name2) || attr_name2.includes(attr_name1)) {
|
|
73079
73009
|
// 根据包含的字数多少判断相似度
|
|
@@ -73082,7 +73012,6 @@ function attrSimilarity(attr_name1, attr_name2) {
|
|
|
73082
73012
|
return similarity;
|
|
73083
73013
|
}
|
|
73084
73014
|
}
|
|
73085
|
-
|
|
73086
73015
|
// 按照模型进行匹配
|
|
73087
73016
|
var attr_map = model.attr_map;
|
|
73088
73017
|
var result = attr_map.find(function (item) {
|
|
@@ -73093,16 +73022,13 @@ function attrSimilarity(attr_name1, attr_name2) {
|
|
|
73093
73022
|
}
|
|
73094
73023
|
return 0;
|
|
73095
73024
|
}
|
|
73096
|
-
|
|
73097
73025
|
/* 获取属性值匹配 */
|
|
73098
73026
|
function attrValueSimilarity(attr, attr_value1, attr_value2) {
|
|
73099
73027
|
var min_similarity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.8;
|
|
73100
73028
|
if (!attr_value1 || !attr_value2) return 0;
|
|
73101
|
-
|
|
73102
73029
|
// 避免数字,导致includes报错
|
|
73103
73030
|
attr_value1 = "".concat(attr_value1);
|
|
73104
73031
|
attr_value2 = "".concat(attr_value2);
|
|
73105
|
-
|
|
73106
73032
|
// 属性值互相包含,判断相似度相似
|
|
73107
73033
|
var similarity = 0;
|
|
73108
73034
|
if (attr_value1.includes(attr_value2) || attr_value2.includes(attr_value1)) {
|
|
@@ -73161,7 +73087,6 @@ function matchPropertyItem(matchInfo, propertyItem) {
|
|
|
73161
73087
|
return;
|
|
73162
73088
|
}
|
|
73163
73089
|
var result = -1;
|
|
73164
|
-
|
|
73165
73090
|
// 第一步,针对特殊的情况进行匹配
|
|
73166
73091
|
if (matchInfo.platform === 'pdd' && propertyItem.property_name === '适用人群') {
|
|
73167
73092
|
// 拼多多的使用人群(建筑工人、医护人员。。。)与 淘宝、抖音的适用人群 匹配
|
|
@@ -73187,7 +73112,6 @@ function matchPropertyItem(matchInfo, propertyItem) {
|
|
|
73187
73112
|
return ['上市年份季节', '上市时节'].includes(item.attr_name);
|
|
73188
73113
|
});
|
|
73189
73114
|
}
|
|
73190
|
-
|
|
73191
73115
|
// 第二步,属性名称完全匹配
|
|
73192
73116
|
if (result === -1) {
|
|
73193
73117
|
result = attrs.findIndex(function (item) {
|
|
@@ -73205,7 +73129,6 @@ function matchPropertyItem(matchInfo, propertyItem) {
|
|
|
73205
73129
|
return;
|
|
73206
73130
|
}
|
|
73207
73131
|
}
|
|
73208
|
-
|
|
73209
73132
|
// 第三步,使用相识度进行匹配
|
|
73210
73133
|
var similarityAttr = [];
|
|
73211
73134
|
attrs.forEach(function (item) {
|
|
@@ -73235,7 +73158,6 @@ function matchPropertyItem(matchInfo, propertyItem) {
|
|
|
73235
73158
|
console.log(e);
|
|
73236
73159
|
}
|
|
73237
73160
|
}
|
|
73238
|
-
|
|
73239
73161
|
/**
|
|
73240
73162
|
* 初始化属性值
|
|
73241
73163
|
* */
|
|
@@ -73251,12 +73173,10 @@ function initPropertyValue(propertyItem) {
|
|
|
73251
73173
|
return '';
|
|
73252
73174
|
}
|
|
73253
73175
|
}
|
|
73254
|
-
|
|
73255
73176
|
/* 材质成分属性列表 */
|
|
73256
73177
|
var materialList = ['材质成分', '面料材质', '面料俗称', '材质', '面料名称', '主面料成分'];
|
|
73257
73178
|
/* 材质含量属性列表 */
|
|
73258
73179
|
var qualityList = ['成分含量', '面料材质成分含量', '面料材质成分含量(%)', '主面料成分的含量', '面料材质含量'];
|
|
73259
|
-
|
|
73260
73180
|
/**
|
|
73261
73181
|
* 进行属性值的匹配
|
|
73262
73182
|
* */
|
|
@@ -73270,7 +73190,6 @@ function matchPropertyValue(matchInfo, propertyItem, attr) {
|
|
|
73270
73190
|
// 参考值为空
|
|
73271
73191
|
return valueItem;
|
|
73272
73192
|
}
|
|
73273
|
-
|
|
73274
73193
|
// 参考值内容
|
|
73275
73194
|
var attr_values = [];
|
|
73276
73195
|
if (Array.isArray(attr.value)) {
|
|
@@ -73295,15 +73214,12 @@ function matchPropertyValue(matchInfo, propertyItem, attr) {
|
|
|
73295
73214
|
});
|
|
73296
73215
|
attr_values = n_attr_values;
|
|
73297
73216
|
}
|
|
73298
|
-
|
|
73299
73217
|
// console.log('匹配属性', propertyItem.property_name, propertyItem.property_type, attr_values
|
|
73300
|
-
|
|
73301
73218
|
if (propertyItem.property_type == 'input' || propertyItem.property_type == 'inputComponent' || propertyItem.property_type == 'date') {
|
|
73302
73219
|
// 输入类属性(纯文本,数值+单位,日期,范围输入)
|
|
73303
73220
|
valueItem = matchInputPropertyValue(matchInfo, propertyItem, attr_values);
|
|
73304
73221
|
} else {
|
|
73305
73222
|
// 选择类属性(单选、多选、组合多选、层级单选)
|
|
73306
|
-
|
|
73307
73223
|
var property_values = _toConsumableArray(propertyItem.select_values);
|
|
73308
73224
|
if (materialList.includes(propertyItem.property_name) || qualityList.includes(propertyItem.property_name)) {
|
|
73309
73225
|
// 匹配 材质成分以及成分含量 内容
|
|
@@ -73326,16 +73242,13 @@ function matchPropertyValue(matchInfo, propertyItem, attr) {
|
|
|
73326
73242
|
}
|
|
73327
73243
|
return valueItem;
|
|
73328
73244
|
}
|
|
73329
|
-
|
|
73330
73245
|
/**
|
|
73331
73246
|
* 特性属性匹配 匹配材质成分 含量,
|
|
73332
73247
|
* · 需要先进行解析在进行匹配
|
|
73333
73248
|
* */
|
|
73334
73249
|
function matchMaterialQualityValue(matchInfo, propertyItem, property_values, attr_values) {
|
|
73335
73250
|
var match_type = materialList.includes(propertyItem.property_name) ? 1 : 2;
|
|
73336
|
-
|
|
73337
73251
|
// console.log('匹配 材质含量类型' + match_type, propertyItem.property_name, attr_values)
|
|
73338
|
-
|
|
73339
73252
|
var material_values = [];
|
|
73340
73253
|
attr_values.forEach(function (item) {
|
|
73341
73254
|
// 优先解析 棉[100%] 棉100% 棉 等格式
|
|
@@ -73351,7 +73264,6 @@ function matchMaterialQualityValue(matchInfo, propertyItem, property_values, att
|
|
|
73351
73264
|
var options = parsePercentageRange(item);
|
|
73352
73265
|
if (options.min === null || options.min === undefined) {
|
|
73353
73266
|
// 范围解析失败,使用其他进行解析
|
|
73354
|
-
|
|
73355
73267
|
var materialOption = parseMaterial(item);
|
|
73356
73268
|
if (materialOption) {
|
|
73357
73269
|
options = {
|
|
@@ -73409,7 +73321,6 @@ function matchMaterialQualityValue(matchInfo, propertyItem, property_values, att
|
|
|
73409
73321
|
// 数值+单位,直接返回数值()
|
|
73410
73322
|
return "".concat(maxPercentage);
|
|
73411
73323
|
}
|
|
73412
|
-
|
|
73413
73324
|
// 处理其他类型
|
|
73414
73325
|
var percentageValue = '';
|
|
73415
73326
|
if (minPercentage < maxPercentage) {
|
|
@@ -73422,7 +73333,6 @@ function matchMaterialQualityValue(matchInfo, propertyItem, property_values, att
|
|
|
73422
73333
|
// 纯文本,直接返回
|
|
73423
73334
|
return percentageValue;
|
|
73424
73335
|
}
|
|
73425
|
-
|
|
73426
73336
|
// 选择,进行处理
|
|
73427
73337
|
var valueItem = property_values.find(function (item) {
|
|
73428
73338
|
return item.name === percentageValue;
|
|
@@ -73434,7 +73344,6 @@ function matchMaterialQualityValue(matchInfo, propertyItem, property_values, att
|
|
|
73434
73344
|
// 未匹配到,拆分处理进行处理
|
|
73435
73345
|
for (var i = 0; i < property_values.length; i++) {
|
|
73436
73346
|
var item = property_values[i];
|
|
73437
|
-
|
|
73438
73347
|
// 解析百分比范围选项
|
|
73439
73348
|
var options = parsePercentageRange(item.name);
|
|
73440
73349
|
if (isMatchNumberRange(minPercentage, maxPercentage, options)) {
|
|
@@ -73450,13 +73359,11 @@ function matchMaterialQualityValue(matchInfo, propertyItem, property_values, att
|
|
|
73450
73359
|
return undefined;
|
|
73451
73360
|
}
|
|
73452
73361
|
}
|
|
73453
|
-
|
|
73454
73362
|
/**
|
|
73455
73363
|
* 匹配输入项
|
|
73456
73364
|
* */
|
|
73457
73365
|
function matchInputPropertyValue(matchInfo, propertyItem, attr_values) {
|
|
73458
73366
|
// console.log(propertyItem.property_name, propertyItem.property_type,attr_values)
|
|
73459
|
-
|
|
73460
73367
|
var valueItem = '';
|
|
73461
73368
|
if (materialList.includes(propertyItem.property_name) || qualityList.includes(propertyItem.property_name)) {
|
|
73462
73369
|
// 匹配 材质成分以及成分含量 内容
|
|
@@ -73506,7 +73413,6 @@ function matchInputPropertyValue(matchInfo, propertyItem, attr_values) {
|
|
|
73506
73413
|
}
|
|
73507
73414
|
}
|
|
73508
73415
|
}
|
|
73509
|
-
|
|
73510
73416
|
// if (propertyItem.property_name.includes('CCC') || propertyItem.property_name.includes('3C')) {
|
|
73511
73417
|
// // 玩具3C认证
|
|
73512
73418
|
// let result = attrs.findIndex(item => item.attr_name.includes('CCC') || item.attr_name.includes('3C'))
|
|
@@ -73517,7 +73423,6 @@ function matchInputPropertyValue(matchInfo, propertyItem, attr_values) {
|
|
|
73517
73423
|
// return goodsAttr.value
|
|
73518
73424
|
// }
|
|
73519
73425
|
// }
|
|
73520
|
-
|
|
73521
73426
|
// if (propertyItem.property_name.includes('型号') && matchInfo.cate_path.includes('3C数码配件')) {
|
|
73522
73427
|
//
|
|
73523
73428
|
// let result = attrs.findIndex(item => item.attr_name.includes('货号'))
|
|
@@ -73531,14 +73436,12 @@ function matchInputPropertyValue(matchInfo, propertyItem, attr_values) {
|
|
|
73531
73436
|
// return goods.goods_sn
|
|
73532
73437
|
// }
|
|
73533
73438
|
// }
|
|
73534
|
-
|
|
73535
73439
|
if (propertyItem.property_type == 'input') {
|
|
73536
73440
|
// 纯文本输入
|
|
73537
73441
|
valueItem = attr_values.join('、');
|
|
73538
73442
|
} else if (propertyItem.property_type === 'inputComponent') ;
|
|
73539
73443
|
return valueItem;
|
|
73540
73444
|
}
|
|
73541
|
-
|
|
73542
73445
|
/**
|
|
73543
73446
|
* 匹配单选项
|
|
73544
73447
|
* */
|
|
@@ -73559,9 +73462,7 @@ function matchSingleSelectPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73559
73462
|
// 有内容,并且相似度大于80%
|
|
73560
73463
|
return valueItem;
|
|
73561
73464
|
}
|
|
73562
|
-
|
|
73563
73465
|
// 没有完全匹配的属性值,开始根据最相似的值进行匹配
|
|
73564
|
-
|
|
73565
73466
|
// 当前属性支持自定义选项,如果筛选的数值小于0.8, 需要创建一个自定义属性
|
|
73566
73467
|
if (propertyItem.select_custom && propertyItem.property_name === '货号') {
|
|
73567
73468
|
// 相似度太小,创建一个自定义属性值
|
|
@@ -73576,7 +73477,6 @@ function matchSingleSelectPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73576
73477
|
}
|
|
73577
73478
|
return valueItem;
|
|
73578
73479
|
}
|
|
73579
|
-
|
|
73580
73480
|
/**
|
|
73581
73481
|
* 匹配常规多选项属性值
|
|
73582
73482
|
* */
|
|
@@ -73599,13 +73499,11 @@ function matchMultiSelectPropertyValue(matchInfo, propertyItem, property_values,
|
|
|
73599
73499
|
}
|
|
73600
73500
|
return valueList;
|
|
73601
73501
|
}
|
|
73602
|
-
|
|
73603
73502
|
/**
|
|
73604
73503
|
* 匹配组合多选项
|
|
73605
73504
|
* */
|
|
73606
73505
|
function matchMultiComplexPropertyValue(matchInfo, propertyItem, property_values, attr_values) {
|
|
73607
73506
|
// console.log('组合多选', propertyItem.property_name, attr_values)
|
|
73608
|
-
|
|
73609
73507
|
// 获取材质 和 成分
|
|
73610
73508
|
var n_attr_values = attr_values.map(function (item) {
|
|
73611
73509
|
var _item;
|
|
@@ -73632,12 +73530,10 @@ function matchMultiComplexPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73632
73530
|
}).filter(function (item) {
|
|
73633
73531
|
return item === null || item === void 0 ? void 0 : item.material;
|
|
73634
73532
|
});
|
|
73635
|
-
|
|
73636
73533
|
// 匹配结果
|
|
73637
73534
|
var valueList = [];
|
|
73638
73535
|
var totalPercentage = 0;
|
|
73639
73536
|
var disableContentNumber = 0;
|
|
73640
|
-
|
|
73641
73537
|
// 根据属性的来源属性值进行属性值匹配
|
|
73642
73538
|
n_attr_values.forEach(function (attrValue) {
|
|
73643
73539
|
// 获取对应的属性值
|
|
@@ -73657,7 +73553,6 @@ function matchMultiComplexPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73657
73553
|
valueList.push(valueItem);
|
|
73658
73554
|
}
|
|
73659
73555
|
});
|
|
73660
|
-
|
|
73661
73556
|
// 当前选项数量超过属性最大选项数量限制
|
|
73662
73557
|
if (propertyItem !== null && propertyItem !== void 0 && propertyItem.select_max_num && valueList.length > propertyItem.select_max_num) {
|
|
73663
73558
|
// 按照相似度进行排序,相似的排最前
|
|
@@ -73677,7 +73572,6 @@ function matchMultiComplexPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73677
73572
|
}
|
|
73678
73573
|
});
|
|
73679
73574
|
}
|
|
73680
|
-
|
|
73681
73575
|
// 整体需填写含量的总数不等于100,进行含量分配处理
|
|
73682
73576
|
if (totalPercentage !== 100 && disableContentNumber < valueList.length) {
|
|
73683
73577
|
// 需要填的成分含量 总数不等于100
|
|
@@ -73703,7 +73597,6 @@ function matchMultiComplexPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73703
73597
|
}
|
|
73704
73598
|
return valueList;
|
|
73705
73599
|
}
|
|
73706
|
-
|
|
73707
73600
|
/**
|
|
73708
73601
|
* 获取数据模型匹配结果
|
|
73709
73602
|
* */
|
|
@@ -73722,7 +73615,6 @@ function modelMatchSimilarityValue(propertyItem, property_values, attrValue) {
|
|
|
73722
73615
|
property_values.splice(valueIndex, 1);
|
|
73723
73616
|
return valueItem;
|
|
73724
73617
|
}
|
|
73725
|
-
|
|
73726
73618
|
// 2.再进行相似度匹配
|
|
73727
73619
|
for (var i = 0; i < property_values.length; i++) {
|
|
73728
73620
|
var _valueItem6;
|
|
@@ -73743,7 +73635,6 @@ function modelMatchSimilarityValue(propertyItem, property_values, attrValue) {
|
|
|
73743
73635
|
}
|
|
73744
73636
|
return valueItem;
|
|
73745
73637
|
}
|
|
73746
|
-
|
|
73747
73638
|
/* 解析内容获取 材质成分 */
|
|
73748
73639
|
function parseMaterial(str) {
|
|
73749
73640
|
var regex = /^([\u4e00-\u9fa5()a-zA-Z0-9\-_]+?)(?:\[?(\d+\.?\d*)%\]?)?$/;
|
|
@@ -73755,14 +73646,11 @@ function parseMaterial(str) {
|
|
|
73755
73646
|
}
|
|
73756
73647
|
return materialInfo;
|
|
73757
73648
|
}
|
|
73758
|
-
|
|
73759
73649
|
/* 解析百分比,获取百分比数值,解析失败返回0 */
|
|
73760
73650
|
function parsePercentage(str) {
|
|
73761
73651
|
if (!str) return 0;
|
|
73762
|
-
|
|
73763
73652
|
// 要求字符串必须以%结尾
|
|
73764
73653
|
if (!str.trim().endsWith('%')) return 0;
|
|
73765
|
-
|
|
73766
73654
|
// 移除所有非数字字符(保留小数点和负号)
|
|
73767
73655
|
var numericString = str.replace(/[^\d.-]/g, '');
|
|
73768
73656
|
// 尝试解析为浮点数
|
|
@@ -73770,7 +73658,6 @@ function parsePercentage(str) {
|
|
|
73770
73658
|
// 返回有效数字或 0
|
|
73771
73659
|
return Number.isNaN(parsedValue) ? 0 : parsedValue;
|
|
73772
73660
|
}
|
|
73773
|
-
|
|
73774
73661
|
/* 解析百分比数值范围 */
|
|
73775
73662
|
function parsePercentageRange(str) {
|
|
73776
73663
|
var itemName = str.replace(/(/g, '(').replace(/)/g, ')').replace(/—/g, '-');
|
|
@@ -73829,21 +73716,17 @@ function parsePercentageRange(str) {
|
|
|
73829
73716
|
}
|
|
73830
73717
|
return optionsItem;
|
|
73831
73718
|
}
|
|
73832
|
-
|
|
73833
73719
|
/* 数值取整,保留小数点后一位 */
|
|
73834
73720
|
function mathRoundNumber(num) {
|
|
73835
73721
|
var number = Number(num);
|
|
73836
73722
|
return Math.round(number * 10) / 10;
|
|
73837
73723
|
}
|
|
73838
|
-
|
|
73839
73724
|
/* 解析匹配数值范围 */
|
|
73840
73725
|
function isMatchNumberRange(userMin, userMax, option) {
|
|
73841
73726
|
// 用户范围完全在选项左侧之外
|
|
73842
73727
|
if (option.min == null || userMax < option.min || userMax === option.min && !option.includeMin) return false;
|
|
73843
|
-
|
|
73844
73728
|
// 用户范围完全在选项右侧之外
|
|
73845
73729
|
if (option.max == null || userMin > option.max || userMin === option.max && !option.includeMax) return false;
|
|
73846
|
-
|
|
73847
73730
|
// 用户范围与选项范围有交集
|
|
73848
73731
|
return true;
|
|
73849
73732
|
}
|
|
@@ -73858,9 +73741,7 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
73858
73741
|
// 使用‘select_values’, 子属性会进行筛选
|
|
73859
73742
|
var property_type = propertyItem.property_type;
|
|
73860
73743
|
var property_values = _toConsumableArray(propertyItem.select_values);
|
|
73861
|
-
|
|
73862
73744
|
//// 1. 优先使用补充数据进行预测,如商品标题,备注,货号
|
|
73863
|
-
|
|
73864
73745
|
var goodsTitle = ((goods === null || goods === void 0 ? void 0 : goods.title) || '') + ((goods === null || goods === void 0 ? void 0 : goods.remark) || '');
|
|
73865
73746
|
// console.log("预测信息 - 商品", goodsTitle, propertyItem.property_name)
|
|
73866
73747
|
if (goodsTitle) {
|
|
@@ -73892,7 +73773,6 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
73892
73773
|
}
|
|
73893
73774
|
return;
|
|
73894
73775
|
}
|
|
73895
|
-
|
|
73896
73776
|
// 通过规格预测
|
|
73897
73777
|
if (goods.specs && goods.specs.length > 0 && ['颜色', '尺码'].includes(propertyItem.property_name)) {
|
|
73898
73778
|
var keys = [];
|
|
@@ -74072,7 +73952,6 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
74072
73952
|
return;
|
|
74073
73953
|
}
|
|
74074
73954
|
}
|
|
74075
|
-
|
|
74076
73955
|
/// 2.根据设定默认值
|
|
74077
73956
|
var defaultItem = getAttrDefaultValue(matchInfo, propertyItem);
|
|
74078
73957
|
if (defaultItem) {
|
|
@@ -74092,9 +73971,7 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
74092
73971
|
}
|
|
74093
73972
|
return;
|
|
74094
73973
|
}
|
|
74095
|
-
|
|
74096
73974
|
/// 3.设置普遍默认值,如:其他,其它,other等
|
|
74097
|
-
|
|
74098
73975
|
if (matchInfo.cate_path.includes('男装') || matchInfo.cate_path.includes('女装') || matchInfo.cate_path.includes('童装')) {
|
|
74099
73976
|
var _result2;
|
|
74100
73977
|
_result2 = property_values.find(function (item) {
|
|
@@ -74125,7 +74002,6 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
74125
74002
|
}
|
|
74126
74003
|
if (matchInfo.platform === 'albb' && ['产地', '服装风格'].includes(propertyItem.property_name) && ['singleSelect', 'multiSelect'].includes(property_type)) {
|
|
74127
74004
|
// 阿里巴巴,部分选项不清楚如何选择,直接随机选
|
|
74128
|
-
|
|
74129
74005
|
var index = mathRandomNumber(property_values.length);
|
|
74130
74006
|
if (index !== -1) {
|
|
74131
74007
|
var _valueItem6 = property_values[index];
|
|
@@ -74138,7 +74014,6 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
74138
74014
|
}
|
|
74139
74015
|
}
|
|
74140
74016
|
}
|
|
74141
|
-
|
|
74142
74017
|
/**
|
|
74143
74018
|
* 根据文本内容信息进行预测
|
|
74144
74019
|
* */
|
|
@@ -74264,7 +74139,7 @@ var fetchWithRetry = /*#__PURE__*/function () {
|
|
|
74264
74139
|
}
|
|
74265
74140
|
}, opt);
|
|
74266
74141
|
_context.n = 1;
|
|
74267
|
-
return axios(postDatas)
|
|
74142
|
+
return axios(postDatas).catch(function (err) {
|
|
74268
74143
|
return err;
|
|
74269
74144
|
});
|
|
74270
74145
|
case 1:
|
|
@@ -74381,7 +74256,6 @@ var getAlibabaItemPublihProps = /*#__PURE__*/function () {
|
|
|
74381
74256
|
var property = {
|
|
74382
74257
|
matchPropertiesValue: matchPropertiesValue
|
|
74383
74258
|
};
|
|
74384
|
-
|
|
74385
74259
|
/**
|
|
74386
74260
|
* 匹配属性值
|
|
74387
74261
|
* */
|
|
@@ -74425,7 +74299,6 @@ function _matchPropertiesValue() {
|
|
|
74425
74299
|
propertiesData.list.forEach(function (propertyItem) {
|
|
74426
74300
|
initMatchProperty(propertyItem);
|
|
74427
74301
|
});
|
|
74428
|
-
|
|
74429
74302
|
// 是否全部匹配完成
|
|
74430
74303
|
matchOver = true; // 已选属性值内容,后续可作为预测的依据之一
|
|
74431
74304
|
selectAttrs = []; // 开始进行模板数据匹配
|
|
@@ -74793,7 +74666,6 @@ function initMatchProperty(propertyItem) {
|
|
|
74793
74666
|
}
|
|
74794
74667
|
});
|
|
74795
74668
|
}
|
|
74796
|
-
|
|
74797
74669
|
/**
|
|
74798
74670
|
* 更新子属性的值,目前仅发现单选有子属性,其他类型暂未发现有子属性
|
|
74799
74671
|
* */
|
|
@@ -74866,7 +74738,6 @@ function _updateChildrenProperty() {
|
|
|
74866
74738
|
childrenList.forEach(function (propertyItem) {
|
|
74867
74739
|
if (childrenItem && childrenItem.property_id === propertyItem.property_id) {
|
|
74868
74740
|
// 当前列表中已经存在子属性,在该子属性下添加显示条件
|
|
74869
|
-
|
|
74870
74741
|
if (conditionItem && conditionItem.parent_value_ids) {
|
|
74871
74742
|
// 当前获取的显示条件,直接添加父属性的选择值
|
|
74872
74743
|
conditionItem.parent_value_ids.push(parentItemValueId);
|
|
@@ -74956,9 +74827,7 @@ var error = {
|
|
|
74956
74827
|
type: '系统报错'
|
|
74957
74828
|
};
|
|
74958
74829
|
}
|
|
74959
|
-
|
|
74960
74830
|
// 自定义错误
|
|
74961
|
-
|
|
74962
74831
|
var code = match[1];
|
|
74963
74832
|
var msg = match[2];
|
|
74964
74833
|
var type = '';
|
|
@@ -74975,24 +74844,6 @@ var error = {
|
|
|
74975
74844
|
}
|
|
74976
74845
|
};
|
|
74977
74846
|
|
|
74978
|
-
// 全局对象 polyfill
|
|
74979
|
-
if (typeof globalThis === 'undefined') {
|
|
74980
|
-
window.globalThis = globalThis;
|
|
74981
|
-
}
|
|
74982
|
-
if (typeof globalThis === 'undefined') {
|
|
74983
|
-
globalThis.global = globalThis;
|
|
74984
|
-
}
|
|
74985
|
-
|
|
74986
|
-
// 确保 globalThis 在非浏览器环境有定义
|
|
74987
|
-
if (typeof globalThis === 'undefined') {
|
|
74988
|
-
globalThis.self = globalThis;
|
|
74989
|
-
}
|
|
74990
|
-
var main = {
|
|
74991
|
-
createCategoryProperties: createCategoryProperties,
|
|
74992
|
-
getOriginProperty: getOriginProperty,
|
|
74993
|
-
matchCategoryProperties: matchCategoryProperties,
|
|
74994
|
-
createCategoryPropertyTemplate: createCategoryPropertyTemplate
|
|
74995
|
-
};
|
|
74996
74847
|
/**
|
|
74997
74848
|
* 转换自定义属性列表,
|
|
74998
74849
|
* */
|
|
@@ -75039,7 +74890,6 @@ function createCategoryProperties(platform, ptAttrs) {
|
|
|
75039
74890
|
return null;
|
|
75040
74891
|
}
|
|
75041
74892
|
}
|
|
75042
|
-
|
|
75043
74893
|
/**
|
|
75044
74894
|
* 自定义属性类型装换回原来的类型
|
|
75045
74895
|
* */
|
|
@@ -75071,7 +74921,6 @@ function getOriginProperty(platform, type) {
|
|
|
75071
74921
|
return '';
|
|
75072
74922
|
}
|
|
75073
74923
|
}
|
|
75074
|
-
|
|
75075
74924
|
/**
|
|
75076
74925
|
* 匹配属性值
|
|
75077
74926
|
* @param matchDatas 匹配数据
|
|
@@ -75134,7 +74983,7 @@ function _matchCategoryProperties() {
|
|
|
75134
74983
|
return _context.a(2, Promise.reject(error.getError('10001-没有检测到属性!')));
|
|
75135
74984
|
case 2:
|
|
75136
74985
|
_context.n = 3;
|
|
75137
|
-
return property.matchPropertiesValue(matchInfo, properties, attrs, goods)
|
|
74986
|
+
return property.matchPropertiesValue(matchInfo, properties, attrs, goods).catch(function (err) {
|
|
75138
74987
|
if (err instanceof Error) {
|
|
75139
74988
|
return Promise.reject(error.getError(err.message));
|
|
75140
74989
|
}
|
|
@@ -75200,7 +75049,6 @@ function _matchCategoryProperties() {
|
|
|
75200
75049
|
}));
|
|
75201
75050
|
return _matchCategoryProperties.apply(this, arguments);
|
|
75202
75051
|
}
|
|
75203
|
-
|
|
75204
75052
|
/**
|
|
75205
75053
|
* 创建分类属性模板
|
|
75206
75054
|
*
|
|
@@ -75243,5 +75091,12 @@ function createCategoryPropertyTemplate(properties) {
|
|
|
75243
75091
|
return attrs;
|
|
75244
75092
|
}
|
|
75245
75093
|
|
|
75246
|
-
|
|
75094
|
+
Object.defineProperty(exports, "getGlobal", {
|
|
75095
|
+
enumerable: true,
|
|
75096
|
+
get: function () { return globalThisUtils.getGlobal; }
|
|
75097
|
+
});
|
|
75098
|
+
exports.createCategoryProperties = createCategoryProperties;
|
|
75099
|
+
exports.createCategoryPropertyTemplate = createCategoryPropertyTemplate;
|
|
75100
|
+
exports.getOriginProperty = getOriginProperty;
|
|
75101
|
+
exports.matchCategoryProperties = matchCategoryProperties;
|
|
75247
75102
|
//# sourceMappingURL=ftdsy-attr.cjs.js.map
|