Commit 4d028376 by 秦嘉祺

Merge branch 'feature/20210305_新增删除功能' into 'master'

新增删除功能

See merge request !1
parents 880f24ed 97236ca1
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
Row, Row,
Select, Select,
message, message,
Popconfirm
} from 'antd'; } from 'antd';
import React, { Component, Fragment } from 'react'; import React, { Component, Fragment } from 'react';
...@@ -176,9 +177,20 @@ class TableList extends Component<TableListProps, TableListState> { ...@@ -176,9 +177,20 @@ class TableList extends Component<TableListProps, TableListState> {
title: '操作', title: '操作',
render: (text, record: any) => ( render: (text, record: any) => (
<Fragment> <Fragment>
{record.ExportStatus === 0 ?
<Popconfirm
title="确定删除该条数据?"
onConfirm={() =>this.confirm(record.ID)}
okText="确认"
cancelText="取消"
>
<Button type="danger">删除</Button>
</Popconfirm>
: (
record.ExportStatus === 2 ?
<a href={apiAddress +'/Coupon/ExportCode?partnerid='+ record.PartnerID + "&id=" + record.ID}> <a href={apiAddress +'/Coupon/ExportCode?partnerid='+ record.PartnerID + "&id=" + record.ID}>
<Button disabled={record.ExportStatus !== 2} type="primary">下载</Button> <Button type="primary">下载</Button> </a> : <Button disabled={true} type="primary">下载</Button>
</a> )}
</Fragment> </Fragment>
), ),
}, },
...@@ -221,6 +233,17 @@ class TableList extends Component<TableListProps, TableListState> { ...@@ -221,6 +233,17 @@ class TableList extends Component<TableListProps, TableListState> {
}); });
}; };
confirm = (id : number) => {
const { dispatch } = this.props;
dispatch({
type: 'listAndtableList/remove',
payload: {
id:id
},
callback: this.onSuccess
})
}
handleFormReset = () => { handleFormReset = () => {
const { form, dispatch } = this.props; const { form, dispatch } = this.props;
form.resetFields(); form.resetFields();
...@@ -240,30 +263,6 @@ class TableList extends Component<TableListProps, TableListState> { ...@@ -240,30 +263,6 @@ class TableList extends Component<TableListProps, TableListState> {
}); });
}; };
handleMenuClick = (e: { key: string }) => {
const { dispatch } = this.props;
const { selectedRows } = this.state;
if (!selectedRows) return;
switch (e.key) {
case 'remove':
dispatch({
type: 'listAndtableList/remove',
payload: {
key: selectedRows.map(row => row.key),
},
callback: () => {
this.setState({
selectedRows: [],
});
},
});
break;
default:
break;
}
};
handleSelectRows = (rows: TableListItem[]) => { handleSelectRows = (rows: TableListItem[]) => {
this.setState({ this.setState({
selectedRows: rows, selectedRows: rows,
...@@ -334,7 +333,7 @@ class TableList extends Component<TableListProps, TableListState> { ...@@ -334,7 +333,7 @@ class TableList extends Component<TableListProps, TableListState> {
type: 'listAndtableList/fetch', type: 'listAndtableList/fetch',
}); });
message.success('添加成功'); message.success('操作成功');
this.handleModalVisible(); this.handleModalVisible();
} else { } else {
message.error(response.data); message.error(response.data);
...@@ -394,12 +393,6 @@ class TableList extends Component<TableListProps, TableListState> { ...@@ -394,12 +393,6 @@ class TableList extends Component<TableListProps, TableListState> {
} = this.props; } = this.props;
const { selectedRows, modalVisible, updateModalVisible, stepFormValues } = this.state; const { selectedRows, modalVisible, updateModalVisible, stepFormValues } = this.state;
const menu = (
<Menu onClick={this.handleMenuClick} selectedKeys={[]}>
<Menu.Item key="remove">删除</Menu.Item>
<Menu.Item key="approval">批量审批</Menu.Item>
</Menu>
);
const parentMethods = { const parentMethods = {
handleAdd: this.handleAdd, handleAdd: this.handleAdd,
......
...@@ -60,11 +60,11 @@ const Model: ModelType = { ...@@ -60,11 +60,11 @@ const Model: ModelType = {
}, },
*remove({ payload, callback }, { call, put }) { *remove({ payload, callback }, { call, put }) {
const response = yield call(removeRule, payload); const response = yield call(removeRule, payload);
yield put({ // yield put({
type: 'save', // type: 'save',
payload: response, // payload: response,
}); // });
if (callback) callback(); if (callback) callback(response);
}, },
*update({ payload, callback }, { call, put }) { *update({ payload, callback }, { call, put }) {
const response = yield call(updateRule, payload); const response = yield call(updateRule, payload);
......
...@@ -3,10 +3,11 @@ import { TableListParams } from './data.d'; ...@@ -3,10 +3,11 @@ import { TableListParams } from './data.d';
//export const apiAddress = "http://localhost:8001"; //export const apiAddress = "http://localhost:8001";
//export const apiAddress = "http://172.16.0.152:809"; //export const apiAddress = "http://172.16.0.152:809";
export const apiAddress = "http://115.159.226.87:8090"; export const apiAddress = "http://115.159.226.87:8090";
const getExportRecord = apiAddress + "/Coupon/GetExportRecord"; const getExportRecord = apiAddress + "/Coupon/GetExportRecord";
const addExportRecord =apiAddress + "/Coupon/AddExportRecord"; const addExportRecord =apiAddress + "/Coupon/AddExportRecord";
const deleteExportRecord =apiAddress + "/Coupon/DeleteExportRecord";
const exportCode =apiAddress + "/Coupon/ExportCode"; const exportCode =apiAddress + "/Coupon/ExportCode";
export async function queryRule(params: TableListParams) { export async function queryRule(params: TableListParams) {
...@@ -20,11 +21,11 @@ export async function queryRule(params: TableListParams) { ...@@ -20,11 +21,11 @@ export async function queryRule(params: TableListParams) {
} }
export async function removeRule(params: TableListParams) { export async function removeRule(params: TableListParams) {
return request('/api/rule', { return request(deleteExportRecord, {
method: 'POST', method: 'POST',
data: { data: {
...params, ...params,
method: 'delete', method: 'post',
}, },
}); });
} }
......
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