Commit 79adc898 authored by guang.wu's avatar guang.wu

feat: 添加竞价模版

parent e020b0fb
import { Form, Button, Input, Select, notification, Cascader, InputNumber } from 'antd';
import { Form, Button, Input, Select, notification, Cascader, InputNumber, Upload } from 'antd';
import React, { Component } from 'react';
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';
const FormItem = Form.Item;
const { Option } = Select;
......@@ -32,6 +34,14 @@ class goodsManage extends Component {
this.props.handleSearch(1);
};
// 下载模版
onDownload = () => {
const form = this.formRef.current;
const values = form.getFieldsValue();
console.log('values :>> ', values);
apiDownBiddingTemplate(values);
};
valueMin = value => {
const { getFieldValue, setFieldsValue } = this.formRef.current;
const minVal = getFieldValue('supplyPriceMin');
......@@ -167,6 +177,14 @@ class goodsManage extends Component {
<Button onClick={() => this.onReset()} className={styles.button}>
重置
</Button>
<Upload {...uploadConfig}>
<Button type="primary" ghost className={styles.button}>
导入
</Button>
</Upload>
<Button onClick={() => this.onDownload()} type="link" className={styles.button}>
下载模板
</Button>
</FormItem>
</Form>
);
......
import React from 'react';
import { Input, Form, InputNumber, Button } from 'antd';
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 [
......@@ -143,3 +144,15 @@ 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,
};
......@@ -2,6 +2,8 @@
import request from '@/utils/request';
import config from '../../../config/env.config';
import { stringify } from 'qs';
import { saveAs } from 'file-saver';
import { format } from 'date-fns';
import _ from 'lodash';
const { goodsApi, kdspApi } = config;
......@@ -421,3 +423,31 @@ export async function apiBiddingList(params) {
headers,
});
}
/**
* 导入竞价商品信息
* yApi:
* * */
export async function apiUploadGoodsFile(file) {
const params = new FormData();
params.append('file', file);
const data = await request.post('/api/merchants/orders/deliveries/batches/import', {
data: params,
prefix: goodsApi,
});
return data;
}
/**
* 下载竞价商品模版
* yApi: http://yapi.quantgroups.com/project/389/interface/api/67269
* * */
export async function apiDownBiddingTemplate(params) {
const res = await request.post('/api/merchants/products/bidding-template/export', {
data: stringify(_.omitBy(params, v => v === undefined && v === null && v === '')),
headers,
prefix: goodsApi,
responseType: 'arrayBuffer',
});
const blob = new Blob([res]);
saveAs(blob, `自营商品供货价更新表-${format(new Date(), 'yyyy-MM-dd')}.xlsx`);
}
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