Commit 57cf31c7 authored by 武广's avatar 武广

Merge branch 'feature-0430-gold' into 'master'

Feature 0430 gold

See merge request !121
parents 9b668ec5 1c00ea67
...@@ -233,6 +233,7 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -233,6 +233,7 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const editRef = useRef(null); const editRef = useRef(null);
const packageRef = useRef(null); const packageRef = useRef(null);
const customer = useContext(ServiceContext); const customer = useContext(ServiceContext);
const customerRef = useRef(customer);
const [form] = Form.useForm(); const [form] = Form.useForm();
const [specInitValue, setSpecInitValue] = useState(initSpecReced()); const [specInitValue, setSpecInitValue] = useState(initSpecReced());
...@@ -321,7 +322,9 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -321,7 +322,9 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const isGoodsManage = window.location.pathname.indexOf('popGoodsManage') < 0; const isGoodsManage = window.location.pathname.indexOf('popGoodsManage') < 0;
const dynamicColumns = [ const dynamicColumns = [
...columsData, ...columsData,
...(isGoodsManage ? StaticColumns(customer) : StaticColumnsPop(customer)), ...(isGoodsManage
? StaticColumns(customerRef.current)
: StaticColumnsPop(customerRef.current)),
]; ];
setDefaultColumns(dynamicColumns); setDefaultColumns(dynamicColumns);
}; };
...@@ -401,6 +404,38 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -401,6 +404,38 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const getFormValues = debounce(async () => { const getFormValues = debounce(async () => {
const cleanValues = await onSpecificationEvent(); const cleanValues = await onSpecificationEvent();
props.onValuesChange({ infoSpecData: cleanValues }); props.onValuesChange({ infoSpecData: cleanValues });
setTimeout(async () => {
const values = await form.validateFields();
// eslint-disable-next-line no-shadow
const cleanValues = {
firstValues: cleanArray(values.firstSpecValue || []),
secondValues: cleanArray(values.secondSpecValue || []),
firstSpecId:
values.firstSpecValue && values.firstSpecValue.length ? values.firstSpecId : null,
secondSpecId:
values.secondSpecValue && values.secondSpecValue.length ? values.secondSpecId : null,
};
const { inIdList: fisrtInIdList, noIdList: fisrtNoIdList } = filterSkuNotIdList(
cleanValues.firstValues,
);
const { inIdList: secndInIdList, noIdList: secndNoIdList } = filterSkuNotIdList(
cleanValues.secondValues,
);
const createSkuList = createProductData(
{
firstSpecId: cleanValues.firstSpecId,
secondSpecId: cleanValues.secondSpecId,
fisrtInIdList,
secndInIdList,
fisrtNoIdList,
secndNoIdList,
},
customer.isEdit,
skuList,
);
props.onValuesChange({ skuList: fliterSkuListSortData([...createSkuList]) });
}, 0);
}, 400); }, 400);
const packageValueChange = () => { const packageValueChange = () => {
...@@ -444,6 +479,16 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -444,6 +479,16 @@ const FormPriceOrStock = forwardRef((props, ref) => {
}, },
})); }));
useEffect(() => {
customerRef.current = customer;
}, [customer]);
useEffect(() => {
(async () => {
await onSpecificationEvent();
})();
}, [customer.isGold]);
useEffect(() => { useEffect(() => {
if (customer.isEdit || customer.isUseCache) { if (customer.isEdit || customer.isUseCache) {
if (!editData) { if (!editData) {
......
...@@ -31,6 +31,7 @@ import { ServiceContext } from './context'; ...@@ -31,6 +31,7 @@ import { ServiceContext } from './context';
import { GOOD_MANAGE } from '@/../config/permission.config'; import { GOOD_MANAGE } from '@/../config/permission.config';
import styles from './common.less'; import styles from './common.less';
import { GoldCategory } from '@/config/app.config'; import { GoldCategory } from '@/config/app.config';
import { debounce } from '@/utils/utils';
/** /**
* 服务商品改造-商品模块 * 服务商品改造-商品模块
...@@ -377,7 +378,7 @@ const ServiceGoods = options => { ...@@ -377,7 +378,7 @@ const ServiceGoods = options => {
} }
setPageLoading(false); setPageLoading(false);
})(); })();
}, [SourceData, categoryIds]); }, [SourceData]);
useEffect(() => { useEffect(() => {
if (options.visible) { if (options.visible) {
...@@ -443,10 +444,10 @@ const ServiceGoods = options => { ...@@ -443,10 +444,10 @@ const ServiceGoods = options => {
const onCategoryChange = e => { const onCategoryChange = e => {
setCategoryIds(e); setCategoryIds(e);
let txt = ''; let txt = '';
if (categoryIds.includes(GoldCategory)) { if (e.includes(GoldCategory)) {
txt = '千克';
} else if (e.includes(GoldCategory)) {
txt = ''; txt = '';
} else {
txt = '千克';
} }
if (txt) { if (txt) {
message.warning(`商品品类已切换,规格重量单位已自动切换为${txt}`, 6); message.warning(`商品品类已切换,规格重量单位已自动切换为${txt}`, 6);
...@@ -454,7 +455,7 @@ const ServiceGoods = options => { ...@@ -454,7 +455,7 @@ const ServiceGoods = options => {
}; };
// 保存草稿 // 保存草稿
const onSaveDraft = async () => { const onSaveDraft = debounce(async () => {
const info = localStorage.get(localAutoSaveKey); const info = localStorage.get(localAutoSaveKey);
if ( if (
!info || !info ||
...@@ -506,7 +507,7 @@ const ServiceGoods = options => { ...@@ -506,7 +507,7 @@ const ServiceGoods = options => {
handleCancel(true); handleCancel(true);
}, },
}); });
}; }, 400);
const isPopGoods = location.pathname.indexOf('popGoodsManage') > 0; // pop商品管理-商品库(应付审计用的, 驳回和修改状态下不能编辑) const isPopGoods = location.pathname.indexOf('popGoodsManage') > 0; // pop商品管理-商品库(应付审计用的, 驳回和修改状态下不能编辑)
const providerValue = { const providerValue = {
pageId, pageId,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment