123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- angular.module('push')
- .controller('SelfchecklistCtrl', function ($scope,SelfcheckService,$stateParams,UserService,$ionicPopup,
- $timeout,$ionicModal,$ionicActionSheet,ionicDatePicker,$ionicScrollDelegate) {
- $scope.passname=$stateParams.name
- $scope.isShowSearchButton = true;
- $scope.keyfilter=''
- $scope.CaseDatalist =function (orgname){
- $scope.showLoadingToast();
- console.log(orgname)
- var paramslist={
- userid:UserService.id,
- restype:$stateParams.restype,
- node:UserService.node,
- orgname:orgname,
- isQualified:'01'
- }
- SelfcheckService.getSelfchecklist(paramslist).then(function (res){
- $scope.hideLoadingToast();
- console.log(res)
- if(res.code==3350){
- $scope.list=res.data
- }else {
- $ionicPopup.alert({
- title: '提示',
- template: res.message
- });
- }
- }).catch(function (res){
- $scope.hideLoadingToast();
- $ionicPopup.alert({
- title: '提示',
- template: "服务器错误"
- });
- })
- }
- $scope.CaseDatalist('0')
- $scope.showSearchButtonLeft = function () {
- $scope.isShowSearchButton = false;
- $timeout(function () {
- $(".showSearchInput").focus();
- }, 300)
- };
- $scope.clearSearch = function () {
- $scope.isShowSearchButton = true;
- $scope.keyfilter= '';
- $scope.CaseDatalist('0');
- }
- $scope.ondetail=function (item){
- let row={
- id:item.id,
- type: '2',
- restype:$stateParams.restype,
- }
- $scope.go('Selfcheckdetail', {obj: JSON.stringify(row)});
- }
- $scope.oninputs=function (row){
- $scope.Entrylistdata.forEach(function (res){
- res.items.forEach(function (resitem){
- if(row){
- for(let key in row){
- if(resitem.property==key){
- resitem.value=row[key]+''
- }
- }
- }else {
- resitem.value=""
- }
- })
- })
- $ionicScrollDelegate.scrollTop(true);
- $scope.SelfcheckinputModal.show();
- }
- //下面是录入弹框
- $ionicModal.fromTemplateUrl('modules/Selfcheck/views/Selfcheckinput.html', {
- scope: $scope,
- backdropClickToClose:false
- }).then(function (modal) {
- $scope.SelfcheckinputModal = modal;
- });
- SelfcheckService.getEntrylist ($stateParams.restype).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;
- if(obj.isshow){
- if(categorylist[index].text=='是'){
- judgeisshow(obj,'true')
- }else {
- judgeisshow(obj,'false')
- }
- }
- 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 judgeisshow(obj,val){
- $scope.Entrylistdata.forEach((row)=>{
- row.items.forEach((rowitems)=>{
- if( obj.isshow.includes(rowitems.property)){
- rowitems.isshow=val
- }
- })
- })
- }
- function Processingdata(){
- 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.restype,
- 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.restype,
- }
- $ionicPopup.alert({
- title: '提示',
- template: "自检成功"
- });
- $scope.SelfcheckinputModal.hide()
- $scope.CaseDatalist('0')
- }else {
- $ionicPopup.alert({
- title: '提示',
- template: res.message
- });
- }
- }).catch(function (res) {
- console.log(res)
- $ionicPopup.alert({
- title: '提示',
- template: "服务器错误"
- });
- })
- }
- }
- })
|