index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <div class="container">
  3. <el-row>
  4. <div class="tool-bar">
  5. <div>
  6. <span class="title-name">仪表盘标题</span>
  7. </div>
  8. <div style = "position:absolute:top:0px;right:0px">
  9. <el-button class="miniSuccess" @click="control_edit()">编辑</el-button>
  10. <el-button class="successBorder" @click="handleLinkChart">
  11. 添加图表
  12. </el-button>
  13. </div>
  14. </div>
  15. </el-row>
  16. <el-row>
  17. <div>
  18. <draggable v-model="boardList" group="itxst" animation="300" :group="{name: 'dashboard',pull: true}" @start="onStart" @end="onEnd">
  19. <transition-group>
  20. <el-card class="box-card board-card" key="1" v-for="item in boardList">
  21. <div slot="header" class="clearfix">
  22. <span>{{item.title}}</span>
  23. <div style="float: right; padding: 3px 0;display:inline-block;">
  24. <i class="el-icon-edit" style="color:#009C69;cursor:pointer;" />
  25. <i class="el-icon-delete" style="color:#009C69;cursor:pointer;" />
  26. </div>
  27. </div>
  28. <div class="board-item" >
  29. 表格
  30. <BarChart v-if = "item.boardtype == 'bar'" :chart-data="item.chartData" />
  31. <LineChart v-if = "item.boardtype == 'line'" :chart-data="item.chartData" />
  32. <!-- <HorizontalBarChart v-if = "item.boardtype == 'horizontal_bar'" :chart-data="item.chartData" /> -->
  33. <PieChart v-if = "item.boardtype == 'pie'" :chart-data="item.chartData" />
  34. <!-- <LineBarChart v-if = "item.boardtype == 'line_bar'" :chart-data="item.chartData" /> -->
  35. </div>
  36. <!-- <div class="board-item" v-if="item.boardtype == 'line'">
  37. <keep-alive>
  38. <component :is="chartLine.myComponent" ref="chartLine" />
  39. </keep-alive>
  40. </div> -->
  41. </el-card>
  42. </transition-group>
  43. </draggable>
  44. </div>
  45. </el-row>
  46. <el-row>
  47. </el-row>
  48. <el-dialog title="我的图表" :visible.sync="showChartList">
  49. <!-- <el-button type="primary" size="mini" @click="$router.push({ name: 'ChartPanel', params: { id: 'create' , isEdit: 'edit'}})">
  50. 创建新的图表
  51. </el-button> -->
  52. <el-button class="save" style="margin-bottom: 10px;" @click="jumpCreate()"> 创建新的图表 </el-button>
  53. <el-table :data="myChartList" border>
  54. <el-table-column :label="$t('common.name')" width="200" prop="chart_name" />
  55. <el-table-column :label="$t('common.desc')" prop="desc" />
  56. <el-table-column :label="$t('common.operation')" align="center">
  57. <template slot-scope="scope">
  58. <el-button class="miniPrimary" :disabled="isExisted(scope.row)" @click="linkChart(scope.row)">添加</el-button>
  59. <el-button size="mini" type="warning" style="padding: 6px 10px !important;font-size:14px;" @click="jumpEdit2(scope.row)"> 编辑 </el-button>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  64. <el-button class="cancelClose1" @click="showChartList = false">{{$t('common.closed')}}</el-button>
  65. </div>
  66. </el-dialog>
  67. </div>
  68. </template>
  69. <script>
  70. import draggable from 'vuedraggable'
  71. import { GetDataByName } from '@/api/common'
  72. // import { ChartTable } from '@/components/ChartTable'
  73. import ChartTable from '@/componentChart/ChartTable.vue'
  74. import LineChart from '@/componentChart/LineChart.vue'
  75. import BarChart from '@/componentChart/BarChart.vue'
  76. import HorizontalBarChart from '@/componentChart/HorizontalBarChart.vue'
  77. import PieChart from '@/componentChart/PieChart.vue'
  78. import LineBarChart from '@/componentChart/LineBarChart.vue'
  79. import Cookies from 'js-cookie'
  80. export default {
  81. name: 'Addboard2',
  82. components: { draggable , ChartTable ,LineChart,BarChart ,HorizontalBarChart, PieChart, LineBarChart},
  83. data() {
  84. return {
  85. isRoleEdit: [],
  86. boardList: [
  87. {
  88. title:'图表1',boardId:1,boardtype:'bar',
  89. chartData:{
  90. chartType:'bar',
  91. xAxisArr: ['2019-01', '2019-02', '2019-03', '2019-04', '2019-05', '2019-06', '2019-07', '2019-08', '2019-09', '2019-10', '2019-11', '2019-12'],
  92. legendArr: ['数据1', '数据2', '数据3'],
  93. dataArr:[
  94. [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
  95. [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
  96. [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
  97. ]
  98. }
  99. },
  100. {
  101. title:'图表2',boardId:2,boardtype:'line',
  102. chartData:{
  103. chartType:'line',
  104. xAxisArr: ['2019-01', '2019-02', '2019-03', '2019-04', '2019-05', '2019-06', '2019-07', '2019-08', '2019-09', '2019-10', '2019-11', '2019-12'],
  105. legendArr: ['数据1', '数据2', '数据3'],
  106. dataArr:[
  107. [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
  108. [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
  109. [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
  110. ]
  111. }
  112. },
  113. {
  114. title:'图表3',boardId:3,boardtype:'pie',
  115. chartData:{
  116. chartType:'pie',
  117. xAxisArr: ['2019-01', '2019-02', '2019-03', '2019-04', '2019-05', '2019-06', '2019-07', '2019-08', '2019-09', '2019-10', '2019-11', '2019-12'],
  118. legendArr: ['数据1', '数据2', '数据3', '数据4', '线条1'],
  119. dataArr:[1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
  120. }
  121. },
  122. {title:'图表3'},
  123. {title:'图表3'},
  124. {title:'图表3'},
  125. {title:'图表3'},
  126. ],
  127. chartTable: {
  128. dialogFormVisible: false,
  129. dialogStatus: '',
  130. myComponent: null
  131. },
  132. chartLine: {
  133. dialogFormVisible: false,
  134. dialogStatus: '',
  135. myComponent: null
  136. },
  137. myChartList: [],
  138. showChartList: false,
  139. chartLoading: {},
  140. isEdit: 'view',
  141. dashboardList: [],
  142. currentDashboard: undefined,
  143. editDialogVisible: false,
  144. dbObj: {},
  145. loading: false,
  146. isCollapse: false,
  147. did: undefined,
  148. isTitle: '2',
  149. editBtn: false,
  150. control_btn: '编辑',
  151. control_btn_l: false,
  152. }
  153. },
  154. created() {
  155. // console.log('this.$route.params.id', this.$route.params.id)
  156. // const isEdit = this.$route.params.isEdit
  157. // this.isEdit = isEdit
  158. this.getList()
  159. this.chartTable.dialogFormVisible = true
  160. this.chartLine.dialogFormVisible = true
  161. const vue = this
  162. // var myComponent1 = () => import('./chartTable.vue')
  163. // vue.chartTable.myComponent = myComponent1
  164. // var myComponent2 = () => import('./chartLine.vue')
  165. // vue.chartTable.myComponent = myComponent2
  166. },
  167. methods: {
  168. onStart(){
  169. console.log(2222)
  170. },
  171. onEnd(){
  172. console.log(this.boardList)
  173. },
  174. getList() {
  175. // const vue = this
  176. // var myComponent = () => import('./chartTable.vue')
  177. // return vue.chartTable.myComponent = myComponent
  178. this.loading = true
  179. // if (this.$route.params.id) {
  180. // this.did = this.$route.params.id
  181. // } else {
  182. // this.did = this.did
  183. // }
  184. },
  185. //添加图表
  186. handleLinkChart() {
  187. var send_data = {
  188. name: 'getChartListV2',
  189. page: 1,
  190. offset: 1,
  191. pagecount: 10,
  192. returntype: 'Map',
  193. parammaps: {
  194. pastureid: Cookies.get('pastureid'),
  195. empid: Cookies.get('employeid')
  196. }
  197. }
  198. GetDataByName(send_data).then(response => {
  199. console.log('table数据', response.data.list)
  200. if (response.data.list !== null) {
  201. this.myChartList = response.data.list
  202. this.showChartList = true
  203. } else {
  204. this.myChartList = []
  205. this.showChartList = true
  206. }
  207. })
  208. },
  209. }
  210. }
  211. </script>
  212. <style scoped>
  213. .board{
  214. width:300px;height:300px;border:1px soild #333;display:inline-block;background: #2ed1f9;padding: 5px 5px;margin-right: 15px;margin-bottom: 15px;
  215. }
  216. .tool-bar {
  217. display: block; border-top: none;
  218. height: 80px;
  219. line-height: 4;
  220. color: #303133;
  221. padding: 0 10px;
  222. position: relative;
  223. }
  224. .title-name {
  225. font-size: 20px;
  226. font-weight: 600;
  227. color: #333;
  228. margin-left: 0;
  229. }
  230. /* span {
  231. color: #c0c4cc;
  232. font-size: 12px;
  233. margin-left: 10px;
  234. }
  235. .text {
  236. font-size: 14px;
  237. }
  238. .item {
  239. margin-bottom: 18px;
  240. } */
  241. .clearfix:before,
  242. .clearfix:after {
  243. display: table;
  244. content: "";
  245. }
  246. .clearfix:after {
  247. clear: both
  248. }
  249. .board-card {
  250. width: 400px;min-height: 360px;
  251. padding: 20px 10px;
  252. display: inline-block;
  253. margin: 0px 0px 20px 20px;
  254. }
  255. </style>
  256. <style lang="scss" scoped>
  257. </style>