This commit is contained in:
Jay 2017-04-06 17:31:36 +08:00
parent e18fa6546b
commit b8ccbe4cd3
11 changed files with 340 additions and 32 deletions

View File

@ -60,6 +60,7 @@
"ERR0058": "timezone輸入錯誤",
"ERR0059": "timezone設定失敗",
"ERR0060": "手環ID輸入錯誤",
"ERR0061": "手環ID已存在",
"ERR7000": "命令執行失敗",

View File

@ -84787,10 +84787,10 @@ var IOPanel = function (_React$Component) {
_react2.default.createElement(
_semanticUiReact.Menu,
{ attached: 'top', tabular: true },
_react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'DigitOutput', name: '1', active: this.state.tabIdx == "1", onClick: this.tabItemClick }),
_react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'DigitInput', name: '2', active: this.state.tabIdx == "2", onClick: this.tabItemClick }),
_react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'AnalogyOutput', name: '3', active: this.state.tabIdx == "3", onClick: this.tabItemClick }),
_react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'AnalogyInput', name: '4', active: this.state.tabIdx == "4", onClick: this.tabItemClick }),
_react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'DigitalOutput', name: '1', active: this.state.tabIdx == "1", onClick: this.tabItemClick }),
_react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'DigitalInput', name: '2', active: this.state.tabIdx == "2", onClick: this.tabItemClick }),
_react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'AnalogOutput', name: '3', active: this.state.tabIdx == "3", onClick: this.tabItemClick }),
_react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'AnalogInput', name: '4', active: this.state.tabIdx == "4", onClick: this.tabItemClick }),
_react2.default.createElement(
_semanticUiReact.Menu.Menu,
{ position: 'right' },
@ -87814,7 +87814,7 @@ var ListItem = function ListItem(_ref) {
_react2.default.createElement(
_semanticUiReact.Table.Cell,
null,
data.mac
data.wristband
),
_react2.default.createElement(
_semanticUiReact.Table.Cell,
@ -88143,6 +88143,10 @@ var _WristbandInfo = __webpack_require__(1141);
var _WristbandInfo2 = _interopRequireDefault(_WristbandInfo);
var _Location = __webpack_require__(1145);
var _Location2 = _interopRequireDefault(_Location);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@ -88179,6 +88183,8 @@ var WristbandPage = function (_React$Component) {
return _react2.default.createElement(_LocStatus2.default, null);
case 'wristband':
return _react2.default.createElement(_WristbandInfo2.default, null);
case 'location':
return _react2.default.createElement(_Location2.default, null);
default:
return null;
}
@ -88222,6 +88228,13 @@ var WristbandPage = function (_React$Component) {
} },
'\u624B\u74B0\u540D\u7A31\u8A2D\u5B9A'
),
_react2.default.createElement(
_semanticUiReact.Menu.Item,
{ active: this.state.page == 'location', onClick: function onClick() {
_this2.changePage('location');
} },
'\u5B9A\u4F4D\u9EDE\u8A2D\u5B9A'
),
_react2.default.createElement(
_semanticUiReact.Menu.Item,
{ active: this.state.page == 'locstatus', onClick: function onClick() {
@ -92941,10 +92954,11 @@ var WristbandInfo = function (_React$Component) {
showDialog = _this$props.showDialog,
toggleLoading = _this$props.toggleLoading;
toggleLoading(1);
fetch('/api/wristband/getwristbandlist', (0, _actions.getRequest)()).then(function (response) {
return response.json();
}).then(function (json) {
toggleLoading(0);
if (json.status != 1) return showDialog(json.message);
_this.setState({
list: json.data.record || []
@ -93041,6 +93055,26 @@ var WristbandInfo = function (_React$Component) {
_semanticUiReact.Table.HeaderCell,
null,
'\u624B\u74B0\u540D\u7A31'
),
_react2.default.createElement(
_semanticUiReact.Table.HeaderCell,
null,
'\u8EAB\u4EFD'
),
_react2.default.createElement(
_semanticUiReact.Table.HeaderCell,
null,
'\u76E3\u63A7'
),
_react2.default.createElement(
_semanticUiReact.Table.HeaderCell,
null,
'\u901A\u77E5'
),
_react2.default.createElement(
_semanticUiReact.Table.HeaderCell,
null,
'\u555F\u7528'
)
)
),
@ -93158,6 +93192,26 @@ var ListItem = function ListItem(_ref) {
_semanticUiReact.Table.Cell,
null,
data.name
),
_react2.default.createElement(
_semanticUiReact.Table.Cell,
null,
data.identity
),
_react2.default.createElement(
_semanticUiReact.Table.Cell,
null,
data.monitor == 1 ? '啟用' : '停用'
),
_react2.default.createElement(
_semanticUiReact.Table.Cell,
null,
data.notify == 1 ? '啟用' : '停用'
),
_react2.default.createElement(
_semanticUiReact.Table.Cell,
null,
data.switch == 1 ? '啟用' : '停用'
)
);
};
@ -93279,5 +93333,147 @@ var WristbandModal = function WristbandModal(_ref) {
};
exports.default = WristbandModal;
/***/ }),
/* 1144 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = __webpack_require__(0);
var _react2 = _interopRequireDefault(_react);
var _semanticUiReact = __webpack_require__(8);
var _actions = __webpack_require__(22);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var stateDefault = function stateDefault() {
return {
list: [],
modal: {
open: false,
type: 0,
data: {}
}
};
};
var Location = function (_React$Component) {
_inherits(Location, _React$Component);
function Location() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, Location);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Location.__proto__ || Object.getPrototypeOf(Location)).call.apply(_ref, [this].concat(args))), _this), _this.state = _extends({}, stateDefault()), _this.getList = function () {
var _this$props = _this.props,
showDialog = _this$props.showDialog,
toggleLoading = _this$props.toggleLoading;
toggleLoading(1);
fetch('/api/wristband/getlocationlist', (0, _actions.getRequest)()).then(function (response) {
return response.json();
}).then(function (json) {
toggleLoading(0);
if (json.status != 1) return showDialog(json.message);
_this.setState({
list: json.data.record || []
});
});
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(Location, [{
key: 'componentDidMount',
value: function componentDidMount() {
this.getList();
}
}, {
key: 'render',
value: function render() {
return _react2.default.createElement(
_semanticUiReact.Container,
{ fluid: true },
_react2.default.createElement(
_semanticUiReact.Segment,
{ className: 'clearfix' },
_react2.default.createElement(_semanticUiReact.Button, { floated: 'right', basic: true, color: 'green', style: { marginBottom: '15px' }, content: '\u65B0\u589E', icon: 'plus' })
)
);
}
}]);
return Location;
}(_react2.default.Component);
exports.default = Location;
/***/ }),
/* 1145 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _reactRedux = __webpack_require__(25);
var _actions = __webpack_require__(22);
var _Location = __webpack_require__(1144);
var _Location2 = _interopRequireDefault(_Location);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var mapStateToProps = function mapStateToProps(state) {
return {
i18n: state.i18n
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
showDialog: function showDialog(msg) {
dispatch((0, _actions.add_dialog_msg)(msg));
},
toggleLoading: function toggleLoading() {
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
dispatch((0, _actions.toggle_loading)(flag));
}
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_Location2.default);
/***/ })
/******/ ]);

View File

@ -344,8 +344,8 @@
"porttype": [
{ "code": "1", "name": "DigitalOutput" },
{ "code": "2", "name": "DigitalInput" },
{ "code": "3", "name": "AnalogyOutput" },
{ "code": "4", "name": "AnalogyInput" }
{ "code": "3", "name": "AnalogOutput" },
{ "code": "4", "name": "AnalogInput" }
],
"select": {
"select_action": "請選擇動作",

View File

@ -128,7 +128,7 @@ router
.post('/getstatus', (req, res, n) => {
if (!config.permission.wristband) return n('ERR9000');
let query = "select w.`name`, coalesce(l.`name`, l2.`name`) as locname, ll.*\
let query = "select w.`name`, w.`mac` as wristband, coalesce(l.`name`, l2.`name`) as locname, ll.*\
from ??.?? w\
left join ( \
select * from ( \
@ -145,7 +145,8 @@ router
left join ??.?? l2\
on \
l2.`serialnumber` = ll.`devid` \
";
where \
w.`switch` = 1 ";
let param = [config.db.db9, 'wristband', config.db.db9, 'rawdata', config.db.db9, 'lastdata', config.db.db9, 'location', config.db.db9, 'location', ];
let sortfield = '';
@ -233,25 +234,32 @@ router
if (!arr.data) return n('ERR0000')
if (!arr.data.mac) return n('ERR0060');
let name = arr.data.name || '';
let identity = arr.data.identity || 0;
let monitor = arr.data.monitor || 0;
let notify = arr.data.notify || 0;
let sw = arr.data.switch || 0;
let query = "insert into ??.?? (`mac`, `name`, `identity`, `monitor`, `notify`, `switch`, `ctime`, `mtime`) values \
( ?, ?, ?, ?, ?, ?, unix_timestamp(), unix_timestamp() )";
let param = [config.db.db9, 'wristband', arr.data.mac, name, identity, monitor, notify, sw];
let query = "select count(*) as c from ??.?? where `mac` = ?";
let param = [config.db.db9, 'wristband', arr.data.mac];
res.db.query(query, param, (err, row) => {
if (err) return rt.err(res, err, n, 'ERR8001');
if (err || row.length == 0) return rt.err(res, err, n, "ERR8000");
if (row[0].c > 0) return n("ERR0061");
res.api_res = {
record: []
};
n();
});
let name = arr.data.name || '';
let identity = arr.data.identity || 0;
let monitor = arr.data.monitor || 0;
let notify = arr.data.notify || 0;
let sw = arr.data.switch || 0;
let query = "insert into ??.?? (`mac`, `name`, `identity`, `monitor`, `notify`, `switch`, `ctime`, `mtime`) values \
( ?, ?, ?, ?, ?, ?, unix_timestamp(), unix_timestamp() )";
let param = [config.db.db9, 'wristband', arr.data.mac, name, identity, monitor, notify, sw];
res.db.query(query, param, (err, row) => {
if (err) return rt.err(res, err, n, 'ERR8001');
res.api_res = {
record: []
};
n();
});
})
})
.post('/editwristband', (req, res, n) => {
if (!config.permission.wristband) return n('ERR9000');
@ -285,6 +293,25 @@ router
n();
})
})
.post('/getlocationlist', (req, res, n) => {
if (!config.permission.wristband) return n('ERR9000');
let query = "select * from ??.??";
let param = [config.db.db9, 'location'];
res.db.query(query, param, (err, row) => {
if (err) return rt.err(res, err, n, "ERR8000");
res.api_res = {
record: tool.checkArray(row)
}
n();
});
})
.post('/addlocation', (req, res, n) => {
if (!config.permission.wristband) return n('ERR9000');
if (!tool.checkPermission(req)) return n('ERR9000');
})
.all('*', rt.send);
module.exports = router;

View File

@ -41,10 +41,10 @@ class IOPanel extends React.Component {
return (
<div>
<Menu attached="top" tabular>
<Menu.Item content="DigitOutput" name="1" active={this.state.tabIdx == "1"} onClick={this.tabItemClick} />
<Menu.Item content="DigitInput" name="2" active={this.state.tabIdx == "2"} onClick={this.tabItemClick} />
<Menu.Item content="AnalogyOutput" name="3" active={this.state.tabIdx == "3"} onClick={this.tabItemClick} />
<Menu.Item content="AnalogyInput" name="4" active={this.state.tabIdx == "4"} onClick={this.tabItemClick} />
<Menu.Item content="DigitalOutput" name="1" active={this.state.tabIdx == "1"} onClick={this.tabItemClick} />
<Menu.Item content="DigitalInput" name="2" active={this.state.tabIdx == "2"} onClick={this.tabItemClick} />
<Menu.Item content="AnalogOutput" name="3" active={this.state.tabIdx == "3"} onClick={this.tabItemClick} />
<Menu.Item content="AnalogInput" name="4" active={this.state.tabIdx == "4"} onClick={this.tabItemClick} />
<Menu.Menu position="right">
<Menu.Item content="AddIO" icon="plus" onClick={()=>{ioModal(0)}}/>
</Menu.Menu>

View File

@ -6,7 +6,7 @@ const ListItem = ({i18n, data}) => {
return (
<Table.Row>
<Table.Cell>{data.mac}</Table.Cell>
<Table.Cell>{data.wristband}</Table.Cell>
<Table.Cell>{data.locname}</Table.Cell>
<Table.Cell>{data.val3 ? parseInt(data.val3, 16) : ''}</Table.Cell>
<Table.Cell>{data.val4 ? `${parseInt(data.val4, 16)}%` : ''}</Table.Cell>

View File

@ -0,0 +1,50 @@
import React from 'react';
import {Container, Segment, Button} from 'semantic-ui-react';
import {getRequest} from '../../../../actions';
const stateDefault = ()=>({
list: [],
modal: {
open: false,
type: 0,
data: {}
}
})
class Location extends React.Component {
state = {
...stateDefault()
}
componentDidMount() {
this.getList();
}
getList = () => {
let {showDialog, toggleLoading} = this.props;
toggleLoading(1);
fetch('/api/wristband/getlocationlist', getRequest())
.then(response=>response.json())
.then(json => {
toggleLoading(0);
if(json.status != 1) return showDialog(json.message);
this.setState({
list: json.data.record || []
})
})
}
render() {
return (
<Container fluid>
<Segment className="clearfix">
<Button floated="right" basic color="green" style={{marginBottom: '15px'}} content="新增" icon="plus" />
</Segment>
</Container>
)
}
}
export default Location;

View File

@ -11,6 +11,10 @@ const ListItem = ({ i18n, data, delWristband, editWristband }) => {
</Table.Cell>
<Table.Cell>{data.mac}</Table.Cell>
<Table.Cell>{data.name}</Table.Cell>
<Table.Cell>{data.identity}</Table.Cell>
<Table.Cell>{data.monitor == 1 ? '啟用' : '停用'}</Table.Cell>
<Table.Cell>{data.notify == 1 ? '啟用' : '停用'}</Table.Cell>
<Table.Cell>{data.switch == 1 ? '啟用' : '停用'}</Table.Cell>
</Table.Row>
)
}

View File

@ -24,10 +24,11 @@ class WristbandInfo extends React.Component {
getList = () => {
let {showDialog, toggleLoading} = this.props;
toggleLoading(1);
fetch('/api/wristband/getwristbandlist', getRequest())
.then(response=>response.json())
.then(json =>{
toggleLoading(0);
if(json.status != 1) return showDialog(json.message);
this.setState({
list: json.data.record || []
@ -95,6 +96,10 @@ class WristbandInfo extends React.Component {
<Table.HeaderCell>操作</Table.HeaderCell>
<Table.HeaderCell>手環ID</Table.HeaderCell>
<Table.HeaderCell>手環名稱</Table.HeaderCell>
<Table.HeaderCell>身份</Table.HeaderCell>
<Table.HeaderCell>監控</Table.HeaderCell>
<Table.HeaderCell>通知</Table.HeaderCell>
<Table.HeaderCell>啟用</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>

View File

@ -2,6 +2,7 @@ import React from 'react';
import {Grid, Container, Segment, Menu, List} from 'semantic-ui-react';
import LocStatus from '../../../containers/AdminPage/Wristband/LocStatus';
import WristbandInfo from '../../../containers/AdminPage/Wristband/WristbandInfo';
import Location from '../../../containers/AdminPage/Wristband/Location';
class WristbandPage extends React.Component{
state = {
@ -20,7 +21,9 @@ class WristbandPage extends React.Component{
case 'locstatus':
return <LocStatus/>;
case 'wristband':
return <WristbandInfo />
return <WristbandInfo />;
case 'location':
return <Location />
default:
return null;
}
@ -39,6 +42,9 @@ class WristbandPage extends React.Component{
<Menu.Item active={this.state.page == 'wristband'} onClick={()=>{this.changePage('wristband')}}>
手環名稱設定
</Menu.Item>
<Menu.Item active={this.state.page == 'location'} onClick={()=>{this.changePage('location')}}>
定位點設定
</Menu.Item>
<Menu.Item active={this.state.page == 'locstatus'} onClick={()=>{ this.changePage('locstatus'); }}>
位置資訊
</Menu.Item>

View File

@ -0,0 +1,19 @@
import { connect } from 'react-redux';
import { add_dialog_msg, toggle_loading } from '../../../actions';
import LocationPage from '../../../components/AdminPage/Wristband/Location';
const mapStateToProps = (state) => ({
i18n: state.i18n
});
const mapDispatchToProps = (dispatch, ownProps) => ({
showDialog: (msg) => {
dispatch(add_dialog_msg(msg));
},
toggleLoading: (flag = false) => {
dispatch(toggle_loading(flag));
}
})
export default connect(mapStateToProps, mapDispatchToProps)(LocationPage);