dictionarylist.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. (function () {
  2. angular.module('devself.common').controller('dictionarylistCtrl', function ($scope, $http, $modal, $ocLazyLoad, $alert, $loading, $state,$bsRouterState) {
  3. $scope.title = "字典列表";
  4. $scope.searchTypeKey = "";
  5. $scope.dicvalue = "";
  6. $scope.diclist = [];
  7. $scope.viewport = {
  8. selector: "div[name='dictionarybody']",
  9. padding: 0
  10. };
  11. $state.params=$bsRouterState.$params($scope);
  12. //初始分页参数
  13. $scope.finddata = {
  14. pageindex: 1,//页数
  15. pagesize: 10,//每页展示记录条数
  16. ptotal: 0//总记录数
  17. };
  18. //监视页数变化
  19. $scope.$watch("finddata.pageindex", function (newVal, oldVal) {
  20. if ($scope.finddata.ptotal > 0) {
  21. $scope.getList();
  22. }
  23. });
  24. //查询
  25. $scope.search = function () {
  26. $scope.finddata.pageindex = 1;
  27. $scope.finddata.ptotal = 0;
  28. $scope.getList();
  29. };
  30. //查询
  31. $scope.getList = function () {
  32. $loading.show();
  33. $http({
  34. method: "get",
  35. url: "../../api/dictionary/dictionaryList",
  36. params: {
  37. 'dicTypeKey': $scope.searchTypeKey,
  38. 'pageIndex': $scope.finddata.pageindex,
  39. 'pageSize': $scope.finddata.pagesize,
  40. 'appId': $state.params.appid,
  41. 'dicvalue' : $scope.dicvalue,
  42. }
  43. }).then(function (result) {
  44. $loading.hide();
  45. $scope.diclist = result.data.item.list;
  46. $scope.finddata.ptotal = result.data.item.total;
  47. if (result.data.item.total == 0) {
  48. //$alert({ title: '消息:', content: '没有查询到字典记录', placement: 'top', type: 'info', show: true, duration: 3 });
  49. }
  50. }, function (resp) {
  51. $loading.hide();
  52. $alert({title: '错误:', content: '服务器错误', placement: 'top', type: 'info', show: true, duration: 3});
  53. });
  54. };
  55. //删除字典
  56. $scope.deletedic = function (id) {
  57. if (!confirm("确认删除?")) {
  58. return;
  59. }
  60. $http.get("../../api/dictionary/delDictionary", {params: {'dictionaryid': id}}).then(function (result) {
  61. $alert({
  62. title: '成功:',
  63. content: result.data.msg,
  64. placement: 'top',
  65. type: 'info',
  66. show: true,
  67. duration: 3
  68. });
  69. $scope.getList();
  70. }, function (req) {
  71. $alert({title: '错误:', content: '服务器错误', placement: 'top', type: 'info', show: true, duration: 3});
  72. });
  73. };
  74. var savemodalCtrl = function ($scope, $http) {
  75. $scope.params = myModal.params;
  76. $scope.content = myModal.params.content;
  77. $scope.dicTypeList = [{dictype: "系统", id: 1}, {dictype: "普通", id: 2}];
  78. $scope.submit = function (isflag) {
  79. if (isflag) {
  80. $loading.show();
  81. $http({
  82. method: "post",
  83. url: "../../api/dictionary/dictionarySave",
  84. data: {
  85. "dictionaryid": $scope.content.dictionaryid,
  86. "dictypekey": $scope.content.dictypekey,
  87. "dicvalue": $scope.content.dicvalue,
  88. "dictype": $scope.content.dictype,
  89. "dicnote": $scope.content.dicnote,
  90. "dickey": $scope.content.dickey,
  91. "applicationid": $state.params.appid
  92. }
  93. }).then(function (result) {
  94. $loading.hide();
  95. $alert({
  96. title: '成功:',
  97. content: result.data.msg,
  98. placement: 'top',
  99. type: 'info',
  100. show: true,
  101. duration: 3
  102. });
  103. //重新刷新列表
  104. $scope.getList();
  105. $scope.$hide();
  106. }), function (resp) {
  107. $alert({
  108. title: '错误:',
  109. content: '服务器错误',
  110. placement: 'top',
  111. type: 'info',
  112. show: true,
  113. duration: 3
  114. });
  115. }
  116. }
  117. }
  118. };
  119. savemodalCtrl.$inject = ['$scope', '$http'];
  120. //新增或编辑字典 模态框
  121. var myModal = $modal({
  122. resolve: {
  123. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  124. return [$ocLazyLoad.load('../js/setting/DictionaryManage/savedicmodal.css')];
  125. }]
  126. },
  127. scope: $scope,
  128. controller: savemodalCtrl,
  129. templateUrl: '../js/setting/DictionaryManage/savedicmodal.html',
  130. show: false,
  131. animation: 'am-fade-and-slide-top'
  132. });
  133. //打开字典新增模态框
  134. $scope.savemodal = function () {
  135. myModal.content = {};
  136. myModal.params = {
  137. title: "字典新增",
  138. dicTypeKeyDisabled: false,
  139. dicTypeDisabled: true,
  140. content: {dictype: 2}
  141. };
  142. myModal.$promise.then(myModal.show);
  143. };
  144. //打开字典编辑模态框
  145. $scope.editmodal = function (id) {
  146. myModal.params = {
  147. title: "字典编辑",
  148. dicTypeKeyDisabled: true,
  149. dicTypeDisabled: false,
  150. content: {}
  151. };
  152. $loading.show();
  153. $http.get("../../api/dictionary/getDictionaryByID", {params: {'id': id}}).then(function (result) {
  154. console.log(result);
  155. $loading.hide();
  156. myModal.params.content = result.data.item;
  157. myModal.$promise.then(myModal.show);
  158. }, function () {
  159. $alert({title: '错误:', content: '服务器错误', placement: 'top', type: 'info', show: true, duration: 3});
  160. });
  161. };
  162. $scope.getList();//初始化列表
  163. $scope.reset = function () {
  164. $scope.searchTypeKey = "";
  165. $scope.dicvalue = "";
  166. //$scope.selectparams.selectdzzmc = $scope.selectparams.dzzmc = $scope.selectparams.zzlb = $scope.selectparams.jczzfl = '';
  167. }
  168. });
  169. })();