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

fix: 修改导入功能

parent 79adc898
......@@ -4,8 +4,7 @@ import { SwapRightOutlined } from '@ant-design/icons';
import { connect } from 'dva';
import styles from '../../style.less';
import { stateList } from '../../staticdata';
import { uploadConfig } from '../staticdata';
import { apiDownBiddingTemplate } from '../../service';
import { apiDownBiddingTemplate, apiUploadGoodsFile } from '../../service';
const FormItem = Form.Item;
const { Option } = Select;
......@@ -18,6 +17,7 @@ class goodsManage extends Component {
state = {
productType: null,
loading: false,
};
componentDidMount() {
......@@ -38,7 +38,6 @@ class goodsManage extends Component {
onDownload = () => {
const form = this.formRef.current;
const values = form.getFieldsValue();
console.log('values :>> ', values);
apiDownBiddingTemplate(values);
};
......@@ -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() {
const { treeData } = this.props;
const selectW = { width: 250 };
......@@ -177,8 +198,8 @@ class goodsManage extends Component {
<Button onClick={() => this.onReset()} className={styles.button}>
重置
</Button>
<Upload {...uploadConfig}>
<Button type="primary" ghost className={styles.button}>
<Upload {...this.uploadConfig()}>
<Button type="primary" loading={this.state.loading} ghost className={styles.button}>
导入
</Button>
</Upload>
......
......@@ -2,7 +2,6 @@ import React from 'react';
import { Input, Form, InputNumber, Button, notification } from 'antd';
import { isIntegerNotMust, isCheckPriceTwoDecimal } from '@/utils/validator';
import styles from './style.less';
import { apiUploadGoodsFile } from '../service';
export function column(specArr = []) {
return [
......@@ -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) {
/**
* 导入竞价商品信息
* yApi:
* yApi: http://yapi.quantgroups.com/project/389/interface/api/45896
* * */
export async function apiUploadGoodsFile(file) {
const params = new FormData();
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,
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