'use strict';
app.controller('recordCtrl', ["$scope", "i18nService", "$rootScope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_data", "api_text", "api_user_data", function($scope, i18nService, $rootScope, $state, $timeout, $interval, $modal, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_data, api_text, api_user_data) {
$scope.langs = i18nService.getAllLangs();
$scope.lang = 'zh-cn';
i18nService.setCurrentLang($scope.lang);
// $(window).resize(function() {
// // console.log("1111")
// });
var loginUser = $rootScope.user;
// var voiceurl=$rootScope.audioiIp;
// delete $rootScope.user.authority;
var pdKey = $state.current.pdKey;
$scope.gridOptions = {};
$scope.gridOptions.data = 'myData';
$scope.gridOptions.enableColumnResizing = true;
$scope.gridOptions.enableFiltering = false;
$scope.gridOptions.enableGridMenu = true;
$scope.gridOptions.enableRowSelection = true;
$scope.gridOptions.showGridFooter = true;
$scope.gridOptions.showColumnFooter = false;
$scope.gridOptions.fastWatch = true;
// $scope.gridOptions.useExternalFiltering=true;
$scope.gridOptions.useExternalPagination = true;
$scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
$scope.gridOptions.paginationPageSize = 10;
$scope.gridOptions.multiSelect = true;
var mun = $scope.gridOptions.paginationPageSize;
// $scope.gridOptions.rowTemplate = "
";
$scope.gridOptions.rowIdentity = function(row) {
return row.id;
};
$scope.gridOptions.getRowIdentity = function(row) {
return row.id;
};
$scope.transferstate = function(item) {
// var handstate = "未受理";
if (item.isExcute==1) {
return "已受理";
}else if(item.isExcute==2){
return "不受理";
}else{
return "未受理";
}
}
$scope.bushouli=function(item){
// console.log(item)
SweetAlert.swal({
title: "确认不受理?",
text: "确认不受理后,将无法转换为事件工单!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "确定",
cancelButtonText: "取消",
closeOnConfirm: false,
closeOnCancel: false
}, function (isConfirm) {
if (isConfirm) {
item.isExcute=2;
delete item.item;
api_bpm_data.updData("hjzxRecord",{"hjzxRecord":item}).then(function(res){
if(res.status==200){
SweetAlert.swal({
title: "操作成功!",
type: "success",
confirmButtonColor: "#007AFF"
}, function() {
$scope.refreshData('expand-right', $scope.filData);
});
}else{
SweetAlert.swal({
title: "系统错误",
text: "系统错误,请稍后重试!",
type: "error",
confirmButtonColor: "#DD6B55"
});
}
})
} else {
SweetAlert.swal("操作取消", "数据安全", "error");
}
});
}
$scope.transfersucc = function(item) {
var handstate = "有效";
if (item.isValid) { //未处理
handstate = "无效";
}
return handstate;
}
$scope.transferTime = function(time) {
return moment(time).format('YYYY-MM-DD HH:mm');
}
$scope.gridOptions.columnDefs = [{
name: 'item',
displayName: '序号',
width: 50,
cellTemplate: '' +
'
{{row.entity.item}}
' +
'
'
},
{
name: 'recTime',
displayName: '留言时间',
width: '23%',
cellTemplate: '' +
'
{{grid.appScope.transferTime(row.entity.recTime)}}
' +
'
'
},
{
name: 'ano',
displayName: '来电号码',
width: '20%',
cellTemplate: '' +
'
{{row.entity.ano}}
' +
'
'
},
// {
// name: 'isValid',
// displayName: '有效状态',
// width: '10%',
// cellTemplate: '' +
// '
{{grid.appScope.transfersucc(row.entity)}}
' +
// '
'
// },
{
name: 'isExcute',
displayName: '处理状态',
width: '13%',
cellTemplate: '' +
'
{{grid.appScope.transferstate(row.entity)}}
'
},
{ name: '操作', cellTemplate: '
' }
];
$scope.value = 10;
$scope.decrement = function() {
$scope.value = $scope.value - 1;
};
$scope.gridOptions.onRegisterApi = function(gridApi) {
$scope.gridApi = gridApi;
gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
var filtersData = $scope.memoryfilterData;
filtersData.idx = newPage - 1;
filtersData.sum = pageSize;
$scope.refreshData('expand-right', filtersData);
});
$scope.selected = {
items: []
}
};
$scope.memoryfilterData = defaultFilterData = {
"idx": 0,
"sum": mun
};
/*--------- new incident --------- */
$scope.selectRowFunction = function(recorddata) {
var filterData = { "idx": 0, "sum": 10, "requester": { "mphone": recorddata.ano, "telephone": recorddata.ano, "selectType": 1 } }
api_user_data.fetchDataList('requester', filterData).then(function(data) {
var myData = Restangular.stripRestangular(data);
// $rootScope.phone="";
$rootScope.setbusy();
if (myData.list.length == 0) {
var modalInstance = $modal.open({
templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
controller: function($scope, $modalInstance, api_user_data) {
$scope.title = "新增报修人";
$scope.requester = {};
$scope.onChangeadd = function(searchData) {
$scope.searchKey = searchData.account;
var requesdata = angular.copy(searchData)
if (requesdata.telephone) {
delete requesdata.telephone;
}
angular.extend($scope.requester, requesdata);
}
$scope.refreshUseradd = function(searchKey) { //请求人搜索
$scope.requester.account = searchKey;
$scope.searchData = searchKey;
serchdataadd(searchKey);
}
$scope.getMydata = function(x) {
var reqestdatap = JSON.parse(x[0])
if ($scope.requester.telephone) {
delete reqestdatap.telephone;
}
$scope.searchField = JSON.parse(x[0]).account;
angular.extend($scope.requester, reqestdatap);
}
$scope.getMydataone = function(x) {
$scope.searchField = x;
$scope.requester.account = x;
}
serchdataadd();
function serchdataadd(searchKey) {
if (searchKey) {
var filterData = {
'requester': {
'searchKey': searchKey,
},
idx: 0,
sum: 10
};
} else {
var filterData = {
idx: 0,
sum: 10
};
}
api_user_data.fetchDataList('requester', filterData).then(function(response) {
var myData = response;
$scope.myData = myData.list;
});
}
$scope.requester = { 'telephone': recorddata.ano };
$scope.ok = function() {
$modalInstance.close($scope.requester);
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
},
});
modalInstance.result.then(function(selectedItem) {
if (selectedItem) {
if (selectedItem.telephone && !selectedItem.mphone) {
selectedItem.telephone = angular.copy(selectedItem.mphone);
delete selectedItem.mphone;
}
var data = {
'requester': selectedItem
};
api_user_data.addData('requester', data).then(function(response) {
if (response.status == 200) {
var data = { 'model': { 'requestershow': response.data, 'recordId': recorddata.id, 'incident': { 'requester': response.data, 'area': response.areaDTO, 'place': response.placeDTO, 'houseNumber': response.houseNumber, 'source': { 'id': 1548 } } } }
$state.go('app.incident.title', { 'model': JSON.stringify(data) });
}
})
}
});
} else if (myData.list.length == 1) {
var data = { 'model': { 'requestershow': myData.list[0], 'recordId': recorddata.id, 'incident': { 'requester': myData.list[0], 'area': myData.list[0].areaDTO, 'place': myData.list[0].placeDTO, 'houseNumber': myData.list[0].houseNumber, 'source': { 'id': 1548 } } } }
$state.go('app.incident.title', { 'model': JSON.stringify(data) });
} else {
var modalInstance = $modal.open({
templateUrl: 'assets/views/createincident.html',
controller: function($scope, datas, $modalInstance, api_user_data) {
$scope.title = "请确定报修人";
$scope.requester = myData.list;
$scope.choice = function(requester) {
$modalInstance.dismiss('cancel');
var data = { 'model': { 'requestershow': requester, 'recordId': recorddata.id, 'incident': { 'requester': requester, 'area': requester.areaDTO, 'place': requester.placeDTO, 'houseNumber': requester.houseNumber, 'source': { 'id': 1548 } } } }
$state.go('app.incident.title', { 'model': JSON.stringify(data) });
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
},
resolve: {
datas: function() {
return recorddata;
}
},
size: "lg"
});
}
});
// var formdata = {
// 'model': {
// 'incident': {
// 'source': { 'id': 1 },
// },
// 'recordId': data.id
// }
// }
// $state.go('app.incident.chart', { 'model': JSON.stringify(formdata) });
};
/*--------- Recordings --------- */
// $scope.recordcall = function(data) {
// $scope.oldRecord(data);
// var modalInstance = $modal.open({
// templateUrl: 'assets/views/incident/tpl/audio.html',
// controller: function($rootScope, $scope, $modalInstance, $sce) {
// $scope.data = {
// "name": "视频",
// "url": callIp + "/recording/recording?recordId=" + data.id
// };
// $rootScope.setbusy();
// $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
// $scope.cancel = function() {
// $modalInstance.dismiss('cancel');
// // $rootScope.setidle();
// };
// $modalInstance.close();
// }
// });
// modalInstance.result.then(function(result) {
// // $rootScope.setidle();
// }, function(reason) {
// $rootScope.setidle();
// });
// };
//录音
$scope.recordcall = function(data) {
var modalInstance = $modal.open({
backdrop: "static",
templateUrl: 'assets/views/incident/tpl/audio.html',
controller: function($rootScope, $scope, $modalInstance, $sce, $http, api_playservice) {
$scope.audioUrl=$sce.trustAsResourceUrl(callIp+data.recFileName);
// $rootScope.setbusy();
// $scope.datasurl = "";
// $http({
// url: callIp + "/recording/recording?recordId=" + data.id,
// method: 'GET',
// headers: {},
// }).success(function(data, status, headers, config) {
// $scope.data = {
// "name": "视频",
// "url": $sce.trustAsResourceUrl("http://" + data.rrpath)
// };
// $scope.datasurl = data.rrpath;
// }).error(function(data, status, headers, config) {});
// $scope.download = function(contentId, filename) {
// $http({
// url: "http://" + $scope.datasurl,
// method: 'GET',
// headers: {
// 'Content-type': 'application/octet-stream',
// },
// responseType: 'arraybuffer'
// }).success(function(data, status, headers, config) {
// var file = new Blob([data], {
// type: 'application/octet-stream'
// });
// //trick to download store a file having its URL
// var fileURL = URL.createObjectURL(file);
// var a = document.createElement('a');
// a.href = fileURL;
// a.target = '_blank';
// a.download = filename;
// document.body.appendChild(a);
// a.click();
// }).error(function(data, status, headers, config) {
// // console.log(data);
// });
// }
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
$modalInstance.close();
}
});
modalInstance.result.then(function(result) {
// $rootScope.setidle();
}, function(reason) {
$rootScope.setidle();
});
};
/*--------- call --------- */
$scope.recordcallid = function(data) {
// var telephone = '9' + data.ano;
$rootScope.callout = 2;
// if ($rootScope.takes) {
// api_text.dialout($rootScope.takes, "@0", telephone).then(function(data) {
// if (data.errno == 0) {
// $rootScope.status = 6;
// $scope.oldRecord(data);
// }
// })
// } else {
// SweetAlert.swal({
// title: "呼叫失败",
// text: "请先签入呼叫中心!",
// type: "error",
// confirmButtonColor: "#DD6B55"
// });
// }
if (localStorage.getItem('fenjiNumber')) {
// var caller = localStorage.getItem('phoneNumber');//呼叫人
// console.log(sessionStorage.getItem('phones'))
// var phones = JSON.parse(sessionStorage.getItem('phones'));
// var isHuajihao = phones.length?phones.some(v=>v == data.ano):false;
// console.log(isHuajihao)
// if(isHuajihao){
// tlwsa.tlaCallagc(data.ano);//呼叫坐席
// }else{
// tlwsa.tlaCallout(data.ano, caller, 0);//呼叫外线
// }
// var caller = localStorage.getItem('fenjiNumber');//呼叫人
// tlwsa.tlaCallout(data.ano, caller, 0);
$rootScope.toggle('off-sidebar');
} else {
SweetAlert.swal({
title: "呼叫失败",
text: "请先签入呼叫中心!",
type: "error",
confirmButtonColor: "#DD6B55",
});
}
};
/*--------- old record --------- */
$scope.oldRecord = function(data) {
api_bpm_data.updData("hjzxRecord", { 'id': data.id, 'field1': '1', 'isValid': data.isValid, 'isExcute': data.isExcute }).then(function(data) {
if (data.status) {
$scope.refreshData('expand-right', defaultFilterData);
}
});
};
/*--------- record status translate --------- */
$scope.record = function(data) {
var keydata = 0;
if (data.isValid == 1) {
keydata = 0;
} else {
keydata = 1;
}
api_bpm_data.updData("hjzxRecord", { 'id': data.id, 'isValid': keydata, 'isExcute': 1, 'field1': '1' }).then(function(data) {
if (data.status) {
SweetAlert.swal({
title: "提交成功!",
text: "有效状态转换成功!",
type: "success"
}, function() {
$scope.refreshData('expand-right', defaultFilterData);
});
} else {
SweetAlert.swal({
title: "提交失败!",
text: "有效状态转换失败,请重试!",
type: "error"
});
}
}, function() {
$scope.ldloading[style.replace('-', '_')] = false;
});
};
/*--------- double click --------- */
// $scope.onDblClick = function(row) {
// var modelfile = { model: { incident: row.entity } };
// if (row.entity.state == "未受理") {
// angular.extend(modelfile.model.incident, { status: 1 })
// } else {
// angular.extend(modelfile.model.incident, { status: 0 })
// }
// $state.go('app.desk.form_editor', { formKey: 'desk_detail', service: 'api_user_data', model: JSON.stringify(modelfile) });
// };
$scope.open = function ($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.opened = !$scope.opened;
};
$scope.endOpen = function ($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.startOpened = false;
$scope.endOpened = !$scope.endOpened;
};
$scope.startOpen = function ($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.endOpened = false;
$scope.startOpened = !$scope.startOpened;
};
/*--------- get zhe list data--------- */
var defaultFilterData = {
"idx": 0,
"sum": mun
};
$scope.filData={
"idx":0,
"sum":10,
"hjzxRecord":{
"isExcute":0
}
}
$scope.searchstate="weishouli";
$scope.toIncident=function(data){
$state.go('app.incident.detail', {
formKey: 'incident_back',
pdKey: 'incident',
dataId: data.incidentDTO.id,
taskId: data.incidentDTO.taskId,
processInstanceId: data.incidentDTO.processInstanceId,
isRecord:"ok"
});
}
$scope.onChange=function(data){
var toData="";
if(data=="weishouli"){
toData=0
}else if(data=="yishouli"){
toData=1
}else if(data=="bushouli"){
toData=2
}
$scope.filData.hjzxRecord.isExcute=toData;
$scope.searchstate=data;
$scope.refreshData('expand-right', $scope.filData);
}
// 搜索
$scope.search=function(){
if($scope.filData.hjzxRecord.startTime){
$scope.filData.hjzxRecord.startTime=moment($scope.filData.hjzxRecord.startTime).format('YYYY-MM-DD HH:mm:ss')
}
if($scope.filData.hjzxRecord.endTime){
$scope.filData.hjzxRecord.endTime=moment($scope.filData.hjzxRecord.endTime).format('YYYY-MM-DD HH:mm:ss')
}
$scope.refreshData('expand-right', $scope.filData);
}
// 清空
$scope.cleanItem=function(){
delete $scope.filData.hjzxRecord.startTime;
delete $scope.filData.hjzxRecord.endTime;
$scope.refreshData('expand-right', $scope.filData);
}
$scope.ldloading = {};
$scope.refreshData = function(style, filterData) {
$scope.ldloading[style.replace('-', '_')] = true;
if (angular.isUndefined(filterData)) {
filterData = defaultFilterData;
}
$scope.myData = [];
$scope.gridOptions['sum'] = filterData.sum;
api_bpm_data.fetchDataList("hjzxRecord", filterData).then(function(data) {
var myData = Restangular.stripRestangular(data);
$scope.gridOptions['totalItems'] = myData.totalNum;
$scope.myData = myData.list;
for (var i = 0; i < $scope.myData.length; i++) {
$scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
if(!$scope.myData[i]["id"]){
$scope.myData[i]["id"]=i
}
}
// console.log($scope.myData)
$scope.ldloading[style.replace('-', '_')] = false;
}, function() {
$scope.ldloading[style.replace('-', '_')] = false;
});
};
$scope.refreshData2 = function(style, filterData) {
$scope.ldloading[style.replace('-', '_')] = true;
if (angular.isUndefined(filterData)) {
filterData = defaultFilterData;
}
// $scope.myData = [];
$scope.gridOptions['sum'] = filterData.sum;
api_bpm_data.fetchDataList("hjzxRecord", filterData).then(function(data) {
var myData = Restangular.stripRestangular(data);
$scope.gridOptions['totalItems'] = myData.totalNum;
$scope.myData = myData.list;
for (var i = 0; i < $scope.myData.length; i++) {
$scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
if(!$scope.myData[i]["id"]){
$scope.myData[i]["id"]=i
}
}
// console.log($scope.myData)
$scope.ldloading[style.replace('-', '_')] = false;
}, function() {
$scope.ldloading[style.replace('-', '_')] = false;
});
};
$scope.refreshData('expand-right', $scope.filData);
$scope.timer=$interval(function(){
$scope.refreshData2('expand-right', $scope.filData);
},$rootScope.refreshTime);
$scope.$on('$destroy',function(){
$interval.cancel($scope.timer)
});
}]);
/*--------- operation --------- */
app.controller('Recordoperator', ['$rootScope', '$http', '$scope', '$modal', function($rootScope, $http, $scope, $modal) {
// $scope.handle = false;
// $scope.isvalid = false;
// $scope.novalid = false;
// console.log($scope.item);
// if (!$scope.item.isExcute && !$scope.item.isValid) {
// $scope.handle = true;
// } else { $scope.handle = false; }
// if (!$scope.item.isExcute) {
// if ($scope.item.isValid) {
// $scope.isvalid = true;
// $scope.novalid = false;
// } else {
// $scope.isvalid = false;
// $scope.novalid = true;
// }
// } else {
// $scope.isvalid = false;
// }
$scope.isHuibo = (function(){
var phones = JSON.parse(sessionStorage.getItem('phones'));
console.log(phones,$scope.item.ano)
var isHuajihao = phones.length?phones.some(v=>v == $scope.item.ano):false;
return !isHuajihao;
})()
$scope.weishouli=false;
$scope.yishouli=false;
$scope.bushouli=false;
var loginUser = $rootScope.user;
$scope.chuli=false;
for(var i=0;i' +
'新建事件' +
'不受理' +
// '有效' +
// '无效' +
'回放' +
'回拨' +
'查看事件' +
' '
};
});