app.controller('informationcateCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "Restangular", "api_bpm_data", "api_solution","api_wechatfile","api_sysinfo", function($rootScope, $scope, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, Restangular, api_bpm_data, api_solution,api_wechatfile,api_sysinfo) { // $scope.langs=i18nService.getAllLangs(); $scope.lang = 'zh-cn'; var loginUser = $rootScope.user; var i = 0; $scope.out = []; $scope.outdata = []; var systemtype = []; $scope.addcate = false; $scope.changecate = false; $scope.addType = function(element) { $scope.addcate = true $scope.changecate = false } $scope.remove = function(data1) { if(data1){ var modalInstance = $modal.open({ templateUrl: 'assets/views/delete.html', controller: function($scope, scope, $modalInstance, api_bpm_data) { $scope.title = "服务指南分类删除?"; $scope.connect = "确定要删除此服务指南分类?"; $scope.ok = function() { $modalInstance.close(data1); }; $scope.cancel = function() { $modalInstance.dismiss('cancel'); }; }, size: 'sm', resolve: { scope: function() { return $scope; } } }); modalInstance.result.then(function(selectedItem) { selectedItem.deleted=true; api_sysinfo.addData('dictionary',selectedItem).then(function(res){ if(res.status==200){ SweetAlert.swal({ title: "删除成功!", type: "success", confirmButtonColor: "#007AFF" }, function() { $scope.getListData(); }); }else{ SweetAlert.swal({ title: "系统错误", text: "系统错误,请稍后重试!", type: "error", confirmButtonColor: "#DD6B55" }, function() { $scope.getListData(); }); } }) }) }else{ SweetAlert.swal({ title: "操作失败", text: "请选择需要删除的选项!", type: "error", confirmButtonColor: "#DD6B55" }) } } var childdata = {}; $scope.subdata = {}; $scope.listData=[]; $scope.listIdx=-1; $scope.selectData=""; $scope.addCategory=""; $scope.changeValue=""; $scope.getListData=function(){ var data={ "key":"service_type", "type":"list" } api_wechatfile.getDictionary(data).then(function(res){ $scope.listData=res }) } $scope.getListData(); $scope.listSelect=function(data,idx){ $scope.listIdx=idx; $scope.changecate = true; $scope.addcate = false; $scope.selectData=data; $scope.changeValue=data.name } $scope.parentdata = {}; $scope.cancel = function() { $scope.userdata = []; $scope.outdata = []; }; //修改 $scope.submitchange = function(data1,data2) { if(data1){ data2.name=data1; api_sysinfo.addData('dictionary',data2).then(function(res){ if(res.status==200){ SweetAlert.swal({ title: "修改成功!", type: "success", confirmButtonColor: "#007AFF" }, function() { $scope.getListData(); }); }else{ SweetAlert.swal({ title: "系统错误", text: "系统错误,请稍后重试!", type: "error", confirmButtonColor: "#DD6B55" }, function() { $scope.getListData(); }); } }) }else{ SweetAlert.swal({ title: "修改失败", text: "修改值不能为空!", type: "error", confirmButtonColor: "#DD6B55" }); } }; //新增 $scope.submitadd = function(data1) { if(data1){ var data={ deleted:false, "key":"service_type", "name":data1, "orders":0, "system":false, }; api_sysinfo.addData('dictionary',data).then(function(res){ if(res.status==200){ SweetAlert.swal({ title: "新增成功!", type: "success", confirmButtonColor: "#007AFF" }, function() { $scope.getListData(); }); }else{ SweetAlert.swal({ title: "系统错误", text: "系统错误,请稍后重试!", type: "error", confirmButtonColor: "#DD6B55" }); } }) }else{ SweetAlert.swal({ title: "新增失败", text: "新增值不能为空!", type: "error", confirmButtonColor: "#DD6B55" }); } } }]);