statistics.vue 12 KB

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