angular.module('push') .controller('techDemandCheckCtrl', function ($scope, AccountService, $stateParams, UserService, $ionicPopup, dataToolsService, $ionicSlideBoxDelegate) { $scope.defaultLan = UserService.defaultLan; $scope.id = $stateParams.id; $scope.node = UserService.node; $scope.comefrom = $stateParams.comefrom; $scope.list = $stateParams.list; $scope.isBroker = false; $scope.permission1 = false;//公开 $scope.permission2 = false;//技术经纪人可见 $scope.permission3 = false;//高校院所专家可见 $scope.permission4 = false;//私密 $scope.cooperationmodelInfo = ""; if ($scope.node == '330122000') { $scope.agree = 1; } else { $scope.agree = true; } $scope.checkData = {}; $scope.checkShow = $stateParams.checkShow; $scope.resubmitData = {}; //通过当前技术需求id获取当前的技术需求 var getDemandInfo = function () { AccountService.getDemandInfo($stateParams.id).then(function (res) { if (res.code == 3350) { var data = res.data; $scope.projectname = data.projectname; $scope.capitalScale = data.capitalScale; $scope.contactor = data.contactor; $scope.tel = data.tel; $scope.photolist = data.photoList; $scope.taskintroduction = data.taskintroduction; $scope.cooperationmodelCHN = data.cooperationmodelCHN; $scope.tonglucheckstatus = data.tonglucheckstatus; $scope.refusereason = data.refusereason; $scope.node = data.node; $scope.permissionvalue = data.permissionvalue; var splitArr = []; if($scope.permissionvalue == 1 || $scope.permissionvalue == 2 || $scope.permissionvalue == 3 || $scope.permissionvalue == 4 || $scope.permissionvalue == 5){ splitArr.push($scope.permissionvalue); }else if($scope.permissionvalue != null){ splitArr = $scope.permissionvalue.split(','); }else{ splitArr.push(1); } for (var i = 0; i < splitArr.length; i++) { if (splitArr[i] == 1) { $scope.permission1 = true; } if (splitArr[i] == 2) { $scope.permission2 = true; } if (splitArr[i] == 3) { $scope.permission3 = true; } if (splitArr[i] == 4) { $scope.permission4 = true; } } var cooperationmodel = data.cooperationmodel; if (cooperationmodel != null && cooperationmodel != "") { dataToolsService.getCooperationmodelByCode(cooperationmodel).then(function (newRes) { if (newRes.code == 3350) { $scope.cooperationmodelInfo = newRes.data; } }) } //判断创建者是不是技术经纪人 dataToolsService.judgeUserBroker(data.creator).then(function (isBrokerRes) { if (isBrokerRes.code == 3350) { $scope.isBroker = isBrokerRes.data; if (isBrokerRes.data) { //当前用户是技术经纪人 AccountService.getUserCheckInfo(data.creator).then(function (response) { if (response.code == 3350) { var user = response.data; $scope.contactor = user.applyname; $scope.tel = user.tel; } }); } AccountService.getCompanyById(data.companyid).then(function (nameRes) { if (res.code == 3350) { $scope.companyName = nameRes.data; AccountService.getUserNameById(data.creator).then(function (userRes) { if (res.code == 3350) { $scope.userName = userRes.data; } }); } }); } }); } }); } getDemandInfo(); //点击图片放大 $scope.bigImage = false; //初始默认大图是隐藏的 $scope.hideBigImage = function () { $scope.bigImage = false; }; $scope.shouBigImage = function (index) { //传递一个参数(图片的URl) if ($scope.app) { $scope.setStatusBar(1); } $scope.bigImage = true; //显示大图 $(function () { $('div.pinch-zoom').each(function () { new RTP.PinchZoom($(this), {}); }); }); $ionicSlideBoxDelegate.update();//重绘,让图片显示出来 //图片总数量 setTimeout(function () { // console.log(parseInt($ionicSlideBoxDelegate.slidesCount())); // console.log(parseInt($ionicSlideBoxDelegate.currentIndex())); $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, 0); //获取图片 var imgObj = document.getElementsByClassName('bigimage'); var n; for (n = 0; n < imgObj.length; n++) { // 获取图片的原始高度和宽度 var oldWid = imgObj[n].naturalWidth; var oldHei = imgObj[n].naturalHeight; var screen = document.body.offsetWidth; var screenH = window.innerHeight; // console.log(oldWid/oldHei); // console.log(screen ); var rate = oldWid / oldHei; if (oldWid >= screen && oldHei >= screenH) { var tw = screen; var th = tw / rate; if (th < screenH) { imgObj[n].style.width = tw + 'px'; imgObj[n].style.height = th + 'px'; imgObj[n].style.marginTop = (screenH - th) / 2 + 'px'; } else { imgObj[n].style.width = screenH * rate + 'px'; imgObj[n].style.height = screenH + 'px'; imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px'; } } else if (oldWid >= screen && oldHei <= screenH) { imgObj[n].style.width = screen + 'px'; imgObj[n].style.height = screen / rate + 'px'; imgObj[n].style.marginTop = (screenH - screen / rate) / 2 + 'px'; } else if (oldWid <= screen && oldHei >= screenH) { // var hh=screenH; // var ww=screenH*rate; imgObj[n].style.width = screenH * rate + 'px'; imgObj[n].style.height = screenH + 'px'; imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px'; } else { imgObj[n].style.width = oldWid + 'px'; imgObj[n].style.height = oldHei + 'px'; imgObj[n].style.marginLeft = (screen - oldWid) / 2 + 'px'; imgObj[n].style.marginTop = (screenH - oldHei) / 2 + 'px'; } } }, 500); }; $scope.agreeClick = function () { if ($scope.node == '330122000') { $scope.agree = 1; } else { $scope.agree = true; } } $scope.rollClick = function () { $scope.agree = -2; } $scope.rejectClick = function () { if ($scope.node == '330122000') { $scope.agree = -1; } else { $scope.agree = false; } } //需求审核 $scope.checkDemand = function (id) { if ($scope.node != '330122000') { if ($scope.agree) { var value = 1; } else { var value = -1 } } if ($scope.node == '330122000') { if ($scope.agree == 1) { var value = 1; } if ($scope.agree == -1) { var value = -1 } if ($scope.agree == -2) { var value = -2 } } if (value == -1 || value == -2) { if ($scope.checkData.refusereason == "" || $scope.checkData.refusereason == null) { if (value == -1) { $ionicPopup.alert({ title: '确定', template: '请填写拒绝理由' }); } if (value == -2) { $ionicPopup.alert({ title: '确定', template: '请填写退回理由' }); } return; } } AccountService.checkTechDemand(value, id, $scope.checkData.refusereason).then(function (res) { if (res.code == 3350) { $scope.go('techDemandDetail'); } }) } $scope.checkDemandAgain = function (list, demandId) { list.infoSectionList = []; list.infoSectionList[0] = {}; list.infoSectionList[0].unitlist = []; if ($scope.projectname) { var value = {}; value.tcname = "projectname"; value.content = $scope.projectname; list.infoSectionList[0].unitlist.push(value); } if ($scope.capitalScale) { var value = {}; value.tcname = "capitalScale"; value.content = $scope.capitalScale; list.infoSectionList[0].unitlist.push(value); } if ($scope.contactor) { var value = {}; value.tcname = "contactor"; value.content = $scope.contactor; list.infoSectionList[0].unitlist.push(value); } if ($scope.tel) { var value = {}; value.tcname = "tel"; value.content = $scope.tel; list.infoSectionList[0].unitlist.push(value); list.tel = $scope.tel; } if ($scope.cooperationmodelInfo) { var value = {}; value.tcname = "cooperationmodel"; value.content = $scope.cooperationmodelInfo; list.infoSectionList[0].unitlist.push(value); } if ($scope.taskintroduction) { var value = {}; value.tcname = "taskintroduction"; value.content = $scope.taskintroduction; list.infoSectionList[0].unitlist.push(value); } if ($scope.companyName) { var value = {}; value.tcname = "oid"; value.content = $scope.companyName; list.infoSectionList[0].unitlist.push(value); } if ($scope.photolist) { var value = {}; value = $scope.photolist; list.infoSectionList[0].unitlist.push(value); } list.baseInfoModel = {}; list.baseInfoModel.oid = list.companyid; list.baseInfoModel.permission1 = $scope.permission1; list.baseInfoModel.permission2 = $scope.permission2; list.baseInfoModel.permission3 = $scope.permission3; list.baseInfoModel.permission4 = $scope.permission4; list.title = $scope.projectname; list.content = $scope.taskintroduction; list.photolist = $scope.photolist; //判断当前用户是不是技术经纪人 dataToolsService.judgeUserBroker(UserService.id).then(function (res) { $scope.userIsBroker = false; if (res.code == 3350) { $scope.userIsBroker = res.data; }else{ $scope.userIsBroker = false; } $scope.go('taskRelease', {data: list, userIsBroker: $scope.userIsBroker, demandId:demandId}); }) /*$scope.go('techDemandCheckAgain', {resubmitData: $scope.resubmitData});*/ } }) ;