From 80e9bdda2efe7309acb76aeb9ebe935008fec92d Mon Sep 17 00:00:00 2001 From: tengge1 <930372551@qq.com> Date: Wed, 23 Oct 2019 20:56:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9C=BA=E6=9E=84=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E7=AA=97=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/editor/system/dept/EditDeptWindow.jsx | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 ShadowEditor.Web/src/editor/system/dept/EditDeptWindow.jsx diff --git a/ShadowEditor.Web/src/editor/system/dept/EditDeptWindow.jsx b/ShadowEditor.Web/src/editor/system/dept/EditDeptWindow.jsx new file mode 100644 index 00000000..81b9034a --- /dev/null +++ b/ShadowEditor.Web/src/editor/system/dept/EditDeptWindow.jsx @@ -0,0 +1,96 @@ +import { PropTypes, Window, Content, Buttons, Form, FormControl, Label, Input, Button } from '../../../third_party'; + +/** + * 组织机构编辑窗口 + * @author tengge / https://github.com/tengge1 + */ +class EditDeptWindow extends React.Component { + constructor(props) { + super(props); + + this.state = { + id: props.id, + name: props.name, + }; + + this.handleChange = this.handleChange.bind(this); + this.handleSave = this.handleSave.bind(this, props.callback); + this.handleClose = this.handleClose.bind(this); + } + + render() { + const { name } = this.state; + + return + +
+ + + + +
+
+ + + + +
; + } + + handleChange(value, name) { + this.setState({ + [name]: value, + }); + } + + handleSave(callback) { + const { id, name } = this.state; + + if (!name || name.trim() === '') { + app.toast(_t('Name is not allowed to be empty.')); + return; + } + + const url = !id ? `/api/Role/Add` : `/api/Role/Edit`; + + fetch(`${app.options.server}${url}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: `ID=${id}&Name=${name}`, + }).then(response => { + response.json().then(json => { + if (json.Code !== 200) { + app.toast(_t(json.Msg)); + return; + } + this.handleClose(); + callback && callback(); + }); + }); + } + + handleClose() { + app.removeElement(this); + } +} + +EditDeptWindow.propTypes = { + id: PropTypes.string, + name: PropTypes.string, + callback: PropTypes.func, +}; + +EditDeptWindow.defaultProps = { + id: '', + name: '', + callback: null, +}; + +export default EditDeptWindow; \ No newline at end of file