Commit d1372010 authored by 武广's avatar 武广

feat: 添加编辑商品套餐

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