| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377 |
- <!--
- * @Author: wanglj 471442253@qq.com
- * @Date: 2022-12-13 10:28:33
- * @LastEditors: wanglj
- * @LastEditTime: 2023-03-27 16:41:46
- * @Description: file content
- * @FilePath: \opms_frontend\src\views\index\index.vue
- -->
- <template>
- <div class="index">
- <div class="left">
- <el-card class="board">
- <div slot="header" class="card-title">
- <span>个人看板</span>
- <div class="buttons">
- <el-button v-show="!editFlag" type="text" @click="editFlag = true">编辑布局</el-button>
- <el-button v-show="editFlag" type="text" @click="visible = true">编辑指标</el-button>
- <el-button v-show="editFlag" type="text" @click="saveLayout">保存布局</el-button>
- </div>
- </div>
- <el-row align="middle" :gutter="10" type="flex">
- <VueDragger
- v-model="privateBoard"
- :animation="500"
- :disabled="!editFlag"
- drag-class="drag"
- :force-fallback="true"
- ghost-class="ghost"
- handle=".mover">
- <el-col v-for="(item, index) in privateBoard" :key="index" class="mover" :span="6">
- <div class="board-container">
- <vab-icon class="icon" :icon="item.report_icon" />
- <div class="text">
- <p class="num">{{ item.report_data }}</p>
- <p>{{ item.report_name }}</p>
- </div>
- <vab-icon v-show="editFlag" class="close" icon="close-fill" @click.stop="handleDel(index)" />
- </div>
- </el-col>
- </VueDragger>
- </el-row>
- </el-card>
- <grid-layout
- :class="{ grid: editFlag }"
- :col-num="24"
- :is-draggable="editFlag"
- :is-mirrored="false"
- :is-resizable="editFlag"
- :layout.sync="layout"
- :margin="[10, 10]"
- :row-height="30"
- :use-css-transforms="true"
- :use-style-cursor="false"
- :vertical-compact="true"
- @layout-ready="layoutReadyEvent">
- <grid-item
- v-for="(item, index) in layout"
- :key="index"
- :h="item.h"
- :i="item.i"
- :w="item.w"
- :x="item.x"
- :y="item.y"
- @resized="handleResize">
- <h4>
- {{ item.name }}
- <!-- <div class="buttons">
- <el-select v-model="forecast" style="width: 120px">
- <el-option label="公司数据" value="1" />
- </el-select>
- </div> -->
- <div class="buttons">
- <el-radio-group
- v-show="!editFlag && (item.i == 20002 || item.i == 20003)"
- v-model="item.searchType"
- size="mini"
- @change="refresh(item, index)">
- <el-radio-button label="year">年</el-radio-button>
- <el-radio-button label="quarter">季度</el-radio-button>
- <el-radio-button label="month">月</el-radio-button>
- </el-radio-group>
- <el-radio-group
- v-show="!editFlag && (item.i == 20006 || item.i == 20007)"
- v-model="item.searchType"
- size="mini"
- @change="refresh(item, index)">
- <el-radio-button label="1">一季度</el-radio-button>
- <el-radio-button label="2">二季度</el-radio-button>
- <el-radio-button label="3">三季度</el-radio-button>
- <el-radio-button label="4">三季度</el-radio-button>
- <el-radio-button label="0">全年</el-radio-button>
- </el-radio-group>
- <el-radio-group
- v-show="!editFlag && item.i == 20010"
- v-model="item.searchType"
- size="mini"
- @change="refresh(item, index)">
- <el-radio-button label="week">周</el-radio-button>
- <el-radio-button label="month">月</el-radio-button>
- </el-radio-group>
- <el-select
- v-show="!editFlag && item.i == 20009"
- v-model="item.searchType"
- placeholder="月份"
- size="mini"
- style="width: 100px"
- @change="refresh(item, index)">
- <el-option v-for="month in 12" :key="month" :label="month + '月'" :value="month" />
- </el-select>
- <el-button v-show="!editFlag" class="refreshBtn" type="text" @click="refresh(item, index)">
- 刷新
- </el-button>
- <vab-icon v-show="editFlag" icon="close-fill" @click="gridDel(index)" />
- </div>
- </h4>
- <div :id="item.i">
- <template v-if="item.i == 20009">
- <!-- <el-form label-width="40px" size="mini">
- <el-row justify="end" style="margin: 10px 0; padding: 0 5px" type="flex">
- <el-col :span="6">
- <el-form-item label="月份">
- <el-select
- v-show="!editFlag"
- v-model="item.searchType"
- placeholder="月份"
- size="mini"
- style="width: 100%"
- @change="refresh(item, index)">
- <el-option v-for="month in 12" :key="month" :label="month" :value="month" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form> -->
- <el-table border :data="item.table" height="100%" size="mini" style="width: 100%">
- <el-table-column align="center" label="周" prop="week" width="60px" />
- <el-table-column align="center" label="邮件" prop="email" />
- <el-table-column align="center" label="拜访" prop="payvisit" />
- <el-table-column align="center" label="电话" prop="phone" />
- </el-table>
- </template>
- </div>
- </grid-item>
- </grid-layout>
- </div>
- <div class="right">
- <el-card class="calendar">
- <div slot="header" class="card-title">
- <span>日程安排</span>
- <!-- <el-button style="padding: 0" type="text">添加</el-button> -->
- </div>
- <div class="week">
- <vab-icon
- icon="arrow-left-s-line"
- @click="
- date -= 7
- getDateList()
- " />
- <ul>
- <li
- v-for="(item, index) in list"
- :key="index"
- :class="{ active: item.day == day }"
- @click="dateClick(item)">
- <span>{{ dayList[item.day] }}</span>
- <span>{{ item.date }}</span>
- </li>
- </ul>
- <vab-icon
- icon="arrow-right-s-line"
- @click="
- date += 7
- getDateList()
- " />
- </div>
- <el-timeline v-if="activities.length">
- <el-timeline-item v-for="(activity, index) in activities" :key="index">
- <div class="detail" :class="{ active: activity.active }">
- <p class="time">
- {{ activity.schDate }}
- <!-- <el-button type="text">详情</el-button> -->
- </p>
- <p>{{ activity.schTitle }}</p>
- </div>
- </el-timeline-item>
- </el-timeline>
- <div class="timelineEmpty">暂无日程</div>
- </el-card>
- <el-card class="notice">
- <div slot="header" class="card-title">
- <span>公告</span>
- <div class="buttons">
- <el-button size="mini" @click="handleHistoryNotice">
- 更多
- <i class="el-icon-arrow-right el-icon--right"></i>
- </el-button>
- </div>
- </div>
- <ul>
- <li v-for="(message, index) in messageList" :key="index" class="notice-list" @click="getNoticeInfo(message)">
- <p>
- <span>【{{ msgTypeFormat(message) }}】</span>
- {{ message.msgTitle }}
- </p>
- <p class="time">
- <vab-icon icon="time-line" />
- {{ parseTime(message.createdTime, '{y}-{m}-{d}') }}
- </p>
- </li>
- </ul>
- </el-card>
- </div>
- <!-- 编辑指标 -->
- <el-dialog title="编辑指标" :visible.sync="visible" @open="getBoardOptions">
- <el-tabs v-model="activeName" type="card">
- <el-tab-pane label="看板数据" name="first">
- <ul class="add-board">
- <li v-for="(item, index) in addBoard" :key="index" @click="item.checked = !item.checked">
- <div class="board-container">
- <vab-icon class="icon" :icon="item.reportIcon" />
- <div class="text">
- <p class="num">*</p>
- <p>{{ item.reportName }}</p>
- </div>
- <vab-icon v-show="item.checked" class="check" icon="check-fill" />
- </div>
- </li>
- </ul>
- </el-tab-pane>
- <el-tab-pane label="销售指标" name="second">
- <ul class="add-board">
- <li v-for="(item, index) in addLayout" :key="index" @click="item.checked = !item.checked">
- <div class="board-container">
- <vab-icon class="icon" :icon="item.reportIcon" />
- <div class="text">
- <p class="num">*</p>
- <p>{{ item.reportName }}</p>
- </div>
- <vab-icon v-show="item.checked" class="check" icon="check-fill" />
- </div>
- </li>
- </ul>
- </el-tab-pane>
- </el-tabs>
- <template #footer>
- <el-button @click="visible = false">取 消</el-button>
- <el-button type="primary" @click="save">确 定</el-button>
- </template>
- </el-dialog>
- <!--通知公告详情-->
- <notice-details ref="notice-details" />
- </div>
- </template>
- <script>
- import NoticeDetails from '@/views/system/notice/details.vue'
- import * as echarts from 'echarts'
- import VueDragger from 'vuedraggable'
- import VueGridLayout from 'vue-grid-layout'
- import to from 'await-to-js'
- import indexApi from '@/api/index'
- import messageApi from '@/api/system/message'
- export default {
- name: 'Index',
- components: {
- NoticeDetails,
- VueDragger,
- GridLayout: VueGridLayout.GridLayout,
- GridItem: VueGridLayout.GridItem,
- },
- data() {
- return {
- editFlag: false,
- privateBoard: [
- // {
- // report_name: '当前客户数(个)',
- // id: 1,
- // report_icon: 'account-circle-line',
- // checked: false,
- // },
- // {
- // report_name: '新增客户数(个)',
- // id: 2,
- // report_icon: 'user-add-line',
- // checked: false,
- // },
- // {
- // report_name: '跟进客户数(个)',
- // id: 3,
- // report_icon: 'account-pin-box-line',
- // checked: false,
- // },
- // {
- // report_name: '合同订单数(个)',
- // id: 4,
- // report_icon: 'account-circle-line',
- // checked: false,
- // },
- // {
- // report_name: '合同订单金额(元)',
- // id: 5,
- // report_icon: 'exchange-cny-fill',
- // checked: false,
- // },
- // {
- // report_name: '新增机会数(个)',
- // id: 6,
- // report_icon: 'mail-add-line',
- // checked: false,
- // },
- // {
- // report_name: '新增机会金额(元)',
- // id: 7,
- // report_icon: 'exchange-cny-fill',
- // checked: false,
- // },
- // {
- // report_name: '采购合同数(个)',
- // id: 8,
- // report_icon: 'account-circle-line',
- // checked: false,
- // },
- // {
- // report_name: '采购金额(元)',
- // id: 9,
- // report_icon: 'money-cny-circle-line',
- // checked: false,
- // },
- // {
- // report_name: '应收未收(元)',
- // id: 10,
- // report_icon: 'money-cny-circle-line',
- // checked: false,
- // },
- // {
- // report_name: '计划付款(元)',
- // id: 11,
- // report_icon: 'money-cny-circle-line',
- // checked: false,
- // },
- // {
- // report_name: '当前库存成本(元)',
- // id: 12,
- // report_icon: 'money-cny-circle-line',
- // checked: false,
- // },
- ],
- addBoard: [],
- addLayout: [],
- visible: false,
- layout: [],
- day: -1,
- list: [],
- activities: [],
- charts: [],
- activeName: 'first',
- forecast: '1',
- date: 0,
- dayList: ['日', '一', '二', '三', '四', '五', '六'],
- messageList: [],
- msgTypeOptions: [],
- }
- },
- mounted() {
- this.init()
- this.getDateList()
- this.getOptions()
- this.handleNoticeList()
- this.$baseEventBus.$on('receivedMessage', () => {
- console.log('---------------通知更新公告----------------')
- this.handleNoticeList()
- })
- window.addEventListener('resize', this.handleResize)
- },
- beforeDestroy() {
- window.removeEventListener('resize', this.handleResize)
- },
- methods: {
- async getHomeNumReportData() {
- let ids = this.privateBoard.map((item) => {
- return item.id
- })
- const {
- data: { num_report_response },
- } = await indexApi.getHomeNumReportData({ ids: Array.from(new Set(ids)) })
- let privateBoardData = []
- this.privateBoard.forEach((item, index) => {
- num_report_response.forEach((val) => {
- if (item.id === val.id) {
- this.privateBoard[index].report_data = val.data
- privateBoardData.push(this.privateBoard[index])
- }
- })
- })
- this.privateBoard = privateBoardData
- },
- // 布局信息
- async init() {
- const [err, res] = await to(indexApi.getHomeReport({ module_code: 'HomePage' }))
- if (err) return
- const obj = JSON.parse(res.data.configInfo)
- this.privateBoard = obj.num_report_config || []
- if (obj.data_report_config && obj.data_report_config.length) {
- this.layout = obj.data_report_config.map((item) => {
- return {
- x: item.location_x,
- y: item.location_y,
- i: item.id,
- desc: item.report_desc,
- name: item.report_name,
- type: item.report_type,
- h: item.size_h,
- w: item.size_w,
- searchType: (() => {
- if (item.id == 20006 || item.id == 20007) {
- return '0'
- } else if (item.id == 20010) {
- return 'week'
- } else if (item.id == 20009) {
- return new Date().getMonth() + 1
- } else {
- return 'year'
- }
- // item.id != 20006 && item.id != 20007 ? 'year' : '0'
- })(),
- }
- })
- }
- await this.$nextTick()
- this.initChart()
- this.getHomeNumReportData()
- },
- initChart() {
- // console.log(this.layout, 'layout')
- this.charts = []
- for (let i = 0; i < this.layout.length; i++) {
- this.getChartSize(this.layout[i].i)
- if (this.layout[i].i == 20006 || this.layout[i].i == 20007) {
- this.drawGoalChart(this.layout[i].i, i)
- } else if (this.layout[i].i == 20008) {
- this.drawCheckChart(this.layout[i].i, i)
- } else if (this.layout[i].i == 20009) {
- this.getTable(this.layout[i].i, i)
- } else if (this.layout[i].i == 20010) {
- this.drawProjectTrans(this.layout[i].i, i)
- } else if (this.layout[i].i == 20011) {
- this.drawMoneyAmount(this.layout[i].i, i)
- } else if (this.layout[i].i == 20012) {
- this.drawMoneyReturn(this.layout[i].i, i)
- } else if (this.layout[i].i >= 20000 && this.layout[i].i <= 20003) {
- this.drawChart(this.layout[i].i, i)
- }
- }
- },
- //刷新
- refresh(item, index) {
- if (this.charts[index]) {
- this.charts[index].dispose && this.charts[index].dispose()
- }
- if (item.i == 20006 || item.i == 20007) {
- this.drawGoalChart(item.i, index, item.searchType)
- } else if (item.i == 20008) {
- this.drawCheckChart(item.i, index, item.searchType)
- } else if (item.i == 20009) {
- this.getTable(item.i, index, item.searchType)
- } else if (item.i == 20010) {
- this.drawProjectTrans(item.i, index, item.searchType)
- } else if (item.i == 20011) {
- this.drawMoneyAmount(item.i, index, item.searchType)
- } else if (item.i == 20012) {
- this.drawMoneyReturn(item.i, index, item.searchType)
- } else {
- this.drawChart(item.i, index, item.searchType)
- }
- },
- // 获取表格
- async getTable(id, i, searchType) {
- console.log(id, i)
- const [err, res] = await to(indexApi.getHomeDataReportData({ id, Params: { date: searchType } }))
- if (err) this.drawMoneyReturn
- this.layout.forEach((item) => {
- if (item.i == id) item.table = res.data.data || []
- })
- this.$forceUpdate()
- },
- getChartSize(id) {
- // console.log(id, 'id')
- const bar = document.getElementById(id)
- // console.log(bar, 'bar')
- bar.style.height = bar.parentNode.clientHeight - 65 + 'px'
- bar.style.width = bar.parentNode.clientWidth + 'px'
- },
- async drawChart(id, i, searchType) {
- const [err, res] = await to(indexApi.getHomeDataReportData({ id, Params: { searchType } }))
- if (err) return
- if (!res.data.data) return
- const chartBar = echarts.init(document.getElementById(id))
- const option = {
- grid: {
- bottom: 30,
- top: 40,
- right: 10,
- left: 10,
- containLabel: true,
- },
- tooltip: {
- trigger: 'axis',
- },
- xAxis: [
- {
- type: 'category',
- data: res.data.data.xData,
- axisTick: {
- alignWithLabel: true,
- },
- },
- ],
- yAxis: [
- {
- type: 'value',
- name: '金额(元)',
- alignTicks: true,
- },
- {
- type: 'value',
- name: res.data.id == 20000 || res.data.id == 20002 ? '签约完成率(%)' : '回款率(%)',
- min: 0,
- max: 100,
- alignTicks: true,
- interval: 20,
- axisLabel: {
- formatter: '{value} %',
- },
- },
- ],
- series: [
- {
- name: '销售指标',
- type: 'bar',
- data: res.data.data.yDataTarget,
- },
- {
- name: '销售额度',
- type: 'bar',
- data: res.data.data.yDataReal,
- },
- {
- name: '回款率',
- type: 'line',
- yAxisIndex: 1,
- tooltip: {
- valueFormatter: function (value) {
- return value + '%'
- },
- },
- data: res.data.data.percentData,
- },
- ],
- }
- chartBar.setOption(option)
- this.charts[i] = chartBar
- },
- async drawCheckChart(id, i) {
- const chartBar = echarts.init(document.getElementById(id))
- const [err, res] = await to(indexApi.getHomeDataReportData({ id }))
- if (err) return
- console.log(res, 'res')
- const option = {
- grid: {
- bottom: 30,
- top: 40,
- right: 10,
- left: 10,
- containLabel: true,
- },
- tooltip: {
- trigger: 'axis',
- },
- xAxis: [
- {
- type: 'category',
- data: res.data.data.xData,
- axisTick: {
- alignWithLabel: true,
- },
- },
- ],
- yAxis: [
- {
- type: 'value',
- name: '打卡(次)',
- },
- ],
- series: [
- {
- name: '打卡频次',
- type: 'bar',
- data: res.data.data.yDataTarget,
- },
- ],
- }
- chartBar.setOption(option)
- this.charts[i] = chartBar
- },
- async drawProjectTrans(id, i, searchType = 'week') {
- const [err, res] = await to(indexApi.getHomeDataReportData({ id, Params: { searchType } }))
- if (err) return
- const arr = res.data.data || []
- const chartBar = echarts.init(document.getElementById(id))
- const option = {
- grid: {
- bottom: 0,
- top: 40,
- right: 10,
- left: 10,
- containLabel: true,
- },
- tooltip: {
- trigger: 'axis',
- },
- xAxis: [
- {
- type: 'category',
- data: ['新增', 'C转B', 'B转A', 'A转签约', 'C转A', 'C转签约', 'B转签约', '储备转A/B/C/签约'],
- axisTick: {
- alignWithLabel: true,
- },
- axisLabel: {
- interval: 0,
- rotate: 30,
- },
- },
- ],
- yAxis: [
- {
- type: 'value',
- name: '数量',
- },
- ],
- series: arr.map((item, index) => {
- return {
- name: (() => {
- if (index === 0) {
- return 'BIOBANK方案'
- } else if (index === 1) {
- return 'CELLSOP方案'
- } else {
- return 'LIMS方案'
- }
- })(),
- type: 'bar',
- data: item,
- }
- }),
- }
- chartBar.setOption(option)
- this.charts[i] = chartBar
- },
- async drawMoneyAmount(id, i) {
- const [err, res] = await to(indexApi.getHomeDataReportData({ id }))
- if (err) return
- const arr = res.data.data || []
- const chartBar = echarts.init(document.getElementById(id))
- const option = {
- grid: {
- bottom: 30,
- top: 40,
- right: 10,
- left: 10,
- containLabel: true,
- },
- tooltip: {
- trigger: 'axis',
- },
- xAxis: [
- {
- type: 'category',
- data: ['BioBank', 'CellSOP', 'LIMS'],
- axisTick: {
- alignWithLabel: true,
- },
- },
- ],
- yAxis: [
- {
- type: 'value',
- name: '出货金额(元)',
- },
- ],
- series: arr.map((item, index) => {
- return {
- name: (() => {
- if (index === 0) {
- return 'A类项目'
- } else {
- return 'B类项目'
- }
- })(),
- type: 'bar',
- data: item,
- }
- }),
- }
- chartBar.setOption(option)
- this.charts[i] = chartBar
- },
- async drawMoneyReturn(id, i) {
- const [err, res] = await to(indexApi.getHomeDataReportData({ id }))
- if (err) return
- const arr = res.data.data || []
- const chartBar = echarts.init(document.getElementById(id))
- const option = {
- grid: {
- bottom: 30,
- top: 40,
- right: 10,
- left: 10,
- containLabel: true,
- },
- tooltip: {
- trigger: 'axis',
- },
- xAxis: [
- {
- type: 'category',
- data: ['BioBank', 'CellSOP', 'LIMS'],
- axisTick: {
- alignWithLabel: true,
- },
- },
- ],
- yAxis: [
- {
- type: 'value',
- name: '回款金额(元)',
- },
- ],
- series: arr.map((item, index) => {
- return {
- name: (() => {
- if (index === 0) {
- return '当月签约'
- } else if (index === 1) {
- return '累计签约'
- } else if (index === 2) {
- return '当月回款'
- } else {
- return '累计回款'
- }
- })(),
- type: 'bar',
- data: item,
- }
- }),
- }
- chartBar.setOption(option)
- this.charts[i] = chartBar
- },
- async drawGoalChart(id, i, searchType) {
- const chartBar = echarts.init(document.getElementById(id))
- const [err, res] = await to(
- indexApi.getHomeDataReportData({
- id,
- Params: {
- year: new Date().getFullYear(),
- quarter: parseInt(searchType),
- },
- })
- )
- if (err) return
- console.log(res.data.data)
- const option = {
- grid: {
- bottom: 30,
- top: 40,
- right: 10,
- left: 10,
- containLabel: true,
- },
- tooltip: {
- trigger: 'axis',
- },
- xAxis: [
- {
- type: 'category',
- data: res.data.data.xData,
- axisTick: {
- alignWithLabel: true,
- },
- },
- ],
- yAxis: [
- {
- type: 'value',
- name: '金额(万元)',
- alignTicks: true,
- },
- ],
- series: [
- {
- name: id == 20006 ? '销售指标' : '回款指标',
- type: 'bar',
- data: res.data.data.yDataTarget,
- },
- {
- name: id == 20006 ? '销售额度' : '回款额度',
- type: 'bar',
- data: res.data.data.yDataReal,
- },
- ],
- }
- chartBar.setOption(option)
- this.charts[i] = chartBar
- },
- initFunnel() {
- this.chartFunnel = echarts.init(document.getElementById('funnel'))
- const option = {
- tooltip: {
- trigger: 'item',
- formatter: '{b} : {d}%',
- },
- label: {
- formatter: '{b} {c}',
- },
- labelLine: {
- show: true,
- },
- series: [
- {
- name: '销售漏斗',
- type: 'funnel',
- top: 10,
- bottom: 10,
- minSize: '20%',
- maxSize: '100%',
- label: {
- position: 'inside',
- formatter: '{c}%',
- color: '#fff',
- },
- data: [
- { value: 500, name: '初步洽谈' },
- { value: 300, name: '深入沟通' },
- { value: 250, name: '产品报价' },
- { value: 150, name: '成交项目' },
- { value: 120, name: '流失项目' },
- ],
- },
- {
- name: '销售漏斗',
- type: 'funnel',
- top: 10,
- bottom: 10,
- minSize: '20%',
- maxSize: '100%',
- z: 1,
- data: [
- { value: 500, name: '初步洽谈' },
- { value: 300, name: '深入沟通' },
- { value: 250, name: '产品报价' },
- { value: 150, name: '成交项目' },
- { value: 120, name: '流失项目' },
- ],
- },
- ],
- }
- this.chartFunnel.setOption(option)
- },
- async handleResize() {
- await this.$nextTick()
- for (let i = 0; i < this.layout.length; i++) {
- this.getChartSize(this.layout[i].i)
- if (this.charts[i]) this.charts[i].resize && this.charts[i].resize()
- }
- },
- layoutReadyEvent() {
- this.initChart()
- },
- handleDel(index) {
- this.privateBoard.splice(index, 1)
- },
- gridDel(index) {
- this.layout.splice(index, 1)
- },
- async save() {
- const board = this.addBoard.filter((item) => item.checked == true)
- this.privateBoard = []
- for (const item of board) {
- this.privateBoard.push({
- report_name: item.reportName,
- id: item.id,
- report_icon: item.reportIcon,
- })
- }
- const layout = this.addLayout.filter((item) => item.checked == true)
- for (const item of layout) {
- const index = this.layout.findIndex((each) => each.i == item.id)
- if (index > -1) continue
- this.layout.push({
- x: 0,
- y: 0,
- w: 12,
- h: 10,
- i: item.id,
- type: 'bar',
- name: item.reportName,
- searchType: 'year',
- })
- }
- this.visible = false
- await this.$nextTick()
- this.initChart()
- },
- async saveLayout() {
- this.editFlag = false
- const params = {
- module_code: 'HomePage',
- data_report_config: [],
- num_report_config: this.privateBoard,
- }
- params.data_report_config = this.layout.map((item) => {
- return {
- location_x: item.x,
- location_y: item.y,
- id: item.i,
- report_desc: item.desc,
- report_name: item.name,
- report_type: item.type,
- size_h: item.h,
- size_w: item.w,
- }
- })
- const [err, res] = await to(indexApi.setUpHomeConfig(params))
- if (err) return
- this.$message.success(res.msg)
- this.getHomeNumReportData()
- },
- getDateList() {
- const now = new Date()
- const date = new Date(now.getTime() + this.date * 1000 * 60 * 60 * 24)
- const day = date.getDay()
- this.day = day
- this.list = new Array(7)
- for (let i = 0; i < this.list.length; i++) {
- this.list[i] = {}
- const flag = -(day - i)
- const time = new Date(date.getTime() + flag * 1000 * 60 * 60 * 24)
- this.list[i].time = new Date(time)
- this.list[i].day = this.list[i].time.getDay()
- this.list[i].date = this.list[i].time.getDate()
- if (flag == 0) this.dateClick(this.list[i])
- }
- },
- async dateClick(item) {
- this.day = item.day
- const [err, res] = await to(indexApi.getSchedule({ schDate: this.parseTime(item.time) }))
- if (err) return
- this.activities = res.data.list || []
- const date = new Date().getTime()
- this.activities.forEach((item) => {
- const start = new Date(item.schDate).getTime()
- const end = new Date(item.schDateEnd).getTime()
- item.active = start <= date && end >= date
- })
- },
- async getBoardOptions() {
- this.activeName = 'first'
- const [err, res] = await to(indexApi.getRoleReportList())
- if (err) return
- console.log(res)
- const arr = res.data.list || []
- arr.forEach((item) => (item.checked = false))
- this.addLayout = arr.filter((item) => item.reportType == 20)
- this.addLayout.forEach((item) => {
- const index = this.layout.findIndex((each) => each.i == item.id)
- if (index > -1) item.checked = true
- })
- this.addBoard = arr.filter((item) => item.reportType == 10)
- this.addBoard.forEach((item) => {
- const index = this.privateBoard.findIndex((each) => each.id == item.id)
- if (index > -1) item.checked = true
- })
- },
- getOptions() {
- this.getDicts('sys_msg_type').then((response) => {
- this.msgTypeOptions = response.data.values || []
- })
- },
- msgTypeFormat(row) {
- return this.selectDictLabel(this.msgTypeOptions, row.msgType)
- },
- handleHistoryNotice() {
- this.$router.push({
- name: 'NoticeHistory',
- })
- },
- async handleNoticeList() {
- const { data } = await messageApi.getList({ msgType: '10' })
- this.messageList = data.list
- },
- getNoticeInfo(row) {
- this.$refs['notice-details'].open(row.id)
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- $base: '.index';
- #{$base} {
- display: flex;
- background: #f6f8f9;
- height: calc(100vh - 60px - 12px * 2 - 40px);
- .el-card {
- margin-bottom: 12px;
- border-radius: 4px;
- }
- .card-title {
- font-size: 16px;
- font-weight: 700;
- line-height: 22px;
- height: 22px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- i {
- font-weight: normal;
- cursor: pointer;
- &:hover {
- color: #1d66dc;
- }
- }
- }
- .left {
- flex: 1;
- margin-right: 10px;
- overflow-x: hidden;
- overflow-y: auto;
- .buttons {
- .el-radio-group {
- margin-right: 4px;
- }
- }
- .board {
- display: flex;
- flex-direction: column;
- margin-bottom: 2px;
- ::v-deep .el-card__body {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- }
- .el-row {
- height: 100%;
- flex-wrap: wrap;
- > div,
- > div span {
- display: flex;
- height: 100%;
- align-items: center;
- flex-wrap: wrap;
- width: 100%;
- }
- .ghost {
- background: #ecf5ff;
- }
- .drag {
- background: pink;
- }
- .el-col {
- display: flex;
- height: 60px;
- margin: 20px 0;
- user-select: none;
- cursor: pointer;
- }
- }
- }
- }
- .right {
- width: 450px;
- .detail {
- height: 64px;
- border: 1px solid rgb(235, 237, 240);
- border-radius: 4px;
- &.active {
- border: 1px solid #d7e8f4;
- background: #f7fbfe;
- p:last-child {
- font-weight: bold;
- }
- }
- p {
- height: 32px;
- line-height: 32px;
- padding: 0 10px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .time {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- }
- .calendar {
- height: 60%;
- border-radius: 4px;
- display: flex;
- flex-direction: column;
- ::v-deep .el-card__body {
- flex: 1;
- overflow: hidden;
- }
- .week {
- height: 48px;
- display: flex;
- align-items: center;
- ul {
- flex: 1;
- display: flex;
- height: 48px;
- li {
- flex: 1;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- user-select: none;
- cursor: pointer;
- &.active span:last-child {
- background: rgb(34, 76, 218);
- color: #fff;
- }
- span {
- flex: 1;
- height: 24px;
- width: 24px;
- text-align: center;
- line-height: 24px;
- }
- span:first-child {
- color: rgb(150, 151, 153);
- }
- span:last-child {
- color: rgb(50, 50, 51);
- border-radius: 4px;
- }
- }
- }
- i {
- height: 24px;
- width: 24px;
- font-size: 24px;
- color: rgb(100, 101, 102);
- background: rgb(247, 248, 250);
- border-radius: 4px;
- cursor: pointer;
- transition: 0.3s all;
- &:hover {
- color: #fff;
- background: rgb(100, 101, 102);
- }
- }
- }
- .el-timeline {
- margin-top: 20px;
- padding-top: 4px;
- height: calc(100% - 72px);
- overflow: auto;
- .el-timeline-item {
- padding-bottom: 10px;
- }
- }
- .timelineEmpty {
- height: calc(100% - 72px);
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- .notice {
- height: calc(40% - 12px);
- display: flex;
- flex-direction: column;
- ::v-deep .el-card__body {
- flex: 1;
- overflow: auto;
- }
- .notice-list {
- display: flex;
- justify-content: space-between;
- height: 40px;
- line-height: 40px;
- border-bottom: 1px solid #ebeef5;
- p:first-child {
- flex: 1;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- span {
- font-weight: bold;
- }
- }
- }
- }
- }
- ::v-deep .el-timeline-item__tail {
- border-left: 2px dashed #e4e7ed;
- }
- // #funnel,
- // #bar {
- // height: 100%;
- // }
- .vue-grid-layout {
- margin-left: -10px;
- margin-right: -10px;
- &.grid {
- background: linear-gradient(90deg, #fff 10px, transparent 0), linear-gradient(#fff 10px, transparent 0);
- background-size: calc((100% - 10px) / 24) 40px;
- background-position: top 0px left 0px;
- }
- }
- .vue-grid-item {
- background: #fff;
- border: 1px solid #ebeef5;
- border-radius: 4px;
- box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
- overflow: hidden;
- .el-form-item--mini.el-form-item {
- margin-bottom: 0;
- }
- h4 {
- line-height: 22px;
- height: 54px;
- font-size: 16px;
- padding: 16px 20px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- border-bottom: 1px solid #ebeef5;
- i {
- font-size: 24px;
- font-weight: bold;
- cursor: pointer;
- &:hover {
- color: #1d66dc;
- }
- }
- }
- .refreshBtn {
- margin-left: 8px;
- }
- }
- .board-container {
- display: flex;
- height: 60px;
- border: 1px solid #eee;
- align-items: center;
- border-radius: 8px;
- padding: 0 10px;
- flex: 1;
- cursor: pointer;
- user-select: none;
- &:hover {
- box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
- }
- .icon {
- font-size: 32px;
- border-radius: 4px;
- width: 40px;
- height: 40px;
- color: #1d66dc;
- background: #ecf5ff;
- &.ri-money-cny-circle-line {
- color: #e6a23c;
- background: #fdf6ec;
- }
- &.ri-exchange-cny-fill {
- color: #f56c6c;
- background: #fef0f0;
- }
- }
- .full-icon {
- flex: 1;
- font-size: 32px;
- }
- .close {
- font-size: 32px;
- transition: 0.3s all;
- &:hover {
- color: #1d66dc;
- }
- }
- .check {
- font-size: 32px;
- color: #67c23a;
- }
- .text {
- padding-left: 10px;
- color: #9499a0;
- flex: 1;
- .num {
- font-size: 22px;
- font-weight: bold;
- color: #333;
- }
- }
- }
- .add-board {
- height: 500px;
- overflow: auto;
- li + li {
- margin-top: 10px;
- }
- }
- </style>
|