angular.module('push') .controller('SelfcheckinputCtrl', function ($scope,SelfcheckService,$stateParams,$ionicPopup,$ionicActionSheet,ionicDatePicker,UserService) { console.log($stateParams) $scope.passname=$stateParams.name SelfcheckService.getEntrylist ($stateParams.type).then(function (res){ console.log(res) if(res.code==3350){ $scope.Entrylistdata=res.data }else { $ionicPopup.alert({ title: '提示', template: res.message }); } }).catch(function (res){ console.log(res) $ionicPopup.alert({ title: '提示', template: "服务器错误" }); }) //验证 $scope.clearNum = function(obj, attr){ if(obj[attr] != obj[attr].replace(/\D/g,"")){ var alertPopup = $ionicPopup.alert({ template: '请输入正整数!' }); alertPopup.then(function(res) { console.log('Thank you for not eating my delicious ice cream cone'); }); } obj[attr] = obj[attr].replace(/\D/g,""); } //下拉选择 $scope.selectionclick=function (type,obj){ if(type==3){ var stringResult = obj.selectionvalue.split(','); var categorylist=[] stringResult.forEach((res)=>{ categorylist.push({ text:res }) }) $ionicActionSheet.show({ cancelOnStateChange: true, cssClass: 'action_s', cancelText: '取消', buttons: categorylist, buttonClicked: function (index) { obj.value = categorylist[index].text; return true; } }); }else { // 日期选择 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, "-"); obj.value = 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); } } function Processingdata(){ console.log($scope.Entrylistdata) var params={} for(let row of $scope.Entrylistdata){ for(let itemsrow of row.items){ if(itemsrow.ismust&&!itemsrow.value){ $ionicPopup.alert({ template: '请输入'+itemsrow.info }); return false }else { if(itemsrow.value){ params[itemsrow.property]=itemsrow.value } } } } console.log(params) return params } //开始检测 $scope.gotest=function (){ let Processingfinal=Processingdata() if(Processingfinal){ $scope.showLoadingToast(); let params={ userid: UserService.id, node: UserService.node, restype: $stateParams.type, data: Processingfinal } console.log(params) SelfcheckService.postRecord(params).then((res)=>{ $scope.hideLoadingToast(); console.log(res) if(res.code==3350){ let row={ id:res.data, type: '2', restype:$stateParams.type, } $scope.go('Selfcheckdetail', {obj: JSON.stringify(row)}); }else { $ionicPopup.alert({ title: '提示', template: res.message }); } }).catch(function (res) { console.log(res) $ionicPopup.alert({ title: '提示', template: "服务器错误" }); }) } } })