123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- (function ($app) {
- $app.module('ylmis').controller('dictionaryCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, AuthUser, $bsRouterState) {
- $scope.dataList = [];
- $state.params = $bsRouterState.$params($scope);
- //初始化查询参数
- $scope.selectparams = {
- dictionaryName: '',
- name: '',
- dictionaryCode: '',
- pageIndex: 1,
- pageSize: 10,
- };
- $scope.pageInfo = { ptotal: 0 };
- //监视页数变化
- $scope.$watch("selectparams.pageIndex", function (newVal, oldVal) {
- if ($scope.pageInfo.ptotal > 0) {
- $scope.loadData();
- }
- });
- //查询
- $scope.search = function () {
- $scope.loadData();
- };
- //加载列表数据
- $scope.loadData = function () {
- $http
- ({
- method: 'post', url: '../../api/systemsetting/Dictionary/GetList', data: $scope.selectparams
- }).then(function (result) {
- $scope.dataList = result.data.Data.rows;
- $scope.pageInfo.ptotal = result.data.Data.total;
- });
- };
- $scope.showMsg = function (title, content) {
- $alert({
- title: title + ':',
- content: content,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- };
- $scope.addDic = function () {
- $scope.edit(null, '新增字典元素');
- };
- $scope.editDic = function (dicID) {
- $scope.edit(dicID, '修改字典元素');
- };
- $scope.delDic = function () {
- if (confirm("是否要删除该字典元素?")) {
- var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.DictionaryItemID; });
- if (ids.length <= 0) {
- $scope.showMsg("消息", "请选择需要删除的数据");
- return false;
- }
- $http.post('../../api/systemsetting/Dictionary/Delete', { dicItemIDs: ids }).then(function (res) {
- if (res.data.IsSuccess) {
- $scope.loadData();
- $scope.showMsg('成功', '删除成功');
- } else {
- $scope.showMsg('错误', res.data.Message);
- }
- });
- }
- };
- $scope.editData = {};
- $scope.edit = function (id, title) {
- $scope.editData.params = {
- dicItemID: id,
- title: title
- };
- $scope.editData.parentLoad = $scope.loadData;
- editModal.$promise.then(editModal.show);
- };
- //定义模态框
- var editModal = $modal({
- resolve: {
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
- return $ocLazyLoad.load('systemsetting/dictionary/edit.js?' + window.sysVersion);
- }]
- },
- scope: $scope,
- controller: 'editDictionaryCtrl',
- templateUrl: '../main/systemsetting/dictionary/edit.html',
- show: false,
- animation: 'am-fade-and-slide-top'
- });
- $scope.loadData();
- });
- })(angular);
|