SelfchecklistCtrl.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. angular.module('push')
  2. .controller('SelfchecklistCtrl', function ($scope,SelfcheckService,$stateParams,UserService,$ionicPopup,
  3. $timeout,$ionicModal,$ionicActionSheet,ionicDatePicker,$ionicScrollDelegate) {
  4. $scope.passname=$stateParams.name
  5. $scope.isShowSearchButton = true;
  6. $scope.keyfilter=''
  7. $scope.CaseDatalist =function (orgname){
  8. $scope.showLoadingToast();
  9. console.log(orgname)
  10. var paramslist={
  11. userid:UserService.id,
  12. restype:$stateParams.restype,
  13. node:UserService.node,
  14. orgname:orgname,
  15. isQualified:'01'
  16. }
  17. SelfcheckService.getSelfchecklist(paramslist).then(function (res){
  18. $scope.hideLoadingToast();
  19. console.log(res)
  20. if(res.code==3350){
  21. $scope.list=res.data
  22. }else {
  23. $ionicPopup.alert({
  24. title: '提示',
  25. template: res.message
  26. });
  27. }
  28. }).catch(function (res){
  29. $scope.hideLoadingToast();
  30. $ionicPopup.alert({
  31. title: '提示',
  32. template: "服务器错误"
  33. });
  34. })
  35. }
  36. $scope.CaseDatalist('0')
  37. $scope.showSearchButtonLeft = function () {
  38. $scope.isShowSearchButton = false;
  39. $timeout(function () {
  40. $(".showSearchInput").focus();
  41. }, 300)
  42. };
  43. $scope.clearSearch = function () {
  44. $scope.isShowSearchButton = true;
  45. $scope.keyfilter= '';
  46. $scope.CaseDatalist('0');
  47. }
  48. $scope.ondetail=function (item){
  49. let row={
  50. id:item.id,
  51. type: '2',
  52. restype:$stateParams.restype,
  53. }
  54. $scope.go('Selfcheckdetail', {obj: JSON.stringify(row)});
  55. }
  56. $scope.oninputs=function (row){
  57. $scope.Entrylistdata.forEach(function (res){
  58. res.items.forEach(function (resitem){
  59. if(row){
  60. for(let key in row){
  61. if(resitem.property==key){
  62. resitem.value=row[key]+''
  63. }
  64. }
  65. }else {
  66. resitem.value=""
  67. }
  68. })
  69. })
  70. $ionicScrollDelegate.scrollTop(true);
  71. $scope.SelfcheckinputModal.show();
  72. }
  73. //下面是录入弹框
  74. $ionicModal.fromTemplateUrl('modules/Selfcheck/views/Selfcheckinput.html', {
  75. scope: $scope,
  76. backdropClickToClose:false
  77. }).then(function (modal) {
  78. $scope.SelfcheckinputModal = modal;
  79. });
  80. SelfcheckService.getEntrylist ($stateParams.restype).then(function (res){
  81. console.log(res)
  82. if(res.code==3350){
  83. $scope.Entrylistdata=res.data
  84. }else {
  85. $ionicPopup.alert({
  86. title: '提示',
  87. template: res.message
  88. });
  89. }
  90. }).catch(function (res){
  91. console.log(res)
  92. $ionicPopup.alert({
  93. title: '提示',
  94. template: "服务器错误"
  95. });
  96. })
  97. //验证
  98. $scope.clearNum = function(obj, attr){
  99. if(obj[attr] != obj[attr].replace(/\D/g,"")){
  100. var alertPopup = $ionicPopup.alert({
  101. template: '请输入正整数!'
  102. });
  103. alertPopup.then(function(res) {
  104. console.log('Thank you for not eating my delicious ice cream cone');
  105. });
  106. }
  107. obj[attr] = obj[attr].replace(/\D/g,"");
  108. }
  109. //下拉选择
  110. $scope.selectionclick=function (type,obj){
  111. if(type==3){
  112. var stringResult = obj.selectionvalue.split(',');
  113. var categorylist=[]
  114. stringResult.forEach((res)=>{
  115. categorylist.push({
  116. text:res
  117. })
  118. })
  119. $ionicActionSheet.show({
  120. cancelOnStateChange: true,
  121. cssClass: 'action_s',
  122. cancelText: '取消',
  123. buttons: categorylist,
  124. buttonClicked: function (index) {
  125. obj.value = categorylist[index].text;
  126. if(obj.isshow){
  127. if(categorylist[index].text=='是'){
  128. judgeisshow(obj,'true')
  129. }else {
  130. judgeisshow(obj,'false')
  131. }
  132. }
  133. return true;
  134. }
  135. });
  136. }else {
  137. // 日期选择
  138. var datePickerObj = {
  139. //选择日期后的回掉
  140. callback: function (val) {
  141. if (typeof (val) === 'undefined') {
  142. } else {
  143. var date = new Date(val);
  144. if (date.toLocaleString().charAt(/\s+/) != -1) {
  145. var temp = date.toLocaleString().replace(/\//g, "-");
  146. obj.value = temp;
  147. }
  148. datePickerObj.inputDate = new Date(val); //更新日期弹框上的日期
  149. }
  150. },
  151. disabledDates: [
  152. new Date(2016, 2, 16),
  153. new Date(2015, 3, 16),
  154. new Date(2015, 4, 16),
  155. new Date(2015, 5, 16),
  156. new Date('Wednesday, August 12, 2015'),
  157. new Date("2016-08-16"),
  158. new Date(1439676000000)
  159. ],
  160. from: new Date(1949, 1, 1),
  161. to: new Date(2050, 11, 31),
  162. inputDate: new Date(),
  163. mondayFirst: true,
  164. disableWeekdays: [], //设置不能选中
  165. closeOnSelect: false,
  166. dateFormat: 'yyyy-MM-dd',
  167. templateType: 'popup',
  168. };
  169. ionicDatePicker.openDatePicker(datePickerObj);
  170. }
  171. }
  172. function judgeisshow(obj,val){
  173. $scope.Entrylistdata.forEach((row)=>{
  174. row.items.forEach((rowitems)=>{
  175. if( obj.isshow.includes(rowitems.property)){
  176. rowitems.isshow=val
  177. }
  178. })
  179. })
  180. }
  181. function Processingdata(){
  182. var params={}
  183. for(let row of $scope.Entrylistdata){
  184. for(let itemsrow of row.items){
  185. if(itemsrow.ismust&&!itemsrow.value){
  186. $ionicPopup.alert({
  187. template: '请输入'+itemsrow.info
  188. });
  189. return false
  190. }else {
  191. if(itemsrow.value){
  192. params[itemsrow.property]=itemsrow.value
  193. }
  194. }
  195. }
  196. }
  197. console.log(params)
  198. return params
  199. }
  200. //开始检测
  201. $scope.gotest=function (){
  202. let Processingfinal=Processingdata()
  203. if(Processingfinal){
  204. $scope.showLoadingToast();
  205. let params={
  206. userid: UserService.id,
  207. node: UserService.node,
  208. restype: $stateParams.restype,
  209. data: Processingfinal
  210. }
  211. console.log(params)
  212. SelfcheckService.postRecord(params).then((res)=>{
  213. $scope.hideLoadingToast();
  214. console.log(res)
  215. if(res.code==3350){
  216. let row={
  217. id:res.data,
  218. type: '2',
  219. restype:$stateParams.restype,
  220. }
  221. $ionicPopup.alert({
  222. title: '提示',
  223. template: "自检成功"
  224. });
  225. $scope.SelfcheckinputModal.hide()
  226. $scope.CaseDatalist('0')
  227. }else {
  228. $ionicPopup.alert({
  229. title: '提示',
  230. template: res.message
  231. });
  232. }
  233. }).catch(function (res) {
  234. console.log(res)
  235. $ionicPopup.alert({
  236. title: '提示',
  237. template: "服务器错误"
  238. });
  239. })
  240. }
  241. }
  242. })