Commit 71843f40 authored by guang.wu's avatar guang.wu

feat: 添加竞价修改功能

parent f4e553b1
import React, { useState, createContext } from 'react'; import React, { useState, createContext, useEffect } from 'react';
import { Modal, Table, Form } from 'antd'; import { Modal, Table, Form } from 'antd';
import { column } from '../staticdata'; import { column } from '../staticdata';
import styles from '../style.less'; import styles from '../style.less';
import { apiProductBiddingUpdate } from '../../service';
/** /**
* 更新供货价 * 更新供货价
* * */ * * */
const UpdatePriceStock = options => { const UpdatePriceStock = options => {
const { visible, skuData, productId } = options;
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [specArr, setSpecArr] = useState([]); // 规格列
const [form] = Form.useForm(); const [form] = Form.useForm();
const onSubmit = async () => { const onSubmit = async () => {
const value = await form.validateFields(); const value = await form.validateFields();
console.log('value :>> ', value); if (!value?.data?.length) return;
const params = {
productId,
skus: value.data,
};
setLoading(true); setLoading(true);
await apiProductBiddingUpdate(params);
setLoading(false); setLoading(false);
options.refresh(); options.refresh();
options.onCancel(); options.onCancel();
...@@ -21,14 +29,47 @@ const UpdatePriceStock = options => { ...@@ -21,14 +29,47 @@ const UpdatePriceStock = options => {
const EditableContext = createContext(null); const EditableContext = createContext(null);
useEffect(() => {
if (options.visible) {
let firstSpecTitle = '';
let secondSpecTitle = '';
const arr = [];
skuData.forEach(item => {
if (item.firstSpec && item.firstSpecValue) {
firstSpecTitle = item.firstSpec;
}
if (item.secondSpec && item.secondSpecValue) {
secondSpecTitle = item.secondSpec;
}
});
if (firstSpecTitle) {
arr.push({
title: firstSpecTitle,
width: 135,
align: 'center',
dataIndex: 'firstSpecValue',
});
}
if (secondSpecTitle) {
arr.push({
title: secondSpecTitle,
width: 135,
align: 'center',
dataIndex: 'secondSpecValue',
});
}
setSpecArr(arr);
}
}, [visible]);
return ( return (
<Modal <Modal
title="修改供货价" title="修改供货价"
open={options.visible} open={visible}
onCancel={options.onCancel} onCancel={options.onCancel}
onOk={onSubmit} onOk={onSubmit}
confirmLoading={loading} confirmLoading={loading}
width={900} width={1000}
className={styles.priceStockTable} className={styles.priceStockTable}
destroyOnClose destroyOnClose
> >
...@@ -36,9 +77,10 @@ const UpdatePriceStock = options => { ...@@ -36,9 +77,10 @@ const UpdatePriceStock = options => {
<EditableContext.Provider value={form}> <EditableContext.Provider value={form}>
<Table <Table
className={styles.priceStockTable} className={styles.priceStockTable}
rowKey="key" rowKey="id"
columns={column.call(this)} columns={column.call(this, specArr)}
dataSource={options.data} dataSource={skuData}
pagination={false}
/> />
</EditableContext.Provider> </EditableContext.Provider>
</Form> </Form>
......
...@@ -16,6 +16,7 @@ import { ...@@ -16,6 +16,7 @@ import {
queryAllAfterAddress, queryAllAfterAddress,
apiEnableUpdataStock, apiEnableUpdataStock,
apiQueryLastChangeLog, apiQueryLastChangeLog,
apiProductBiddingInfo,
} from '../service'; } from '../service';
import LogModal from '../LogModal'; import LogModal from '../LogModal';
import { column, JDSHOPID } from '../staticdata'; import { column, JDSHOPID } from '../staticdata';
...@@ -30,11 +31,11 @@ import { GOOD_MANAGE } from '@/../config/permission.config'; ...@@ -30,11 +31,11 @@ import { GOOD_MANAGE } from '@/../config/permission.config';
import LocalStroage from '@/utils/localStorage'; import LocalStroage from '@/utils/localStorage';
import configApi from '@/../config/env.config'; import configApi from '@/../config/env.config';
@connect(({ goodsManage, menu }) => ({ @connect(({ SupplyPrice, menu }) => ({
goodsManage, SupplyPrice,
permissions: menu.permissions, permissions: menu.permissions,
})) }))
class goodsManage extends Component { class supplyPriceUpdate extends Component {
state = { state = {
pageNo: 1, pageNo: 1,
loading: false, loading: false,
...@@ -65,7 +66,8 @@ class goodsManage extends Component { ...@@ -65,7 +66,8 @@ class goodsManage extends Component {
searchValue: {}, // 搜索条件 searchValue: {}, // 搜索条件
refresh: '', // 外卖刷新 refresh: '', // 外卖刷新
visibleUpdatePrice: false, // 修改价格弹窗 visibleUpdatePrice: false, // 修改价格弹窗
skuPriceStockList: [{ key: 1 }, { key: 2 }], // 修改价格弹窗数据 skuPriceStockList: [], // 修改价格弹窗数据
spuId: '',
}; };
currentLog = null; currentLog = null;
...@@ -77,7 +79,7 @@ class goodsManage extends Component { ...@@ -77,7 +79,7 @@ class goodsManage extends Component {
canEditable = false; canEditable = false;
componentDidMount() { componentDidMount() {
this.props.goodsManage.tableData = {}; this.props.SupplyPrice.tableData = {};
this.categoryList(this.state.productType); this.categoryList(this.state.productType);
this.categoryListByType(this.state.productType); this.categoryListByType(this.state.productType);
this.getVirtualCategory(); this.getVirtualCategory();
...@@ -100,7 +102,7 @@ class goodsManage extends Component { ...@@ -100,7 +102,7 @@ class goodsManage extends Component {
const { dispatch } = this.props; const { dispatch } = this.props;
const { pageSize, pageNo } = this.state; const { pageSize, pageNo } = this.state;
dispatch({ dispatch({
type: 'goodsManage/getList', type: 'SupplyPrice/getList',
payload: { payload: {
pageNo, pageNo,
pageSize, pageSize,
...@@ -336,10 +338,21 @@ class goodsManage extends Component { ...@@ -336,10 +338,21 @@ class goodsManage extends Component {
}); });
}; };
// 显示更新供货价弹窗
serviceVisbleChange = async row => { serviceVisbleChange = async row => {
this.setState({ try {
visibleUpdatePrice: true, const { data } = await apiProductBiddingInfo({
}); productId: row.spuId,
});
if (!data) return;
this.setState({
spuId: row.spuId,
skuPriceStockList: data,
visibleUpdatePrice: true,
});
} catch (e) {
console.log(e);
}
}; };
// 显示新增商品弹窗 // 显示新增商品弹窗
...@@ -370,7 +383,7 @@ class goodsManage extends Component { ...@@ -370,7 +383,7 @@ class goodsManage extends Component {
render() { render() {
const { const {
goodsManage: { tableData = {} }, SupplyPrice: { tableData = {} },
permissions, permissions,
} = this.props; } = this.props;
const rowSelection = { const rowSelection = {
...@@ -514,7 +527,8 @@ class goodsManage extends Component { ...@@ -514,7 +527,8 @@ class goodsManage extends Component {
onCancel={() => { onCancel={() => {
this.setState({ visibleUpdatePrice: false }); this.setState({ visibleUpdatePrice: false });
}} }}
data={this.state.skuPriceStockList} skuData={this.state.skuPriceStockList}
productId={this.state.spuId}
refresh={this.handleSearch} refresh={this.handleSearch}
/> />
)} )}
...@@ -523,4 +537,4 @@ class goodsManage extends Component { ...@@ -523,4 +537,4 @@ class goodsManage extends Component {
} }
} }
export default Form.create()(goodsManage); export default Form.create()(supplyPriceUpdate);
import * as api from '../service';
const Model = {
namespace: 'SupplyPrice',
state: {
tableData: {},
shopList: [],
statusList: [],
cid1List: [],
cid2List: [],
cid3List: [],
treeData: [],
},
effects: {
*getList({ payload }, { call, put }) {
const params = payload;
const productCategoryId = payload?.productCategoryId || [];
params.productCategoryId =
(productCategoryId.length && productCategoryId[productCategoryId.length - 1]) || '';
const res = yield call(api.apiBiddingList, params);
if (res && !res.data) return;
yield put({
type: 'saveData',
payload: {
tableData: res.data,
},
});
},
*categoryList({ payload }, { call, put }) {
const [data] = yield call(api.categoryList, payload.value);
if (!data) return;
yield put({
type: 'saveCategory',
payload: {
[payload.categoryNum]: data,
},
});
},
},
reducers: {
saveData(state, action) {
const data = action.payload;
return { ...state, ...data };
},
dataList(state, action) {
const data = action.payload;
return { ...state, ...data };
},
saveCategory(state, action) {
const data = action.payload;
return { ...state, ...data };
},
},
};
export default Model;
import React from 'react'; import React from 'react';
import { Input, Form } from 'antd'; import { Input, Form, InputNumber } from 'antd';
import styles from '../style.less'; import { isIntegerNotMust, isCheckPriceTwoDecimal } from '@/utils/validator';
import { isNumberSection, isCheckPriceTwoDecimal } from '@/utils/validator'; import styles from './style.less';
export function column() { export function column(specArr = []) {
return [ return [
...specArr,
{ {
title: '供货价', title: '供货价',
dataIndex: 'supplyPrice', dataIndex: 'supplyPrice',
width: 150, width: 150,
align: 'center', align: 'center',
render: (_, row, index) => ( render: (_, row, index) => (
<div className={styles.price}> <div>
<Form.Item <Form.Item
label="" label=""
key="supplyPrice" key="supplyPrice"
...@@ -32,6 +33,16 @@ export function column() { ...@@ -32,6 +33,16 @@ export function column() {
width: 135, width: 135,
align: 'center', align: 'center',
dataIndex: 'marketPrice', dataIndex: 'marketPrice',
render: (_, row, index) => (
<div>
<span>{row.marketPrice}</span>
<div className={styles.hidden}>
<Form.Item label="" key="id" name={['data', index, 'skuId']} initialValue={row.id}>
<input />
</Form.Item>
</div>
</div>
),
}, },
{ {
title: '重量(kg)', title: '重量(kg)',
...@@ -51,12 +62,9 @@ export function column() { ...@@ -51,12 +62,9 @@ export function column() {
key="productStock" key="productStock"
name={['data', index, 'productStock']} name={['data', index, 'productStock']}
initialValue={row.productStock} initialValue={row.productStock}
rules={[ rules={[{ required: true, message: '请输入库存!' }, { validator: isIntegerNotMust }]}
{ required: true, message: '请输入库存!' },
{ validator: isNumberSection, min: 1, max: 500, message: '请输入1-500的整数' },
]}
> >
<Input allowClear /> <InputNumber min={1} max={500} />
</Form.Item> </Form.Item>
</div> </div>
), ),
...@@ -66,22 +74,6 @@ export function column() { ...@@ -66,22 +74,6 @@ export function column() {
width: 120, width: 120,
dataIndex: 'productStockWarning', dataIndex: 'productStockWarning',
align: 'center', align: 'center',
render: (_, row, index) => (
<div>
<Form.Item
label=""
key="productStockWarning"
name={['data', index, 'productStockWarning']}
rules={[
{ required: true, message: '请输入库存!' },
{ validator: isNumberSection, min: 1, max: 500, message: '请输入1-500的整数' },
]}
initialValue={row.productStockWarning}
>
<Input allowClear />
</Form.Item>
</div>
),
}, },
{ {
title: '商品自编码', title: '商品自编码',
......
.priceStockTable { .priceStockTable {
:global(.ant-table-cell) { :global(.ant-table-cell) {
padding: 5px 0 0 0 !important; padding: 5px 0 0 0 !important;
line-height: 32px !important;
vertical-align: top !important;
} }
} }
.hidden {
width: 0;
height: 0;
margin: 0;
padding: 0;
overflow: hidden;
}
...@@ -387,3 +387,39 @@ export async function apiProductStock(data) { ...@@ -387,3 +387,39 @@ export async function apiProductStock(data) {
params: data, params: data,
}); });
} }
/**
* 获取竞价详情
* yApi: http://yapi.quantgroups.com/project/389/interface/api/67169
* * */
export async function apiProductBiddingInfo(params) {
return request.get('/api/merchants/products/bidding/detail', {
prefix: goodsApi,
params,
});
}
/**
* 供应商更新商品供货价库存
* yApi: http://yapi.quantgroups.com/project/389/interface/api/67139
* * */
export async function apiProductBiddingUpdate(params) {
return request.post('/api/merchants/products/bidding/edit', {
prefix: goodsApi,
data: stringify(params),
headers,
});
}
/**
* 可竞价sku列表
* yApi: http://yapi.quantgroups.com/project/389/interface/api/67164
* * */
export async function apiBiddingList(params) {
const [data] = await request.post('/api/merchants/products/bidding/page', {
prefix: goodsApi,
data: stringify(params),
headers,
});
return data;
}
...@@ -193,21 +193,17 @@ export const isNumberSection = (rule, value, callback) => { ...@@ -193,21 +193,17 @@ export const isNumberSection = (rule, value, callback) => {
// 验证是否整数,非必填 // 验证是否整数,非必填
export function isIntegerNotMust(rule, value, callback) { export function isIntegerNotMust(rule, value, callback) {
if (!value) { if (!value) {
callback(); return Promise.resolve();
} }
setTimeout(() => { if (!Number(value)) {
if (!Number(value)) { return Promise.reject(new Error('请输入正整数'));
callback(new Error('请输入正整数')); }
} else { const re = /^[0-9]*[1-9][0-9]*$/;
const re = /^[0-9]*[1-9][0-9]*$/; const rsCheck = re.test(value);
const rsCheck = re.test(value); if (!rsCheck) {
if (!rsCheck) { return Promise.reject(new Error('请输入正整数'));
callback(new Error('请输入正整数')); }
} else { return Promise.resolve();
callback();
}
}
}, 1000);
} }
// 验证是否是[0-1]的小数 // 验证是否是[0-1]的小数
......
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