123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809 |
- '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 = "<div ng-click=\"onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $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: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
- '</div>'
- },
- {
- name: 'name',
- displayName: '耗材分类',
- width: '14%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.name}}</div>' +
- '</div>'
- },
- {
- name: 'brandModel',
- displayName: '品牌型号',
- width: '14%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.brandModel}}</div>' +
- '</div>'
- },
- {
- name: 'specification',
- displayName: '规格',
- width: '14%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.specification}}</div>' +
- '</div>'
- },
- {
- name: 'inventoryNum',
- displayName: '在库数量',
- width: '12%',
- minWidth: '120',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.inventoryNum}}</div>' +
- '</div>'
- },
- {
- name: 'inventorySum',
- displayName: '入库总数量',
- width: '14%',
- minWidth: '120',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.inventorySum}}</div>' +
- '</div>'
- },
- {
- name: 'updateTime',
- displayName: '最后更新时间',
- width: '14%',
- minWidth: '160',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.updateTime)}}</div>' +
- '</div>'
- },
- {
- name: '操作',
- enableSorting: false,
- minWidth: 120,
- cellTemplate: '<wtt style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
- enableFiltering: false
- },
- ];
- $scope.value = 10;
- $scope.decrement = function() {
- $scope.value = $scope.value - 1;
- };
- $scope.transferTime = function(time) {
- return moment(time).format('YYYY-MM-DD HH:mm');
- }
- $scope.record = function() {
- api_text.record($rootScope.takes).then(function(data) {
- if (data.errno == 0) {
- $scope.busy = false;
- }
- })
- };
- $scope.parameters = null;
- $scope.open = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $scope.endOpen = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- $scope.startOpen = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- $scope.othcode = {};
- var items = [];
- $scope.selected = {
- items: []
- };
- $scope.select_val = {}; //下拉框查询
- //列表排序
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- var index = 0;
- var oldheader = {};
- gridApi.grid.sortColumn = function(gridApi) {
- if (oldheader.field) {
- if (oldheader.field == gridApi.field) {
- // index = 0;
- } else {
- index = 0;
- }
- }
- index++;
- oldheader = gridApi;
- var fildata = $scope.memoryfilterData;
- if (index % 3 == 0) {
- delete $scope.memoryfilterData.incident;
- fildata = $scope.memoryfilterData;
- } else if (index % 3 == 1) {
- if (fildata.incident) {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata.incident, { "sort": gridApi.field });
- } else {
- angular.extend(fildata.incident, { "sort": gridApi.field + " desc , _incident.acceptDate" });
- }
- } else {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata, { 'incident': { "sort": gridApi.field } });
- } else {
- angular.extend(fildata, { 'incident': { "sort": gridApi.field + " desc , _incident.acceptDate" } });
- }
- }
- } else if (index % 3 == 2) {
- if (fildata.incident) {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata.incident, { "sort": gridApi.field, "order": "asc" });
- } else {
- angular.extend(fildata.incident, { "sort": gridApi.field + " asc , _incident.acceptDate" });
- }
- } else {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata, { 'incident': { "sort": gridApi.field, "order": "asc" } });
- } else {
- angular.extend(fildata.incident, { "sort": gridApi.field + " asc , _incident.acceptDate" });
- }
- }
- }
- $scope.refreshData('expand-right', $scope.fileData);
- }
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- $scope.fenye = newPage - 1;
- filtersData.idx = newPage - 1;
- $scope.fileData.idx=newPage - 1;
- filtersData.sum = pageSize;
- $scope.fileData.sum=pageSize;
- $scope.refreshData('expand-right', $scope.fileData);
- });
- gridApi.core.on.filterChanged($scope, function() {
- var grid = this.grid;
- if ($rootScope.user.group) {
- var filtersData = {
- idx: 0,
- sum: mun
- };
- } else {
- var filtersData = {
- idx: 0,
- sum: mun
- };
- }
- angular.forEach(grid.columns, function(item) {
- if (item.enableFiltering) {
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- filtersData = $scope.memoryfilterData
- if (angular.isUndefined(filtersData['incident'])) {
- filtersData['incident'] = {};
- }
- if (item.field == 'requester.name') {
- filtersData['incident']['requester'] = {};
- filtersData.incident.requester['accountName'] = item.filters[0].term;
- } else if (item.field == 'handlingPersonnelUser.name') {
- filtersData['incident']['handlingPersonnelUser'] = {};
- filtersData.incident.handlingPersonnelUser['name'] = item.filters[0].term;
- } else if (item.field == 'requester.account') {
- filtersData['incident']['requester'] = {};
- filtersData.incident.requester['account'] = item.filters[0].term;
- } else if (item.field == 'acceptUser.name') {
- filtersData['incident']['acceptUser'] = {};
- filtersData.incident.acceptUser['name'] = item.filters[0].term;
- } else {
- filtersData['incident'][item.field] = item.filters[0].term;
- }
- }
- }
- });
- filtersData.idx = 0;
- $scope.memoryfilterData = filtersData;
- $scope.refreshData('expand-right', $scope.fileData);
- });
- };
- var items = [];
- //当前人是否分组
- if ($rootScope.user.group) {
- if ($rootScope.user.group.length == 0) {
- SweetAlert.swal("访问失败!", "当前登录人未分配工作组,无权限访问,请添加工作组后重试。", "error");
- } else {
- $scope.memoryfilterData = defaultFilterData = {
- "idx": 0,
- "sum": mun
- };
- }
- } else {
- $scope.memoryfilterData = defaultFilterData = {
- "idx": 0,
- "sum": mun
- };
- }
- var wt_data = {};
- //导出
- $scope.hc_export = function() {
- if ($scope.wt_data_display == true) {
- SweetAlert.swal({
- title: "导出失败",
- text: "请选择分类!",
- type: "error"
- });
- } else {
- var filadata = angular.copy($scope.memoryfilterData);
- filadata.sum = 10000;
- var wt_url = api_cmdb3.exportData("downDataModel/consumable/1", wt_data).getRequestedUrl()
- $http({
- url: wt_url,
- method: 'POST',
- data: JSON.stringify(wt_data),
- headers: {
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- var file = new Blob([data], {
- type: 'application/vnd.ms-excel'
- });
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = '耗材列表.xls';
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- console.log(data);
- });
- }
- };
- if ($stateParams.model) {
- if (JSON.parse($stateParams.model).searchType && JSON.parse($stateParams.model).searchType != null) {
- $scope.searchTypes = JSON.parse($stateParams.model).searchType;
- } else {
- $scope.searchTypes = "todo";
- }
- } else {
- $scope.searchTypes = "todo";
- }
- if ($rootScope.user.group) {
- var defaultFilterData = {
- "idx": 0,
- "sum": mun
- };
- } else {
- var defaultFilterData = {
- "idx": 0,
- "sum": mun
- };
- }
- if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.incident)) {
- defaultFilterData['searchType'] = $rootScope.search.incident;
- $scope.searchTypes = $rootScope.search.incident;
- }
- if ($rootScope['cmdbs'] != 'incident') { $rootScope.idx = 1 }
- if (angular.isDefined($rootScope.idx) && $rootScope.cmdbs != "false") {
- $rootScope['cmdbs'] = 'incident';
- defaultFilterData.idx = $rootScope.idx - 1;
- } else { $rootScope.cmdbs = ""; }
- $scope.ldloading = {};
- //获取列表数据
- var pdKey = "consumable";
- $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.refreshData2 = 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.refreshDat_name = function() {
- // var dat = {
- // "key": "haocaifenlei",
- // }
- // api_cmdb4.fetchDataList(dat).then(function(data) {
- // $scope.search_data = data;
- // $scope.search_data.unshift({ 'name': '全部' });
- // });
- var dat = {
- "key": "haocaifenlei",
- "type":"tree"
- }
- api_wechatfile.getDictionary(dat).then(function(data) {
- $scope.search_data = data;
- // $scope.search_data.unshift({ 'name': '全部' });
- });
- };
- // 耗材查询分类修改
- $scope.refreshDat_name_updata = function() {
- var dat = {
- "key": "haocaifenlei",
- "type":"tree"
- }
- api_wechatfile.getDictionary(dat).then(function(data) {
- $scope.updata_name = data;
- });
- };
- $scope.refreshDat_name();
- $scope.refreshDat_name_updata();
- // $scope.refreshDat_pinpai();
- // $scope.refreshDat_guige();
- $scope.refreshData('expand-right', $scope.fileData);
- $scope.timer=$interval(function(){
- $scope.refreshData2('expand-right', $scope.fileData);
- },$rootScope.refreshTime);
- $scope.$on('$destroy',function(){
- $interval.cancel($scope.timer)
- });
- }]);
- //操作按钮权限控制
- app.controller('hc_caozuoCtrl', ['$rootScope', '$http', '$scope', '$modal', '$state', function($rootScope, $http, $scope, $modal, $state) {
- // 编辑按钮
- $scope.edit = function() {
- $rootScope.hc_eject_name_caozuo = $scope.item.name; //耗材名称
- $rootScope.hc_eject_brandModel_caozuo = $scope.item.brandModel; //耗材品牌型号
- $rootScope.hc_eject_specification_caozuo = $scope.item.specification; //耗材规格
- $rootScope.hc_eject_inventoryNum_caozuo = $scope.item.inventoryNum; //耗材在库数量
- $rootScope.hc_eject_inventorySum_caozuo = $scope.item.inventorySum; //耗材入库数量
- $rootScope.hc_eject_id_caozuo = $scope.item.id; //耗材id
- $rootScope.hc_eject_big = true; //编辑弹出框
- $rootScope.hc_eject_sma = true; //编辑弹出框
- $rootScope.hc_toedit = "new_after";
- };
- //查看按钮
- $scope.see = function() {
- // console.log($scope.item.id);
- // idd=$scope.item.id;
- $state.go('app.means.consumables_see', { idd: $scope.item.id })
- }
- }]);
- //操作
- app.directive('wtt', function() {
- return {
- restrict: 'E',
- scope: {
- item: '=',
- colobject: '='
- },
- controller: 'hc_caozuoCtrl',
- template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
- // '<a class="handlefont" ng-click="see()">查看</a>' +
- '<a class="bianjifont" ng-click="edit()">编辑</a>' +
- '</div></div>'
- };
- });
|