Blame view

src/views/home/index.vue 10.4 KB
赵千 committed
1
<template>
任超 committed
2 3 4 5
  <div class="home">
    <div class="home-left">
      <el-row :gutter="8">
        <el-col :span="12">
任超 committed
6
          <el-card shadow="hover" :body-style="{ padding: '0' }" style="height:260px">
蔡俊立 committed
7 8 9 10
            <div slot="header" class="flexst">
              <h5 class="title">常办项目</h5>
              <el-button type="primary" @click="setFrequencyProject()">配置常办</el-button>
            </div>
任超 committed
11
            <ul class="workbench flexst">
任超 committed
12
              <li v-for="(item, index) in projectList" @click="handleProject(item)" class="pointer" :key="index"
任超 committed
13
                :style="{ backgroundColor: newsListColor[index] }">
任超 committed
14
                <i class="el-icon-s-claim"></i>
蔡俊立 committed
15
                {{ item.name }}
任超 committed
16 17
              </li>
            </ul>
任超 committed
18 19 20
          </el-card>
        </el-col>
        <el-col :span="12">
任超 committed
21
          <el-card shadow="hover" style="height:260px">
任超 committed
22
            <div slot="header" class="flexst">
蔡俊立 committed
23
              <h5 class="title">系统通知</h5>
蔡俊立 committed
24 25
              <el-popover placement="right" width="50" trigger="hover">
                <ul class="pointer">
任超 committed
26
                  <li @click="$store.dispatch('tagsView/addView', moreNotice)">查看更多</li>
蔡俊立 committed
27 28 29
                </ul>
                <i class="el-icon-s-unfold pointer" slot="reference"></i>
              </el-popover>
任超 committed
30
            </div>
任超 committed
31 32 33
            <ul>
              <li v-for="(item, index) in noticeList" :key="index" @click="handleNotice(item)" class="flexst pointer">
                <p class="list-title">{{ item.noticeTitle }}</p>
蔡俊立 committed
34
                <p class="marginZL15">{{ item.noticePublishTime.substring(0, 10) }}</p>
任超 committed
35
                <p v-if="item.userBrowse == '1'" style="color:red">未读</p>
蔡俊立 committed
36
                <p v-else style="color:green">已读</p>
任超 committed
37 38
              </li>
            </ul>
任超 committed
39 40 41 42 43
          </el-card>
        </el-col>
      </el-row>
      <el-row :gutter="8" class="marginTop10">
        <el-col :span="12">
任超 committed
44
          <el-card shadow="hover" style="height:215px">
任超 committed
45 46 47 48 49
            <div slot="header" class="flexst">
              <h5 class="title">待办事项</h5>
              <i class="el-icon-s-unfold pointer"></i>
            </div>
            <ul>
蔡俊立 committed
50
              <li v-for="(item, index) in todoList" :key="index" class="flexst">
任超 committed
51
                <p class="right15">{{ item.dealTime.substring(0, 10) }}</p>
任超 committed
52
                <p class="list-title" style="text-align:right">{{ item.dealBusiness }} ({{ item.dealStep + '环节' }})</p>
任超 committed
53 54 55 56 57
              </li>
            </ul>
          </el-card>
        </el-col>
        <el-col :span="12">
任超 committed
58
          <el-card shadow="hover" style="height:215px">
任超 committed
59
            <div slot="header" class="flexst">
田浩浩 committed
60
              <h5 class="title">政策法规</h5>
蔡俊立 committed
61 62
              <el-popover placement="right" width="50" trigger="hover">
                <ul class="pointer">
任超 committed
63
                  <li @click="$store.dispatch('tagsView/addView', moreNotice)">查看更多</li>
蔡俊立 committed
64 65 66
                </ul>
                <i class="el-icon-s-unfold pointer" slot="reference"></i>
              </el-popover>
任超 committed
67 68
            </div>
            <ul>
任超 committed
69 70
              <li v-for="(item, index) in policyList" @click="handleView(item.noticeFileUrl)" :key="index"
                class="flexst pointer">
任超 committed
71 72
                <p class="right15 list-title">{{ item.noticeTitle }}</p>
                <p>{{ item.createtime.substring(0, 10) }}</p>
任超 committed
73 74 75 76 77
              </li>
            </ul>
          </el-card>
        </el-col>
      </el-row>
任超 committed
78 79
      <el-card shadow="hover" class="marginTop10 box-mountNode" id="mountNodeCon"
        :body-style="{ padding: '8px 6px 0 6px' }">
任超 committed
80 81 82 83
        <div id="mountNode"></div>
      </el-card>
    </div>
    <div class="home-right">
任超 committed
84
      <el-card shadow="hover">
任超 committed
85 86 87 88 89
        <div slot="header" class="flexst">
          <h5 class="title">用户登录时间</h5>
        </div>
        <div id="loginTime"></div>
      </el-card>
任超 committed
90
      <el-card class="marginTop10" shadow="hover">
蔡俊立 committed
91 92 93 94 95
        <div slot="header" class="flexst">
          <h5 class="title">动态信息</h5>
          <i class="el-icon-s-unfold pointer"></i>
        </div>
        <ul>
任超 committed
96
          <li v-for="(item, index) in doneList.slice(0, 10)" :key="index" class="flexst dynamicInfo">
任超 committed
97 98
            <p class="right15">{{ item.dealTime.substring(0, 10) }}</p>
            <p class="list-title">{{ item.dealBusiness }} ({{ item.dealStep + '环节' }})</p>
蔡俊立 committed
99 100
          </li>
        </ul>
任超 committed
101 102
      </el-card>
    </div>
任超 committed
103
    <addDialog ref="addProject" v-model="projectDialog" :bindItem="projectList" />
赵千 committed
104 105 106
  </div>
</template>
<script>
任超 committed
107
import * as G2 from '@antv/g2'
任超 committed
108
import vueSeamlessScroll from "vue-seamless-scroll"
任超 committed
109
import { getHomeNoticeList, getHomeTodoList, getHomeDoneList, getHomeFrequentProjects } from "@/api/user.js";
蔡俊立 committed
110
import addDialog from "./components/addProject.vue";
赵千 committed
111
export default {
任超 committed
112
  name: 'home',
任超 committed
113
  components: { vueSeamlessScroll, addDialog },
赵千 committed
114 115
  data () {
    return {
任超 committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
      listData: [
        {
          icon: '',
          title: '任务'
        },
        {
          icon: '',
          title: '邮件'
        },
        {
          icon: '',
          title: '消息'
        },
        {
          icon: '',
          title: '日历'
        },
        {
          icon: '',
          title: '常用功能'
        },
        {
          icon: '',
          title: '申请'
        }
      ],
      newsListColor: ['#61AEFF', '#43DEB3', '#F3C143', '#F09936', '#9C92FF', '#589FFF',],
任超 committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
      chartData: [{
        year: '1991',
        value: 15468
      }, {
        year: '1992',
        value: 16100
      }, {
        year: '1993',
        value: 15900
      }, {
        year: '1994',
        value: 17409
      }, {
        year: '1995',
        value: 17000
      }, {
        year: '1996',
        value: 31056
      }, {
任超 committed
162 163
        year: '1996',
        value: 31056
任超 committed
164
      }],
任超 committed
165
      // 系统通知
蔡俊立 committed
166 167 168 169 170 171 172 173 174 175 176
      noticeData: {},
      noticeList: [],//通知列表
      todoList: [],//待办列表
      doneList: [],//已办列表
      policyList: [],//法律法规列表
      projectList: [],//常办项目列表
      projectDialog: false,
      moreNotice: {
        fullPath: '/system/xttz/xttzview',
        name: '系统通知',
        path: '/system/xttz/xttzview',
任超 committed
177
        meta: { title: '系统通知' }
任超 committed
178
      },
赵千 committed
179 180
    }
  },
任超 committed
181
  mounted () {
蔡俊立 committed
182
    this.buildChart();//构建图标
任超 committed
183
    this.loginTimeChart()
蔡俊立 committed
184 185 186 187
    this.queryTodoList();//获取待办列表
    this.queryDoneList();//获取已办列表
    this.queryNoticeList();//获取通知、法律法规列表
    this.queryProjectList();//获取常办项目列表
赵千 committed
188 189
  },
  methods: {
任超 committed
190 191 192 193
    handleProject (item) {
      let url = item.uri.split('/').slice(0, 3).join('/')
      this.$router.push(url)
    },
蔡俊立 committed
194 195
    handleView (pdfUrl) {
      const href = pdfUrl
任超 committed
196 197
      window.open(href, '_blank');
    },
蔡俊立 committed
198
    //获取待办事项列表
任超 committed
199
    queryTodoList () {
蔡俊立 committed
200
      getHomeTodoList().then(res => {
任超 committed
201
        if (res.result) {
任超 committed
202
          this.todoList = res.result
蔡俊立 committed
203 204 205 206
        }
      })
    },
    //获取已办事项列表
任超 committed
207
    queryDoneList () {
蔡俊立 committed
208
      getHomeDoneList().then(res => {
任超 committed
209
        if (res.result) {
蔡俊立 committed
210 211 212 213 214
          this.doneList = res.result
        }
      })
    },
    //获取通知列表
任超 committed
215
    queryNoticeList () {
蔡俊立 committed
216
      getHomeNoticeList().then(res => {
任超 committed
217
        if (res.result) {
任超 committed
218
          this.noticeList = res.result.noticeList
任超 committed
219
          this.noticeList.forEach(item => {
蔡俊立 committed
220
            item.noticePublishTime = this._timedate(item.noticePublishTime)
任超 committed
221
          })
任超 committed
222
          this.policyList = res.result.policyList
蔡俊立 committed
223 224 225
        }
      })
    },
蔡俊立 committed
226
    //获取常办项目列表
任超 committed
227
    queryProjectList () {
蔡俊立 committed
228
      getHomeFrequentProjects().then(res => {
任超 committed
229
        if (res.result && res.result.length > 0) {
蔡俊立 committed
230
          this.projectList = res.result
任超 committed
231 232
        } else {
          this.projectList = this.listData
蔡俊立 committed
233 234 235
        }
      })
    },
任超 committed
236 237 238 239 240 241 242 243 244 245
    _timedate (d) {
      var td = new Date();
      td = new Date(td.getFullYear(), td.getMonth(), td.getDate());
      var od = new Date(d);
      od = new Date(od.getFullYear(), od.getMonth(), od.getDate());
      var xc = (od - td) / 1000 / 60 / 60 / 24;
      if (xc == -1) {
        return "昨天";
      } else if (xc == 0) {
        return "今天";
任超 committed
246
      } else {
任超 committed
247
        return d
任超 committed
248 249
      }
    },
任超 committed
250
    buildChart () {
任超 committed
251
      let height = document.getElementById("mountNodeCon").offsetHeight - 20
任超 committed
252 253
      var chart = new G2.Chart({
        container: 'mountNode',
任超 committed
254
        height: height
任超 committed
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
      });
      chart.source(this.chartData);
      chart.scale({
        value: {
          min: 10000
        },
        year: {
          range: [0, 1]
        }
      });
      chart.axis('value', {
        label: {
          formatter: function formatter (val) {
            return (val / 10000).toFixed(1) + 'k';
          }
        }
      });
      chart.tooltip({
        crosshairs: true
      })
      chart.forceFit();
      chart.area().position('year*value').shape('smooth');
      chart.line().position('year*value').size(2).shape('smooth');
      chart.render();
任超 committed
279
    },
任超 committed
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
    loginTimeChart () {
      var data = [{
        item: '用户1',
        count: 40,
        percent: 0.4
      }, {
        item: '用户2',
        count: 21,
        percent: 0.21
      }, {
        item: '用户3',
        count: 17,
        percent: 0.17
      }]
      var chart = new G2.Chart({
        container: 'loginTime',
        height: 260
      });
      chart.source(data, {
        percent: {
          formatter: function formatter (val) {
任超 committed
301
            val = val * 100 + '小时';
任超 committed
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
            return val;
          }
        }
      });
      chart.coord('theta');
      chart.tooltip({
        showTitle: false
      });
      chart.interval().position('percent').color('item').label('percent', {
        offset: -40,
        textStyle: {
          textAlign: 'center',
          shadowBlur: 2,
          shadowColor: 'rgba(0, 0, 0, .45)'
        }
      }).tooltip('item*percent', function (item, percent) {
任超 committed
318
        percent = percent * 100 + '小时';
任超 committed
319 320 321 322 323 324 325 326 327 328 329
        return {
          name: item,
          value: percent
        };
      }).style({
        lineWidth: 1,
        stroke: '#fff'
      });
      chart.forceFit();
      chart.render();
    },
蔡俊立 committed
330
    //跳转到更多通知列表页面
任超 committed
331
    jumpToMoreNotice () {
蔡俊立 committed
332 333 334
      console.log(this.$route);
    },
    //配置常办项目
任超 committed
335
    setFrequencyProject () {
蔡俊立 committed
336 337
      this.projectDialog = true;
    },
任超 committed
338
    handleNotice (item) {
任超 committed
339
      this.$alertMes(item.noticeTitle, item.noticeContent)
任超 committed
340
    }
赵千 committed
341 342 343
  }
}
</script>
任超 committed
344
<style scoped lang="scss">
任超 committed
345
@import "~@/styles/mixin.scss";
任超 committed
346
@import "./index.scss";
任超 committed
347 348

/deep/.el-card__body {
任超 committed
349
  padding: 3px 10px 5px 10px;
任超 committed
350
  overflow: hidden;
任超 committed
351
}
赵千 committed
352
</style>