index.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  1. <!--
  2. * @Author: wanglj 471442253@qq.com
  3. * @Date: 2022-12-13 10:28:33
  4. * @LastEditors: wanglj
  5. * @LastEditTime: 2023-03-27 16:41:46
  6. * @Description: file content
  7. * @FilePath: \opms_frontend\src\views\index\index.vue
  8. -->
  9. <template>
  10. <div class="index">
  11. <div class="left">
  12. <el-card class="board">
  13. <div slot="header" class="card-title">
  14. <span>个人看板</span>
  15. <div class="buttons">
  16. <el-button v-show="!editFlag" type="text" @click="editFlag = true">编辑布局</el-button>
  17. <el-button v-show="editFlag" type="text" @click="visible = true">编辑指标</el-button>
  18. <el-button v-show="editFlag" type="text" @click="saveLayout">保存布局</el-button>
  19. </div>
  20. </div>
  21. <el-row align="middle" :gutter="10" type="flex">
  22. <VueDragger
  23. v-model="privateBoard"
  24. :animation="500"
  25. :disabled="!editFlag"
  26. drag-class="drag"
  27. :force-fallback="true"
  28. ghost-class="ghost"
  29. handle=".mover">
  30. <el-col v-for="(item, index) in privateBoard" :key="index" class="mover" :span="6">
  31. <div class="board-container">
  32. <vab-icon class="icon" :icon="item.report_icon" />
  33. <div class="text">
  34. <p class="num">{{ item.report_data }}</p>
  35. <p>{{ item.report_name }}</p>
  36. </div>
  37. <vab-icon v-show="editFlag" class="close" icon="close-fill" @click.stop="handleDel(index)" />
  38. </div>
  39. </el-col>
  40. </VueDragger>
  41. </el-row>
  42. </el-card>
  43. <grid-layout
  44. :class="{ grid: editFlag }"
  45. :col-num="24"
  46. :is-draggable="editFlag"
  47. :is-mirrored="false"
  48. :is-resizable="editFlag"
  49. :layout.sync="layout"
  50. :margin="[10, 10]"
  51. :row-height="30"
  52. :use-css-transforms="true"
  53. :use-style-cursor="false"
  54. :vertical-compact="true"
  55. @layout-ready="layoutReadyEvent">
  56. <grid-item
  57. v-for="(item, index) in layout"
  58. :key="index"
  59. :h="item.h"
  60. :i="item.i"
  61. :w="item.w"
  62. :x="item.x"
  63. :y="item.y"
  64. @resized="handleResize">
  65. <h4>
  66. {{ item.name }}
  67. <!-- <div class="buttons">
  68. <el-select v-model="forecast" style="width: 120px">
  69. <el-option label="公司数据" value="1" />
  70. </el-select>
  71. </div> -->
  72. <div class="buttons">
  73. <el-radio-group
  74. v-show="!editFlag && (item.i == 20002 || item.i == 20003)"
  75. v-model="item.searchType"
  76. size="mini"
  77. @change="refresh(item, index)">
  78. <el-radio-button label="year">年</el-radio-button>
  79. <el-radio-button label="quarter">季度</el-radio-button>
  80. <el-radio-button label="month">月</el-radio-button>
  81. </el-radio-group>
  82. <el-radio-group
  83. v-show="!editFlag && (item.i == 20006 || item.i == 20007)"
  84. v-model="item.searchType"
  85. size="mini"
  86. @change="refresh(item, index)">
  87. <el-radio-button label="1">一季度</el-radio-button>
  88. <el-radio-button label="2">二季度</el-radio-button>
  89. <el-radio-button label="3">三季度</el-radio-button>
  90. <el-radio-button label="4">三季度</el-radio-button>
  91. <el-radio-button label="0">全年</el-radio-button>
  92. </el-radio-group>
  93. <el-radio-group
  94. v-show="!editFlag && item.i == 20010"
  95. v-model="item.searchType"
  96. size="mini"
  97. @change="refresh(item, index)">
  98. <el-radio-button label="week">周</el-radio-button>
  99. <el-radio-button label="month">月</el-radio-button>
  100. </el-radio-group>
  101. <el-select
  102. v-show="!editFlag && item.i == 20009"
  103. v-model="item.searchType"
  104. placeholder="月份"
  105. size="mini"
  106. style="width: 100px"
  107. @change="refresh(item, index)">
  108. <el-option v-for="month in 12" :key="month" :label="month + '月'" :value="month" />
  109. </el-select>
  110. <el-button v-show="!editFlag" class="refreshBtn" type="text" @click="refresh(item, index)">
  111. 刷新
  112. </el-button>
  113. <vab-icon v-show="editFlag" icon="close-fill" @click="gridDel(index)" />
  114. </div>
  115. </h4>
  116. <div :id="item.i">
  117. <template v-if="item.i == 20009">
  118. <!-- <el-form label-width="40px" size="mini">
  119. <el-row justify="end" style="margin: 10px 0; padding: 0 5px" type="flex">
  120. <el-col :span="6">
  121. <el-form-item label="月份">
  122. <el-select
  123. v-show="!editFlag"
  124. v-model="item.searchType"
  125. placeholder="月份"
  126. size="mini"
  127. style="width: 100%"
  128. @change="refresh(item, index)">
  129. <el-option v-for="month in 12" :key="month" :label="month" :value="month" />
  130. </el-select>
  131. </el-form-item>
  132. </el-col>
  133. </el-row>
  134. </el-form> -->
  135. <el-table border :data="item.table" height="100%" size="mini" style="width: 100%">
  136. <el-table-column align="center" label="周" prop="week" width="60px" />
  137. <el-table-column align="center" label="邮件" prop="email" />
  138. <el-table-column align="center" label="拜访" prop="payvisit" />
  139. <el-table-column align="center" label="电话" prop="phone" />
  140. </el-table>
  141. </template>
  142. </div>
  143. </grid-item>
  144. </grid-layout>
  145. </div>
  146. <div class="right">
  147. <el-card class="calendar">
  148. <div slot="header" class="card-title">
  149. <span>日程安排</span>
  150. <!-- <el-button style="padding: 0" type="text">添加</el-button> -->
  151. </div>
  152. <div class="week">
  153. <vab-icon
  154. icon="arrow-left-s-line"
  155. @click="
  156. date -= 7
  157. getDateList()
  158. " />
  159. <ul>
  160. <li
  161. v-for="(item, index) in list"
  162. :key="index"
  163. :class="{ active: item.day == day }"
  164. @click="dateClick(item)">
  165. <span>{{ dayList[item.day] }}</span>
  166. <span>{{ item.date }}</span>
  167. </li>
  168. </ul>
  169. <vab-icon
  170. icon="arrow-right-s-line"
  171. @click="
  172. date += 7
  173. getDateList()
  174. " />
  175. </div>
  176. <el-timeline v-if="activities.length">
  177. <el-timeline-item v-for="(activity, index) in activities" :key="index">
  178. <div class="detail" :class="{ active: activity.active }">
  179. <p class="time">
  180. {{ activity.schDate }}
  181. <!-- <el-button type="text">详情</el-button> -->
  182. </p>
  183. <p>{{ activity.schTitle }}</p>
  184. </div>
  185. </el-timeline-item>
  186. </el-timeline>
  187. <div class="timelineEmpty">暂无日程</div>
  188. </el-card>
  189. <el-card class="notice">
  190. <div slot="header" class="card-title">
  191. <span>公告</span>
  192. <div class="buttons">
  193. <el-button size="mini" @click="handleHistoryNotice">
  194. 更多
  195. <i class="el-icon-arrow-right el-icon--right"></i>
  196. </el-button>
  197. </div>
  198. </div>
  199. <ul>
  200. <li v-for="(message, index) in messageList" :key="index" class="notice-list" @click="getNoticeInfo(message)">
  201. <p>
  202. <span>【{{ msgTypeFormat(message) }}】</span>
  203. {{ message.msgTitle }}
  204. </p>
  205. <p class="time">
  206. <vab-icon icon="time-line" />
  207. {{ parseTime(message.createdTime, '{y}-{m}-{d}') }}
  208. </p>
  209. </li>
  210. </ul>
  211. </el-card>
  212. </div>
  213. <!-- 编辑指标 -->
  214. <el-dialog title="编辑指标" :visible.sync="visible" @open="getBoardOptions">
  215. <el-tabs v-model="activeName" type="card">
  216. <el-tab-pane label="看板数据" name="first">
  217. <ul class="add-board">
  218. <li v-for="(item, index) in addBoard" :key="index" @click="item.checked = !item.checked">
  219. <div class="board-container">
  220. <vab-icon class="icon" :icon="item.reportIcon" />
  221. <div class="text">
  222. <p class="num">*</p>
  223. <p>{{ item.reportName }}</p>
  224. </div>
  225. <vab-icon v-show="item.checked" class="check" icon="check-fill" />
  226. </div>
  227. </li>
  228. </ul>
  229. </el-tab-pane>
  230. <el-tab-pane label="销售指标" name="second">
  231. <ul class="add-board">
  232. <li v-for="(item, index) in addLayout" :key="index" @click="item.checked = !item.checked">
  233. <div class="board-container">
  234. <vab-icon class="icon" :icon="item.reportIcon" />
  235. <div class="text">
  236. <p class="num">*</p>
  237. <p>{{ item.reportName }}</p>
  238. </div>
  239. <vab-icon v-show="item.checked" class="check" icon="check-fill" />
  240. </div>
  241. </li>
  242. </ul>
  243. </el-tab-pane>
  244. </el-tabs>
  245. <template #footer>
  246. <el-button @click="visible = false">取 消</el-button>
  247. <el-button type="primary" @click="save">确 定</el-button>
  248. </template>
  249. </el-dialog>
  250. <!--通知公告详情-->
  251. <notice-details ref="notice-details" />
  252. </div>
  253. </template>
  254. <script>
  255. import NoticeDetails from '@/views/system/notice/details.vue'
  256. import * as echarts from 'echarts'
  257. import VueDragger from 'vuedraggable'
  258. import VueGridLayout from 'vue-grid-layout'
  259. import to from 'await-to-js'
  260. import indexApi from '@/api/index'
  261. import messageApi from '@/api/system/message'
  262. export default {
  263. name: 'Index',
  264. components: {
  265. NoticeDetails,
  266. VueDragger,
  267. GridLayout: VueGridLayout.GridLayout,
  268. GridItem: VueGridLayout.GridItem,
  269. },
  270. data() {
  271. return {
  272. editFlag: false,
  273. privateBoard: [
  274. // {
  275. // report_name: '当前客户数(个)',
  276. // id: 1,
  277. // report_icon: 'account-circle-line',
  278. // checked: false,
  279. // },
  280. // {
  281. // report_name: '新增客户数(个)',
  282. // id: 2,
  283. // report_icon: 'user-add-line',
  284. // checked: false,
  285. // },
  286. // {
  287. // report_name: '跟进客户数(个)',
  288. // id: 3,
  289. // report_icon: 'account-pin-box-line',
  290. // checked: false,
  291. // },
  292. // {
  293. // report_name: '合同订单数(个)',
  294. // id: 4,
  295. // report_icon: 'account-circle-line',
  296. // checked: false,
  297. // },
  298. // {
  299. // report_name: '合同订单金额(元)',
  300. // id: 5,
  301. // report_icon: 'exchange-cny-fill',
  302. // checked: false,
  303. // },
  304. // {
  305. // report_name: '新增机会数(个)',
  306. // id: 6,
  307. // report_icon: 'mail-add-line',
  308. // checked: false,
  309. // },
  310. // {
  311. // report_name: '新增机会金额(元)',
  312. // id: 7,
  313. // report_icon: 'exchange-cny-fill',
  314. // checked: false,
  315. // },
  316. // {
  317. // report_name: '采购合同数(个)',
  318. // id: 8,
  319. // report_icon: 'account-circle-line',
  320. // checked: false,
  321. // },
  322. // {
  323. // report_name: '采购金额(元)',
  324. // id: 9,
  325. // report_icon: 'money-cny-circle-line',
  326. // checked: false,
  327. // },
  328. // {
  329. // report_name: '应收未收(元)',
  330. // id: 10,
  331. // report_icon: 'money-cny-circle-line',
  332. // checked: false,
  333. // },
  334. // {
  335. // report_name: '计划付款(元)',
  336. // id: 11,
  337. // report_icon: 'money-cny-circle-line',
  338. // checked: false,
  339. // },
  340. // {
  341. // report_name: '当前库存成本(元)',
  342. // id: 12,
  343. // report_icon: 'money-cny-circle-line',
  344. // checked: false,
  345. // },
  346. ],
  347. addBoard: [],
  348. addLayout: [],
  349. visible: false,
  350. layout: [],
  351. day: -1,
  352. list: [],
  353. activities: [],
  354. charts: [],
  355. activeName: 'first',
  356. forecast: '1',
  357. date: 0,
  358. dayList: ['日', '一', '二', '三', '四', '五', '六'],
  359. messageList: [],
  360. msgTypeOptions: [],
  361. }
  362. },
  363. mounted() {
  364. this.init()
  365. this.getDateList()
  366. this.getOptions()
  367. this.handleNoticeList()
  368. this.$baseEventBus.$on('receivedMessage', () => {
  369. console.log('---------------通知更新公告----------------')
  370. this.handleNoticeList()
  371. })
  372. window.addEventListener('resize', this.handleResize)
  373. },
  374. beforeDestroy() {
  375. window.removeEventListener('resize', this.handleResize)
  376. },
  377. methods: {
  378. async getHomeNumReportData() {
  379. let ids = this.privateBoard.map((item) => {
  380. return item.id
  381. })
  382. const {
  383. data: { num_report_response },
  384. } = await indexApi.getHomeNumReportData({ ids: Array.from(new Set(ids)) })
  385. let privateBoardData = []
  386. this.privateBoard.forEach((item, index) => {
  387. num_report_response.forEach((val) => {
  388. if (item.id === val.id) {
  389. this.privateBoard[index].report_data = val.data
  390. privateBoardData.push(this.privateBoard[index])
  391. }
  392. })
  393. })
  394. this.privateBoard = privateBoardData
  395. },
  396. // 布局信息
  397. async init() {
  398. const [err, res] = await to(indexApi.getHomeReport({ module_code: 'HomePage' }))
  399. if (err) return
  400. const obj = JSON.parse(res.data.configInfo)
  401. this.privateBoard = obj.num_report_config || []
  402. if (obj.data_report_config && obj.data_report_config.length) {
  403. this.layout = obj.data_report_config.map((item) => {
  404. return {
  405. x: item.location_x,
  406. y: item.location_y,
  407. i: item.id,
  408. desc: item.report_desc,
  409. name: item.report_name,
  410. type: item.report_type,
  411. h: item.size_h,
  412. w: item.size_w,
  413. searchType: (() => {
  414. if (item.id == 20006 || item.id == 20007) {
  415. return '0'
  416. } else if (item.id == 20010) {
  417. return 'week'
  418. } else if (item.id == 20009) {
  419. return new Date().getMonth() + 1
  420. } else {
  421. return 'year'
  422. }
  423. // item.id != 20006 && item.id != 20007 ? 'year' : '0'
  424. })(),
  425. }
  426. })
  427. }
  428. await this.$nextTick()
  429. this.initChart()
  430. this.getHomeNumReportData()
  431. },
  432. initChart() {
  433. // console.log(this.layout, 'layout')
  434. this.charts = []
  435. for (let i = 0; i < this.layout.length; i++) {
  436. this.getChartSize(this.layout[i].i)
  437. if (this.layout[i].i == 20006 || this.layout[i].i == 20007) {
  438. this.drawGoalChart(this.layout[i].i, i)
  439. } else if (this.layout[i].i == 20008) {
  440. this.drawCheckChart(this.layout[i].i, i)
  441. } else if (this.layout[i].i == 20009) {
  442. this.getTable(this.layout[i].i, i)
  443. } else if (this.layout[i].i == 20010) {
  444. this.drawProjectTrans(this.layout[i].i, i)
  445. } else if (this.layout[i].i == 20011) {
  446. this.drawMoneyAmount(this.layout[i].i, i)
  447. } else if (this.layout[i].i == 20012) {
  448. this.drawMoneyReturn(this.layout[i].i, i)
  449. } else if (this.layout[i].i >= 20000 && this.layout[i].i <= 20003) {
  450. this.drawChart(this.layout[i].i, i)
  451. }
  452. }
  453. },
  454. //刷新
  455. refresh(item, index) {
  456. if (this.charts[index]) {
  457. this.charts[index].dispose && this.charts[index].dispose()
  458. }
  459. if (item.i == 20006 || item.i == 20007) {
  460. this.drawGoalChart(item.i, index, item.searchType)
  461. } else if (item.i == 20008) {
  462. this.drawCheckChart(item.i, index, item.searchType)
  463. } else if (item.i == 20009) {
  464. this.getTable(item.i, index, item.searchType)
  465. } else if (item.i == 20010) {
  466. this.drawProjectTrans(item.i, index, item.searchType)
  467. } else if (item.i == 20011) {
  468. this.drawMoneyAmount(item.i, index, item.searchType)
  469. } else if (item.i == 20012) {
  470. this.drawMoneyReturn(item.i, index, item.searchType)
  471. } else {
  472. this.drawChart(item.i, index, item.searchType)
  473. }
  474. },
  475. // 获取表格
  476. async getTable(id, i, searchType) {
  477. console.log(id, i)
  478. const [err, res] = await to(indexApi.getHomeDataReportData({ id, Params: { date: searchType } }))
  479. if (err) this.drawMoneyReturn
  480. this.layout.forEach((item) => {
  481. if (item.i == id) item.table = res.data.data || []
  482. })
  483. this.$forceUpdate()
  484. },
  485. getChartSize(id) {
  486. // console.log(id, 'id')
  487. const bar = document.getElementById(id)
  488. // console.log(bar, 'bar')
  489. bar.style.height = bar.parentNode.clientHeight - 65 + 'px'
  490. bar.style.width = bar.parentNode.clientWidth + 'px'
  491. },
  492. async drawChart(id, i, searchType) {
  493. const [err, res] = await to(indexApi.getHomeDataReportData({ id, Params: { searchType } }))
  494. if (err) return
  495. if (!res.data.data) return
  496. const chartBar = echarts.init(document.getElementById(id))
  497. const option = {
  498. grid: {
  499. bottom: 30,
  500. top: 40,
  501. right: 10,
  502. left: 10,
  503. containLabel: true,
  504. },
  505. tooltip: {
  506. trigger: 'axis',
  507. },
  508. xAxis: [
  509. {
  510. type: 'category',
  511. data: res.data.data.xData,
  512. axisTick: {
  513. alignWithLabel: true,
  514. },
  515. },
  516. ],
  517. yAxis: [
  518. {
  519. type: 'value',
  520. name: '金额(元)',
  521. alignTicks: true,
  522. },
  523. {
  524. type: 'value',
  525. name: res.data.id == 20000 || res.data.id == 20002 ? '签约完成率(%)' : '回款率(%)',
  526. min: 0,
  527. max: 100,
  528. alignTicks: true,
  529. interval: 20,
  530. axisLabel: {
  531. formatter: '{value} %',
  532. },
  533. },
  534. ],
  535. series: [
  536. {
  537. name: '销售指标',
  538. type: 'bar',
  539. data: res.data.data.yDataTarget,
  540. },
  541. {
  542. name: '销售额度',
  543. type: 'bar',
  544. data: res.data.data.yDataReal,
  545. },
  546. {
  547. name: '回款率',
  548. type: 'line',
  549. yAxisIndex: 1,
  550. tooltip: {
  551. valueFormatter: function (value) {
  552. return value + '%'
  553. },
  554. },
  555. data: res.data.data.percentData,
  556. },
  557. ],
  558. }
  559. chartBar.setOption(option)
  560. this.charts[i] = chartBar
  561. },
  562. async drawCheckChart(id, i) {
  563. const chartBar = echarts.init(document.getElementById(id))
  564. const [err, res] = await to(indexApi.getHomeDataReportData({ id }))
  565. if (err) return
  566. console.log(res, 'res')
  567. const option = {
  568. grid: {
  569. bottom: 30,
  570. top: 40,
  571. right: 10,
  572. left: 10,
  573. containLabel: true,
  574. },
  575. tooltip: {
  576. trigger: 'axis',
  577. },
  578. xAxis: [
  579. {
  580. type: 'category',
  581. data: res.data.data.xData,
  582. axisTick: {
  583. alignWithLabel: true,
  584. },
  585. },
  586. ],
  587. yAxis: [
  588. {
  589. type: 'value',
  590. name: '打卡(次)',
  591. },
  592. ],
  593. series: [
  594. {
  595. name: '打卡频次',
  596. type: 'bar',
  597. data: res.data.data.yDataTarget,
  598. },
  599. ],
  600. }
  601. chartBar.setOption(option)
  602. this.charts[i] = chartBar
  603. },
  604. async drawProjectTrans(id, i, searchType = 'week') {
  605. const [err, res] = await to(indexApi.getHomeDataReportData({ id, Params: { searchType } }))
  606. if (err) return
  607. const arr = res.data.data || []
  608. const chartBar = echarts.init(document.getElementById(id))
  609. const option = {
  610. grid: {
  611. bottom: 0,
  612. top: 40,
  613. right: 10,
  614. left: 10,
  615. containLabel: true,
  616. },
  617. tooltip: {
  618. trigger: 'axis',
  619. },
  620. xAxis: [
  621. {
  622. type: 'category',
  623. data: ['新增', 'C转B', 'B转A', 'A转签约', 'C转A', 'C转签约', 'B转签约', '储备转A/B/C/签约'],
  624. axisTick: {
  625. alignWithLabel: true,
  626. },
  627. axisLabel: {
  628. interval: 0,
  629. rotate: 30,
  630. },
  631. },
  632. ],
  633. yAxis: [
  634. {
  635. type: 'value',
  636. name: '数量',
  637. },
  638. ],
  639. series: arr.map((item, index) => {
  640. return {
  641. name: (() => {
  642. if (index === 0) {
  643. return 'BIOBANK方案'
  644. } else if (index === 1) {
  645. return 'CELLSOP方案'
  646. } else {
  647. return 'LIMS方案'
  648. }
  649. })(),
  650. type: 'bar',
  651. data: item,
  652. }
  653. }),
  654. }
  655. chartBar.setOption(option)
  656. this.charts[i] = chartBar
  657. },
  658. async drawMoneyAmount(id, i) {
  659. const [err, res] = await to(indexApi.getHomeDataReportData({ id }))
  660. if (err) return
  661. const arr = res.data.data || []
  662. const chartBar = echarts.init(document.getElementById(id))
  663. const option = {
  664. grid: {
  665. bottom: 30,
  666. top: 40,
  667. right: 10,
  668. left: 10,
  669. containLabel: true,
  670. },
  671. tooltip: {
  672. trigger: 'axis',
  673. },
  674. xAxis: [
  675. {
  676. type: 'category',
  677. data: ['BioBank', 'CellSOP', 'LIMS'],
  678. axisTick: {
  679. alignWithLabel: true,
  680. },
  681. },
  682. ],
  683. yAxis: [
  684. {
  685. type: 'value',
  686. name: '出货金额(元)',
  687. },
  688. ],
  689. series: arr.map((item, index) => {
  690. return {
  691. name: (() => {
  692. if (index === 0) {
  693. return 'A类项目'
  694. } else {
  695. return 'B类项目'
  696. }
  697. })(),
  698. type: 'bar',
  699. data: item,
  700. }
  701. }),
  702. }
  703. chartBar.setOption(option)
  704. this.charts[i] = chartBar
  705. },
  706. async drawMoneyReturn(id, i) {
  707. const [err, res] = await to(indexApi.getHomeDataReportData({ id }))
  708. if (err) return
  709. const arr = res.data.data || []
  710. const chartBar = echarts.init(document.getElementById(id))
  711. const option = {
  712. grid: {
  713. bottom: 30,
  714. top: 40,
  715. right: 10,
  716. left: 10,
  717. containLabel: true,
  718. },
  719. tooltip: {
  720. trigger: 'axis',
  721. },
  722. xAxis: [
  723. {
  724. type: 'category',
  725. data: ['BioBank', 'CellSOP', 'LIMS'],
  726. axisTick: {
  727. alignWithLabel: true,
  728. },
  729. },
  730. ],
  731. yAxis: [
  732. {
  733. type: 'value',
  734. name: '回款金额(元)',
  735. },
  736. ],
  737. series: arr.map((item, index) => {
  738. return {
  739. name: (() => {
  740. if (index === 0) {
  741. return '当月签约'
  742. } else if (index === 1) {
  743. return '累计签约'
  744. } else if (index === 2) {
  745. return '当月回款'
  746. } else {
  747. return '累计回款'
  748. }
  749. })(),
  750. type: 'bar',
  751. data: item,
  752. }
  753. }),
  754. }
  755. chartBar.setOption(option)
  756. this.charts[i] = chartBar
  757. },
  758. async drawGoalChart(id, i, searchType) {
  759. const chartBar = echarts.init(document.getElementById(id))
  760. const [err, res] = await to(
  761. indexApi.getHomeDataReportData({
  762. id,
  763. Params: {
  764. year: new Date().getFullYear(),
  765. quarter: parseInt(searchType),
  766. },
  767. })
  768. )
  769. if (err) return
  770. console.log(res.data.data)
  771. const option = {
  772. grid: {
  773. bottom: 30,
  774. top: 40,
  775. right: 10,
  776. left: 10,
  777. containLabel: true,
  778. },
  779. tooltip: {
  780. trigger: 'axis',
  781. },
  782. xAxis: [
  783. {
  784. type: 'category',
  785. data: res.data.data.xData,
  786. axisTick: {
  787. alignWithLabel: true,
  788. },
  789. },
  790. ],
  791. yAxis: [
  792. {
  793. type: 'value',
  794. name: '金额(万元)',
  795. alignTicks: true,
  796. },
  797. ],
  798. series: [
  799. {
  800. name: id == 20006 ? '销售指标' : '回款指标',
  801. type: 'bar',
  802. data: res.data.data.yDataTarget,
  803. },
  804. {
  805. name: id == 20006 ? '销售额度' : '回款额度',
  806. type: 'bar',
  807. data: res.data.data.yDataReal,
  808. },
  809. ],
  810. }
  811. chartBar.setOption(option)
  812. this.charts[i] = chartBar
  813. },
  814. initFunnel() {
  815. this.chartFunnel = echarts.init(document.getElementById('funnel'))
  816. const option = {
  817. tooltip: {
  818. trigger: 'item',
  819. formatter: '{b} : {d}%',
  820. },
  821. label: {
  822. formatter: '{b} {c}',
  823. },
  824. labelLine: {
  825. show: true,
  826. },
  827. series: [
  828. {
  829. name: '销售漏斗',
  830. type: 'funnel',
  831. top: 10,
  832. bottom: 10,
  833. minSize: '20%',
  834. maxSize: '100%',
  835. label: {
  836. position: 'inside',
  837. formatter: '{c}%',
  838. color: '#fff',
  839. },
  840. data: [
  841. { value: 500, name: '初步洽谈' },
  842. { value: 300, name: '深入沟通' },
  843. { value: 250, name: '产品报价' },
  844. { value: 150, name: '成交项目' },
  845. { value: 120, name: '流失项目' },
  846. ],
  847. },
  848. {
  849. name: '销售漏斗',
  850. type: 'funnel',
  851. top: 10,
  852. bottom: 10,
  853. minSize: '20%',
  854. maxSize: '100%',
  855. z: 1,
  856. data: [
  857. { value: 500, name: '初步洽谈' },
  858. { value: 300, name: '深入沟通' },
  859. { value: 250, name: '产品报价' },
  860. { value: 150, name: '成交项目' },
  861. { value: 120, name: '流失项目' },
  862. ],
  863. },
  864. ],
  865. }
  866. this.chartFunnel.setOption(option)
  867. },
  868. async handleResize() {
  869. await this.$nextTick()
  870. for (let i = 0; i < this.layout.length; i++) {
  871. this.getChartSize(this.layout[i].i)
  872. if (this.charts[i]) this.charts[i].resize && this.charts[i].resize()
  873. }
  874. },
  875. layoutReadyEvent() {
  876. this.initChart()
  877. },
  878. handleDel(index) {
  879. this.privateBoard.splice(index, 1)
  880. },
  881. gridDel(index) {
  882. this.layout.splice(index, 1)
  883. },
  884. async save() {
  885. const board = this.addBoard.filter((item) => item.checked == true)
  886. this.privateBoard = []
  887. for (const item of board) {
  888. this.privateBoard.push({
  889. report_name: item.reportName,
  890. id: item.id,
  891. report_icon: item.reportIcon,
  892. })
  893. }
  894. const layout = this.addLayout.filter((item) => item.checked == true)
  895. for (const item of layout) {
  896. const index = this.layout.findIndex((each) => each.i == item.id)
  897. if (index > -1) continue
  898. this.layout.push({
  899. x: 0,
  900. y: 0,
  901. w: 12,
  902. h: 10,
  903. i: item.id,
  904. type: 'bar',
  905. name: item.reportName,
  906. searchType: 'year',
  907. })
  908. }
  909. this.visible = false
  910. await this.$nextTick()
  911. this.initChart()
  912. },
  913. async saveLayout() {
  914. this.editFlag = false
  915. const params = {
  916. module_code: 'HomePage',
  917. data_report_config: [],
  918. num_report_config: this.privateBoard,
  919. }
  920. params.data_report_config = this.layout.map((item) => {
  921. return {
  922. location_x: item.x,
  923. location_y: item.y,
  924. id: item.i,
  925. report_desc: item.desc,
  926. report_name: item.name,
  927. report_type: item.type,
  928. size_h: item.h,
  929. size_w: item.w,
  930. }
  931. })
  932. const [err, res] = await to(indexApi.setUpHomeConfig(params))
  933. if (err) return
  934. this.$message.success(res.msg)
  935. this.getHomeNumReportData()
  936. },
  937. getDateList() {
  938. const now = new Date()
  939. const date = new Date(now.getTime() + this.date * 1000 * 60 * 60 * 24)
  940. const day = date.getDay()
  941. this.day = day
  942. this.list = new Array(7)
  943. for (let i = 0; i < this.list.length; i++) {
  944. this.list[i] = {}
  945. const flag = -(day - i)
  946. const time = new Date(date.getTime() + flag * 1000 * 60 * 60 * 24)
  947. this.list[i].time = new Date(time)
  948. this.list[i].day = this.list[i].time.getDay()
  949. this.list[i].date = this.list[i].time.getDate()
  950. if (flag == 0) this.dateClick(this.list[i])
  951. }
  952. },
  953. async dateClick(item) {
  954. this.day = item.day
  955. const [err, res] = await to(indexApi.getSchedule({ schDate: this.parseTime(item.time) }))
  956. if (err) return
  957. this.activities = res.data.list || []
  958. const date = new Date().getTime()
  959. this.activities.forEach((item) => {
  960. const start = new Date(item.schDate).getTime()
  961. const end = new Date(item.schDateEnd).getTime()
  962. item.active = start <= date && end >= date
  963. })
  964. },
  965. async getBoardOptions() {
  966. this.activeName = 'first'
  967. const [err, res] = await to(indexApi.getRoleReportList())
  968. if (err) return
  969. console.log(res)
  970. const arr = res.data.list || []
  971. arr.forEach((item) => (item.checked = false))
  972. this.addLayout = arr.filter((item) => item.reportType == 20)
  973. this.addLayout.forEach((item) => {
  974. const index = this.layout.findIndex((each) => each.i == item.id)
  975. if (index > -1) item.checked = true
  976. })
  977. this.addBoard = arr.filter((item) => item.reportType == 10)
  978. this.addBoard.forEach((item) => {
  979. const index = this.privateBoard.findIndex((each) => each.id == item.id)
  980. if (index > -1) item.checked = true
  981. })
  982. },
  983. getOptions() {
  984. this.getDicts('sys_msg_type').then((response) => {
  985. this.msgTypeOptions = response.data.values || []
  986. })
  987. },
  988. msgTypeFormat(row) {
  989. return this.selectDictLabel(this.msgTypeOptions, row.msgType)
  990. },
  991. handleHistoryNotice() {
  992. this.$router.push({
  993. name: 'NoticeHistory',
  994. })
  995. },
  996. async handleNoticeList() {
  997. const { data } = await messageApi.getList({ msgType: '10' })
  998. this.messageList = data.list
  999. },
  1000. getNoticeInfo(row) {
  1001. this.$refs['notice-details'].open(row.id)
  1002. },
  1003. },
  1004. }
  1005. </script>
  1006. <style lang="scss" scoped>
  1007. $base: '.index';
  1008. #{$base} {
  1009. display: flex;
  1010. background: #f6f8f9;
  1011. height: calc(100vh - 60px - 12px * 2 - 40px);
  1012. .el-card {
  1013. margin-bottom: 12px;
  1014. border-radius: 4px;
  1015. }
  1016. .card-title {
  1017. font-size: 16px;
  1018. font-weight: 700;
  1019. line-height: 22px;
  1020. height: 22px;
  1021. display: flex;
  1022. justify-content: space-between;
  1023. align-items: center;
  1024. i {
  1025. font-weight: normal;
  1026. cursor: pointer;
  1027. &:hover {
  1028. color: #1d66dc;
  1029. }
  1030. }
  1031. }
  1032. .left {
  1033. flex: 1;
  1034. margin-right: 10px;
  1035. overflow-x: hidden;
  1036. overflow-y: auto;
  1037. .buttons {
  1038. .el-radio-group {
  1039. margin-right: 4px;
  1040. }
  1041. }
  1042. .board {
  1043. display: flex;
  1044. flex-direction: column;
  1045. margin-bottom: 2px;
  1046. ::v-deep .el-card__body {
  1047. flex: 1;
  1048. display: flex;
  1049. flex-direction: column;
  1050. justify-content: space-around;
  1051. }
  1052. .el-row {
  1053. height: 100%;
  1054. flex-wrap: wrap;
  1055. > div,
  1056. > div span {
  1057. display: flex;
  1058. height: 100%;
  1059. align-items: center;
  1060. flex-wrap: wrap;
  1061. width: 100%;
  1062. }
  1063. .ghost {
  1064. background: #ecf5ff;
  1065. }
  1066. .drag {
  1067. background: pink;
  1068. }
  1069. .el-col {
  1070. display: flex;
  1071. height: 60px;
  1072. margin: 20px 0;
  1073. user-select: none;
  1074. cursor: pointer;
  1075. }
  1076. }
  1077. }
  1078. }
  1079. .right {
  1080. width: 450px;
  1081. .detail {
  1082. height: 64px;
  1083. border: 1px solid rgb(235, 237, 240);
  1084. border-radius: 4px;
  1085. &.active {
  1086. border: 1px solid #d7e8f4;
  1087. background: #f7fbfe;
  1088. p:last-child {
  1089. font-weight: bold;
  1090. }
  1091. }
  1092. p {
  1093. height: 32px;
  1094. line-height: 32px;
  1095. padding: 0 10px;
  1096. white-space: nowrap;
  1097. overflow: hidden;
  1098. text-overflow: ellipsis;
  1099. }
  1100. .time {
  1101. display: flex;
  1102. justify-content: space-between;
  1103. align-items: center;
  1104. }
  1105. }
  1106. .calendar {
  1107. height: 60%;
  1108. border-radius: 4px;
  1109. display: flex;
  1110. flex-direction: column;
  1111. ::v-deep .el-card__body {
  1112. flex: 1;
  1113. overflow: hidden;
  1114. }
  1115. .week {
  1116. height: 48px;
  1117. display: flex;
  1118. align-items: center;
  1119. ul {
  1120. flex: 1;
  1121. display: flex;
  1122. height: 48px;
  1123. li {
  1124. flex: 1;
  1125. display: flex;
  1126. flex-direction: column;
  1127. align-items: center;
  1128. justify-content: center;
  1129. user-select: none;
  1130. cursor: pointer;
  1131. &.active span:last-child {
  1132. background: rgb(34, 76, 218);
  1133. color: #fff;
  1134. }
  1135. span {
  1136. flex: 1;
  1137. height: 24px;
  1138. width: 24px;
  1139. text-align: center;
  1140. line-height: 24px;
  1141. }
  1142. span:first-child {
  1143. color: rgb(150, 151, 153);
  1144. }
  1145. span:last-child {
  1146. color: rgb(50, 50, 51);
  1147. border-radius: 4px;
  1148. }
  1149. }
  1150. }
  1151. i {
  1152. height: 24px;
  1153. width: 24px;
  1154. font-size: 24px;
  1155. color: rgb(100, 101, 102);
  1156. background: rgb(247, 248, 250);
  1157. border-radius: 4px;
  1158. cursor: pointer;
  1159. transition: 0.3s all;
  1160. &:hover {
  1161. color: #fff;
  1162. background: rgb(100, 101, 102);
  1163. }
  1164. }
  1165. }
  1166. .el-timeline {
  1167. margin-top: 20px;
  1168. padding-top: 4px;
  1169. height: calc(100% - 72px);
  1170. overflow: auto;
  1171. .el-timeline-item {
  1172. padding-bottom: 10px;
  1173. }
  1174. }
  1175. .timelineEmpty {
  1176. height: calc(100% - 72px);
  1177. display: flex;
  1178. align-items: center;
  1179. justify-content: center;
  1180. }
  1181. }
  1182. .notice {
  1183. height: calc(40% - 12px);
  1184. display: flex;
  1185. flex-direction: column;
  1186. ::v-deep .el-card__body {
  1187. flex: 1;
  1188. overflow: auto;
  1189. }
  1190. .notice-list {
  1191. display: flex;
  1192. justify-content: space-between;
  1193. height: 40px;
  1194. line-height: 40px;
  1195. border-bottom: 1px solid #ebeef5;
  1196. p:first-child {
  1197. flex: 1;
  1198. min-width: 0;
  1199. overflow: hidden;
  1200. text-overflow: ellipsis;
  1201. white-space: nowrap;
  1202. }
  1203. span {
  1204. font-weight: bold;
  1205. }
  1206. }
  1207. }
  1208. }
  1209. }
  1210. ::v-deep .el-timeline-item__tail {
  1211. border-left: 2px dashed #e4e7ed;
  1212. }
  1213. // #funnel,
  1214. // #bar {
  1215. // height: 100%;
  1216. // }
  1217. .vue-grid-layout {
  1218. margin-left: -10px;
  1219. margin-right: -10px;
  1220. &.grid {
  1221. background: linear-gradient(90deg, #fff 10px, transparent 0), linear-gradient(#fff 10px, transparent 0);
  1222. background-size: calc((100% - 10px) / 24) 40px;
  1223. background-position: top 0px left 0px;
  1224. }
  1225. }
  1226. .vue-grid-item {
  1227. background: #fff;
  1228. border: 1px solid #ebeef5;
  1229. border-radius: 4px;
  1230. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  1231. overflow: hidden;
  1232. .el-form-item--mini.el-form-item {
  1233. margin-bottom: 0;
  1234. }
  1235. h4 {
  1236. line-height: 22px;
  1237. height: 54px;
  1238. font-size: 16px;
  1239. padding: 16px 20px;
  1240. display: flex;
  1241. justify-content: space-between;
  1242. align-items: center;
  1243. border-bottom: 1px solid #ebeef5;
  1244. i {
  1245. font-size: 24px;
  1246. font-weight: bold;
  1247. cursor: pointer;
  1248. &:hover {
  1249. color: #1d66dc;
  1250. }
  1251. }
  1252. }
  1253. .refreshBtn {
  1254. margin-left: 8px;
  1255. }
  1256. }
  1257. .board-container {
  1258. display: flex;
  1259. height: 60px;
  1260. border: 1px solid #eee;
  1261. align-items: center;
  1262. border-radius: 8px;
  1263. padding: 0 10px;
  1264. flex: 1;
  1265. cursor: pointer;
  1266. user-select: none;
  1267. &:hover {
  1268. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  1269. }
  1270. .icon {
  1271. font-size: 32px;
  1272. border-radius: 4px;
  1273. width: 40px;
  1274. height: 40px;
  1275. color: #1d66dc;
  1276. background: #ecf5ff;
  1277. &.ri-money-cny-circle-line {
  1278. color: #e6a23c;
  1279. background: #fdf6ec;
  1280. }
  1281. &.ri-exchange-cny-fill {
  1282. color: #f56c6c;
  1283. background: #fef0f0;
  1284. }
  1285. }
  1286. .full-icon {
  1287. flex: 1;
  1288. font-size: 32px;
  1289. }
  1290. .close {
  1291. font-size: 32px;
  1292. transition: 0.3s all;
  1293. &:hover {
  1294. color: #1d66dc;
  1295. }
  1296. }
  1297. .check {
  1298. font-size: 32px;
  1299. color: #67c23a;
  1300. }
  1301. .text {
  1302. padding-left: 10px;
  1303. color: #9499a0;
  1304. flex: 1;
  1305. .num {
  1306. font-size: 22px;
  1307. font-weight: bold;
  1308. color: #333;
  1309. }
  1310. }
  1311. }
  1312. .add-board {
  1313. height: 500px;
  1314. overflow: auto;
  1315. li + li {
  1316. margin-top: 10px;
  1317. }
  1318. }
  1319. </style>