123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- 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: "服务器错误"
- });
- })
- }
- }
- })
|