123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011 |
- '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.searchData = function(){
- $scope.refreshData('expand-right', $scope.fileData);
- }
- // 修改供货公司
- $scope.changeCompany = function(e){
- console.log(e)
- $scope.companyIds = e;
- }
- //修改开始价格和结束价格
- $scope.changePrice = function(val,type){
- $scope[type] = val?Math.abs(parseFloat(val.toFixed(2), 10)):val;
- }
- // 监听编辑在库数量
- $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.clearForm = function(){
- $rootScope.hc_eject_unit = '';
- $rootScope.hc_eject_name_caozuo = '';
- $rootScope.hc_eject_brandModel_caozuo = '';
- $rootScope.hc_eject_specification_caozuo = '';
- $rootScope.hc_eject_companyIds_caozuo = [];
- $rootScope.hc_eject_startPrice_caozuo = '';
- $rootScope.hc_eject_endPrice_caozuo = '';
- $rootScope.hc_eject_isWarehousing_caozuo = 0;
- $rootScope.hc_eject_inventoryNum_caozuo = '';
- $rootScope.hc_eject_inventorySum_caozuo = '';
- delete $rootScope.hc_eject_id_caozuo;
- // -------------------
- $scope.hc.unit = ''
- $scope.select_updata_name.updata_name = {name:''};
- $scope.select_updata_pinpai.updata_pinpai = {name:''};
- $scope.select_updata_guige.updata_guige = {name:''};
- $scope.hc_eject_inventoryNum = '';
- $scope.hc_eject_inventorySum = '';
- $scope.isWarehousing = 0;
- $scope.startPrice = '';
- $scope.endPrice = '';
- $scope.companyIds = null;
- }
- //新增
- $rootScope.isAdds = false;//是否是新增
- $scope.addData = function () {
- $scope.clearForm();
- $rootScope.isAdds = true;
- $rootScope.hc_eject_big = true; //编辑弹出框
- $rootScope.hc_eject_sma = true; //编辑弹出框
- // $rootScope.hc_toedit = "new_after";
- }
- // 监听下拉框搜索
- // $scope.$watch('select_val.search_data', function (val) {
- // if (val) {
- // $scope.fileData.consumable["keyWord"] = 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_unit = '';
- $rootScope.hc_eject_name_caozuo = '';
- $rootScope.hc_eject_brandModel_caozuo = '';
- $rootScope.hc_eject_specification_caozuo = '';
- $rootScope.hc_eject_companyIds_caozuo = [];
- $rootScope.hc_eject_startPrice_caozuo = '';
- $rootScope.hc_eject_endPrice_caozuo = '';
- $rootScope.hc_eject_isWarehousing_caozuo = 0;
- $rootScope.hc_eject_inventoryNum_caozuo = '';
- $rootScope.hc_eject_inventorySum_caozuo = '';
- delete $rootScope.hc_eject_id_caozuo;
- // ----------------------------------
- $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;
- var dat = {
- "key": "haocaifenlei",
- "type": "tree"
- }
- api_wechatfile.getDictionary(dat).then(function (data) {
- data = data || [];
- $scope.select_updata_name.updata_name = data.find(v=>v.name == val);
- });
- }
- })
- // 下拉框名称
- $scope.$watch('select_updata_name.updata_name', function (val) {
- // console.log(val);
- val = val || {name:''};
- if (!val.name) {
- } else {
- $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) {
- if (data.status == 200) {
- $scope.updata_pinpai = data.list;
- var flag = data.list.find(v=>v.name == $scope.select_updata_pinpai.updata_pinpai.name);
- if(!flag){
- $scope.select_updata_pinpai.updata_pinpai.name = '';
- $scope.hc_eject_brandModel = '';
- }
- }
- });
- }
- $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) {
- if (data.status == 200) {
- $scope.updata_guige = data.list;
- var flag = data.list.find(v=>v.name == $scope.select_updata_guige.updata_guige.name);
- if(!flag){
- $scope.select_updata_guige.updata_guige.name = '';
- $scope.hc_eject_specification = '';
- }
- }
- });
- }
- $scope.refreshDat_guige();
- }
- })
- $scope.selected = {
- items: []
- }
- //删除
- $scope.removeData = function () {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- var rmvList = [];
- $scope.title = '耗材删除';
- $scope.connect = '确定要删除此耗材?';
- angular.forEach(scope.selected.items, function (item) {
- rmvList.push(item.id);
- });
- $scope.ok = function () {
- $modalInstance.close(rmvList);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- if (selectedItem.length > 0) {
- api_user_data.rmvData('consumable', selectedItem).then(function (response) {
- if (response.data) {
- SweetAlert.swal({
- title: "删除成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $scope.myData = _.reject($scope.myData, function (o) {
- return _.includes(selectedItem, o.id);
- });
- $scope.selected = {
- items: []
- };
- $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length;
- $scope.gridApi.grid.selection.selectedCount = 0;
- $scope.refreshData('expand-right', $scope.fileData);
- });
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- }
- }
- })
- }
- // 第三方公司查询
- $scope.refreshDat_company = function (name,companyIds=[]) {
- $scope.updata_company = [];
- name = name || "";
- companyIds = companyIds || [];
- var dat = {
- "company": {
- serviceTypeIds:"1709",
- name:name
- },
- "idx": 0,
- "sum": 999
- }
- api_sysinfo.fetchDataList("company", dat).then(function (data) {
- if (data.status == 200) {
- if(companyIds.length){
- companyIds.forEach(v=>{
- data.list.forEach((v1,i)=>{
- if(v.id == v1.id){
- data.list.splice(i,1)
- }
- })
- })
- }
- $scope.updata_company = data.list;
- }
- });
- }
- $scope.refreshDat_company();
- // 规格
- $scope.$watch('hc_eject_specification_caozuo', function (val) {
- // $scope.hc_eject_specification = val;
- $scope.select_updata_guige.updata_guige = {name: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.select_updata_pinpai.updata_pinpai = {name:val}
- })
- // 下拉框品牌
- $scope.$watch('select_updata_pinpai.updata_pinpai', function (val) {
- console.log(val);
- if (val == undefined) {
- } else {
- $scope.hc_eject_brandModel = val.name;
- }
- })
- //供货公司hc_eject_companyIds_caozuo
- $scope.$watch('hc_eject_companyIds_caozuo', function (ids) {
- ids = ids || [];
- var dat = {
- "company": {
- serviceTypeIds:"1709",
- },
- "idx": 0,
- "sum": 999
- }
- api_sysinfo.fetchDataList("company", dat).then(function (data) {
- if (data.status == 200) {
- var arr = [];
- data.list.forEach(v=>{
- ids.forEach(v1=>{
- if(v.id == v1){
- arr.push(v);
- }
- })
- })
- $scope.companyIds = arr;
- }
- });
- })
- // 单位hc_eject_unit
- $scope.$watch('hc_eject_unit', function (val) {
- $scope.hc.unit = val;
- })
- // 费用区间开始hc_eject_startPrice_caozuo
- $scope.$watch('hc_eject_startPrice_caozuo', function (val) {
- $scope.startPrice = val;
- })
- // 费用区间开始hc_eject_endPrice_caozuo
- $scope.$watch('hc_eject_endPrice_caozuo', function (val) {
- $scope.endPrice = val;
- })
- // 是否库存hc_eject_isWarehousing_caozuo
- $scope.$watch('hc_eject_isWarehousing_caozuo', function (val) {
- $scope.isWarehousing = val;
- })
- // 在库数量
- $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.changeWarehousing = function(type){
- $scope.isWarehousing = type;
- }
- // 编辑保存按钮
- $scope.companyIds = null;
- $scope.startPrice = '';
- $scope.endPrice = '';
- $scope.isWarehousing = 0;
- $scope.hc_eject_inventorySum = '';
- $scope.updata_company = [];
- $scope.hc = {
- unit: '',//单位
- }
- $scope.preservation = function () {
- if (!$scope.select_updata_name.updata_name.name
- ||!$scope.select_updata_pinpai.updata_pinpai.name
- ||!$scope.select_updata_guige.updata_guige.name
- ||!$scope.companyIds
- ||(!$scope.startPrice&&$scope.startPrice!==0)
- ||(!$scope.endPrice&&$scope.endPrice!==0)
- ||($scope.isWarehousing == 1&&($scope.hc_eject_inventorySum===null||$scope.hc_eject_inventoryNum===null))
- ) {
- SweetAlert.swal({
- title: "保存失败",
- text: "必填数据不能为空!",
- type: "error"
- });
- } else {
- var pdKey = "consumable";
- var edit_data = {
- "consumable": {
- "name": $scope.select_updata_name.updata_name.name,
- "unit": $scope.hc.unit,
- "brandModel": $scope.select_updata_pinpai.updata_pinpai.name,
- "specification": $scope.select_updata_guige.updata_guige.name,
- isInventory:$scope.isWarehousing,
- startPrice:$scope.startPrice,
- endPrice:$scope.endPrice,
- companyIds:$scope.companyIds.map(v=>v.id).toString()
- }
- };
- if($scope.isWarehousing == 1){
- edit_data.consumable.inventoryNum = $scope.hc_eject_inventoryNum;
- edit_data.consumable.inventorySum = $scope.hc_eject_inventorySum;
- }
- if($rootScope.isAdds){
- edit_data.consumable.inOutInventory = 1;//入库1,出库2
- }else{
- edit_data.consumable.id = $rootScope.hc_eject_id_caozuo;
- }
- api_cmdb3[$rootScope.isAdds?'addData':'preservation'](pdKey, edit_data).then(function (data) {
- if (data.status == 200) {
- $scope.refreshData('expand-right', $scope.fileData);
- SweetAlert.swal({
- title: ($rootScope.isAdds?'新增':'修改')+"成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $rootScope.hc_eject_big = false; //编辑弹出框
- $rootScope.hc_eject_sma = false; //编辑弹出框
- // $rootScope.hc_toedit = "new_top";
- }
- })
- }
- }
- $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: 'spdCode',
- displayName: '耗材编码',
- minWidth: '120',
- },
- {
- name: 'name',
- displayName: '耗材名称',
- minWidth: '120',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.name}}</div>' +
- '</div>'
- },
- {
- name: 'brandModel',
- displayName: '品牌型号',
- minWidth: '120',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.brandModel}}</div>' +
- '</div>'
- },
- {
- name: 'specification',
- displayName: '规格',
- minWidth: '120',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.specification}}</div>' +
- '</div>'
- },
- {
- name: 'unit',
- displayName: '单位',
- minWidth: '120',
- },
- {
- name: 'price',
- displayName: '价格区间',
- minWidth: '120',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.startPrice}} ~ {{row.entity.endPrice}}</div>' +
- '</div>'
- },
- {
- name: 'companyIds',
- displayName: '供货公司',
- minWidth: '120',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.companyNames}}</div>' +
- '</div>'
- },
- // {
- // name: 'isInventory',
- // displayName: '是否库存',
- // width: '10%',
- // minWidth: '120',
- // cellTemplate: '<div>' +
- // '<div class="ui-grid-cell-contents">{{row.entity.isInventory == 1 ? "是" : "否"}}</div>' +
- // '</div>'
- // },
- // {
- // name: 'inventorySum',
- // displayName: '入库总数量',
- // width: '11%',
- // minWidth: '120',
- // cellTemplate: '<div>' +
- // '<div class="ui-grid-cell-contents">{{row.entity.inventorySum}}</div>' +
- // '</div>'
- // },
- {
- name: 'inventoryNum',
- displayName: '在库数量',
- minWidth: '120',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.inventoryNum}}</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) {
- $scope.fenye = newPage - 1;
- $scope.fileData.idx = newPage - 1;
- $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);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
- var j = 0;
- for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
- if (scope.grid.appScope.selected.items[i] == scope.entity) {
- j++;
- break;
- }
- }
- // console.log("j="+j)
- if (j == 1) {
- scope.grid.appScope.selected.items.splice(i, 1);
- } else {
- scope.grid.appScope.selected.items.push(scope.entity)
- }
- });
- };
- 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);
- $scope.gridOptions['totalItems'] = myData.totalNum;
- for (var i = 0; i < myData.list.length; i++) {
- myData.list[i]['item'] = i + 1 + filterData.idx * filterData.sum;
- }
- // ------------------
- var dat = {
- "company": {
- serviceTypeIds:"1709",
- },
- "idx": 0,
- "sum": 999
- }
- api_sysinfo.fetchDataList("company", dat).then(function (data) {
- if (data.status == 200) {
- // data.list
- $scope.myData = myData.list;
- myData.list.map(v=>{
- var ids = v.companyIds?v.companyIds.split(','):[];
- var strArr = [];
- ids.forEach(v1=>{
- data.list.forEach(v2=>{
- if(v1 == v2.id){
- strArr.push(v2.name);
- }
- })
- })
- v.companyNames = strArr.toString();
- return v;
- })
- }
- });
- } 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 () {
- // --------------------------------
- console.log($scope.item)
- $rootScope.isAdds = false;
- $rootScope.hc_eject_big = true; //编辑弹出框
- $rootScope.hc_eject_sma = true; //编辑弹出框
- $rootScope.hc_eject_unit = $scope.item.unit;//单位
- $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_companyIds_caozuo = $scope.item.companyIds.split(','); //供货公司
- $rootScope.hc_eject_startPrice_caozuo = $scope.item.startPrice; //费用区间开始
- $rootScope.hc_eject_endPrice_caozuo = $scope.item.endPrice; //费用区间结束
- $rootScope.hc_eject_isWarehousing_caozuo = $scope.item.isInventory || 0; //是否库存
- $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
- };
- //查看按钮
- $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>'
- };
- });
|