angular.module('push') .controller('orgInspectCtrl', function ($scope, dataToolsService, $ionicActionSheet, $sce, $ionicPopup, ionicDatePicker, $stateParams, UserService, AccountService, CommentService, UtilService, $timeout, CommonService, ConfigService) { $scope.stateParamsValue = $stateParams.value; $scope.value = $stateParams.value ? $stateParams.value : 1; $scope.params = {}; $scope.highorginspection = {}; $scope.threeyearinfo = {}; $scope.category = {}; $scope.obtainway = {}; $scope.basicname = "基本信息"; $scope.intellecname = "知识产权"; $scope.balancename = "收支信息"; $scope.othername = "其他信息"; $scope.year = new Date().getFullYear(); $scope.saleflag = true; $scope.changesaleflag = function () { $scope.saleflag = !$scope.saleflag; } $scope.assetflag = true; $scope.changeasset = function () { $scope.assetflag = !$scope.assetflag; } $scope.researchmoneyflag = true; $scope.changeresearchmoney = function () { $scope.researchmoneyflag = !$scope.researchmoneyflag; } $scope.chinaresearchmoneyflag = true; $scope.changechinaresearchmoney = function () { $scope.chinaresearchmoneyflag = !$scope.chinaresearchmoneyflag; } $scope.collectway = true; $scope.changecollectway = function () { $scope.collectway = !$scope.collectway; } $scope.islogin = ConfigService.islogin; if (!$scope.islogin) { if (localStorage.wxFlag == "true") { if (localStorage.isUserBindWx == 0) { var wxFlag = JSON.parse(localStorage.params); if (wxFlag.weChatModel) { $scope.go('bindPhone', { params: localStorage.params, comfrom: 'maincontroller', url: window.location.href.split('#/')[1] }); } else { $scope.go('login'); return; } } else { $scope.go('login'); return; } } else { $scope.go('login'); return; } } $scope.showcategorylist = function () { var categorylist = []; AccountService.getDomainInfo(0, UserService.node).then(function (res) { if (res.code == 3350) { // console.log(res); angular.forEach(res.data, function (val) { categorylist.push({ text: '' + val.name + '', itemkey: val.id, itemvalue: val.name, //名字, itemcode: val.code }) }) $ionicActionSheet.show({ cancelOnStateChange: true, cssClass: 'action_s', cancelText: '取消', buttons: categorylist, buttonClicked: function (index) { $scope.highorginspection.category = categorylist[index].itemvalue; return true; } }); } else { } }) }; $scope.showobtainlist = function () { var obtainlist = []; dataToolsService.getTypeEntryListByTypeName("highorgobtainway").then(function (res) { if (res.code == 3350) { angular.forEach(res.data, function (val) { obtainlist.push({ text: '' + val.itemkey + '', itemkey: val.id, itemvalue: val.itemkey, //名字, itemcode: val.itemvalue }) }) $ionicActionSheet.show({ cancelOnStateChange: true, cssClass: 'action_s', cancelText: '取消', buttons: obtainlist, buttonClicked: function (index) { $scope.highorginspection.obtainway = obtainlist[index].itemvalue; return true; } }); } }) }; var isparticipatestandard = false; $scope.watchIsChange = function () { if (isparticipatestandard == false) { isparticipatestandard = true; $scope.highorginspection.isparticipatestandard = true; } else { isparticipatestandard = false; $scope.highorginspection.isparticipatestandard = false; } }; $scope.technicaladvanced = 1; $scope.changetechnical = function (index) { $scope.technicaladvanced = index; $scope.highorginspection.technicaladvanced = index; } $scope.coresupport = 1; $scope.changesupportrole = function (index) { $scope.coresupport = index; $scope.highorginspection.coresupport = index; } $scope.convertaverage = 1; $scope.changetechnicaltransform = function (index) { $scope.convertaverage = index; $scope.highorginspection.convertaverage = index; } var otherindevelopfee = false; $scope.watchPercentIsChange = function () { if (otherindevelopfee == false) { otherindevelopfee = true; $scope.threeyearinfo.otherindevelopfee = true; } else { otherindevelopfee = false; $scope.threeyearinfo.otherindevelopfee = false; } }; $scope.showtaxway1 = function () { var taxwaylist = []; dataToolsService.getTypeEntryListByTypeName("expropriationmethod").then(function (res) { if (res.code == 3350) { angular.forEach(res.data, function (val) { taxwaylist.push({ text: '' + val.itemkey + '', itemkey: val.id, itemvalue: val.itemkey, //名字, itemcode: val.itemvalue }) }) $ionicActionSheet.show({ cancelOnStateChange: true, cssClass: 'action_s', cancelText: '取消', buttons: taxwaylist, buttonClicked: function (index) { $scope.threeyearinfo.collectway1 = taxwaylist[index].itemvalue; return true; } }); } }) }; $scope.showtaxway2 = function () { var taxwaylist = []; dataToolsService.getTypeEntryListByTypeName("expropriationmethod").then(function (res) { if (res.code == 3350) { angular.forEach(res.data, function (val) { taxwaylist.push({ text: '' + val.itemkey + '', itemkey: val.id, itemvalue: val.itemkey, //名字, itemcode: val.itemvalue }) }) $ionicActionSheet.show({ cancelOnStateChange: true, cssClass: 'action_s', cancelText: '取消', buttons: taxwaylist, buttonClicked: function (index) { $scope.threeyearinfo.collectway2 = taxwaylist[index].itemvalue; return true; } }); } }) }; $scope.showtaxway3 = function () { var taxwaylist = []; dataToolsService.getTypeEntryListByTypeName("expropriationmethod").then(function (res) { if (res.code == 3350) { angular.forEach(res.data, function (val) { taxwaylist.push({ text: '' + val.itemkey + '', itemkey: val.id, itemvalue: val.itemkey, //名字, itemcode: val.itemvalue }) }) $ionicActionSheet.show({ cancelOnStateChange: true, cssClass: 'action_s', cancelText: '取消', buttons: taxwaylist, buttonClicked: function (index) { $scope.threeyearinfo.collectway3 = taxwaylist[index].itemvalue; return true; } }); } }) }; $scope.gobackpage = function () { if (!$stateParams.value) { if ($scope.value != 1) { $scope.value--; } else { $scope.go('tab.activityIndex'); } } else { $scope.go('orgInspectList', {isuserlist: false}); } } $scope.isRelateUl = false; $scope.companylist = []; $scope.selectOrgname = function (orgname) { if (orgname) { $timeout(function () { dataToolsService.getOrganizationModelByOrgname(orgname, 0, 0).then(function (response) { $scope.companylist = response.data; $scope.isRelateUl = true; }, function () { }) }, 1000); } else { $scope.isRelateUl = false; $scope.companylist = []; } } $scope.ttt = function (tmptitle) { return $sce.trustAsHtml(tmptitle); } $scope.fatherdata = {}; $scope.setCompanyName = function (organizationInfo) { $scope.organizationInfo = organizationInfo; $scope.highorginspection.orgname = organizationInfo.name; if (organizationInfo.registrationdate) { $scope.highorginspection.registerdate = organizationInfo.registrationdate.split(/\s+/)[0]; } $scope.highorginspection.orgcode = organizationInfo.orgcode; $scope.category.value = organizationInfo.categoryid; $scope.isRelateUl = false; } $scope.regex=/^[+-]?\d+(\.\d+)?$/ $scope.pdregex=/1[3|4|5|7|8|9][0-9]{9}/ $scope.tpdregex=/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/ $scope.goNextPage = function () { if ($scope.value != 4) { //必填项没有填的话就不可以点击下一步 if ($scope.value == 1) { if (!$scope.highorginspection.orgname || !$scope.highorginspection.registerdate || !$scope.highorginspection.contracttel||!$scope.highorginspection.declaredate) { $ionicPopup.alert({ title: '提示', template: '请填写必填项!' }); return; } if($scope.highorginspection.contracttel!=undefined){ if(!$scope.pdregex.test($scope.highorginspection.contracttel)||$scope.highorginspection.contracttel.length!=11){ $ionicPopup.alert({ title: '提示', template: '请填正确手机号码!' }); return; } } if($scope.highorginspection.workercount!=undefined){ if(!$scope.regex.test($scope.highorginspection.workercount)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.highorginspection.technicalcount!=undefined){ if(!$scope.regex.test($scope.highorginspection.technicalcount)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } } //必填项没有填的话就不可以点击下一步 if ($scope.value == 2) { if (!$scope.highorginspection.oneintellectualcount || !$scope.highorginspection.twointellectualcount || !$scope.highorginspection.obtainway) { $ionicPopup.alert({ title: '提示', template: '请填写必填项!' }); return; } if($scope.highorginspection.oneintellectualcount!=undefined){ console.log( $scope.highorginspection.patentcount) if(!$scope.regex.test($scope.highorginspection.oneintellectualcount)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.highorginspection.twointellectualcount!=undefined){ if(!$scope.regex.test($scope.highorginspection.twointellectualcount)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.highorginspection.patentcount!=undefined){ if(!$scope.regex.test($scope.highorginspection.patentcount)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.highorginspection.practicalpatentcount!=undefined){ console.log( $scope.highorginspection.patentcount) if(!$scope.regex.test($scope.highorginspection.practicalpatentcount)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.highorginspection.appearancepatentcount!=undefined){ if(!$scope.regex.test($scope.highorginspection.appearancepatentcount)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } } if($scope.value == 3){ if($scope.threeyearinfo.sale3!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.sale3)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.sale2!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.sale2)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.sale1!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.sale1)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.asset3!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.sale3)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.asset2!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.asset2)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.asset1!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.asset1)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.researchmoney3!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.researchmoney3)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.researchmoney2!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.researchmoney2)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.researchmoney1!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.researchmoney1)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.chinaresearchmoney3!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.chinaresearchmoney3)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.chinaresearchmoney2!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.chinaresearchmoney2)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.chinaresearchmoney1!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.chinaresearchmoney1)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.income!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.income)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.techincome!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.techincome)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.threeyearinfo.intellectureincome!=undefined){ if(!$scope.regex.test($scope.threeyearinfo.intellectureincome)){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } } $scope.value++; } else { //表单参数验证 if (!$scope.highorginspection.orgname || !$scope.highorginspection.registerdate || !$scope.highorginspection.contracttel || !$scope.highorginspection.oneintellectualcount || !$scope.highorginspection.twointellectualcount || !$scope.highorginspection.obtainway) { $ionicPopup.alert({ title: '提示', template: '输入数据有误!请检查' }); return; } if($scope.highorginspection.establishaccountsystem!=undefined){ if(!$scope.regex.test($scope.highorginspection.establishaccountsystem)||$scope.highorginspection.establishaccountsystem>6){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.highorginspection.universityindustrycooperation!=undefined){ if(!$scope.regex.test($scope.highorginspection.universityindustrycooperation)||$scope.highorginspection.universityindustrycooperation>6){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.highorginspection.buildinnovationplatform!=undefined){ if(!$scope.regex.test($scope.highorginspection.buildinnovationplatform)||$scope.highorginspection.buildinnovationplatform>4){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } if($scope.highorginspection.establishrewardsystem!=undefined){ if(!$scope.regex.test($scope.highorginspection.establishrewardsystem)||$scope.highorginspection.establishrewardsystem>4){ $ionicPopup.alert({ title: '提示', template: '请填正确数值!' }); return; } } //开始检测 if (!$scope.highorginspection.technicaladvanced) { $scope.highorginspection.technicaladvanced = 1; } if (!$scope.highorginspection.coresupport) { $scope.highorginspection.coresupport = 1; } if (!$scope.highorginspection.convertaverage) { $scope.highorginspection.convertaverage = 1; } $scope.highorginspection.isparticipatestandard = $scope.highorginspection.isparticipatestandard == true ? 1 : 0; $scope.highorginspection.otherindevelopfee = $scope.highorginspection.otherindevelopfee == true ? 1 : 0; $scope.highorginspection.data = $scope.threeyearinfo; //通过接口发送至后台,用于存入数据库 $scope.params.data = $scope.highorginspection; $scope.params.node = UserService.node; $scope.params.userid = UserService.id; AccountService.insertHighInspect($scope.params).then(function (res) { if (res.code == 3350) { $scope.go("orgSelfReport", { data: $scope.params, scoreConnid: res.data, highorginspection: $stateParams.highorginspection, registerdate:$scope.highorginspection.registerdate }); }else { $ionicPopup.alert({ title: '提示', template: res.message }); } }) } } // 时间日期 // 日期选择 $scope.validedTime = new Date(); //打开日期选择框 $scope.openDatePicker = function (obj) { var datePickerObj = { //选择日期后的回掉 callback: function (val) { if (typeof (val) === 'undefined') { } else { var date = new Date(val); if (date.toLocaleString().charAt(/\s+/) != -1) { var temp = date.toLocaleString().replace(/\//g, "-"); $scope.highorginspection[obj]= temp; } datePickerObj.inputDate = new Date(val); //更新日期弹框上的日期 } }, disabledDates: [ new Date(2016, 2, 16), new Date(2015, 3, 16), new Date(2015, 4, 16), new Date(2015, 5, 16), new Date('Wednesday, August 12, 2015'), new Date("2016-08-16"), new Date(1439676000000) ], from: new Date(1949, 1, 1), to: new Date(2050, 11, 31), inputDate: new Date(), mondayFirst: true, disableWeekdays: [], //设置不能选中 closeOnSelect: false, dateFormat: 'yyyy-MM-dd', templateType: 'popup', } ionicDatePicker.openDatePicker(datePickerObj); }; $scope.choiceToggle = true; $scope.changeToggle = function () { $scope.choiceToggle = !$scope.choiceToggle; } if ($stateParams.highorginspection) { $scope.highorginspection = $stateParams.highorginspection; $scope.threeyearinfo = $scope.highorginspection.data; $scope.category.value = $scope.highorginspection.category; $scope.obtainway.value = $scope.highorginspection.obtainway; $scope.technicaladvanced = $scope.highorginspection.technicaladvanced; $scope.coresupport = $scope.highorginspection.coresupport; $scope.convertaverage = $scope.highorginspection.convertaverage; } }) ;