directive.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. starter.directive('payBillList', function () {
  2. return {
  3. restrict: "E",
  4. scope: {
  5. bills: "=bills",
  6. loading: "=loading"
  7. },
  8. templateUrl: 'templates/template-payBillList.html',
  9. controller: function ($scope, $state, global) {
  10. $scope.user = global.user.usrid;
  11. $scope.todetails = function (id) {
  12. $state.go('paybilldetails', {
  13. id: id
  14. })
  15. }
  16. }
  17. }
  18. })
  19. .directive('filterBar', function () {
  20. return {
  21. restrict: "E",
  22. scope: {
  23. setuser: "&",
  24. selClick: "&",
  25. centerData: "=",
  26. userId: "="
  27. },
  28. templateUrl: "templates/template-filterbar.html",
  29. controller: function ($scope, $state, formatFilter, Member) {
  30. setdata();
  31. $scope.$watch('userId', function (newValue, oldValue) {
  32. if (newValue === oldValue) return;
  33. if (Member.selectedemplst.length > 0) {
  34. $scope.values.user_id = Member.selectedemplst[0].user_id;
  35. $scope.right_title = Member.selectedemplst[0].username;
  36. $scope.right_data[1].name = "选择单个成员" + formatFilter("({0})", Member.selectedemplst[0].username);
  37. $scope.selClick($scope.values);
  38. }
  39. });
  40. $scope.selectclick = function (item, index) {
  41. $scope.acitve_indexs[$scope.key] = index;
  42. $scope.Ishidded = !$scope.Ishidded;
  43. if ($scope.key == "R" && index == 1) {
  44. Member.routename = "";
  45. Member.titlename = "选择单个成员";
  46. Member.selectedemplst = [];
  47. $state.go('selectsinglemember');
  48. return;
  49. } else if ($scope.key == "R" && index == 0) {
  50. Member.selectedemplst = [];
  51. $scope.setuser();
  52. $scope.right_title = $scope.right_data[0].name = "全部成员";
  53. $scope.right_data[1].name = "选择单个成员";
  54. }
  55. $scope.key == "L" ? $scope.values.date = $scope.left_data[index].key : ($scope.key == "C" ? $scope.values.status = $scope.centerData[index].key : $scope.values.user_id = $scope.right_data[index].key);
  56. $scope.selClick($scope.values);
  57. };
  58. $scope.headerclick = function (key) {
  59. if ($scope.key == key) {
  60. $scope.Ishidded = !$scope.Ishidded;
  61. } else {
  62. $scope.key = key;
  63. $scope.Ishidded = false;
  64. }
  65. };
  66. function setdata() {
  67. $scope.acitve_indexs = {"L": 0, "C": 0, "R": 0};
  68. $scope.key = "L";
  69. $scope.Ishidded = true;
  70. $scope.left_data = [];
  71. var year = new Date().getFullYear();
  72. $scope.left_data.push({"key": null, "name": "全部时间", "check": true});
  73. for (var y = year; y >= year - 1; y--) {
  74. $scope.left_data.push({"key": formatFilter('{0}', y), "name": formatFilter('{0}年 全年', y), "check": false});
  75. for (var m = 1; m < 13; m++) {
  76. $scope.left_data.push({"key": formatFilter('{0}-{1}', y, m), "name": formatFilter('{0}年 {1}月', y, m), "check": false})
  77. }
  78. }
  79. $scope.right_data = [{"key": null, "name": "全部成员", "check": true}, {"key": null, "name": "选择单个成员", "check": false}];
  80. $scope.data = {"L": $scope.left_data, "C": $scope.centerData, "R": $scope.right_data};
  81. $scope.values = {"date": _.find($scope.left_data, {check: true}).key, "status": _.find($scope.centerData, {check: true}).key, "user_id": _.find($scope.right_data, {check: true}).key};
  82. $scope.right_title = $scope.right_data[0].name;
  83. }
  84. }
  85. }
  86. })