consumablesCtrl.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. 'use strict';
  2. 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) {
  3. $scope.ceshi = "耗材系统";
  4. $scope.langs = i18nService.getAllLangs();
  5. $scope.lang = 'zh-cn';
  6. i18nService.setCurrentLang($scope.lang);
  7. $scope.myData = [];
  8. var loginUser = $rootScope.user;
  9. // 监听编辑在库数量
  10. $scope.$watch('hc_eject_inventoryNum', function(val, oldval) {
  11. var zhengze = /^\w{0,5}$/;
  12. if (!zhengze.exec(val)) {
  13. $scope.hc_eject_inventoryNum = oldval;
  14. }
  15. });
  16. $scope.fileData={
  17. "idx":0,
  18. "sum":10,
  19. "consumable":{}
  20. }
  21. // 监听下拉框搜索
  22. $scope.$watch('select_val.search_data', function(val) {
  23. // if (val == undefined) {
  24. // $scope.wt_data_display = true;
  25. // } else if (val.name == '全部') {
  26. // wt_data = { consumable: {} };
  27. // $scope.wt_data_display = false;
  28. // if ($scope.fenye == undefined) {
  29. // $scope.fenye = 0
  30. // };
  31. // $scope.memoryfilterData = {
  32. // idx: $scope.fenye,
  33. // sum: 10
  34. // }
  35. // //获取列表数据
  36. // $scope.refreshData = function(style, filterData) {
  37. // // var data1={idx: 0, sum: 10};
  38. // var pdKey = "consumable";
  39. // $scope.myData = [];
  40. // api_cmdb3.fetchDataList(pdKey, filterData).then(function(data) {
  41. // // console.log(data.list);
  42. // if (data.list) {
  43. // var myData = Restangular.stripRestangular(data);
  44. // var list = [];
  45. // $scope.gridOptions['totalItems'] = myData.totalNum;
  46. // $scope.myData = myData.list;
  47. // for (var i = 0; i < $scope.myData.length; i++) {
  48. // $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  49. // }
  50. // } else {
  51. // SweetAlert.swal({
  52. // title: "系统错误",
  53. // text: "请稍后再试!",
  54. // type: "error"
  55. // });
  56. // }
  57. // $scope.ldloading[style.replace('-', '_')] = false;
  58. // }, function() {
  59. // $scope.ldloading[style.replace('-', '_')] = false;
  60. // });
  61. // };
  62. // $scope.refreshData('expand-right', $scope.memoryfilterData);
  63. // } else {
  64. // wt_data = { consumable: { "name": val.name } };
  65. // $scope.wt_data_display = false;
  66. // if ($scope.fenye == undefined) {
  67. // $scope.fenye = 0
  68. // };
  69. // $scope.memoryfilterData = {
  70. // idx: $scope.fenye,
  71. // sum: 10,
  72. // consumable: { "name": val.name }
  73. // }
  74. // //获取列表数据
  75. // $scope.refreshData = function(style, filterData) {
  76. // var pdKey = "consumable";
  77. // $scope.myData = [];
  78. // // $scope.gridOptions['sum'] = filterData.sum;
  79. // api_cmdb3.fetchDataList(pdKey, filterData).then(function(data) {
  80. // // console.log(data.list);
  81. // if (data.list) {
  82. // var myData = Restangular.stripRestangular(data);
  83. // var list = [];
  84. // $scope.gridOptions['totalItems'] = myData.totalNum;
  85. // $scope.myData = myData.list;
  86. // for (var i = 0; i < $scope.myData.length; i++) {
  87. // $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  88. // }
  89. // } else {
  90. // SweetAlert.swal({
  91. // title: "系统错误",
  92. // text: "请稍后再试!",
  93. // type: "error"
  94. // });
  95. // }
  96. // $scope.ldloading[style.replace('-', '_')] = false;
  97. // }, function() {
  98. // $scope.ldloading[style.replace('-', '_')] = false;
  99. // });
  100. // };
  101. // $scope.refreshData('expand-right', $scope.memoryfilterData);
  102. // }
  103. $scope.fileData.consumable["name"]=val.name;
  104. $scope.refreshData('expand-right', $scope.fileData);
  105. })
  106. $scope.new_data = function() {
  107. $scope.myData = [];
  108. $scope.refreshData('expand-right', $scope.memoryfilterData);
  109. }
  110. var pdKey = $state.current.pdKey;
  111. $rootScope.hc_eject_big = false; //编辑弹出框
  112. $rootScope.hc_eject_sma = false; //编辑弹出框
  113. $rootScope.hc_toedit = "new_top";
  114. // 关闭编辑弹出框
  115. $scope.close = function() {
  116. $rootScope.hc_eject_big = false; //编辑弹出框
  117. $rootScope.hc_eject_sma = false; //编辑弹出框
  118. $rootScope.hc_toedit = "new_top";
  119. $scope.select_updata_name = {}; //编辑下拉框名称
  120. $scope.select_updata_guige = {}; //编辑下拉框规格
  121. $scope.select_updata_pinpai = {}; //编辑下拉框品牌
  122. }
  123. $scope.select_updata_name = {}; //编辑下拉框名称
  124. $scope.select_updata_guige = {}; //编辑下拉框规格
  125. $scope.select_updata_pinpai = {}; //编辑下拉框品牌
  126. // 名称
  127. $scope.$watch('hc_eject_name_caozuo', function(val) {
  128. if (val != undefined) {
  129. // console.log(val);
  130. $scope.hc_eject_name = val;
  131. }
  132. })
  133. // 下拉框名称
  134. $scope.$watch('select_updata_name.updata_name', function(val) {
  135. // console.log(val);
  136. if (val == undefined) {
  137. } else {
  138. // $scope.hc_eject_name = val.name;
  139. // // 耗材查询品牌
  140. // $scope.refreshDat_pinpai = function() {
  141. // var dat = {
  142. // "key": "pinpai",
  143. // parent: val.id
  144. // }
  145. // api_cmdb4.fetchDataList(dat).then(function(data) {
  146. // $scope.updata_pinpai = data;
  147. // });
  148. // }
  149. // $scope.refreshDat_pinpai();
  150. // // 耗材查询规格
  151. // $scope.refreshDat_guige = function() {
  152. // var dat = {
  153. // "key": "guige",
  154. // parent: val.id
  155. // }
  156. // api_cmdb4.fetchDataList(dat).then(function(data) {
  157. // $scope.updata_guige = data;
  158. // });
  159. // }
  160. // $scope.refreshDat_guige();
  161. $scope.hc_eject_name = val.name;
  162. // 耗材查询品牌
  163. $scope.refreshDat_pinpai = function() {
  164. var dat = {
  165. "dictionaryTree":{
  166. "key": "pinpai",
  167. parent: val.id
  168. },
  169. "idx":0,
  170. "sum":999
  171. }
  172. api_sysinfo.fetchDataList("dictionaryTree",dat).then(function(data) {
  173. $scope.updata_pinpai = data;
  174. });
  175. }
  176. $scope.refreshDat_pinpai();
  177. // 耗材查询规格
  178. $scope.refreshDat_guige = function() {
  179. // var dat = {
  180. // "key": "guige",
  181. // parent: val.id,
  182. // "type":"tree"
  183. // }
  184. // api_wechatfile.getDictionary(dat).then(function(data) {
  185. // $scope.updata_guige = data;
  186. // });
  187. var dat = {
  188. "dictionaryTree":{
  189. "key": "guige",
  190. parent: val.id
  191. },
  192. "idx":0,
  193. "sum":999
  194. }
  195. api_sysinfo.fetchDataList("dictionaryTree",dat).then(function(data) {
  196. $scope.updata_pinpai = data;
  197. });
  198. }
  199. $scope.refreshDat_guige();
  200. }
  201. })
  202. // 规格
  203. $scope.$watch('hc_eject_specification_caozuo', function(val) {
  204. $scope.hc_eject_specification = val;
  205. })
  206. // 下拉框规格
  207. $scope.$watch('select_updata_guige.updata_guige', function(val) {
  208. // console.log(val);
  209. if (val == undefined) {
  210. } else {
  211. $scope.hc_eject_specification = val.name;
  212. }
  213. })
  214. // 品牌
  215. $scope.$watch('hc_eject_brandModel_caozuo', function(val) {
  216. $scope.hc_eject_brandModel = val;
  217. })
  218. // 下拉框品牌
  219. $scope.$watch('select_updata_pinpai.updata_pinpai', function(val) {
  220. // console.log(val);
  221. if (val == undefined) {
  222. } else {
  223. $scope.hc_eject_brandModel = val.name;
  224. }
  225. })
  226. // 在库数量
  227. $scope.$watch('hc_eject_inventoryNum_caozuo', function(val) {
  228. $scope.hc_eject_inventoryNum = val;
  229. })
  230. // 入库数量
  231. $scope.$watch('hc_eject_inventorySum_caozuo', function(val) {
  232. $scope.hc_eject_inventorySum = val;
  233. })
  234. $scope.reset=function(){
  235. $scope.select_val={};
  236. $scope.fileData.consumable={};
  237. $scope.refreshData('expand-right', $scope.fileData);
  238. }
  239. // 编辑保存按钮
  240. $scope.preservation = function() {
  241. if ($scope.add_virtualMachinesNum == '') {
  242. SweetAlert.swal({
  243. title: "保存失败",
  244. text: "必填数据不能为空!",
  245. type: "error"
  246. });
  247. } else {
  248. var pdKey = "consumable";
  249. var edit_data = {
  250. "consumable": {
  251. "name": $scope.hc_eject_name,
  252. "brandModel": $scope.hc_eject_brandModel,
  253. "specification": $scope.hc_eject_specification,
  254. "inventoryNum": $scope.hc_eject_inventoryNum,
  255. "inventorySum": $scope.hc_eject_inventorySum,
  256. "id": $rootScope.hc_eject_id_caozuo
  257. }
  258. };
  259. api_cmdb3.preservation(pdKey, edit_data).then(function(data) {
  260. if (data.status == 200) {
  261. // $scope.refreshData = function(style, filterData) {
  262. // var pdKey = "consumable";
  263. // $scope.myData = [];
  264. // $scope.gridOptions['sum'] = filterData.sum;
  265. // api_cmdb3.fetchDataList(pdKey, filterData).then(function(data) {
  266. // // console.log(data.list);
  267. // if (data.list) {
  268. // var myData = Restangular.stripRestangular(data);
  269. // var list = [];
  270. // $scope.gridOptions['totalItems'] = myData.totalNum;
  271. // $scope.myData = myData.list;
  272. // for (var i = 0; i < $scope.myData.length; i++) {
  273. // $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  274. // }
  275. // } else {
  276. // SweetAlert.swal({
  277. // title: "系统错误",
  278. // text: "请稍后再试!",
  279. // type: "error"
  280. // });
  281. // }
  282. // $scope.ldloading[style.replace('-', '_')] = false;
  283. // }, function() {
  284. // $scope.ldloading[style.replace('-', '_')] = false;
  285. // });
  286. // };
  287. $scope.refreshData('expand-right', $scope.fileData);
  288. SweetAlert.swal({
  289. title: "修改成功",
  290. confirmButtonColor: "#007AFF",
  291. type: "success"
  292. });
  293. $rootScope.hc_eject_big = false; //编辑弹出框
  294. $rootScope.hc_eject_sma = false; //编辑弹出框
  295. $rootScope.hc_toedit = "new_top";
  296. $scope.select_updata_name = {}; //编辑下拉框名称
  297. $scope.select_updata_guige = {}; //编辑下拉框规格
  298. $scope.select_updata_pinpai = {}; //编辑下拉框品牌
  299. }
  300. })
  301. }
  302. }
  303. $scope.gridOptions = {};
  304. $scope.gridOptions.data = 'myData';
  305. $scope.gridOptions.enableColumnResizing = true;
  306. $scope.gridOptions.enableFiltering = false;
  307. $scope.gridOptions.enableGridMenu = true;
  308. $scope.gridOptions.enableSelectAll = true;
  309. $scope.gridOptions.enableRowSelection = true;
  310. $scope.gridOptions.showGridFooter = true;
  311. $scope.gridOptions.showColumnFooter = false;
  312. $scope.gridOptions.fastWatch = true;
  313. $scope.gridOptions.enableSorting = true;
  314. $scope.gridOptions.useExternalSorting = true;
  315. $scope.gridOptions.useExternalFiltering = false;
  316. $scope.gridOptions.useExternalPagination = true;
  317. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  318. $scope.gridOptions.paginationPageSize = 10;
  319. $scope.gridOptions.multiSelect = true;
  320. var mun = $scope.gridOptions.paginationPageSize;
  321. $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>";
  322. $scope.gridOptions.rowIdentity = function(row) {
  323. return row.id;
  324. };
  325. $scope.gridOptions.getRowIdentity = function(row) {
  326. return row.id;
  327. };
  328. $scope.transferColor = function(item) {
  329. var color = "icon iconfont icon-zhengchang greenfont";
  330. if (item.colourInfo) {
  331. if (item.colourInfo.id == 1) {
  332. color = "icon iconfont icon-yiyuqi redfont";
  333. } else if (item.colourInfo.id == 2) {
  334. color = "iconfont icon-yuqixinxiu yellofont";
  335. }
  336. } else {
  337. // color = "white";
  338. }
  339. return color;
  340. }
  341. $scope.transfertip = function(item) {
  342. var tip = "正常";
  343. if (item.colourInfo) {
  344. if (item.colourInfo.id == 1) {
  345. tip = "逾期";
  346. } else if (item.colourInfo.id == 2) {
  347. tip = "即将逾期";
  348. }
  349. } else {
  350. // color = "white";
  351. }
  352. return tip;
  353. }
  354. $scope.transferstatus = function(item) {
  355. var statecolor = "#fc4c58";
  356. if (item.id == 2) { //待处理
  357. statecolor = "#fc4c58";
  358. } else if (item.id == 7) { //待审核
  359. statecolor = "#fcb44c";
  360. } else if (item.id == 3) { //请求重新指派
  361. statecolor = "#ebf902";
  362. } else if (item.id == 4) { //处理中
  363. statecolor = "#0aa5f5";
  364. } else if (item.id == 5) { //已解决
  365. statecolor = "#2edbb8";
  366. } else if (item.id == 6) { //已关闭
  367. statecolor = "#bbbbbb";
  368. }
  369. return statecolor;
  370. }
  371. // 双击查看
  372. $scope.onDblClick=function(row){
  373. $state.go('app.means.consumables_see', { idd: row.entity.id })
  374. }
  375. $scope.gridOptions.columnDefs = [{
  376. name: 'item',
  377. displayName: '序号',
  378. width: 49,
  379. cellTemplate: '<div>' +
  380. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  381. '</div>'
  382. },
  383. {
  384. name: 'name',
  385. displayName: '耗材分类',
  386. width: '14%',
  387. cellTemplate: '<div>' +
  388. '<div class="ui-grid-cell-contents">{{row.entity.name}}</div>' +
  389. '</div>'
  390. },
  391. {
  392. name: 'brandModel',
  393. displayName: '品牌型号',
  394. width: '14%',
  395. cellTemplate: '<div>' +
  396. '<div class="ui-grid-cell-contents">{{row.entity.brandModel}}</div>' +
  397. '</div>'
  398. },
  399. {
  400. name: 'specification',
  401. displayName: '规格',
  402. width: '14%',
  403. cellTemplate: '<div>' +
  404. '<div class="ui-grid-cell-contents">{{row.entity.specification}}</div>' +
  405. '</div>'
  406. },
  407. {
  408. name: 'inventoryNum',
  409. displayName: '在库数量',
  410. width: '12%',
  411. minWidth: '120',
  412. cellTemplate: '<div>' +
  413. '<div class="ui-grid-cell-contents">{{row.entity.inventoryNum}}</div>' +
  414. '</div>'
  415. },
  416. {
  417. name: 'inventorySum',
  418. displayName: '入库总数量',
  419. width: '14%',
  420. minWidth: '120',
  421. cellTemplate: '<div>' +
  422. '<div class="ui-grid-cell-contents">{{row.entity.inventorySum}}</div>' +
  423. '</div>'
  424. },
  425. {
  426. name: 'updateTime',
  427. displayName: '最后更新时间',
  428. width: '14%',
  429. minWidth: '160',
  430. cellTemplate: '<div>' +
  431. '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.updateTime)}}</div>' +
  432. '</div>'
  433. },
  434. {
  435. name: '操作',
  436. enableSorting: false,
  437. minWidth: 120,
  438. cellTemplate: '<wtt style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
  439. enableFiltering: false
  440. },
  441. ];
  442. $scope.value = 10;
  443. $scope.decrement = function() {
  444. $scope.value = $scope.value - 1;
  445. };
  446. $scope.transferTime = function(time) {
  447. return moment(time).format('YYYY-MM-DD HH:mm');
  448. }
  449. $scope.record = function() {
  450. api_text.record($rootScope.takes).then(function(data) {
  451. if (data.errno == 0) {
  452. $scope.busy = false;
  453. }
  454. })
  455. };
  456. $scope.parameters = null;
  457. $scope.open = function($event) {
  458. $event.preventDefault();
  459. $event.stopPropagation();
  460. $scope.opened = !$scope.opened;
  461. };
  462. $scope.endOpen = function($event) {
  463. $event.preventDefault();
  464. $event.stopPropagation();
  465. $scope.startOpened = false;
  466. $scope.endOpened = !$scope.endOpened;
  467. };
  468. $scope.startOpen = function($event) {
  469. $event.preventDefault();
  470. $event.stopPropagation();
  471. $scope.endOpened = false;
  472. $scope.startOpened = !$scope.startOpened;
  473. };
  474. $scope.othcode = {};
  475. var items = [];
  476. $scope.selected = {
  477. items: []
  478. };
  479. $scope.select_val = {}; //下拉框查询
  480. //列表排序
  481. $scope.gridOptions.onRegisterApi = function(gridApi) {
  482. $scope.gridApi = gridApi;
  483. var index = 0;
  484. var oldheader = {};
  485. gridApi.grid.sortColumn = function(gridApi) {
  486. if (oldheader.field) {
  487. if (oldheader.field == gridApi.field) {
  488. // index = 0;
  489. } else {
  490. index = 0;
  491. }
  492. }
  493. index++;
  494. oldheader = gridApi;
  495. var fildata = $scope.memoryfilterData;
  496. if (index % 3 == 0) {
  497. delete $scope.memoryfilterData.incident;
  498. fildata = $scope.memoryfilterData;
  499. } else if (index % 3 == 1) {
  500. if (fildata.incident) {
  501. if (gridApi.field == "acceptDate") {
  502. angular.extend(fildata.incident, { "sort": gridApi.field });
  503. } else {
  504. angular.extend(fildata.incident, { "sort": gridApi.field + " desc , _incident.acceptDate" });
  505. }
  506. } else {
  507. if (gridApi.field == "acceptDate") {
  508. angular.extend(fildata, { 'incident': { "sort": gridApi.field } });
  509. } else {
  510. angular.extend(fildata, { 'incident': { "sort": gridApi.field + " desc , _incident.acceptDate" } });
  511. }
  512. }
  513. } else if (index % 3 == 2) {
  514. if (fildata.incident) {
  515. if (gridApi.field == "acceptDate") {
  516. angular.extend(fildata.incident, { "sort": gridApi.field, "order": "asc" });
  517. } else {
  518. angular.extend(fildata.incident, { "sort": gridApi.field + " asc , _incident.acceptDate" });
  519. }
  520. } else {
  521. if (gridApi.field == "acceptDate") {
  522. angular.extend(fildata, { 'incident': { "sort": gridApi.field, "order": "asc" } });
  523. } else {
  524. angular.extend(fildata.incident, { "sort": gridApi.field + " asc , _incident.acceptDate" });
  525. }
  526. }
  527. }
  528. $scope.refreshData('expand-right', $scope.fileData);
  529. }
  530. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  531. var filtersData = $scope.memoryfilterData;
  532. $scope.fenye = newPage - 1;
  533. filtersData.idx = newPage - 1;
  534. $scope.fileData.idx=newPage - 1;
  535. filtersData.sum = pageSize;
  536. $scope.fileData.sum=pageSize;
  537. $scope.refreshData('expand-right', $scope.fileData);
  538. });
  539. gridApi.core.on.filterChanged($scope, function() {
  540. var grid = this.grid;
  541. if ($rootScope.user.group) {
  542. var filtersData = {
  543. idx: 0,
  544. sum: mun
  545. };
  546. } else {
  547. var filtersData = {
  548. idx: 0,
  549. sum: mun
  550. };
  551. }
  552. angular.forEach(grid.columns, function(item) {
  553. if (item.enableFiltering) {
  554. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  555. filtersData = $scope.memoryfilterData
  556. if (angular.isUndefined(filtersData['incident'])) {
  557. filtersData['incident'] = {};
  558. }
  559. if (item.field == 'requester.name') {
  560. filtersData['incident']['requester'] = {};
  561. filtersData.incident.requester['accountName'] = item.filters[0].term;
  562. } else if (item.field == 'handlingPersonnelUser.name') {
  563. filtersData['incident']['handlingPersonnelUser'] = {};
  564. filtersData.incident.handlingPersonnelUser['name'] = item.filters[0].term;
  565. } else if (item.field == 'requester.account') {
  566. filtersData['incident']['requester'] = {};
  567. filtersData.incident.requester['account'] = item.filters[0].term;
  568. } else if (item.field == 'acceptUser.name') {
  569. filtersData['incident']['acceptUser'] = {};
  570. filtersData.incident.acceptUser['name'] = item.filters[0].term;
  571. } else {
  572. filtersData['incident'][item.field] = item.filters[0].term;
  573. }
  574. }
  575. }
  576. });
  577. filtersData.idx = 0;
  578. $scope.memoryfilterData = filtersData;
  579. $scope.refreshData('expand-right', $scope.fileData);
  580. });
  581. };
  582. var items = [];
  583. //当前人是否分组
  584. if ($rootScope.user.group) {
  585. if ($rootScope.user.group.length == 0) {
  586. SweetAlert.swal("访问失败!", "当前登录人未分配工作组,无权限访问,请添加工作组后重试。", "error");
  587. } else {
  588. $scope.memoryfilterData = defaultFilterData = {
  589. "idx": 0,
  590. "sum": mun
  591. };
  592. }
  593. } else {
  594. $scope.memoryfilterData = defaultFilterData = {
  595. "idx": 0,
  596. "sum": mun
  597. };
  598. }
  599. var wt_data = {};
  600. //导出
  601. $scope.hc_export = function() {
  602. if ($scope.wt_data_display == true) {
  603. SweetAlert.swal({
  604. title: "导出失败",
  605. text: "请选择分类!",
  606. type: "error"
  607. });
  608. } else {
  609. var filadata = angular.copy($scope.memoryfilterData);
  610. filadata.sum = 10000;
  611. var wt_url = api_cmdb3.exportData("downDataModel/consumable/1", wt_data).getRequestedUrl()
  612. $http({
  613. url: wt_url,
  614. method: 'POST',
  615. data: JSON.stringify(wt_data),
  616. headers: {
  617. 'Accept': '*/*'
  618. },
  619. responseType: 'arraybuffer'
  620. }).success(function(data, status, headers, config) {
  621. // $scope.ldloading.zoom_in = false;
  622. var file = new Blob([data], {
  623. type: 'application/vnd.ms-excel'
  624. });
  625. var fileURL = URL.createObjectURL(file);
  626. var a = document.createElement('a');
  627. a.href = fileURL;
  628. a.target = '_blank';
  629. a.download = '耗材列表.xls';
  630. document.body.appendChild(a);
  631. a.click();
  632. }).error(function(data, status, headers, config) {
  633. // $scope.ldloading.zoom_in = false;
  634. console.log(data);
  635. });
  636. }
  637. };
  638. if ($stateParams.model) {
  639. if (JSON.parse($stateParams.model).searchType && JSON.parse($stateParams.model).searchType != null) {
  640. $scope.searchTypes = JSON.parse($stateParams.model).searchType;
  641. } else {
  642. $scope.searchTypes = "todo";
  643. }
  644. } else {
  645. $scope.searchTypes = "todo";
  646. }
  647. if ($rootScope.user.group) {
  648. var defaultFilterData = {
  649. "idx": 0,
  650. "sum": mun
  651. };
  652. } else {
  653. var defaultFilterData = {
  654. "idx": 0,
  655. "sum": mun
  656. };
  657. }
  658. if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.incident)) {
  659. defaultFilterData['searchType'] = $rootScope.search.incident;
  660. $scope.searchTypes = $rootScope.search.incident;
  661. }
  662. if ($rootScope['cmdbs'] != 'incident') { $rootScope.idx = 1 }
  663. if (angular.isDefined($rootScope.idx) && $rootScope.cmdbs != "false") {
  664. $rootScope['cmdbs'] = 'incident';
  665. defaultFilterData.idx = $rootScope.idx - 1;
  666. } else { $rootScope.cmdbs = ""; }
  667. $scope.ldloading = {};
  668. //获取列表数据
  669. var pdKey = "consumable";
  670. $scope.refreshData = function(style, filterData) {
  671. // var pdKey = "consumable";
  672. $scope.myData = [];
  673. $scope.gridOptions['sum'] = filterData.sum;
  674. api_cmdb3.fetchDataList(pdKey, filterData).then(function(data) {
  675. // console.log(data.list);
  676. if (data.list) {
  677. var myData = Restangular.stripRestangular(data);
  678. var list = [];
  679. $scope.gridOptions['totalItems'] = myData.totalNum;
  680. $scope.myData = myData.list;
  681. for (var i = 0; i < $scope.myData.length; i++) {
  682. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  683. }
  684. } else {
  685. SweetAlert.swal({
  686. title: "系统错误",
  687. text: "请稍后再试!",
  688. type: "error"
  689. });
  690. }
  691. $scope.ldloading[style.replace('-', '_')] = false;
  692. }, function() {
  693. $scope.ldloading[style.replace('-', '_')] = false;
  694. });
  695. };
  696. $scope.refreshData2 = function(style, filterData) {
  697. // var pdKey = "consumable";
  698. // $scope.myData = [];
  699. $scope.gridOptions['sum'] = filterData.sum;
  700. api_cmdb3.fetchDataList(pdKey, filterData).then(function(data) {
  701. // console.log(data.list);
  702. if (data.list) {
  703. var myData = Restangular.stripRestangular(data);
  704. var list = [];
  705. $scope.gridOptions['totalItems'] = myData.totalNum;
  706. $scope.myData = myData.list;
  707. for (var i = 0; i < $scope.myData.length; i++) {
  708. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  709. }
  710. } else {
  711. SweetAlert.swal({
  712. title: "系统错误",
  713. text: "请稍后再试!",
  714. type: "error"
  715. });
  716. }
  717. $scope.ldloading[style.replace('-', '_')] = false;
  718. }, function() {
  719. $scope.ldloading[style.replace('-', '_')] = false;
  720. });
  721. };
  722. // 耗材查询分类
  723. $scope.refreshDat_name = function() {
  724. // var dat = {
  725. // "key": "haocaifenlei",
  726. // }
  727. // api_cmdb4.fetchDataList(dat).then(function(data) {
  728. // $scope.search_data = data;
  729. // $scope.search_data.unshift({ 'name': '全部' });
  730. // });
  731. var dat = {
  732. "key": "haocaifenlei",
  733. "type":"tree"
  734. }
  735. api_wechatfile.getDictionary(dat).then(function(data) {
  736. $scope.search_data = data;
  737. // $scope.search_data.unshift({ 'name': '全部' });
  738. });
  739. };
  740. // 耗材查询分类修改
  741. $scope.refreshDat_name_updata = function() {
  742. var dat = {
  743. "key": "haocaifenlei",
  744. "type":"tree"
  745. }
  746. api_wechatfile.getDictionary(dat).then(function(data) {
  747. $scope.updata_name = data;
  748. });
  749. };
  750. $scope.refreshDat_name();
  751. $scope.refreshDat_name_updata();
  752. // $scope.refreshDat_pinpai();
  753. // $scope.refreshDat_guige();
  754. $scope.refreshData('expand-right', $scope.fileData);
  755. $scope.timer=$interval(function(){
  756. $scope.refreshData2('expand-right', $scope.fileData);
  757. },$rootScope.refreshTime);
  758. $scope.$on('$destroy',function(){
  759. $interval.cancel($scope.timer)
  760. });
  761. }]);
  762. //操作按钮权限控制
  763. app.controller('hc_caozuoCtrl', ['$rootScope', '$http', '$scope', '$modal', '$state', function($rootScope, $http, $scope, $modal, $state) {
  764. // 编辑按钮
  765. $scope.edit = function() {
  766. $rootScope.hc_eject_name_caozuo = $scope.item.name; //耗材名称
  767. $rootScope.hc_eject_brandModel_caozuo = $scope.item.brandModel; //耗材品牌型号
  768. $rootScope.hc_eject_specification_caozuo = $scope.item.specification; //耗材规格
  769. $rootScope.hc_eject_inventoryNum_caozuo = $scope.item.inventoryNum; //耗材在库数量
  770. $rootScope.hc_eject_inventorySum_caozuo = $scope.item.inventorySum; //耗材入库数量
  771. $rootScope.hc_eject_id_caozuo = $scope.item.id; //耗材id
  772. $rootScope.hc_eject_big = true; //编辑弹出框
  773. $rootScope.hc_eject_sma = true; //编辑弹出框
  774. $rootScope.hc_toedit = "new_after";
  775. };
  776. //查看按钮
  777. $scope.see = function() {
  778. // console.log($scope.item.id);
  779. // idd=$scope.item.id;
  780. $state.go('app.means.consumables_see', { idd: $scope.item.id })
  781. }
  782. }]);
  783. //操作
  784. app.directive('wtt', function() {
  785. return {
  786. restrict: 'E',
  787. scope: {
  788. item: '=',
  789. colobject: '='
  790. },
  791. controller: 'hc_caozuoCtrl',
  792. template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  793. // '<a class="handlefont" ng-click="see()">查看</a>' +
  794. '<a class="bianjifont" ng-click="edit()">编辑</a>' +
  795. '</div></div>'
  796. };
  797. });