Commit d1372010 authored by 武广's avatar 武广

feat: 添加编辑商品套餐

parent 1b66eb80
......@@ -234,8 +234,9 @@ export const apiQueryLastChangeLog = skuId =>
// 商品上下架
export const apiChangeStateGoods = async params => {
const data = await request.post('/product/api/merchant/pushedOrOffline/batch', {
data: params,
data: stringify(params),
prefix: goodsApi,
headers,
});
return data;
};
import React from 'react';
import { Button, Badge, Switch } from 'antd';
import { Button, Badge, Switch, Modal } from 'antd';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import styles from './style.less';
import { resetTime } from '../../utils/utils';
import { apiChangeStateGoods } from './service';
const { confirm } = Modal;
export const productType = [
{
value: 1,
......@@ -33,11 +36,19 @@ export const productType = [
export function column() {
const onChangeState = async ({ skuId, state }) => {
const res = await apiChangeStateGoods({
ids: skuId,
productState: +state === 6 ? 7 : 6, // 6:上架,7:下架
confirm({
icon: <ExclamationCircleOutlined />,
content: `确认${+state === 6 ? '下架' : '上架'}商品?`,
onOk: async () => {
const res = await apiChangeStateGoods({
ids: skuId,
productState: +state === 6 ? 7 : 6, // 6:上架,7:下架
});
if (res.businessCode === '0000' && res.code === '0000') {
this.handleSearch();
}
},
});
this.handleSearch();
};
return [
......
......@@ -228,15 +228,22 @@ const FormPackage = forwardRef((props, ref) => {
};
useEffect(() => {
console.log('props.initData :>> ', props.initData);
if (props.initData && props.initData.length) {
if (props.initData.length !== list.length) {
const arr = [];
props.initData.forEach((item, i) => {
let children = [];
if (
item.serviceItem &&
item.serviceItem.setMealContent &&
item.serviceItem.setMealContent.length
) {
children = [...item.serviceItem.setMealContent];
}
arr.push({
uuid: i,
specName: `套餐${i + 1}`,
children: [],
children,
});
});
setList(arr);
......
......@@ -214,6 +214,7 @@ const CreateBatchFormItems = ({ specInitValue, batchChange, editRef, defaultColu
const FormPriceOrStock = forwardRef((props, ref) => {
const { specList, editData, skuList = [], onSpecChange } = props;
const editRef = useRef(null);
const packageRef = useRef(null);
const customer = useContext(ServiceContext);
......@@ -226,9 +227,7 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const onCheck = async () => {
try {
console.log('11111 :>> ', 11111);
const setMealContent = await packageRef.current.onCheck();
console.log('222 :>> ', 222);
const values = await form.validateFields();
const items = await editRef.current.onCheck();
if (items) {
......
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