edit.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. (function ($app) {
  2. $app.module('ylmis').controller('editDictionaryCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, AuthUser, $bsRouterState) {
  3. $scope.params = $scope.$parent.$parent.editData.params;
  4. $scope.parentLoad = $scope.$parent.$parent.editData.parentLoad;
  5. $scope.dicItem = {};
  6. $scope.readonly = false;
  7. $scope.selectDictionaryParams = {
  8. url: '../../api/systemsetting/Dictionary/GetDicListForSelect',
  9. isMulti: false,
  10. selectData: { code: '代码', name: '名称' },
  11. columns: { DictionaryCode: '代码', Name: '名称' },
  12. selectLabelKey: 'DictionaryCode',
  13. selectValuekey: 'DictionaryCode',
  14. selectedValueData: '',
  15. selectedLabeData: '',
  16. selectedJData: [],
  17. selectParams: {
  18. }
  19. };
  20. $scope.$watch('selectDictionaryParams.selectedValueData', function (newVal) {
  21. if (newVal != '' && newVal != undefined) {
  22. $scope.dicItem.DictionaryCode = newVal;
  23. }
  24. });
  25. $scope.loadData = function () {
  26. $loading.show();
  27. $http({
  28. method: "post",
  29. url: "../../api/systemsetting/Dictionary/GetDicItem",
  30. data: {
  31. dicItemID: $scope.params.dicItemID
  32. }
  33. }).then(function (result) {
  34. $loading.hide();
  35. $scope.dicItem = result.data.Data;
  36. $scope.selectDictionaryParams.selectedLabeData = $scope.dicItem.DictionaryCode;
  37. });
  38. }
  39. $scope.saveData = function (isflag) {
  40. if (isflag) {
  41. $loading.show();
  42. $http({
  43. method: "post",
  44. url: "../../api/systemsetting/Dictionary/EditDicItem",
  45. data: {
  46. dicItem: $scope.dicItem
  47. }
  48. }).then(function (result) {
  49. $loading.hide();
  50. if (result.data.IsSuccess) {
  51. $scope.showMsg('成功', '保存成功。');
  52. //重新刷新列表
  53. $scope.parentLoad();
  54. $scope.$hide();
  55. } else {
  56. $scope.showMsg('成功', result.data.Message);
  57. }
  58. }, function (resp) {
  59. $loading.hide();
  60. $scope.showMsg('错误', '服务器错误');
  61. });
  62. }
  63. }
  64. if ($scope.params.dicItemID) {
  65. $scope.loadData();
  66. $scope.readonly = $scope.dicItem.IsEditable;
  67. }
  68. });
  69. })(angular);