| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- <template>
- <div class="container">
- <el-row>
- <div class="tool-bar">
- <div>
- <span class="title-name">仪表盘标题</span>
- </div>
- <div style = "position:absolute:top:0px;right:0px">
- <el-button class="miniSuccess" @click="control_edit()">编辑</el-button>
- <el-button class="successBorder" @click="handleLinkChart">
- 添加图表
- </el-button>
- </div>
-
- </div>
- </el-row>
- <el-row>
- <div>
- <draggable v-model="boardList" group="itxst" animation="300" :group="{name: 'dashboard',pull: true}" @start="onStart" @end="onEnd">
- <transition-group>
- <el-card class="box-card board-card" key="1" v-for="item in boardList">
- <div slot="header" class="clearfix">
- <span>{{item.title}}</span>
-
- <div style="float: right; padding: 3px 0;display:inline-block;">
- <i class="el-icon-edit" style="color:#009C69;cursor:pointer;" />
- <i class="el-icon-delete" style="color:#009C69;cursor:pointer;" />
- </div>
- </div>
- <div class="board-item" >
- 表格
-
- <BarChart v-if = "item.boardtype == 'bar'" :chart-data="item.chartData" />
- <LineChart v-if = "item.boardtype == 'line'" :chart-data="item.chartData" />
- <!-- <HorizontalBarChart v-if = "item.boardtype == 'horizontal_bar'" :chart-data="item.chartData" /> -->
- <PieChart v-if = "item.boardtype == 'pie'" :chart-data="item.chartData" />
- <!-- <LineBarChart v-if = "item.boardtype == 'line_bar'" :chart-data="item.chartData" /> -->
- </div>
- <!-- <div class="board-item" v-if="item.boardtype == 'line'">
- <keep-alive>
- <component :is="chartLine.myComponent" ref="chartLine" />
- </keep-alive>
- </div> -->
- </el-card>
-
-
- </transition-group>
- </draggable>
- </div>
- </el-row>
- <el-row>
- </el-row>
-
-
- <el-dialog title="我的图表" :visible.sync="showChartList">
- <!-- <el-button type="primary" size="mini" @click="$router.push({ name: 'ChartPanel', params: { id: 'create' , isEdit: 'edit'}})">
- 创建新的图表
- </el-button> -->
- <el-button class="save" style="margin-bottom: 10px;" @click="jumpCreate()"> 创建新的图表 </el-button>
- <el-table :data="myChartList" border>
- <el-table-column :label="$t('common.name')" width="200" prop="chart_name" />
- <el-table-column :label="$t('common.desc')" prop="desc" />
- <el-table-column :label="$t('common.operation')" align="center">
- <template slot-scope="scope">
- <el-button class="miniPrimary" :disabled="isExisted(scope.row)" @click="linkChart(scope.row)">添加</el-button>
- <el-button size="mini" type="warning" style="padding: 6px 10px !important;font-size:14px;" @click="jumpEdit2(scope.row)"> 编辑 </el-button>
- </template>
- </el-table-column>
- </el-table>
- <div slot="footer" class="dialog-footer" style="bottom: 10px;">
- <el-button class="cancelClose1" @click="showChartList = false">{{$t('common.closed')}}</el-button>
- </div>
- </el-dialog>
-
-
- </div>
- </template>
- <script>
- import draggable from 'vuedraggable'
-
- import { GetDataByName } from '@/api/common'
- // import { ChartTable } from '@/components/ChartTable'
- import ChartTable from '@/componentChart/ChartTable.vue'
- import LineChart from '@/componentChart/LineChart.vue'
- import BarChart from '@/componentChart/BarChart.vue'
- import HorizontalBarChart from '@/componentChart/HorizontalBarChart.vue'
- import PieChart from '@/componentChart/PieChart.vue'
- import LineBarChart from '@/componentChart/LineBarChart.vue'
- import Cookies from 'js-cookie'
-
- export default {
- name: 'Addboard2',
-
- components: { draggable , ChartTable ,LineChart,BarChart ,HorizontalBarChart, PieChart, LineBarChart},
- data() {
- return {
- isRoleEdit: [],
-
- boardList: [
- {
- title:'图表1',boardId:1,boardtype:'bar',
- chartData:{
- chartType:'bar',
- 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'],
- legendArr: ['数据1', '数据2', '数据3'],
- dataArr:[
- [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
- [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
- [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
-
- ]
- }
- },
- {
- title:'图表2',boardId:2,boardtype:'line',
- chartData:{
- chartType:'line',
- 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'],
- legendArr: ['数据1', '数据2', '数据3'],
- dataArr:[
- [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
- [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
- [1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
- ]
- }
- },
- {
- title:'图表3',boardId:3,boardtype:'pie',
- chartData:{
- chartType:'pie',
- 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'],
- legendArr: ['数据1', '数据2', '数据3', '数据4', '线条1'],
- dataArr:[1, 10, 7, 0, 1, 7, 7, 6, 4, 4, 1, 6],
-
- }
- },
- {title:'图表3'},
- {title:'图表3'},
- {title:'图表3'},
- {title:'图表3'},
- ],
- chartTable: {
- dialogFormVisible: false,
- dialogStatus: '',
- myComponent: null
- },
- chartLine: {
- dialogFormVisible: false,
- dialogStatus: '',
- myComponent: null
- },
- myChartList: [],
- showChartList: false,
- chartLoading: {},
- isEdit: 'view',
- dashboardList: [],
- currentDashboard: undefined,
- editDialogVisible: false,
- dbObj: {},
- loading: false,
- isCollapse: false,
- did: undefined,
- isTitle: '2',
- editBtn: false,
- control_btn: '编辑',
- control_btn_l: false,
-
- }
- },
- created() {
- // console.log('this.$route.params.id', this.$route.params.id)
- // const isEdit = this.$route.params.isEdit
- // this.isEdit = isEdit
-
- this.getList()
- this.chartTable.dialogFormVisible = true
- this.chartLine.dialogFormVisible = true
- const vue = this
- // var myComponent1 = () => import('./chartTable.vue')
- // vue.chartTable.myComponent = myComponent1
- // var myComponent2 = () => import('./chartLine.vue')
- // vue.chartTable.myComponent = myComponent2
- },
- methods: {
- onStart(){
- console.log(2222)
- },
- onEnd(){
- console.log(this.boardList)
-
- },
-
- getList() {
- // const vue = this
- // var myComponent = () => import('./chartTable.vue')
- // return vue.chartTable.myComponent = myComponent
-
- this.loading = true
- // if (this.$route.params.id) {
- // this.did = this.$route.params.id
- // } else {
- // this.did = this.did
- // }
-
- },
- //添加图表
- handleLinkChart() {
- var send_data = {
- name: 'getChartListV2',
- page: 1,
- offset: 1,
- pagecount: 10,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- empid: Cookies.get('employeid')
- }
- }
- GetDataByName(send_data).then(response => {
- console.log('table数据', response.data.list)
- if (response.data.list !== null) {
- this.myChartList = response.data.list
- this.showChartList = true
- } else {
- this.myChartList = []
- this.showChartList = true
- }
- })
- },
-
- }
- }
- </script>
- <style scoped>
- .board{
- width:300px;height:300px;border:1px soild #333;display:inline-block;background: #2ed1f9;padding: 5px 5px;margin-right: 15px;margin-bottom: 15px;
- }
- .tool-bar {
- display: block; border-top: none;
- height: 80px;
- line-height: 4;
- color: #303133;
- padding: 0 10px;
- position: relative;
-
- }
- .title-name {
- font-size: 20px;
- font-weight: 600;
- color: #333;
- margin-left: 0;
- }
- /* span {
- color: #c0c4cc;
- font-size: 12px;
- margin-left: 10px;
- }
- .text {
- font-size: 14px;
- }
- .item {
- margin-bottom: 18px;
- } */
- .clearfix:before,
- .clearfix:after {
- display: table;
- content: "";
- }
- .clearfix:after {
- clear: both
- }
- .board-card {
- width: 400px;min-height: 360px;
- padding: 20px 10px;
- display: inline-block;
- margin: 0px 0px 20px 20px;
- }
- </style>
- <style lang="scss" scoped>
- </style>
|