From 6980c95ca6a5beb1ebfe32f3a2e241fc00011cdd Mon Sep 17 00:00:00 2001 From: zhenxianyimeng <1920405993@qq.com> Date: Tue, 16 Jul 2019 23:24:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=83=A8=E9=97=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-web/src/models/admin/deptmentList.js | 15 ++++++++++++- admin-web/src/pages/Admin/DeptmentList.js | 26 ++++++++++++++++++++++ admin-web/src/services/admin.js | 6 +++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/admin-web/src/models/admin/deptmentList.js b/admin-web/src/models/admin/deptmentList.js index ab44614ea..b659beca0 100644 --- a/admin-web/src/models/admin/deptmentList.js +++ b/admin-web/src/models/admin/deptmentList.js @@ -1,5 +1,11 @@ import { message } from 'antd'; -import { deptTreePage, deptTreeAll, addDeptment, updateDeptment } from '../../services/admin'; +import { + deptTreePage, + deptTreeAll, + addDeptment, + updateDeptment, + deleteDeptment, +} from '../../services/admin'; const buildSelectTree = list => { return list.map(item => { @@ -35,6 +41,13 @@ export default { onSuccess && onSuccess(); } }, + *delete({ payload }, { call, put }) { + const { onSuccess, body } = payload; + const response = yield call(deleteDeptment, body); + if (response && response.code === 0) { + onSuccess && onSuccess(); + } + }, *update({ payload }, { call, put }) { const { onSuccess, body } = payload; const response = yield call(updateDeptment, body); diff --git a/admin-web/src/pages/Admin/DeptmentList.js b/admin-web/src/pages/Admin/DeptmentList.js index a741a72c8..512c8bdfe 100644 --- a/admin-web/src/pages/Admin/DeptmentList.js +++ b/admin-web/src/pages/Admin/DeptmentList.js @@ -130,6 +130,32 @@ export default class DepetmentList extends PureComponent { } }; + handleDelete(row) { + const { dispatch } = this.props; + Modal.confirm({ + title: `确认删除?`, + content: `${row.name}`, + onOk() { + dispatch({ + type: 'deptmentList/delete', + payload: { + body: { + id: row.id, + }, + onSuccess: () => { + message.success('删除成功'); + this.handleModalVisible(); + }, + onFail: response => { + message.warn('删除失败' + response.message); + }, + }, + }); + }, + onCancel() {}, + }); + } + handleAdd = ({ fields, modalType, initValues }) => { const { dispatch } = this.props; if (modalType === 'add') { diff --git a/admin-web/src/services/admin.js b/admin-web/src/services/admin.js index d39953d0e..b3dca958e 100644 --- a/admin-web/src/services/admin.js +++ b/admin-web/src/services/admin.js @@ -74,6 +74,12 @@ export async function updateDeptment(params) { }); } +export async function deleteDeptment(params) { + return request(`/admin-api/admins/dept/delete?${stringify(params)}`, { + method: 'POST', + }); +} + export async function deptTreePage(params) { return request(`/admin-api/admins/dept/tree/page?${stringify(params)}`, { method: 'GET',