ftdsy-attr 2.3.6 → 2.3.7
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.
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
type Pt = 'pdd' | 'tb' | 'jd' | 'dy' | 'shopee' | 'xhs' | 'ks' | 'dsy' | 'albb' | 'shopeebt' | 'tgc' | 'wxsph' | 'tiktok' | 'tm' | 'tiktokUs' | 'hktvmall';
|
|
2
|
+
type PropertyType = 'unknown' | 'input' | 'singleSelect' | 'multiSelect' | 'treeSingleSelect' | 'inputComponent' | 'multiComplex' | 'date' | 'image';
|
|
3
|
+
type RuleName = 'requiredRule' | 'maxLengthRule' | 'valueTypeRule' | 'maxItemsRule' | 'format' | 'regexRule';
|
|
4
|
+
type ComponentType = 'input' | 'unit' | 'select' | 'operator' | 'label';
|
|
5
|
+
type goodsAttr = {
|
|
6
|
+
id?: string;
|
|
7
|
+
attr_name: string;
|
|
8
|
+
value: string | string[];
|
|
9
|
+
value_id?: string | string[];
|
|
10
|
+
};
|
|
11
|
+
type PropertyOption = {
|
|
12
|
+
label: string;
|
|
13
|
+
value: string;
|
|
14
|
+
parent_value?: string[];
|
|
15
|
+
label_cn?: string;
|
|
16
|
+
disableContent?: boolean;
|
|
17
|
+
value_path?: string;
|
|
18
|
+
value_ids_path?: string[];
|
|
19
|
+
children?: PropertyOption[];
|
|
20
|
+
};
|
|
21
|
+
type PropertyComponent = {
|
|
22
|
+
type: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
options: PropertyOption[];
|
|
26
|
+
text?: string;
|
|
27
|
+
precision?: number;
|
|
28
|
+
};
|
|
29
|
+
type Rule = {
|
|
30
|
+
name: RuleName;
|
|
31
|
+
value: string;
|
|
32
|
+
exProperty?: string;
|
|
33
|
+
};
|
|
34
|
+
type Condition = {
|
|
35
|
+
parent_id: string;
|
|
36
|
+
parent_value_ids: string[];
|
|
37
|
+
};
|
|
38
|
+
type DsyAttr = {
|
|
39
|
+
property_id: string;
|
|
40
|
+
property_required: boolean;
|
|
41
|
+
property_name: string;
|
|
42
|
+
property_name_cn?: string;
|
|
43
|
+
property_type: PropertyType;
|
|
44
|
+
property_values: PropertyOption[];
|
|
45
|
+
property_component?: PropertyComponent[];
|
|
46
|
+
property_tips?: string;
|
|
47
|
+
rules: Rule[];
|
|
48
|
+
has_children: boolean;
|
|
49
|
+
select_custom?: boolean;
|
|
50
|
+
show_condition?: Condition[];
|
|
51
|
+
measure_templates?: any;
|
|
52
|
+
property_pic_rule?: {
|
|
53
|
+
available: boolean;
|
|
54
|
+
required: boolean;
|
|
55
|
+
};
|
|
56
|
+
isCStore?: boolean;
|
|
57
|
+
};
|
|
58
|
+
type DsyAttrValue = {
|
|
59
|
+
valueId: string | string[];
|
|
60
|
+
value: string | string[];
|
|
61
|
+
};
|
|
62
|
+
type DsyAttrWithValue = DsyAttr & DsyAttrValue;
|
|
63
|
+
type MatchDatas = {
|
|
64
|
+
cate_id: string | number;
|
|
65
|
+
cate_path: string | string[];
|
|
66
|
+
platform: string;
|
|
67
|
+
properties: any[];
|
|
68
|
+
attrs?: any[];
|
|
69
|
+
title?: string;
|
|
70
|
+
goods_sn?: string;
|
|
71
|
+
ccc_code?: string;
|
|
72
|
+
remark?: string;
|
|
73
|
+
specs?: any;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
declare const getGlobal: () => any;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 转换自定义属性列表,
|
|
80
|
+
* */
|
|
81
|
+
declare function createCategoryProperties(platform: Pt, ptAttrs: any): Promise<DsyAttr[] | null>;
|
|
82
|
+
/**
|
|
83
|
+
* 自定义属性类型装换回原来的类型
|
|
84
|
+
* */
|
|
85
|
+
declare function getOriginProperty(platform: Pt, type: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* 匹配属性值
|
|
88
|
+
* @param matchDatas 匹配数据
|
|
89
|
+
* @param matchLevel 匹配等级 2: 必传属性必填(匹配不到会随机选择),3:全属性都必填(匹配不到会随机选择)
|
|
90
|
+
* @param outType 匹配结果输出类型 group: 分组(已去除),template: 模板, list: 自定义属性列表(不含’品牌‘)
|
|
91
|
+
* */
|
|
92
|
+
declare function matchCategoryProperties(matchDatas: MatchDatas, matchLevel?: number, outType?: 'template' | 'list'): Promise<{
|
|
93
|
+
msg: string;
|
|
94
|
+
data: DsyAttrWithValue[];
|
|
95
|
+
code: number;
|
|
96
|
+
} | {
|
|
97
|
+
msg: string;
|
|
98
|
+
data: goodsAttr[];
|
|
99
|
+
code: number;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* 根据模板重新填写属性
|
|
103
|
+
*
|
|
104
|
+
* */
|
|
105
|
+
/**
|
|
106
|
+
* 创建分类属性模板
|
|
107
|
+
*
|
|
108
|
+
* 返回案例如下:
|
|
109
|
+
* input: { attr_name: '货号', value: 'abc' };
|
|
110
|
+
* date: { attr_name: '日期', value: '2025-8-1' };
|
|
111
|
+
* inputComponent: { attr_name: '含量', value: '100%' };
|
|
112
|
+
* singleSelect: { attr_name: '材质', value: '聚酯纤维' };
|
|
113
|
+
* singleSelect: { attr_name: '材质', value: '聚酯纤维' };
|
|
114
|
+
* multiSelect: { attr_name: '材质', value: '[聚酯纤维, 棉]' };
|
|
115
|
+
* multiComplex: { attr_name: '材质', value: '[聚酯纤维[80%], 棉[20%]]' };
|
|
116
|
+
* treeSingleSelect: { attr_name: '风格', value: '休闲风-简约风' };
|
|
117
|
+
* */
|
|
118
|
+
declare function createCategoryPropertyTemplate(properties: (DsyAttrWithValue | goodsAttr)[]): goodsAttr[];
|
|
119
|
+
declare const ftdsyAttr: {
|
|
120
|
+
createCategoryProperties: typeof createCategoryProperties;
|
|
121
|
+
getOriginProperty: typeof getOriginProperty;
|
|
122
|
+
matchCategoryProperties: typeof matchCategoryProperties;
|
|
123
|
+
createCategoryPropertyTemplate: typeof createCategoryPropertyTemplate;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export { createCategoryProperties, createCategoryPropertyTemplate, ftdsyAttr as default, getGlobal, getOriginProperty, matchCategoryProperties };
|
|
127
|
+
export type { ComponentType, Condition, DsyAttr, DsyAttrValue, DsyAttrWithValue, MatchDatas, PropertyComponent, PropertyOption, PropertyType, Pt, Rule, RuleName, goodsAttr };
|