iloom-flatten/.microcompact/mpo3ttcy/functions.Edit:34.txt

71 lines
3.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

The file /home/project/src/components/warehouse/ProductForm.tsx has been updated. Made 1 replacement.
Here's the result of running `cat -n` on a snippet of the edited file:
287→ return '01';
288→ }
289→ };
290→
291→ // 选择产品建议
292→ const selectProductSuggestion = async (suggestion: ProductSuggestion) => {
293→ // 获取该产品的纱线配比
294→ const ratios = productRatios[suggestion.id] || [];
295→
296→ // 提取产品码前缀并生成新的产品码
297→ let newFabricCode = '';
298→ const fabricMatch = suggestion.fabric_code.match(/^(.*?)(\d+)$/);
299→ if (fabricMatch && companyId) {
300→ const prefix = fabricMatch[1];
301→ newFabricCode = await generateNextFabricCode(companyId, prefix);
302→ } else {
303→ newFabricCode = suggestion.fabric_code;
304→ }
305→
306→ // 生成色号(基于该产品名称-克重-颜色组合的最大值+1
307→ // 注意:颜色字段为空,因为用户需要手动输入新颜色
308→ // 这里先使用建议产品的颜色来查询色号,实际保存时会用用户输入的颜色
309→ let newColorCode = '01';
310→ if (companyId) {
311→ newColorCode = await generateNextColorCode(
312→ companyId,
313→ suggestion.product_name,
314→ suggestion.total_weight,
315→ suggestion.color
316→ );
317→ }
318→
319→ setFormData(prev => ({
320→ ...prev,
321→ product_name: suggestion.product_name,
322→ // 自动填写克重
323→ total_weight: suggestion.total_weight ? String(suggestion.total_weight) : '',
324→ warp_weight: suggestion.warp_weight ? String(suggestion.warp_weight) : '',
325→ weft_weight: suggestion.weft_weight ? String(suggestion.weft_weight) : '',
326→ // 颜色需要用户自己输入,不自动填写
327→ color: '',
328→ // 产品码自动生成(基于数据库最大值+1
329→ fabric_code: newFabricCode,
330→ // 色号自动生成(基于该产品名称-克重-颜色组合的最大值+1
331→ color_code: newColorCode,
332→ // 自动填写生产采购价
333→ production_price: suggestion.production_price ? String(suggestion.production_price) : '',
334→ // 自动填写纱线配比
335→ yarn_ratios: ratios.length > 0
336→ ? ratios.map(r => ({ yarn_name: r.yarn_name, ratio: r.ratio, yarn_type: (r.yarn_type as 'warp' | 'weft' | 'all') || 'all' }))
337→ : [{ yarn_name: '', ratio: 100, yarn_type: 'all' }],
338→ image_url: suggestion.image_url || undefined
339→ }));
340→
341→ if (suggestion.image_url) {
342→ setPreviewUrl(suggestion.image_url);
343→ }
344→
345→ setShowProductSuggestions(false);
346→
347→ // 加载该产品的克重建议
348→ searchWeights(suggestion.product_name);
349→ };
350→
351→ // 处理总克重输入
352→ const handleTotalWeightChange = (value: string) => {
353→ setFormData(prev => ({ ...prev, total_weight: value }));
354→