informationCateCtrl.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. app.controller('informationcateCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "Restangular", "api_bpm_data", "api_solution","api_wechatfile","api_sysinfo", function($rootScope, $scope, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, Restangular, api_bpm_data, api_solution,api_wechatfile,api_sysinfo) {
  2. // $scope.langs=i18nService.getAllLangs();
  3. $scope.lang = 'zh-cn';
  4. var loginUser = $rootScope.user;
  5. var i = 0;
  6. $scope.out = [];
  7. $scope.outdata = [];
  8. var systemtype = [];
  9. $scope.addcate = false;
  10. $scope.changecate = false;
  11. $scope.addType = function(element) {
  12. $scope.addcate = true
  13. $scope.changecate = false
  14. }
  15. $scope.remove = function(data1) {
  16. if(data1){
  17. var modalInstance = $modal.open({
  18. templateUrl: 'assets/views/delete.html',
  19. controller: function($scope, scope, $modalInstance, api_bpm_data) {
  20. $scope.title = "服务指南分类删除?";
  21. $scope.connect = "确定要删除此服务指南分类?";
  22. $scope.ok = function() {
  23. $modalInstance.close(data1);
  24. };
  25. $scope.cancel = function() {
  26. $modalInstance.dismiss('cancel');
  27. };
  28. },
  29. size: 'sm',
  30. resolve: {
  31. scope: function() {
  32. return $scope;
  33. }
  34. }
  35. });
  36. modalInstance.result.then(function(selectedItem) {
  37. selectedItem.deleted=true;
  38. api_sysinfo.addData('dictionary',selectedItem).then(function(res){
  39. if(res.status==200){
  40. SweetAlert.swal({
  41. title: "删除成功!",
  42. type: "success",
  43. confirmButtonColor: "#007AFF"
  44. }, function() {
  45. $scope.getListData();
  46. });
  47. }else{
  48. SweetAlert.swal({
  49. title: "系统错误",
  50. text: "系统错误,请稍后重试!",
  51. type: "error",
  52. confirmButtonColor: "#DD6B55"
  53. }, function() {
  54. $scope.getListData();
  55. });
  56. }
  57. })
  58. })
  59. }else{
  60. SweetAlert.swal({
  61. title: "操作失败",
  62. text: "请选择需要删除的选项!",
  63. type: "error",
  64. confirmButtonColor: "#DD6B55"
  65. })
  66. }
  67. }
  68. var childdata = {};
  69. $scope.subdata = {};
  70. $scope.listData=[];
  71. $scope.listIdx=-1;
  72. $scope.selectData="";
  73. $scope.addCategory="";
  74. $scope.changeValue="";
  75. $scope.getListData=function(){
  76. var data={
  77. "key":"service_type",
  78. "type":"list"
  79. }
  80. api_wechatfile.getDictionary(data).then(function(res){
  81. $scope.listData=res
  82. })
  83. }
  84. $scope.getListData();
  85. $scope.listSelect=function(data,idx){
  86. $scope.listIdx=idx;
  87. $scope.changecate = true;
  88. $scope.addcate = false;
  89. $scope.selectData=data;
  90. $scope.changeValue=data.name
  91. }
  92. $scope.parentdata = {};
  93. $scope.cancel = function() {
  94. $scope.userdata = [];
  95. $scope.outdata = [];
  96. };
  97. //修改
  98. $scope.submitchange = function(data1,data2) {
  99. if(data1){
  100. data2.name=data1;
  101. api_sysinfo.addData('dictionary',data2).then(function(res){
  102. if(res.status==200){
  103. SweetAlert.swal({
  104. title: "修改成功!",
  105. type: "success",
  106. confirmButtonColor: "#007AFF"
  107. }, function() {
  108. $scope.getListData();
  109. });
  110. }else{
  111. SweetAlert.swal({
  112. title: "系统错误",
  113. text: "系统错误,请稍后重试!",
  114. type: "error",
  115. confirmButtonColor: "#DD6B55"
  116. }, function() {
  117. $scope.getListData();
  118. });
  119. }
  120. })
  121. }else{
  122. SweetAlert.swal({
  123. title: "修改失败",
  124. text: "修改值不能为空!",
  125. type: "error",
  126. confirmButtonColor: "#DD6B55"
  127. });
  128. }
  129. };
  130. //新增
  131. $scope.submitadd = function(data1) {
  132. if(data1){
  133. var data={
  134. deleted:false,
  135. "key":"service_type",
  136. "name":data1,
  137. "orders":0,
  138. "system":false,
  139. };
  140. api_sysinfo.addData('dictionary',data).then(function(res){
  141. if(res.status==200){
  142. SweetAlert.swal({
  143. title: "新增成功!",
  144. type: "success",
  145. confirmButtonColor: "#007AFF"
  146. }, function() {
  147. $scope.getListData();
  148. });
  149. }else{
  150. SweetAlert.swal({
  151. title: "系统错误",
  152. text: "系统错误,请稍后重试!",
  153. type: "error",
  154. confirmButtonColor: "#DD6B55"
  155. });
  156. }
  157. })
  158. }else{
  159. SweetAlert.swal({
  160. title: "新增失败",
  161. text: "新增值不能为空!",
  162. type: "error",
  163. confirmButtonColor: "#DD6B55"
  164. });
  165. }
  166. }
  167. }]);