list.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. (function ($app) {
  2. $app.module('ylmis').controller('dictionaryCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, AuthUser, $bsRouterState) {
  3. $scope.dataList = [];
  4. $state.params = $bsRouterState.$params($scope);
  5. //初始化查询参数
  6. $scope.selectparams = {
  7. dictionaryName: '',
  8. name: '',
  9. dictionaryCode: '',
  10. pageIndex: 1,
  11. pageSize: 10,
  12. };
  13. $scope.pageInfo = { ptotal: 0 };
  14. //监视页数变化
  15. $scope.$watch("selectparams.pageIndex", function (newVal, oldVal) {
  16. if ($scope.pageInfo.ptotal > 0) {
  17. $scope.loadData();
  18. }
  19. });
  20. //查询
  21. $scope.search = function () {
  22. $scope.loadData();
  23. };
  24. //加载列表数据
  25. $scope.loadData = function () {
  26. $http
  27. ({
  28. method: 'post', url: '../../api/systemsetting/Dictionary/GetList', data: $scope.selectparams
  29. }).then(function (result) {
  30. $scope.dataList = result.data.Data.rows;
  31. $scope.pageInfo.ptotal = result.data.Data.total;
  32. });
  33. };
  34. $scope.showMsg = function (title, content) {
  35. $alert({
  36. title: title + ':',
  37. content: content,
  38. placement: 'top',
  39. type: 'info',
  40. show: true,
  41. duration: 3
  42. });
  43. };
  44. $scope.addDic = function () {
  45. $scope.edit(null, '新增字典元素');
  46. };
  47. $scope.editDic = function (dicID) {
  48. $scope.edit(dicID, '修改字典元素');
  49. };
  50. $scope.delDic = function () {
  51. if (confirm("是否要删除该字典元素?")) {
  52. var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.DictionaryItemID; });
  53. if (ids.length <= 0) {
  54. $scope.showMsg("消息", "请选择需要删除的数据");
  55. return false;
  56. }
  57. $http.post('../../api/systemsetting/Dictionary/Delete', { dicItemIDs: ids }).then(function (res) {
  58. if (res.data.IsSuccess) {
  59. $scope.loadData();
  60. $scope.showMsg('成功', '删除成功');
  61. } else {
  62. $scope.showMsg('错误', res.data.Message);
  63. }
  64. });
  65. }
  66. };
  67. $scope.editData = {};
  68. $scope.edit = function (id, title) {
  69. $scope.editData.params = {
  70. dicItemID: id,
  71. title: title
  72. };
  73. $scope.editData.parentLoad = $scope.loadData;
  74. editModal.$promise.then(editModal.show);
  75. };
  76. //定义模态框
  77. var editModal = $modal({
  78. resolve: {
  79. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  80. return $ocLazyLoad.load('systemsetting/dictionary/edit.js?' + window.sysVersion);
  81. }]
  82. },
  83. scope: $scope,
  84. controller: 'editDictionaryCtrl',
  85. templateUrl: '../main/systemsetting/dictionary/edit.html',
  86. show: false,
  87. animation: 'am-fade-and-slide-top'
  88. });
  89. $scope.loadData();
  90. });
  91. })(angular);