statistics.vue 8.2 KB

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