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