123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529 |
- app.controller('hc_flwhCtrl', ["$rootScope", "$scope", "$http", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data","api_cmdb4","api_wechatfile", function($rootScope, $scope, $http, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data,api_cmdb4,api_wechatfile) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- $scope.cancles = true;
- var loginUser = $rootScope.user;
- var fildata = { "idx": 0, "sum": 1000 };
- $scope.choice = false;
- $scope.backcolor = [];
- $scope.outarea = [];
- $scope.outplace = [];
- $scope.pla = {};
- $scope.areaid = {};
- $scope.areaname = "";
- $scope.areaplace = true;
- $scope.freshenarea = function() {
- api_user_data.fetchDataList('area', fildata).then(function(response) {
- if (response) {
- if (response.status = 200) {
- $scope.outarea = response.list;
- }
- }
- })
- }
- $scope.freshenarea();
- $scope.freshenplace = function(id) {
- if (id) {
- var fildata = { "idx": 0, "sum": 1000, "place": { areaId: id } };
- api_user_data.fetchDataList('place', fildata).then(function(response) {
- if (response) {
- if (response.status = 200) {
- $scope.outplace = response.list;
- }
- }
- })
- }
- }
- $scope.ckickrow = function(data) {
- $scope.choice = false;
- $scope.areaid = data.id;
- $scope.areaname = data.area;
- $scope.areaplace = true;
- if (data.id) {
- $scope.freshenplace(data.id);
- // var fildata={"idx":0,"sum":1000,"place":{areaId:data.id}};
- // api_user_data.fetchDataList('place',fildata).then(function(response){
- // if(response){
- // if(response.status=200){
- // $scope.outplace= response.list;
- // }
- // }
- // })
- } else {}
- }
- $scope.clickplace = function(pla) {
- $scope.areaplace = false;
- $scope.pla = pla
- }
- $scope.name_shuzu=[];
- $scope.pinpai_shuzu=[];
- $scope.guige_shuzu=[];
- $scope.name_show=false;
- $scope.pinpai_show=false;
- $scope.guige_show=false;
- //耗材名称编辑
- $scope.name_edit=function(){
- $scope.name_show=true;
- }
- // 名称取消
- $scope.name_quxiao=function(){
- $scope.name_show=false;
- }
- // 耗材名称分类
- $scope.refreshDat_name = function () {
- var dat = {
- "key":"haocaifenlei",
- "type":"list"
- }
- api_cmdb4.fetchDataList(dat).then(function (data) {
- $scope.names=data;
- // console.log($scope.names);
- });
- };
- //点击耗材名称,查询品牌型号和规格
- $scope.clickname=function(res,index){
- $scope.index=index;
- if(res.id!=''&&res.id!=undefined){
- $scope.panduan="修改";
- $scope.tit=res.name;
- $scope.ids=res.id;
- //品牌型号
- var dat={
- "key":"pinpai",
- "parent":res.id
- }
- api_cmdb4.fetchDataList(dat).then(function (data) {
- $scope.xinghaos=data;
- // console.log($scope.xinghaos)
- });
- //规格
- var dat1={
- "key":"guige",
- "parent":res.id
- }
- api_cmdb4.fetchDataList(dat1).then(function (data) {
- $scope.guiges=data;
- });
- }else{
- $scope.panduan="新增";
- $scope.tit='';
- $scope.ids=''
- }
- }
- //名称新增按钮
- $scope.add_name=function(){
- $scope.names.unshift({name:"添加名称"});
- }
- //型号新增按钮
- $scope.add_xinghao=function(){
- if($scope.tit==''||$scope.tit==undefined){
- SweetAlert.swal({
- title: "新增失败",
- text: "请先选择名称!",
- type: "error"
- });
- }else{
- $scope.xinghaos.unshift({name:"添加型号"})
- }
- }
- // 规格新增按钮
- $scope.add_guige=function(){
- if($scope.tit==''||$scope.tit==undefined){
- SweetAlert.swal({
- title: "新增失败",
- text: "请先选择名称!",
- type: "error"
- });
- }else{
- $scope.guiges.unshift({name:"添加规格"})
- }
- }
- //名称编辑完成
- $scope.name_wancheng=function(res){
- for(var k=0;k<$scope.names.length;k++){
- $scope.name_shuzu.push($scope.names[k].name)
- }
- if($scope.ids!=''&&$scope.ids!=undefined){
- if($scope.name_ipt[res]==''||$scope.name_ipt[res]==undefined){
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值不能为空!",
- type: "error"
- });
- }else{
- if($scope.name_shuzu.indexOf($scope.name_ipt[res])!==-1){
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值已存在!",
- type: "error"
- });
- }else{
- var dat1={
- "id":$scope.ids,
- "type": "list",
- "name": $scope.name_ipt[res],
- "value": "1",
- }
- api_cmdb4.upDictionary(dat1).then(function (data) {
- $scope.name_show=false;
- $scope.refreshDat_name();
- });
- $scope.name_shuzu=[];
- SweetAlert.swal({
- title: "修改成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- }
- }
- }else{
- if($scope.name_ipt[res]==''||$scope.name_ipt[res]==undefined){
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值不能为空!",
- type: "error"
- });
- }else{
- if($scope.name_shuzu.indexOf($scope.name_ipt[res])!==-1){
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值已存在!",
- type: "error"
- });
- }else{
- var dat={
- "key":"haocaifenlei",
- "name":$scope.name_ipt[res],
- "type":"list",
- "value":1
- }
- api_cmdb4.addDictionary(dat).then(function (data) {
- $scope.name_show=false;
- $scope.refreshDat_name();
- });
- $scope.name_shuzu=[];
- SweetAlert.swal({
- title: "新增成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- }
- }
- }
- }
- // 名称删除
- $scope.name_del=function(res){
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- var dat1={
- "id":res.id,
- "deleted":true
- }
- api_cmdb4.upDictionary(dat1).then(function (data) {
- $scope.refreshDat_name();
- });
- $scope.tit='';
- $scope.ids='';
- SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- }
- //品牌编辑
- $scope.pinpai_edit=function(res,index){
- $scope.pinpai_index=index;
- if(res.id!=''&&res.id!=undefined){
- $scope.pinpai_panduan="修改";
- $scope.pinpai_ids=res.id;
- }else{
- $scope.pinpai_panduan="新增";
- $scope.pinpai_ids='';
- }
- $scope.pinpai_show=true;
- }
- // 品牌取消
- $scope.pinpai_quxiao=function(){
- $scope.pinpai_show=false;
- }
- //品牌完成
- $scope.pinpai_wancheng=function(res){
- for(var k=0;k<$scope.xinghaos.length;k++){
- $scope.pinpai_shuzu.push($scope.xinghaos[k].name)
- }
- if($scope.pinpai_ids!=''&&$scope.pinpai_ids!=undefined){
- if($scope.pinpai_ipt[res]==''||$scope.pinpai_ipt[res]==undefined){
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值不能为空!",
- type: "error"
- });
- }else{
- if($scope.pinpai_shuzu.indexOf($scope.pinpai_ipt[res])!==-1){
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值已存在!",
- type: "error"
- });
- }else{
- var dat1={
- "id":$scope.pinpai_ids,
- "type": "list",
- "name": $scope.pinpai_ipt[res],
- "value": "1",
- }
- api_cmdb4.upDictionary(dat1).then(function (data) {
- $scope.pinpai_show=false;
- //品牌型号
- var dat2={
- "key":"pinpai",
- "parent":$scope.ids
- }
- api_cmdb4.fetchDataList(dat2).then(function (data) {
- $scope.xinghaos=data;
- });
- });
- $scope.pinpai_shuzu=[];
- SweetAlert.swal({
- title: "修改成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- }
- }
- }else{
- if($scope.pinpai_ipt[res]==''||$scope.pinpai_ipt[res]==undefined){
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值不能为空!",
- type: "error"
- });
- }else{
- if($scope.pinpai_shuzu.indexOf($scope.pinpai_ipt[res])!==-1){
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值已存在!",
- type: "error"
- });
- }else{
- var dat={
- "key":"pinpai",
- "name":$scope.pinpai_ipt[res],
- "type":"list",
- "value":1,
- "parent":$scope.ids
- }
- api_cmdb4.addDictionary(dat).then(function (data) {
- $scope.pinpai_show=false;
- //品牌型号
- var dat1={
- "key":"pinpai",
- "parent":$scope.ids
- }
- api_cmdb4.fetchDataList(dat1).then(function (data) {
- $scope.xinghaos=data;
- });
- });
- $scope.pinpai_shuzu=[];
- SweetAlert.swal({
- title: "新增成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- }
- }
- }
- }
- //品牌删除
- $scope.pinpai_del=function(res){
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- var dat1={
- "id":res.id,
- "deleted":true
- }
- api_cmdb4.upDictionary(dat1).then(function (data) {
- api_cmdb4.upDictionary(dat1).then(function (data) {
- $scope.pinpai_show=false;
- //品牌型号
- var dat2={
- "key":"pinpai",
- "parent":$scope.ids
- }
- api_cmdb4.fetchDataList(dat2).then(function (data) {
- $scope.xinghaos=data;
- });
- });
- });
- SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- }
- // 规格编辑
- $scope.guige_edit=function(res,index){
- $scope.guige_index=index;
- if(res.id!=''&&res.id!=undefined){
- $scope.guige_panduan="修改";
- $scope.guige_ids=res.id;
- }else{
- $scope.guige_panduan="新增";
- $scope.guige_ids='';
- }
- $scope.guige_show=true;
- }
- // 规格取消
- $scope.guige_quxiao=function(){
- $scope.guige_show=false;
- }
- //规格完成
- $scope.guige_wancheng=function(res){
- for(var k=0;k<$scope.guiges.length;k++){
- $scope.guige_shuzu.push($scope.guiges[k].name)
- }
- if($scope.guige_ids!=''&&$scope.guige_ids!=undefined){
- if($scope.guige_ipt[res]==''||$scope.guige_ipt[res]==undefined){
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值不能为空!",
- type: "error"
- });
- }else{
- if($scope.guige_shuzu.indexOf($scope.guige_ipt[res])!==-1){
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值已存在!",
- type: "error"
- });
- }else{
- var dat1={
- "id":$scope.guige_ids,
- "type": "list",
- "name": $scope.guige_ipt[res],
- "value": "1",
- }
- api_cmdb4.upDictionary(dat1).then(function (data) {
- $scope.guige_show=false;
- //品牌型号
- var dat2={
- "key":"guige",
- "parent":$scope.ids
- }
- api_cmdb4.fetchDataList(dat2).then(function (data) {
- $scope.guiges=data;
- });
- });
- $scope.guige_shuzu=[];
- SweetAlert.swal({
- title: "修改成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- }
- }
- }else{
- if($scope.guige_ipt[res]==''||$scope.guige_ipt[res]==undefined){
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值不能为空!",
- type: "error"
- });
- }else{
- if($scope.guige_shuzu.indexOf($scope.guige_ipt[res])!==-1){
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值已存在!",
- type: "error"
- });
- }else{
- var dat={
- "key":"guige",
- "name":$scope.guige_ipt[res],
- "type":"list",
- "value":1,
- "parent":$scope.ids
- }
- api_cmdb4.addDictionary(dat).then(function (data) {
- $scope.guige_show=false;
- //品牌型号
- var dat1={
- "key":"guige",
- "parent":$scope.ids
- }
- api_cmdb4.fetchDataList(dat1).then(function (data) {
- $scope.guiges=data;
- });
- });
- $scope.guige_shuzu=[];
- SweetAlert.swal({
- title: "新增成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- }
- }
- }
- }
- //规格删除
- $scope.guige_del=function(res){
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- var dat1={
- "id":res.id,
- "deleted":true
- }
- api_cmdb4.upDictionary(dat1).then(function (data) {
- api_cmdb4.upDictionary(dat1).then(function (data) {
- $scope.guige_show=false;
- //品牌型号
- var dat2={
- "key":"guige",
- "parent":$scope.ids
- }
- api_cmdb4.fetchDataList(dat2).then(function (data) {
- $scope.guiges=data;
- });
- });
- });
- SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- }
- $scope.refreshDat_name();
- }]);
|