informationCtrl.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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. engineer: 1,
  197. }
  198. }).then(function (res) {
  199. $scope.createUserData = res.list
  200. })
  201. }
  202. $scope.getCreateUser()
  203. // 发布
  204. $scope.release = function (data) {
  205. var modalInstance = $modal.open({
  206. templateUrl: 'assets/views/delete.html',
  207. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  208. $scope.title = '服务指南发布';
  209. $scope.connect = '确定要发布此服务指南?';
  210. $scope.ok = function () {
  211. $modalInstance.close(data);
  212. };
  213. $scope.cancel = function () {
  214. $modalInstance.dismiss('cancel');
  215. };
  216. },
  217. size: 'sm',
  218. resolve: {
  219. scope: function () {
  220. return $scope;
  221. }
  222. }
  223. });
  224. modalInstance.result.then(function (selectedItem) {
  225. if (selectedItem) {
  226. selectedItem.status = 1;
  227. delete selectedItem.item;
  228. api_solution.updData('serviceGuide', {
  229. "serviceGuide": selectedItem
  230. }).then(function (response) {
  231. if (response.data) {
  232. SweetAlert.swal({
  233. title: "发布成功!",
  234. type: "success",
  235. confirmButtonColor: "#007AFF"
  236. }, function () {
  237. $scope.myData = _.reject($scope.myData, function (o) {
  238. return _.includes(selectedItem, o.id);
  239. });
  240. $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length;
  241. $scope.refreshData('expand-right', $scope.jry_fileData);
  242. });
  243. } else {
  244. SweetAlert.swal({
  245. title: "操作异常!",
  246. text: "系统异常,请稍后重试,或者联系管理员!",
  247. type: "error"
  248. });
  249. }
  250. })
  251. }
  252. })
  253. }
  254. $scope.minTime = "";
  255. $scope.maxTime = "";
  256. // 新增
  257. $scope.addData = function () {
  258. $state.go('app.system.form', {
  259. formKey: 'serviceGuideForm',
  260. service: 'api_solution'
  261. });
  262. }
  263. //列表操作按钮-查看
  264. // $scope.onDblClick = function(data) {
  265. // var modelfile = { model: { serviceGuide: data } };
  266. // $state.go('app.system.form_editor', { formKey: 'serviceGuideDetail', service: 'api_solution', model: JSON.stringify(modelfile) });
  267. // };
  268. $scope.seeDetail = function (data) {
  269. var modelfile = {
  270. model: {
  271. serviceGuide: data
  272. }
  273. };
  274. $state.go('app.system.form_editor', {
  275. formKey: 'serviceGuideDetail',
  276. service: 'api_solution',
  277. model: JSON.stringify(modelfile)
  278. });
  279. };
  280. //列表操作按钮-编辑
  281. $scope.saveData = function (data) {
  282. var modelData = {
  283. model: {
  284. serviceGuide: data
  285. }
  286. };
  287. $state.go('app.system.form', {
  288. formKey: 'serviceGuideEdi',
  289. service: 'api_solution',
  290. model: JSON.stringify(modelData),
  291. 'isServiceGuideEdit': "true"
  292. });
  293. };
  294. // 搜索
  295. $scope.searchData = function () {
  296. if ($scope.minTime) {
  297. $scope.jry_fileData.serviceGuide.startTime = moment($scope.minTime).format("YYYY-MM-DD HH:mm:ss")
  298. }
  299. if ($scope.maxTime) {
  300. $scope.jry_fileData.serviceGuide.endTime = moment($scope.maxTime).format("YYYY-MM-DD HH:mm:ss")
  301. }
  302. $scope.refreshData('expand-right', $scope.jry_fileData);
  303. }
  304. // 清空
  305. $scope.clean = function () {
  306. delete $scope.jry_fileData.serviceGuide.title;
  307. delete $scope.jry_fileData.serviceGuide.serviceType;
  308. delete $scope.jry_fileData.serviceGuide.startTime;
  309. $scope.minTime = "";
  310. delete $scope.jry_fileData.serviceGuide.endTime;
  311. $scope.maxTime = "";
  312. delete $scope.jry_fileData.serviceGuide.createUser;
  313. $scope.refreshData('expand-right', $scope.jry_fileData);
  314. }
  315. // 撤回
  316. $scope.withdraw = function (data) {
  317. var modalInstance = $modal.open({
  318. templateUrl: 'assets/views/delete.html',
  319. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  320. $scope.title = '服务指南撤回';
  321. $scope.connect = '确定要撤回此服务指南?';
  322. $scope.ok = function () {
  323. $modalInstance.close(data);
  324. };
  325. $scope.cancel = function () {
  326. $modalInstance.dismiss('cancel');
  327. };
  328. },
  329. size: 'sm',
  330. resolve: {
  331. scope: function () {
  332. return $scope;
  333. }
  334. }
  335. });
  336. modalInstance.result.then(function (selectedItem) {
  337. if (selectedItem) {
  338. console.log(selectedItem);
  339. delete selectedItem.item;
  340. selectedItem.status = 3;
  341. api_solution.updData("serviceGuide", {
  342. "serviceGuide": selectedItem
  343. }).then(function (res) {
  344. if (res.data) {
  345. SweetAlert.swal({
  346. title: "撤回成功!",
  347. type: "success",
  348. confirmButtonColor: "#007AFF"
  349. })
  350. $scope.refreshData('expand-right', $scope.jry_fileData);
  351. } else {
  352. SweetAlert.swal({
  353. title: "操作异常!",
  354. text: "系统异常,请稍后重试,或者联系管理员!",
  355. type: "error"
  356. });
  357. }
  358. })
  359. }
  360. })
  361. }
  362. // 删除
  363. $scope.removeData = function (data) {
  364. var modalInstance = $modal.open({
  365. templateUrl: 'assets/views/delete.html',
  366. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  367. var rmvList = [];
  368. $scope.title = '服务指南删除';
  369. $scope.connect = '确定要删除此服务指南?';
  370. // angular.forEach(scope.selected.items, function(item) {
  371. // rmvList.push(item.id);
  372. // });
  373. rmvList.push(data.id);
  374. $scope.ok = function () {
  375. $modalInstance.close(rmvList);
  376. };
  377. $scope.cancel = function () {
  378. $modalInstance.dismiss('cancel');
  379. };
  380. },
  381. size: 'sm',
  382. resolve: {
  383. scope: function () {
  384. return $scope;
  385. }
  386. }
  387. });
  388. modalInstance.result.then(function (selectedItem) {
  389. if (selectedItem) {
  390. if (selectedItem.length > 0) {
  391. api_solution.rmvData('serviceGuide', selectedItem).then(function (response) {
  392. if (response.data) {
  393. SweetAlert.swal({
  394. title: "删除成功!",
  395. type: "success",
  396. confirmButtonColor: "#007AFF"
  397. }, function () {
  398. $scope.myData = _.reject($scope.myData, function (o) {
  399. return _.includes(selectedItem, o.id);
  400. });
  401. $scope.selected = {
  402. items: []
  403. };
  404. $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length;
  405. // $scope.gridApi.grid.selection.selectedCount = 0;
  406. $scope.refreshData('expand-right', $scope.jry_fileData);
  407. });
  408. } else {
  409. SweetAlert.swal({
  410. title: "操作异常!",
  411. text: "系统异常,请稍后重试,或者联系管理员!",
  412. type: "error"
  413. });
  414. }
  415. })
  416. }
  417. }
  418. })
  419. }
  420. $scope.selected = {
  421. items: []
  422. }
  423. $scope.editted = {
  424. items: []
  425. }
  426. $scope.jry_fileData = {
  427. "idx": 0,
  428. "sum": 10,
  429. "serviceGuide": {}
  430. }
  431. $scope.gridOptions.onRegisterApi = function (gridApi) {
  432. $scope.gridApi = gridApi;
  433. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  434. // var filtersData = $scope.memoryfilterData;
  435. // filtersData.idx = newPage - 1;
  436. $scope.jry_fileData.idx = newPage - 1;
  437. // filtersData.sum = pageSize;
  438. $scope.jry_fileData.sum = pageSize;
  439. // defaultFilterData = filtersData;
  440. $scope.refreshData('expand-right', $scope.jry_fileData);
  441. });
  442. };
  443. // api_solution.jry_fetchDataList("serviceGuide",{"idx":0,"sum":10}).then(function(res){
  444. // console.log(res)
  445. // })
  446. $scope.serviceGuideType = [];
  447. // 获取分类
  448. $scope.getType = function () {
  449. var data = {
  450. key: "service_type",
  451. type: "list"
  452. }
  453. api_wechatfile.getDictionary(data).then(function (res) {
  454. $scope.serviceGuideType = res
  455. })
  456. }
  457. $scope.getType()
  458. $scope.ldloading = {};
  459. //获取数据
  460. $scope.refreshData = function (style, filterData) {
  461. $scope.ldloading[style.replace('-', '_')] = true;
  462. if (angular.isUndefined(filterData)) {
  463. filterData = defaultFilterData;
  464. }
  465. if (angular.isDefined($scope.searchTypes)) {
  466. filterData['searchType'] = $scope.searchTypes;
  467. }
  468. $scope.myData = [];
  469. // filterData['flag'] = -1;
  470. // console.log("filterData=" + JSON.stringify(filterData))
  471. api_solution.jry_fetchDataList('serviceGuide', filterData).then(function (data) {
  472. var myData = Restangular.stripRestangular(data);
  473. $scope.gridOptions.totalItems = myData.totalNum;
  474. $scope.myData = myData.list;
  475. for (var i = 0; i < $scope.myData.length; i++) {
  476. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  477. $scope.myData[i]['createTime'] = moment($scope.myData[i]['createTime']).format('YYYY-MM-DD HH:mm:ss')
  478. }
  479. $scope.ldloading[style.replace('-', '_')] = false;
  480. // console.log("$scope.myData="+JSON.stringify($scope.myData))
  481. }, function () {
  482. $scope.ldloading[style.replace('-', '_')] = false;
  483. });
  484. };
  485. //获取数据
  486. $scope.refreshData2 = function (style, filterData) {
  487. $scope.ldloading[style.replace('-', '_')] = true;
  488. if (angular.isUndefined(filterData)) {
  489. filterData = defaultFilterData;
  490. }
  491. if (angular.isDefined($scope.searchTypes)) {
  492. filterData['searchType'] = $scope.searchTypes;
  493. }
  494. // $scope.myData = [];
  495. // filterData['flag'] = -1;
  496. // console.log("filterData=" + JSON.stringify(filterData))
  497. api_solution.jry_fetchDataList('serviceGuide', filterData).then(function (data) {
  498. var myData = Restangular.stripRestangular(data);
  499. $scope.gridOptions.totalItems = myData.totalNum;
  500. $scope.myData = myData.list;
  501. for (var i = 0; i < $scope.myData.length; i++) {
  502. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  503. $scope.myData[i]['createTime'] = moment($scope.myData[i]['createTime']).format('YYYY-MM-DD HH:mm:ss')
  504. }
  505. $scope.ldloading[style.replace('-', '_')] = false;
  506. // console.log("$scope.myData="+JSON.stringify($scope.myData))
  507. }, function () {
  508. $scope.ldloading[style.replace('-', '_')] = false;
  509. });
  510. };
  511. $scope.timer = $interval(function () {
  512. $scope.refreshData2('expand-right', $scope.jry_fileData);
  513. }, $rootScope.refreshTime);
  514. $scope.$on('$destroy', function () {
  515. $interval.cancel($scope.timer)
  516. })
  517. $scope.refreshData('expand-right', $scope.jry_fileData);
  518. }]);