ftdsy-attr 2.1.8 → 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 -182
- package/dist/ftdsy-attr.cjs.js.map +1 -1
- package/dist/ftdsy-attr.d.ts +3 -9
- package/dist/ftdsy-attr.esm.mjs +9 -179
- package/dist/ftdsy-attr.esm.mjs.map +1 -1
- package/package.json +4 -3
package/dist/ftdsy-attr.esm.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document);
|
|
3
3
|
import axios from 'axios';
|
|
4
|
+
import '@/env';
|
|
5
|
+
export { getGlobal } from '@/globalThis-utils';
|
|
4
6
|
|
|
5
7
|
function _arrayLikeToArray(r, a) {
|
|
6
8
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -325,7 +327,6 @@ var getPropertyType$9 = function getPropertyType(item) {
|
|
|
325
327
|
return 'input';
|
|
326
328
|
}
|
|
327
329
|
};
|
|
328
|
-
|
|
329
330
|
/**
|
|
330
331
|
* 根据拼多多分类规则与属性,生成自定义 上货属性
|
|
331
332
|
* */
|
|
@@ -340,7 +341,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
340
341
|
property_required: item.required,
|
|
341
342
|
property_name: item.name,
|
|
342
343
|
// 属性名称
|
|
343
|
-
|
|
344
344
|
property_type: getPropertyType$9(item),
|
|
345
345
|
// 控件类型
|
|
346
346
|
property_values: ((_item$values = item.values) === null || _item$values === void 0 ? void 0 : _item$values.map(function (option) {
|
|
@@ -371,7 +371,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
371
371
|
allParentId.push(conditionItem.parent_id);
|
|
372
372
|
});
|
|
373
373
|
}
|
|
374
|
-
|
|
375
374
|
// 当前为必填项,添加必填规则
|
|
376
375
|
if (result.property_required) {
|
|
377
376
|
result.rules.push({
|
|
@@ -379,7 +378,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
379
378
|
value: 'true'
|
|
380
379
|
});
|
|
381
380
|
}
|
|
382
|
-
|
|
383
381
|
// 当前为纯文本,添加文本输入最大字符数
|
|
384
382
|
if (result.property_type === 'input' && Number(item.max_value)) {
|
|
385
383
|
result.rules.push({
|
|
@@ -387,7 +385,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
387
385
|
value: item.max_value
|
|
388
386
|
});
|
|
389
387
|
}
|
|
390
|
-
|
|
391
388
|
// 当前为多选,添加多选选项数量规则
|
|
392
389
|
if (result.property_type === 'multiSelect' && item.choose_max_num) {
|
|
393
390
|
result.rules.push({
|
|
@@ -395,7 +392,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
395
392
|
value: String(item.choose_max_num)
|
|
396
393
|
});
|
|
397
394
|
}
|
|
398
|
-
|
|
399
395
|
// 当前为日期,添加日期格式规则 (拼多多日期格式为‘yyyy-MM-dd’, 目前仅发现”生产日期“)
|
|
400
396
|
if (result.property_type === 'date') {
|
|
401
397
|
result.rules.push({
|
|
@@ -403,7 +399,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
403
399
|
value: 'yyyy-MM-dd'
|
|
404
400
|
});
|
|
405
401
|
}
|
|
406
|
-
|
|
407
402
|
// 带单位
|
|
408
403
|
if (result.property_type === 'inputComponent' && item.value_unit && item.value_unit.length > 0) {
|
|
409
404
|
var units = item.value_unit.filter(function (unit) {
|
|
@@ -433,7 +428,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
433
428
|
}
|
|
434
429
|
return result;
|
|
435
430
|
});
|
|
436
|
-
|
|
437
431
|
// 遍历属性列表,根据属性值再检验一遍父属性是否为必填项
|
|
438
432
|
// 拼多多,'男装-短裤-短裤'中‘面料俗称’未非必填,但子项‘材质’为必填,提交数据的时候'面料俗称'也是必填项
|
|
439
433
|
attr.forEach(function (item) {
|
|
@@ -466,7 +460,6 @@ function createCategoryProperties$a(categoryProperties) {
|
|
|
466
460
|
});
|
|
467
461
|
});
|
|
468
462
|
}
|
|
469
|
-
|
|
470
463
|
/* 旧版 */
|
|
471
464
|
// function createCategoryProperties(categoryProperties: any[]): DsyAttr[] {
|
|
472
465
|
//
|
|
@@ -695,7 +688,6 @@ function createCategoryProperties$9(categoryProperties) {
|
|
|
695
688
|
result.property_required = rules.some(function (i) {
|
|
696
689
|
return i.name === 'requiredRule';
|
|
697
690
|
}) || false;
|
|
698
|
-
|
|
699
691
|
// 自定义输入
|
|
700
692
|
result.select_custom = rules.some(function (i) {
|
|
701
693
|
return i.name === 'valueAttributeRule';
|
|
@@ -754,7 +746,6 @@ function createCategoryProperties$9(categoryProperties) {
|
|
|
754
746
|
precision: i.type === 'input' && precision ? Number(precision) : undefined
|
|
755
747
|
});
|
|
756
748
|
});
|
|
757
|
-
|
|
758
749
|
// if (precision && precision !== '') {
|
|
759
750
|
// // 添加精度规则
|
|
760
751
|
// const txt = result.property_component.map(item => {
|
|
@@ -794,7 +785,6 @@ function createCategoryProperties$9(categoryProperties) {
|
|
|
794
785
|
return result;
|
|
795
786
|
});
|
|
796
787
|
}
|
|
797
|
-
|
|
798
788
|
// /* 旧版 */
|
|
799
789
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
800
790
|
//
|
|
@@ -1121,7 +1111,6 @@ function createCategoryProperties$8(categoryProperties) {
|
|
|
1121
1111
|
property_required: item.isRequired,
|
|
1122
1112
|
property_name: item.name,
|
|
1123
1113
|
// 属性名称
|
|
1124
|
-
|
|
1125
1114
|
property_type: getPropertyType$7(item.inputType),
|
|
1126
1115
|
// 控件类型
|
|
1127
1116
|
property_values: item.attrValueList.map(function (i) {
|
|
@@ -1149,7 +1138,6 @@ function createCategoryProperties$8(categoryProperties) {
|
|
|
1149
1138
|
value: 'true'
|
|
1150
1139
|
});
|
|
1151
1140
|
}
|
|
1152
|
-
|
|
1153
1141
|
// 部分类目属性在C店的情况下必填 部分属性则不能使用
|
|
1154
1142
|
if (item.features.findIndex(function (rule) {
|
|
1155
1143
|
return rule.key === 'isCStore' && rule.fvalue === '1';
|
|
@@ -1161,7 +1149,6 @@ function createCategoryProperties$8(categoryProperties) {
|
|
|
1161
1149
|
result.property_required = true;
|
|
1162
1150
|
}
|
|
1163
1151
|
}
|
|
1164
|
-
|
|
1165
1152
|
// 级联选择器需要过滤一遍可选值
|
|
1166
1153
|
if (result.property_type == 'treeSingleSelect') {
|
|
1167
1154
|
// 存在二级属性
|
|
@@ -1266,7 +1253,6 @@ function createCategoryProperties$8(categoryProperties) {
|
|
|
1266
1253
|
return result;
|
|
1267
1254
|
});
|
|
1268
1255
|
}
|
|
1269
|
-
|
|
1270
1256
|
// /* 旧版 */
|
|
1271
1257
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
1272
1258
|
//
|
|
@@ -1524,7 +1510,6 @@ function createCategoryProperties$7(categoryProperties) {
|
|
|
1524
1510
|
select_custom: Boolean(item.diy_type),
|
|
1525
1511
|
has_children: false
|
|
1526
1512
|
};
|
|
1527
|
-
|
|
1528
1513
|
// 必填时 添加规则
|
|
1529
1514
|
if (item.required === 1) result.rules.push({
|
|
1530
1515
|
name: 'requiredRule',
|
|
@@ -1534,7 +1519,6 @@ function createCategoryProperties$7(categoryProperties) {
|
|
|
1534
1519
|
name: 'maxItemsRule',
|
|
1535
1520
|
value: String(item.multi_select_max)
|
|
1536
1521
|
});
|
|
1537
|
-
|
|
1538
1522
|
// 材质(多集合)
|
|
1539
1523
|
if (result.property_type === 'multiComplex') {
|
|
1540
1524
|
result.measure_templates = item.measure_templates;
|
|
@@ -1551,7 +1535,6 @@ function createCategoryProperties$7(categoryProperties) {
|
|
|
1551
1535
|
options: []
|
|
1552
1536
|
}];
|
|
1553
1537
|
}
|
|
1554
|
-
|
|
1555
1538
|
// 输入控件
|
|
1556
1539
|
if (result.property_type === 'inputComponent') {
|
|
1557
1540
|
var _item$measure_templat;
|
|
@@ -1582,7 +1565,6 @@ function createCategoryProperties$7(categoryProperties) {
|
|
|
1582
1565
|
return result;
|
|
1583
1566
|
});
|
|
1584
1567
|
}
|
|
1585
|
-
|
|
1586
1568
|
// /* 旧版 */
|
|
1587
1569
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
1588
1570
|
//
|
|
@@ -1763,7 +1745,6 @@ function createCategoryProperties$6(categoryProperties) {
|
|
|
1763
1745
|
property_required: item.required,
|
|
1764
1746
|
property_name: item.propName,
|
|
1765
1747
|
// 属性名称
|
|
1766
|
-
|
|
1767
1748
|
property_type: getPropertyType$5(item.propInputType),
|
|
1768
1749
|
// 控件类型
|
|
1769
1750
|
select_custom: item.customInput,
|
|
@@ -1781,7 +1762,6 @@ function createCategoryProperties$6(categoryProperties) {
|
|
|
1781
1762
|
name: 'requiredRule',
|
|
1782
1763
|
value: 'true'
|
|
1783
1764
|
});
|
|
1784
|
-
|
|
1785
1765
|
// 携带单位
|
|
1786
1766
|
if ((_item$unitProp = item.unitProp) !== null && _item$unitProp !== void 0 && _item$unitProp.length) {
|
|
1787
1767
|
result.property_type = 'inputComponent';
|
|
@@ -1795,7 +1775,6 @@ function createCategoryProperties$6(categoryProperties) {
|
|
|
1795
1775
|
})
|
|
1796
1776
|
}];
|
|
1797
1777
|
}
|
|
1798
|
-
|
|
1799
1778
|
// 多选框 携带有最大选项数
|
|
1800
1779
|
if (result.property_type === 'multiSelect' && item.propValueMaximum) {
|
|
1801
1780
|
result.rules.push({
|
|
@@ -1806,7 +1785,6 @@ function createCategoryProperties$6(categoryProperties) {
|
|
|
1806
1785
|
return result;
|
|
1807
1786
|
});
|
|
1808
1787
|
}
|
|
1809
|
-
|
|
1810
1788
|
/* 旧版 */
|
|
1811
1789
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
1812
1790
|
//
|
|
@@ -2036,7 +2014,6 @@ function createCategoryProperties$5(categoryProperties) {
|
|
|
2036
2014
|
var result = createCategoryPropertyItem(item);
|
|
2037
2015
|
// 添加属性到属性列表
|
|
2038
2016
|
attrs.push(result);
|
|
2039
|
-
|
|
2040
2017
|
// 检测子属性
|
|
2041
2018
|
if (item.attribute_value_list) {
|
|
2042
2019
|
var _item$attribute_value;
|
|
@@ -2074,7 +2051,6 @@ function createCategoryProperties$5(categoryProperties) {
|
|
|
2074
2051
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2075
2052
|
_loop();
|
|
2076
2053
|
}
|
|
2077
|
-
|
|
2078
2054
|
// console.log(attrs)
|
|
2079
2055
|
} catch (err) {
|
|
2080
2056
|
_iterator.e(err);
|
|
@@ -2093,7 +2069,6 @@ function createCategoryPropertyItem(item) {
|
|
|
2093
2069
|
property_required: item.mandatory,
|
|
2094
2070
|
property_name: (lang === null || lang === void 0 ? void 0 : lang.value) || item.name,
|
|
2095
2071
|
// 属性名称
|
|
2096
|
-
|
|
2097
2072
|
property_type: getPropertyType$4(item.attribute_info.input_type),
|
|
2098
2073
|
// 控件类型
|
|
2099
2074
|
property_values: ((_item$attribute_value2 = item.attribute_value_list) === null || _item$attribute_value2 === void 0 ? void 0 : _item$attribute_value2.map(function (i) {
|
|
@@ -2129,7 +2104,6 @@ function createCategoryPropertyItem(item) {
|
|
|
2129
2104
|
})
|
|
2130
2105
|
});
|
|
2131
2106
|
}
|
|
2132
|
-
|
|
2133
2107
|
// 多选,添加选择数量限制
|
|
2134
2108
|
if (result.property_type === 'multiSelect' && item.attribute_info.max_value_count) {
|
|
2135
2109
|
result.rules.push({
|
|
@@ -2139,7 +2113,6 @@ function createCategoryPropertyItem(item) {
|
|
|
2139
2113
|
}
|
|
2140
2114
|
return result;
|
|
2141
2115
|
}
|
|
2142
|
-
|
|
2143
2116
|
// /* 旧版 */
|
|
2144
2117
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
2145
2118
|
//
|
|
@@ -2275,7 +2248,6 @@ function createCategoryProperties$4(categoryProperties) {
|
|
|
2275
2248
|
property_required: item.isRequired,
|
|
2276
2249
|
property_name: item.name,
|
|
2277
2250
|
// 属性名称
|
|
2278
|
-
|
|
2279
2251
|
property_type: getPropertyType$3(item.inputType),
|
|
2280
2252
|
// 控件类型
|
|
2281
2253
|
select_custom: item.customizable,
|
|
@@ -2289,7 +2261,6 @@ function createCategoryProperties$4(categoryProperties) {
|
|
|
2289
2261
|
rules: [],
|
|
2290
2262
|
has_children: false
|
|
2291
2263
|
};
|
|
2292
|
-
|
|
2293
2264
|
// 官方没给 但提交时只能3个
|
|
2294
2265
|
if (result.property_type === 'multiComplex') result.rules.push({
|
|
2295
2266
|
name: 'maxItemsRule',
|
|
@@ -2298,7 +2269,6 @@ function createCategoryProperties$4(categoryProperties) {
|
|
|
2298
2269
|
return result;
|
|
2299
2270
|
});
|
|
2300
2271
|
}
|
|
2301
|
-
|
|
2302
2272
|
// /* 旧版 */
|
|
2303
2273
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
2304
2274
|
//
|
|
@@ -2483,7 +2453,6 @@ function createCategoryProperties$3(categoryProperties) {
|
|
|
2483
2453
|
return result;
|
|
2484
2454
|
});
|
|
2485
2455
|
}
|
|
2486
|
-
|
|
2487
2456
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
2488
2457
|
//
|
|
2489
2458
|
// const properties: PropertyItem[] = categoryProperties.map(item => {
|
|
@@ -2628,7 +2597,6 @@ function createCategoryProperties$2(categoryProperties) {
|
|
|
2628
2597
|
property_required: item._required,
|
|
2629
2598
|
property_name: item.name,
|
|
2630
2599
|
// 属性名称
|
|
2631
|
-
|
|
2632
2600
|
property_type: getPropertyType$1(item.type_v2),
|
|
2633
2601
|
// 控件类型
|
|
2634
2602
|
property_values: item.value ? item.value.split(';').map(function (i) {
|
|
@@ -2666,7 +2634,6 @@ function createCategoryProperties$2(categoryProperties) {
|
|
|
2666
2634
|
return result;
|
|
2667
2635
|
});
|
|
2668
2636
|
}
|
|
2669
|
-
|
|
2670
2637
|
// /* 旧版 */
|
|
2671
2638
|
// function createCategoryProperties(categoryProperties: any[]): PropertyItem[] {
|
|
2672
2639
|
//
|
|
@@ -2817,7 +2784,6 @@ function getOriginProperty$1(type) {
|
|
|
2817
2784
|
return 'unknown';
|
|
2818
2785
|
}
|
|
2819
2786
|
}
|
|
2820
|
-
|
|
2821
2787
|
/**
|
|
2822
2788
|
* 将Tiktok属性列表 转换自定义属性列表,
|
|
2823
2789
|
* */
|
|
@@ -5669,7 +5635,6 @@ var clothing_children = [{
|
|
|
5669
5635
|
tiktok: '',
|
|
5670
5636
|
tiktokUs: ''
|
|
5671
5637
|
}
|
|
5672
|
-
|
|
5673
5638
|
// {
|
|
5674
5639
|
// title: '童装/婴儿装/亲子装-',
|
|
5675
5640
|
// pdd: '',
|
|
@@ -6909,7 +6874,6 @@ var clothing_underwear = [{
|
|
|
6909
6874
|
}];
|
|
6910
6875
|
|
|
6911
6876
|
// 服饰配件
|
|
6912
|
-
|
|
6913
6877
|
var clothing_accessory = [{
|
|
6914
6878
|
title: '服饰配件-手帕',
|
|
6915
6879
|
pdd: '8699',
|
|
@@ -10309,7 +10273,6 @@ var shoes_women = [{
|
|
|
10309
10273
|
tiktok: '',
|
|
10310
10274
|
tiktokUs: ''
|
|
10311
10275
|
}
|
|
10312
|
-
|
|
10313
10276
|
// {
|
|
10314
10277
|
// title: '',
|
|
10315
10278
|
// pdd: '',
|
|
@@ -11184,7 +11147,6 @@ var shoes_motion = [{
|
|
|
11184
11147
|
tiktok: '',
|
|
11185
11148
|
tiktokUs: ''
|
|
11186
11149
|
}
|
|
11187
|
-
|
|
11188
11150
|
// {
|
|
11189
11151
|
// title: '运动鞋-',
|
|
11190
11152
|
// pdd: '',
|
|
@@ -64691,7 +64653,6 @@ var vehicle_motorcycle = [{
|
|
|
64691
64653
|
* 分类模型,用于匹配分类
|
|
64692
64654
|
* */
|
|
64693
64655
|
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));
|
|
64694
|
-
|
|
64695
64656
|
/**
|
|
64696
64657
|
* 检测获取具体分类,用于判断处理
|
|
64697
64658
|
* @param platform 平台编码
|
|
@@ -64727,7 +64688,6 @@ function perparePropertyGroup(properties) {
|
|
|
64727
64688
|
var propertiesData = {
|
|
64728
64689
|
list: [],
|
|
64729
64690
|
// 正常属性列表(不包含‘品牌’属性)
|
|
64730
|
-
|
|
64731
64691
|
require_total: 0,
|
|
64732
64692
|
// 必填属性总数
|
|
64733
64693
|
require_count: 0,
|
|
@@ -64738,12 +64698,10 @@ function perparePropertyGroup(properties) {
|
|
|
64738
64698
|
// 非必填属性列表
|
|
64739
64699
|
children_list: [],
|
|
64740
64700
|
// 子属性列表
|
|
64741
|
-
|
|
64742
64701
|
brand_property: {},
|
|
64743
64702
|
// '品牌'属性
|
|
64744
64703
|
material_quality_property: {} // ‘材料成分’属性
|
|
64745
64704
|
};
|
|
64746
|
-
|
|
64747
64705
|
//// 第一步,进行数据分组拆分, 拆分出:“品牌”属性,必填属性,非必填属性,子属性, 其中‘材料成分’属性外部登记(方便后期进行检测)
|
|
64748
64706
|
properties.forEach(function (item) {
|
|
64749
64707
|
var attrItem = _objectSpread2(_objectSpread2({}, item), {}, {
|
|
@@ -64778,17 +64736,14 @@ function perparePropertyGroup(properties) {
|
|
|
64778
64736
|
}
|
|
64779
64737
|
}
|
|
64780
64738
|
});
|
|
64781
|
-
|
|
64782
64739
|
//// 第二步,检测是否有子属性,有子属性需添加到 必填列表 与 非必填列表 中
|
|
64783
64740
|
if (propertiesData.children_list.length > 0) {
|
|
64784
64741
|
// 检测到当前有子属性,注意子属性可能存在多条件显示,或者 次级子属性的情况
|
|
64785
|
-
|
|
64786
64742
|
var required_list = [];
|
|
64787
64743
|
var other_list = [];
|
|
64788
64744
|
var children_list = _toConsumableArray(propertiesData.children_list).sort(function (a, b) {
|
|
64789
64745
|
return Number(b.has_children) - Number(a.has_children);
|
|
64790
64746
|
}); // 排序有子属性的排前
|
|
64791
|
-
|
|
64792
64747
|
propertiesData.required_list.forEach(function (item) {
|
|
64793
64748
|
// 遍历,按顺序添加到新列表中
|
|
64794
64749
|
required_list.push(item);
|
|
@@ -64805,7 +64760,6 @@ function perparePropertyGroup(properties) {
|
|
|
64805
64760
|
getChildrenProperty(other_list, item, children_list);
|
|
64806
64761
|
}
|
|
64807
64762
|
});
|
|
64808
|
-
|
|
64809
64763
|
// 将剩余的子属性分别添加到两个列表中
|
|
64810
64764
|
children_list.forEach(function (item) {
|
|
64811
64765
|
if (item.property_required) {
|
|
@@ -64817,12 +64771,10 @@ function perparePropertyGroup(properties) {
|
|
|
64817
64771
|
propertiesData.required_list = required_list;
|
|
64818
64772
|
propertiesData.other_list = other_list;
|
|
64819
64773
|
}
|
|
64820
|
-
|
|
64821
64774
|
//// 第三步,合成完整的列表
|
|
64822
64775
|
propertiesData.list = [].concat(_toConsumableArray(propertiesData.required_list), _toConsumableArray(propertiesData.other_list));
|
|
64823
64776
|
return propertiesData;
|
|
64824
64777
|
}
|
|
64825
|
-
|
|
64826
64778
|
/**
|
|
64827
64779
|
* 第二步,重新将子属性编排入 必填项列表 与 非必填项列表
|
|
64828
64780
|
* */
|
|
@@ -64837,7 +64789,6 @@ function getChildrenProperty(list, parentItem, children_list) {
|
|
|
64837
64789
|
if (childrenItem.show_condition.length === 1) {
|
|
64838
64790
|
// 子属性只有一个显示条件,直接添加
|
|
64839
64791
|
children_list.splice(index, 1); // 移除属性列表
|
|
64840
|
-
|
|
64841
64792
|
childrenItem.property_required = parentItem.property_required; // 子属性设置必选标识
|
|
64842
64793
|
list.push(childrenItem);
|
|
64843
64794
|
// 检测当时子属性是否有再下级子属性
|
|
@@ -65057,7 +65008,6 @@ var model = {
|
|
|
65057
65008
|
},
|
|
65058
65009
|
// {value: ['铜氨丝','铜氨丝(铜氨纤维)'], similarity: 1},
|
|
65059
65010
|
// {value: ['铜氨纤维(铜氨丝)','铜氨丝(铜氨纤维)'], similarity: 1},
|
|
65060
|
-
|
|
65061
65011
|
{
|
|
65062
65012
|
value: ['氨纶', '聚氨酯弹性纤维(氨纶)'],
|
|
65063
65013
|
similarity: 1
|
|
@@ -72684,7 +72634,6 @@ var map = [{
|
|
|
72684
72634
|
}];
|
|
72685
72635
|
var defaultModel = {
|
|
72686
72636
|
map: map
|
|
72687
|
-
|
|
72688
72637
|
// getAttrValue(matchInfo: object, propertyItem) {
|
|
72689
72638
|
//
|
|
72690
72639
|
// let attrDatas = map.find(item => item.attr.includes(propertyItem.property_name))
|
|
@@ -72798,17 +72747,14 @@ function checkValue(value) {
|
|
|
72798
72747
|
if (value === null || value === undefined || value === "") {
|
|
72799
72748
|
return false;
|
|
72800
72749
|
}
|
|
72801
|
-
|
|
72802
72750
|
// 数组类型
|
|
72803
72751
|
if (Array.isArray(value)) {
|
|
72804
72752
|
return value.length > 0;
|
|
72805
72753
|
}
|
|
72806
|
-
|
|
72807
72754
|
// 对象类型
|
|
72808
72755
|
if (_typeof(value) === "object" && value !== null) {
|
|
72809
72756
|
return Object.keys(value).length > 0;
|
|
72810
72757
|
}
|
|
72811
|
-
|
|
72812
72758
|
// 其他类型(数字、布尔值等)视为有效
|
|
72813
72759
|
return true;
|
|
72814
72760
|
} catch (error) {
|
|
@@ -72816,7 +72762,6 @@ function checkValue(value) {
|
|
|
72816
72762
|
return false;
|
|
72817
72763
|
}
|
|
72818
72764
|
}
|
|
72819
|
-
|
|
72820
72765
|
/**
|
|
72821
72766
|
* 获取2个字符串的相似度
|
|
72822
72767
|
* @param {string} str1 字符串1
|
|
@@ -72827,20 +72772,18 @@ function getStringSimilarity(str1, str2) {
|
|
|
72827
72772
|
// 优化点1:避免重复计数
|
|
72828
72773
|
var arr2 = str2.split(''); // 将字符串转为数组便于操作
|
|
72829
72774
|
var sameNum = 0;
|
|
72830
|
-
|
|
72831
72775
|
// 遍历时删除已匹配字符避免重复计数
|
|
72832
72776
|
var _iterator = _createForOfIteratorHelper(str1),
|
|
72833
72777
|
_step;
|
|
72834
72778
|
try {
|
|
72835
72779
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
72836
|
-
var
|
|
72837
|
-
var index = arr2.indexOf(
|
|
72780
|
+
var char = _step.value;
|
|
72781
|
+
var index = arr2.indexOf(char);
|
|
72838
72782
|
if (index !== -1) {
|
|
72839
72783
|
sameNum++;
|
|
72840
72784
|
arr2.splice(index, 1); // 移除已匹配字符
|
|
72841
72785
|
}
|
|
72842
72786
|
}
|
|
72843
|
-
|
|
72844
72787
|
// 优化点2:引入Dice系数计算相似度
|
|
72845
72788
|
} catch (err) {
|
|
72846
72789
|
_iterator.e(err);
|
|
@@ -72848,17 +72791,15 @@ function getStringSimilarity(str1, str2) {
|
|
|
72848
72791
|
_iterator.f();
|
|
72849
72792
|
}
|
|
72850
72793
|
var diceCoefficient = 2 * sameNum / (str1.length + str2.length);
|
|
72851
|
-
|
|
72852
72794
|
// 优化点3:短字符串完全包含时的加权处理
|
|
72853
72795
|
var _ref = str1.length > str2.length ? [str1, str2] : [str2, str1],
|
|
72854
72796
|
_ref2 = _slicedToArray(_ref, 2),
|
|
72855
72797
|
longer = _ref2[0],
|
|
72856
72798
|
shorter = _ref2[1];
|
|
72857
72799
|
var inclusionBonus = 0;
|
|
72858
|
-
|
|
72859
72800
|
// 如果短串是长串的子集则增加匹配度(字符全部包含权重增加)
|
|
72860
|
-
if (shorter.split('').every(function (
|
|
72861
|
-
return longer.includes(
|
|
72801
|
+
if (shorter.split('').every(function (char) {
|
|
72802
|
+
return longer.includes(char);
|
|
72862
72803
|
})) {
|
|
72863
72804
|
inclusionBonus = 0.3 * (shorter.length / longer.length);
|
|
72864
72805
|
// 判断是否字符串完成包含,增加权重
|
|
@@ -72866,16 +72807,13 @@ function getStringSimilarity(str1, str2) {
|
|
|
72866
72807
|
inclusionBonus += 0.2;
|
|
72867
72808
|
}
|
|
72868
72809
|
}
|
|
72869
|
-
|
|
72870
72810
|
// 优化点4:长度差异补偿(短串越接近长串得分越高)
|
|
72871
72811
|
var lengthRatio = shorter.length / longer.length;
|
|
72872
72812
|
var lengthCompensation = 0.2 * lengthRatio;
|
|
72873
|
-
|
|
72874
72813
|
// 最终相似度 = Dice系数 + 包含奖励 + 长度补偿
|
|
72875
72814
|
// 最终相似度不能大于1,方便多选时优先使用完全匹配和模型匹配
|
|
72876
72815
|
return Math.min(diceCoefficient + inclusionBonus + lengthCompensation, 0.99);
|
|
72877
72816
|
}
|
|
72878
|
-
|
|
72879
72817
|
/**
|
|
72880
72818
|
* 判断字符串中是否包含某些字符
|
|
72881
72819
|
*
|
|
@@ -72899,7 +72837,6 @@ function isTextInclude(text, arr) {
|
|
|
72899
72837
|
throw new Error('type 参数错误有误,只能是includeOne或includeAll');
|
|
72900
72838
|
}
|
|
72901
72839
|
}
|
|
72902
|
-
|
|
72903
72840
|
/* 获取当前时间节点 */
|
|
72904
72841
|
function getCurrentTime() {
|
|
72905
72842
|
var date = new Date();
|
|
@@ -72929,7 +72866,6 @@ function getCurrentTime() {
|
|
|
72929
72866
|
lastSeason: lastSeason
|
|
72930
72867
|
};
|
|
72931
72868
|
}
|
|
72932
|
-
|
|
72933
72869
|
/* 数值取随机数,获取指定数字内的随机数 */
|
|
72934
72870
|
function mathRandomNumber(num) {
|
|
72935
72871
|
if (num === 0 || !num) {
|
|
@@ -72978,7 +72914,6 @@ function getAttrDefaultValue(matchInfo, propertyItem) {
|
|
|
72978
72914
|
return undefined;
|
|
72979
72915
|
}
|
|
72980
72916
|
}
|
|
72981
|
-
|
|
72982
72917
|
// 根据属性选项进行预测筛选
|
|
72983
72918
|
var property_values = _toConsumableArray(propertyItem.select_values);
|
|
72984
72919
|
var _loop = function _loop() {
|
|
@@ -72991,7 +72926,6 @@ function getAttrDefaultValue(matchInfo, propertyItem) {
|
|
|
72991
72926
|
// console.log('跳过')
|
|
72992
72927
|
return 0; // continue
|
|
72993
72928
|
}
|
|
72994
|
-
|
|
72995
72929
|
// console.log(fieldValues)
|
|
72996
72930
|
// console.log(property_values)
|
|
72997
72931
|
if (propertyItem.property_type == 'input' || propertyItem.property_type == 'date' || propertyItem.property_type == 'inputComponent') {
|
|
@@ -73025,7 +72959,6 @@ function getAttrDefaultValue(matchInfo, propertyItem) {
|
|
|
73025
72959
|
}
|
|
73026
72960
|
} else {
|
|
73027
72961
|
// 选择单选
|
|
73028
|
-
|
|
73029
72962
|
// 先进行全匹配,匹配成功则直接返回
|
|
73030
72963
|
var valueItem = property_values.find(function (item) {
|
|
73031
72964
|
var result = fieldValues.findIndex(function (fieldValue) {
|
|
@@ -73034,7 +72967,6 @@ function getAttrDefaultValue(matchInfo, propertyItem) {
|
|
|
73034
72967
|
// console.log(item.name, result)
|
|
73035
72968
|
return result !== -1;
|
|
73036
72969
|
});
|
|
73037
|
-
|
|
73038
72970
|
// 如全内容匹配失败,进行内容包含匹配
|
|
73039
72971
|
if (!valueItem) {
|
|
73040
72972
|
valueItem = property_values.find(function (item) {
|
|
@@ -73062,7 +72994,6 @@ function getAttrDefaultValue(matchInfo, propertyItem) {
|
|
|
73062
72994
|
}
|
|
73063
72995
|
return undefined;
|
|
73064
72996
|
}
|
|
73065
|
-
|
|
73066
72997
|
/*
|
|
73067
72998
|
* 获取属性名匹配
|
|
73068
72999
|
* */
|
|
@@ -73071,7 +73002,6 @@ function attrSimilarity(attr_name1, attr_name2) {
|
|
|
73071
73002
|
if (attr_name1 === attr_name2) {
|
|
73072
73003
|
return 1;
|
|
73073
73004
|
}
|
|
73074
|
-
|
|
73075
73005
|
// 属性值互相包含,判断相似度相似
|
|
73076
73006
|
if (attr_name1.includes(attr_name2) || attr_name2.includes(attr_name1)) {
|
|
73077
73007
|
// 根据包含的字数多少判断相似度
|
|
@@ -73080,7 +73010,6 @@ function attrSimilarity(attr_name1, attr_name2) {
|
|
|
73080
73010
|
return similarity;
|
|
73081
73011
|
}
|
|
73082
73012
|
}
|
|
73083
|
-
|
|
73084
73013
|
// 按照模型进行匹配
|
|
73085
73014
|
var attr_map = model.attr_map;
|
|
73086
73015
|
var result = attr_map.find(function (item) {
|
|
@@ -73091,16 +73020,13 @@ function attrSimilarity(attr_name1, attr_name2) {
|
|
|
73091
73020
|
}
|
|
73092
73021
|
return 0;
|
|
73093
73022
|
}
|
|
73094
|
-
|
|
73095
73023
|
/* 获取属性值匹配 */
|
|
73096
73024
|
function attrValueSimilarity(attr, attr_value1, attr_value2) {
|
|
73097
73025
|
var min_similarity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.8;
|
|
73098
73026
|
if (!attr_value1 || !attr_value2) return 0;
|
|
73099
|
-
|
|
73100
73027
|
// 避免数字,导致includes报错
|
|
73101
73028
|
attr_value1 = "".concat(attr_value1);
|
|
73102
73029
|
attr_value2 = "".concat(attr_value2);
|
|
73103
|
-
|
|
73104
73030
|
// 属性值互相包含,判断相似度相似
|
|
73105
73031
|
var similarity = 0;
|
|
73106
73032
|
if (attr_value1.includes(attr_value2) || attr_value2.includes(attr_value1)) {
|
|
@@ -73159,7 +73085,6 @@ function matchPropertyItem(matchInfo, propertyItem) {
|
|
|
73159
73085
|
return;
|
|
73160
73086
|
}
|
|
73161
73087
|
var result = -1;
|
|
73162
|
-
|
|
73163
73088
|
// 第一步,针对特殊的情况进行匹配
|
|
73164
73089
|
if (matchInfo.platform === 'pdd' && propertyItem.property_name === '适用人群') {
|
|
73165
73090
|
// 拼多多的使用人群(建筑工人、医护人员。。。)与 淘宝、抖音的适用人群 匹配
|
|
@@ -73185,7 +73110,6 @@ function matchPropertyItem(matchInfo, propertyItem) {
|
|
|
73185
73110
|
return ['上市年份季节', '上市时节'].includes(item.attr_name);
|
|
73186
73111
|
});
|
|
73187
73112
|
}
|
|
73188
|
-
|
|
73189
73113
|
// 第二步,属性名称完全匹配
|
|
73190
73114
|
if (result === -1) {
|
|
73191
73115
|
result = attrs.findIndex(function (item) {
|
|
@@ -73203,7 +73127,6 @@ function matchPropertyItem(matchInfo, propertyItem) {
|
|
|
73203
73127
|
return;
|
|
73204
73128
|
}
|
|
73205
73129
|
}
|
|
73206
|
-
|
|
73207
73130
|
// 第三步,使用相识度进行匹配
|
|
73208
73131
|
var similarityAttr = [];
|
|
73209
73132
|
attrs.forEach(function (item) {
|
|
@@ -73233,7 +73156,6 @@ function matchPropertyItem(matchInfo, propertyItem) {
|
|
|
73233
73156
|
console.log(e);
|
|
73234
73157
|
}
|
|
73235
73158
|
}
|
|
73236
|
-
|
|
73237
73159
|
/**
|
|
73238
73160
|
* 初始化属性值
|
|
73239
73161
|
* */
|
|
@@ -73249,12 +73171,10 @@ function initPropertyValue(propertyItem) {
|
|
|
73249
73171
|
return '';
|
|
73250
73172
|
}
|
|
73251
73173
|
}
|
|
73252
|
-
|
|
73253
73174
|
/* 材质成分属性列表 */
|
|
73254
73175
|
var materialList = ['材质成分', '面料材质', '面料俗称', '材质', '面料名称', '主面料成分'];
|
|
73255
73176
|
/* 材质含量属性列表 */
|
|
73256
73177
|
var qualityList = ['成分含量', '面料材质成分含量', '面料材质成分含量(%)', '主面料成分的含量', '面料材质含量'];
|
|
73257
|
-
|
|
73258
73178
|
/**
|
|
73259
73179
|
* 进行属性值的匹配
|
|
73260
73180
|
* */
|
|
@@ -73268,7 +73188,6 @@ function matchPropertyValue(matchInfo, propertyItem, attr) {
|
|
|
73268
73188
|
// 参考值为空
|
|
73269
73189
|
return valueItem;
|
|
73270
73190
|
}
|
|
73271
|
-
|
|
73272
73191
|
// 参考值内容
|
|
73273
73192
|
var attr_values = [];
|
|
73274
73193
|
if (Array.isArray(attr.value)) {
|
|
@@ -73293,15 +73212,12 @@ function matchPropertyValue(matchInfo, propertyItem, attr) {
|
|
|
73293
73212
|
});
|
|
73294
73213
|
attr_values = n_attr_values;
|
|
73295
73214
|
}
|
|
73296
|
-
|
|
73297
73215
|
// console.log('匹配属性', propertyItem.property_name, propertyItem.property_type, attr_values
|
|
73298
|
-
|
|
73299
73216
|
if (propertyItem.property_type == 'input' || propertyItem.property_type == 'inputComponent' || propertyItem.property_type == 'date') {
|
|
73300
73217
|
// 输入类属性(纯文本,数值+单位,日期,范围输入)
|
|
73301
73218
|
valueItem = matchInputPropertyValue(matchInfo, propertyItem, attr_values);
|
|
73302
73219
|
} else {
|
|
73303
73220
|
// 选择类属性(单选、多选、组合多选、层级单选)
|
|
73304
|
-
|
|
73305
73221
|
var property_values = _toConsumableArray(propertyItem.select_values);
|
|
73306
73222
|
if (materialList.includes(propertyItem.property_name) || qualityList.includes(propertyItem.property_name)) {
|
|
73307
73223
|
// 匹配 材质成分以及成分含量 内容
|
|
@@ -73324,16 +73240,13 @@ function matchPropertyValue(matchInfo, propertyItem, attr) {
|
|
|
73324
73240
|
}
|
|
73325
73241
|
return valueItem;
|
|
73326
73242
|
}
|
|
73327
|
-
|
|
73328
73243
|
/**
|
|
73329
73244
|
* 特性属性匹配 匹配材质成分 含量,
|
|
73330
73245
|
* · 需要先进行解析在进行匹配
|
|
73331
73246
|
* */
|
|
73332
73247
|
function matchMaterialQualityValue(matchInfo, propertyItem, property_values, attr_values) {
|
|
73333
73248
|
var match_type = materialList.includes(propertyItem.property_name) ? 1 : 2;
|
|
73334
|
-
|
|
73335
73249
|
// console.log('匹配 材质含量类型' + match_type, propertyItem.property_name, attr_values)
|
|
73336
|
-
|
|
73337
73250
|
var material_values = [];
|
|
73338
73251
|
attr_values.forEach(function (item) {
|
|
73339
73252
|
// 优先解析 棉[100%] 棉100% 棉 等格式
|
|
@@ -73349,7 +73262,6 @@ function matchMaterialQualityValue(matchInfo, propertyItem, property_values, att
|
|
|
73349
73262
|
var options = parsePercentageRange(item);
|
|
73350
73263
|
if (options.min === null || options.min === undefined) {
|
|
73351
73264
|
// 范围解析失败,使用其他进行解析
|
|
73352
|
-
|
|
73353
73265
|
var materialOption = parseMaterial(item);
|
|
73354
73266
|
if (materialOption) {
|
|
73355
73267
|
options = {
|
|
@@ -73407,7 +73319,6 @@ function matchMaterialQualityValue(matchInfo, propertyItem, property_values, att
|
|
|
73407
73319
|
// 数值+单位,直接返回数值()
|
|
73408
73320
|
return "".concat(maxPercentage);
|
|
73409
73321
|
}
|
|
73410
|
-
|
|
73411
73322
|
// 处理其他类型
|
|
73412
73323
|
var percentageValue = '';
|
|
73413
73324
|
if (minPercentage < maxPercentage) {
|
|
@@ -73420,7 +73331,6 @@ function matchMaterialQualityValue(matchInfo, propertyItem, property_values, att
|
|
|
73420
73331
|
// 纯文本,直接返回
|
|
73421
73332
|
return percentageValue;
|
|
73422
73333
|
}
|
|
73423
|
-
|
|
73424
73334
|
// 选择,进行处理
|
|
73425
73335
|
var valueItem = property_values.find(function (item) {
|
|
73426
73336
|
return item.name === percentageValue;
|
|
@@ -73432,7 +73342,6 @@ function matchMaterialQualityValue(matchInfo, propertyItem, property_values, att
|
|
|
73432
73342
|
// 未匹配到,拆分处理进行处理
|
|
73433
73343
|
for (var i = 0; i < property_values.length; i++) {
|
|
73434
73344
|
var item = property_values[i];
|
|
73435
|
-
|
|
73436
73345
|
// 解析百分比范围选项
|
|
73437
73346
|
var options = parsePercentageRange(item.name);
|
|
73438
73347
|
if (isMatchNumberRange(minPercentage, maxPercentage, options)) {
|
|
@@ -73448,13 +73357,11 @@ function matchMaterialQualityValue(matchInfo, propertyItem, property_values, att
|
|
|
73448
73357
|
return undefined;
|
|
73449
73358
|
}
|
|
73450
73359
|
}
|
|
73451
|
-
|
|
73452
73360
|
/**
|
|
73453
73361
|
* 匹配输入项
|
|
73454
73362
|
* */
|
|
73455
73363
|
function matchInputPropertyValue(matchInfo, propertyItem, attr_values) {
|
|
73456
73364
|
// console.log(propertyItem.property_name, propertyItem.property_type,attr_values)
|
|
73457
|
-
|
|
73458
73365
|
var valueItem = '';
|
|
73459
73366
|
if (materialList.includes(propertyItem.property_name) || qualityList.includes(propertyItem.property_name)) {
|
|
73460
73367
|
// 匹配 材质成分以及成分含量 内容
|
|
@@ -73504,7 +73411,6 @@ function matchInputPropertyValue(matchInfo, propertyItem, attr_values) {
|
|
|
73504
73411
|
}
|
|
73505
73412
|
}
|
|
73506
73413
|
}
|
|
73507
|
-
|
|
73508
73414
|
// if (propertyItem.property_name.includes('CCC') || propertyItem.property_name.includes('3C')) {
|
|
73509
73415
|
// // 玩具3C认证
|
|
73510
73416
|
// let result = attrs.findIndex(item => item.attr_name.includes('CCC') || item.attr_name.includes('3C'))
|
|
@@ -73515,7 +73421,6 @@ function matchInputPropertyValue(matchInfo, propertyItem, attr_values) {
|
|
|
73515
73421
|
// return goodsAttr.value
|
|
73516
73422
|
// }
|
|
73517
73423
|
// }
|
|
73518
|
-
|
|
73519
73424
|
// if (propertyItem.property_name.includes('型号') && matchInfo.cate_path.includes('3C数码配件')) {
|
|
73520
73425
|
//
|
|
73521
73426
|
// let result = attrs.findIndex(item => item.attr_name.includes('货号'))
|
|
@@ -73529,14 +73434,12 @@ function matchInputPropertyValue(matchInfo, propertyItem, attr_values) {
|
|
|
73529
73434
|
// return goods.goods_sn
|
|
73530
73435
|
// }
|
|
73531
73436
|
// }
|
|
73532
|
-
|
|
73533
73437
|
if (propertyItem.property_type == 'input') {
|
|
73534
73438
|
// 纯文本输入
|
|
73535
73439
|
valueItem = attr_values.join('、');
|
|
73536
73440
|
} else if (propertyItem.property_type === 'inputComponent') ;
|
|
73537
73441
|
return valueItem;
|
|
73538
73442
|
}
|
|
73539
|
-
|
|
73540
73443
|
/**
|
|
73541
73444
|
* 匹配单选项
|
|
73542
73445
|
* */
|
|
@@ -73557,9 +73460,7 @@ function matchSingleSelectPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73557
73460
|
// 有内容,并且相似度大于80%
|
|
73558
73461
|
return valueItem;
|
|
73559
73462
|
}
|
|
73560
|
-
|
|
73561
73463
|
// 没有完全匹配的属性值,开始根据最相似的值进行匹配
|
|
73562
|
-
|
|
73563
73464
|
// 当前属性支持自定义选项,如果筛选的数值小于0.8, 需要创建一个自定义属性
|
|
73564
73465
|
if (propertyItem.select_custom && propertyItem.property_name === '货号') {
|
|
73565
73466
|
// 相似度太小,创建一个自定义属性值
|
|
@@ -73574,7 +73475,6 @@ function matchSingleSelectPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73574
73475
|
}
|
|
73575
73476
|
return valueItem;
|
|
73576
73477
|
}
|
|
73577
|
-
|
|
73578
73478
|
/**
|
|
73579
73479
|
* 匹配常规多选项属性值
|
|
73580
73480
|
* */
|
|
@@ -73597,13 +73497,11 @@ function matchMultiSelectPropertyValue(matchInfo, propertyItem, property_values,
|
|
|
73597
73497
|
}
|
|
73598
73498
|
return valueList;
|
|
73599
73499
|
}
|
|
73600
|
-
|
|
73601
73500
|
/**
|
|
73602
73501
|
* 匹配组合多选项
|
|
73603
73502
|
* */
|
|
73604
73503
|
function matchMultiComplexPropertyValue(matchInfo, propertyItem, property_values, attr_values) {
|
|
73605
73504
|
// console.log('组合多选', propertyItem.property_name, attr_values)
|
|
73606
|
-
|
|
73607
73505
|
// 获取材质 和 成分
|
|
73608
73506
|
var n_attr_values = attr_values.map(function (item) {
|
|
73609
73507
|
var _item;
|
|
@@ -73630,12 +73528,10 @@ function matchMultiComplexPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73630
73528
|
}).filter(function (item) {
|
|
73631
73529
|
return item === null || item === void 0 ? void 0 : item.material;
|
|
73632
73530
|
});
|
|
73633
|
-
|
|
73634
73531
|
// 匹配结果
|
|
73635
73532
|
var valueList = [];
|
|
73636
73533
|
var totalPercentage = 0;
|
|
73637
73534
|
var disableContentNumber = 0;
|
|
73638
|
-
|
|
73639
73535
|
// 根据属性的来源属性值进行属性值匹配
|
|
73640
73536
|
n_attr_values.forEach(function (attrValue) {
|
|
73641
73537
|
// 获取对应的属性值
|
|
@@ -73655,7 +73551,6 @@ function matchMultiComplexPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73655
73551
|
valueList.push(valueItem);
|
|
73656
73552
|
}
|
|
73657
73553
|
});
|
|
73658
|
-
|
|
73659
73554
|
// 当前选项数量超过属性最大选项数量限制
|
|
73660
73555
|
if (propertyItem !== null && propertyItem !== void 0 && propertyItem.select_max_num && valueList.length > propertyItem.select_max_num) {
|
|
73661
73556
|
// 按照相似度进行排序,相似的排最前
|
|
@@ -73675,7 +73570,6 @@ function matchMultiComplexPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73675
73570
|
}
|
|
73676
73571
|
});
|
|
73677
73572
|
}
|
|
73678
|
-
|
|
73679
73573
|
// 整体需填写含量的总数不等于100,进行含量分配处理
|
|
73680
73574
|
if (totalPercentage !== 100 && disableContentNumber < valueList.length) {
|
|
73681
73575
|
// 需要填的成分含量 总数不等于100
|
|
@@ -73701,7 +73595,6 @@ function matchMultiComplexPropertyValue(matchInfo, propertyItem, property_values
|
|
|
73701
73595
|
}
|
|
73702
73596
|
return valueList;
|
|
73703
73597
|
}
|
|
73704
|
-
|
|
73705
73598
|
/**
|
|
73706
73599
|
* 获取数据模型匹配结果
|
|
73707
73600
|
* */
|
|
@@ -73720,7 +73613,6 @@ function modelMatchSimilarityValue(propertyItem, property_values, attrValue) {
|
|
|
73720
73613
|
property_values.splice(valueIndex, 1);
|
|
73721
73614
|
return valueItem;
|
|
73722
73615
|
}
|
|
73723
|
-
|
|
73724
73616
|
// 2.再进行相似度匹配
|
|
73725
73617
|
for (var i = 0; i < property_values.length; i++) {
|
|
73726
73618
|
var _valueItem6;
|
|
@@ -73741,7 +73633,6 @@ function modelMatchSimilarityValue(propertyItem, property_values, attrValue) {
|
|
|
73741
73633
|
}
|
|
73742
73634
|
return valueItem;
|
|
73743
73635
|
}
|
|
73744
|
-
|
|
73745
73636
|
/* 解析内容获取 材质成分 */
|
|
73746
73637
|
function parseMaterial(str) {
|
|
73747
73638
|
var regex = /^([\u4e00-\u9fa5()a-zA-Z0-9\-_]+?)(?:\[?(\d+\.?\d*)%\]?)?$/;
|
|
@@ -73753,14 +73644,11 @@ function parseMaterial(str) {
|
|
|
73753
73644
|
}
|
|
73754
73645
|
return materialInfo;
|
|
73755
73646
|
}
|
|
73756
|
-
|
|
73757
73647
|
/* 解析百分比,获取百分比数值,解析失败返回0 */
|
|
73758
73648
|
function parsePercentage(str) {
|
|
73759
73649
|
if (!str) return 0;
|
|
73760
|
-
|
|
73761
73650
|
// 要求字符串必须以%结尾
|
|
73762
73651
|
if (!str.trim().endsWith('%')) return 0;
|
|
73763
|
-
|
|
73764
73652
|
// 移除所有非数字字符(保留小数点和负号)
|
|
73765
73653
|
var numericString = str.replace(/[^\d.-]/g, '');
|
|
73766
73654
|
// 尝试解析为浮点数
|
|
@@ -73768,7 +73656,6 @@ function parsePercentage(str) {
|
|
|
73768
73656
|
// 返回有效数字或 0
|
|
73769
73657
|
return Number.isNaN(parsedValue) ? 0 : parsedValue;
|
|
73770
73658
|
}
|
|
73771
|
-
|
|
73772
73659
|
/* 解析百分比数值范围 */
|
|
73773
73660
|
function parsePercentageRange(str) {
|
|
73774
73661
|
var itemName = str.replace(/(/g, '(').replace(/)/g, ')').replace(/—/g, '-');
|
|
@@ -73827,21 +73714,17 @@ function parsePercentageRange(str) {
|
|
|
73827
73714
|
}
|
|
73828
73715
|
return optionsItem;
|
|
73829
73716
|
}
|
|
73830
|
-
|
|
73831
73717
|
/* 数值取整,保留小数点后一位 */
|
|
73832
73718
|
function mathRoundNumber(num) {
|
|
73833
73719
|
var number = Number(num);
|
|
73834
73720
|
return Math.round(number * 10) / 10;
|
|
73835
73721
|
}
|
|
73836
|
-
|
|
73837
73722
|
/* 解析匹配数值范围 */
|
|
73838
73723
|
function isMatchNumberRange(userMin, userMax, option) {
|
|
73839
73724
|
// 用户范围完全在选项左侧之外
|
|
73840
73725
|
if (option.min == null || userMax < option.min || userMax === option.min && !option.includeMin) return false;
|
|
73841
|
-
|
|
73842
73726
|
// 用户范围完全在选项右侧之外
|
|
73843
73727
|
if (option.max == null || userMin > option.max || userMin === option.max && !option.includeMax) return false;
|
|
73844
|
-
|
|
73845
73728
|
// 用户范围与选项范围有交集
|
|
73846
73729
|
return true;
|
|
73847
73730
|
}
|
|
@@ -73856,9 +73739,7 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
73856
73739
|
// 使用‘select_values’, 子属性会进行筛选
|
|
73857
73740
|
var property_type = propertyItem.property_type;
|
|
73858
73741
|
var property_values = _toConsumableArray(propertyItem.select_values);
|
|
73859
|
-
|
|
73860
73742
|
//// 1. 优先使用补充数据进行预测,如商品标题,备注,货号
|
|
73861
|
-
|
|
73862
73743
|
var goodsTitle = ((goods === null || goods === void 0 ? void 0 : goods.title) || '') + ((goods === null || goods === void 0 ? void 0 : goods.remark) || '');
|
|
73863
73744
|
// console.log("预测信息 - 商品", goodsTitle, propertyItem.property_name)
|
|
73864
73745
|
if (goodsTitle) {
|
|
@@ -73890,7 +73771,6 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
73890
73771
|
}
|
|
73891
73772
|
return;
|
|
73892
73773
|
}
|
|
73893
|
-
|
|
73894
73774
|
// 通过规格预测
|
|
73895
73775
|
if (goods.specs && goods.specs.length > 0 && ['颜色', '尺码'].includes(propertyItem.property_name)) {
|
|
73896
73776
|
var keys = [];
|
|
@@ -74070,7 +73950,6 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
74070
73950
|
return;
|
|
74071
73951
|
}
|
|
74072
73952
|
}
|
|
74073
|
-
|
|
74074
73953
|
/// 2.根据设定默认值
|
|
74075
73954
|
var defaultItem = getAttrDefaultValue(matchInfo, propertyItem);
|
|
74076
73955
|
if (defaultItem) {
|
|
@@ -74090,9 +73969,7 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
74090
73969
|
}
|
|
74091
73970
|
return;
|
|
74092
73971
|
}
|
|
74093
|
-
|
|
74094
73972
|
/// 3.设置普遍默认值,如:其他,其它,other等
|
|
74095
|
-
|
|
74096
73973
|
if (matchInfo.cate_path.includes('男装') || matchInfo.cate_path.includes('女装') || matchInfo.cate_path.includes('童装')) {
|
|
74097
73974
|
var _result2;
|
|
74098
73975
|
_result2 = property_values.find(function (item) {
|
|
@@ -74123,7 +74000,6 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
74123
74000
|
}
|
|
74124
74001
|
if (matchInfo.platform === 'albb' && ['产地', '服装风格'].includes(propertyItem.property_name) && ['singleSelect', 'multiSelect'].includes(property_type)) {
|
|
74125
74002
|
// 阿里巴巴,部分选项不清楚如何选择,直接随机选
|
|
74126
|
-
|
|
74127
74003
|
var index = mathRandomNumber(property_values.length);
|
|
74128
74004
|
if (index !== -1) {
|
|
74129
74005
|
var _valueItem6 = property_values[index];
|
|
@@ -74136,7 +74012,6 @@ function predictionPropertyItem(matchInfo, propertyItem, selectAttrs, goods) {
|
|
|
74136
74012
|
}
|
|
74137
74013
|
}
|
|
74138
74014
|
}
|
|
74139
|
-
|
|
74140
74015
|
/**
|
|
74141
74016
|
* 根据文本内容信息进行预测
|
|
74142
74017
|
* */
|
|
@@ -74262,7 +74137,7 @@ var fetchWithRetry = /*#__PURE__*/function () {
|
|
|
74262
74137
|
}
|
|
74263
74138
|
}, opt);
|
|
74264
74139
|
_context.n = 1;
|
|
74265
|
-
return axios(postDatas)
|
|
74140
|
+
return axios(postDatas).catch(function (err) {
|
|
74266
74141
|
return err;
|
|
74267
74142
|
});
|
|
74268
74143
|
case 1:
|
|
@@ -74379,7 +74254,6 @@ var getAlibabaItemPublihProps = /*#__PURE__*/function () {
|
|
|
74379
74254
|
var property = {
|
|
74380
74255
|
matchPropertiesValue: matchPropertiesValue
|
|
74381
74256
|
};
|
|
74382
|
-
|
|
74383
74257
|
/**
|
|
74384
74258
|
* 匹配属性值
|
|
74385
74259
|
* */
|
|
@@ -74423,7 +74297,6 @@ function _matchPropertiesValue() {
|
|
|
74423
74297
|
propertiesData.list.forEach(function (propertyItem) {
|
|
74424
74298
|
initMatchProperty(propertyItem);
|
|
74425
74299
|
});
|
|
74426
|
-
|
|
74427
74300
|
// 是否全部匹配完成
|
|
74428
74301
|
matchOver = true; // 已选属性值内容,后续可作为预测的依据之一
|
|
74429
74302
|
selectAttrs = []; // 开始进行模板数据匹配
|
|
@@ -74791,7 +74664,6 @@ function initMatchProperty(propertyItem) {
|
|
|
74791
74664
|
}
|
|
74792
74665
|
});
|
|
74793
74666
|
}
|
|
74794
|
-
|
|
74795
74667
|
/**
|
|
74796
74668
|
* 更新子属性的值,目前仅发现单选有子属性,其他类型暂未发现有子属性
|
|
74797
74669
|
* */
|
|
@@ -74864,7 +74736,6 @@ function _updateChildrenProperty() {
|
|
|
74864
74736
|
childrenList.forEach(function (propertyItem) {
|
|
74865
74737
|
if (childrenItem && childrenItem.property_id === propertyItem.property_id) {
|
|
74866
74738
|
// 当前列表中已经存在子属性,在该子属性下添加显示条件
|
|
74867
|
-
|
|
74868
74739
|
if (conditionItem && conditionItem.parent_value_ids) {
|
|
74869
74740
|
// 当前获取的显示条件,直接添加父属性的选择值
|
|
74870
74741
|
conditionItem.parent_value_ids.push(parentItemValueId);
|
|
@@ -74954,9 +74825,7 @@ var error = {
|
|
|
74954
74825
|
type: '系统报错'
|
|
74955
74826
|
};
|
|
74956
74827
|
}
|
|
74957
|
-
|
|
74958
74828
|
// 自定义错误
|
|
74959
|
-
|
|
74960
74829
|
var code = match[1];
|
|
74961
74830
|
var msg = match[2];
|
|
74962
74831
|
var type = '';
|
|
@@ -74973,42 +74842,6 @@ var error = {
|
|
|
74973
74842
|
}
|
|
74974
74843
|
};
|
|
74975
74844
|
|
|
74976
|
-
// 增强全局对象 polyfill
|
|
74977
|
-
(function () {
|
|
74978
|
-
if (typeof globalThisThis !== 'undefined') return globalThisThis;
|
|
74979
|
-
return globalThis;
|
|
74980
|
-
})();
|
|
74981
|
-
|
|
74982
|
-
// 确保所有全局对象引用都指向 globalThisThis
|
|
74983
|
-
Object.defineProperty(globalThisObject, 'globalThis', {
|
|
74984
|
-
value: globalThisObject,
|
|
74985
|
-
writable: true,
|
|
74986
|
-
enumerable: false,
|
|
74987
|
-
configurable: true
|
|
74988
|
-
});
|
|
74989
|
-
Object.defineProperty(globalThisObject, 'globalThis', {
|
|
74990
|
-
value: globalThisObject,
|
|
74991
|
-
writable: true,
|
|
74992
|
-
enumerable: false,
|
|
74993
|
-
configurable: true
|
|
74994
|
-
});
|
|
74995
|
-
Object.defineProperty(globalThisObject, 'globalThis', {
|
|
74996
|
-
value: globalThisObject,
|
|
74997
|
-
writable: true,
|
|
74998
|
-
enumerable: false,
|
|
74999
|
-
configurable: true
|
|
75000
|
-
});
|
|
75001
|
-
|
|
75002
|
-
// 导出全局对象
|
|
75003
|
-
var getGlobal = function getGlobal() {
|
|
75004
|
-
return globalThisObject;
|
|
75005
|
-
};
|
|
75006
|
-
var main = {
|
|
75007
|
-
createCategoryProperties: createCategoryProperties,
|
|
75008
|
-
getOriginProperty: getOriginProperty,
|
|
75009
|
-
matchCategoryProperties: matchCategoryProperties,
|
|
75010
|
-
createCategoryPropertyTemplate: createCategoryPropertyTemplate
|
|
75011
|
-
};
|
|
75012
74845
|
/**
|
|
75013
74846
|
* 转换自定义属性列表,
|
|
75014
74847
|
* */
|
|
@@ -75055,7 +74888,6 @@ function createCategoryProperties(platform, ptAttrs) {
|
|
|
75055
74888
|
return null;
|
|
75056
74889
|
}
|
|
75057
74890
|
}
|
|
75058
|
-
|
|
75059
74891
|
/**
|
|
75060
74892
|
* 自定义属性类型装换回原来的类型
|
|
75061
74893
|
* */
|
|
@@ -75087,7 +74919,6 @@ function getOriginProperty(platform, type) {
|
|
|
75087
74919
|
return '';
|
|
75088
74920
|
}
|
|
75089
74921
|
}
|
|
75090
|
-
|
|
75091
74922
|
/**
|
|
75092
74923
|
* 匹配属性值
|
|
75093
74924
|
* @param matchDatas 匹配数据
|
|
@@ -75150,7 +74981,7 @@ function _matchCategoryProperties() {
|
|
|
75150
74981
|
return _context.a(2, Promise.reject(error.getError('10001-没有检测到属性!')));
|
|
75151
74982
|
case 2:
|
|
75152
74983
|
_context.n = 3;
|
|
75153
|
-
return property.matchPropertiesValue(matchInfo, properties, attrs, goods)
|
|
74984
|
+
return property.matchPropertiesValue(matchInfo, properties, attrs, goods).catch(function (err) {
|
|
75154
74985
|
if (err instanceof Error) {
|
|
75155
74986
|
return Promise.reject(error.getError(err.message));
|
|
75156
74987
|
}
|
|
@@ -75216,7 +75047,6 @@ function _matchCategoryProperties() {
|
|
|
75216
75047
|
}));
|
|
75217
75048
|
return _matchCategoryProperties.apply(this, arguments);
|
|
75218
75049
|
}
|
|
75219
|
-
|
|
75220
75050
|
/**
|
|
75221
75051
|
* 创建分类属性模板
|
|
75222
75052
|
*
|
|
@@ -75259,5 +75089,5 @@ function createCategoryPropertyTemplate(properties) {
|
|
|
75259
75089
|
return attrs;
|
|
75260
75090
|
}
|
|
75261
75091
|
|
|
75262
|
-
export {
|
|
75092
|
+
export { createCategoryProperties, createCategoryPropertyTemplate, getOriginProperty, matchCategoryProperties };
|
|
75263
75093
|
//# sourceMappingURL=ftdsy-attr.esm.mjs.map
|