Commit 5a981862 authored by cellee's avatar cellee

修复设施、公告、合同bug ,重做权限管理页面

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent 7ba2ef55
...@@ -2,7 +2,7 @@ import * as service from '../../services/tos'; ...@@ -2,7 +2,7 @@ import * as service from '../../services/tos';
import { message } from 'antd'; import { message } from 'antd';
import { Link, useIntl, connect, Dispatch, history } from 'umi'; import { Link, useIntl, connect, Dispatch, history } from 'umi';
import { routerRedux } from 'dva/router' import { routerRedux } from 'dva/router';
import { printf } from '@/utils/log'; import { printf } from '@/utils/log';
...@@ -12,63 +12,64 @@ export default { ...@@ -12,63 +12,64 @@ export default {
Data: null, Data: null,
Result: null, Result: null,
DataSave: null, DataSave: null,
DataSaveDetail:null, DataSaveDetail: null,
}, },
reducers: { reducers: {
returnPage(state, { Data}) { returnPage(state, { Data }) {
return { ...state, Data }; return { ...state, Data };
}, },
returnResult(state, { Result}) { returnResult(state, { Result }) {
return { ...state, Result}; return { ...state, Result };
}, },
returnDataSave(state, { DataSave }) { returnDataSave(state, { DataSave }) {
return {...state,DataSave} return { ...state, DataSave };
}, },
returnDataSaveDetail(state, { DataSaveDetail }) { returnDataSaveDetail(state, { DataSaveDetail }) {
return {...state,DataSaveDetail} return { ...state, DataSaveDetail };
}, },
}, },
effects: { effects: {
//标准请求 //标准请求
*RA({ playload }, { call, put }) { *RA({ playload }, { call, put }) {
const resp = yield call(service.RA, playload); const resp = yield call(service.RA, playload);
console.log(resp) console.log(resp);
if (resp.code == 500||resp.error_code!="0000") { if (resp.code == 500 || resp.error_code != '0000') {
} }
if (resp.error_code != "0000") { if (resp.error_code != '0000') {
printf(playload, resp) printf(playload, resp);
} } else {
else {
switch (playload.index) { switch (playload.index) {
case 41: { case 41:
{
// let Data = resp.data; // let Data = resp.data;
// yield put({ type: 'returnPage', Data }); // yield put({ type: 'returnPage', Data });
} break; }
case 42: { break;
history.go(-1) case 42:
} break; {
case 45: { history.go(-1);
let Data = resp; }
break;
case 45:
{
let Data = resp.data;
yield put({ type: 'returnPage', Data }); yield put({ type: 'returnPage', Data });
} break; }
break;
} }
} }
}, },
*ResultClear({ }, { put }) { *ResultClear({}, { put }) {
var tmp=null var tmp = null;
yield put({type: 'returnResult', tmp} ) yield put({ type: 'returnResult', tmp });
}, },
*SA({ playload }, { call, put }) { *SA({ playload }, { call, put }) {
var DataSave = playload var DataSave = playload;
yield put({type: 'returnDataSave', DataSave} ) yield put({ type: 'returnDataSave', DataSave });
}, },
}, },
}; };
import React from 'react';
import { connect, routerRedux } from 'dva';
import { Table, Button, Input, DatePicker, Select, Modal } from 'antd';
import styles from './style.less';
import { ConnectState } from '@/models/connect';
import { router } from 'umi';
const { RangePicker } = DatePicker;
class Account extends React.Component {
//构造
constructor(props) {
super(props);
this.state = {
data: [],
total: 0,
id: '',
status: undefined,
statusList: ['正常', '关闭'],
moment: [],
delData: [],
visible: false,
nowUser: '',
name: '',
};
}
/*----------------- 方法集 ------------------*/
//模态框相关
showModal = () => {
let flag = 0;
const { delData } = this.state;
const nowUser = this.props.currentUser;
if (nowUser.permission != null) {
for (let i = 0; i < nowUser.permission.length; i++) {
if (nowUser.permission[i] == '19') {
flag = 1;
}
}
}
if (flag == 0) {
alert('缺少用户删除权限!');
return;
}
for (let i = 0; i < delData.length; i++) {
if (delData[i].userID == 1) {
alert('禁止删除超级管理员!');
return;
}
if (delData[i].userID == this.props.currentUser.userid) {
alert('禁止删除当前用户!');
return;
}
}
this.setState({
visible: true,
});
};
handleOk = (e) => {
this.del();
this.setState({
visible: false,
});
};
handleCancel = (e) => {
this.setState({
visible: false,
});
};
//批量删除
del() {
const { delData } = this.state;
for (let i = 0; i < delData.length; i++) {
if (delData[i].tosUserId == 1) {
alert('禁止删除超级管理员!');
return;
}
if (delData[i].tosUserId == this.props.currentUser.userid) {
alert('禁止删除当前用户!');
return;
}
}
this.props.dispatch({
type: 'accountModel/delAdccount',
payload: this.state.delData,
callback: (res) => {
if (res) {
if (res.error_code == '0000') {
alert(res.error_msg);
this.setState({
delData: '',
});
this.getData();
} else if (res.error_code == '0001') {
alert(res.error_msg);
} else if (res.error_code == '0002') {
alert(res.error_msg);
} else if (res.error_code == '0008') {
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
alert('删除失败!未知错误!');
}
}
},
});
}
//获取所有用户
getData = () => {
const params = {
id: this.state.id,
status: this.state.status,
moment: this.state.moment,
name: this.state.name,
// leaderID: this.props.currentUser.userid,
leaderID: '21232f297a57a5a743894a0e4a801fc3',
userPhone: '18813787835',
};
console.log(params);
this.props.dispatch({
type: 'accountModel/getAccount',
// type: 'tUModel/getTosUser',
payload: params,
callback: (res) => {
if (res) {
console.log(res);
/* for (var i = 0; i < res.rows.length; i++) {
var model = res.rows[i];
var updated_date = this.getLocalTime(model.createTime.time);
model.createTime = updated_date;
}*/
this.setState({
data: res.data.rows,
total: res.data.total,
/* data: res.rows,
total: res.total,*/
});
} else if (res.error_code == '0008') {
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
}
},
});
};
getLocalTime(nS) {
return new Date(parseInt(nS))
.toLocaleString('chinese', { hour12: false })
.replace(/:\d{1,2}$/, ' ');
}
//跳转到编辑页面
edit = (params) => {
let flag = 0;
const nowUser = this.props.currentUser;
let oneself = 0;
if (params == null && nowUser.level == 1) {
// alert("您当前用户等级不允许创建新用户!");
// return;
}
if (params != null && params.userID != null && params.userID == this.props.currentUser.userid) {
oneself = 1;
}
if (nowUser.permission != null) {
for (let i = 0; i < nowUser.permission.length; i++) {
if (params != null) {
if (oneself == 1) {
flag = 1;
}
if (nowUser.permission[i] == '17') {
flag = 1;
}
} else {
if (nowUser.permission[i] == '16') {
flag = 1;
}
}
}
}
if (flag == 0) {
if (params != null) {
// alert("缺少用户信息编辑权限!");
// return;
} else {
// alert("缺少创建用户权限!");
// return;
}
}
this.props.dispatch(
routerRedux.push({
pathname: '/AccountManagement/account/edit',
query: params,
}),
);
};
//用户禁用,启用
changeStatus = (e) => {
const params = {
userStatus: e.userStatus == '0' ? 1 : 0,
userID: e.id,
};
this.props.dispatch({
type: 'accountModel/quitAndUser',
payload: params,
callback: (res) => {
if (res.error_code == '0000') {
this.getData();
} else if (res.error_code == '0001') {
alert(res.error_msg);
} else if (res.error_code == '0002') {
alert(res.error_msg);
} else if (res.error_code == '0008') {
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
alert('修改用户状态失败!未知错误!');
}
},
});
};
//搜索状态变更
statusChange = (e) => {
this.setState({ status: e == undefined ? undefined : e == 1 ? 0 : 1 });
};
//账号名称变更
nameChange = (e) => {
this.setState({ name: e.target.value });
};
//日期变更
dateChange = (e) => {
this.setState({ moment: e });
};
//初始化
componentDidMount() {
const nowUser = this.props.currentUser.userid;
this.setState({
nowUser: nowUser,
});
this.getData();
}
/*--------------------------------------*/
//表格列名
columns = [
{
title: 'Account Name',
dataIndex: 'tosUserName',
key: 'userAccount',
},
{
title: 'Grade',
dataIndex: 'tosuserLevel',
key: 'userLevel',
render: (text, record) => (
<span>
{record.tosuserLevel == 5 ? '超级管理员' : ''}
{record.tosuserLevel == 4 ? '一级管理员' : ''}
{record.tosuserLevel == 3 ? '二级管理员' : ''}
{record.tosuserLevel == 2 ? '三级管理员' : ''}
{record.tosuserLevel == 1 ? '一级管理员' : ''}
</span>
),
},
{
title: 'Status',
dataIndex: 'userStatus',
key: 'userStatus',
render: (text, record) => <span>{record.userStatus == 0 ? '启用' : '禁用'}</span>,
},
{
title: 'Created By',
dataIndex: 'tosUserServiceCell',
key: 'createAccount',
},
{
title: 'Creation Time',
dataIndex: 'createTime',
key: 'createTime',
},
{
title: 'Actions',
dataIndex: 'action',
key: 'action',
render: (text, record) => (
<span>
<Button
style={{ background: 'transparent', border: 0, color: '#1890FF' }}
onClick={() => this.edit(record)}
>
Edit
</Button>
<Button
style={{ background: 'transparent', border: 0, color: '#1890FF' }}
onClick={() => this.changeStatus(record)}
>
{' '}
{record.userStatus == 1 ? 'lock' : 'unlock'}
</Button>
{/*{record.userID == 1||record.userID == this.props.currentUser.userid?'':
<Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.changeStatus(record)}>
{record.userStatus == 1 ? "lock" : "unlock"}</Button>}*/}
</span>
),
},
];
//行选择
rowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
delData: selectedRows,
});
},
};
//渲染
render() {
const { data, total, statusList } = this.state;
const statusSelect = statusList.map((item, index) => (
<Select.Option value={index}>{item}</Select.Option>
));
return (
<div className={styles.body}>
<div className={styles.inputBox}>
<Input
id="deviceName"
className={styles.input}
placeholder="账号名称"
onChange={(e) => this.nameChange(e)}
/>
{/*<Input id="Name" className={styles.input} placeholder="发布人姓名" />*/}
<RangePicker
style={{ marginLeft: 20 }}
renderExtraFooter={() => ''}
showTime
onChange={(e) => this.dateChange(e)}
/>
<Select placeholder="状态" onChange={(e) => this.statusChange(e)} allowClear={true}>
{statusSelect}
</Select>
<Button onClick={() => this.getData()}>搜索</Button>
</div>
<div style={{ marginTop: 10 }}>
<Button className={styles.button2} onClick={() => this.edit(null)}>
新建
</Button>
</div>
<div>
<Table
rowKey={(record) => record.userID}
className={styles.table}
rowSelection={this.rowSelection}
columns={this.columns}
dataSource={data}
size="small"
pagination={{ showQuickJumper: true, pageSize: 10, total: total }}
/>
<Button className={styles.button3} onClick={() => this.showModal()}>
删除
</Button>
</div>
<Modal
title="确认删除?"
visible={this.state.visible}
onOk={this.handleOk}
onCancel={this.handleCancel}
>
<div style={{ textAlign: 'center' }}>
<p style={{ fontSize: 18 }}>删除信息将不可恢复</p>
</div>
</Modal>
</div>
);
}
}
export default connect(({ user }: ConnectState) => ({
currentUser: user.currentUser,
}))(Account);
.contop {
background: #fff;
padding: 20px;
border-right: 4px;
margin-bottom: 15px;
.pages {
text-align: right;
padding: 10px;
}
}
.contop2 {
padding: 0 10px 20px;
}
import React from 'react'; import React, { useState, useEffect } from 'react';
import {connect, routerRedux} from 'dva'; import { Form, Input, Button, Pagination } from 'antd';
import {Table, Button, Input, DatePicker, Select, Modal} from "antd"; import { connect, history } from 'umi';
import styles from './style.less'; import { SearchOutlined, ClearOutlined, PlusOutlined } from '@ant-design/icons';
import {ConnectState} from "@/models/connect"; import ProTable from '@ant-design/pro-table';
import {router} from "umi"; import { getCookie } from '@/utils/method';
const {RangePicker,} = DatePicker; import './Account.less';
class Account extends React.Component { import moment from 'moment';
//构造 const Account = (props: any) => {
constructor(props) { const { dispatch, Data, DataSave, DataSaveDetail, Result, loading } = props;
super(props); const RA = (index: any, values: any) => {
this.state = { dispatch({ type: 'Account/RA', playload: { index: index, body: values } });
data: [],
total: 0,
id: '',
status: undefined,
statusList: ["正常", "关闭"],
moment: [],
delData: [],
visible: false,
nowUser: '',
name: '',
}
}
/*----------------- 方法集 ------------------*/
//模态框相关
showModal = () => {
let flag = 0;
const { delData } = this.state;
const nowUser = this.props.currentUser;
if(nowUser.permission!=null){
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="19"){
flag = 1;
}
}
}
if(flag == 0){
alert("缺少用户删除权限!");
return;
}
for(let i=0;i<delData.length;i++){
if(delData[i].userID == 1){
alert("禁止删除超级管理员!");
return;
}
if(delData[i].userID == this.props.currentUser.userid){
alert("禁止删除当前用户!");
return;
}
}
this.setState({
visible: true,
});
};
handleOk = (e) => {
this.del();
this.setState({
visible: false,
});
};
handleCancel = (e) => {
this.setState({
visible: false,
});
};
//批量删除
del() {
const { delData } = this.state;
for(let i=0;i<delData.length;i++){
if(delData[i].tosUserId == 1){
alert("禁止删除超级管理员!");
return;
}
if(delData[i].tosUserId == this.props.currentUser.userid){
alert("禁止删除当前用户!");
return;
}
}
this.props.dispatch({
type: 'accountModel/delAdccount',
payload: this.state.delData,
callback: (res) => {
if (res) {
if (res.error_code == "0000") {
alert(res.error_msg);
this.setState({
delData: '',
});
this.getData();
} else if(res.error_code == "0001"){
alert(res.error_msg);
} else if(res.error_code == "0002"){
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
alert("删除失败!未知错误!");
}
}
}
});
}; };
//获取所有用户
getData = () => {
const params = {
id: this.state.id,
status: this.state.status,
moment: this.state.moment,
name: this.state.name,
// leaderID: this.props.currentUser.userid,
leaderID:"21232f297a57a5a743894a0e4a801fc3",
userPhone:"18813787835"
};
console.log(params);
this.props.dispatch({
type: 'accountModel/getAccount',
// type: 'tUModel/getTosUser',
payload: params,
callback: (res) => {
if (res) {
console.log(res);
/* for (var i = 0; i < res.rows.length; i++) {
var model = res.rows[i];
var updated_date = this.getLocalTime(model.createTime.time);
model.createTime = updated_date;
}*/
this.setState({ // 数据
data: res.data.rows, useEffect(() => {
total: res.data.total, let obj = {
/* data: res.rows, leaderID: getCookie('id'),
total: res.total,*/
})
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
}
}
});
}; };
RA(45, obj);
getLocalTime(nS) { }, [1]); //页面进来执行一次
return new Date(parseInt(nS)).toLocaleString('chinese', { hour12: false }).replace(/:\d{1,2}$/, ' ');
} // 数据
//跳转到编辑页面 useEffect(() => {
edit = (params) => { if (Data == null) {
let flag = 0; let obj = {
const nowUser = this.props.currentUser; leaderID: getCookie('id'),
let oneself = 0;
if(params==null&&nowUser.level==1){
// alert("您当前用户等级不允许创建新用户!");
// return;
}
if(params!=null&&params.userID!=null&&(params.userID == this.props.currentUser.userid)){
oneself = 1;
}
if(nowUser.permission!=null){
for(let i=0;i<nowUser.permission.length;i++){
if(params!=null){
if(oneself == 1){
flag = 1;
}
if(nowUser.permission[i]=="17"){
flag = 1;
}
}else{
if(nowUser.permission[i]=="16"){
flag = 1;
}
}
}
}
if(flag == 0){
if(params!=null){
// alert("缺少用户信息编辑权限!");
// return;
}else{
// alert("缺少创建用户权限!");
// return;
}
}
this.props.dispatch(routerRedux.push({
pathname: '/AccountManagement/account/edit',
query: params,
}))
};
//用户禁用,启用
changeStatus = (e) => {
const params = {
userStatus: e.userStatus == '0' ? 1 : 0,
userID: e.id,
}; };
this.props.dispatch({ RA(45, obj);
type: 'accountModel/quitAndUser',
payload: params,
callback: (res) => {
if(res.error_code == "0000"){
this.getData();
}else if(res.error_code == "0001"){
alert(res.error_msg);
}else if(res.error_code == "0002"){
alert(res.error_msg);
}else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
}else{
alert("修改用户状态失败!未知错误!");
} }
} }, [Data]); //页面进来执行一次
});
};
//搜索状态变更
statusChange = (e) => {
this.setState({status: e == undefined ? undefined : (e == 1 ? 0 : 1)});
};
//账号名称变更
nameChange = (e) => {
this.setState({name: e.target.value});
};
//日期变更
dateChange = (e) => {
this.setState({moment: e});
};
//初始化 // 表单标识
componentDidMount() { const [form] = Form.useForm();
const nowUser = this.props.currentUser.userid;
this.setState({
nowUser: nowUser
});
this.getData();
}
/*--------------------------------------*/ // 表头
//表格列名 const columns = [
columns = [
{ {
title: 'Account Name', title: 'Account Name',
dataIndex: 'tosUserName', dataIndex: 'tosUserName',
...@@ -253,24 +47,22 @@ class Account extends React.Component { ...@@ -253,24 +47,22 @@ class Account extends React.Component {
title: 'Grade', title: 'Grade',
dataIndex: 'tosuserLevel', dataIndex: 'tosuserLevel',
key: 'userLevel', key: 'userLevel',
render: (text, record) => ( render: (text: any) => (
<span> <span>
{record.tosuserLevel == 5 ? "超级管理员" : ""} {text == 5 || text == 0 ? '超级管理员' : ''}
{record.tosuserLevel == 4 ? "一级管理员" : ""} {text == 4 ? '一级管理员' : ''}
{record.tosuserLevel == 3 ? "二级管理员" : ""} {text == 3 ? '二级管理员' : ''}
{record.tosuserLevel == 2 ? "三级管理员" : ""} {text == 2 ? '三级管理员' : ''}
{record.tosuserLevel == 1 ? "一级管理员" : ""} {text == 1 ? '一级管理员' : ''}
</span> </span>
) ),
}, },
{ {
title: 'Status', title: 'Status',
dataIndex: 'userStatus', dataIndex: 'userStatus',
key: 'userStatus', key: 'userStatus',
render: (text, record) => ( render: (text: any) => <span>{text == 0 ? '启用' : '禁用'}</span>,
<span>{record.userStatus == 0 ? "启用" : "禁用"}</span>
)
}, },
{ {
title: 'Created By', title: 'Created By',
...@@ -281,20 +73,33 @@ class Account extends React.Component { ...@@ -281,20 +73,33 @@ class Account extends React.Component {
title: 'Creation Time', title: 'Creation Time',
dataIndex: 'createTime', dataIndex: 'createTime',
key: 'createTime', key: 'createTime',
render: (text: any) => {
return moment(text.time).format('YYYY-MM-DD');
},
}, },
{ {
title: 'Actions', title: 'Actions',
dataIndex: 'action', dataIndex: 'action',
key: 'action', key: 'action',
render: (text, record) => ( render: (record: any) => (
<span> <span>
<Button style={{background: 'transparent', border: 0, color: '#1890FF'}} <Button
onClick={() => this.edit(record)}>Edit</Button> type="link"
<Button style={{background: 'transparent', border: 0, color: '#1890FF'}} onClick={() => {
onClick={() => this.changeStatus(record)}> {record.userStatus == 1 ? "lock" : "unlock"}</Button> edit(record);
}}
>
Edit
</Button>
<Button
type="link"
onClick={() => {
lockS(record);
}}
>
{record.userStatus == 1 ? 'Lock' : 'Unlock'}
</Button>
{/*{record.userID == 1||record.userID == this.props.currentUser.userid?'': {/*{record.userID == 1||record.userID == this.props.currentUser.userid?'':
<Button style={{background: 'transparent', border: 0, color: '#1890FF'}} <Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.changeStatus(record)}> onClick={() => this.changeStatus(record)}>
...@@ -303,65 +108,104 @@ class Account extends React.Component { ...@@ -303,65 +108,104 @@ class Account extends React.Component {
), ),
}, },
]; ];
//行选择
rowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
delData: selectedRows
});
},
};
//渲染 const edit = (item: any) => {
render() { history.push('./account/edit');
const {data, total, statusList} = this.state; };
const statusSelect = statusList.map((item, index) => ( const lockS = (item: any) => {};
<Select.Option value={index}>{item}</Select.Option>
));
return ( return (
<div className={styles.body}> <>
<div className={styles.inputBox}> <div className="contop">
<Input id="deviceName" className={styles.input} placeholder="账号名称" onChange={(e) => this.nameChange(e)}/> <Form
{/*<Input id="Name" className={styles.input} placeholder="发布人姓名" />*/} autoComplete="off"
<RangePicker layout="inline"
style={{marginLeft: 20}} form={form}
renderExtraFooter={() => ''} name="contract"
showTime // onFinish={onFinishContract}
onChange={(e) => this.dateChange(e)} >
/> <Form.Item name="username">
<Select className={styles.input} placeholder="状态" onChange={(e) => this.statusChange(e)} <Input allowClear placeholder="Account Name" />
allowClear={true}>{statusSelect}</Select> </Form.Item>
<Button className={styles.button1} onClick={() => this.getData()}>搜索</Button> <Form.Item name="creator">
<Input allowClear placeholder="Account Creator" />
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit" icon={<SearchOutlined />} loading={loading}>
Search{' '}
</Button>
<Button
htmlType="button"
// onClick={onReset}
style={{ marginLeft: '15px' }}
icon={<ClearOutlined />}
loading={loading}
>
{' '}
Reset
</Button>
</Form.Item>
</Form>
</div> </div>
<div style={{marginTop: 10}}>
<Button className={styles.button2} onClick={() => this.edit(null)}>新建</Button> <div className="contop contop2">
</div> <ProTable
<div> // request={requestHeadl}
<Table rowKey={'id'}
rowKey={record => record.userID} dataSource={Data ? Data.rows : null}
className={styles.table} columns={columns}
rowSelection={this.rowSelection} pagination={false} // 隐藏默认分页
columns={this.columns} search={false}
dataSource={data} loading={loading}
size="small" toolBarRender={() => [
pagination={{showQuickJumper: true, pageSize: 10, total: total}} <Button
type="primary"
loading={loading}
icon={<PlusOutlined />}
onClick={() => {
// Jump(0, 'Add');
}}
>
Add Account
</Button>,
]}
options={{
density: false,
fullScreen: false,
reload: () => {
edit;
},
setting: false,
}}
headerTitle="Account list"
// pagination={{ defaultCurrent: 1, total: Data.totalRow }}
/>
<div className="pages">
<Pagination
// onShowSizeChange={pageSizeHandler}
// current={Data.total}
total={Data ? Data.total : 0}
pageSize={Data ? Data.total : 0}
/> />
<Button className={styles.button3} onClick={() => this.showModal()}>删除</Button>
</div> </div>
<Modal
title="确认删除?"
visible={this.state.visible}
onOk={this.handleOk}
onCancel={this.handleCancel}>
<div style={{textAlign: "center"}}><p style={{fontSize: 18}}>删除信息将不可恢复</p></div>
</Modal>
</div> </div>
</>
); );
} };
}
const AccountProps = (styte: any) => {
console.log(styte);
const { Data, DataSave, DataSaveDetail, Result } = styte.Account;
const loading = styte.loading.models.Account || false;
return {
Data,
DataSave,
DataSaveDetail,
Result,
loading,
};
};
export default connect(({user}: ConnectState) => ({ export default connect(AccountProps)(Account);
currentUser: user.currentUser,
}))(Account);
...@@ -16,8 +16,6 @@ const Contract = (props: any) => { ...@@ -16,8 +16,6 @@ const Contract = (props: any) => {
dispatch({ type: 'Contract/RA', playload: { index: index, body: values } }); dispatch({ type: 'Contract/RA', playload: { index: index, body: values } });
}; };
console.log(userListLoading);
// 把请求装在一个地方 // 把请求装在一个地方
function requst(payload: any) { function requst(payload: any) {
dispatch({ type: 'ContractModel/getList', payload: payload }); dispatch({ type: 'ContractModel/getList', payload: payload });
......
...@@ -18,6 +18,8 @@ import locale from 'antd/es/date-picker/locale/en_US'; ...@@ -18,6 +18,8 @@ import locale from 'antd/es/date-picker/locale/en_US';
import SearchOptionsCommnity from '@/components/SearchOptions/SearchOptionsCommnity'; import SearchOptionsCommnity from '@/components/SearchOptions/SearchOptionsCommnity';
import { tipList } from '@/utils/tip'; import { tipList } from '@/utils/tip';
import FileViewer from 'react-file-viewer';
const ContractContent = (props: any) => { const ContractContent = (props: any) => {
const { ContractModel, dispatch } = props; const { ContractModel, dispatch } = props;
const { RangePicker } = DatePicker; // 日期组件 const { RangePicker } = DatePicker; // 日期组件
...@@ -33,7 +35,9 @@ const ContractContent = (props: any) => { ...@@ -33,7 +35,9 @@ const ContractContent = (props: any) => {
const startTime = moment().format('YYYY-MM-DD'); // 开始默认事件 const startTime = moment().format('YYYY-MM-DD'); // 开始默认事件
const overTime = moment().add(1, 'month').format('YYYY-MM-DD'); // 结束默认事件 const overTime = moment().add(1, 'month').format('YYYY-MM-DD'); // 结束默认事件
const [fileList, setFileList] = useState([] as any); const [fileList, setFileList] = useState([] as any); // 图片列表
const [uploadUp, setUploadUp] = useState(true); // 禁止上传 直到选择了小区后
const [comtyName, setComtyName] = useState(null); // 小区名字
console.log(tipList); console.log(tipList);
...@@ -44,13 +48,17 @@ const ContractContent = (props: any) => { ...@@ -44,13 +48,17 @@ const ContractContent = (props: any) => {
} else if (ContractModel.record === 0) { } else if (ContractModel.record === 0) {
form.resetFields(); form.resetFields();
} else { } else {
// 发起请求
RA(47, ContractModel.record.contractFileName);
let arr = ContractModel.record.contractFileName.split(','); let arr = ContractModel.record.contractFileName.split(',');
let obj = new Array(); let obj = new Array();
for (var i in arr) { for (var i in arr) {
let a = { let a = {
uid: arr[i], uid: i,
name: arr[i], name: arr[i],
url: 'http://', status: 'done',
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
}; };
obj.push(a); obj.push(a);
} }
...@@ -99,7 +107,7 @@ const ContractContent = (props: any) => { ...@@ -99,7 +107,7 @@ const ContractContent = (props: any) => {
const uploadProps = { const uploadProps = {
accept: '.doc,.docx,.jpg,.png,.pdf', accept: '.doc,.docx,.jpg,.png,.pdf',
action: '/tos/image/upload', action: '/tos/image/upload',
data: { imageType: 'tosContract' }, data: { imageType: 'tosContract', extends: comtyName },
fileList: fileList, fileList: fileList,
onChange({ file, fileList }: { file: any; fileList: any }) { onChange({ file, fileList }: { file: any; fileList: any }) {
setFileList(fileList); setFileList(fileList);
...@@ -128,6 +136,13 @@ const ContractContent = (props: any) => { ...@@ -128,6 +136,13 @@ const ContractContent = (props: any) => {
}; };
// 选择小区名字并赋值 // 选择小区名字并赋值
const opname = (value: any) => { const opname = (value: any) => {
// 打开上传 如果选择了 小区就打开 否则 禁止上传
value ? setUploadUp(false) : setUploadUp(true);
// 如果切换了 清掉上传的图片
if (value != comtyName) {
setFileList([]);
}
setComtyName(value); // 赋值小区名字 给到上传
form.setFieldsValue({ form.setFieldsValue({
communityName: value, communityName: value,
}); });
...@@ -238,7 +253,7 @@ const ContractContent = (props: any) => { ...@@ -238,7 +253,7 @@ const ContractContent = (props: any) => {
label="Contract Annex" label="Contract Annex"
rules={[{ required: true, message: `${tipList[6]}` }]} rules={[{ required: true, message: `${tipList[6]}` }]}
> >
<Upload {...uploadProps} listType={'picture-card'}> <Upload {...uploadProps} listType={'picture-card'} disabled={uploadUp}>
{fileList.length >= 3 ? null : <PlusOutlined />} {fileList.length >= 3 ? null : <PlusOutlined />}
</Upload> </Upload>
</Form.Item> </Form.Item>
...@@ -259,7 +274,7 @@ const ContractContent = (props: any) => { ...@@ -259,7 +274,7 @@ const ContractContent = (props: any) => {
></TextArea> ></TextArea>
</Form.Item> </Form.Item>
</div> </div>
<div className={styles.box8item2x2}> <div className={styles.box8item2x2} style={{ marginLeft: 150 }}>
The system will send out reminders of contract expiration on 25 . The system will send out reminders of contract expiration on 25 .
{/* <span style={{color:'#f00'}}>&nbsp;{stateTime}</span> */} {/* <span style={{color:'#f00'}}>&nbsp;{stateTime}</span> */}
</div> </div>
...@@ -268,7 +283,7 @@ const ContractContent = (props: any) => { ...@@ -268,7 +283,7 @@ const ContractContent = (props: any) => {
<div> <div>
<LINE /> <LINE />
<Button type="primary" htmlType="submit"> <Button type="primary" htmlType="submit">
Conserve Submit
</Button> </Button>
</div> </div>
</div> </div>
......
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