statistics.vue 8.0 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. box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
  45. transition: all 0.2s;
  46. border-radius: 6px;
  47. color: #ffffff;
  48. height: 110px;
  49. display: flex;
  50. flex-direction: column;
  51. justify-content: center;
  52. align-items: center;
  53. &.terques {
  54. background: #17BE6B;
  55. }
  56. &.purple {
  57. background: #A218A5;
  58. }
  59. &.red {
  60. background: #ED3F14;
  61. }
  62. &.yellow {
  63. background: #FF9900;
  64. }
  65. &.blue {
  66. background: #2D8CF0;
  67. }
  68. &:hover {
  69. box-shadow: 2px 2px 8px 0 rgba(0, 0, 0, 0.38);
  70. }
  71. &:after {
  72. position: absolute;
  73. content: "";
  74. left: 50%;
  75. bottom: 3px;
  76. width: 0;
  77. height: 2px;
  78. transform: translate(-50%, 0);
  79. background-color: #FFFFFF;
  80. border-radius: 2px;
  81. transition: all 0.3s;
  82. opacity: 0;
  83. }
  84. > h1 {
  85. font-size: 36px;
  86. margin: -2px 0 0;
  87. padding: 0;
  88. font-weight: 500;
  89. }
  90. > p {
  91. font-size: 18px;
  92. margin: 0;
  93. padding: 0;
  94. }
  95. }
  96. &.active {
  97. > div {
  98. &:after {
  99. width: 90%;
  100. opacity: 1;
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. </style>
  108. <script>
  109. export default {
  110. name: 'ProjectStatistics',
  111. props: {
  112. projectid: {
  113. default: 0
  114. },
  115. canload: {
  116. type: Boolean,
  117. default: true
  118. },
  119. },
  120. data () {
  121. return {
  122. loadYet: false,
  123. loadIng: 0,
  124. columns: [],
  125. taskType: '未完成',
  126. lists: [],
  127. listPage: 1,
  128. listTotal: 0,
  129. noDataText: "数据加载中.....",
  130. statistics_unfinished: 0,
  131. statistics_overdue: 0,
  132. statistics_complete: 0,
  133. }
  134. },
  135. created() {
  136. this.columns = [{
  137. "title": "任务名称",
  138. "key": 'title',
  139. "minWidth": 100,
  140. }, {
  141. "title": "创建人",
  142. "key": 'createuser',
  143. "minWidth": 80,
  144. }, {
  145. "title": "负责人",
  146. "key": 'username',
  147. "minWidth": 80,
  148. }, {
  149. "title": "创建时间",
  150. "width": 160,
  151. render: (h, params) => {
  152. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  153. }
  154. }];
  155. },
  156. mounted() {
  157. if (this.canload) {
  158. this.loadYet = true;
  159. this.getLists(true);
  160. }
  161. },
  162. watch: {
  163. projectid() {
  164. if (this.loadYet) {
  165. this.getLists(true);
  166. }
  167. },
  168. canload(val) {
  169. if (val && !this.loadYet) {
  170. this.loadYet = true;
  171. this.getLists(true);
  172. }
  173. },
  174. taskType() {
  175. if (this.loadYet) {
  176. this.getLists(true);
  177. }
  178. }
  179. },
  180. methods: {
  181. setPage(page) {
  182. this.listPage = page;
  183. this.getLists();
  184. },
  185. setPageSize(size) {
  186. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  187. this.listPageSize = size;
  188. this.getLists();
  189. }
  190. },
  191. getLists(resetLoad) {
  192. if (resetLoad === true) {
  193. this.listPage = 1;
  194. }
  195. if (this.projectid == 0) {
  196. this.lists = [];
  197. this.listTotal = 0;
  198. this.noDataText = "没有相关的数据";
  199. return;
  200. }
  201. this.loadIng++;
  202. let tempType = this.taskType;
  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 (tempType != this.taskType) {
  217. return;
  218. }
  219. if (res.ret === 1) {
  220. this.lists = res.data.lists;
  221. this.listTotal = res.data.total;
  222. } else {
  223. this.lists = [];
  224. this.listTotal = 0;
  225. this.noDataText = res.msg;
  226. }
  227. this.statistics_unfinished = res.data.statistics_unfinished || 0;
  228. this.statistics_overdue = res.data.statistics_overdue || 0;
  229. this.statistics_complete = res.data.statistics_complete || 0;
  230. }
  231. });
  232. },
  233. }
  234. }
  235. </script>