Commit 839828f5 authored by cellee's avatar cellee

账号新增编辑,两个接口更新提示更改

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent 9342b445
......@@ -14,6 +14,8 @@ export default {
DataSave: null,
DataSaveDetail: null,
Permission: null,
SubResult: null, // 结果
},
reducers: {
......@@ -32,6 +34,15 @@ export default {
returnPermission(state, { Permission }) {
return { ...state, Permission };
},
returnAddAccount(state, result) {
let SubResult = { ...state.SubResult, ...result.Data };
return { ...state, SubResult };
},
returnDelccount(state, { SubResult }) {
return { ...state, SubResult };
},
},
effects: {
......@@ -43,6 +54,7 @@ export default {
}
if (resp.error_code != '0000') {
printf(playload, resp);
message.error(`${resp.error_code}:${resp.error_msg}`);
} else {
switch (playload.index) {
case 41:
......@@ -53,16 +65,18 @@ export default {
break;
case 38:
{
console.log(resp);
let Data = {
statr: 0,
};
yield put({ type: 'returnAddAccount', Data });
}
break;
case 42:
{
// 保存成功, 清掉原来数据 并且跳转
message.success('Submitted Successfully !');
let Data = null;
yield put({ type: 'returnPage', Data });
history.go(-1);
let Data = {
desc: 0,
};
yield put({ type: 'returnAddAccount', Data });
}
break;
case 45:
......@@ -109,5 +123,11 @@ export default {
console.log(DataSave);
yield put({ type: 'returnDataSave', DataSave });
},
// 清除
*AccountClear({}, { put }) {
var SubResult = null;
yield put({ type: 'returnDelccount', SubResult });
},
},
};
import React, { useState, useEffect, useRef } from 'react';
import {
Form,
Input,
Button,
Pagination,
message,
Descriptions,
Checkbox,
Tree,
Radio,
} from 'antd';
import { Form, Input, Button, Pagination, message, Descriptions, Spin, Tree, Radio } from 'antd';
import { connect, history } from 'umi';
import { SearchOutlined, ClearOutlined, EditOutlined, LeftOutlined } from '@ant-design/icons';
import { getCookie } from '@/utils/method';
......@@ -27,18 +17,13 @@ import moment from 'moment';
const Account = (props: any) => {
const module = 'Account';
const { dispatch, Data, DataSave, DataSaveDetail, Result, loading, user } = props;
// 拉取数据的条件存储
const [term, setTerm] = useState({} as any);
// 小区列表
// const [comList, setCommunityList] = useState(CommunityList as any);
const { dispatch, Data, DataSave, SubResult, CommunityList, loading, user } = props;
// 权限列表
const treeData = enUsFaci || zhCnFaci;
const [expandedKeys, setExpandedKeys] = useState<string[]>([]); // 展开栏目
const [checkedKeys, setCheckedKeys] = useState<string[]>([] as any); // 默认已选栏目
const [checkedKeys, setCheckedKeys] = useState([] as any); // 默认已选栏目
const [selectedKeys, setSelectedKeys] = useState<string[]>([]); // 设置选中的树节点
const [autoExpandParent, setAutoExpandParent] = useState<boolean>(true); // 树形菜单展开关闭
......@@ -80,9 +65,21 @@ const Account = (props: any) => {
}
}, [user]);
useEffect(() => {
// 提交信息结果
if (SubResult != null) {
if (SubResult.statr == 0 && SubResult.desc == 0) {
// 保存成功, 清掉原来数据 并且跳转
message.success('Submitted Successfully !');
dispatch({ type: module + '/ReData' });
dispatch({ type: module + '/AccountClear' });
history.go(-1);
}
}
}, [SubResult]);
// 保存提交
const onFinishContract = async (value: any) => {
// console.log(value);
if (
value.tosAccountName.length <= 2 &&
value.tosUserPhone.length != 8 &&
......@@ -91,7 +88,8 @@ const Account = (props: any) => {
// 姓名联系方式
message.error('Please enter the correct name and contact information!');
return false;
} else if (checkedKeys.length == 0) {
} else if (checkedKeys[0].key) {
// 如果存在key 就是没有选择
// 权限
message.error('Please Select Permission!');
return false;
......@@ -110,7 +108,12 @@ const Account = (props: any) => {
value.creatorName = getCookie('name'); //新建者账号
value.creatorId = getCookie('id'); //新建者ID
delete value.community;
// console.log(value);
// console.log(checkedKeys);
// 判断有没有 0 有就删除
for (var i in checkedKeys) {
checkedKeys[i] == '0' ? checkedKeys.splice(i, 1) : '';
}
// 另传权限
let obj = {
......@@ -120,7 +123,6 @@ const Account = (props: any) => {
return parseInt(n1) - parseInt(n2);
}),
};
// console.log(obj);
RA(38, value, module, dispatch); // 信息上传
RA(42, obj, module, dispatch); // 权限上传
......@@ -173,7 +175,7 @@ const Account = (props: any) => {
// 选择小区名字并赋值
return (
<>
<Spin spinning={loading}>
<div className="contop" style={{ padding: '12px 20px' }}>
<h3 className="capi">
<EditOutlined />
......@@ -222,7 +224,7 @@ const Account = (props: any) => {
</Descriptions>
<Form.Item name="community" label="Community">
<SelectCommunity />
<SelectCommunity checklist={CommunityList == null ? null : CommunityList} />
</Form.Item>
<div className="diy" style={{ marginBottom: '14px' }}>
......@@ -271,13 +273,12 @@ const Account = (props: any) => {
</div>
</Form>
</div>
</>
</Spin>
);
};
const AccountProps = (state: any) => {
console.log(state);
const { Data, DataSave, DataSaveDetail, Result } = state.Account;
const { Data, DataSave, DataSaveDetail, Result, SubResult } = state.Account;
const { CommunityList } = state.Init; // 小区列表
const loading = state.loading.models.Account || false;
const { user } = state;
......@@ -289,6 +290,7 @@ const AccountProps = (state: any) => {
loading,
CommunityList,
user, // 获取当前账户信息
SubResult,
};
};
......
......@@ -17,7 +17,7 @@ import moment from 'moment';
const Account = (props: any) => {
const module = 'Account';
const { dispatch, Data, DataSave, DataSaveDetail, Result, loading, Permission, user } = props;
const { dispatch, Data, DataSave, DataSaveDetail, SubResult, loading, Permission, user } = props;
// 权限列表
const treeData = enUsFaci || zhCnFaci;
......@@ -102,16 +102,17 @@ const Account = (props: any) => {
// 监听改变状态提交结果
useEffect(() => {
if (Result != null) {
message.success('Successful Operation !');
// setOver(false);
// 清除结果
dispatch({ type: 'Account/ResultClear' });
dispatch({ type: 'Account/ReData' });
// 退回列表
history.push('/AccountManagement/account');
// 提交信息结果
if (SubResult != null) {
if (SubResult.statr == 0 && SubResult.desc == 0) {
// 保存成功, 清掉原来数据 并且跳转
message.success('Submitted Successfully !');
dispatch({ type: module + '/ReData' });
dispatch({ type: module + '/AccountClear' });
history.go(-1);
}
}
}, [Result]);
}, [SubResult]);
// 保存提交
const onFinishContract = async (value: any) => {
......@@ -143,8 +144,14 @@ const Account = (props: any) => {
value.creatorName = getCookie('name'); //新建者账号
value.creatorId = getCookie('id'); //新建者ID
delete value.community;
// console.log(value);
value.id = DataSave.id;
// 判断有没有 0 有就删除
for (var i in checkedKeys) {
checkedKeys[i] == '0' ? checkedKeys.splice(i, 1) : '';
}
// 另传权限
let obj = {
userName: value.tosUserName,
......@@ -153,11 +160,9 @@ const Account = (props: any) => {
return parseInt(n1) - parseInt(n2);
}),
};
console.log(value);
console.log(obj);
// RA(38, value, module, dispatch); // 信息上传
// RA(42, obj, module, dispatch); // 权限上传
RA(38, value, module, dispatch); // 信息上传
RA(42, obj, module, dispatch); // 权限上传
}
};
......@@ -315,7 +320,7 @@ const Account = (props: any) => {
};
const AccountProps = (state: any) => {
const { Data, DataSave, DataSaveDetail, Result, Permission } = state.Account;
const { Data, DataSave, DataSaveDetail, Result, Permission, SubResult } = state.Account;
const loading = state.loading.models.Account || false;
const { user } = state;
return {
......@@ -326,6 +331,7 @@ const AccountProps = (state: any) => {
loading,
Permission,
user,
SubResult,
};
};
......
/*
* @Author: your name
* @Date: 2020-11-19 16:54:53
* @LastEditTime: 2020-11-27 17:32:30
* @LastEditors: your name
* @Description: In User Settings Edit
* @FilePath: \tostumi\src\utils\tip.ts
*/
// 合同提示
export const tipList = [
['Please Input Contract Numbe!'],
......@@ -61,9 +69,9 @@ export const BookingsTip = [
// 账号新增编辑
export const AccountTip = [
[{ required: true, type: 'email', message: 'Please enter email address !' }],
[{ required: true, message: 'Required' }],
[{ required: true, message: 'Please enter the correct contact information !' }],
[{ required: false, type: 'email', message: 'Please enter email address !' }],
[{ required: false, message: 'Required' }],
[{ required: false, message: 'Please enter the correct contact information !' }],
[{ required: true, message: 'Required' }],
[{ required: true, message: 'Required' }],
[{ required: true, message: 'Required' }],
......
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