informationCtrl.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. 'use strict';
  2. /**
  3. * controller for User Profile Example
  4. */
  5. app.controller('informationCtr', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", "api_login", "api_configure_data", "api_solution", "api_wechatfile", function ($rootScope, $scope, $state, $timeout, $interval, $modal, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data, api_login, api_configure_data, api_solution, api_wechatfile) {
  6. $scope.langs = i18nService.getAllLangs();
  7. $scope.lang = 'zh-cn';
  8. i18nService.setCurrentLang($scope.lang);
  9. var loginUser = $rootScope.user;
  10. $scope.xinzeng = false;
  11. $scope.shanchu = false;
  12. $scope.bianji = false;
  13. $scope.fabu = false;
  14. $scope.chehui = false;
  15. for (var i = 0; i < loginUser.menu.length; i++) {
  16. if (loginUser.menu[i].link == "fuwuzhinanliebiao_xinzeng") {
  17. $scope.xinzeng = true
  18. }
  19. if (loginUser.menu[i].link == "fuwuzhinanliebiao_shanchu") {
  20. $scope.shanchu = true
  21. }
  22. if (loginUser.menu[i].link == "fuwuzhinanliebiao_bianji") {
  23. $scope.bianji = true
  24. }
  25. if (loginUser.menu[i].link == "fuwuzhinanliebiao_fabu") {
  26. $scope.fabu = true
  27. }
  28. if (loginUser.menu[i].link == "fuwuzhinanliebiao_chehui") {
  29. $scope.chehui = true
  30. }
  31. }
  32. //$scope.allright=false;
  33. //$scope.allrightnot=true;
  34. $scope.gridOptions = {};
  35. $scope.gridOptions.data = 'myData';
  36. $scope.gridOptions.enableColumnResizing = true;
  37. $scope.gridOptions.enableFiltering = true;
  38. $scope.gridOptions.enableGridMenu = true;
  39. $scope.gridOptions.enableRowSelection = true;
  40. $scope.gridOptions.showGridFooter = true;
  41. $scope.gridOptions.showColumnFooter = false;
  42. $scope.gridOptions.fastWatch = true;
  43. $scope.gridOptions.useExternalFiltering = true;
  44. $scope.gridOptions.useExternalPagination = true;
  45. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  46. $scope.gridOptions.paginationPageSize = 10;
  47. $scope.gridOptions.multiSelect = true;
  48. $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.onDblClick(row.entity)\" 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>";
  49. $scope.gridOptions.rowIdentity = function (row) {
  50. return row.id;
  51. };
  52. $scope.gridOptions.getRowIdentity = function (row) {
  53. return row.id;
  54. };
  55. //remote data
  56. $scope.gridOptions.columnDefs = [{
  57. name: 'item',
  58. displayName: '序号',
  59. enableFiltering: false,
  60. width: 50
  61. },
  62. {
  63. name: 'title',
  64. displayName: '标题',
  65. width: '25%',
  66. enableFiltering: false
  67. },
  68. {
  69. name: 'serviceType.name',
  70. displayName: '分类',
  71. width: '13%',
  72. enableFiltering: false
  73. },
  74. {
  75. name: 'createUser.name',
  76. displayName: '创建人',
  77. width: '8%',
  78. enableFiltering: false
  79. },
  80. {
  81. name: 'createUser.dept.dept',
  82. displayName: '发布科室',
  83. width: '10%',
  84. enableFiltering: false
  85. },
  86. {
  87. name: 'createTime',
  88. displayName: '创建时间',
  89. width: '10%',
  90. minWidth:'140',
  91. enableFiltering: false,
  92. cellTemplate: '<div>' +
  93. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{grid.appScope.transferTime(row.entity.createTime)}}</div>' +
  94. '</div>'
  95. },
  96. {
  97. name: 'status',
  98. displayName: '状态',
  99. width: '8%',
  100. enableFiltering: false,
  101. cellTemplate: '<div>' +
  102. '<div class="ui-grid-cell-contents">{{grid.appScope.getStatus(row.entity.status)}}</div>' +
  103. '</div>'
  104. },
  105. {
  106. minWidth: '310',
  107. name: '操作',
  108. enableFiltering: false,
  109. cellTemplate: '<div class="links cl-effect-1 pull-left ui-grid-cell-contents">' +
  110. '<a ng-click="grid.appScope.saveData(row.entity)" class="bianjifont" ng-show="grid.appScope.showBianji(row.entity)&&grid.appScope.bianji" tooltip="编辑" tooltip-placement="left">编辑</a>' +
  111. '<a ng-click="grid.appScope.removeData(row.entity)" class="bianjifont" ng-show="grid.appScope.showShanchu(row.entity)&&grid.appScope.shanchu" tooltip="删除" tooltip-placement="left">删除</a>' +
  112. '<a ng-click="grid.appScope.seeDetail(row.entity)" class="bianjifont" ng-show="grid.appScope.showChakan(row.entity)" tooltip="查看" tooltip-placement="left">查看</a>' +
  113. '<a ng-click="grid.appScope.release(row.entity)" class="bianjifont" ng-show="grid.appScope.showFabu(row.entity)&&grid.appScope.fabu" tooltip="发布" tooltip-placement="left">发布</a>' +
  114. '<a ng-click="grid.appScope.withdraw(row.entity)" class="bianjifont" ng-show="grid.appScope.showChehui(row.entity)&&grid.appScope.chehui" tooltip="撤回" tooltip-placement="left">撤回</a>' +
  115. '</div>'
  116. },
  117. ];
  118. $scope.transferTime = function(time) {
  119. return moment(time).format('YYYY-MM-DD HH:mm');
  120. }
  121. // 状态名转化
  122. $scope.getStatus = function (data) {
  123. if (data == 1) {
  124. return "已发布"
  125. } else if (data == 2) {
  126. return "暂存"
  127. } else if (data == 3) {
  128. return "已撤回"
  129. }
  130. }
  131. // 撤回显示隐藏
  132. $scope.showChehui = function (data) {
  133. // console.log(data);
  134. if (data.status == 1) {
  135. return true
  136. } else {
  137. return false
  138. }
  139. }
  140. // 发布显示隐藏
  141. $scope.showFabu = function (data) {
  142. if (data.status == 2 || data.status == 3) {
  143. return true
  144. } else {
  145. return false
  146. }
  147. }
  148. // 查看显示隐藏
  149. $scope.showChakan = function (data) {
  150. // if(data.status==1||data.status==2){
  151. return true
  152. // }else{
  153. // return false
  154. // }
  155. }
  156. // 删除显示隐藏
  157. $scope.showShanchu = function (data) {
  158. if (data.status == 2 || data.status == 3) {
  159. return true
  160. } else {
  161. return false
  162. }
  163. }
  164. // 编辑显示隐藏
  165. $scope.showBianji = function (data) {
  166. if (data.status == 2 || data.status == 3) {
  167. return true
  168. } else {
  169. return false
  170. }
  171. }
  172. $scope.open = function ($event) {
  173. $event.preventDefault();
  174. $event.stopPropagation();
  175. $scope.opened = !$scope.opened;
  176. };
  177. $scope.endOpen = function ($event) {
  178. $event.preventDefault();
  179. $event.stopPropagation();
  180. $scope.startOpened = false;
  181. $scope.endOpened = !$scope.endOpened;
  182. };
  183. $scope.startOpen = function ($event) {
  184. $event.preventDefault();
  185. $event.stopPropagation();
  186. $scope.endOpened = false;
  187. $scope.startOpened = !$scope.startOpened;
  188. };
  189. // 获取创建人
  190. $scope.getCreateUser = function () {
  191. api_configure_data.fetchDataList("user", {
  192. "idx": 0,
  193. "sum": 1000,
  194. "user":{
  195. "simple": true
  196. }
  197. }).then(function (res) {
  198. $scope.createUserData = res.list
  199. })
  200. }
  201. $scope.getCreateUser()
  202. // 发布
  203. $scope.release = function (data) {
  204. var modalInstance = $modal.open({
  205. templateUrl: 'assets/views/delete.html',
  206. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  207. $scope.title = '服务指南发布';
  208. $scope.connect = '确定要发布此服务指南?';
  209. $scope.ok = function () {
  210. $modalInstance.close(data);
  211. };
  212. $scope.cancel = function () {
  213. $modalInstance.dismiss('cancel');
  214. };
  215. },
  216. size: 'sm',
  217. resolve: {
  218. scope: function () {
  219. return $scope;
  220. }
  221. }
  222. });
  223. modalInstance.result.then(function (selectedItem) {
  224. if (selectedItem) {
  225. selectedItem.status = 1;
  226. delete selectedItem.item;
  227. api_solution.updData('serviceGuide', {
  228. "serviceGuide": selectedItem
  229. }).then(function (response) {
  230. if (response.data) {
  231. SweetAlert.swal({
  232. title: "发布成功!",
  233. type: "success",
  234. confirmButtonColor: "#007AFF"
  235. }, function () {
  236. $scope.myData = _.reject($scope.myData, function (o) {
  237. return _.includes(selectedItem, o.id);
  238. });
  239. $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length;
  240. $scope.refreshData('expand-right', $scope.jry_fileData);
  241. });
  242. } else {
  243. SweetAlert.swal({
  244. title: "操作异常!",
  245. text: "系统异常,请稍后重试,或者联系管理员!",
  246. type: "error"
  247. });
  248. }
  249. })
  250. }
  251. })
  252. }
  253. $scope.minTime = "";
  254. $scope.maxTime = "";
  255. // 新增
  256. $scope.addData = function () {
  257. $state.go('app.system.form', {
  258. formKey: 'serviceGuideForm',
  259. service: 'api_solution'
  260. });
  261. }
  262. //列表操作按钮-查看
  263. // $scope.onDblClick = function(data) {
  264. // var modelfile = { model: { serviceGuide: data } };
  265. // $state.go('app.system.form_editor', { formKey: 'serviceGuideDetail', service: 'api_solution', model: JSON.stringify(modelfile) });
  266. // };
  267. $scope.seeDetail = function (data) {
  268. var modelfile = {
  269. model: {
  270. serviceGuide: data
  271. }
  272. };
  273. $state.go('app.system.form_editor', {
  274. formKey: 'serviceGuideDetail',
  275. service: 'api_solution',
  276. model: JSON.stringify(modelfile)
  277. });
  278. };
  279. //列表操作按钮-编辑
  280. $scope.saveData = function (data) {
  281. var modelData = {
  282. model: {
  283. serviceGuide: data
  284. }
  285. };
  286. $state.go('app.system.form', {
  287. formKey: 'serviceGuideEdi',
  288. service: 'api_solution',
  289. model: JSON.stringify(modelData),
  290. 'isServiceGuideEdit': "true"
  291. });
  292. };
  293. // 搜索
  294. $scope.searchData = function () {
  295. if ($scope.minTime) {
  296. $scope.jry_fileData.serviceGuide.startTime = moment($scope.minTime).format("YYYY-MM-DD HH:mm:ss")
  297. }
  298. if ($scope.maxTime) {
  299. $scope.jry_fileData.serviceGuide.endTime = moment($scope.maxTime).format("YYYY-MM-DD HH:mm:ss")
  300. }
  301. $scope.refreshData('expand-right', $scope.jry_fileData);
  302. }
  303. // 清空
  304. $scope.clean = function () {
  305. delete $scope.jry_fileData.serviceGuide.title;
  306. delete $scope.jry_fileData.serviceGuide.serviceType;
  307. delete $scope.jry_fileData.serviceGuide.startTime;
  308. $scope.minTime = "";
  309. delete $scope.jry_fileData.serviceGuide.endTime;
  310. $scope.maxTime = "";
  311. delete $scope.jry_fileData.serviceGuide.createUser;
  312. $scope.refreshData('expand-right', $scope.jry_fileData);
  313. }
  314. // 撤回
  315. $scope.withdraw = function (data) {
  316. var modalInstance = $modal.open({
  317. templateUrl: 'assets/views/delete.html',
  318. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  319. $scope.title = '服务指南撤回';
  320. $scope.connect = '确定要撤回此服务指南?';
  321. $scope.ok = function () {
  322. $modalInstance.close(data);
  323. };
  324. $scope.cancel = function () {
  325. $modalInstance.dismiss('cancel');
  326. };
  327. },
  328. size: 'sm',
  329. resolve: {
  330. scope: function () {
  331. return $scope;
  332. }
  333. }
  334. });
  335. modalInstance.result.then(function (selectedItem) {
  336. if (selectedItem) {
  337. console.log(selectedItem);
  338. delete selectedItem.item;
  339. selectedItem.status = 3;
  340. api_solution.updData("serviceGuide", {
  341. "serviceGuide": selectedItem
  342. }).then(function (res) {
  343. if (res.data) {
  344. SweetAlert.swal({
  345. title: "撤回成功!",
  346. type: "success",
  347. confirmButtonColor: "#007AFF"
  348. })
  349. $scope.refreshData('expand-right', $scope.jry_fileData);
  350. } else {
  351. SweetAlert.swal({
  352. title: "操作异常!",
  353. text: "系统异常,请稍后重试,或者联系管理员!",
  354. type: "error"
  355. });
  356. }
  357. })
  358. }
  359. })
  360. }
  361. // 删除
  362. $scope.removeData = function (data) {
  363. var modalInstance = $modal.open({
  364. templateUrl: 'assets/views/delete.html',
  365. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  366. var rmvList = [];
  367. $scope.title = '服务指南删除';
  368. $scope.connect = '确定要删除此服务指南?';
  369. // angular.forEach(scope.selected.items, function(item) {
  370. // rmvList.push(item.id);
  371. // });
  372. rmvList.push(data.id);
  373. $scope.ok = function () {
  374. $modalInstance.close(rmvList);
  375. };
  376. $scope.cancel = function () {
  377. $modalInstance.dismiss('cancel');
  378. };
  379. },
  380. size: 'sm',
  381. resolve: {
  382. scope: function () {
  383. return $scope;
  384. }
  385. }
  386. });
  387. modalInstance.result.then(function (selectedItem) {
  388. if (selectedItem) {
  389. if (selectedItem.length > 0) {
  390. api_solution.rmvData('serviceGuide', selectedItem).then(function (response) {
  391. if (response.data) {
  392. SweetAlert.swal({
  393. title: "删除成功!",
  394. type: "success",
  395. confirmButtonColor: "#007AFF"
  396. }, function () {
  397. $scope.myData = _.reject($scope.myData, function (o) {
  398. return _.includes(selectedItem, o.id);
  399. });
  400. $scope.selected = {
  401. items: []
  402. };
  403. $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length;
  404. // $scope.gridApi.grid.selection.selectedCount = 0;
  405. $scope.refreshData('expand-right', $scope.jry_fileData);
  406. });
  407. } else {
  408. SweetAlert.swal({
  409. title: "操作异常!",
  410. text: "系统异常,请稍后重试,或者联系管理员!",
  411. type: "error"
  412. });
  413. }
  414. })
  415. }
  416. }
  417. })
  418. }
  419. $scope.selected = {
  420. items: []
  421. }
  422. $scope.editted = {
  423. items: []
  424. }
  425. $scope.jry_fileData = {
  426. "idx": 0,
  427. "sum": 10,
  428. "serviceGuide": {}
  429. }
  430. $scope.gridOptions.onRegisterApi = function (gridApi) {
  431. $scope.gridApi = gridApi;
  432. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  433. // var filtersData = $scope.memoryfilterData;
  434. // filtersData.idx = newPage - 1;
  435. $scope.jry_fileData.idx = newPage - 1;
  436. // filtersData.sum = pageSize;
  437. $scope.jry_fileData.sum = pageSize;
  438. // defaultFilterData = filtersData;
  439. $scope.refreshData('expand-right', $scope.jry_fileData);
  440. });
  441. };
  442. // api_solution.jry_fetchDataList("serviceGuide",{"idx":0,"sum":10}).then(function(res){
  443. // console.log(res)
  444. // })
  445. $scope.serviceGuideType = [];
  446. // 获取分类
  447. $scope.getType = function () {
  448. var data = {
  449. key: "service_type",
  450. type: "list"
  451. }
  452. api_wechatfile.getDictionary(data).then(function (res) {
  453. $scope.serviceGuideType = res
  454. })
  455. }
  456. $scope.getType()
  457. $scope.ldloading = {};
  458. //获取数据
  459. $scope.refreshData = function (style, filterData) {
  460. $scope.ldloading[style.replace('-', '_')] = true;
  461. if (angular.isUndefined(filterData)) {
  462. filterData = defaultFilterData;
  463. }
  464. if (angular.isDefined($scope.searchTypes)) {
  465. filterData['searchType'] = $scope.searchTypes;
  466. }
  467. $scope.myData = [];
  468. // filterData['flag'] = -1;
  469. // console.log("filterData=" + JSON.stringify(filterData))
  470. api_solution.jry_fetchDataList('serviceGuide', filterData).then(function (data) {
  471. var myData = Restangular.stripRestangular(data);
  472. $scope.gridOptions.totalItems = myData.totalNum;
  473. $scope.myData = myData.list;
  474. for (var i = 0; i < $scope.myData.length; i++) {
  475. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  476. $scope.myData[i]['createTime'] = moment($scope.myData[i]['createTime']).format('YYYY-MM-DD HH:mm:ss')
  477. }
  478. $scope.ldloading[style.replace('-', '_')] = false;
  479. // console.log("$scope.myData="+JSON.stringify($scope.myData))
  480. }, function () {
  481. $scope.ldloading[style.replace('-', '_')] = false;
  482. });
  483. };
  484. //获取数据
  485. $scope.refreshData2 = function (style, filterData) {
  486. $scope.ldloading[style.replace('-', '_')] = true;
  487. if (angular.isUndefined(filterData)) {
  488. filterData = defaultFilterData;
  489. }
  490. if (angular.isDefined($scope.searchTypes)) {
  491. filterData['searchType'] = $scope.searchTypes;
  492. }
  493. // $scope.myData = [];
  494. // filterData['flag'] = -1;
  495. // console.log("filterData=" + JSON.stringify(filterData))
  496. api_solution.jry_fetchDataList('serviceGuide', filterData).then(function (data) {
  497. var myData = Restangular.stripRestangular(data);
  498. $scope.gridOptions.totalItems = myData.totalNum;
  499. $scope.myData = myData.list;
  500. for (var i = 0; i < $scope.myData.length; i++) {
  501. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  502. $scope.myData[i]['createTime'] = moment($scope.myData[i]['createTime']).format('YYYY-MM-DD HH:mm:ss')
  503. }
  504. $scope.ldloading[style.replace('-', '_')] = false;
  505. // console.log("$scope.myData="+JSON.stringify($scope.myData))
  506. }, function () {
  507. $scope.ldloading[style.replace('-', '_')] = false;
  508. });
  509. };
  510. $scope.timer = $interval(function () {
  511. $scope.refreshData2('expand-right', $scope.jry_fileData);
  512. }, $rootScope.refreshTime);
  513. $scope.$on('$destroy', function () {
  514. $interval.cancel($scope.timer)
  515. })
  516. $scope.refreshData('expand-right', $scope.jry_fileData);
  517. }]);