1.增加年份选择功能

2.增加地接需要审核结果页面,查看哪些产品和价格是否通过功能
3.地接可以在审核界面跳过去修改产品价格功能
perf/export-docx
黄文强@HWQ-PC 12 months ago
parent 3a592a640d
commit 58fc202f69

@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import { Tooltip, Button, Card, Col, Row, Breadcrumb, Table, Popconfirm, Form, Input, InputNumber, Tag, Modal, Select, Tree, FloatButton, DatePicker, Spin, message } from 'antd';
import { Link } from 'react-router-dom';
import { Tooltip, Button, Card, Col, Row, Breadcrumb, Table, Popconfirm, Form, Input, InputNumber, Tag, Modal, Select, Tree, FloatButton, DatePicker, Spin, message, Divider } from 'antd';
import { Link, useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { useProductsTypes, useProductsAuditStatesMapVal } from '@/hooks/useProductsSets';
import Extras from './Detail/Extras';
@ -24,6 +24,7 @@ import { PERM_PRODUCTS_MANAGEMENT } from '@/config';
function Detail() {
const { t } = useTranslation();
const [form] = Form.useForm();
const navigate = useNavigate()
const { RangePicker } = DatePicker;
const [tags, setTags] = useState([]);
const [isModalVisible, setIsModalVisible] = useState(false);
@ -45,7 +46,7 @@ function Detail() {
const { Search } = Input;
const [addProductVisible, setAddProductVisible] = useState(false);
const [editingProduct, setEditingProduct] = useProductsStore((state) => [state.editingProduct, state.setEditingProduct]);
const [agencyProducts, setAgencyProducts] = useProductsStore((state) => [state.agencyProducts, state.setAgencyProducts]);
const [agencyProducts, setAgencyProducts,loading] = useProductsStore((state) => [state.agencyProducts, state.setAgencyProducts, state.loading]);
const { getAgencyProducts, activeAgency } = useProductsStore();
const [expandedKeys, setExpandedKeys] = useState([]);
const [searchValue, setSearchValue] = useState('');
@ -59,6 +60,26 @@ function Detail() {
const [selectedDays, setSelectedDays] = useState([]);
const [weekdays, setWeekdays] = useState([]);
const [info, setInfo] = useState();
const yearOptions = [];
const currentYear = dayjs().year();
const baseYear = Number(use_year === 'all' ? currentYear : use_year);
for (let i = baseYear - 3; i <= baseYear + 3; i++) {
yearOptions.push({ label: i, value: i, });
}
const [param, setParam] = useState({ pick_year: baseYear, pick_agency: travel_agency_id });
const [pickYear, setPickYear] = useState(baseYear);
const handleYearChange = (value) => {
setPickYear(value);
setParam((pre) => ({ ...pre, ...{ pick_year: value } }));
};
const handleGetAgencyProducts = ({pick_year, pick_agency}={}) => {
const year = pick_year || use_year;
const agency = pick_agency || travel_agency_id;
console.log("loading",loading);
getAgencyProducts({ travel_agency_id: agency, use_year: year, audit_state });
console.log("loading",loading);
console.log("AgencyProducts",agencyProducts);
};
const travel_agency_name = activeAgency.travel_agency_name;
const audit_state_id = activeAgency.audit_state_id;
let isCanEditable = !(audit_state_id === 1 || audit_state_id === 3 || audit_state_id === -1)
@ -76,6 +97,7 @@ function Detail() {
? formatDate(currentQuotationRecord.use_dates_end)
: null;
const [editIndex, setEditIndex] = useState(null);
const presets = useDatePresets();
const handleBatchImportData = (data) => {
@ -271,13 +293,63 @@ function Detail() {
}, []);
useEffect(()=>{
handleGetAgencyProducts(param);
},[param]);
useEffect(() => {
editingProductQuotation();
}, [treeData, editingProduct])
const editingProductQuotation = () => {
console.log("editingProduct", editingProduct)
const editingProductID = editingProduct.id;
console.log("editingProductID", editingProductID)
let stopProgram = false;
for (const element of treeData) {
if (stopProgram) {
return;
}
const childList = element.children;
for (const product of childList) {
const childrenID = product.key.split('-')[1];
if (editingProductID == childrenID) {
const fatherKey = product.key.split('-')[0];
setSelectedCategory(productProject[fatherKey]);
stopProgram = true;
const tempInfo = product._raw.info;
const tempLgc_details = product._raw.lgc_details.find(record => record.lgc === 2);
console.log("tempLgc_details", tempLgc_details);
const tempQuotation = product._raw.quotation;
console.log({
info: tempInfo,
lgc_details: {
title: tempLgc_details.title,
description: tempLgc_details.descriptions
},
})
setQuotation(tempQuotation);
setTags([languageLabel]);
setRemainderLanguage(HTLanguageSets.filter(item => item.key !== language.toString()));
form.setFieldsValue({
info: tempInfo,
lgc_details: {
title: tempLgc_details.title,
description: tempLgc_details.descriptions
},
})
break;
}
}
}
}
useEffect(() => {
const fetchData = async () => {
if (productsTypes && !dataFetched) {
const agency_id = { travel_agency_id };
await getAgencyProducts(agency_id);
if (productsTypes.length > 0 && travel_agency_id && Object.keys(agencyProducts).length > 0) {
const generateTreeData = (productsTypes, productsData) => {
return productsTypes.map(type => ({
title: type.label,
@ -287,56 +359,22 @@ function Detail() {
title: product.info.title,
key: `${type.value}-${product.info.id}`,
_raw: product,
}))
})),
}));
};
const tempExpandedKeys = productsTypes.map(item => item.key)
const tempExpandedKeys = productsTypes.map(item => item.key);
const treeData = generateTreeData(productsTypes, agencyProducts);
setDataFetched(true); // true
setTreeData(treeData);
setExpandedKeys(tempExpandedKeys);
console.log("stateMapVal", stateMapVal);
setProductsData(agencyProducts);
setDefaultData(treeData);
setDataList(flattenTreeData(treeData));
setDataFetched(true);
}
};
fetchData();
}, [agencyProducts, dataFetched]);
// useEffect(()=>{
// // if(editingProduct && treeData){
// editingProductQuotation();
// // }
// },[treeData,editingProduct])
// const editingProductQuotation = () => {
// console.log("editingProduct",editingProduct)
// const editingProductID = editingProduct.id;
// let stopProgram = false;
// for (const element of treeData) {
// if (stopProgram) {
// return;
// }
// const childList = element.children;
// for (const product of childList) {
// const childrenID = product.key.split('-')[1];
// console.log("childrenID",childrenID);
// console.log("editingProductID",editingProductID);
// if (editingProductID == childrenID) {
// console.log("AAAAAAAAAA");
// console.log("product",product);
// stopProgram = true;
// handleNodeSelect(product);
// break;
// }
// }
// }
// }
}, [productsTypes, travel_agency_id, use_year, audit_state, agencyProducts]);
const flattenTreeData = (tree) => {
let flatList = [];
const flatten = (nodes) => {
@ -351,17 +389,6 @@ function Detail() {
return flatList;
};
// const ProductsSave = async (products) => {
// await postProductsSave(products)
// .then((json)=> {
// if (json.errcode === 0) {
// message.success("");
// }else{
// message.error("")
// }
// })
// }
const getParentKey = (key, tree) => {
let parentKey;
for (let i = 0; i < tree.length; i++) {
@ -425,7 +452,6 @@ function Detail() {
const handleDelete = (index) => {
const newData = [...quotation];
// // const index = newData.findIndex((item) => id === item.id);
newData.splice(index, 1);
const sortedData = [...newData].sort((a, b) => {
const aValidPeriod = dayjs(a.use_dates_end).diff(dayjs(a.use_dates_start));
@ -438,7 +464,6 @@ function Detail() {
return aGroupSize - bGroupSize;
});
setQuotation(sortedData);
};
@ -569,11 +594,6 @@ function Detail() {
});
}
const handleTagClick = (tag) => {
setSelectedTag(tag);
const matchedLanguage = HTLanguageSets.find(language => language.label === tag);
@ -657,7 +677,6 @@ function Detail() {
//
const handleNodeSelect = (_, { node }) => {
console.log("node",node)
setSelectedNodeid(node.key);
const fatherKey = node.key.split('-')[0];
setSelectedCategory(productProject[fatherKey]);
@ -675,7 +694,6 @@ function Detail() {
let infoData = node._raw.info;
setInfo(node._raw.info);
const newLgcDetails = node._raw.lgc_details
const fatherKey = node.key.split('-')[0];
setSelectedNodeid(node.key);
form.setFieldsValue({
info: {
@ -728,6 +746,7 @@ function Detail() {
let initialQuotationData = null;
let infoData = null;
let lgcDetailsData = null;
console.log("")
productsData[fatherKey].forEach(element => {
if (element.info.id === node._raw.info.id) {
initialQuotationData = element.quotation;
@ -956,16 +975,12 @@ function Detail() {
return
}
tempInfo = {
...info,
...values.info,
audit_state: "-1"
}
console.log("tempInfo", tempInfo)
let tempQuotation = quotation.map(element => {
@ -1000,12 +1015,27 @@ function Detail() {
return (
<Spin spinning={treeData.length === 0}>
<div >
<div>
<Row>
<Col span={6} className=' relative'>
<Card className='w-[inherit] fixed overflow-y-auto max-h-[80%] max-w-[22%] overflow-x-auto'>
<Row>
<Search style={{ marginBottom: 8 }} placeholder="Search" onChange={onChange} />
<Col>
<Search placeholder="Search" onChange={onChange} />
</Col>
<Col>
<Divider type="vertical" />
</Col>
<Col>
<Select
options={yearOptions}
// variant="borderless"
className="w-24"
size="middle"
value={pickYear}
onChange={handleYearChange}
/>
</Col>
</Row>
<Tree
style={{ overflowX: 'auto' }}
@ -1125,9 +1155,6 @@ function Detail() {
<Button type="primary" htmlType="submit" style={{ marginTop: 16, float: "right", marginRight: "20%" }}>
{t('Save')}
</Button>
{/* <Button type="primary" htmlType="submit" style={{ marginTop: 16, float: "right", marginRight: "5%" }}>
提交审核
</Button> */}
</Card>
</Form>
@ -1153,6 +1180,10 @@ function Detail() {
formData.append('travel_agency_id', travel_agency_id);
const { errcode, result } = await postForm(`${HT_HOST}/Service_BaseInfoWeb/agency_submit`, formData);
console.log("errcode", errcode);
if (errcode === 0) {
message.success("提交审核成功");
navigate(`/products/${travel_agency_id}/${use_year}/${audit_state}/audit`);
}
console.log("result", result);
}} />
</Tooltip>

Loading…
Cancel
Save