'use strict'; app.controller('hc_consumablesCtrl', ["$scope", "$http", "i18nService", "$rootScope", "$state", "$timeout", "moment", "$interval", "$modal", "$stateParams", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", "api_text", "api_bpm_data", "api_user_data", "api_cmdb", "api_cmdb2", "api_cmdb3", "api_cmdb4","api_wechatfile","api_sysinfo", function($scope, $http, i18nService, $rootScope, $state, $timeout, moment, $interval, $modal, $stateParams, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain, api_text, api_bpm_data, api_user_data, api_cmdb, api_cmdb2, api_cmdb3, api_cmdb4,api_wechatfile,api_sysinfo) { $scope.ceshi = "耗材系统"; $scope.langs = i18nService.getAllLangs(); $scope.lang = 'zh-cn'; i18nService.setCurrentLang($scope.lang); $scope.myData = []; var loginUser = $rootScope.user; // 监听编辑在库数量 $scope.$watch('hc_eject_inventoryNum', function(val, oldval) { var zhengze = /^\w{0,5}$/; if (!zhengze.exec(val)) { $scope.hc_eject_inventoryNum = oldval; } }); $scope.fileData={ "idx":0, "sum":10, "consumable":{} } // 监听下拉框搜索 $scope.$watch('select_val.search_data', function(val) { // if (val == undefined) { // $scope.wt_data_display = true; // } else if (val.name == '全部') { // wt_data = { consumable: {} }; // $scope.wt_data_display = false; // if ($scope.fenye == undefined) { // $scope.fenye = 0 // }; // $scope.memoryfilterData = { // idx: $scope.fenye, // sum: 10 // } // //获取列表数据 // $scope.refreshData = function(style, filterData) { // // var data1={idx: 0, sum: 10}; // var pdKey = "consumable"; // $scope.myData = []; // api_cmdb3.fetchDataList(pdKey, filterData).then(function(data) { // // console.log(data.list); // if (data.list) { // var myData = Restangular.stripRestangular(data); // var list = []; // $scope.gridOptions['totalItems'] = myData.totalNum; // $scope.myData = myData.list; // for (var i = 0; i < $scope.myData.length; i++) { // $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum // } // } else { // SweetAlert.swal({ // title: "系统错误", // text: "请稍后再试!", // type: "error" // }); // } // $scope.ldloading[style.replace('-', '_')] = false; // }, function() { // $scope.ldloading[style.replace('-', '_')] = false; // }); // }; // $scope.refreshData('expand-right', $scope.memoryfilterData); // } else { // wt_data = { consumable: { "name": val.name } }; // $scope.wt_data_display = false; // if ($scope.fenye == undefined) { // $scope.fenye = 0 // }; // $scope.memoryfilterData = { // idx: $scope.fenye, // sum: 10, // consumable: { "name": val.name } // } // //获取列表数据 // $scope.refreshData = function(style, filterData) { // var pdKey = "consumable"; // $scope.myData = []; // // $scope.gridOptions['sum'] = filterData.sum; // api_cmdb3.fetchDataList(pdKey, filterData).then(function(data) { // // console.log(data.list); // if (data.list) { // var myData = Restangular.stripRestangular(data); // var list = []; // $scope.gridOptions['totalItems'] = myData.totalNum; // $scope.myData = myData.list; // for (var i = 0; i < $scope.myData.length; i++) { // $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum // } // } else { // SweetAlert.swal({ // title: "系统错误", // text: "请稍后再试!", // type: "error" // }); // } // $scope.ldloading[style.replace('-', '_')] = false; // }, function() { // $scope.ldloading[style.replace('-', '_')] = false; // }); // }; // $scope.refreshData('expand-right', $scope.memoryfilterData); // } if(val){ $scope.fileData.consumable["name"]=val.name; $scope.refreshData('expand-right', $scope.fileData); } }) $scope.new_data = function() { $scope.myData = []; $scope.refreshData('expand-right', $scope.memoryfilterData); } var pdKey = $state.current.pdKey; $rootScope.hc_eject_big = false; //编辑弹出框 $rootScope.hc_eject_sma = false; //编辑弹出框 $rootScope.hc_toedit = "new_top"; // 关闭编辑弹出框 $scope.close = function() { $rootScope.hc_eject_big = false; //编辑弹出框 $rootScope.hc_eject_sma = false; //编辑弹出框 $rootScope.hc_toedit = "new_top"; $scope.select_updata_name = {}; //编辑下拉框名称 $scope.select_updata_guige = {}; //编辑下拉框规格 $scope.select_updata_pinpai = {}; //编辑下拉框品牌 } $scope.select_updata_name = {}; //编辑下拉框名称 $scope.select_updata_guige = {}; //编辑下拉框规格 $scope.select_updata_pinpai = {}; //编辑下拉框品牌 // 名称 $scope.$watch('hc_eject_name_caozuo', function(val) { if (val != undefined) { // console.log(val); $scope.hc_eject_name = val; } }) // 下拉框名称 $scope.$watch('select_updata_name.updata_name', function(val) { // console.log(val); if (val == undefined) { } else { // $scope.hc_eject_name = val.name; // // 耗材查询品牌 // $scope.refreshDat_pinpai = function() { // var dat = { // "key": "pinpai", // parent: val.id // } // api_cmdb4.fetchDataList(dat).then(function(data) { // $scope.updata_pinpai = data; // }); // } // $scope.refreshDat_pinpai(); // // 耗材查询规格 // $scope.refreshDat_guige = function() { // var dat = { // "key": "guige", // parent: val.id // } // api_cmdb4.fetchDataList(dat).then(function(data) { // $scope.updata_guige = data; // }); // } // $scope.refreshDat_guige(); $scope.hc_eject_name = val.name; // 耗材查询品牌 $scope.refreshDat_pinpai = function() { var dat = { "dictionaryTree":{ "key": "pinpai", parent: val.id }, "idx":0, "sum":999 } api_sysinfo.fetchDataList("dictionaryTree",dat).then(function(data) { $scope.updata_pinpai = data; }); } $scope.refreshDat_pinpai(); // 耗材查询规格 $scope.refreshDat_guige = function() { // var dat = { // "key": "guige", // parent: val.id, // "type":"tree" // } // api_wechatfile.getDictionary(dat).then(function(data) { // $scope.updata_guige = data; // }); var dat = { "dictionaryTree":{ "key": "guige", parent: val.id }, "idx":0, "sum":999 } api_sysinfo.fetchDataList("dictionaryTree",dat).then(function(data) { $scope.updata_pinpai = data; }); } $scope.refreshDat_guige(); } }) // 规格 $scope.$watch('hc_eject_specification_caozuo', function(val) { $scope.hc_eject_specification = val; }) // 下拉框规格 $scope.$watch('select_updata_guige.updata_guige', function(val) { // console.log(val); if (val == undefined) { } else { $scope.hc_eject_specification = val.name; } }) // 品牌 $scope.$watch('hc_eject_brandModel_caozuo', function(val) { $scope.hc_eject_brandModel = val; }) // 下拉框品牌 $scope.$watch('select_updata_pinpai.updata_pinpai', function(val) { // console.log(val); if (val == undefined) { } else { $scope.hc_eject_brandModel = val.name; } }) // 在库数量 $scope.$watch('hc_eject_inventoryNum_caozuo', function(val) { $scope.hc_eject_inventoryNum = val; }) // 入库数量 $scope.$watch('hc_eject_inventorySum_caozuo', function(val) { $scope.hc_eject_inventorySum = val; }) $scope.reset=function(){ $scope.select_val={}; $scope.fileData.consumable={}; $scope.refreshData('expand-right', $scope.fileData); } // 编辑保存按钮 $scope.preservation = function() { if ($scope.add_virtualMachinesNum == '') { SweetAlert.swal({ title: "保存失败", text: "必填数据不能为空!", type: "error" }); } else { var pdKey = "consumable"; var edit_data = { "consumable": { "name": $scope.hc_eject_name, "brandModel": $scope.hc_eject_brandModel, "specification": $scope.hc_eject_specification, "inventoryNum": $scope.hc_eject_inventoryNum, "inventorySum": $scope.hc_eject_inventorySum, "id": $rootScope.hc_eject_id_caozuo } }; api_cmdb3.preservation(pdKey, edit_data).then(function(data) { if (data.status == 200) { // $scope.refreshData = function(style, filterData) { // var pdKey = "consumable"; // $scope.myData = []; // $scope.gridOptions['sum'] = filterData.sum; // api_cmdb3.fetchDataList(pdKey, filterData).then(function(data) { // // console.log(data.list); // if (data.list) { // var myData = Restangular.stripRestangular(data); // var list = []; // $scope.gridOptions['totalItems'] = myData.totalNum; // $scope.myData = myData.list; // for (var i = 0; i < $scope.myData.length; i++) { // $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum // } // } else { // SweetAlert.swal({ // title: "系统错误", // text: "请稍后再试!", // type: "error" // }); // } // $scope.ldloading[style.replace('-', '_')] = false; // }, function() { // $scope.ldloading[style.replace('-', '_')] = false; // }); // }; $scope.refreshData('expand-right', $scope.fileData); SweetAlert.swal({ title: "修改成功", confirmButtonColor: "#007AFF", type: "success" }); $rootScope.hc_eject_big = false; //编辑弹出框 $rootScope.hc_eject_sma = false; //编辑弹出框 $rootScope.hc_toedit = "new_top"; $scope.select_updata_name = {}; //编辑下拉框名称 $scope.select_updata_guige = {}; //编辑下拉框规格 $scope.select_updata_pinpai = {}; //编辑下拉框品牌 } }) } } $scope.gridOptions = {}; $scope.gridOptions.data = 'myData'; $scope.gridOptions.enableColumnResizing = true; $scope.gridOptions.enableFiltering = false; $scope.gridOptions.enableGridMenu = true; $scope.gridOptions.enableSelectAll = true; $scope.gridOptions.enableRowSelection = true; $scope.gridOptions.showGridFooter = true; $scope.gridOptions.showColumnFooter = false; $scope.gridOptions.fastWatch = true; $scope.gridOptions.enableSorting = true; $scope.gridOptions.useExternalSorting = true; $scope.gridOptions.useExternalFiltering = false; $scope.gridOptions.useExternalPagination = true; $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100]; $scope.gridOptions.paginationPageSize = 10; $scope.gridOptions.multiSelect = true; var mun = $scope.gridOptions.paginationPageSize; $scope.gridOptions.rowTemplate = "
"; $scope.gridOptions.rowIdentity = function(row) { return row.id; }; $scope.gridOptions.getRowIdentity = function(row) { return row.id; }; $scope.transferColor = function(item) { var color = "icon iconfont icon-zhengchang greenfont"; if (item.colourInfo) { if (item.colourInfo.id == 1) { color = "icon iconfont icon-yiyuqi redfont"; } else if (item.colourInfo.id == 2) { color = "iconfont icon-yuqixinxiu yellofont"; } } else { // color = "white"; } return color; } $scope.transfertip = function(item) { var tip = "正常"; if (item.colourInfo) { if (item.colourInfo.id == 1) { tip = "逾期"; } else if (item.colourInfo.id == 2) { tip = "即将逾期"; } } else { // color = "white"; } return tip; } $scope.transferstatus = function(item) { var statecolor = "#fc4c58"; if (item.id == 2) { //待处理 statecolor = "#fc4c58"; } else if (item.id == 7) { //待审核 statecolor = "#fcb44c"; } else if (item.id == 3) { //请求重新指派 statecolor = "#ebf902"; } else if (item.id == 4) { //处理中 statecolor = "#0aa5f5"; } else if (item.id == 5) { //已解决 statecolor = "#2edbb8"; } else if (item.id == 6) { //已关闭 statecolor = "#bbbbbb"; } return statecolor; } // 双击查看 $scope.onDblClick=function(row){ $state.go('app.means.consumables_see', { idd: row.entity.id }) } $scope.gridOptions.columnDefs = [{ name: 'item', displayName: '序号', width: 49, cellTemplate: '