123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- <template>
- <drawer-tabs-container>
- <div class="project-statistics">
- <!-- 标签 -->
- <ul class="state-overview">
- <li :class="[taskType==='未完成'?'active':'']" @click="taskType='未完成'">
- <div class="yellow">
- <h1 class="count">{{statistics_unfinished}}</h1>
- <p>未完成任务</p>
- </div>
- </li>
- <li :class="[taskType==='已超期'?'active':'']" @click="taskType='已超期'">
- <div class="red">
- <h1 class="count">{{statistics_overdue}}</h1>
- <p>超期任务</p>
- </div>
- </li>
- <li :class="[taskType==='已完成'?'active':'']" @click="taskType='已完成'">
- <div class="terques">
- <h1 class="count">{{statistics_complete}}</h1>
- <p>已完成任务</p>
- </div>
- </li>
- </ul>
- <!-- 列表 -->
- <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
- <!-- 分页 -->
- <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>
- </div>
- </drawer-tabs-container>
- </template>
- <style lang="scss" scoped>
- .project-statistics {
- .tableFill {
- margin: 12px 12px 20px;
- }
- ul.state-overview {
- display: flex;
- align-items: center;
- > li {
- flex: 1;
- cursor: pointer;
- margin: 0 10px 5px;
- > div {
- position: relative;
- box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
- transition: all 0.2s;
- border-radius: 6px;
- color: #ffffff;
- height: 110px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- &.terques {
- background: #17BE6B;
- }
- &.purple {
- background: #A218A5;
- }
- &.red {
- background: #ED3F14;
- }
- &.yellow {
- background: #FF9900;
- }
- &.blue {
- background: #2D8CF0;
- }
- &:hover {
- box-shadow: 2px 2px 8px 0 rgba(0, 0, 0, 0.38);
- }
- &:after {
- position: absolute;
- content: "";
- left: 50%;
- bottom: 3px;
- width: 0;
- height: 2px;
- transform: translate(-50%, 0);
- background-color: #FFFFFF;
- border-radius: 2px;
- transition: all 0.3s;
- opacity: 0;
- }
- > h1 {
- font-size: 36px;
- margin: -2px 0 0;
- padding: 0;
- font-weight: 500;
- }
- > p {
- font-size: 18px;
- margin: 0;
- padding: 0;
- }
- }
- &.active {
- > div {
- &:after {
- width: 90%;
- opacity: 1;
- }
- }
- }
- }
- }
- }
- </style>
- <script>
- import DrawerTabsContainer from "../DrawerTabsContainer";
- import Task from "../../mixins/task";
- /**
- * 项目统计
- */
- export default {
- name: 'ProjectStatistics',
- components: {DrawerTabsContainer},
- props: {
- projectid: {
- default: 0
- },
- canload: {
- type: Boolean,
- default: true
- },
- },
- mixins: [
- Task
- ],
- data () {
- return {
- loadYet: false,
- loadIng: 0,
- columns: [],
- taskType: '未完成',
- lists: [],
- listPage: 1,
- listTotal: 0,
- noDataText: "数据加载中.....",
- statistics_unfinished: 0,
- statistics_overdue: 0,
- statistics_complete: 0,
- }
- },
- created() {
- this.columns = [{
- "title": "任务名称",
- "key": 'title',
- "minWidth": 120,
- render: (h, params) => {
- return this.renderTaskTitle(h, params);
- }
- }, {
- "title": "创建人",
- "key": 'createuser',
- "minWidth": 80,
- }, {
- "title": "负责人",
- "key": 'username',
- "minWidth": 80,
- }, {
- "title": "完成",
- "minWidth": 70,
- "align": "center",
- render: (h, params) => {
- return h('span', params.row.complete ? '√' : '-');
- }
- }, {
- "title": "创建时间",
- "width": 160,
- render: (h, params) => {
- return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
- }
- }];
- },
- mounted() {
- if (this.canload) {
- this.loadYet = true;
- this.getLists(true);
- }
- $A.setOnTaskInfoListener('components/project/statistics', (act, detail) => {
- if (detail.projectid != this.projectid) {
- return;
- }
- //
- this.lists.some((task, i) => {
- if (task.id == detail.id) {
- this.lists.splice(i, 1, detail);
- return true;
- }
- });
- //
- switch (act) {
- case "delete": // 删除任务
- case "archived": // 归档
- this.lists.some((task, i) => {
- if (task.id == detail.id) {
- this.lists.splice(i, 1);
- if (task.complete) {
- this.statistics_complete--;
- } else {
- this.statistics_unfinished++;
- }
- return true;
- }
- });
- break;
- case "unarchived": // 取消归档
- let has = false;
- this.lists.some((task) => {
- if (task.id == detail.id) {
- if (task.complete) {
- this.statistics_complete++;
- } else {
- this.statistics_unfinished--;
- }
- return has = true;
- }
- });
- if (!has) {
- this.lists.unshift(detail);
- }
- break;
- case "complete": // 标记完成
- this.statistics_complete++;
- this.statistics_unfinished--;
- break;
- case "unfinished": // 标记未完成
- this.statistics_complete--;
- this.statistics_unfinished++;
- break;
- }
- });
- },
- watch: {
- projectid() {
- if (this.loadYet) {
- this.getLists(true);
- }
- },
- canload(val) {
- if (val && !this.loadYet) {
- this.loadYet = true;
- this.getLists(true);
- }
- },
- taskType() {
- if (this.loadYet) {
- this.getLists(true);
- }
- }
- },
- methods: {
- setPage(page) {
- this.listPage = page;
- this.getLists();
- },
- setPageSize(size) {
- if (Math.max($A.runNum(this.listPageSize), 10) != size) {
- this.listPageSize = size;
- this.getLists();
- }
- },
- getLists(resetLoad) {
- if (resetLoad === true) {
- this.listPage = 1;
- }
- if (this.projectid == 0) {
- this.lists = [];
- this.listTotal = 0;
- this.noDataText = "没有相关的数据";
- return;
- }
- this.loadIng++;
- let tempType = this.taskType;
- this.noDataText = "数据加载中.....";
- $A.aAjax({
- url: 'project/task/lists',
- data: {
- page: Math.max(this.listPage, 1),
- pagesize: Math.max($A.runNum(this.listPageSize), 10),
- projectid: this.projectid,
- type: this.taskType,
- statistics: 1
- },
- complete: () => {
- this.loadIng--;
- },
- error: () => {
- this.noDataText = "数据加载失败!";
- },
- success: (res) => {
- if (tempType != this.taskType) {
- return;
- }
- if (res.ret === 1) {
- this.lists = res.data.lists;
- this.listTotal = res.data.total;
- this.noDataText = "没有相关的数据";
- } else {
- this.lists = [];
- this.listTotal = 0;
- this.noDataText = res.msg;
- }
- this.statistics_unfinished = res.data.statistics_unfinished || 0;
- this.statistics_overdue = res.data.statistics_overdue || 0;
- this.statistics_complete = res.data.statistics_complete || 0;
- }
- });
- },
- }
- }
- </script>
|