|
@@ -33,6 +33,8 @@ function DictManager() {
|
|
|
const [groupTypeList, setGroupTypeList] = useState([]);
|
|
|
const [total, setTotal] = useState(0);
|
|
|
const [current, setCurrent] = useState(1);
|
|
|
+ const [revise, setRevise] = useState(false);//是否修改 新增修改内容
|
|
|
+ const [unsaved, setUnsaved] = useState(false);// 修改未保存弹窗
|
|
|
const [params, setParams] = useState({
|
|
|
pages: 1,
|
|
|
current: 1,
|
|
@@ -111,60 +113,6 @@ function DictManager() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- // 处理组织结构数据回显
|
|
|
- function getHospitals(arr) {
|
|
|
- arr.forEach((item, i, array) => {
|
|
|
- item.value = item.hospitalId
|
|
|
- item.title = item.hospitalName
|
|
|
- if (!item.children && item.depts) {
|
|
|
- item.depts.forEach(it => {
|
|
|
- it.value = item.parentId + '-' + it.deptId
|
|
|
- if (it.relation == 1) {
|
|
|
- list.push(it.value)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- if (item.type != 0 && item.relation == 1) {
|
|
|
- list.push(item.value)
|
|
|
- console.log(list)
|
|
|
- }
|
|
|
- if (item.children) {
|
|
|
- getHospitals(item.children)
|
|
|
- }
|
|
|
- })
|
|
|
- return list
|
|
|
- }
|
|
|
-
|
|
|
- // 禁用/启用接口
|
|
|
- function disableUser(id, status) {
|
|
|
- const param = { id: id, status: status };
|
|
|
- xPost(api.disableUser, param).then((res) => {
|
|
|
- if (res.data.code === 200) {
|
|
|
- getDictionary();
|
|
|
- setMsvisible(false);
|
|
|
- message.success((status ? '启用' : '禁用') + "成功");
|
|
|
- } else {
|
|
|
- message.warning(res.data.msg || '操作失败');
|
|
|
- }
|
|
|
- }).catch(() => {
|
|
|
- message.error("接口出错");
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- //重置密码
|
|
|
- function onResetPsd(id) {
|
|
|
- const param = { id: id };
|
|
|
- xPost(api.resetPasswordUser, param).then((res) => {
|
|
|
- if (res.data.code === 200) {
|
|
|
- getDictionary();
|
|
|
- message.success("重置成功");
|
|
|
- } else {
|
|
|
- message.warning(res.data.msg || '操作失败');
|
|
|
- }
|
|
|
- }).catch(() => {
|
|
|
- message.error("接口出错");
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
//删除
|
|
|
function deleteDictionary() {
|
|
@@ -173,6 +121,7 @@ function DictManager() {
|
|
|
if (res.data.code === 200) {
|
|
|
getDictionary();
|
|
|
setMsvisible(false);
|
|
|
+ setDictId(null)
|
|
|
message.success("删除成功");
|
|
|
} else {
|
|
|
message.warning(res.data.msg || '操作失败');
|
|
@@ -229,24 +178,43 @@ function DictManager() {
|
|
|
setModalType(type)
|
|
|
}
|
|
|
|
|
|
- //提示框确认事件
|
|
|
- function handleOk() {
|
|
|
- if (modalType == 1) {
|
|
|
- deleteDictionary(id)
|
|
|
- } else if (modalType == 2) {
|
|
|
- disableUser(id, 0)
|
|
|
- } else if (modalType == 3) {
|
|
|
- onResetPsd(id);
|
|
|
- }
|
|
|
- }
|
|
|
//提示框取消
|
|
|
- function handleCancel() {
|
|
|
+ function deleteCancel() {
|
|
|
setMsvisible(false);
|
|
|
}
|
|
|
+ // 新增修改 取消/关闭
|
|
|
function cancel() {
|
|
|
+ if(revise){
|
|
|
+ setUnsaved(true)
|
|
|
+ }else{
|
|
|
+ setVisible(false)
|
|
|
+ setFormData(null)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function isChange(tog){
|
|
|
+ setRevise(tog)
|
|
|
+ }
|
|
|
+
|
|
|
+ function addCancel() {
|
|
|
+ setRevise(false)
|
|
|
setVisible(false)
|
|
|
+ setUnsaved(false)
|
|
|
setFormData(null)
|
|
|
}
|
|
|
+
|
|
|
+ function unsavedCancel() {
|
|
|
+ setUnsaved(false)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存 新增修改
|
|
|
+ function userChange() {
|
|
|
+ setRevise(false)
|
|
|
+ setVisible(false)
|
|
|
+ getDictionary()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
function userChange() {
|
|
|
let val = form.getFieldsValue() // 页面刷新
|
|
|
const param = {
|
|
@@ -363,9 +331,19 @@ function DictManager() {
|
|
|
forceRender={true}
|
|
|
>
|
|
|
<UserContext.Provider value={{ id, type, formData, dictList }}>
|
|
|
- <AddUser userChange={userChange} />
|
|
|
+ <AddUser userChange={userChange} cancel={cancel} isChange={isChange} />
|
|
|
</UserContext.Provider>
|
|
|
-
|
|
|
+ <Modal
|
|
|
+ title="提示"
|
|
|
+ okText='确定'
|
|
|
+ cancelText='取消'
|
|
|
+ width={400}
|
|
|
+ visible={unsaved}
|
|
|
+ onOk={addCancel}
|
|
|
+ onCancel={unsavedCancel}
|
|
|
+ >
|
|
|
+ <p>当前数据未保存 是否确认关闭?</p>
|
|
|
+ </Modal>
|
|
|
</Modal>
|
|
|
: ''}
|
|
|
<Modal
|
|
@@ -374,10 +352,10 @@ function DictManager() {
|
|
|
cancelText='取消'
|
|
|
width={400}
|
|
|
visible={msvisible}
|
|
|
- onOk={handleOk}
|
|
|
- onCancel={handleCancel}
|
|
|
+ onOk={deleteDictionary}
|
|
|
+ onCancel={deleteCancel}
|
|
|
>
|
|
|
- <p>{tipText[modalType]}</p>
|
|
|
+ <p>确定要删除该参数?</p>
|
|
|
</Modal>
|
|
|
</div >
|
|
|
)
|