statistics.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="project-statistics">
  3. <!-- 标签 -->
  4. <ul class="state-overview">
  5. <li :class="[taskType==='未完成'?'active':'']" @click="taskType='未完成'">
  6. <div class="yellow">
  7. <h1 class="count">{{statistics_unfinished}}</h1>
  8. <p>未完成任务</p>
  9. </div>
  10. </li>
  11. <li :class="[taskType==='已超期'?'active':'']" @click="taskType='已超期'">
  12. <div class="red">
  13. <h1 class="count">{{statistics_overdue}}</h1>
  14. <p>超期任务</p>
  15. </div>
  16. </li>
  17. <li :class="[taskType==='已完成'?'active':'']" @click="taskType='已完成'">
  18. <div class="terques">
  19. <h1 class="count">{{statistics_complete}}</h1>
  20. <p>已完成任务</p>
  21. </div>
  22. </li>
  23. </ul>
  24. <!-- 列表 -->
  25. <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
  26. <!-- 分页 -->
  27. <Page class="pageBox" :total="listTotal" :current="listPage" :disabled="loadIng > 0" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total transfer></Page>
  28. </div>
  29. </template>
  30. <style lang="scss" scoped>
  31. .project-statistics {
  32. .tableFill {
  33. margin: 12px 12px 20px;
  34. }
  35. ul.state-overview {
  36. display: flex;
  37. align-items: center;
  38. > li {
  39. flex: 1;
  40. cursor: pointer;
  41. margin: 0 10px 5px;
  42. > div {
  43. position: relative;
  44. -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
  45. box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
  46. transition: all 0.2s;
  47. border-radius: 6px;
  48. color: #ffffff;
  49. height: 110px;
  50. display: flex;
  51. flex-direction: column;
  52. justify-content: center;
  53. align-items: center;
  54. &.terques {
  55. background: #17BE6B;
  56. }
  57. &.purple {
  58. background: #A218A5;
  59. }
  60. &.red {
  61. background: #ED3F14;
  62. }
  63. &.yellow {
  64. background: #FF9900;
  65. }
  66. &.blue {
  67. background: #2D8CF0;
  68. }
  69. &:hover {
  70. box-shadow: 2px 2px 8px 0 rgba(0, 0, 0, 0.38);
  71. }
  72. &:after {
  73. position: absolute;
  74. content: "";
  75. left: 50%;
  76. bottom: 3px;
  77. width: 0;
  78. height: 2px;
  79. transform: translate(-50%, 0);
  80. background-color: #FFFFFF;
  81. border-radius: 2px;
  82. transition: all 0.3s;
  83. opacity: 0;
  84. }
  85. > h1 {
  86. font-size: 36px;
  87. margin: -2px 0 0;
  88. padding: 0;
  89. font-weight: 500;
  90. }
  91. > p {
  92. font-size: 18px;
  93. margin: 0;
  94. padding: 0;
  95. }
  96. }
  97. &.active {
  98. > div {
  99. &:after {
  100. width: 90%;
  101. opacity: 1;
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. </style>
  109. <script>
  110. export default {
  111. name: 'ProjectStatistics',
  112. props: {
  113. projectid: {
  114. default: 0
  115. },
  116. canload: {
  117. type: Boolean,
  118. default: true
  119. },
  120. },
  121. data () {
  122. return {
  123. loadYet: false,
  124. loadIng: 0,
  125. columns: [],
  126. taskType: '未完成',
  127. lists: [],
  128. listPage: 1,
  129. listTotal: 0,
  130. noDataText: "数据加载中.....",
  131. statistics_unfinished: 0,
  132. statistics_overdue: 0,
  133. statistics_complete: 0,
  134. }
  135. },
  136. created() {
  137. this.columns = [{
  138. "title": "任务名称",
  139. "key": 'title',
  140. "minWidth": 100,
  141. }, {
  142. "title": "创建人",
  143. "key": 'createuser',
  144. "minWidth": 80,
  145. }, {
  146. "title": "负责人",
  147. "key": 'username',
  148. "minWidth": 80,
  149. }, {
  150. "title": "创建时间",
  151. "width": 160,
  152. render: (h, params) => {
  153. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  154. }
  155. }];
  156. },
  157. mounted() {
  158. if (this.canload) {
  159. this.loadYet = true;
  160. this.getLists(true);
  161. }
  162. },
  163. watch: {
  164. projectid() {
  165. if (this.loadYet) {
  166. this.getLists(true);
  167. }
  168. },
  169. canload(val) {
  170. if (val && !this.loadYet) {
  171. this.loadYet = true;
  172. this.getLists(true);
  173. }
  174. },
  175. taskType() {
  176. if (this.loadYet) {
  177. this.getLists(true);
  178. }
  179. }
  180. },
  181. methods: {
  182. setPage(page) {
  183. this.listPage = page;
  184. this.getLists();
  185. },
  186. setPageSize(size) {
  187. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  188. this.listPageSize = size;
  189. this.getLists();
  190. }
  191. },
  192. getLists(resetLoad) {
  193. if (resetLoad === true) {
  194. this.listPage = 1;
  195. }
  196. if (this.projectid == 0) {
  197. this.lists = [];
  198. this.listTotal = 0;
  199. this.noDataText = "没有相关的数据";
  200. return;
  201. }
  202. this.loadIng++;
  203. $A.aAjax({
  204. url: 'project/task/lists',
  205. data: {
  206. page: Math.max(this.listPage, 1),
  207. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  208. projectid: this.projectid,
  209. type: this.taskType,
  210. statistics: 1
  211. },
  212. complete: () => {
  213. this.loadIng--;
  214. },
  215. success: (res) => {
  216. if (res.ret === 1) {
  217. this.lists = res.data.lists;
  218. this.listTotal = res.data.total;
  219. this.statistics_unfinished = res.data.statistics_unfinished;
  220. this.statistics_overdue = res.data.statistics_overdue;
  221. this.statistics_complete = res.data.statistics_complete;
  222. } else {
  223. this.lists = [];
  224. this.listTotal = 0;
  225. this.noDataText = res.msg;
  226. this.statistics_unfinished = 0;
  227. this.statistics_overdue = 0;
  228. this.statistics_complete = 0;
  229. }
  230. }
  231. });
  232. },
  233. }
  234. }
  235. </script>