Commit ddfa33ce authored by guang.wu's avatar guang.wu

fix: 修改导入功能

parent 79adc898
...@@ -4,8 +4,7 @@ import { SwapRightOutlined } from '@ant-design/icons'; ...@@ -4,8 +4,7 @@ import { SwapRightOutlined } from '@ant-design/icons';
import { connect } from 'dva'; import { connect } from 'dva';
import styles from '../../style.less'; import styles from '../../style.less';
import { stateList } from '../../staticdata'; import { stateList } from '../../staticdata';
import { uploadConfig } from '../staticdata'; import { apiDownBiddingTemplate, apiUploadGoodsFile } from '../../service';
import { apiDownBiddingTemplate } from '../../service';
const FormItem = Form.Item; const FormItem = Form.Item;
const { Option } = Select; const { Option } = Select;
...@@ -18,6 +17,7 @@ class goodsManage extends Component { ...@@ -18,6 +17,7 @@ class goodsManage extends Component {
state = { state = {
productType: null, productType: null,
loading: false,
}; };
componentDidMount() { componentDidMount() {
...@@ -38,7 +38,6 @@ class goodsManage extends Component { ...@@ -38,7 +38,6 @@ class goodsManage extends Component {
onDownload = () => { onDownload = () => {
const form = this.formRef.current; const form = this.formRef.current;
const values = form.getFieldsValue(); const values = form.getFieldsValue();
console.log('values :>> ', values);
apiDownBiddingTemplate(values); apiDownBiddingTemplate(values);
}; };
...@@ -95,6 +94,28 @@ class goodsManage extends Component { ...@@ -95,6 +94,28 @@ class goodsManage extends Component {
}); });
}; };
// 上传文件设置
uploadConfig = () => {
const that = this;
return {
name: 'file',
async customRequest(info) {
that.setState({
loading: true,
});
const result = await apiUploadGoodsFile(info.file);
if (result.businessCode === '0000') {
notification.success({ message: '导入成功' });
}
that.setState({
loading: false,
});
},
accept: '.xlsx',
showUploadList: false,
};
};
render() { render() {
const { treeData } = this.props; const { treeData } = this.props;
const selectW = { width: 250 }; const selectW = { width: 250 };
...@@ -177,8 +198,8 @@ class goodsManage extends Component { ...@@ -177,8 +198,8 @@ class goodsManage extends Component {
<Button onClick={() => this.onReset()} className={styles.button}> <Button onClick={() => this.onReset()} className={styles.button}>
重置 重置
</Button> </Button>
<Upload {...uploadConfig}> <Upload {...this.uploadConfig()}>
<Button type="primary" ghost className={styles.button}> <Button type="primary" loading={this.state.loading} ghost className={styles.button}>
导入 导入
</Button> </Button>
</Upload> </Upload>
......
...@@ -2,7 +2,6 @@ import React from 'react'; ...@@ -2,7 +2,6 @@ import React from 'react';
import { Input, Form, InputNumber, Button, notification } from 'antd'; import { Input, Form, InputNumber, Button, notification } from 'antd';
import { isIntegerNotMust, isCheckPriceTwoDecimal } from '@/utils/validator'; import { isIntegerNotMust, isCheckPriceTwoDecimal } from '@/utils/validator';
import styles from './style.less'; import styles from './style.less';
import { apiUploadGoodsFile } from '../service';
export function column(specArr = []) { export function column(specArr = []) {
return [ return [
...@@ -144,15 +143,3 @@ export function columnManage() { ...@@ -144,15 +143,3 @@ export function columnManage() {
}, },
]; ];
} }
export const uploadConfig = {
name: 'file',
async customRequest(info) {
const result = await apiUploadGoodsFile(info.file);
if (result.businessCode === '0000') {
notification.success({ message: '导入成功' });
}
},
accept: '.xlsx',
showUploadList: false,
};
...@@ -426,12 +426,13 @@ export async function apiBiddingList(params) { ...@@ -426,12 +426,13 @@ export async function apiBiddingList(params) {
/** /**
* 导入竞价商品信息 * 导入竞价商品信息
* yApi: * yApi: http://yapi.quantgroups.com/project/389/interface/api/45896
* * */ * * */
export async function apiUploadGoodsFile(file) { export async function apiUploadGoodsFile(file) {
const params = new FormData(); const params = new FormData();
params.append('file', file); params.append('file', file);
const data = await request.post('/api/merchants/orders/deliveries/batches/import', { params.append('type', 6);
const data = await request.post('/api/merchants/importFile/excel', {
data: params, data: params,
prefix: goodsApi, prefix: goodsApi,
}); });
......
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