物联网开发完成话机功能

This commit is contained in:
wuxw 2024-06-01 03:08:50 +08:00
parent d7f32d56cf
commit d904280fdf
7 changed files with 214 additions and 79 deletions

20
app.js
View File

@ -40,20 +40,20 @@ let opts = {
}
// todo 测试环境 测试使用生产环境请用nginx带来
app.use('/callComponent', proxy('http://192.168.100.108:8088', opts));
app.use('/app', proxy('http://192.168.100.108:8088', opts));
app.use('/ws', createProxyMiddleware({
target: 'http://192.168.100.108:8008',
changeOrigin: true,
ws: true
}));
// app.use('/callComponent', proxy('http://192.168.100.108:8088', opts));
// app.use('/app', proxy('http://192.168.100.108:8088', opts));
// app.use('/ws', createProxyMiddleware({
// target: 'http://192.168.100.108:8008',
// changeOrigin: true,
// ws: true
// }));
// todo 本机 开发用生产环境请用nginx带来
// app.use('/ws', proxy('http://127.0.0.1:8008', opts));
// app.use('/callComponent', proxy('http://127.0.0.1:8008', opts));
// app.use('/app', proxy('http://127.0.0.1:8008', opts));
app.use('/ws', proxy('http://127.0.0.1:8008', opts));
app.use('/callComponent', proxy('http://127.0.0.1:8008', opts));
app.use('/app', proxy('http://127.0.0.1:8008', opts));
//app.listen(3000);
app.use(express.json());

View File

@ -1,65 +1,79 @@
<div>
<div id="chooseEnterCommunityModel" class="modal fade" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div id="chooseEnterCommunityModel" class="modal fade" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="addPrivilegeModalLabel"><span><vc:i18n name="切换小区" namespace="chooseEnterCommunity"></vc:i18n></span></h3>
<h3 class="modal-title" id="addPrivilegeModalLabel">
<vc:i18n name="切换小区" namespace="chooseEnterCommunity"></vc:i18n>
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p style="color: red;">{{navCommunityInfo.errorInfo}}</p>
<div class="row">
<div class="col-lg-12">
<div class="ibox ">
<div class="row">
<div class="col-sm-7 m-b-xs">
</div>
<div class="col-sm-5">
<div class="input-group">
<input :placeholder="vc.i18n('输入小区名称','chooseEnterCommunity')" v-model="navCommunityInfo.searchCommunityName" type="text" class="form-control form-control-sm">
<span class="input-group-append">
<button type="button" class="btn btn-sm btn-primary"
v-on:click="_queryEnterCommunity()"><span><vc:i18n name="查询" namespace="chooseEnterCommunity"></vc:i18n></span></button>
</span>
</div>
</div>
<div class="ibox ">
<div class="row">
<div class="col-sm-7 m-b-xs">
</div>
<div class="col-sm-5">
<div class="input-group">
<input :placeholder="vc.i18n('输入小区名称','chooseEnterCommunity')"
v-model="navCommunityInfo.searchCommunityName" type="text"
class="form-control form-control-sm">
<span class="input-group-append">
<button type="button" class="btn btn-sm btn-primary"
v-on:click="_queryEnterCommunity()"><span>
<vc:i18n name="查询" namespace="chooseEnterCommunity"></vc:i18n>
</span></button>
</span>
</div>
<div class="table-responsive" style="margin-top:15px">
<table class="table table-striped">
<thead>
<tr>
<th class="text-center"><span><vc:i18n name="小区" namespace="chooseEnterCommunity"></vc:i18n></span>ID</th>
<th data-hide="phone" class="text-center"><span><vc:i18n name="名称" namespace="chooseEnterCommunity"></vc:i18n></span></th>
<th data-hide="phone" class="text-center"><span><vc:i18n name="地址" namespace="chooseEnterCommunity"></vc:i18n></span></th>
<th class="text-center"><span><vc:i18n name="操作" namespace="chooseEnterCommunity"></vc:i18n></span></th>
</tr>
</thead>
<tbody>
<tr v-for="community in navCommunityInfo.communityInfo">
<td class="text-center">
{{community.communityId}}
</td>
<td class="text-center">
{{community.name}}
</td>
<td class="text-center">
{{community.address}}
</td>
<td class="text-center">
<div class="btn-group">
<button class="btn-white btn btn-xs" v-on:click="_chooseCurrentCommunity(community)"><span><vc:i18n name="选择" namespace="chooseEnterCommunity"></vc:i18n></span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<vc:create path="frame/paginationPlus" namespace="chooseEnterCommunity"></vc:create>
</div>
</div>
<div class="table-responsive" style="margin-top:15px">
<table class="table table-striped">
<thead>
<tr>
<th class="text-center">
<vc:i18n name="小区ID" namespace="chooseEnterCommunity"></vc:i18n>
</th>
<th data-hide="phone" class="text-center">
<vc:i18n name="名称" namespace="chooseEnterCommunity"></vc:i18n>
</th>
<th data-hide="phone" class="text-center">
<vc:i18n name="地址" namespace="chooseEnterCommunity"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="操作" namespace="chooseEnterCommunity"></vc:i18n>
</th>
</tr>
</thead>
<tbody>
<tr v-for="community in navCommunityInfo.communityInfo">
<td class="text-center">
{{community.communityId}}
</td>
<td class="text-center">
{{community.name}}
</td>
<td class="text-center">
{{community.address}}
</td>
<td class="text-center">
<div class="btn-group">
<button class="btn-white btn btn-xs"
@click="_chooseCurrentCommunity(community)"><span>
<vc:i18n name="选择" namespace="chooseEnterCommunity"></vc:i18n>
</span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<vc:create path="frame/paginationPlus" namespace="chooseEnterCommunity"></vc:create>
</div>
</div>
</div>

View File

@ -20,8 +20,9 @@
$that.listEnterCommunity(DEFAULT_PAGE, DEFAULT_ROW);
});
vc.on('chooseEnterCommunity', 'paginationPlus', 'page_event', function (_currentPage) {
vc.component.listEnterCommunity(_currentPage, DEFAULT_ROW);
$that.listEnterCommunity(_currentPage, DEFAULT_ROW);
});
},
methods: {
listEnterCommunity: function (_page, _row) {
@ -52,14 +53,12 @@
},
_chooseCurrentCommunity: function (_currentCommunity) {
vc.setCurrentCommunity(_currentCommunity);
//vm.navCommunityInfo._currentCommunity = _currentCommunity;
//中心加载当前页
//location.reload();
vc.jumpToPage("/");
},
_queryEnterCommunity: function () {
$that.listEnterCommunity(DEFAULT_PAGE, DEFAULT_ROW)
}
},
}
});
})(window.vc);

View File

@ -31,14 +31,14 @@
vc.http.apiGet('/sysDocument/querySysDocument',
param,
function (json, res) {
let _sysDocumentManageInfo = JSON.parse(json);
let _total = _sysDocumentManageInfo.total;
let _json = JSON.parse(json);
let _total = _json.total;
if(_total < 1){
return;
}
vc.component.documentInfo.title = _sysDocumentManageInfo.data[0].docTitle;
vc.component.documentInfo.context = _sysDocumentManageInfo.data[0].docContent;
$that.documentInfo.title = _json.data[0].docTitle;
$that.documentInfo.context = _json.data[0].docContent;
}, function (errInfo, error) {
console.log('请求失败处理');
}

View File

@ -4,7 +4,7 @@
<div class="modal-content">
<div class="modal-body">
<div class="row margin-bottom">
<div class="col-sm-3"></div>
<div class="col-sm-2"></div>
<div class="col-sm-6 padding-lr-0">
<input class="form-control" placeholder="请输入房屋编号,业主名称,车辆编号或者家庭成员名称等"
v-model="searchCommunityDataInfo.searchValue" @keyup.enter="_doSearchCommunityData()" />
@ -14,6 +14,11 @@
<vc:i18n name="查询" namespace="simplifyAcceptance"></vc:i18n>
</button>
</div>
<div class="col-sm-2 padding-lr-0 margin-left-xs">
<button type="button" class="form-control btn btn-white" @click="_queryCallInTel()">
<vc:i18n name="通话中号码" namespace="simplifyAcceptance"></vc:i18n>
</button>
</div>
</div>
<div class="vc-line-primary"></div>
<div class="margin-top margin-bottom" style="min-height: 200px;">

View File

@ -13,17 +13,22 @@
repairs: [],
visits: [],
staffs: [],
noData: true
noData: true,
machine:{},
ws:{}
},
},
_initMethod: function () {
$that._initTelMachine();
},
_initEvent: function () {
vc.on('searchCommunityDataModel', '_loadData', function (_param) {
$that._clearSearchCommunityData();
//$('#searchCommunityDataModel').modal('show');
});
vc.on('searchCommunityDataModel', 'sendTelMsg',function(_data){
$that.searchCommunityDataInfo.ws.send(_data);
});
},
methods: {
_doSearchCommunityData: function () {
@ -80,6 +85,9 @@
window.open('/#/pages/property/simplifyAcceptance?tab=业务受理');
},
_clearSearchCommunityData: function () {
let _ws = $that.searchCommunityDataInfo.ws;
let _machine = $that.searchCommunityDataInfo.machine;
$that.searchCommunityDataInfo = {
searchValue: '',
noData: true,
@ -92,8 +100,117 @@
repairs: [],
visits: [],
staffs: [],
machine:_machine,
ws:_ws
};
}
},
_initTelMachine: function (_page, _row) {
let param = {
params: {
page: 1,
row: 1,
communityId: vc.getCurrentCommunity().communityId,
iotApiCode:'queryTelMachineBmoImpl'
}
};
vc.http.apiGet('/iot.getOpenApi',
param,
function (json, res) {
let _json = JSON.parse(json);
if (_json.code != 0 || _json.data.length <1) {
return;
}
let _data = _json.data[0];
$that.searchCommunityDataInfo.machine = _data;
$that._connectTelMachine(_data);
}, function () {
console.log('请求失败处理');
}
);
},
_queryCallInTel:function(){
let _ws = $that.searchCommunityDataInfo.ws;
if(!_ws){
vc.toast('未连接固定电话');
return ;
}
$that.searchCommunityDataInfo.ws.send(
JSON.stringify({
action: 'Query',
type: 'Device',
cb: 'cb_data'
})
);
},
_connectTelMachine:function(_machine){
let _protocol = window.location.protocol;
let url = "ws://";
if (_protocol.startsWith('https')) {
url = "wss://";
}
url = url+ _machine.machineIp+":"+_machine.machinePort+"/APP_2AD85C71-BEF8-463C-9B4B-B672F603542A_fast";
let ws = new WebSocket(url);
ws.onerror = function (event) {
console.log('消息', event.data);
setTimeout(function(){
$that._connectTelMachine(_machine);
},2)
};
ws.onclose = function (event) { //断开连接函数
};
//与WebSocket建立连接
ws.onopen = function (event) { //连接成功函数
};
ws.onmessage = function (data) {
console.log(data.data);
data = JSON.parse(data.data);
if (data.message == 'query') { //主动查询时的返回
if (data.name == 'Device' && data.param.CallerId) {
$that._clearSearchCommunityData();
$that.searchCommunityDataInfo.searchValue = data.param.CallerId;
$that._doSearchCommunityData();
return;
}
if (data.name == 'Device' && data.param.hasOwnProperty('CallerId')) {
vc.toast('座机未返回通话中号码');
return;
}
return;
}
let param = data.param;
if(param && param.status == 'CallIn'){
$that._clearSearchCommunityData();
$that.searchCommunityDataInfo.searchValue = param.number;
$('#searchCommunityDataModel').modal('show');
$that._doSearchCommunityData();
return;
}
$that._saveTelMachineMsg(data);
}
$that.searchCommunityDataInfo.ws = ws;
},
_saveTelMachineMsg: function (_data) {
_data.iotApiCode='telMachineMsgBmoImpl';
_data.communityId = vc.getCurrentCommunity().communityId;
_data.machineId = $that.searchCommunityDataInfo.machine.machineId;
vc.http.apiPost('/iot.postOpenApi',
_data,
function (json, res) {
let _json = JSON.parse(json);
if (_json.code != 0 ) {
console.log('同步座机信息失败',_data.msg)
return;
}
}, function () {
console.log('请求失败处理');
}
);
},
}
});

View File

@ -20,14 +20,14 @@
},
methods: {
textOrgName: function() {
var _tmpOrgLevel = vc.component.viewDataInfo.orgLevel;
var _tmpOrgLevel = $that.viewDataInfo.orgLevel;
var param = {
params: {
page: 1,
row: 30,
orgLevel: _tmpOrgLevel,
parentOrgId: vc.component.viewDataInfo.parentOrgId,
orgName: vc.component.viewDataInfo.orgName
parentOrgId: $that.viewDataInfo.parentOrgId,
orgName: $that.viewDataInfo.orgName
}
};
//发送get请求
@ -38,16 +38,16 @@
if (_tmpOrgLevel == 2) {
if (arr.length > 0) {
vc.toast("公司名重复");
vc.component.flagOrgName = true
$that.flagOrgName = true
} else {
vc.component.flagOrgName = false
$that.flagOrgName = false
}
} else if (_tmpOrgLevel == 3) {
if (arr.length > 0) {
vc.toast("组织名称重复");
vc.component.flagOrgName = true
$that.flagOrgName = true
} else {
vc.component.flagOrgName = false
$that.flagOrgName = false
}
}
},