|
|
@ -1,16 +1,13 @@
|
|
|
|
import { useState, useEffect } from 'react';
|
|
|
|
import { useState, useEffect } from 'react';
|
|
|
|
import { message, Divider, Empty, Flex } from 'antd';
|
|
|
|
import { Divider, Empty, Flex } from 'antd';
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
import Extras from './Detail/Extras';
|
|
|
|
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
import SecondHeaderWrapper from '@/components/SecondHeaderWrapper';
|
|
|
|
import SecondHeaderWrapper from '@/components/SecondHeaderWrapper';
|
|
|
|
import Header from './Detail/Header';
|
|
|
|
import Header from './Detail/Header';
|
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
import useProductsStore from '@/stores/Products/Index';
|
|
|
|
import useProductsStore from '@/stores/Products/Index';
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
import { HT_HOST } from '@/config';
|
|
|
|
import { PERM_PRODUCTS_MANAGEMENT } from '@/config';
|
|
|
|
import { postForm } from '@/utils/request';
|
|
|
|
|
|
|
|
import { PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT } from '@/config';
|
|
|
|
|
|
|
|
import { usingStorage } from '@/hooks/usingStorage';
|
|
|
|
import { usingStorage } from '@/hooks/usingStorage';
|
|
|
|
import ProductsTree from './Detail/ProductsTree';
|
|
|
|
import ProductsTree from './Detail/ProductsTree';
|
|
|
|
import ProductInfo from './Detail/ProductInfo';
|
|
|
|
import ProductInfo from './Detail/ProductInfo';
|
|
|
@ -18,11 +15,9 @@ import useAuthStore from '@/stores/Auth';
|
|
|
|
import NewProductModal from './Detail/NewProductModal';
|
|
|
|
import NewProductModal from './Detail/NewProductModal';
|
|
|
|
|
|
|
|
|
|
|
|
function Detail() {
|
|
|
|
function Detail() {
|
|
|
|
// const { t } = useTranslation();
|
|
|
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
const navigate = useNavigate();
|
|
|
|
const { travel_agency_id, audit_state, use_year } = useParams();
|
|
|
|
const { travel_agency_id, audit_state, use_year } = useParams();
|
|
|
|
const [addProductVisible, setAddProductVisible] = useState(false);
|
|
|
|
const [addProductVisible, setAddProductVisible] = useState(false);
|
|
|
|
const [editingProduct, ] = useProductsStore((state) => [state.editingProduct]);
|
|
|
|
|
|
|
|
const [agencyProducts, loading] = useProductsStore((state) => [state.agencyProducts, state.loading]);
|
|
|
|
const [agencyProducts, loading] = useProductsStore((state) => [state.agencyProducts, state.loading]);
|
|
|
|
const [getAgencyProducts, activeAgency] = useProductsStore((state) => [state.getAgencyProducts, state.activeAgency]);
|
|
|
|
const [getAgencyProducts, activeAgency] = useProductsStore((state) => [state.getAgencyProducts, state.activeAgency]);
|
|
|
|
const [setSwitchParams] = useProductsStore((state) => [state.setSwitchParams]);
|
|
|
|
const [setSwitchParams] = useProductsStore((state) => [state.setSwitchParams]);
|
|
|
@ -42,165 +37,16 @@ function Detail() {
|
|
|
|
setSwitchParams(param);
|
|
|
|
setSwitchParams(param);
|
|
|
|
// setEditingProduct({});
|
|
|
|
// setEditingProduct({});
|
|
|
|
getAgencyProducts(param);
|
|
|
|
getAgencyProducts(param);
|
|
|
|
// console.log("AgencyProducts",agencyProducts);
|
|
|
|
|
|
|
|
// navigate(`/products/${agency}/${year}/${audit_state}/edit`);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isPermitted = useAuthStore((state) => state.isPermitted);
|
|
|
|
const isPermitted = useAuthStore((state) => state.isPermitted);
|
|
|
|
const [editable, setEditable] = useState(true);
|
|
|
|
const topPerm = isPermitted(PERM_PRODUCTS_MANAGEMENT); // 高级权限
|
|
|
|
|
|
|
|
const [newActionable, setNewActionable] = useState(false);
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
const notAudit = activeAgency.audit_state_id < 0 || activeAgency.audit_state_id === 3;
|
|
|
|
const notAudit = activeAgency.audit_state_id < 0 || activeAgency.audit_state_id === 3;
|
|
|
|
const hasAuditPer = isPermitted(PERM_PRODUCTS_OFFER_AUDIT);
|
|
|
|
setNewActionable(topPerm || notAudit);
|
|
|
|
const hasEditPer = isPermitted(PERM_PRODUCTS_OFFER_PUT);
|
|
|
|
|
|
|
|
setEditable(hasAuditPer ? true : notAudit && hasEditPer);
|
|
|
|
|
|
|
|
// setEditable(true); // debug: 0
|
|
|
|
|
|
|
|
// console.log('editable', hasAuditPer, (notAudit && hasEditPer));
|
|
|
|
|
|
|
|
return () => {};
|
|
|
|
return () => {};
|
|
|
|
}, [activeAgency, editingProduct]);
|
|
|
|
}, [activeAgency]);
|
|
|
|
|
|
|
|
|
|
|
|
//保存产品
|
|
|
|
|
|
|
|
// const onSave = async (values) => {
|
|
|
|
|
|
|
|
// let tempInfo;
|
|
|
|
|
|
|
|
// if (info.id === '') {
|
|
|
|
|
|
|
|
// tempInfo = {
|
|
|
|
|
|
|
|
// ...info,
|
|
|
|
|
|
|
|
// ...values.info,
|
|
|
|
|
|
|
|
// city_name: values.info.city_name.label,
|
|
|
|
|
|
|
|
// audit_state: '-1',
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// delete tempInfo.product_type_name;
|
|
|
|
|
|
|
|
// delete tempInfo.dept_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let tempQuotation = quotation.map((element) => {
|
|
|
|
|
|
|
|
// const updateData = {
|
|
|
|
|
|
|
|
// ...element,
|
|
|
|
|
|
|
|
// audit_state: '-1',
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// delete updateData.tempKey;
|
|
|
|
|
|
|
|
// return updateData;
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// let tempLgc_details = [{ ...lgc_details }];
|
|
|
|
|
|
|
|
// const tempData = {
|
|
|
|
|
|
|
|
// travel_agency_id,
|
|
|
|
|
|
|
|
// info: tempInfo,
|
|
|
|
|
|
|
|
// quotation: tempQuotation,
|
|
|
|
|
|
|
|
// lgc_details: Object.values(lgc_details),
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// console.log('tempData', tempData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_save`, tempData);
|
|
|
|
|
|
|
|
// console.log('result', result);
|
|
|
|
|
|
|
|
// if (errcode === 0) {
|
|
|
|
|
|
|
|
// message.success('保存成功');
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// message.error(`保存失败: ${result}`);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tempInfo = {
|
|
|
|
|
|
|
|
// ...info,
|
|
|
|
|
|
|
|
// ...values.info,
|
|
|
|
|
|
|
|
// audit_state: '-1',
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('tempInfo', tempInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let tempQuotation = quotation.map((element) => {
|
|
|
|
|
|
|
|
// const updateData = {
|
|
|
|
|
|
|
|
// ...element,
|
|
|
|
|
|
|
|
// audit_state: '-1',
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// return updateData;
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const tempData = {
|
|
|
|
|
|
|
|
// travel_agency_id,
|
|
|
|
|
|
|
|
// info: tempInfo,
|
|
|
|
|
|
|
|
// quotation: tempQuotation,
|
|
|
|
|
|
|
|
// lgc_details: Object.values(lgc_details),
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('tempData', tempData);
|
|
|
|
|
|
|
|
// // const { errcode, result } = await postProductsSave(tempData);
|
|
|
|
|
|
|
|
// const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_save`, tempData);
|
|
|
|
|
|
|
|
// if (errcode === 0) {
|
|
|
|
|
|
|
|
// message.success('保存成功');
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// message.error(`保存失败: ${result}`);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//提交审核方法
|
|
|
|
|
|
|
|
const submitReview = async () => {
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
|
|
|
formData.append('use_year', use_year);
|
|
|
|
|
|
|
|
formData.append('travel_agency_id', travel_agency_id);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
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`);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
message.error('提交审核失败');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('result', result);
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('提交审核请求失败', error);
|
|
|
|
|
|
|
|
message.error('提交审核请求失败');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<SecondHeaderWrapper
|
|
|
|
<SecondHeaderWrapper
|
|
|
@ -211,8 +57,7 @@ function Detail() {
|
|
|
|
title={activeAgency.travel_agency_name}
|
|
|
|
title={activeAgency.travel_agency_name}
|
|
|
|
refresh={handleGetAgencyProducts}
|
|
|
|
refresh={handleGetAgencyProducts}
|
|
|
|
handleNewProduct={() => setAddProductVisible(true)}
|
|
|
|
handleNewProduct={() => setAddProductVisible(true)}
|
|
|
|
handleSubmitForAudit={submitReview}
|
|
|
|
newActionable={newActionable}
|
|
|
|
editable={editable}
|
|
|
|
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
}>
|
|
|
|
}>
|
|
|
|
{isEmpty(agencyProducts) ? (
|
|
|
|
{isEmpty(agencyProducts) ? (
|
|
|
@ -224,8 +69,7 @@ function Detail() {
|
|
|
|
<ProductsTree className='basis-64 sticky top-16 overflow-y-auto shrink-0' style={{ height: 'calc(100vh - 150px)' }} />
|
|
|
|
<ProductsTree className='basis-64 sticky top-16 overflow-y-auto shrink-0' style={{ height: 'calc(100vh - 150px)' }} />
|
|
|
|
<Divider type={'vertical'} className='mx-1 h-auto' />
|
|
|
|
<Divider type={'vertical'} className='mx-1 h-auto' />
|
|
|
|
<div className=' flex-auto grow-0 min-w-[800px]'>
|
|
|
|
<div className=' flex-auto grow-0 min-w-[800px]'>
|
|
|
|
<ProductInfo editable={editable} />
|
|
|
|
<ProductInfo />
|
|
|
|
{!isEmpty(editingProduct) && <Extras productId={editingProduct?.info?.id} />}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Flex>
|
|
|
|
</Flex>
|
|
|
|
|
|
|
|
|
|
|
|