deptCtrl.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. 'use strict';
  2. /**
  3. * controller for User Profile Example
  4. */
  5. app.controller('deptlistCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", function($rootScope, $scope, $state, $timeout, $interval, $modal, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data) {
  6. $scope.langs = i18nService.getAllLangs();
  7. $scope.lang = 'zh-cn';
  8. i18nService.setCurrentLang($scope.lang);
  9. $scope.jry_user = JSON.parse(localStorage.getItem('jry_user'));
  10. $scope.jry_user_duty = null;
  11. if($scope.jry_user&&$scope.jry_user.duty){
  12. $scope.jry_user_duty = $scope.jry_user.duty;
  13. }
  14. var loginUser = $rootScope.user;
  15. $scope.xinzeng=false;
  16. $scope.shanchu=false;
  17. $scope.bianji=false;
  18. for(var i=0;i<loginUser.menu.length;i++){
  19. if(loginUser.menu[i].link=="bumenguanli_xinzeng"){
  20. $scope.xinzeng=true
  21. }
  22. if(loginUser.menu[i].link=="bumenguanli_shanchu"){
  23. $scope.shanchu=true
  24. }
  25. if(loginUser.menu[i].link=="bumenguanli_bianji"){
  26. $scope.bianji=true
  27. }
  28. }
  29. $scope.gridOptions = {};
  30. $scope.gridOptions.data = 'myData';
  31. $scope.gridOptions.enableColumnResizing = true;
  32. $scope.gridOptions.enableFiltering = true;
  33. $scope.gridOptions.enableGridMenu = true;
  34. $scope.gridOptions.enableRowSelection = true;
  35. $scope.gridOptions.showGridFooter = true;
  36. $scope.gridOptions.showColumnFooter = false;
  37. $scope.gridOptions.fastWatch = true;
  38. $scope.gridOptions.useExternalFiltering = true;
  39. $scope.gridOptions.useExternalPagination = true;
  40. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  41. $scope.gridOptions.paginationPageSize = 10;
  42. $scope.gridOptions.multiSelect = false;
  43. $scope.gridOptions.rowTemplate= "<div ng-dblclick=\"grid.appScope.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>";
  44. $scope.gridOptions.rowIdentity = function(row) {
  45. return row.id;
  46. };
  47. $scope.gridOptions.getRowIdentity = function(row) {
  48. return row.id;
  49. };
  50. $scope.gridOptions.columnDefs = [{
  51. name: 'item',
  52. displayName: '序号',
  53. width: 50,
  54. enableFiltering: false
  55. },
  56. { name: 'branchName', displayName: '院区', width: '10%', enableFiltering: false },
  57. { name: 'dept', displayName: '科室', width: '10%', enableFiltering: false },
  58. { name: 'pcode', displayName: '科室编码', width: '10%', enableFiltering: false },
  59. {
  60. name: 'parent.dept',
  61. displayName: '父级科室',
  62. width: '10%',
  63. enableFiltering: false,
  64. cellTemplate: '<div>' +
  65. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{grid.appScope.transferDept(row.entity.parent.dept)}}</div>' +
  66. '</div>'
  67. },
  68. { name: 'phone', displayName: '科室电话', width: '20%', enableFiltering: false },
  69. {
  70. name: 'area', displayName: '区域地点', width: '20%', enableFiltering: false,
  71. cellTemplate: '<div>' +
  72. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{row.entity.place.area.area+""+row.entity.place.place}} {{row.entity.address}}</div>' +
  73. '</div>'
  74. },
  75. {
  76. name: '操作',
  77. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  78. // '<a ng-click="grid.appScope.saveData(row.entity)" tooltip="编辑" tooltip-placement="right">' +
  79. // '<i class="fa fa-pencil-square-o"></i></a>'+
  80. '<a ng-click="grid.appScope.saveData(row.entity)" ng-show="grid.appScope.bianji" class="bianjifont">编辑</a>' +
  81. '</div></div>',
  82. enableFiltering: false
  83. },
  84. ];
  85. $scope.transferDept=function(data){
  86. if(data){
  87. return data
  88. }else{
  89. return "无"
  90. }
  91. }
  92. $scope.changeBranch = function(branchObj){
  93. delete $scope.fileData.department.area;
  94. delete $scope.fileData.department.place;
  95. $scope.getArea(branchObj.id);
  96. }
  97. // 院区
  98. $scope.getBranch = function () {
  99. var fildata = {
  100. "idx": 0,
  101. "sum": 1000
  102. };
  103. api_user_data.fetchDataList('branch', fildata).then(function (res) {
  104. $scope.branchData=res.list;
  105. if($scope.jry_user_duty){
  106. $scope.fileData.department.branch = $scope.branchData.find(v=>v.id == $scope.jry_user_duty.branch)
  107. }
  108. })
  109. }
  110. $scope.getBranch();
  111. // 区域
  112. $scope.getArea = function (branchId) {
  113. var fildata = {
  114. "idx": 0,
  115. "sum": 1000,
  116. "area":{}
  117. };
  118. if(branchId){
  119. fildata.area.branch = branchId;
  120. }else if($scope.jry_user_duty){
  121. fildata.area.branch=$scope.jry_user_duty.branch
  122. }
  123. api_user_data.fetchDataList('area', fildata).then(function (res) {
  124. $scope.areaData=res.list;
  125. })
  126. }
  127. $scope.getArea();
  128. // 选择区域带出地点
  129. $scope.changeArea=function(item){
  130. $scope.getPlace(item.id)
  131. }
  132. // 地点
  133. $scope.getPlace = function (areaId) {
  134. var fildata = {
  135. "idx": 0,
  136. "sum": 1000,
  137. place: {area: {id: areaId}},
  138. };
  139. api_user_data.fetchDataList('place', fildata).then(function (res) {
  140. $scope.placeData=res.list;
  141. })
  142. }
  143. $scope.saveData = function(selectdata) {
  144. console.log(selectdata)
  145. var modalInstance = $modal.open({
  146. templateUrl: 'assets/views/system/tpl/deptchange.html',
  147. controller: function($scope, scope, $modalInstance, api_user_data) {
  148. $scope.deptdata = {};
  149. $scope.deptdata = angular.copy(selectdata);
  150. if($scope.deptdata.place){
  151. $scope.deptdata.area = $scope.deptdata.place.area;
  152. }
  153. if($scope.deptdata.branch && $scope.deptdata.branchName){
  154. $scope.deptdata.branchObj = {id:$scope.deptdata.branch,hosName:$scope.deptdata.branchName}
  155. }
  156. $scope.areaData=scope.areaData
  157. $scope.deptchoice = {};
  158. $scope.title = '科室修改';
  159. $scope.deptdata.phone = $scope.deptdata.phone || '';
  160. $scope.deptPhones = $scope.deptdata.phone.split(',').map(v => ({id: ++$scope.deptsPhoneId, phone: v}));
  161. $scope.deptsPhoneId = 1;
  162. $scope.isAddDeptsPhone = !($scope.deptdata.phone);
  163. // 新添加科室号码
  164. $scope.addDeptPhone = function() {
  165. $scope.deptPhones.push({ id: ++$scope.deptsPhoneId, phone: "" });
  166. $scope.deptsPhoneChange();
  167. }
  168. // 删除新添加科室号码
  169. $scope.removeDeptPhone = function(index) {
  170. $scope.deptPhones.splice(index, 1);
  171. $scope.deptsPhoneChange();
  172. }
  173. //监听科室电话输入事件
  174. $scope.deptsPhoneChange = function(e, phone) {
  175. if (e !== undefined && phone !== undefined) {
  176. phone.phone = e;
  177. }
  178. // -------------判断添加按钮是否禁用 start
  179. $scope.isAddDeptsPhone = $scope.deptPhones.some((item) => item.phone.trim() === "");
  180. // -------------判断添加按钮是否禁用 end
  181. }
  182. var filterData = { "idx": 0, "sum": 9999 };
  183. $scope.getDeptData=function(keyword = ''){
  184. var postData = {
  185. "idx": 0,
  186. "sum": 20,
  187. department: {
  188. dept:keyword,
  189. selectType: "pinyin_qs",
  190. searchType: "quickStart",
  191. }
  192. };
  193. api_user_data.fetchDataList('department',postData).then(function(data){
  194. $scope.deptchoice = Restangular.stripRestangular(data).list;
  195. })
  196. }
  197. $scope.getDeptData();
  198. $scope.branchchoice = {};
  199. api_user_data.fetchDataList('branch', filterData).then(function(data) {
  200. $scope.branchchoice = Restangular.stripRestangular(data).list;
  201. })
  202. $scope.cancel = function() {
  203. $modalInstance.dismiss('cancel');
  204. };
  205. $scope.changeArea=function(item,isFirst=false){
  206. if(!isFirst){
  207. $scope.deptdata.place = '';
  208. }
  209. var postData={
  210. idx: 0,
  211. sum: 1000
  212. }
  213. if(item){
  214. postData.place={area: {id: item.id}}
  215. }
  216. api_user_data.fetchDataList('place', postData).then(function(data) {
  217. $scope.placeData = Restangular.stripRestangular(data).list;
  218. })
  219. }
  220. $scope.changeArea(selectdata.area,true)
  221. $scope.changeBranch=function(item,isFirst=false){
  222. if(!isFirst){
  223. $scope.deptdata.area = '';
  224. $scope.deptdata.place = '';
  225. }
  226. var postData={
  227. idx: 0,
  228. sum: 1000
  229. }
  230. if(item){
  231. postData.area={branch: item.id}
  232. }
  233. api_user_data.fetchDataList('area', postData).then(function(data) {
  234. $scope.areaData = Restangular.stripRestangular(data).list;
  235. })
  236. }
  237. $scope.changeBranch({id:selectdata.branch,hosName:selectdata.branchName},true)
  238. $scope.savercode = function(deptdata) {
  239. let phones = $scope.deptPhones.filter(v => v.phone.trim() !== '').map(v => v.phone).join(',');
  240. if (deptdata&&deptdata.dept&&phones&&deptdata.area&&deptdata.place&&deptdata.branchObj&&deptdata.pcode){
  241. var fildata = { "department": { "id": deptdata.id, area:{id:deptdata.area.id},place:{id:deptdata.place.id,area:{id:deptdata.area.id}},"deleteFlag":0,"phone":phones, "dept": deptdata.dept,branch:deptdata.branchObj.id, pcode: deptdata.pcode,address:deptdata.address } }
  242. if (deptdata.parent) {
  243. fildata.department.parent= { id: deptdata.parent.id }
  244. }
  245. // console.log(fildata)
  246. api_user_data.updData('department', fildata).then(function(response) {
  247. if (response) {
  248. if (response.status == 200) {
  249. SweetAlert.swal({
  250. title: "修改成功!",
  251. type: "success"
  252. }, function() {
  253. scope.refreshData('expand-right', scope.fileData);
  254. })
  255. } else {
  256. SweetAlert.swal({
  257. title: "修改失败!",
  258. text: response.error,
  259. type: "error"
  260. }, function() {
  261. scope.refreshData('expand-right', scope.fileData);
  262. })
  263. }
  264. $modalInstance.close();
  265. }else{
  266. SweetAlert.swal({
  267. title: "修改失败!",
  268. text: response.error,
  269. type: "error"
  270. }, function() {
  271. scope.refreshData('expand-right', scope.fileData);
  272. })
  273. }
  274. })
  275. }else{
  276. SweetAlert.swal({
  277. title: "修改失败!",
  278. text: "请填写必填项!",
  279. type: "error",
  280. confirmButtonColor: "#DD6B55"
  281. }, function () {
  282. });
  283. }
  284. }
  285. },
  286. resolve: {
  287. scope: function() {
  288. return $scope;
  289. }
  290. }
  291. });
  292. }
  293. $scope.addData = function() {
  294. var modalInstance = $modal.open({
  295. templateUrl: 'assets/views/system/tpl/deptchange.html',
  296. controller: function($scope, $modalInstance, api_user_data) {
  297. $scope.deptdata = {};
  298. var filterData = { "idx": 0, "sum": 9999 };
  299. $scope.title = '科室新增';
  300. $scope.deptPhones = [{id: 1, phone: ""}];
  301. $scope.deptsPhoneId = 1;
  302. $scope.isAddDeptsPhone = true;
  303. // 新添加科室号码
  304. $scope.addDeptPhone = function() {
  305. $scope.deptPhones.push({ id: ++$scope.deptsPhoneId, phone: "" });
  306. $scope.deptsPhoneChange();
  307. }
  308. // 删除新添加科室号码
  309. $scope.removeDeptPhone = function(index) {
  310. $scope.deptPhones.splice(index, 1);
  311. $scope.deptsPhoneChange();
  312. }
  313. //监听科室电话输入事件
  314. $scope.deptsPhoneChange = function(e, phone) {
  315. if (e !== undefined && phone !== undefined) {
  316. phone.phone = e;
  317. }
  318. // -------------判断添加按钮是否禁用 start
  319. $scope.isAddDeptsPhone = $scope.deptPhones.some((item) => item.phone.trim() === "");
  320. // -------------判断添加按钮是否禁用 end
  321. }
  322. $scope.getDeptData=function(keyword = ''){
  323. var postData = {
  324. "idx": 0,
  325. "sum": 20,
  326. department: {
  327. dept:keyword,
  328. selectType: "pinyin_qs",
  329. searchType: "quickStart",
  330. }
  331. };
  332. api_user_data.fetchDataList('department',postData).then(function(data){
  333. $scope.deptchoice = Restangular.stripRestangular(data).list;
  334. })
  335. }
  336. $scope.getDeptData();
  337. api_user_data.fetchDataList('branch', filterData).then(function(data) {
  338. $scope.branchchoice = Restangular.stripRestangular(data).list;
  339. })
  340. // api_user_data.fetchDataList('area', filterData).then(function(data) {
  341. // $scope.areaData = Restangular.stripRestangular(data).list;
  342. // })
  343. // api_wechatfile.getDictionary('department').then(function(data) {
  344. // $scope.deptchoice = Restangular.stripRestangular(data).list;
  345. // })
  346. $scope.cancel = function() {
  347. $modalInstance.dismiss('cancel');
  348. };
  349. $scope.savercode = function(deptdata) {
  350. deptdata.phones = $scope.deptPhones.filter(v => v.phone.trim() !== '').map(v => v.phone).join(',');
  351. if (deptdata&&deptdata.dept&&deptdata.phones&&deptdata.area&&deptdata.place&&deptdata.branchObj&&deptdata.pcode){
  352. $modalInstance.close(deptdata);
  353. }else{
  354. SweetAlert.swal({
  355. title: "新增失败!",
  356. text: "请填写必填项!",
  357. type: "error",
  358. confirmButtonColor: "#DD6B55"
  359. }, function () {
  360. });
  361. }
  362. };
  363. $scope.changeBranch=function(item){
  364. $scope.deptdata.area = '';
  365. $scope.deptdata.place = '';
  366. var postData={
  367. idx: 0,
  368. area: {branch: item.id},
  369. sum: 1000
  370. }
  371. api_user_data.fetchDataList('area', postData).then(function(data) {
  372. $scope.areaData = Restangular.stripRestangular(data).list;
  373. })
  374. }
  375. $scope.changeArea=function(item){
  376. $scope.deptdata.place = '';
  377. var postData={
  378. idx: 0,
  379. place: {area: {id: item.id}},
  380. sum: 1000
  381. }
  382. api_user_data.fetchDataList('place', postData).then(function(data) {
  383. $scope.placeData = Restangular.stripRestangular(data).list;
  384. })
  385. }
  386. }
  387. });
  388. modalInstance.result.then(function(selectedItem) {
  389. if (selectedItem.dept&&selectedItem.phones&&selectedItem.area&&selectedItem.place&&selectedItem.branchObj&&selectedItem.pcode) {
  390. // angular.forEach($scope.myData,function(item){
  391. // if(item.dept==selectedItem.parent.dept){
  392. // selectedItem.parent.id=item.id;
  393. // }
  394. // })
  395. var fildata = { "department": { "phone": selectedItem.phones,"area":{id:selectedItem.area.id},"place":{id:selectedItem.place.id,"area":{id:selectedItem.area.id}}, "dept": selectedItem.dept,branch:selectedItem.branchObj.id,pcode:selectedItem.pcode,address:selectedItem.address } }
  396. if (selectedItem.parent) {
  397. fildata.department.parent= { "id": selectedItem.parent.id }
  398. }
  399. // console.log(fildata)
  400. api_user_data.addData('department', fildata).then(function(response) {
  401. if (response) {
  402. if (response.status == 200) {
  403. SweetAlert.swal({
  404. title: "新增成功!",
  405. type: "success"
  406. }, function() {
  407. $scope.refreshData('expand-right', $scope.fileData);
  408. })
  409. } else {
  410. SweetAlert.swal({
  411. title: "新增失败!",
  412. text: response.msg,
  413. type: "error"
  414. })
  415. }
  416. }
  417. })
  418. } else{
  419. SweetAlert.swal({
  420. title: "新增失败!",
  421. text: "请填写必填项!",
  422. type: "error",
  423. confirmButtonColor: "#DD6B55"
  424. }, function () {
  425. });
  426. }
  427. });
  428. }
  429. $scope.removeData = function() {
  430. var modalInstance = $modal.open({
  431. // templateUrl: 'assets/views/delete.html',
  432. templateUrl: 'assets/views/incident/tpl/acceptTask.tpl.html',
  433. controller: function($scope, scope, $modalInstance, api_bpm_data) {
  434. var rmvList = [];
  435. $scope.title = '科室删除';
  436. $scope.connect = '确定要删除此科室?';
  437. rmvList.push(scope.selected.items);
  438. $scope.ok = function() {
  439. $modalInstance.close(rmvList);
  440. // }
  441. };
  442. $scope.cancel = function() {
  443. $modalInstance.dismiss('cancel');
  444. };
  445. },
  446. size: 'sm',
  447. resolve: {
  448. scope: function() {
  449. return $scope;
  450. }
  451. }
  452. });
  453. modalInstance.result.then(function(selectedItem) {
  454. if (selectedItem) {
  455. if (selectedItem.length > 0) {
  456. console.log(selectedItem);
  457. if (selectedItem[0].children.length>0) {
  458. SweetAlert.swal({
  459. title: "该科室存在子类科室",
  460. text: "请先删除该科室子类科室!",
  461. type: "error"
  462. });
  463. } else {
  464. api_user_data.rmvData('department', [selectedItem[0].id]).then(function(response) {
  465. if (response.status == 200) {
  466. SweetAlert.swal({
  467. title: "删除成功!",
  468. type: "success",
  469. confirmButtonColor: "#007AFF"
  470. }, function() {
  471. $scope.myData = _.reject($scope.myData, function(o) { return _.includes(selectedItem, o.id); });
  472. $scope.selected = {
  473. items: []
  474. };
  475. $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length
  476. $scope.gridApi.grid.selection.selectedCount = 0;
  477. $scope.refreshData('expand-right', $scope.fileData);
  478. });
  479. } else {
  480. SweetAlert.swal({
  481. title: "操作异常!",
  482. text: "系统异常,请稍后重试,或者联系管理员!",
  483. type: "error"
  484. });
  485. }
  486. })
  487. }
  488. }
  489. }
  490. })
  491. }
  492. // $scope.removeData = function() {
  493. // var rmvList = [$scope.selected.items.id]
  494. // if (rmvList.length > 0) {
  495. // api_user_data.rmvData('department', rmvList).then(function(response) {
  496. // if (response.status == 200) {
  497. // SweetAlert.swal({
  498. // title: "删除成功!",
  499. // type: "success",
  500. // confirmButtonColor: "#007AFF"
  501. // }, function() {
  502. // $scope.myData = _.reject($scope.myData, function(o) { return _.includes(rmvList, o.id); });
  503. // $scope.selected = {
  504. // items: []
  505. // };
  506. // });
  507. // } else {
  508. // SweetAlert.swal({
  509. // title: "操作异常!",
  510. // text: "系统异常,请稍后重试,或者联系管理员!",
  511. // type: "error"
  512. // });
  513. // }
  514. // })
  515. // }
  516. // }
  517. $scope.selected = {
  518. items: []
  519. }
  520. $scope.editted = {
  521. items: []
  522. }
  523. $scope.gridOptions.onRegisterApi = function(gridApi) {
  524. $scope.gridApi = gridApi;
  525. // gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){
  526. // // console.log(rowEntity);
  527. // });
  528. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  529. var filtersData = $scope.memoryfilterData;
  530. filtersData.idx = newPage - 1;
  531. filtersData.sum = pageSize;
  532. $scope.fileData.idx=newPage - 1;
  533. $scope.fileData.sum=pageSize;
  534. defaultFilterData = filtersData;
  535. $scope.refreshData('expand-right', $scope.fileData);
  536. });
  537. gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
  538. scope.grid.appScope.selected.items = scope.entity
  539. });
  540. };
  541. var defaultFilterData = {
  542. "idx": 0,
  543. "sum": 10
  544. };
  545. $scope.memoryfilterData = {
  546. "idx": 0,
  547. "sum": 10
  548. }
  549. $scope.fileData={
  550. "idx":0,
  551. "sum":10,
  552. "department":{branch:$scope.jry_user_duty?$scope.jry_user_duty.branch:undefined}
  553. }
  554. $scope.ldloading = {};
  555. $scope.refreshData = function(style, postData) {
  556. var filterData = angular.copy(postData);
  557. if(typeof filterData.department.branch == 'object'){
  558. filterData.department.branch = filterData.department.branch.id
  559. }
  560. $scope.selected.items = {};
  561. $scope.ldloading[style.replace('-', '_')] = true;
  562. if (angular.isUndefined(filterData)) {
  563. filterData = defaultFilterData;
  564. }
  565. $scope.myData = [];
  566. $scope.selected = { items: [] };
  567. if ($scope.gridApi) {
  568. $scope.gridApi.grid.selection.selectedCount = 0;
  569. }
  570. api_user_data.fetchDataList('department', filterData).then(function(data) {
  571. var myData = Restangular.stripRestangular(data);
  572. $scope.gridOptions.totalItems = myData.totalNum;
  573. $scope.myData = myData.list;
  574. for (var i = 0; i < $scope.myData.length; i++) {
  575. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  576. }
  577. $scope.ldloading[style.replace('-', '_')] = false;
  578. }, function() {
  579. $scope.ldloading[style.replace('-', '_')] = false;
  580. });
  581. };
  582. $scope.refreshData2 = function(style, postData) {
  583. var filterData = angular.copy(postData);
  584. if(typeof filterData.department.branch == 'object'){
  585. filterData.department.branch = filterData.department.branch.id
  586. }
  587. $scope.selected.items = {};
  588. $scope.ldloading[style.replace('-', '_')] = true;
  589. if (angular.isUndefined(filterData)) {
  590. filterData = defaultFilterData;
  591. }
  592. // $scope.myData = [];
  593. $scope.selected = { items: [] };
  594. if ($scope.gridApi) {
  595. $scope.gridApi.grid.selection.selectedCount = 0;
  596. }
  597. api_user_data.fetchDataList('department', filterData).then(function(data) {
  598. var myData = Restangular.stripRestangular(data);
  599. $scope.gridOptions.totalItems = myData.totalNum;
  600. $scope.myData = myData.list;
  601. for (var i = 0; i < $scope.myData.length; i++) {
  602. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  603. }
  604. $scope.ldloading[style.replace('-', '_')] = false;
  605. }, function() {
  606. $scope.ldloading[style.replace('-', '_')] = false;
  607. });
  608. };
  609. // 搜索
  610. $scope.searchData=function(){
  611. $scope.refreshData('expand-right', $scope.fileData);
  612. }
  613. // 清空
  614. $scope.clean=function(){
  615. if($scope.jry_user_duty){
  616. $scope.fileData.department.branch = {id:$scope.jry_user_duty.branch,hosName:$scope.jry_user_duty.branchName}
  617. }
  618. delete $scope.fileData.department.dept;
  619. delete $scope.fileData.department.address;
  620. delete $scope.fileData.department.phone;
  621. delete $scope.fileData.department.parent;
  622. delete $scope.fileData.department.area;
  623. delete $scope.fileData.department.place;
  624. $scope.refreshData('expand-right', $scope.fileData);
  625. }
  626. // 获取父级科室下拉
  627. $scope.model={};
  628. $scope.deptData={};
  629. $scope.getDeptData=function(keyword = ''){
  630. var data = {
  631. "idx": 0,
  632. "sum": 20,
  633. department: {
  634. dept:keyword,
  635. selectType: "pinyin_qs",
  636. searchType: "quickStart",
  637. }
  638. };
  639. api_user_data.fetchDataList('department',data).then(function(res){
  640. $scope.deptData=res.list||[];
  641. })
  642. }
  643. $scope.getDeptData();
  644. $scope.refreshData('expand-right', $scope.fileData);
  645. $scope.timer=$interval(function(){
  646. $scope.refreshData2('expand-right', $scope.fileData);
  647. },$rootScope.refreshTime);
  648. $scope.$on('$destroy',function(){
  649. $interval.cancel($scope.timer)
  650. });
  651. }]);