ftdsy-attr 1.0.0 → 1.0.2

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.
@@ -1,156 +0,0 @@
1
- export default {
2
- createCategoryProperties
3
- }
4
-
5
- function createCategoryProperties(categoryPropertys) {
6
-
7
- let propertys = categoryPropertys.map(item => {
8
-
9
- if (item?.property_id !== undefined && item?.property_value !== undefined && item.property_type !== undefined) {
10
- return item
11
- }
12
-
13
- // 属性可选选项
14
- var property_values = []
15
-
16
- if (item.options) {
17
- // 存在可选选项
18
- property_values = item.options.map(value => {
19
- return {
20
- name: value.name,
21
- value_id: value.value_id,
22
- value: value.value,
23
- parent_value: []
24
- }
25
- })
26
- }
27
-
28
- var property_type = 0
29
-
30
- var property_units = []
31
- var property_unit = ''
32
-
33
-
34
- var select_max_num = 0
35
-
36
- var input_max_num = 0
37
- var input_type = ''
38
- var input_format = ''
39
-
40
- var date_format = ''
41
-
42
- var measure_templates = {} // 组合模版
43
-
44
- if (item.type === 'text') {
45
- // 文本
46
- property_type = 1
47
- } else if (item.type === 'select') {
48
- // 单选
49
- property_type = 2
50
- select_max_num = 1
51
- } else if (item.type === 'multi_select') {
52
- // 多选
53
- property_type = 3
54
- select_max_num = item.multi_select_max
55
- } else if (item.type === 'measure') {
56
- // 单位输入
57
- property_type = 4
58
-
59
- if (item.measure_templates.length) {
60
- let measure_templatesItem = item.measure_templates[0]
61
-
62
- let moduleItem = measure_templatesItem.value_modules[0]
63
- moduleItem.units.forEach(unit => {
64
- property_units.push(unit.unit_name)
65
- })
66
- }
67
- property_unit = property_units[0]
68
-
69
- } else if (item.type === 'multi_value_measure') {
70
- // 组合多选 ('面料材质')
71
- property_type = 6
72
- select_max_num = item.multi_select_max
73
-
74
- let measure_values = []
75
- //
76
- if (item.measure_templates.length) {
77
- let measure_templatesItem = item.measure_templates[0]
78
- measure_templates = {
79
- template_id: measure_templatesItem.template_id,
80
- value_modules: measure_templatesItem.value_modules.map(moduleItem => {
81
- return {
82
- input_type: moduleItem.input_type,
83
- module_id: moduleItem.module_id,
84
- prefix: moduleItem.prefix,
85
- suffix: moduleItem.suffix,
86
- unit: moduleItem.units.length ? moduleItem.units[0] : {
87
- unit_id: 0,
88
- unit_name: ''
89
- }
90
- }
91
- })
92
- }
93
-
94
- let moduleItem = measure_templatesItem.value_modules.find(moduleItem => moduleItem.input_type === 'enum_diy')
95
- if (moduleItem) {
96
- // 查询到需要的带单位的
97
- measure_values = moduleItem.values
98
- }
99
- }
100
-
101
- property_values = item.options.map(value => {
102
-
103
- // let disableContent = measure_values.findIndex(valueItem => valueItem.value_name === value.name)
104
-
105
- return {
106
- name: value.name,
107
- value_id: value.value_id,
108
- value: value.value,
109
-
110
- disableContent: false, // 是否需要成分
111
- content: '', // 成分
112
- }
113
- })
114
- }
115
-
116
- let show_condition = []
117
-
118
-
119
- return {
120
-
121
- property_id: item.property_id, // 属性id
122
- property_required: item.required == 1, // 是否必填
123
- property_name: item.property_name, // 属性名称
124
-
125
- property_type: property_type, // 属性类型,0:未知 1:文本,2:单选,3:多选, 4:单位输入(数字)5:日期选择,6:组合多选
126
- property_value: undefined ,// 属性值(根据具体属性类型,属性值类型不同)
127
-
128
- property_values: property_values, // 属性可选值列表(单选、多选)
129
-
130
- property_unit: property_unit, // 单位
131
- property_units: property_units, // 单位列表
132
-
133
- select_max_num: select_max_num ,// 最多选择多少个选项(多选,组合多选使用)
134
- select_custom: false, // 是否支持自定义选项
135
-
136
- input_max_num: input_max_num, // 输入文本最大字数(纯文本输入使用)
137
- input_num: 0, // 当前文本输入字数
138
-
139
- input_type: input_type, // 输入类型(单位输入使用),number: 整数,float: 价格
140
-
141
- input_format: input_format, // 输入格式(单位输入使用)
142
- input_min_value: '', // 范围输入,最小值
143
- input_max_value: '', // 范围输入,最大值
144
-
145
- date_format: date_format, // 日期格式(日期使用)
146
-
147
- measure_templates: measure_templates, // 属性模版 (组合模版)
148
-
149
- has_children: false, // 没有子属性,
150
- show_condition: show_condition ,// 显示条件,有数据即为子属性
151
- condition_values: [], // 子属性根据父属性筛选后的 选项列表
152
- }
153
- })
154
-
155
- return propertys
156
- }
File without changes
File without changes
@@ -1,152 +0,0 @@
1
-
2
- export default {
3
- createCategoryProperties
4
- }
5
-
6
- /**
7
- * 根据拼多多分类规则与属性,生成自定义 上货属性
8
- * */
9
- function createCategoryProperties(categoryPropertys) {
10
-
11
- // 是否包含了子分类
12
- var hasChildren = false
13
-
14
- let propertys = categoryPropertys.filter(item => !item.is_sale).map(item => {
15
-
16
- if (item?.property_id !== undefined && item?.property_value !== undefined && item.property_type !== undefined) {
17
- if (item?.show_condition.length) {
18
- // 有条件,即为 子属性
19
- hasChildren = true
20
- }
21
- return item
22
- }
23
-
24
- var property_values = []
25
- if (item.values) {
26
- // 选项列表
27
- property_values = item.values.map(value => {
28
-
29
- return {
30
- name: value.value,
31
- value_id: value.vid,
32
- value: value.vid,
33
- parent_value: value.parent_vids ? value.parent_vids : []
34
- }
35
- })
36
- }
37
-
38
- var property_type = 0
39
-
40
- var property_units = item.value_unit.filter(unitItem => unitItem)
41
- var property_unit = property_units.length ? property_units[0] : ''
42
-
43
- var select_max_num = 0
44
-
45
- var input_max_num = 0
46
- var input_type = ''
47
- var input_format = ''
48
-
49
- var date_format = ''
50
-
51
- if (item.choose_max_num == 0) {
52
- // 文本
53
- if (item.property_value_type == 5) {
54
- // 日期(拼多多日期格式为‘yyyy-MM-dd’, 目前仅发现”生产日期“)
55
- property_type = 5
56
- date_format = "yyyy-MM-dd"
57
- } else if (property_unit) {
58
- // 有带单位 (拼多多 仅发现整数输入)
59
- property_type = 4
60
- input_type = 'number'
61
- } else {
62
- // 纯文本
63
- property_type = 1
64
- input_max_num = Number(item.max_value) // “input_max_num“ 不可用,一直为0
65
- }
66
-
67
- } else if (item.choose_max_num == 1) {
68
- // 单选
69
- property_type = 2
70
- select_max_num = 1
71
- } else if (item.choose_max_num > 1) {
72
- // 多选
73
- property_type = 3
74
- select_max_num = item.choose_max_num
75
- }
76
-
77
- // 显示条件
78
- var show_condition = []
79
- if (item.show_condition) {
80
- // 当前属性,条件
81
- show_condition = item.show_condition.map(conditionItem => {
82
- return {
83
- parent_property_id: conditionItem.parent_ref_pid,
84
- parent_property_value: conditionItem.parent_vids
85
- }
86
- })
87
- }
88
-
89
- if (show_condition.length) {
90
- // 有条件,即为 子属性
91
- hasChildren = true
92
- }
93
-
94
- return {
95
- property_id: item.ref_pid, // 属性id
96
- property_required: item.required, // 是否必填
97
- property_name: item.name, // 属性名称
98
-
99
- property_values: property_values, // 属性可选值列表
100
- property_type: property_type, // 属性类型,0:未知 1:文本,2:单选,3:多选, 4:单位输入(数字)5:日期选择,6:组合多选
101
- property_value: undefined ,// 属性值(根据具体属性类型,属性值类型不同)
102
-
103
- property_unit: property_unit, // 单位
104
- property_units: property_units, // 单位列表
105
-
106
- select_max_num: select_max_num ,// 最多选择多少个选项(多选,组合多选使用)
107
- select_custom: false, // 是否支持自定义选项
108
-
109
- input_max_num: input_max_num, // 输入文本最大字数(纯文本输入使用)
110
- input_num: 0, // 当前文本输入字数
111
-
112
- input_type: input_type, // 输入类型(单位输入使用),number: 整数,float: 价格
113
-
114
- input_format: input_format, // 输入格式(单位输入使用)
115
- input_min_value: '', // 范围输入,最小值
116
- input_max_value: '', // 范围输入,最大值
117
-
118
- date_format: date_format, // 日期格式(日期使用)
119
-
120
- has_children: false, // 没有子属性,
121
- show_condition: show_condition ,// 显示条件,有数据即为子属性
122
- condition_values: [], // 子属性根据父属性筛选后的 选项列表
123
- }
124
- })
125
-
126
- if (hasChildren) {
127
- // 当前属性列表中存在 子属性,给子属性的父属性设置
128
- propertys.forEach(item => {
129
- if (item.show_condition.length) {
130
- // 当前属性为 子属性, 找到父属性
131
- item.show_condition.forEach(conditionItem => {
132
-
133
- let result = propertys.find(propertyItem => propertyItem.property_id === conditionItem.parent_property_id)
134
- if (result) {
135
- // 找到父属性,并设置父属性 有子属性标识
136
- result.has_children = true
137
- }
138
- })
139
-
140
- // 排序 子属性放至最前面 (方便后续分组)
141
- let index = propertys.findIndex(propertyItem => propertyItem.property_id === item.property_id)
142
- if (index != -1) {
143
- propertys.splice(index , 1)
144
- propertys.unshift(item)
145
- }
146
- }
147
- })
148
- }
149
- // console.log("自定义属性列表", JSON.stringify(propertys))
150
- return propertys
151
-
152
- }
File without changes
@@ -1,321 +0,0 @@
1
-
2
- export default {
3
- createCategoryProperties
4
- }
5
-
6
- function createCategoryProperties(categoryPropertys) {
7
-
8
- console.log(categoryPropertys)
9
-
10
- let propertys = categoryPropertys.map(item => {
11
-
12
- if (item?.property_id && item?.property_name && item?.property_type) {
13
- // 已经转换为自定义完成
14
- return item
15
- }
16
-
17
- if (!item.values) {
18
- item.values = []
19
- }
20
-
21
- var property_required = false
22
-
23
- var select_max_num = 0
24
- var input_max_num = 0
25
-
26
- var has_children = false
27
-
28
- if (item.rules) {
29
- // 属性有规则
30
- var rule = item.rules?.rule || []
31
-
32
- var ruleList = []
33
- if (rule instanceof Array) {
34
- ruleList = [...rule]
35
- } else {
36
- ruleList = [rule]
37
- }
38
-
39
- ruleList.forEach(ruleItem => {
40
- if (ruleItem.name === 'requiredRule') {
41
- // 有找到必须标识
42
- property_required = Boolean(ruleItem.value)
43
- } else if (ruleItem.name === 'maxLengthRule') {
44
- // 输入限制
45
- input_max_num = Number(ruleItem.value)
46
- } else if (ruleItem.name === 'maxInputNumRule') {
47
- // 选择限制
48
- select_max_num = Number(ruleItem.value)
49
- } else if (ruleItem.name === 'devTipRule') {
50
- // 有子属性
51
- has_children = true
52
- }
53
- })
54
-
55
- // if (rule instanceof Array) {
56
- // // 数组
57
-
58
- // } else {
59
- // // 对象
60
- // if (rule.name === 'requiredRule') {
61
- // // 有找到必须标识
62
- // property_required = Boolean(rule.value)
63
- // } else if (rule.name === 'maxLengthRule') {
64
- // // 输入限制
65
- // input_max_num = Number(rule.value)
66
- // } else if (rule.name === 'maxInputNumRule') {
67
- // // 选择限制
68
- // select_max_num = Number(rule.value)
69
- // }
70
- // }
71
- }
72
-
73
- var property_values = []
74
- if (item.options) {
75
- // 单选,多选
76
- if (item.options.option) {
77
- let option = item.options.option
78
- if (option instanceof Array) {
79
- property_values = item.options.option.map(value => {
80
- return {
81
- name: value.displayName,
82
- value_id: value.value,
83
- value: value.value
84
- }
85
- })
86
- } else {
87
- property_values = [{
88
- name: option.displayName,
89
- value_id: option.value,
90
- value: option.value
91
- }]
92
- }
93
- }
94
- }
95
-
96
- var property_unit = ''
97
- var property_units = []
98
- var property_unit_type = ''
99
-
100
- var input_format = '' // 值输入格式,单值输入为空
101
- var input_operator = '' // 多值输入中间分隔符
102
- var input_type = ''
103
- var input_values = [] // 多值输入内容
104
-
105
- var property_tips = ''
106
-
107
- if (item?.properties) {
108
- // 有属性限制
109
- var property = item.properties.property
110
- if (property.unitNames) {
111
- // 需要上传单位
112
- var unit = property.unitNames.unitName
113
- if (unit instanceof Object) {
114
- // 对象
115
- property_unit = unit.value
116
- property_units = [unit.value]
117
- } else if (unit instanceof Array) {
118
- // 数组(当前未遇到)
119
- }
120
- }
121
-
122
- if (property.formats) {
123
- // 输入格式
124
- let format = property.formats.format
125
- // console.log(format)
126
- format.forEach((formatItem, formatIndex) => {
127
-
128
- input_format += formatItem.text || ''
129
-
130
- if (formatItem.type === 'input' && input_format && formatIndex != 0) {
131
- // 多值
132
- input_values.push({
133
- title: format[formatIndex - 1].text || '',
134
- value: ''
135
- })
136
- }
137
-
138
- if (formatItem.type === 'operator') {
139
- // 获取多值分割符
140
- input_operator = formatItem.text
141
- }
142
- })
143
-
144
- }
145
-
146
- if (property.precision) {
147
- // 输入限制(数字,小数点后几位,0为整数)
148
- input_type = property.precision.value > 0 ? 'float' : 'number'
149
- }
150
-
151
- if (property.taoSirType) {
152
- // 限制类型
153
- property_unit_type = property.taoSirType.value
154
- }
155
-
156
-
157
- if (property.tip) {
158
- // 有提示语
159
- property_tips = property.tip?.value || ''
160
- }
161
- }
162
-
163
- var property_type = 0
164
-
165
- var date_format = ''
166
-
167
- if (item.type === 'input') {
168
- // 文本
169
-
170
- select_max_num = 0
171
- if (property_unit) {
172
- // 需要使用到 单位
173
- if (property_unit_type == 'date') {
174
- // 日期类型 (淘宝日期格式为‘yyyy-MM’, 目前仅发现”“)
175
- property_type = 5
176
- if (property_unit === '年') {
177
- date_format = 'yyyy'
178
- } else if (property_unit === '年月') {
179
- date_format = 'yyyy-MM'
180
- } else if (property_unit === '年月日') {
181
- date_format = 'yyyy-MM-dd'
182
- } else {
183
- date_format = 'yyyy-MM'
184
- }
185
- } else {
186
- // 规格输入(数字、带单位)
187
- if (input_format !== '') {
188
- // 需要输入范围值
189
- property_type = 8
190
- } else {
191
- // 只需要输入一个值
192
- property_type = 4
193
- }
194
- }
195
- } else {
196
- // 正常 纯文本
197
- property_type = 1
198
- }
199
-
200
- } else if (item.type === 'singleCheck') {
201
- // 单选
202
- property_type = 2
203
- select_max_num = 1
204
- } else if (item.type === 'multiCheck') {
205
- // 多选
206
- property_type = 3
207
- if (!select_max_num) {
208
- // 没有现在,最多选5个
209
- select_max_num = 5
210
- }
211
-
212
- } else if (item.type === 'multiComplex') {
213
- // 组合 (当前仅“材质成分”)
214
- property_type = 6
215
- var field = item.fields.field
216
-
217
- // 材质(选项)
218
- var material_prop_name = field.find(fieldItem => fieldItem.id === 'material_prop_name')
219
- // 含量(输入)
220
- var material_prop_content = field.find(fieldItem => fieldItem.id === 'material_prop_content')
221
-
222
- // 组合多选 选项内容
223
- if (material_prop_name.options) {
224
-
225
- if (material_prop_name.options.option) {
226
- property_values = material_prop_name.options.option.map(value => {
227
- return {
228
- name: value.displayName,
229
- value_id: value.value,
230
- value: value.value,
231
-
232
- disableContent: false, // 是否需要成分
233
- content: '', // 成分
234
- }
235
- })
236
- }
237
-
238
- }
239
-
240
- // 设置组合规则
241
- if (material_prop_content.rules) {
242
- // 有规则
243
- if (material_prop_content.rules.rule) {
244
-
245
- // 获取不可用
246
- var disableRule = material_prop_content.rules.rule.find(rule => rule.name === 'disableRule')
247
- if (disableRule) {
248
- // 有不可用的规则
249
- var express = disableRule["depend-group"]["depend-express"]
250
- if (express) {
251
- // 获取到无需设置 成分的
252
- express.forEach(expressItem => {
253
-
254
- if (expressItem.fieldId === 'material_prop_name') {
255
-
256
- property_values.push({
257
- name: expressItem.value,
258
- value_id: expressItem.value,
259
- value: expressItem.value,
260
-
261
- disableContent: true, // 是否需要成分
262
- content: '', // 成分
263
- })
264
- }
265
- })
266
- }
267
- }
268
- }
269
- }
270
- // console.log("材质面料选项", JSON.stringify(property_values))
271
-
272
- if (!select_max_num) {
273
- // 没有现在,最多选5个
274
- select_max_num = 7
275
- }
276
- property_tips = '最多设置' + select_max_num + '个'
277
- }
278
-
279
-
280
- let show_condition = []
281
-
282
- return {
283
- property_id: item.id, // 属性id
284
- property_required: property_required, // 是否必填
285
- property_name: item.name, // 属性名称
286
-
287
- property_values: property_values, // 属性可选值列表
288
- property_type: property_type, // 属性类型,0:未知 1:文本,2:单选,3:多选, 4:单位输入(数字)5:日期选择,6:组合多选
289
- property_value: undefined ,// 属性值(根据具体属性类型,属性值类型不同)
290
-
291
- property_unit: property_unit, // 单位
292
- property_units: property_units, // 单位列表
293
-
294
- select_max_num: select_max_num ,// 最多选择多少个选项(多选,组合多选使用)
295
- select_custom: false, // 是否支持自定义选项
296
-
297
- input_max_num: input_max_num, // 输入文本最大字数(纯文本输入使用)
298
- input_num: 0, // 当前文本输入字数
299
-
300
- input_type: input_type, // 输入类型(单位输入使用),number: 整数,float: 价格
301
-
302
- input_format: input_format, // 输入格式(单位输入使用)
303
- input_values: input_values, // 多值输入内容
304
- input_operator: input_operator, // 多值输入分格符
305
- input_min_value: '', // 范围输入,最小值
306
- input_max_value: '', // 范围输入,最大值
307
-
308
- date_format: date_format, // 日期格式(日期使用)
309
-
310
- property_tips: property_tips, // 提示
311
-
312
- has_children: has_children, // 没有子属性,
313
- show_condition: show_condition ,// 显示条件,有数据即为子属性
314
- condition_values: [], // 子属性根据父属性筛选后的 选项列表
315
- }
316
- })
317
-
318
- console.log(propertys)
319
-
320
- return propertys;
321
- }
File without changes
File without changes
File without changes