|
|
|
@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef, useMemo } from 'react';
|
|
|
|
|
import { Button, Card, Col, Row, Breadcrumb, Table, Popconfirm, Form, Input, InputNumber, Tag, Modal, Select, Tree } from 'antd';
|
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
import Date from '@/views/products/Detail/date';
|
|
|
|
|
import AddValidityWithWeekend from '@/views/products/Detail/addValidityWithWeekend';
|
|
|
|
|
import { searchAgencyAction, getAgencyProductsAction } from '@/stores/Products/Index';
|
|
|
|
|
import { useProductsTypes } from '@/hooks/useProductsSets';
|
|
|
|
|
import Extras from './Detail/Extras';
|
|
|
|
@ -91,6 +91,10 @@ function Detail() {
|
|
|
|
|
{ code: "open_weekdays", name: t('products:OpenWeekdays') },
|
|
|
|
|
{ code: "remarks", name: t('products:Remarks') },
|
|
|
|
|
],
|
|
|
|
|
"8": [
|
|
|
|
|
{ code: "code", name: t('products:Code') },
|
|
|
|
|
{ code: "city_name", name: t('products:City') },
|
|
|
|
|
],
|
|
|
|
|
"R": [
|
|
|
|
|
{ code: "code", name: t('products:Code') },
|
|
|
|
|
{ code: "city_name", name: t('products:City') },
|
|
|
|
@ -102,7 +106,6 @@ function Detail() {
|
|
|
|
|
setLanguageStatus(language);
|
|
|
|
|
const matchedLanguage = HTLanguageSets.find(HTLanguage => HTLanguage.key === language.toString());
|
|
|
|
|
const languageLabel = matchedLanguage.label
|
|
|
|
|
// setTags([languageLabel])
|
|
|
|
|
setLanguageLabel(languageLabel)
|
|
|
|
|
setSelectedTag(languageLabel)
|
|
|
|
|
setRemainderLanguage(HTLanguageSets.filter(item => item.key !== language.toString()))
|
|
|
|
@ -130,6 +133,7 @@ function Detail() {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const treeData = generateTreeData(productsTypes, groupedProducts);
|
|
|
|
|
console.log("treeData", treeData)
|
|
|
|
|
setTreeData(treeData);
|
|
|
|
|
setProductsData(groupedProducts);
|
|
|
|
|
setDefaultData(treeData);
|
|
|
|
@ -228,7 +232,7 @@ function Detail() {
|
|
|
|
|
newData.splice(index, 1, { ...item, ...restRow });
|
|
|
|
|
delete newData[index].quotation
|
|
|
|
|
delete newData[index].extras
|
|
|
|
|
console.log("newData",newData)
|
|
|
|
|
console.log("newData", newData)
|
|
|
|
|
setQuotation(newData);
|
|
|
|
|
setEditingid('');
|
|
|
|
|
} else {
|
|
|
|
@ -308,10 +312,10 @@ function Detail() {
|
|
|
|
|
setDatePickerVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleBatchImportOK = () => {
|
|
|
|
|
console.log("quotation",quotation)
|
|
|
|
|
console.log('Batch Import Data:', batchImportData);
|
|
|
|
|
|
|
|
|
|
const handleBatchImportOK = () => {
|
|
|
|
|
console.log("quotation", quotation)
|
|
|
|
|
console.log('Batch Import Data:', batchImportData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建一个新的数据副本,删除 tag 和 validPeriod 属性
|
|
|
|
|
const tempBatchImportData = batchImportData.map(item => {
|
|
|
|
@ -321,11 +325,11 @@ const handleBatchImportOK = () => {
|
|
|
|
|
// 将剩余的属性添加到 quotation 中
|
|
|
|
|
const newData = [...quotation, ...tempBatchImportData];
|
|
|
|
|
|
|
|
|
|
// 更新状态来更新页面
|
|
|
|
|
setQuotation(newData);
|
|
|
|
|
setBatchImportPriceVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新状态来更新页面
|
|
|
|
|
setQuotation(newData);
|
|
|
|
|
setBatchImportPriceVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const EditableCell = ({ editing, dataIndex, title, inputType, record, children, handleDateSelect, ...restProps }) => {
|
|
|
|
|
let inputNode = inputType === 'number' ? <InputNumber /> : <Input />;
|
|
|
|
@ -494,11 +498,24 @@ const handleBatchImportOK = () => {
|
|
|
|
|
if (!selectedTag) return;
|
|
|
|
|
if (!remainderLanguage.some(item => item.label === selectedTag)) return;
|
|
|
|
|
if (remainderLanguage.includes(selectedTag)) return;
|
|
|
|
|
let tempRemainderLanguage = remainderLanguage.filter((item)=>{
|
|
|
|
|
let tempRemainderLanguage = remainderLanguage.filter((item) => {
|
|
|
|
|
return item.label !== selectedTag;
|
|
|
|
|
})
|
|
|
|
|
console.log("AAAA", lgc_details)
|
|
|
|
|
console.log("selectTag", selectedTag)
|
|
|
|
|
|
|
|
|
|
const matchedLanguage = HTLanguageSets.find(HTLanguage => HTLanguage.label === selectedTag);
|
|
|
|
|
const languageKey = matchedLanguage.key
|
|
|
|
|
const tempLgc_details = {
|
|
|
|
|
...lgc_details, [languageKey]: {
|
|
|
|
|
title: {},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log("languageKey", languageKey)
|
|
|
|
|
|
|
|
|
|
setRemainderLanguage(tempRemainderLanguage)
|
|
|
|
|
setTags([...tags, selectedTag])
|
|
|
|
|
|
|
|
|
|
setSelectedTag(null);
|
|
|
|
|
setIsModalVisible(false);
|
|
|
|
|
}
|
|
|
|
@ -532,8 +549,16 @@ const handleBatchImportOK = () => {
|
|
|
|
|
if (selectedNodeid === node.key) return;
|
|
|
|
|
const fatherKey = node.key.split('-')[0];
|
|
|
|
|
setSelectedCategory(productProject[fatherKey])
|
|
|
|
|
|
|
|
|
|
console.log("remainderLanguage",remainderLanguage)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setLanguageStatus(language);
|
|
|
|
|
const matchedLanguage = HTLanguageSets.find(HTLanguage => HTLanguage.key === language.toString());
|
|
|
|
|
const languageLabelRefresh = matchedLanguage.label
|
|
|
|
|
setLanguageLabel(languageLabelRefresh)
|
|
|
|
|
setSelectedTag(languageLabelRefresh)
|
|
|
|
|
setRemainderLanguage(HTLanguageSets.filter(item => item.key !== language.toString()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let initialQuotationData = null;
|
|
|
|
|
let infoData = null;
|
|
|
|
|
let lgcDetailsData = null;
|
|
|
|
@ -547,7 +572,6 @@ const handleBatchImportOK = () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log("infoData", infoData)
|
|
|
|
|
|
|
|
|
|
// 累积 lgc_details 数据
|
|
|
|
|
let newLgcDetails = {};
|
|
|
|
|
lgcDetailsData.forEach(element => {
|
|
|
|
@ -559,7 +583,6 @@ const handleBatchImportOK = () => {
|
|
|
|
|
|
|
|
|
|
setQuotation(initialQuotationData);
|
|
|
|
|
|
|
|
|
|
console.log("descriptions", lgc_details)
|
|
|
|
|
// 使用 setTimeout 确保 lgc_details 已经更新
|
|
|
|
|
form.setFieldsValue({
|
|
|
|
|
info: {
|
|
|
|
@ -576,6 +599,7 @@ const handleBatchImportOK = () => {
|
|
|
|
|
dept_name: infoData.dept_name
|
|
|
|
|
},
|
|
|
|
|
lgc_details: {
|
|
|
|
|
lgc: language,
|
|
|
|
|
title: newLgcDetails[language]?.title || '',
|
|
|
|
|
descriptions: newLgcDetails[language]?.descriptions || ''
|
|
|
|
|
}
|
|
|
|
@ -585,8 +609,6 @@ const handleBatchImportOK = () => {
|
|
|
|
|
const onSave = (values) => {
|
|
|
|
|
const tempData = values;
|
|
|
|
|
tempData['quotation'] = quotation;
|
|
|
|
|
// tempData['extras'] = bindingData;
|
|
|
|
|
// tempData['lgc_details'] = languageStatus;
|
|
|
|
|
setSaveData(tempData);
|
|
|
|
|
console.log("保存的数据", tempData)
|
|
|
|
|
};
|
|
|
|
@ -623,10 +645,16 @@ const handleBatchImportOK = () => {
|
|
|
|
|
<h2>{t('products:productProject')}</h2>
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
{selectedCategory.map((item, index) => (
|
|
|
|
|
<Col span={8} id={index}>
|
|
|
|
|
<Col span={8} id={index} key={`${item.code}-${index}`}>
|
|
|
|
|
<Form.Item name={['info', item.code]} label={item.name}>
|
|
|
|
|
{item.code === "duration" ? (
|
|
|
|
|
<Input suffix="H"/>
|
|
|
|
|
<Input suffix="H" />
|
|
|
|
|
) : (item.code === "display_to_c") ? (
|
|
|
|
|
<Select>
|
|
|
|
|
<Select.Option value="plan_only">在计划显示,不在报价信显示</Select.Option>
|
|
|
|
|
<Select.Option value="plan_and_quote">计划和报价信都要显示</Select.Option>
|
|
|
|
|
<Select.Option value="none"> 计划和报价信都不用显示</Select.Option>
|
|
|
|
|
</Select>
|
|
|
|
|
) : (
|
|
|
|
|
<Input />
|
|
|
|
|
)}
|
|
|
|
@ -658,7 +686,7 @@ const handleBatchImportOK = () => {
|
|
|
|
|
optionFilterProp="children"
|
|
|
|
|
onChange={handleTagChange}
|
|
|
|
|
value={remainderLanguage.some((item) => item.label === selectedTag) ? selectedTag : undefined}
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
remainderLanguage.map((value, label) => (
|
|
|
|
@ -699,7 +727,7 @@ const handleBatchImportOK = () => {
|
|
|
|
|
<Button onClick={handleAdd} type="primary" style={{ marginBottom: 16 }}>
|
|
|
|
|
{t('products:addQuotation')}
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Button onClick={handleBatchImport} type="primary" style={{ marginBottom: 16 }}>批量添加</Button>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Card>
|
|
|
|
@ -726,10 +754,10 @@ const handleBatchImportOK = () => {
|
|
|
|
|
onOk={handleDateOk}
|
|
|
|
|
onCancel={() => setDatePickerVisible(false)}
|
|
|
|
|
>
|
|
|
|
|
<Date onDateChange={handleDateChange} />
|
|
|
|
|
<AddValidityWithWeekend onDateChange={handleDateChange} />
|
|
|
|
|
</Modal>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
batchImportPriceVisible && (
|
|
|
|
@ -740,7 +768,7 @@ const handleBatchImportOK = () => {
|
|
|
|
|
onCancel={() => setBatchImportPriceVisible(false)}
|
|
|
|
|
width="80%"
|
|
|
|
|
>
|
|
|
|
|
<BatchImportPrice onBatchImportData={handleBatchImportData}/>
|
|
|
|
|
<BatchImportPrice onBatchImportData={handleBatchImportData} />
|
|
|
|
|
</Modal>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|