statistics.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. import Task from "../../mixins/task";
  113. export default {
  114. name: 'ProjectStatistics',
  115. components: {DrawerTabsContainer},
  116. props: {
  117. projectid: {
  118. default: 0
  119. },
  120. canload: {
  121. type: Boolean,
  122. default: true
  123. },
  124. },
  125. mixins: [
  126. Task
  127. ],
  128. data () {
  129. return {
  130. loadYet: false,
  131. loadIng: 0,
  132. columns: [],
  133. taskType: '未完成',
  134. lists: [],
  135. listPage: 1,
  136. listTotal: 0,
  137. noDataText: "数据加载中.....",
  138. statistics_unfinished: 0,
  139. statistics_overdue: 0,
  140. statistics_complete: 0,
  141. }
  142. },
  143. created() {
  144. this.columns = [{
  145. "title": "任务名称",
  146. "key": 'title',
  147. "minWidth": 120,
  148. render: (h, params) => {
  149. return this.renderTaskTitle(h, params);
  150. }
  151. }, {
  152. "title": "创建人",
  153. "key": 'createuser',
  154. "minWidth": 80,
  155. }, {
  156. "title": "负责人",
  157. "key": 'username',
  158. "minWidth": 80,
  159. }, {
  160. "title": "创建时间",
  161. "width": 160,
  162. render: (h, params) => {
  163. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  164. }
  165. }];
  166. },
  167. mounted() {
  168. if (this.canload) {
  169. this.loadYet = true;
  170. this.getLists(true);
  171. }
  172. $A.setOnTaskInfoListener('components/project/statistics', (act, detail) => {
  173. if (this.projectid > 0 && detail.projectid != this.projectid) {
  174. return;
  175. }
  176. this.lists.some((task, i) => {
  177. if (task.id == detail.id) {
  178. this.lists.splice(i, 1, detail);
  179. return true;
  180. }
  181. });
  182. //
  183. switch (act) {
  184. case "delete": // 删除任务
  185. case "archived": // 归档
  186. this.lists.some((task, i) => {
  187. if (task.id == detail.id) {
  188. this.lists.splice(i, 1);
  189. if (task.complete) {
  190. this.statistics_complete--;
  191. } else {
  192. this.statistics_unfinished++;
  193. }
  194. return true;
  195. }
  196. });
  197. break;
  198. case "unarchived": // 取消归档
  199. let has = false;
  200. this.lists.some((task) => {
  201. if (task.id == detail.id) {
  202. if (task.complete) {
  203. this.statistics_complete++;
  204. } else {
  205. this.statistics_unfinished--;
  206. }
  207. return has = true;
  208. }
  209. });
  210. if (!has) {
  211. this.lists.unshift(detail);
  212. }
  213. break;
  214. case "complete": // 标记完成
  215. this.statistics_complete++;
  216. this.statistics_unfinished--;
  217. break;
  218. case "unfinished": // 标记未完成
  219. this.statistics_complete--;
  220. this.statistics_unfinished++;
  221. break;
  222. }
  223. });
  224. },
  225. watch: {
  226. projectid() {
  227. if (this.loadYet) {
  228. this.getLists(true);
  229. }
  230. },
  231. canload(val) {
  232. if (val && !this.loadYet) {
  233. this.loadYet = true;
  234. this.getLists(true);
  235. }
  236. },
  237. taskType() {
  238. if (this.loadYet) {
  239. this.getLists(true);
  240. }
  241. }
  242. },
  243. methods: {
  244. setPage(page) {
  245. this.listPage = page;
  246. this.getLists();
  247. },
  248. setPageSize(size) {
  249. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  250. this.listPageSize = size;
  251. this.getLists();
  252. }
  253. },
  254. getLists(resetLoad) {
  255. if (resetLoad === true) {
  256. this.listPage = 1;
  257. }
  258. if (this.projectid == 0) {
  259. this.lists = [];
  260. this.listTotal = 0;
  261. this.noDataText = "没有相关的数据";
  262. return;
  263. }
  264. this.loadIng++;
  265. let tempType = this.taskType;
  266. $A.aAjax({
  267. url: 'project/task/lists',
  268. data: {
  269. page: Math.max(this.listPage, 1),
  270. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  271. projectid: this.projectid,
  272. type: this.taskType,
  273. statistics: 1
  274. },
  275. complete: () => {
  276. this.loadIng--;
  277. },
  278. success: (res) => {
  279. if (tempType != this.taskType) {
  280. return;
  281. }
  282. if (res.ret === 1) {
  283. this.lists = res.data.lists;
  284. this.listTotal = res.data.total;
  285. this.noDataText = "没有相关的数据";
  286. } else {
  287. this.lists = [];
  288. this.listTotal = 0;
  289. this.noDataText = res.msg;
  290. }
  291. this.statistics_unfinished = res.data.statistics_unfinished || 0;
  292. this.statistics_overdue = res.data.statistics_overdue || 0;
  293. this.statistics_complete = res.data.statistics_complete || 0;
  294. }
  295. });
  296. },
  297. }
  298. }
  299. </script>