Commit 4160c41d authored by MrShi's avatar MrShi

新开dev_ssz分支,业主模块相关

parent 54d57050
......@@ -80,13 +80,24 @@ export default defineConfig({
name: 'usemanagement',
icon:'ProfileOutlined',
routes: [
{
/* {
path: './LIFEUserManagement',
name: 'lifeusers',
routes: [
{ path: './', component: './UserManagement/LIFEUserManagement/Users' },
{ path: './Add', component: './UserManagement/LIFEUserManagement/UsersAdd' },
]
},*/
{
path: './tosUser',
name: 'lifeusers',
routes: [
{ path: './', component: './UserManagement/tosUser/TosUser' },
{ path: './create', component: './UserManagement/tosUser/TosUserCreate' },
{ path: './common', component: './UserManagement/tosUser/commonUser' },
{ path: './edit', component: './UserManagement/tosUser/TosUserEdit' },
{ path: './details', component: './UserManagement/tosUser/TosUserDetails' },
]
},
{
path: './ServiceProviderManagement',
......@@ -105,6 +116,29 @@ export default defineConfig({
},
]
},
/*{
path: '/tosUser/create',
component: './tosUser/TosUserCreate',
hideInMenu: true,
},
{
path: '/tosUser/common',
component: './tosUser/commonUser',
hideInMenu: true,
},
{
path: '/tosUser/edit',
component: './tosUser/TosUserEdit',
hideInMenu: true,
},
{
path: '/tosUser/details',
component: './tosUser/TosUserDetails',
hideInMenu: true,
},*/
{
path: '/PropertyManagement',
name: 'propertymanagement',
......
......@@ -7,17 +7,57 @@
*/
export default {
dev: {
'/api/': {
/* '/api/': {
target: 'https://preview.pro.ant.design',
changeOrigin: true,
pathRewrite: { '^': '' },
},*/
'/api/': {
target: 'http://localhost:8080',
changeOrigin: true,
pathRewrite: { '^': '' },
},
'/res/': {
target: 'http://mapleonlyone.top',
changeOrigin: true,
pathRewrite: { '^': '' },
},
'/cash/tos-manager/bill/': {
target: 'http://acc-huahui.oss-cn-shenzhen.aliyuncs.com',
changeOrigin: true,
pathRewrite: { '^': '' },
},
'/tos/': {
target: 'http://47.74.233.180:8651',
changeOrigin: true,
pathRewrite: { '^': '' },
},
},
test: {
'/api/': {
/* '/api/': {
target: 'https://preview.pro.ant.design',
changeOrigin: true,
pathRewrite: { '^': '' },
},*/
'/api/': {
target: 'http://localhost:8080',
changeOrigin: true,
pathRewrite: { '^': '' },
},
'/res/': {
target: 'http://mapleonlyone.top',
changeOrigin: true,
pathRewrite: { '^': '' },
},
'/cash/tos-manager/bill/': {
target: 'http://acc-huahui.oss-cn-shenzhen.aliyuncs.com',
changeOrigin: true,
pathRewrite: { '^': '' },
},
'/tos/': {
target: 'http://47.74.233.180:8651',
changeOrigin: true,
pathRewrite: { '^': '' },
},
},
pre: {
......
......@@ -32,11 +32,6 @@
"test:component": "umi test ./src/components",
"tsc": "tsc"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint-staged"
}
},
"lint-staged": {
"**/*.less": "stylelint --syntax less",
"**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js",
......@@ -50,6 +45,7 @@
"not ie <= 10"
],
"dependencies": {
"js-export-excel": "^1.1.2",
"@ant-design/icons": "^4.0.0",
"@ant-design/pro-layout": "^5.0.16",
"@ant-design/pro-table": "2.3.4",
......
import {getOwnerDetail,getOwner, getTosUser,delAdvertisement,saveAdvertisement,quitAndUserAd,uploadApk,checkVideo } from '@/services/tosUser';
export default{
namespace: 'tUModel',
state: {
data: [],
},
effects: {
*getTosUser({callback,payload},{ call, put }) {
const response = yield call(getTosUser,payload);
yield put({
type: "get",
});
if(callback) callback(response);
},
*getOwner({callback,payload},{ call, put }) {
const response = yield call(getOwner,payload);
yield put({
type: "getOwner",
});
if(callback) callback(response);
},
*getOwnerDetail({callback,payload},{ call, put }) {
const response = yield call(getOwnerDetail,payload);
yield put({
type: "getOwnerDetail",
});
if(callback) callback(response);
},
*delAdvertisement({callback,payload},{ call, put }) {
const response = yield call(delAdvertisement,payload);
yield put({
type: "del",
});
if(callback) callback(response);
},
*saveAdvertisement({callback,payload},{ call, put }) {
const response = yield call(saveAdvertisement,payload);
yield put({
type: "save",
});
if(callback) callback(response);
},
*quitAndUserAd({callback,payload},{ call, put }) {
const response = yield call(quitAndUserAd,payload);
yield put({
type: "quit",
});
if(callback) callback(response);
},
*uploadApk({callback,payload},{ call, put }) {
const response = yield call(uploadApk,payload);
yield put({
type: "apk",
});
if(callback) callback(response);
},
*checkVideo({callback,payload},{ call, put }) {
const response = yield call(checkVideo,payload);
yield put({
type: "check",
});
if(callback) callback(response);
},
},
reducers: {
get(state, action) {
return {
...state,
data:action.payload || {},
};
},
getOwner(state, action) {
return {
...state,
data:action.payload || {},
};
},
getOwnerDetail(state, action) {
return {
...state,
data:action.payload || {},
};
},
del(state, action) {
return {
...state,
data:action.payload || {},
};
},
save(state, action) {
return {
...state,
data:action.payload || {},
};
},
quit(state, action) {
return {
...state,
data:action.payload || {},
};
},
apk(state, action) {
return {
...state,
data:action.payload || {},
};
},
check(state, action) {
return {
...state,
data:action.payload || {},
};
},
},
};
import React, { Component, PropTypes } from 'react';
import { Checkbox } from 'antd';
import { connect } from 'dva';
import styles from './style.less';
const CheckboxGroup = Checkbox.Group;
const CheckGroup=({
checkId,
checkAll,
checkedList,
checkAllValue,
checkAllLable,
hasChildren,
children,
dispatch,
character,
allListId,
indeterminate,
checkAllId
})=>{
function onCheckAllChange(e){
let newList=character.newList;
newList[checkId]={
['allListId'+checkId]:allListId,
['checkAllId'+checkId]:checkAllId,
['checkedList'+checkId]: e.target.checked ? allListId : [],
// ['indeterminate'+checkId]: !indeterminate,
['checkAll'+checkId]: e.target.checked,
};
dispatch({
type:'character/getAuthorityList',
payload:{
newList:newList
}
})
}
function selectCheckbox(checkedList){
let newList=character.newList;
newList[checkId]={
['allListId'+checkId]:allListId,
['checkAllId'+checkId]:checkAllId,
['checkedList'+checkId]: checkedList,
// ['indeterminate'+checkId]: !!checkedList.length && (checkedList.length < allListId.length),
['checkAll'+checkId]: checkedList.length >0,
};
dispatch({
type:'character/updateState',
payload:{
newList:newList
}
})
}
return(
<div className={styles.allCheckbox} id={checkId}>
<Checkbox checked={checkAll } value={checkAllValue} onChange={(e)=>onCheckAllChange(e)} >{ checkAllLable}</Checkbox >
{
hasChildren ?
<CheckboxGroup className={styles.subCheckbox} value={checkedList} onChange={selectCheckbox}>
{
children.map((sub, subKey) => {
return <Checkbox value={sub.menuid} id={`${sub.menuid}`} key={subKey} >{sub.name}</Checkbox >
})
}
</CheckboxGroup > : null
}
</div >
)
}
CheckGroup.propTypes = {
// searchValue: PropTypes.string,
// characterList: PropTypes.array,
// dispatch: PropTypes.func,
// showSubModal: PropTypes.bool,
// deteleSubModal: PropTypes.bool
};
export default connect(({ character, loading }) => ({ character, loading }))(CheckGroup);
import React from 'react';
import {connect, routerRedux} from 'dva';
import {Table, Button, Input, Select, Modal, Tooltip, Upload, Icon, Checkbox, Row, Radio, Tag}
from "antd";
import styles from './style.less';
import {ConnectState} from "@/models/connect";
import XLSX from "@/pages/account/xlsx.core.min";
import {router} from "umi";
import 'moment/locale/zh-cn';
// @ts-ignore
import SelectOptions from '../../../components/SelectOptions/index';
class TosUser extends React.Component {
//构造
constructor(props) {
super(props);
this.state = {
data: [],
province: undefined,
city: undefined,
district: undefined,
street: undefined,
total: 1,
name: '',
model: '',
status: undefined,
statusList: [{label:"在线",value:"1"}, {label:"故障",value:"3"},{label:"未激活",value:"4"}],
provinceList: [],
cityList: [{name: "未选择省"}],
districtList: [{name: "未选择市"}],
streetList: [{name: "未选择区"}],
delData: [],
visible: false,
deviceStatus: '',
selectedRowKeys: [],
used: null,
newAdd: null,
strList: [],
newList:[],
authorityList:[
{
"children": [
{
"children": [],
"hasChildren": false,
"is_admin": 1,
"menuid": 5,
"name": "组织架构",
"parentid": 1,
"sort": 10,
"state": "",
"is_checked": true
},
{
"children": [],
"hasChildren": false,
"is_admin": 1,
"menuid": 6,
"name": "员工管理",
"parentid": 1,
"sort": 20,
"state": "",
"is_checked": true
},
{
"children": [],
"hasChildren": false,
"is_admin": 1,
"menuid": 11,
"name": "角色管理",
"parentid": 1,
"sort": 30,
"state": "",
"is_checked": false
},
{
"children": [],
"hasChildren": false,
"is_admin": 1,
"menuid": 17,
"name": "企业设置",
"parentid": 1,
"sort": 2,
"state": "",
"is_checked": true
},
{
"children": [],
"hasChildren": false,
"is_admin": 1,
"menuid": 26,
"name": "员工管理",
"parentid": 1,
"sort": 1,
"state": "",
"is_checked": false
}
],
"hasChildren": true,
"is_admin": 1,
"menuid": 1,
"name": "企业",
"parentid": 0,
"sort": 20,
"state": "closed",
"is_checked": true
},
{
"children": [
{
"children": [],
"hasChildren": false,
"is_admin": 1,
"menuid": 12,
"name": "供应商订单",
"parentid": 4,
"sort": 10,
"state": "",
"is_checked": true
},
{
"children": [],
"hasChildren": false,
"is_admin": 1,
"menuid": 15,
"name": "供应商管理",
"parentid": 4,
"sort": 20,
"state": "",
"is_checked": false
},
{
"children": [],
"hasChildren": false,
"is_admin": 1,
"menuid": 16,
"name": "成为供应商",
"parentid": 4,
"sort": 30,
"state": "",
"is_checked": true
}
],
"hasChildren": true,
"is_admin": 1,
"menuid": 4,
"name": "供应商",
"parentid": 0,
"sort": 11,
"state": "closed",
"is_checked": true
}
],
}
}
/*----------------- 方法集 ------------------*/
//重置
reset = () => {
this.setState({
province: undefined,
city: undefined,
district: undefined,
street: undefined,
status: undefined,
name: '',
},() => {
// this.getDevice();
});
};
//模态框相关
showModal = () => {
let flag = 0;
const nowUser = this.props.currentUser;
if(nowUser.permission!=null){
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="4"){
if(this.state.delData==null||this.state.delData.length<=0){
alert("未选中删除项!");
return;
}
flag = 1;
this.setState({
visible: true,
});
}
}
}else{
// alert("找不到用户权限记录!");
// return;
}
if(flag == 0){
alert("缺少设备删除权限!");
}
};
handleOk = () => {
this.del();
this.setState({
visible: false,
});
};
handleCancel = () => {
this.setState({
visible: false,
});
};
//获取所有设备
getDevice = () => {
const params = {
// address: (this.state.province == undefined ? '' : this.state.province.label) +
// (this.state.city == undefined ? '' : '-' + this.state.city.label) +
// (this.state.district == undefined ? '' : '-' + this.state.district.label) +
// (this.state.street == undefined ? '' : '-' + this.state.street.label),
name: this.state.name,
model: this.state.model,
status: this.state.status,
id: this.props.currentUser.userid,
// userPhone:"18813787835",
// id:"240ebdfbac82417082ff789750760b83",
// ownerName: "哈喽kk",
communityArray: ["A4","A7","A5"]
};
this.props.dispatch({
type: 'tUModel/getOwner',
payload: params,
callback: (res) => {
if (res) {
/*this.setState({
data: res.rows,
total: res.total,
})*/
if(res.error_code == "0000"){
this.setState({
data: res.data.rows,
total: res.data.total,
})
}
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("Tos查询出错!未知错误!");
}
}
}
});
};
//跳转到编辑页面
edit = (params) => {
let flag = 0;
const nowUser = this.props.currentUser;
this.props.dispatch(routerRedux.push({
pathname: '/UserManagement/tosUser/create',
query: params,
}))
if(nowUser.permission!=null){
if(params==null){
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="3"){
flag = 1;
this.props.dispatch(routerRedux.push({
pathname: '/tosUser/create',
query: params,
}))
}
}
}else{
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="2"){
flag = 1;
this.props.dispatch(routerRedux.push({
pathname: '/tosUser/create',
query: params,
}))
}
}
}
}else{
//alert("找不到用户权限记录!");
//return;;
}
if(flag == 0){
if(params==null){
// alert("缺少设备添加权限!");
}else{
// alert("缺少设备修改权限!");
}
}
};
//跳转到编辑页面
edit2 = (params) => {
let flag = 0;
const nowUser = this.props.currentUser;
this.props.dispatch(routerRedux.push({
pathname: '/UserManagement/tosUser/edit',
query: params,
}))
if(nowUser.permission!=null){
if(params==null){
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="3"){
flag = 1;
this.props.dispatch(routerRedux.push({
pathname: 'tosUser/edit',
query: params,
}))
}
}
}else{
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="2"){
flag = 1;
this.props.dispatch(routerRedux.push({
pathname: '/tosUser/edit',
query: params,
}))
}
}
}
}else{
//alert("找不到用户权限记录!");
//return;;
}
/* if(flag == 0){
if(params==null){
alert("缺少设备添加权限!");
}else{
alert("缺少设备修改权限!");
}
}*/
};
//跳转到详情页面
details = (params) => {
this.props.dispatch(routerRedux.push({
// pathname: '/tosUser/details',
pathname: '/UserManagement/tosUser/details',
query: params,
}))
};
//设备状态变更
statusChange = (e) => {
this.setState({status: e == undefined ? undefined : e});
};
//设备名称和型号修改
nameAndModelChange = (e) => {
this.setState({name: e.target.value});
};
//加载省
provinceload = (code) => {
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: code,},
callback: (res) => {
if (res) {
this.setState({
provinceList: res.data,
});
}
}
});
};
//省变更
provinceChange = (e) => {
if (e == undefined) {
this.setState({
cityList: [{name: "未选择省"}],
districtList: [{name: "未选择市"}],
streetList: [{name: "未选择区"}],
province: undefined,
city: undefined,
district: undefined,
street: undefined,
})
} else {
this.setState({province: {label: e.label,}});
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: e.key,},
callback: (res) => {
if (res) {
this.setState({
cityList: res.data,
city: undefined,
district: undefined,
street: undefined,
});
}
}
});
}
};
//市变更
cityChange = (e) => {
if (e == undefined) {
this.setState({
districtList: [{name: "未选择市"}],
streetList: [{name: "未选择区"}],
city: undefined,
district: undefined,
street: undefined,
})
} else {
this.setState({city: {label: e.label,}});
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: e.key,},
callback: (res) => {
if (res) {
this.setState({
districtList: res.data,
district: undefined,
street: undefined,
});
}
}
});
}
};
//区变更
districtChange = (e) => {
if (e == undefined) {
this.setState({
streetList: [{name: "未选择区"}],
district: undefined,
street: undefined,
})
} else {
this.setState({district: {label: e.label,}});
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: e.key,},
callback: (res) => {
if (res) {
this.setState({
streetList: res.data,
street: undefined,
});
}
}
});
}
};
//批量删除
del() {
this.props.dispatch({
type: 'deviceModel/delDevice',
payload: this.state.delData,
callback: (res) => {
if (res) {
if (res.error_code == "0000") {
alert(res.error_msg);
// this.getDevice();
} 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("删除失败!未知错误!");
}
}
}
});
};
//显示信息
info() {
const { used, newAdd, strList} = this.state;
const strSelect = strList.map((item) => (
<p>{item}</p>
));
Modal.info({
title: '批量导入结果',
content: (
<div>
<p>绑定<span style={{color:"lightgreen",fontSize:24}}>{newAdd}</span>台设备,
以下<span style={{color:"red",fontSize:24}}>{used}</span>台设备已被占用</p>
{strSelect}
</div>
),
onOk() {},
});
}
//初始化
componentDidMount() {
// this.provinceload(0);
this.getDevice();
}
/*--------------------------------------*/
//表格列名
columns = [
{
title: 'User Name',
dataIndex: 'owerName',
key: 'owerName',
},
{
title: 'Project',
dataIndex: 'owerPhone',
key: 'owerPhone',
},
{
title: 'Affiliated Unit',
dataIndex: 'buildingNumber',
key: 'buildingNumber',
},
{
title: 'User Status',
dataIndex: 'enable',
key: 'enable',
render: (text, record) => (
<span>{record.enable == '1' ? "注册" : "未注册"}</span>
),
/* render: (text, record) => (
<>
{record.map(enable => {
let color = 'green';
if (enable === '1') {
color = 'volcano';
}
if (enable === '0') {
color = 'geekblue';
}
return (
<Tag color={color} key={enable}>
{enable.toUpperCase()}
</Tag>
);
}
</>
),*/
},
/*{
title: '用户类型',
dataIndex: 'deviceRegisterTime',
key: 'deviceRegisterTime',
},
{
title: '状态',
dataIndex: 'deviceWorking',
key: 'deviceWorking',
render: (text, record) => (
<span>{record.deviceWorking == '1' ? "正常" :
(record.deviceWorking == '2' ? "离线" :
(record.deviceWorking == '3' ? "故障" : "未激活"))}</span>
)
},*/
{
title: 'Actions',
dataIndex: 'action',
key: 'action',
render: (text, record) => (
<span>
<Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.details(record)}>Details</Button>
<Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.edit2(record)}>Edit</Button>
</span>
),
},
];
//行选择
rowSelection = {
onChange: (selectedRowKeys , selectedRows) => {
this.setState({
delData: selectedRows
});
},
};
//渲染
render() {
const {
data, total, statusList, provinceList, cityList, districtList,
province, city, district, status, name,newList,authorityList
} = this.state;
const uploadprops = {
// 这里我们只接受excel2007以后版本的文件,accept就是指定文件选择框的文件类型
accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
name: 'file',
headers: {
authorization: 'authorization-text',
},
showUploadList: false,
// 把excel的处理放在beforeUpload事件,否则要把文件上传到通过action指定的地址去后台处理
// 这里我们没有指定action地址,因为没有传到后台
beforeUpload: (file, fileList) => {
const rABS = true;
const f = fileList[0];
const reader = new FileReader();
reader.onload = e => {
let dataResult = e.target.result;
if (!rABS) dataResult = new Uint8Array(dataResult);
const workbook = XLSX.read(dataResult, {
type: rABS ? 'binary' : 'array',
});
// 假设我们的数据在第一个标签
const firstWorksheet = workbook.Sheets[workbook.SheetNames[0]];
// XLSX自带了一个工具把导入的数据转成json
const jsonArr = XLSX.utils.sheet_to_json(firstWorksheet, {header: 1});
// 通过自定义的方法处理Json,得到Excel原始数据传给后端,后端统一处理
const oldDeviceList = [];
for (let i = 0; i < jsonArr.length; i++) {
//去重
if (!oldDeviceList.includes(jsonArr[i][0]) && jsonArr[i][0] != '' && jsonArr[i][0] != null && jsonArr[i][0] != undefined) {
oldDeviceList.push(jsonArr[i][0]);
}
}
this.props.dispatch({
type: 'deviceModel/importUserDeviceListExcel',
payload: {
jsonArr: oldDeviceList,
userID: this.props.currentUser.userid,
},
callback: (res) => {
if (res) {
this.setState({
used: res.data.used,
newAdd: res.data.integer,
strList: res.data.strList,
},() => {
// this.getDevice();
this.info();
});
}
}
});
};
if (rABS) reader.readAsBinaryString(f);
else reader.readAsArrayBuffer(f);
return false;
},
};
const printContent = (comment: any)=>{
console.log(comment)
}
/* const statusSelect = statusList.map((item) => (
<Select.Option value={item.value} label={item.label}>{item.label}</Select.Option>
));
const provinceSelect = provinceList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));
const citySelect = cityList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));
const districtSelect = districtList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));*/
return (
<div className={styles.body}>
<div className={styles.inputBox}>
<Input className={styles.input}
placeholder="User Name"
value={name}
onChange={(e) => this.nameAndModelChange(e)}/>
</div>
<div>
<h1>choose</h1>
<SelectOptions list={['King Garden1', 'King Garden2', '帝景花园小区', 'King Garden3', 'King Garden4', 'A9', 'King Garden5', 'King Garden6', 'CambirdgeGarden', 'King Garden7', '帝景花园小区3期', 'A1', 'A7', 'A5', 'A4', 'A3', 'King Garden8', 'King Garden9', '骏景花园1期', '骏景花园11期', 'King Garden10', '金碧花园2期', 'King Garden11', 'King Garden12', '骏景花园10期', 'King Garden13', '骏景花园2期', 'King Garden14', 'King Garden15', 'King Garden16', 'King Garden17', '帝景花园小区2期', 'King Garden18', 'King Garden19', 'King Garden20', '骏景花园8期', 'King Garden21', 'King Garden22', 'King Garden23', 'King Garden24']} onSubmit={printContent}/>
</div>
{/*<div style={{marginTop:5,marginBottom:5,backgroundColor:"#EEEEEE",padding:15}}>*/}
{/* <div style={{paddingLeft:20 ,paddingRight:20}}>*/}
{/* A B C D E F G H I J K L M N O P Q R S T U V W X Y Z*/}
{/* <Radio style={{float:"right"}}>Select All</Radio><Radio style={{float:"right"}}>Unselect All</Radio>*/}
{/* </div>*/}
{/* <div style={{backgroundColor:"#ffffff",margin:15}}>*/}
{/* <input id="area_name" style={{ width: '150px', marginLeft: 10, marginRight: 15,marginTop:15 }}*/}
{/* placeholder='Project Name' ></input>*/}
{/* <div>*/}
{/* <Row style={{paddingTop:20,paddingLeft:15}}>*/}
{/* /!*<label className={styles.backBox}>A1小区</label>*!/*/}
{/* /!*</Checkbox> <label className={styles.backBox}>A1小区</label>*!/*/}
{/* <Checkbox value="1" ><Button>A1 Project</Button></Checkbox>*/}
{/* <Checkbox value="2" ><Button>A2 Project</Button></Checkbox>*/}
{/* <Checkbox value="3" ><Button>A3 Project</Button></Checkbox>*/}
{/* <Checkbox value="4" ><Button>A4 Project</Button></Checkbox>*/}
{/* <Checkbox value="5" ><Button>A5 Project</Button></Checkbox>*/}
{/* <Checkbox value="6" ><Button>A6 Project</Button></Checkbox>*/}
{/* <Checkbox value="7" ><Button>A7 Project</Button></Checkbox>*/}
{/* </Row>*/}
{/* /!*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>*!/*/}
{/* <Row style={{paddingTop:20,paddingBottom:20,paddingLeft:15}}>*/}
{/* <Checkbox value="8" ><Button>B1 Project</Button></Checkbox>*/}
{/* <Checkbox value="9" ><Button>B2 Project</Button></Checkbox>*/}
{/* <Checkbox value="10" ><Button>B3 Project</Button></Checkbox>*/}
{/* <Checkbox value="11" ><Button>B4 Project</Button></Checkbox>*/}
{/* <Checkbox value="12" ><Button>B5 Project</Button></Checkbox>*/}
{/* <Checkbox value="13" ><Button>B6 Project</Button></Checkbox>*/}
{/* <Checkbox value="14" ><Button>B7 Project</Button></Checkbox>*/}
{/* </Row>*/}
{/* </div>*/}
{/* </div>*/}
{/*</div>*/}
<div>
<Button className={styles.button1} onClick={() => this.getDevice()}>Search</Button>
{/*<Button className={styles.button} onClick={() => this.reset()}>重置</Button>*/}
<Button className={styles.button2} onClick={() => this.edit(null)}>Create New Owner</Button>
<Upload {...uploadprops}>
<Tooltip title="">
<Button className={styles.button2}
style={{width: 150}}>
<Icon type="upload"/>Batch Upload
</Button>
</Tooltip>
</Upload>
</div>
<div>
<Table
rowKey={record => record.deviceID}
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()}>Delete</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,
}))(TosUser);
import React from 'react';
import {connect, routerRedux} from 'dva';
import {Button, Input, Select } from "antd";
import styles from './style.less';
import {ConnectState} from "@/models/connect";
import {router} from "umi";
class TosUserCreate extends React.Component {
//构造
constructor(props) {
super(props);
this.state = {
name: '',
model: '',
id: '',
keeper: '',
phone: '',
status: '',
province: undefined,
city: undefined,
district: undefined,
street: undefined,
provinceList: [],
cityList: [{name: "未选择省"}],
districtList: [{name: "未选择市"}],
streetList: [{name: "未选择区"}],
deviceStatus: '',
sn: '',
phoneBlur: undefined,
}
}
/*----------------- 方法集 --------------- ---*/
//加载省
provinceload = (code) => {
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: code,},
callback: (res) => {
if (res) {
this.setState({
provinceList: res.data,
});
}
}
});
};
//省变更
provinceChange = (e) => {
if (e == undefined) {
this.setState({
cityList: [{name: "未选择省"}],
districtList: [{name: "未选择市"}],
streetList: [{name: "未选择区"}],
province: undefined,
city: undefined,
district: undefined,
street: undefined,
})
} else {
this.setState({province: {label: e.label,}});
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: e.key,},
callback: (res) => {
if (res) {
this.setState({
cityList: res.data,
city: undefined,
district: undefined,
street: undefined,
});
}
}
});
}
};
//市变更
cityChange = (e) => {
if (e == undefined) {
this.setState({
districtList: [{name: "未选择市"}],
streetList: [{name: "未选择区"}],
city: undefined,
district: undefined,
street: undefined,
})
} else {
this.setState({city: {label: e.label,}});
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: e.key,},
callback: (res) => {
if (res) {
this.setState({
districtList: res.data,
district: undefined,
street: undefined,
});
}
}
});
}
};
//区变更
districtChange = (e) => {
if (e == undefined) {
this.setState({
streetList: [{name: "未选择区"}],
district: undefined,
street: undefined,
})
} else {
this.setState({district: {label: e.label,}});
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: e.key,},
callback: (res) => {
if (res) {
this.setState({
streetList: res.data,
street: undefined,
});
}
}
});
}
};
//街道变更
streetChange = (e) => {
if (e == undefined) {
this.setState({
street: undefined,
})
} else {
this.setState({street: {label: e.label,} });
}
};
//app版本变更
appVersionChange = (e) => {
this.setState({appVersion: e.target.value});
};
//app版本变更
firmwareChange = (e) => {
this.setState({firmware: e.target.value});
};
//设备名称变更
nameChange = (e) => {
this.setState({name: e.target.value});
};
//设备模板变更
modelChange = (e) => {
this.setState({model: e.target.value});
};
//设备ID变更
idChange = (e) => {
this.setState({id: e.target.value});
};
//设备sn变更
snChange = (e) => {
this.setState({sn: e.target.value});
};
//管理员变更
keeperChange = (e) => {
this.setState({keeper: e.target.value});
};
//联系电话正则
phoneBlur = () => {
if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(this.state.phone))){
this.setState({
phoneBlur: false,
})
}else{
this.setState({
phoneBlur: true,
},() => {
if(this.state.phoneBlur==true) {
const params = {
deviceAddress: (this.state.province == undefined ? '' : this.state.province.label) +
(this.state.city == undefined ? '' : '-'+this.state.city.label) +
(this.state.district == undefined ? '' : '-'+this.state.district.label) +
(this.state.street == undefined ? '' : '-'+this.state.street.label),
deviceName: this.state.name,
deviceModel: this.state.model,
deviceKeeper: this.state.keeper,
deviceID: this.state.id,
deviceSerialNumber: this.state.sn,
devicePhone: this.state.phone,
deviceWorking: this.state.status == '' ? 2 : this.state.status,
deviceStatus: this.state.deviceStatus ? this.state.deviceStatus : 0,
deviceCreate: this.props.currentUser.userid,
};
console.log("params",params);
this.props.dispatch({
type: 'deviceModel/saveDevice',
payload: params,
callback: (res) => {
if (res.error_code == "0000") {
alert(res.error_msg);
this.back();
} else if (res.error_code == "0002") {
alert(res.error_msg);
this.back();
} else if (res.error_code == "0001"){
alert(res.error_msg);
} else if (res.error_code == "0003"){
alert(res.error_msg)
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
}else {
alert("提交错误!未知原因!");
}
}
});
}
});
}
};
//联系电话变更
phoneChange = (e) => {
this.setState({phone: e.target.value});
};
//联系电话1变更
phoneChange1 = (e) => {
this.setState({phone1: e.target.value});
};
//提交
onSubmit = () => {
this.phoneBlur();
};
//跳转到设备页面
back = () => {
this.props.dispatch(routerRedux.push({
pathname: '/UserManagement/tosUser',
}))
};
//初始化
componentDidMount() {
if(this.props.location.query!=null) {
const params = this.props.location.query;
this.setState({
name: params.deviceName,
model: params.deviceModel,
id: params.deviceID,
sn: params.deviceSerialNumber,
keeper: params.deviceKeeper,
phone: params.devicePhone,
phone1:params.devicePhone1,
status: params.deviceWorking,
deviceStatus: params.deviceStatus,
});
if(params.deviceAddress!=null){
const strs = params.deviceAddress.split("-");
if(strs[0]==''){
return;
}
this.props.dispatch({
type: 'deviceModel/getRegionList',
payload: {
address: params.deviceAddress
},
callback: (res) => {
if (res) {
this.setState({
cityList: res.cityList?res.cityList:[{name: "未选择省"}],
districtList: res.districtList?res.districtList:[{name: "未选择市"}],
streetList: res.streetList?res.streetList:[{name: "未选择区"}],
province: {label:strs[0]},
city: strs[1]?{label:strs[1]}:undefined,
district: strs[2]?{label:strs[2]}:undefined,
street: strs[3]?{label:strs[3]}:undefined,
});
}
}
});
}else{
this.setState({
province: undefined,
city: undefined,
district: undefined,
street: undefined,
});
}
}
this.provinceload(0);
}
/*--------------------------------------*/
//渲染
render() {
const { name, model, keeper, phone,phone1, province, city, district, street,
provinceList, cityList, districtList, streetList, phoneBlur, sn } = this.state;
/* const provinceSelect = provinceList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));
const citySelect = cityList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));
const districtSelect = districtList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));
const streetSelect = streetList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));*/
return(
<div className={styles.body}>
<div style={{marginTop:48}}>
<span className={styles.detailsTitle}>Create New Owner</span>
<div className={styles.detailsBox}>
<div>
<span className={styles.detailsContent}>Owner's Name</span>
<Input className={styles.input} value={sn} placeholder="Single Line Input" onChange={(e) => this.snChange(e)}/>
</div>
<div>
<span className={styles.detailsContent}>Project / community</span>
<Input className={styles.input} value={model} placeholder="Project Name" onChange={(e) => this.modelChange(e)} />
{/*<span className={styles.detailsContent}>设备名称</span>*/}
<Input className={styles.input} value={name} placeholder="Building No" onChange={(e) => this.nameChange(e)} />
<Input className={styles.input} value={keeper} placeholder="Floor" onChange={(e) => this.keeperChange(e)}/>
<Input className={styles.input}
value={phone1} placeholder="Room Number"
onChange={(e) => this.phoneChange1(e)}
/>
</div>
<div>
{/*<span className={styles.detailsContent}>管理员</span>*/}
{/*<Input className={styles.input} value={keeper} onChange={(e) => this.keeperChange(e)}/>*/}
{/* <span className={styles.detailsContent}>联系电话</span>
{phoneBlur != false?
<Input className={styles.input}
value={phone}
onChange={(e) => this.phoneChange(e)}
/>:''}*/}
{/*{phoneBlur == false?*/}
<Input className={styles.input1}
// style={{border:"1px solid red"}}
value={phone} placeholder="Address + postcode"
onChange={(e) => this.phoneChange(e)}
/>
{/* :''}*/}
{/* {phoneBlur == false?
<span style={{color:"red"}}>请输入正确电话号码</span>:''}*/}
</div>
{/* <div>
<span className={styles.detailsContent}>地址</span>
<Select className={styles.downButton}
placeholder="省"
onChange={(e) => this.provinceChange(e)}
allowClear={true}
labelInValue={true}
value={province}>
{provinceSelect}
</Select>
<Select className={styles.downButton}
placeholder="市"
onChange={(e) => this.cityChange(e)}
allowClear={true}
labelInValue={true}
value={city}>
{citySelect}
</Select>
<Select className={styles.downButton}
placeholder="区"
onChange={(e) => this.districtChange(e)}
allowClear={true}
labelInValue={true}
value={district}>
{districtSelect}
</Select>
<Select className={styles.downButton}
placeholder="街道"
onChange={(e) => this.streetChange(e)}
allowClear={true}
labelInValue={true}
value={street}>
{streetSelect}
</Select>
<Input className={styles.input} placeholder="请输入详细位置"/>
</div>*/}
<div style={{marginTop:120}}>
<Button className={styles.button2} onClick={() => this.onSubmit()}>Submit</Button>
<Button className={styles.button1} onClick={() => this.back()}>Return</Button>
</div>
</div>
</div>
</div>
);
}
}
export default connect(({user}:ConnectState) => ({
currentUser: user.currentUser,
}))(TosUserCreate);
import React from 'react';
import {connect, routerRedux} from 'dva';
import {Table, Button, DatePicker, Select, Menu, Modal} from "antd";
import styles from './style.less';
import {ConnectState} from "@/models/connect";
import ExportJsonExcel from 'js-export-excel';
import {router} from "umi";
//npm install js-export-excel
const { RangePicker, } = DatePicker;
class TosUserDetails extends React.Component {
//构造
constructor(props) {
super(props);
this.state = {
record: [],
data: [],
total: 1,
type: undefined,
typeList: ["扫描模块故障", "打印机故障", "触摸屏故障","副屏故障"],
moment: [],
current: 'record',
delData: [],
visible: false,
}
}
/*----------------- 方法集 ------------------*/
//打印excel
downloadExcel = () => {
let flag = 0;
const nowUser = this.props.currentUser;
if(nowUser.permission!=null){
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="14"){
flag = 1;
const data = this.state.record ? this.state.record : '';//表格数据
var option={};
let dataTable = [];
if (data) {
for (let i in data) {
if(data){
let warnType;
if(data[i].warn_type == 1) {
warnType = '扫描模块故障';
}else if(data[i].warn_type == 2) {
warnType = '打印机故障';
}else if(data[i].warn_type == 3) {
warnType = '触摸屏故障';
}else if(data[i].warn_type == 4) {
warnType = '副屏故障';
}
let obj = {
'设备名称': data[i].device_name,
'设备型号': data[i].device_model,
'警报类型': warnType,
'报警时间': data[i].warn_time,
'地址': data[i].device_address,
'联系人': data[i].user_account,
'联系方式': data[i].user_phone,
}
dataTable.push(obj);
}
}
}
option.fileName = '警报信息';
option.datas=[
{
sheetData:dataTable,
sheetName:'sheet',
sheetFilter:['设备名称','设备型号','警报类型','报警时间','联系人','联系方式','地址'],
sheetHeader:['设备名称','设备型号','警报类型','报警时间','联系人','联系方式','地址'],
}
];
var toExcel = new ExportJsonExcel(option);
toExcel.saveExcel();
}
}
}else{
//alert("找不到用户权限记录!");
//return;;
}
if(flag == 0){
alert("缺少批量下载权限!");
return;
}
};
//模态框相关
showModal = () => {
let flag = 0;
let permissionNum = null;
const nowUser = this.props.currentUser;
if(nowUser.permission!=null){
for(let i=0;i<nowUser.permission.length;i++){
if(this.state.current == "record"){
permissionNum = "15";
}else{
permissionNum = "12";
}
if(nowUser.permission[i]==permissionNum){
if(this.state.delData==null||this.state.delData.length<=0){
alert("未选中删除项!");
return;
}
flag = 1;
this.setState({
visible: true,
});
}
}
}else{
//alert("找不到用户权限记录!");
//return;;
}
if(flag == 0){
if(this.state.current == "record"){
alert("缺少警报记录删除权限!");
}else{
alert("缺少警报模板删除权限!");
}
}
};
handleOk = () => {
this.del();
this.setState({
visible: false,
});
};
handleCancel = () => {
this.setState({
visible: false,
});
};
//获取警报数据
getData = () => {
const nowUser = this.props.currentUser.userid;
const params = {
type: this.state.type,
userID: nowUser,
// userPhone:"18813787835",
ownerId:this.props.location.query.id,
owerName:this.props.location.query.owerName,
communityName:this.props.location.query.communityName
};
this.props.dispatch({
type: 'tUModel/getOwnerDetail',
payload: params,
callback: (res) => {
if (res) {
console.log(res);
if(res.error_code == "0000"){
this.setState({
data: res.rows,
total: res.total,
})
} 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("获取失败!未知错误!");
}
}
}
});
};
//获取警报记录数据
getRecord = () => {
const params = {
type: this.state.type,
moment: this.state.moment,
id: this.props.currentUser.userid,
// userPhone:"18813787835"
pwnerId:"770da9de6b6c43f6b61bc3d671fa2e89",
owerName:"jack-小雄",
communityName:"A7"
};
this.props.dispatch({
type: 'tUModel/getOwnerDetail',
payload: params,
callback: (res) => {
if (res) {
console.log(res);
if(res.error_code == "0000"){
this.setState({
data: res.rows,
total: res.total,
})
} 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("获取失败!未知错误!");
}
}
}
});
};
//批量删除
del(){
this.props.dispatch({
type: this.state.current == 'model'?'warnModel/delWarn':'warnModel/delWarnRecord',
payload: this.state.delData,
callback: (res) => {
if (res) {
console.log(res);
if(res.error_code == "0000"){
alert("删除完毕!");
if(this.state.current == 'model'){
this.getData();
}else{
// this.getRecord();
}
}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("删除失败!未知错误!");
}
}
}
});
};
//跳转到编辑页面
edit = (params) => {
this.props.dispatch(routerRedux.push({
pathname: '/tosUser/common',
query: params,
}))
let flag = 0;
const nowUser = this.props.currentUser;
if(nowUser.permission!=null){
if(params==null){
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="11"){
flag = 1;
this.props.dispatch(routerRedux.push({
pathname: '/tosUser/common',
query: params,
}))
}
}
}else{
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="10"){
flag = 1;
this.props.dispatch(routerRedux.push({
pathname: '/tosUser/common',
query: params,
}))
}
}
}
}else{
//alert("找不到用户权限记录!");
//return;;
}
if(flag == 0){
if(params==null){
alert("缺少添加警报模板权限!");
}else{
// alert("缺少修改警报模版权限!");
}
}
};
//警报启用禁用
changeStatus = (e) => {
const params = {
status: e.warnStatus == '0'? 1:0,
warnID: e.warnID ? e.warnID : null,
};
this.props.dispatch({
type: 'warnModel/quitAndUserWarn',
payload: params,
callback: () => {
this.getData();
}
});
};
//状态变更
typeChange = (e) => {
this.setState({type: e == undefined?undefined:e+1});
};
//日期变更
dateChange = (e) => {
this.setState({moment: e});
};
//水平导航
handleClick = (e) => {
this.setState({
current: e.key,
},() => {
if(this.state.current == "record"){
// this.getRecord();
}else{
// this.getData(null);
}
});
};
//跳转到设备页面
back = () => {
this.props.dispatch(routerRedux.push({
pathname: '/UserManagement/tosUser',
}))
};
//提交
onSubmit = () => {
// this.phoneBlur();
};
//初始化
componentDidMount() {
if (this.props.location.query != null) {
const params = this.props.location.query;
this.setState({
current: params.current?params.current:'record',
},() => {
if(this.state.current == "record"){
this.getRecord();
}else{
this.getData();
}
});
}
}
/*--------------------------------------*/
//表格列名
columns = [
{
title: '用户名称',
dataIndex: 'warnType',
key: 'warnType',
render: (text, record) => (
<span>
{record.warnType == 1?'扫描模块故障':''}
{record.warnType == 2?'打印机故障':''}
{record.warnType == 3?'触摸屏故障':''}
{record.warnType == 4?'副屏故障':''}
</span>
),
},
{
title: '联系电话',
dataIndex: 'warnContactsInformation',
key: 'warnContactsInformation',
},
{
title: '联系邮箱',
dataIndex: 'warnDetails',
key: 'warnDetails',
},
{
title: '账号类型',
dataIndex: 'enable',
key: 'warn_time',
},
{
title: '账号状态',
dataIndex: 'user_account',
key: 'user_account',
defaultSortOrder: 'descend',
sorter: (a, b) => a.user_account - b.user_account,
},
/* {
title: '状态',
dataIndex: 'status',
key: 'status',
render: (text, record) => (
<span>
{record.warnStatus == 1? "启用": "禁用"}
</span>
)
},*/
{
title: 'Actions',
dataIndex: 'action',
key: 'action',
render: (text, record) => (
<span>
<Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.edit(record)}>Details</Button>
{/* <Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.changeStatus(record)}>{record.warnStatus == 1? "关闭": "启用"}</Button>*/}
</span>
),
},
];
columns2 = [
{
title: 'User Name',
dataIndex: 'owerName',
key: 'device_name',
},
{
title: 'Contact Details',
dataIndex: 'owerPhone',
key: 'device_model',
},
{
title: 'E-mail',
dataIndex: 'buildingNumber',
key: 'warn_type',
render: (text, record) => (
<span>
{record.warn_type == 1?'扫描模块故障':''}
{record.warn_type == 2?'打印机故障':''}
{record.warn_type == 3?'触摸屏故障':''}
{record.warn_type == 4?'副屏故障':''}
</span>
),
},
{
title: 'Account Type',
dataIndex: 'enable',
key: 'warn_time',
},
{
title: 'User Status',
dataIndex: 'user_account',
key: 'user_account',
defaultSortOrder: 'descend',
sorter: (a, b) => a.user_account - b.user_account,
},
{
title: 'Actions',
dataIndex: 'action',
key: 'action',
render: (text, record) => (
<span>
<Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.edit(record)}>Details</Button>
{/* <Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.edit(record)}>编辑</Button>*/}
</span>
),
},
/* {
title: '联系方式',
dataIndex: 'user_phone',
key: 'user_phone',
},
{
title: '地址',
dataIndex: 'device_address',
key: 'device_address',
},*/
];
//行选择
rowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
delData: selectedRows
},() => {
console.log(this.state.delData);
});
}
};
//渲染
render() {
const { data, total, typeList, current, record, visible,tosUser } = this.state;
const typeSelect = typeList.map((item, index) => (
<Select.Option value={index}>{item}</Select.Option>
));
return (
<div className={styles.body}>
<Button className={styles.button11} onClick={() => this.back()}>Return</Button>
<div style={{marginTop:48}}>
<div>
<span className={styles.detailsTitle}>Owner Details</span>
<div className={styles.detailsBox}>
<div>
<span className={styles.detailsContent}>Name Of Owner</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<span className={styles.detailsContent}>Kamon.Chen</span>
<span className={styles.detailsContent2}>{tosUser}</span>
{/* <span className={styles.detailsContent}>设备ID</span>*/}
<span className={styles.detailsContent2}>{tosUser}</span>
</div>
<div>
<span className={styles.detailsContent}>Contact Details</span>
<span className={styles.detailsContent3} style={{width:200}}>{tosUser}</span>
<span className={styles.detailsContent}>18817589685</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<span className={styles.detailsContent}>sales@huahuico.com</span>
<span className={styles.detailsContent2}>{tosUser}</span>
</div>
{/*<div>*/}
{/* <span className={styles.detailsContent}>联系地址</span>*/}
{/* <span className={styles.detailsContent3}>{total}</span>*/}
{/*</div>*/}
</div>
</div>
</div>
<div style={{padding:30}}>
<Menu
className={styles.menu}
onClick={this.handleClick}
selectedKeys={[current]}
mode="horizontal">
<Menu.Item key="record" className={styles.menuItem}>
Sunshine Stanford
</Menu.Item>
<Menu.Item key="model">
Constant company
</Menu.Item>
</Menu>
</div>
<div className={styles.inputBox}>
<div>
<span className={styles.detailsContent}>Address</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<span className={styles.detailsContent}>Singapore,Albert,Bugis</span>
</div>
<div>
<span className={styles.detailsContent}>Unit No.</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<span className={styles.detailsContent}>03#05-301</span>
<span className={styles.detailsContent2}>{tosUser}</span>
</div>
{/* <Select className={styles.input} placeholder="警报类型" onChange={(e) => this.typeChange(e)}
allowClear={true}>{typeSelect}</Select>
{current == 'record'?
<RangePicker
style={{marginLeft: 20}}
renderExtraFooter={() => ''}
showTime
onChange={(e) => this.dateChange(e)}
/>:''}*/}
</div>
<div>
{current == 'record'?
<div>
<img style ={{width:100,height:100,float:"right"}}src= {"http://www.srthinker.com:5205/file/d575594254a141f29d23d711d9158ba5.png"} />
<Button className={styles.button1} onClick={() => this.getRecord()}>Delete Unit</Button>
</div>
:''}
{current == 'model'?
<div>
<img style ={{width:100,height:100,float:"right"}}src= {"http://www.srthinker.com:5205/file/d575594254a141f29d23d711d9158ba5.png"} />
<Button className={styles.button1} onClick={() => this.getData()}>Delete Unit</Button>
</div>
:''}
{/* {current == 'model'?
<Button className={styles.button2} onClick={() => this.edit(null)}>新建</Button>:''}*/}
</div>
<div>
{current == 'record'?
<div>
<Table
rowKey={record => record.warn_record_id}
className={styles.table}
rowSelection={this.rowSelection}
columns={this.columns2}
dataSource={record}
size="small"
pagination={{showQuickJumper: true, pageSize: 10, total: total}}
/>
<div>
<span className={styles.detailsContent}>Unit No.</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<span className={styles.detailsContent}>03#05-301</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<img style ={{width:100,height:100,float:"right"}}src= {"http://www.srthinker.com:5205/file/d575594254a141f29d23d711d9158ba5.png"} />
<Button className={styles.button1} onClick={() => this.getRecord()}>Delete Unit</Button>
</div>
<Table
rowKey={record => record.warn_record_id}
className={styles.table}
rowSelection={this.rowSelection}
columns={this.columns2}
dataSource={record}
size="small"
pagination={{showQuickJumper: true, pageSize: 10, total: total}}
/>
<div>
{/*<Button className={styles.button2} onClick={() => this.onSubmit()}>提交</Button>*/}
</div>
</div>
:''}
{current == 'model'?
<div>
<Table
rowKey={record => record.warnID}
className={styles.table}
rowSelection={this.rowSelection}
columns={this.columns}
dataSource={data}
size="small"
pagination={{showQuickJumper: true, pageSize: 10, total: total}}
/>
<div>
<span className={styles.detailsContent}>Unit No.</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<span className={styles.detailsContent}>03#05-301</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<img style ={{width:100,height:100,float:"right"}}src= {"http://www.srthinker.com:5205/file/d575594254a141f29d23d711d9158ba5.png"} />
<Button className={styles.button1} onClick={() => this.getRecord()}>Delete Unit</Button>
</div>
<Table
rowKey={record => record.warnID}
className={styles.table}
rowSelection={this.rowSelection}
columns={this.columns}
dataSource={data}
size="small"
pagination={{showQuickJumper: true, pageSize: 10, total: total}}
/>
</div>
:''}
{/*{current == 'record'?
<Button className={styles.button3}
style={{width:120}}
onClick={() => this.downloadExcel()}>
批量下载</Button>:''}*/}
{/*<Button className={styles.button3} onClick={() => this.showModal()}>删除</Button>*/}
</div>
<div>
</div>
<Modal
title="确认删除?"
visible={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,
}))(TosUserDetails);
import React from 'react';
import {connect, routerRedux} from 'dva';
import {Table, Button, DatePicker, Select, Menu, Modal, Input} from "antd";
import styles from './style.less';
import {ConnectState} from "@/models/connect";
import ExportJsonExcel from 'js-export-excel';
import {router} from "umi";
//npm install js-export-excel
const { RangePicker, } = DatePicker;
class TosUserEdit extends React.Component {
//构造
constructor(props) {
super(props);
this.state = {
record: [],
data: [],
total: 1,
type: undefined,
typeList: ["扫描模块故障", "打印机故障", "触摸屏故障","副屏故障"],
moment: [],
current: 'record',
delData: [],
visible: false,
}
}
/*----------------- 方法集 ------------------*/
//打印excel
downloadExcel = () => {
let flag = 0;
const nowUser = this.props.currentUser;
if(nowUser.permission!=null){
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="14"){
flag = 1;
const data = this.state.record ? this.state.record : '';//表格数据
var option={};
let dataTable = [];
if (data) {
for (let i in data) {
if(data){
let warnType;
if(data[i].warn_type == 1) {
warnType = '扫描模块故障';
}else if(data[i].warn_type == 2) {
warnType = '打印机故障';
}else if(data[i].warn_type == 3) {
warnType = '触摸屏故障';
}else if(data[i].warn_type == 4) {
warnType = '副屏故障';
}
let obj = {
'设备名称': data[i].device_name,
'设备型号': data[i].device_model,
'警报类型': warnType,
'报警时间': data[i].warn_time,
'地址': data[i].device_address,
'联系人': data[i].user_account,
'联系方式': data[i].user_phone,
}
dataTable.push(obj);
}
}
}
option.fileName = '警报信息';
option.datas=[
{
sheetData:dataTable,
sheetName:'sheet',
sheetFilter:['设备名称','设备型号','警报类型','报警时间','联系人','联系方式','地址'],
sheetHeader:['设备名称','设备型号','警报类型','报警时间','联系人','联系方式','地址'],
}
];
var toExcel = new ExportJsonExcel(option);
toExcel.saveExcel();
}
}
}else{
//alert("找不到用户权限记录!");
//return;;
}
if(flag == 0){
alert("缺少批量下载权限!");
return;
}
};
//模态框相关
showModal = () => {
let flag = 0;
let permissionNum = null;
const nowUser = this.props.currentUser;
if(nowUser.permission!=null){
for(let i=0;i<nowUser.permission.length;i++){
if(this.state.current == "record"){
permissionNum = "15";
}else{
permissionNum = "12";
}
if(nowUser.permission[i]==permissionNum){
if(this.state.delData==null||this.state.delData.length<=0){
alert("未选中删除项!");
return;
}
flag = 1;
this.setState({
visible: true,
});
}
}
}else{
//alert("找不到用户权限记录!");
//return;;
}
if(flag == 0){
if(this.state.current == "record"){
alert("缺少警报记录删除权限!");
}else{
alert("缺少警报模板删除权限!");
}
}
};
handleOk = () => {
this.del();
this.setState({
visible: false,
});
};
handleCancel = () => {
this.setState({
visible: false,
});
};
//获取警报数据
getData = () => {
const nowUser = this.props.currentUser.userid;
const params = {
type: this.state.type,
userID: nowUser,
userPhone:"18813787835"
};
this.props.dispatch({
type: 'tUModel/getTosUser',
payload: params,
callback: (res) => {
if (res) {
console.log(res);
// if(res.error_code == "0000"){
this.setState({
data: res.rows,
total: res.total,
})
/* } 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("获取警报数据失败!未知错误!");
}*/
}
}
});
};
//获取警报记录数据
getRecord = () => {
const params = {
type: this.state.type,
moment: this.state.moment,
id: this.props.currentUser.userid,
// userPhone:"18813787835"
ownerId:this.props.location.query.id,
owerName:this.props.location.query.owerName,
communityName:this.props.location.query.communityName
};
this.props.dispatch({
// type: 'tUModel/getTosUser',
type: 'tUModel/getOwnerDetail',
payload: params,
callback: (res) => {
// if (res.error_code == "0000"){
this.setState({
record: res.data.rows,
total: res.data.total,
})
/* } 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("获取警报记录失败!未知错误!")
}*/
}
});
};
//批量删除
del(){
this.props.dispatch({
type: this.state.current == 'model'?'warnModel/delWarn':'warnModel/delWarnRecord',
payload: this.state.delData,
callback: (res) => {
if (res) {
console.log(res);
if(res.error_code == "0000"){
alert("删除完毕!");
if(this.state.current == 'model'){
this.getData();
}else{
// this.getRecord();
}
}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("删除失败!未知错误!");
}
}
}
});
};
//跳转到编辑页面
edit = (params) => {
this.props.dispatch(routerRedux.push({
pathname: '/UserManagement/tosUser/common',
query: params,
}))
let flag = 0;
const nowUser = this.props.currentUser;
if(nowUser.permission!=null){
if(params==null){
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="11"){
flag = 1;
this.props.dispatch(routerRedux.push({
pathname: '/tosUser/common',
query: params,
}))
}
}
}else{
for(let i=0;i<nowUser.permission.length;i++){
if(nowUser.permission[i]=="10"){
flag = 1;
this.props.dispatch(routerRedux.push({
pathname: '/warn/edit',
query: params,
}))
}
}
}
}else{
//alert("找不到用户权限记录!");
//return;;
}
if(flag == 0){
if(params==null){
// alert("缺少添加警报模板权限!");
}else{
// alert("缺少修改警报模版权限!");
}
}
};
//警报启用禁用
changeStatus = (e) => {
const params = {
status: e.warnStatus == '0'? 1:0,
warnID: e.warnID ? e.warnID : null,
};
this.props.dispatch({
type: 'warnModel/quitAndUserWarn',
payload: params,
callback: () => {
this.getData();
}
});
};
//状态变更
typeChange = (e) => {
this.setState({type: e == undefined?undefined:e+1});
};
//日期变更
dateChange = (e) => {
this.setState({moment: e});
};
//水平导航
handleClick = (e) => {
this.setState({
current: e.key,
},() => {
if(this.state.current == "record"){
// this.getRecord();
}else{
// this.getData(null);
}
});
};
//跳转到设备页面
back = () => {
this.props.dispatch(routerRedux.push({
pathname: '/UserManagement/tosUser',
}))
};
//提交
onSubmit = () => {
// this.phoneBlur();
};
//初始化
componentDidMount() {
if (this.props.location.query != null) {
const params = this.props.location.query;
this.setState({
current: params.current?params.current:'record',
},() => {
if(this.state.current == "record"){
this.getRecord();
}else{
this.getData();
}
});
}
}
/*--------------------------------------*/
//表格列名
columns = [
{
title: 'User Name',
dataIndex: 'warnType',
key: 'warnType',
render: (text, record) => (
<span>
{record.warnType == 1?'扫描模块故障':''}
{record.warnType == 2?'打印机故障':''}
{record.warnType == 3?'触摸屏故障':''}
{record.warnType == 4?'副屏故障':''}
</span>
),
},
{
title: 'Contact Details',
dataIndex: 'warnContactsInformation',
key: 'warnContactsInformation',
},
{
title: 'E-mail',
dataIndex: 'warnDetails',
key: 'warnDetails',
},
{
title: 'Account Type',
dataIndex: 'enable',
key: 'warn_time',
},
{
title: 'User Status',
dataIndex: 'user_account',
key: 'user_account',
defaultSortOrder: 'descend',
sorter: (a, b) => a.user_account - b.user_account,
},
/* {
title: '状态',
dataIndex: 'status',
key: 'status',
render: (text, record) => (
<span>
{record.warnStatus == 1? "启用": "禁用"}
</span>
)
},*/
{
title: 'Actions',
dataIndex: 'action',
key: 'action',
render: (text, record) => (
<span>
<Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.edit(record)}>Details</Button>
{/* <Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.changeStatus(record)}>{record.warnStatus == 1? "关闭": "启用"}</Button>*/}
</span>
),
},
];
columns2 = [
{
title: 'User Name',
dataIndex: 'owner_family_name',
key: 'owner_family_name',
},
{
title: 'Contact Details',
dataIndex: 'owner_family_phone',
key: 'owner_family_phone',
},
{
title: 'E-mail',
dataIndex: 'owner_family_email',
key: 'owner_family_email',
},
{
title: 'Account Type',
dataIndex: 'owner_relationship',
key: 'owner_relationship',
render: (text, record) => (
<span>
{record.owner_relationship == 1?'家属':''}
{record.owner_relationship == 2?'租户':''}
</span>
),
},
{
title: 'User Status',
dataIndex: 'status',
key: 'status',
defaultSortOrder: 'descend',
sorter: (a, b) => a.user_account - b.user_account,
},
{
title: 'Actions',
dataIndex: 'action',
key: 'action',
render: (text, record) => (
<span>
<Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.edit(record)}>Details</Button>
{/* <Button style={{background: 'transparent', border: 0, color: '#1890FF'}}
onClick={() => this.edit(record)}>编辑</Button>*/}
</span>
),
},
/* {
title: '联系方式',
dataIndex: 'user_phone',
key: 'user_phone',
},
{
title: '地址',
dataIndex: 'device_address',
key: 'device_address',
},*/
];
//行选择
rowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
delData: selectedRows
},() => {
console.log(this.state.delData);
});
}
};
//渲染
render() {
const { data, total, typeList, current, record, visible,tosUser } = this.state;
const typeSelect = typeList.map((item, index) => (
<Select.Option value={index}>{item}</Select.Option>
));
return (
<div className={styles.body}>
<Button className={styles.button11} onClick={() => this.back()}>Return</Button>
<div style={{marginTop:48}}>
<div>
<span className={styles.detailsTitle}>Edit Owner Information</span>
<div className={styles.detailsBox}>
<div>
<span className={styles.detailsContent}>Name Of Owner</span>
<Input className={styles.input} value={this.props.location.query.owerName} placeholder="Name"
/*onChange={(e) => this.snChange(e)}*/
/>
<span className={styles.detailsContent2}>{tosUser}</span>
{/*<span className={styles.detailsContent}>锶想</span>*/}
<span className={styles.detailsContent2}>{tosUser}</span>
{/* <span className={styles.detailsContent}>设备ID</span>*/}
<span className={styles.detailsContent2}>{tosUser}</span>
</div>
<div>
<span className={styles.detailsContent}>Contact Details</span>
<Input className={styles.input} value={this.props.location.query.owerPhone} placeholder="Telephone"
/*onChange={(e) => this.snChange(e)}*/
/>
<span className={styles.detailsContent3} style={{width:200}}>{tosUser}</span>
{/*<span className={styles.detailsContent}>18817589685</span>*/}
<Input className={styles.input} value={this.props.location.query.owerEmail} placeholder="E-mail"
/*onChange={(e) => this.snChange(e)}*/
/>
<span className={styles.detailsContent2}>{tosUser}</span>
{/*<span className={styles.detailsContent}>sales@huahuico.com</span>*/}
<span className={styles.detailsContent2}>{tosUser}</span>
</div>
{/*<div>*/}
{/* <span className={styles.detailsContent}>联系地址</span>*/}
{/* <span className={styles.detailsContent3}>{total}</span>*/}
{/*</div>*/}
</div>
</div>
</div>
<div style={{padding:30}}>
<Menu
className={styles.menu}
onClick={this.handleClick}
selectedKeys={[current]}
mode="horizontal">
<Menu.Item key="record" className={styles.menuItem}>
{this.props.location.query.communityName}
</Menu.Item>
<Menu.Item key="model">
Constant company
</Menu.Item>
</Menu>
</div>
<div className={styles.inputBox}>
<div>
<span className={styles.detailsContent}>Address</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<span className={styles.detailsContent}>{this.props.location.query.addressAndpostalCode}</span>
</div>
<div>
<span className={styles.detailsContent}>Unit No.</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<span className={styles.detailsContent}>{this.props.location.query.roomNumber}</span>
<span className={styles.detailsContent2}>{tosUser}</span>
</div>
{/* <Select className={styles.input} placeholder="警报类型" onChange={(e) => this.typeChange(e)}
allowClear={true}>{typeSelect}</Select>
{current == 'record'?
<RangePicker
style={{marginLeft: 20}}
renderExtraFooter={() => ''}
showTime
onChange={(e) => this.dateChange(e)}
/>:''}*/}
</div>
<div>
{current == 'record'?
<div>
<img style ={{width:100,height:100,float:"right"}}src= {"http://www.srthinker.com:5205/file/d575594254a141f29d23d711d9158ba5.png"} />
{/*<Button className={styles.button1} onClick={() => this.getRecord()}>删除单位</Button>*/}
</div>
:''}
{current == 'model'?
<div>
<img style ={{width:100,height:100,float:"right"}}src= {"http://www.srthinker.com:5205/file/d575594254a141f29d23d711d9158ba5.png"} />
{/*<Button className={styles.button1} onClick={() => this.getData()}>删除单位1</Button>*/}
</div>
:''}
{/* {current == 'model'?
<Button className={styles.button2} onClick={() => this.edit(null)}>新建</Button>:''}*/}
</div>
<div>
{current == 'record'?
<div>
<Table
rowKey={record => record.warn_record_id}
className={styles.table}
rowSelection={this.rowSelection}
columns={this.columns2}
dataSource={record}
size="small"
pagination={{showQuickJumper: true, pageSize: 10, total: total}}
/>
<div>
<span className={styles.detailsContent}>Unit No.</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<span className={styles.detailsContent}>03#05-301</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<img style ={{width:100,height:100,float:"right"}}src= {"http://www.srthinker.com:5205/file/d575594254a141f29d23d711d9158ba5.png"} />
{/*<Button className={styles.button1} onClick={() => this.getRecord()}>删除单位</Button>*/}
</div>
<Table
rowKey={record => record.warn_record_id}
className={styles.table}
rowSelection={this.rowSelection}
columns={this.columns2}
dataSource={record}
size="small"
pagination={{showQuickJumper: true, pageSize: 10, total: total}}
/>
<div>
<Button className={styles.button2} onClick={() => this.onSubmit()}>Submit</Button>
</div>
</div>
:''}
{current == 'model'?
<div>
<Table
rowKey={record => record.warnID}
className={styles.table}
rowSelection={this.rowSelection}
columns={this.columns}
dataSource={data}
size="small"
pagination={{showQuickJumper: true, pageSize: 10, total: total}}
/>
<div>
<span className={styles.detailsContent}>Unit No.</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<span className={styles.detailsContent}>03#05-301</span>
<span className={styles.detailsContent2}>{tosUser}</span>
<img style ={{width:100,height:100,float:"right"}}src= {"http://www.srthinker.com:5205/file/d575594254a141f29d23d711d9158ba5.png"} />
{/*<Button className={styles.button1} onClick={() => this.getRecord()}>删除单位</Button>*/}
</div>
<Table
rowKey={record => record.warnID}
className={styles.table}
rowSelection={this.rowSelection}
columns={this.columns}
dataSource={data}
size="small"
pagination={{showQuickJumper: true, pageSize: 10, total: total}}
/>
</div>
:''}
{/*{current == 'record'?
<Button className={styles.button3}
style={{width:120}}
onClick={() => this.downloadExcel()}>
批量下载</Button>:''}*/}
{/*<Button className={styles.button3} onClick={() => this.showModal()}>删除</Button>*/}
</div>
<div>
</div>
<Modal
title="确认删除?"
visible={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,
}))(TosUserEdit);
import React from 'react';
import {connect, routerRedux} from 'dva';
import {Button, Input, Select } from "antd";
import styles from './style.less';
import {ConnectState} from "@/models/connect";
import {router} from "umi";
class TosUserCreate extends React.Component {
//构造
constructor(props) {
super(props);
this.state = {
name: '',
model: '',
id: '',
keeper: '',
phone: '',
status: '',
province: undefined,
city: undefined,
district: undefined,
street: undefined,
provinceList: [],
cityList: [{name: "未选择省"}],
districtList: [{name: "未选择市"}],
streetList: [{name: "未选择区"}],
deviceStatus: '',
sn: '',
phoneBlur: undefined,
}
}
/*----------------- 方法集 --------------- ---*/
//加载省
provinceload = (code) => {
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: code,},
callback: (res) => {
if (res) {
this.setState({
provinceList: res.data,
});
}
}
});
};
//省变更
provinceChange = (e) => {
if (e == undefined) {
this.setState({
cityList: [{name: "未选择省"}],
districtList: [{name: "未选择市"}],
streetList: [{name: "未选择区"}],
province: undefined,
city: undefined,
district: undefined,
street: undefined,
})
} else {
this.setState({province: {label: e.label,}});
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: e.key,},
callback: (res) => {
if (res) {
this.setState({
cityList: res.data,
city: undefined,
district: undefined,
street: undefined,
});
}
}
});
}
};
//市变更
cityChange = (e) => {
if (e == undefined) {
this.setState({
districtList: [{name: "未选择市"}],
streetList: [{name: "未选择区"}],
city: undefined,
district: undefined,
street: undefined,
})
} else {
this.setState({city: {label: e.label,}});
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: e.key,},
callback: (res) => {
if (res) {
this.setState({
districtList: res.data,
district: undefined,
street: undefined,
});
}
}
});
}
};
//区变更
districtChange = (e) => {
if (e == undefined) {
this.setState({
streetList: [{name: "未选择区"}],
district: undefined,
street: undefined,
})
} else {
this.setState({district: {label: e.label,}});
this.props.dispatch({
type: 'deviceModel/getRegion',
payload: {code: e.key,},
callback: (res) => {
if (res) {
this.setState({
streetList: res.data,
street: undefined,
});
}
}
});
}
};
//街道变更
streetChange = (e) => {
if (e == undefined) {
this.setState({
street: undefined,
})
} else {
this.setState({street: {label: e.label,} });
}
};
//app版本变更
appVersionChange = (e) => {
this.setState({appVersion: e.target.value});
};
//app版本变更
firmwareChange = (e) => {
this.setState({firmware: e.target.value});
};
//设备名称变更
nameChange = (e) => {
this.setState({name: e.target.value});
};
//设备模板变更
modelChange = (e) => {
this.setState({model: e.target.value});
};
//设备ID变更
idChange = (e) => {
this.setState({id: e.target.value});
};
//设备sn变更
snChange = (e) => {
this.setState({sn: e.target.value});
};
//管理员变更
keeperChange = (e) => {
this.setState({keeper: e.target.value});
};
//联系电话正则
phoneBlur = () => {
if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(this.state.phone))){
this.setState({
phoneBlur: false,
})
}else{
this.setState({
phoneBlur: true,
},() => {
if(this.state.phoneBlur==true) {
const params = {
deviceAddress: (this.state.province == undefined ? '' : this.state.province.label) +
(this.state.city == undefined ? '' : '-'+this.state.city.label) +
(this.state.district == undefined ? '' : '-'+this.state.district.label) +
(this.state.street == undefined ? '' : '-'+this.state.street.label),
deviceName: this.state.name,
deviceModel: this.state.model,
deviceKeeper: this.state.keeper,
deviceID: this.state.id,
deviceSerialNumber: this.state.sn,
devicePhone: this.state.phone,
deviceWorking: this.state.status == '' ? 2 : this.state.status,
deviceStatus: this.state.deviceStatus ? this.state.deviceStatus : 0,
deviceCreate: this.props.currentUser.userid,
};
console.log("params",params);
this.props.dispatch({
type: 'deviceModel/saveDevice',
payload: params,
callback: (res) => {
if (res.error_code == "0000") {
alert(res.error_msg);
this.back();
} else if (res.error_code == "0002") {
alert(res.error_msg);
this.back();
} else if (res.error_code == "0001"){
alert(res.error_msg);
} else if (res.error_code == "0003"){
alert(res.error_msg)
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
}else {
alert("提交错误!未知原因!");
}
}
});
}
});
}
};
//联系电话变更
phoneChange = (e) => {
this.setState({phone: e.target.value});
};
//联系电话1变更
phoneChange1 = (e) => {
this.setState({phone1: e.target.value});
};
//提交
onSubmit = () => {
this.phoneBlur();
};
//跳转到设备页面
back = () => {
this.props.dispatch(routerRedux.push({
pathname: '/UserManagement/tosUser/edit',
}))
};
//初始化
componentDidMount() {
if(this.props.location.query!=null) {
const params = this.props.location.query;
this.setState({
name: params.deviceName,
model: params.deviceModel,
id: params.deviceID,
sn: params.deviceSerialNumber,
keeper: params.deviceKeeper,
phone: params.devicePhone,
phone1:params.devicePhone1,
status: params.deviceWorking,
deviceStatus: params.deviceStatus,
});
if(params.deviceAddress!=null){
const strs = params.deviceAddress.split("-");
if(strs[0]==''){
return;
}
this.props.dispatch({
type: 'deviceModel/getRegionList',
payload: {
address: params.deviceAddress
},
callback: (res) => {
if (res) {
this.setState({
cityList: res.cityList?res.cityList:[{name: "未选择省"}],
districtList: res.districtList?res.districtList:[{name: "未选择市"}],
streetList: res.streetList?res.streetList:[{name: "未选择区"}],
province: {label:strs[0]},
city: strs[1]?{label:strs[1]}:undefined,
district: strs[2]?{label:strs[2]}:undefined,
street: strs[3]?{label:strs[3]}:undefined,
});
}
}
});
}else{
this.setState({
province: undefined,
city: undefined,
district: undefined,
street: undefined,
});
}
}
this.provinceload(0);
}
/*--------------------------------------*/
//渲染
render() {
const { name, model, keeper, phone,phone1, province, city, district, street,
provinceList, cityList, districtList, streetList, phoneBlur, sn } = this.state;
/* const provinceSelect = provinceList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));
const citySelect = cityList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));
const districtSelect = districtList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));
const streetSelect = streetList.map((item) => (
<Select.Option value={item.code} label={item.name}>{item.name}</Select.Option>
));*/
return(
<div className={styles.body}>
<Button className={styles.button11} onClick={() => this.back()}>Return</Button>
<div style={{marginTop:48}}>
<span className={styles.detailsTitle}>Family Member/Tenant Details</span>
<div className={styles.detailsBox}>
<div>
<span className={styles.detailsContent}>User Type</span>
{/*<Input className={styles.input} value={sn} onChange={(e) => this.snChange(e)}/>*/}
<span className={styles.detailsContent}>Family Member</span>
</div>
<div>
<span className={styles.detailsContent}>Full Name</span> <Button className={styles.button1} onClick={() => this.onSubmit()}>Cancel Account</Button>
{/*<Input className={styles.input} value={model} placeholder="小区名称" onChange={(e) => this.modelChange(e)} />*/}
<span className={styles.detailsContent}>kamon.chen</span>
{/* <Input className={styles.input} value={name} placeholder="楼号" onChange={(e) => this.nameChange(e)} />
<Input className={styles.input} value={keeper} placeholder="楼层" onChange={(e) => this.keeperChange(e)}/>
<Input className={styles.input}
value={phone1} placeholder="房号"
onChange={(e) => this.phoneChange1(e)}
/>*/}
</div>
<div>
<span className={styles.detailsContent}>Contact Details</span>
<span className={styles.detailsContent}>132222222</span>
<span className={styles.detailsContent}>sales@huahuico.com</span>
</div>
<div style={{marginTop:120}}>
</div>
</div>
</div>
</div>
);
}
}
export default connect(({user}:ConnectState) => ({
currentUser: user.currentUser,
}))(TosUserCreate);
@import '~antd/lib/style/themes/default.less';
.pre {
margin: 12px 0;
padding: 12px 20px;
background: @input-bg;
box-shadow: @card-shadow;
}
.input {
width:200px;
height:34px;
border:1px solid rgba(229, 229, 229, 1);
border-radius:5px;
margin: 0px 10px;
}
.input1 {
width:200px;
height:34px;
border:1px solid rgba(229, 229, 229, 1);
border-radius:5px;
margin: 0px 120px 10px;
}
.body {
background:rgba(255,255,255,1);
border:1px solid rgba(229, 229, 229, 1);
}
.inputBox {
width:1250px;
height:50px;
padding-top: 10px;
}
.downIcon {
position: relative;
left: 80px;
}
.downButton {
width:120px;
height:34px;
border:1px solid rgba(229, 229, 229, 1);
border-radius:5px;
margin: 0px 10px;
text-align: left;
}
.button11 {
width:82px;
height:34px;
background:rgba(234,244,255,1);
border:1px solid rgba(178, 215, 255, 1);
font-size:14px;
font-family:PingFang SC;
font-weight:400;
color:rgba(66,159,255,1);
line-height:34px;
margin:20px 20px 7px 10px;
float: left;
}
.button1 {
width:150px;
height:34px;
background:rgba(234,244,255,1);
border:1px solid rgba(178, 215, 255, 1);
font-size:14px;
font-family:PingFang SC;
font-weight:400;
color:rgba(66,159,255,1);
line-height:34px;
margin: 7px 10px;
float: right;
}
.button2 {
width:150px;
height:34px;
background:rgba(24,144,255,1);
border-radius:4px;
font-size:14px;
font-family:PingFang SC;
font-weight:400;
color:rgba(255,255,255,1);
line-height:34px;
margin: 7px 10px;
float: left;
}
.button3 {
position: relative;
bottom: 52px;
width:72px;
height:32px;
background:rgba(255,255,255,1);
border:1px solid rgba(229, 229, 229, 1);
border-radius:4px;
margin: 10px 10px;
}
.table {
margin-right: 10px;
}
.detailsTitle {
display: inline-block;
font-size:18px;
font-family:PingFang SC;
font-weight:400;
color:rgba(73,73,73,1);
margin: 0px 30px;
}
.detailsContent {
display: inline-block;
font-size:15px;
width: 100px;
font-family:PingFang SC;
font-weight:400;
color:rgba(153,153,153,1);
margin: 10px 10px;
}
.detailsContent2 {
display: inline-block;
font-size:18px;
width: 200px;
font-family:PingFang SC;
font-weight:400;
color:rgba(51,51,51,1);
}
.detailsBox {
border-top: 1px solid rgba(229, 229, 229, 1);
margin: 10px 30px;
}
.font1 {
.detailsContent {
font-family:PingFang SC;
font-weight:400;
color:rgba(153,153,153,1);
margin: 5px 10px;
}
.backBox{
border: 1px solid rgb(0, 12, 23);
font-size: 2em;
margin: 50px ;
background: #1153ff;
}
.allCheckbox{
}
.subCheckbox{
}
}
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,
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: '/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>
{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 className={styles.input} placeholder="状态" onChange={(e) => this.statusChange(e)}
allowClear={true}>{statusSelect}</Select>
<Button className={styles.button1} 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);
import React from 'react';
import {connect, routerRedux} from 'dva';
import {Button, Input, Upload, Icon, Checkbox, Row, Tooltip, List, Modal,Select} from "antd";
import styles from './style.less';
import {ConnectState} from "@/models/connect";
import XLSX from './xlsx.core.min';
import {router} from "umi";
import permission from "@/models/permission";
let go = 0;
let deviceData = [];
let checkUser = 1;
class AccountEdit extends React.Component {
//构造
constructor(props) {
super(props);
this.state = {
account: '',
pw: '',
pw2: '',
id: '',
email: '',
phone: '',
status: '',
radio: 2,
createUser: '',
userId: '',
defaultLevel:'',
permission: [],
targetKeys: [],
deviceData: [],
visible: false,
visible2: false,
newEdit: false,
level: '',
levelList: [{label: '四级管理员', value: 1},
{label: '三级管理员', value: 2},
{label: '二级管理员', value: 3},
{label: '一级管理员', value: 4},
{label: '超级管理员', value: 5}
],
leaderList: [{userAccount: '未选择管理员等级'}],
adList: ["一级管理员", "二级管理员","三级管理员"],
leader: '',
deviceList: [],
addDevice: '',
flag: 1,
used: null,
newAdd: null,
strList: [],
}
}
/*----------------- 方法集 ------------------*/
//显示信息
info() {
let _this = this;
const { used, newAdd, strList} = this.state;
const strSelect = strList.map((item, index) => (
<p>{item}</p>
));
Modal.info({
title: '批量导入结果',
content: (
<div>
<p>绑定<span style={{color:"lightgreen",fontSize:24}}>{newAdd}</span>台设备,
以下<span style={{color:"red",fontSize:24}}>{used}</span>台设备已被占用</p>
{strSelect}
</div>
),
onOk() {
_this.back();
},
});
}
//检测是否存在相同用户
checkUser = () => {
checkUser = 1;
if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
alert("未输入账号名称!");
checkUser = 0;
return;
}
this.props.dispatch({
type: 'accountModel/checkAccountByName',
payload: {
username: this.state.account,
},
callback: (res) => {
if (res) {
if (res.error_code == "0000") {
checkUser = 0;
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
checkUser = 1;
}
}
}
});
};
//跳转到账户页面
back = () => {
this.props.dispatch(routerRedux.push({
pathname: '/account',
}))
};
//获取所有上级
getAllLeader = (level) => {
const params = {
userLevel: level,
};
this.props.dispatch({
type: 'accountModel/getAllLeader',
payload: params,
callback: (res) => {
if (res) {
this.setState({
leaderList: res,
})
}
}
});
};
//两次密码校对
checkPw = () => {
if (this.state.pw == null || this.state.pw == undefined || this.state.pw.trim() == '') {
alert("未输入密码!");
go = 0;
} else if (this.state.pw2 == null || this.state.pw2 == undefined || this.state.pw2.trim() == '') {
alert("未输入确认密码!");
go = 0;
} else if (this.state.pw != this.state.pw2) {
go = 0;
alert("两次输入的密码不同!");
} else {
go = 1;
this.onSubmit();
}
};
//批量导入设备
importUserDeviceListExcel = (id) => {
if (this.state.deviceList != undefined && this.state.deviceList != null && this.state.deviceList != '') {
this.props.dispatch({
type: 'deviceModel/importUserDeviceListExcel',
payload: {
jsonArr: this.state.deviceList,
userID: id,
},
callback: (res) => {
if (res) {
this.setState({
used: res.data.used,
newAdd: res.data.integer,
strList: res.data.strList,
},() => {
this.info();
});
}
}
});
}else{
this.back();
}
};
//获取用户拥有的设备
getUserDevice = (userID) => {
const params = {
userID: userID,
};
this.props.dispatch({
type: 'deviceModel/getTargetKeys',
payload: params,
callback: (res) => {
if (res) {
this.setState({
targetKeys: res
});
}
}
});
};
//获取操作员拥有的设备
getDevice = () => {
const params = {
userID: this.props.currentUser.userid,
};
this.props.dispatch({
type: 'deviceModel/getUserDevice',
payload: params,
callback: (res) => {
deviceData = [];
if (res) {
for (let i = 0; i < res.total; i++) {
if (res.rows[i].deviceSerialNumber != '' && res.rows[i].deviceSerialNumber != null) {
deviceData.push({
key: res.rows[i].deviceID,
title: res.rows[i].deviceSerialNumber,
});
}
}
}
}
});
};
//保存权限信息
savePermission = (id) => {
const nowUser = this.props.currentUser;
this.props.dispatch({
type: 'permissionModel/saveAccountPermission',
payload: {
userName: this.state.account,
userPassword: this.state.pw,
permissionArray: this.state.permission,
},
callback: (res) => {
if(res){
console.log(res);
if(id == nowUser.userid){
this.props.currentUser.permission = this.state.permission;
}
alert(res.error_msg);
}
}
});
};
//获取权限信息
getPermission = (userID) => {
const params1 = this.props.location.query;
const params = {
userID: params1.tosUserName,
};
this.props.dispatch({
type: 'permissionModel/getAccountPermission',
payload: params,
callback: (res) => {
if (res) {
this.setState({
permission: res,
})
}
}
});
};
//绑定单个设备
addToDeviceList() {
const oldDeviceList = this.state.deviceList;
if (!oldDeviceList.includes(this.state.addDevice) && this.state.addDevice != '' && this.state.addDevice != null && this.state.addDevice != undefined) {
oldDeviceList.push(this.state.addDevice);
}
this.setState({
deviceList: oldDeviceList
})
}
//SN变更
addDeviceChange(e) {
this.setState({
addDevice: e.target.value,
});
}
//用户名变更
accountChange = (e) => {
this.setState({account: e.target.value});
};
adChange = (e) => {
this.setState({level: e == undefined?undefined:e+1});
};
//密码变更
pwChange = (e) => {
this.setState({pw: e.target.value});
};
//确认密码变更
pwChange2 = (e) => {
this.setState({pw2: e.target.value});
};
//联系电话变更
phoneChange = (e) => {
this.setState({phone: e.target.value});
};
//联系邮箱变更
emailChange = (e) => {
this.setState({email: e.target.value});
};
//提交前验证
onGo = () => {
if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
alert("未输入账号名称!");
checkUser = 0;
return;
}
this.props.dispatch({
type: 'accountModel/checkAccountByName',
payload: {
username: this.state.account,
},
callback: (res) => {
if (res) {
console.log(res);
if (res.error_code == "0000") {
checkUser = 0;
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
this.checkPw();
}
}
}
});
};
//提交
onSubmit = () => {
if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
alert("未输入账号名称!");
checkUser = 0;
return;
}
this.props.dispatch({
type: 'accountModel/checkAccountByName',//请求一次,通过用户名查表
payload: {
username: this.state.account,
},
callback: (res) => {
if (res) {
console.log(res);
if (res.error_code == "0000") {
// if(this.state.newEdit==true){
// checkUser = 0;
// alert(res.error_msg);
// }else {
let oneself = 0;
if(this.state.id!=null&&(this.state.id == this.props.currentUser.userid)){
oneself = 1;
}
const params = {
/* userAccount: this.state.account,
userID: this.state.id ? this.state.id : null,
userPhone: this.state.phone,
userPassword: this.state.newEdit == true ? this.state.pw : null,
userEmail: this.state.email,
createUser: this.state.createUser != undefined ? this.state.createUser : this.state.userId,
userLevel: this.state.level,*/
userLeader: this.state.leader,
oneself: oneself,
tosUserName:this.state.account,
id:this.state.id ? this.state.id : null,
tosUserPhone:this.state.phone,
userStatus: this.state.status ? this.state.status : 1,
tosUserPwd:this.state.newEdit == true ? this.state.pw : null,
tosUserEmail:this.state.email,
tosuserLevel:this.state.level,
tosUserToCompany:this.state.createUser != undefined ? this.state.createUser : this.state.userId,
tosUserServiceCell:this.state.leader,
};
this.props.dispatch({
type: 'accountModel/saveAccount',// 第二次请求,查不到用户的时候,保存新的用户
payload: params,
callback: (res) => {
console.log(res);
if (res.error_code == "0000") {
// alert(res.error_msg);
console.log("data",res.data);
// this.importUserDeviceListExcel(res.data.userID);
this.savePermission(res.data.userID);// 第三次请求,插入权限表格
} 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("提交失败!");
}
}
});
// }
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
checkUser = 1;
let oneself = 0;
if(this.state.id!=null&&(this.state.id == this.props.currentUser.userid)){
oneself = 1;
}
const params = {
tosUserName:this.state.account,
id:this.state.id ? this.state.id : null,
tosUserPhone:this.state.phone,
userStatus: this.state.status ? this.state.status : 1,
tosUserPwd:this.state.newEdit == true ? this.state.pw : null,
tosUserEmail:this.state.email,
tosuserLevel:this.state.level,
tosUserToCompany:this.state.createUser != undefined ? this.state.createUser : this.state.userId,
tosUserServiceCell:this.state.leader,
userLevel: this.state.level,
userLeader: this.state.leader,
oneself: oneself,
/* userAccount: this.state.account,
userID: this.state.id ? this.state.id : null,
userPhone: this.state.phone,
userStatus: this.state.status ? this.state.status : 1,
userPassword: this.state.newEdit == true ? this.state.pw : null,
userEmail: this.state.email,
createUser: this.state.createUser != undefined ? this.state.createUser : this.state.userId,
userLevel: this.state.level,
userLeader: this.state.leader,
oneself: oneself,*/
};
this.props.dispatch({
type: 'accountModel/saveAccount',
payload: params,
callback: (res) => {
console.log(res);
if (res.error_code == "0000") {
alert(res.error_msg);
console.log("data",res.data);
this.importUserDeviceListExcel(res.data.userID);
this.savePermission(res.data.userID); //第三次请求,RPC保存权限表格
} 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("提交失败!");
}
}
});
}
}
}
});
};
//初始化
componentDidMount() {
this.getDevice();
const nowUser = this.props.currentUser.userid;
if (this.props.location.query != null) {
const params = this.props.location.query;
if (params.userID == null || params.userID == '' || params.userID == undefined) {
this.setState({
newEdit: true
})
}
this.setState({
level:params.tosuserLevel,
account: params.tosUserName,
pw: params.userPassword,
id: params.id,
email: params.tosUserEmail,
phone: params.tosUserPhone,
status: params.deleted,
/* level: params.userLevel,
account: params.userAccount,
pw: params.userPassword,
id: params.userID,
email: params.userEmail,
phone: params.userPhone,
status: params.userStatus,*/
userId: nowUser,
createUser: params.createUser,
leader: params.userLeader ? params.userLeader.toString() : params.userLeader,
},() => {
if(this.props.currentUser.userid==this.state.id){
this.setState({
flag: 0,
})
}
});
if (params.id != '' && params.id != null) {
this.getPermission(params.account);
this.getUserDevice(params.account);
}
if (params.userLevel != '' && params.userLevel != null) {
this.getAllLeader(params.userLevel);
}
}
}
//多选框
onChange(checkedValues) {
this.setState({
permission: checkedValues,
});
}
/*--------------------------------------*/
columns = [
{
title: '设备串号',
dataIndex: 'deviceName',
key: 'deviceName',
},
];
//渲染
render() {
const {
adList,defaultLevel,level, phone, email, permission, account, newEdit, deviceList, pw, pw2, flag
} = this.state;
const adSelect = adList.map((item, index) => (
<Select.Option value={index}>{item}</Select.Option>
));
const uploadprops = {
accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
name: 'file',
headers: {
authorization: 'authorization-text',
},
showUploadList: false,
beforeUpload: (file, fileList) => {
const rABS = true;
const f = fileList[0];
const reader = new FileReader();
reader.onload = e => {
let dataResult = e.target.result;
if (!rABS) dataResult = new Uint8Array(dataResult);
const workbook = XLSX.read(dataResult, {
type: rABS ? 'binary' : 'array',
});
const firstWorksheet = workbook.Sheets[workbook.SheetNames[0]];
const jsonArr = XLSX.utils.sheet_to_json(firstWorksheet, {header: 1});
const oldDeviceList = this.state.deviceList;
for (let i = 0; i < jsonArr.length; i++) {
//去重
if (!oldDeviceList.includes(jsonArr[i][0]) && jsonArr[i][0] != '' && jsonArr[i][0] != null && jsonArr[i][0] != undefined) {
oldDeviceList.push(jsonArr[i][0]);
}
}
this.setState({
deviceList: oldDeviceList
})
};
if (rABS) reader.readAsBinaryString(f);
else reader.readAsArrayBuffer(f);
return false;
},
};
return (
<div className={styles.body}>
<div style={{marginTop: 48}}>
<div className={styles.detailsBox}>
<div>
<span className={styles.detailsContent}>账号</span>
{newEdit != true ?
<Input className={styles.input}
value={account}
onChange={(e) => this.accountChange(e)}
disabled
placeholder="请输入账号名"/>:''}
{newEdit == true ?
<Input className={styles.input}
value={account}
onChange={(e) => this.accountChange(e)}
placeholder="请输入账号名"/>:''}
</div>
<div>
{newEdit == true ?
<span className={styles.detailsContent}>密码</span> : ''}
{newEdit == true ?
<div style={{display: "inline-block"}}>
<Input.Password className={styles.input}
onChange={(e) => this.pwChange(e)}
value={pw}
placeholder="请输入密码"/>
<Input.Password className={styles.input}
onChange={(e) => this.pwChange2(e)}
value={pw2}
placeholder="请再次输入密码"/>
</div>
: ''}
</div>
<div>
<span className={styles.detailsContent}>联系方式</span>
<Input className={styles.input} value={phone} onChange={(e) => this.phoneChange(e)}
placeholder="请输入联系电话"/>
<Input className={styles.input} value={email} onChange={(e) => this.emailChange(e)}
placeholder="请输入联系邮箱"/>
</div>
{newEdit != true ?
<div>
<span className={styles.detailsContent}>用户等级:</span>
<Select className={styles.input} disabled placeholder="用户等级" value={defaultLevel} onChange={(e) => this.adChange(e)}
allowClear={true}>{adSelect}</Select>
</div>:''}
{newEdit == true ?
<div>
<span className={styles.detailsContent}>用户等级:</span>
<Select className={styles.input} placeholder="用户等级" value={level} onChange={(e) => this.adChange(e)}
allowClear={true}>{adSelect}</Select>
</div>:''}
<div>
<div style={{marginTop:20}}>
{/*<span className={styles.detailsContent}*/}
{/* style={{position: "relative", marginTop:20,bottom: 250}}>权限配置</span>*/}
{flag == 0?
<div style={{display: "inline-block"}}>
<Checkbox.Group style={{width: '100%'}}
onChange={(e) => this.onChange(e)}
value={permission}>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>我的设备</span>*/}
<Checkbox value="1" disabled>数据中心</Checkbox>
<Checkbox value="2" disabled>查看life用户</Checkbox>
<Checkbox value="3" disabled>编辑life用户</Checkbox>
<Checkbox value="4" disabled>添加业主档案</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>广告推送</span>*/}
<Checkbox value="5" disabled>注销业主档案</Checkbox>
<Checkbox value="6" disabled>查看服务商</Checkbox>
<Checkbox value="7" disabled>编辑服务商</Checkbox>
<Checkbox value="8" disabled>添加服务商</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>警报提醒</span>*/}
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="9" disabled>注销服务商</Checkbox>
<Checkbox value="10" disabled>查看物业费记录</Checkbox>
<Checkbox value="11" disabled>添加物业费记录</Checkbox>
<Checkbox value="12" disabled>查看物业服务</Checkbox>
</div>
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="13" disabled>编辑物业服务</Checkbox>
<Checkbox value="14" disabled>注销物业服务</Checkbox>
<Checkbox value="15" disabled>查看订单</Checkbox>
<Checkbox value="16" disabled>编辑订单</Checkbox>
</div>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>创建后台账号</span>*/}
<Checkbox value="17" disabled>查看合同</Checkbox>
<Checkbox value="18" disabled>编辑合同</Checkbox>
<Checkbox value="19" disabled>添加合同</Checkbox>
<Checkbox value="20" disabled>查看小区</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}
<Checkbox value="21" disabled>编辑小区</Checkbox>
<Checkbox value="22" disabled>添加小区</Checkbox>
<Checkbox value="23" disabled>查看公告</Checkbox>
<Checkbox value="24" disabled>编辑公告</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}
<Checkbox value="25" disabled>添加公告</Checkbox>
<Checkbox value="26" disabled>查看访客记录</Checkbox>
<Checkbox value="27" disabled>查看预定服务</Checkbox>
<Checkbox value="28" disabled>编辑预定服务</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}
<Checkbox value="29" disabled>添加预定服务</Checkbox>
<Checkbox value="30" disabled>查看后台账号</Checkbox>
<Checkbox value="31" disabled>配置后台账号</Checkbox>
</Row>
</Checkbox.Group>
</div>:''}
{flag == 1?
<div style={{display: "inline-block"}}>
<Checkbox.Group style={{width: '100%'}}
onChange={(e) => this.onChange(e)}
value={permission}>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="1" >数据中心</Checkbox>
<Checkbox value="2" >查看life用户</Checkbox>
<Checkbox value="3" >编辑life用户</Checkbox>
<Checkbox value="4" >添加业主档案</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="5" >注销业主档案</Checkbox>
<Checkbox value="6" >查看服务商</Checkbox>
<Checkbox value="7" >编辑服务商</Checkbox>
<Checkbox value="8" >添加服务商</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="9" >注销服务商</Checkbox>
<Checkbox value="10" >查看物业费记录</Checkbox>
<Checkbox value="11" >添加物业费记录</Checkbox>
<Checkbox value="12" >查看物业服务</Checkbox>
</div>
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="13" >编辑物业服务</Checkbox>
<Checkbox value="14" >注销物业服务</Checkbox>
<Checkbox value="15" >查看订单</Checkbox>
<Checkbox value="16" >编辑订单</Checkbox>
</div>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="17" >查看合同</Checkbox>
<Checkbox value="18" >编辑合同</Checkbox>
<Checkbox value="19" >添加合同</Checkbox>
<Checkbox value="20" >查看小区</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="21" >编辑小区</Checkbox>
<Checkbox value="22" >添加小区</Checkbox>
<Checkbox value="23" >查看公告</Checkbox>
<Checkbox value="24" >编辑公告</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="25" >添加公告</Checkbox>
<Checkbox value="26" >查看访客记录</Checkbox>
<Checkbox value="27" >查看预定服务</Checkbox>
<Checkbox value="28" >编辑预定服务</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="29" >添加预定服务</Checkbox>
<Checkbox value="30" >查看后台账号</Checkbox>
<Checkbox value="31" >配置后台账号</Checkbox>
</Row>
</Checkbox.Group>
</div>:''}
</div>
</div>
{/* <div>
<span className={styles.detailsContent}>绑定设备</span>
<div style={{position: "relative", left: 110, bottom: 50}}>
<Input
className={styles.input}
onChange={(e) => this.addDeviceChange(e)}
placeholder="请输入设备串号"/>
<Button className={styles.button1}
onClick={() => this.addToDeviceList()}>添加</Button>
<Upload {...uploadprops}>
<Tooltip title="">
<Button className={styles.button1}
style={{margin: 5, width: 120}}>
<Icon type="upload"/>批量导入
</Button>
</Tooltip>
</Upload>
<br/>
<List
style={{width: 240}}
size="small"
header={<div>设备串号</div>}
bordered
dataSource={deviceList}
renderItem={item => <List.Item>{item}</List.Item>}
/>
</div>
</div>*/}
<div>
{newEdit == false ?
<Button className={styles.button1}
onClick={() => this.onSubmit()}>提交</Button> : ''}
{newEdit == true ?
<Button className={styles.button1}
// onClick={() => this.onGo()}>提交</Button> : ''}
onClick={() => this.onSubmit()}>提交</Button> : ''}
<Button className={styles.button1} onClick={() => this.back()}>返回</Button>
</div>
</div>
</div>
</div>
);
}
}
export default connect(({user}: ConnectState) => ({
currentUser: user.currentUser,
}))(AccountEdit);
import React from 'react';
import {connect,routerRedux} from 'dva';
import {Button, Input} from "antd";
import styles from './style.less';
import {ConnectState} from "@/models/connect";
import {router} from "umi";
class AccountReset extends React.Component {
//构造
constructor(props) {
super(props);
this.state = {
pw: '',
pw2: '',
newPw: '',
}
}
/*----------------- 方法集 ------------------*/
//跳转到账户页面
back = () => {
this.props.dispatch(routerRedux.push({
pathname: '/account',
}))
};
//两次密码校对
checkPw = () => {
if (this.state.pw == '') {
alert("未输入原密码!");
return;
}
if (this.state.pw2 == '') {
alert("未再次输入密码!");
return;
}
if (this.state.pw != this.state.pw2) {
alert("两次输入的原始密码不同!");
return;
} else if (this.state.newPw != ''){
this.checkUserPw();
}else{
alert("未输入新密码!");
return;
}
};
//检测密码
checkUserPw = () => {
const params = {
username: this.props.currentUser.name,
password: this.state.pw,
};
this.props.dispatch({
type: 'user/checkUserPw',
payload: params,
callback: (res) => {
if (res) {
if(res.error_code=="0000"){
this.handleOk();
}else if(res.error_code == "0001"){
alert(res.error_msg);
}else{
alert("密码校验失败!未知错误!")
}
}
}
});
};
handleOk = () => {
const params = {
userStatus: 1,//暂时写死
userID: this.props.currentUser.userid,
userPassword: this.state.newPw,
oneself: 1,
// userAccount: this.props.currentUser.name,
};
this.props.dispatch({
type: 'accountModel/saveAccount',
payload: params,
callback: (res) => {
console.log(res);
if (res.error_code == "0000") {
alert(res.error_msg);
this.back();
} else if (res.error_code == "0001") {
alert(res.error_msg);
this.back();
} 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("提交失败!未知错误!");
}
}
});
};
//密码变更
pwChange = (e) => {
this.setState({pw: e.target.value});
};
//确认密码变更
pwChange2 = (e) => {
this.setState({pw2: e.target.value});
};
//新密码变更
newPwChange = (e) => {
this.setState({newPw: e.target.value});
};
//提交
onSubmit = () => {
this.checkPw();
};
//初始化
componentDidMount() {}
/*--------------------------------------*/
//渲染
render() {
const {} = this.state;
return (
<div className={styles.body}>
<div style={{marginTop: 48}}>
<div className={styles.detailsBox}>
<div>
<span className={styles.detailsContent}>原始密码</span>
<Input.Password className={styles.input}
onChange={(e) => this.pwChange(e)}/>
</div>
<div>
<span className={styles.detailsContent}>新密码</span>
<Input.Password className={styles.input}
onChange={(e) => this.newPwChange(e)}/>
</div>
<div>
<span className={styles.detailsContent}>重复密码</span>
<Input.Password className={styles.input}
onChange={(e) => this.pwChange2(e)}/>
</div>
<div>
<Button className={styles.button1} onClick={() => this.onSubmit()}>提交</Button>
<Button className={styles.button1} onClick={() => this.back()}>返回</Button>
</div>
</div>
</div>
</div>
);
}
}
export default connect(({user}: ConnectState) => ({
currentUser: user.currentUser,
}))(AccountReset);
@import '~antd/lib/style/themes/default.less';
.pre {
margin: 12px 0;
padding: 12px 20px;
background: @input-bg;
box-shadow: @card-shadow;
}
.input {
width:200px;
height:34px;
border:1px solid rgba(229, 229, 229, 1);
border-radius:5px;
margin: 0px 10px;
}
.body {
background:rgba(255,255,255,1);
border:1px solid rgba(229, 229, 229, 1);
}
.inputBox {
width:1250px;
height:50px;
padding-top: 10px;
}
.downIcon {
position: relative;
left: 80px;
}
.downButton {
width:120px;
height:34px;
border:1px solid rgba(229, 229, 229, 1);
border-radius:5px;
margin: 0px 10px;
text-align: left;
}
.button1 {
width:82px;
height:34px;
background:rgba(234,244,255,1);
border:1px solid rgba(178, 215, 255, 1);
font-size:14px;
font-family:PingFang SC;
font-weight:400;
color:rgba(66,159,255,1);
line-height:34px;
margin: 10px 10px;
}
.button2 {
width:82px;
height:34px;
background:rgba(24,144,255,1);
border-radius:4px;
font-size:14px;
font-family:PingFang SC;
font-weight:400;
color:rgba(255,255,255,1);
line-height:34px;
margin: 7px 10px;
}
.button3 {
position: relative;
bottom: 52px;
width:72px;
height:32px;
background:rgba(255,255,255,1);
border:1px solid rgba(229, 229, 229, 1);
border-radius:4px;
margin: 10px 10px;
}
.table {
margin-right: 10px;
}
.detailsTitle {
display: inline-block;
font-size:18px;
font-family:PingFang SC;
font-weight:400;
color:rgba(73,73,73,1);
margin: 0px 30px;
}
.detailsContent {
display: inline-block;
font-size:18px;
width: 100px;
font-family:PingFang SC;
font-weight:400;
color:rgba(153,153,153,1);
margin: 10px 10px;
}
.detailsContent2 {
display: inline-block;
font-size:18px;
width: 200px;
font-family:PingFang SC;
font-weight:400;
color:rgba(51,51,51,1);
}
.detailsBox {
border-top: 1px solid rgba(229, 229, 229, 1);
margin: 10px 30px;
}
.font {
color:rgba(153,153,153,1);
display: block;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
import request from '@/utils/request';
export async function getTosUser(params) {
return request('/tos/owner/getuser', {
method: 'POST',
data: params,
});
}
export async function getOwner(params) {
return request('/tos/tosOwner/getAll', {
method: 'POST',
data: params,
});
}
export async function getOwnerDetail(params) {
return request('/tos/tosOwner/getDetail', {
method: 'POST',
data: params,
});
}
export async function delAdvertisement(params) {
return request('/api/ad/del', {
method: 'POST',
data: params,
});
}
export async function saveAdvertisement(params) {
return request('/api/ad/save', {
method: 'POST',
data: params,
});
}
export async function quitAndUserAd(params) {
return request('/api/ad/quitAndUserAd', {
method: 'POST',
data: params,
});
}
export async function uploadApk(params) {
return request('/api/uploadApk/apk', {
method: 'POST',
data: params,
});
}
export async function checkVideo(params) {
return request('/api/uploadApk/prview', {
method: 'POST',
data: params,
});
}
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