index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <div class="dashboard-editor-container" v-loading="loading">
  3. <!-- <github-corner class="github-corner" /> -->
  4. <el-row class="system-carousel">
  5. <el-carousel trigger="click" indicator-position="none" :height="bannerHeight+'px'" style="max-height:350px;" :interval="6000" arrow="always" :indicator-position="outside">
  6. <el-carousel-item v-for="(item,key) in slides" :key="key">
  7. <template v-if="item.TYPE==='1'">
  8. <router-link :to="`/shop/index`" target="_self" class="islide">
  9. <img ref="bannerHeight" @load="imgLoad" :src="imageArticle(item.IMAGE)" alt="" >
  10. </router-link>
  11. </template>
  12. <template v-else>
  13. <router-link to="#" target="_self" class="islide">
  14. <img ref="bannerHeight" @load="imgLoad" :src="imageArticle(item.IMAGE)" alt="" @click="handleArticle(item.CONTENT)" >
  15. </router-link>
  16. </template>
  17. </el-carousel-item>
  18. </el-carousel>
  19. </el-row>
  20. <panel-group @handleSetLineChartData="handleSetLineChartData" :rmBv="rmBv" :endTime="endTime" :heightEmpLv='heightEmpLv' :heightCrownLv='heightCrownLv' :decLv="decLv" :key="num" :cycle="cycle" />
  21. <el-row :gutter="40" v-loading="loading">
  22. <el-col :xs="24" :sm="24" :lg="12" v-for="(item,key) in news" :key="key">
  23. <el-card class="box-card">
  24. <el-table :data="item.LISTS" lazy stripe fit highlight-current-row>
  25. <el-table-column align="left" :label="$t('article.title')" prop="TITLE">
  26. <template slot-scope="{row}">
  27. <span @click="handleArticle(row.ID)">
  28. <el-link type="primary" href="#" target="_self" >{{ row.TITLE }}</el-link>
  29. </span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column align="right">
  33. <template slot="header" slot-scope="scope">
  34. <el-button type="text" class="box-card-more">
  35. <router-link :to="`/article/article-list`">{{$t('dashboard.more')}}+</router-link>
  36. </el-button>
  37. </template>
  38. <template slot-scope="{row}">
  39. <span>{{ row.CREATED_AT | parseTime('{y}-{m}-{d}') }}</span>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. </el-card>
  44. </el-col>
  45. </el-row>
  46. <!-- <el-row :gutter="8">
  47. <el-col :xs="{span: 24}" :sm="{span: 24}" :md="{span: 24}" :lg="{span: 12}" :xl="{span: 12}" style="padding-right:8px;margin-bottom:30px;">
  48. <transaction-table />
  49. </el-col>
  50. <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
  51. <todo-list />
  52. </el-col>
  53. <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
  54. <box-card />
  55. </el-col>
  56. </el-row> -->
  57. <el-dialog title="" :visible.sync="dialog" :width="screenWidth" center style="margin-top: -80px;">
  58. <div class="white-box" style="text-align: center; margin-top: -20px;">
  59. <div class="white-box-title">
  60. <h1>{{ article.TITLE }}</h1>
  61. <span>{{ article.CREATED_AT | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
  62. </div>
  63. <div v-html="article.CONTENT" class="white-box-content">
  64. </div>
  65. </div>
  66. </el-dialog>
  67. </div>
  68. </template>
  69. <script>
  70. import GithubCorner from '@/components/GithubCorner'
  71. import PanelGroup from './components/PanelGroup'
  72. import LineChart from './components/LineChart'
  73. import RaddarChart from './components/RaddarChart'
  74. import PieChart from './components/PieChart'
  75. import BarChart from './components/BarChart'
  76. import TransactionTable from './components/TransactionTable'
  77. import TodoList from './components/TodoList'
  78. import BoxCard from './components/BoxCard'
  79. import tool from '@/utils/tool'
  80. import {getScreenWidth} from "@/utils";
  81. import {fetchArticleOne} from "@/api/article";
  82. const lineChartData = {
  83. newVisitis: {
  84. expectedData: [100, 120, 161, 134, 105, 160, 165],
  85. actualData: [120, 82, 91, 154, 162, 140, 145]
  86. },
  87. messages: {
  88. expectedData: [200, 192, 120, 144, 160, 130, 140],
  89. actualData: [180, 160, 151, 106, 145, 150, 130]
  90. },
  91. purchases: {
  92. expectedData: [80, 100, 121, 104, 105, 90, 100],
  93. actualData: [120, 90, 100, 138, 142, 130, 130]
  94. },
  95. shoppings: {
  96. expectedData: [130, 140, 141, 142, 145, 150, 160],
  97. actualData: [120, 82, 91, 154, 162, 140, 130]
  98. }
  99. }
  100. export default {
  101. name: 'DashboardAdmin',
  102. components: {
  103. GithubCorner,
  104. PanelGroup,
  105. LineChart,
  106. RaddarChart,
  107. PieChart,
  108. BarChart,
  109. TransactionTable,
  110. TodoList,
  111. BoxCard
  112. },
  113. data() {
  114. return {
  115. lineChartData: lineChartData.newVisitis,
  116. myEmpLv: {'ID': 0, 'LEVEL_NAME': null, 'ICON_TYPE': 0, 'ICON_NUM': 0},
  117. bannerHeight: '',
  118. slides: [],
  119. news: [],
  120. periodNum: '',
  121. decLvName: '',
  122. myRemainPv: '',
  123. activeEnd: '',
  124. baseEmpLevels: [],
  125. heightEmpLv: '', // 最高级别
  126. heightCrownLv: '',
  127. decLv:'', // 当前等级
  128. cycle: '',//当前业绩期
  129. rmBv: '',
  130. endTime: '',
  131. num: 0,
  132. loading: false,
  133. dialog: false,
  134. article: {
  135. ID: '',
  136. CID: '',
  137. TITLE: '',
  138. CONTENT: '',
  139. CREATED_AT: '',
  140. },
  141. outside: 'outside',
  142. screenWidth: getScreenWidth() > 600 ? '70%' : getScreenWidth() + 'px',
  143. labelPosition: getScreenWidth() > 600 ? 'right' : 'top',
  144. }
  145. },
  146. methods: {
  147. handleSetLineChartData(type) {
  148. this.lineChartData = lineChartData[type]
  149. },
  150. sub_str(str, len = 15) {
  151. if (str) return str.slice(0, len)
  152. },
  153. imgLoad () {
  154. let _this = this
  155. if (_this.$refs.bannerHeight) {
  156. _this.$nextTick(function () {
  157. _this.bannerHeight = _this.$refs.bannerHeight[0] && _this.$refs.bannerHeight[0].height ?
  158. _this.$refs.bannerHeight[0].height
  159. : _this.bannerHeight
  160. })
  161. }
  162. },
  163. imageArticle (imageUrl) {
  164. return tool.getArImage(imageUrl, '/files/')
  165. },
  166. formatDate(data) {
  167. return tool.formatDate(data,false)
  168. },
  169. handleArticle(id) {
  170. this.loading = true
  171. fetchArticleOne(id).then(response => {
  172. this.article = response.data
  173. this.dialog = true
  174. setTimeout(() => {
  175. this.loading = false
  176. }, 0.5 * 1000)
  177. })
  178. },
  179. },
  180. mounted() {
  181. this.$store.dispatch('dashboard/getIndex', {})
  182. .then(response => {
  183. this.num++
  184. let ret = response.data
  185. this.slides = ret.slides
  186. this.news = ret.news
  187. this.periodNum = ret.periodNum
  188. this.decLvName = ret.decLvName
  189. this.myRemainPv = ret.myRemainPv
  190. this.activeEnd = ret.activeEnd
  191. this.decLv = ret.decLv
  192. this.heightEmpLv = ret.empLv
  193. this.heightCrownLv = ret.crownLv
  194. this.cycle = ret.periodNum
  195. this.rmBv = ret.myRemainPv
  196. this.endTime = ret.activeEnd
  197. this.imgLoad();
  198. })
  199. .catch((error) => {
  200. })
  201. window.addEventListener('resize', () => {
  202. this.imgLoad()
  203. }, false)
  204. }
  205. }
  206. </script>
  207. <style lang="scss" scoped>
  208. // img {
  209. // max-height:350px;
  210. // max-width:400px;
  211. // margin: 0 auto;
  212. // }
  213. .islide {
  214. display: block;
  215. text-align: center;
  216. }
  217. .islide img {
  218. max-width: 100%;
  219. max-height: 330px;
  220. }
  221. .box-card .item{
  222. line-height: 30px;
  223. }
  224. .box-card .item span {
  225. float: right;
  226. color: #999;
  227. font-size: 12px;
  228. }
  229. .box-card .item:nth-of-type(odd) {
  230. background: #FAFAFA;
  231. }
  232. ::v-deep .el-carousel__container {
  233. text-align: center !important;
  234. }
  235. .dashboard-editor-container {
  236. padding: 32px;
  237. background-color: rgb(240, 242, 245);
  238. position: relative;
  239. .github-corner {
  240. position: absolute;
  241. top: 0px;
  242. border: 0;
  243. right: 0;
  244. }
  245. .chart-wrapper {
  246. background: #fff;
  247. padding: 16px 16px 0;
  248. margin-bottom: 32px;
  249. }
  250. }
  251. .box-card-more {
  252. float: right;
  253. padding: 3px 10px;
  254. border: 1px solid #ddd;
  255. border-radius: 10px;
  256. }
  257. .box-card-more a {
  258. color: #666;
  259. }
  260. .box-card-more:hover {
  261. border-color: #409EFF;
  262. }
  263. // carousel
  264. .system-carousel {
  265. margin-left: 0px !important;
  266. margin-right: 0px !important;
  267. margin-top: -10px;
  268. }
  269. // carousel
  270. @media (max-width:1024px) {
  271. .chart-wrapper {
  272. padding: 8px;
  273. }
  274. }
  275. ::v-deep .el-carousel__button {
  276. border: 1px solid gray;
  277. width: 8px;
  278. height: 8px;
  279. border-radius: 50%;
  280. }
  281. </style>