statistics.vue 11 KB

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