statistics.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. "minWidth": 70,
  162. "align": "center",
  163. render: (h, params) => {
  164. return h('span', params.row.complete ? '√' : '-');
  165. }
  166. }, {
  167. "title": "创建时间",
  168. "width": 160,
  169. render: (h, params) => {
  170. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  171. }
  172. }];
  173. },
  174. mounted() {
  175. if (this.canload) {
  176. this.loadYet = true;
  177. this.getLists(true);
  178. }
  179. $A.setOnTaskInfoListener('components/project/statistics', (act, detail) => {
  180. if (this.projectid > 0 && detail.projectid != this.projectid) {
  181. return;
  182. }
  183. this.lists.some((task, i) => {
  184. if (task.id == detail.id) {
  185. this.lists.splice(i, 1, detail);
  186. return true;
  187. }
  188. });
  189. //
  190. switch (act) {
  191. case "delete": // 删除任务
  192. case "archived": // 归档
  193. this.lists.some((task, i) => {
  194. if (task.id == detail.id) {
  195. this.lists.splice(i, 1);
  196. if (task.complete) {
  197. this.statistics_complete--;
  198. } else {
  199. this.statistics_unfinished++;
  200. }
  201. return true;
  202. }
  203. });
  204. break;
  205. case "unarchived": // 取消归档
  206. let has = false;
  207. this.lists.some((task) => {
  208. if (task.id == detail.id) {
  209. if (task.complete) {
  210. this.statistics_complete++;
  211. } else {
  212. this.statistics_unfinished--;
  213. }
  214. return has = true;
  215. }
  216. });
  217. if (!has) {
  218. this.lists.unshift(detail);
  219. }
  220. break;
  221. case "complete": // 标记完成
  222. this.statistics_complete++;
  223. this.statistics_unfinished--;
  224. break;
  225. case "unfinished": // 标记未完成
  226. this.statistics_complete--;
  227. this.statistics_unfinished++;
  228. break;
  229. }
  230. });
  231. },
  232. watch: {
  233. projectid() {
  234. if (this.loadYet) {
  235. this.getLists(true);
  236. }
  237. },
  238. canload(val) {
  239. if (val && !this.loadYet) {
  240. this.loadYet = true;
  241. this.getLists(true);
  242. }
  243. },
  244. taskType() {
  245. if (this.loadYet) {
  246. this.getLists(true);
  247. }
  248. }
  249. },
  250. methods: {
  251. setPage(page) {
  252. this.listPage = page;
  253. this.getLists();
  254. },
  255. setPageSize(size) {
  256. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  257. this.listPageSize = size;
  258. this.getLists();
  259. }
  260. },
  261. getLists(resetLoad) {
  262. if (resetLoad === true) {
  263. this.listPage = 1;
  264. }
  265. if (this.projectid == 0) {
  266. this.lists = [];
  267. this.listTotal = 0;
  268. this.noDataText = "没有相关的数据";
  269. return;
  270. }
  271. this.loadIng++;
  272. let tempType = this.taskType;
  273. $A.aAjax({
  274. url: 'project/task/lists',
  275. data: {
  276. page: Math.max(this.listPage, 1),
  277. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  278. projectid: this.projectid,
  279. type: this.taskType,
  280. statistics: 1
  281. },
  282. complete: () => {
  283. this.loadIng--;
  284. },
  285. success: (res) => {
  286. if (tempType != this.taskType) {
  287. return;
  288. }
  289. if (res.ret === 1) {
  290. this.lists = res.data.lists;
  291. this.listTotal = res.data.total;
  292. this.noDataText = "没有相关的数据";
  293. } else {
  294. this.lists = [];
  295. this.listTotal = 0;
  296. this.noDataText = res.msg;
  297. }
  298. this.statistics_unfinished = res.data.statistics_unfinished || 0;
  299. this.statistics_overdue = res.data.statistics_overdue || 0;
  300. this.statistics_complete = res.data.statistics_complete || 0;
  301. }
  302. });
  303. },
  304. }
  305. }
  306. </script>