123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- var editAnnounceCtrl = function ($scope, $http, $filter, $loading) {
- $scope.params = announceModal.params;
- $scope.parentLoad = announceModal.parentLoad;
- $scope.announce = {};
- $scope.roleList = [];
- $scope.userList = [];
- $scope.selectRoleParams = {
- url: '../../api/systemsetting/Role/GetRolesForSelect',
- isMulti: true,
- selectData: { roleName: '角色名称' },
- columns: { RoleName: '角色名称', Description: '说明' },
- selectLabelKey: 'RoleName',
- selectValuekey: 'RoleID',
- selectedValueData: '',
- selectedLabeData: '',
- selectedJData: [],
- selectParams: {
- }
- };
- $scope.selectUserParams = {
- url: '../../api/systemsetting/Account/GetUsersForSelect',
- isMulti: true,
- selectData: { loginID: '登录账号', name: '姓名' },
- columns: { LoginID: '登录账号', Name: '姓名', SexName: '性别' },
- selectLabelKey: 'Name',
- selectValuekey: 'UserID',
- selectedValueData: '',
- selectedLabeData: '',
- selectedJData: [],
- selectParams: {
- }
- };
- $scope.$watch('selectRoleParams.selectedValueData', function (newVal) {
- if (newVal != '' && newVal != undefined) {
- angular.forEach($scope.selectRoleParams.selectedJData, function (val) {
- if ($filter('filter')($scope.roleList, { RoleID: val.RoleID }).length == 0) {
- $scope.roleList.push({
- RoleID: val.RoleID,
- RoleName: val.RoleName,
- Description: val.Description,
- rowChecked: false
- });
- }
- });
- }
- });
- $scope.$watch('selectUserParams.selectedValueData', function (newVal) {
- if (newVal != '' && newVal != undefined) {
- angular.forEach($scope.selectUserParams.selectedJData, function (val) {
- if ($filter('filter')($scope.userList, { UserID: val.UserID }).length == 0) {
- $scope.userList.push({
- UserID: val.UserID,
- LoginID: val.LoginID,
- Name: val.Name,
- Sex: val.Sex,
- SexName: val.SexName,
- rowChecked: false
- });
- }
- });
- }
- });
- $scope.delRole = function () {
- if (confirm('是否确定删除发布角色?')) {
- for (var i = $scope.roleList.length - 1; i >= 0; i--) {
- if ($scope.roleList[i].rowChecked) {
- $scope.roleList.splice(i, 1);
- }
- }
- }
- }
- $scope.delUser = function () {
- if (confirm('是否确定删除发布用户?')) {
- for (var i = $scope.userList.length - 1; i >= 0; i--) {
- if ($scope.userList[i].rowChecked) {
- $scope.userList.splice(i, 1);
- }
- }
- }
- }
- $scope.loadData = function () {
- $loading.show();
- $http({
- method: "post",
- url: "../../api/systemsetting/Announce/GetAnnouncement",
- data: {
- announceID: $scope.params.announceID
- }
- }).then(function (result) {
- $loading.hide();
- $scope.announce = result.data.Data;
- });
- }
- $scope.loadRoleList = function () {
- $loading.show();
- $http({
- method: "post",
- url: "../../api/systemsetting/Announce/AnnounceRoleList",
- data: {
- announceID: $scope.params.announceID
- }
- }).then(function (result) {
- $loading.hide();
- $scope.roleList = angular.forEach(result.data.Data, function (x) { x = angular.extend(x, { rowChecked: false }) });
- });
- }
- $scope.loadUserList = function () {
- $loading.show();
- $http({
- method: "post",
- url: "../../api/systemsetting/Announce/AnnounceUserList",
- data: {
- announceID: $scope.params.announceID
- }
- }).then(function (result) {
- $loading.hide();
- $scope.userList = angular.forEach(result.data.Data, function (x) { x = angular.extend(x, { rowChecked: false }) });
- });
- }
- if ($scope.params.announceID) {
- $scope.loadData();
- $scope.loadUserList();
- $scope.loadRoleList();
- }
- $scope.saveData = function (isflag) {
- if (isflag) {
- $loading.show();
- var url = "../../api/systemsetting/Announce/Add";
- if ($scope.announce.AnnouncementID) {
- url = "../../api/systemsetting/Announce/Edit";
- }
- $http({
- method: "post",
- url: url,
- data: {
- announce: $scope.announce,
- roleList: $scope.roleList,
- userList: $scope.userList
- }
- }).then(function (result) {
- $loading.hide();
- if (result.data.IsSuccess) {
- $scope.showMsg('成功', '保存成功。');
- //重新刷新列表
- $scope.parentLoad();
- $scope.$hide();
- } else {
- $scope.showMsg('成功', result.data.Message);
- }
- }, function (resp) {
- $loading.hide();
- $scope.showMsg('错误', '服务器错误');
- });
- }
- }
- };
- //定义模态框
- var announceModal;
|