SceneSrmMobile.js
4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import React from 'react';
import { Grid, Toast } from 'antd-mobile-v2';
import 'antd-mobile-v2/dist/antd-mobile.css';
import styles from './SceneMobile.less';
// eslint-disable-next-line import/first
import { createForm } from 'rc-form';
import commonConfig from '../../utils/config';
import * as commonServices from '../../services/services';
import * as commonUtils from '../../utils/utils';
import CommobileBase from './CommobileBase';
import CommobileBillEvent from './CommobileBillEvent';
class SceneSrmMobile extends React.Component {
constructor(props) {
super(props);
this.state = {
totalData: [],
};
}
async componentWillMount() {
const masterConfig = {};
const masterData = [];
this.props.onSaveState({ masterConfig, masterData });
/* 获取配置 */
let { sModelType } = this.props;
sModelType = commonUtils.isEmptyObject(sModelType) ? 'scene' : sModelType;
const { token } = this.props.app;
const sLoginType = 'sLoginSrm';
const configUrl = `${commonConfig.server_host}mobilephone/getMenuSrmCss/${sModelType}/${sLoginType}?sModelsId=100`;
const configReturn = (await commonServices.getService(token, configUrl)).data;
if (configReturn.code === 1) {
const returnData = configReturn.dataset.rows;/* 全部数据 */
if (commonUtils.isNotEmptyArr(returnData)) {
this.setState({ totalData: returnData });
}
} else {
Toast.success(configReturn.msg);
}
}
handleGetAllMenuData = () => {
const { totalData } = this.state;
const { token } = this.props.app;
if (commonUtils.isNotEmptyArr(totalData)) {
return totalData.map((item) => {
const firstMenu = {};
firstMenu.bUnReason = item.bUnReason;
firstMenu.bUnTask = item.bUnTask;
firstMenu.bVisible = item.bVisible;
firstMenu.children = item.children;
firstMenu.iOrder = item.iOrder;
firstMenu.sChinese = item.sChinese;
firstMenu.sMenuName = item.sMenuName;
firstMenu.sId = item.sId;
firstMenu.sModelType = item.sModelType;
firstMenu.sName = item.sName;
firstMenu.sParentId = item.sParentId;
firstMenu.sProcName = item.sProcName;
firstMenu.sTitleLogoPath = item.sTitleLogoPath;
firstMenu.sUnType = item.sUnType;
const childrenData = item.children;
const gridData = [];
if (commonUtils.isNotEmptyArr(childrenData)) {
childrenData.forEach((itemChild) => {
const addStata = {};
const dataUrl = `${commonConfig.file_host}file/download?savePathStr=${itemChild.sTitleLogoPath}&sModelsId=100&token=${token}`;
addStata.icon = dataUrl;
addStata.text = itemChild.sMenuName;
addStata.url = itemChild.sName.replace('indexMobile', 'indexSrmMobile');
addStata.sModelsId = itemChild.sId;
addStata.sModelType = itemChild.sModelType;
addStata.iOrder = itemChild.iOrder;
gridData.push(addStata);
});
}
gridData.sort((item, item2) => item.iOrder - item2.iOrder);
return (
<div className="GridContent">
<div className={styles.SubTitle}>{firstMenu.sMenuName}</div>
<Grid data={gridData} hasLine={false} onClick={this.handleGridClick} />
</div>
);
});
}
}
handleGridClick = (el) => {
const { dispatch } = this.props;
const { url } = el;/* 菜单对应的路由地址1 */
if (url !== '') {
const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${el.sModelsId}?sModelsId=${el.sModelsId}`;
dispatch({
type: 'content/onRouterMobile',
payload: {
url, /* 接口地址 */
urlKey: sNameUrl,
sModelsId: el.sModelsId,
sModelType: el.sModelType,
},
});
}
}
/** 修改主表数据 */
handleMasterChange = async (name, sFieldName, changeValue, sId, dropDownData, isWait, masterDataNew) => {
if (sFieldName === 'sMachineId') {
const { dispatch } = this.props;
const returnData = await this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true, masterDataNew);
dispatch({
type: 'app/saveMachineId',
payload: { sMachineId: returnData.masterData.sMachineId },
});
this.props.onSaveState({ ...returnData });
} else {
this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, isWait, masterDataNew);
}
}
render() {
return (
<div>
{this.handleGetAllMenuData()}
</div>
);
}
}
const SceneMobileComponent = createForm()(SceneSrmMobile);
export default CommobileBase(CommobileBillEvent(SceneMobileComponent));