iloom-flatten/.microcompact/mpo3tt75/functions.Edit:31.txt

58 lines
2.6 KiB
Plaintext
Raw Permalink 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:
255→ // 保持两位数格式
256→ return nextNum < 10 ? `0${nextNum}` : String(nextNum);
257→ };
258→
259→ // 选择产品建议
260→ const selectProductSuggestion = async (suggestion: ProductSuggestion) => {
261→ // 获取该产品的纱线配比
262→ const ratios = productRatios[suggestion.id] || [];
263→
264→ // 提取产品码前缀并生成新的产品码
265→ let newFabricCode = '';
266→ const match = suggestion.fabric_code.match(/^(.*?)(\d+)$/);
267→ if (match && companyId) {
268→ const prefix = match[1];
269→ newFabricCode = await generateNextFabricCode(companyId, prefix);
270→ } else {
271→ newFabricCode = suggestion.fabric_code;
272→ }
273→
274→ setFormData(prev => ({
275→ ...prev,
276→ product_name: suggestion.product_name,
277→ // 自动填写克重
278→ total_weight: suggestion.total_weight ? String(suggestion.total_weight) : '',
279→ warp_weight: suggestion.warp_weight ? String(suggestion.warp_weight) : '',
280→ weft_weight: suggestion.weft_weight ? String(suggestion.weft_weight) : '',
281→ // 颜色需要用户自己输入,不自动填写
282→ color: '',
283→ // 产品码自动生成(基于数据库最大值+1
284→ fabric_code: newFabricCode,
285→ // 色号自动生成(递增)
286→ color_code: generateNextColorCode(suggestion.color_code),
287→ // 自动填写生产采购价
288→ production_price: suggestion.production_price ? String(suggestion.production_price) : '',
289→ // 自动填写纱线配比
290→ yarn_ratios: ratios.length > 0
291→ ? ratios.map(r => ({ yarn_name: r.yarn_name, ratio: r.ratio, yarn_type: (r.yarn_type as 'warp' | 'weft' | 'all') || 'all' }))
292→ : [{ yarn_name: '', ratio: 100, yarn_type: 'all' }],
293→ image_url: suggestion.image_url || undefined
294→ }));
295→
296→ if (suggestion.image_url) {
297→ setPreviewUrl(suggestion.image_url);
298→ }
299→
300→ setShowProductSuggestions(false);
301→
302→ // 加载该产品的克重建议
303→ searchWeights(suggestion.product_name);
304→ };
305→
306→ // 处理总克重输入
307→ const handleTotalWeightChange = (value: string) => {
308→ setFormData(prev => ({ ...prev, total_weight: value }));
309→