ChgChartDailog.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <!-- 表格对话框都放这里面 -->
  2. <template>
  3. <el-dialog title="切换图形类型" :visible.sync="show" :close-on-click-modal="false" custom-class="nopadding">
  4. <div class="row">
  5. <div class="col-sm-3">
  6. <ul>
  7. <template v-for="item in charts">
  8. <li :key="item.cid" :class="item.show?'select':''" @click="selectchart(item.cid)">{{item.cname}}</li>
  9. </template>
  10. </ul>
  11. </div>
  12. <div class="col-sm-9">
  13. <template v-for="item in charts">
  14. <div class="one" :key="item.cid" v-show="item.show">
  15. <template v-for="c in item.children">
  16. <span :key="c.index">
  17. <img :src="require('../../assets/chart/' + c.img)">
  18. <br/>
  19. {{ c.name }}
  20. </span>
  21. </template>
  22. <template v-if="item.type == 'map'">
  23. <el-select v-model="mapArea" placeholder="请选择地图区域" style="width:100%">
  24. <el-option
  25. v-for="item in opts.areas"
  26. :key="item.code"
  27. :label="item.name"
  28. :value="item.code">
  29. </el-option>
  30. </el-select>
  31. </template>
  32. </div>
  33. </template>
  34. </div>
  35. </div>
  36. <div slot="footer" class="dialog-footer">
  37. <el-button type="primary" @click="save()">确 定</el-button>
  38. <el-button @click="show = false">取 消</el-button>
  39. </div>
  40. </el-dialog>
  41. </template>
  42. <script>
  43. import {ajax} from '@/common/biConfig'
  44. import $ from 'jquery'
  45. export default {
  46. data(){
  47. return {
  48. show:false,
  49. mapArea:null,
  50. mapAreaname:null,
  51. opts:{
  52. areas:[]
  53. },
  54. chart:null,
  55. charts:[
  56. {cid:"1", cname:"曲线图", type:"line",show:true,children:[
  57. {img:"c1.gif", index:"1", name:"曲线图"}
  58. ]},
  59. {cid:"2", cname:"柱状图",type:"column",show:false,children:[
  60. {img:"c2.gif", index:"1", name:"柱状图"}
  61. ]},
  62. {cid:"3", cname:"条形图",type:"bar",show:false,children:[
  63. {img:"bar.gif", index:"1", name:"条形图"}
  64. ]},
  65. {cid:"4", cname:"面积图",type:"area",show:false,children:[
  66. {img:"area.gif", index:"1", name:"面积图"}
  67. ]},
  68. {cid:"5", cname:"饼图",type:"pie", show:false,children:[
  69. {img:"c3.gif", index:"1", name:"饼图"}
  70. ]},
  71. {cid:"6", cname:"仪表盘",type:"gauge",show:false,children:[
  72. {img:"c4.gif", index:"1", name:"仪表盘"}
  73. ]},
  74. {cid:"7", cname:"雷达图", type:"radar", show:false,children:[
  75. {img:"c5.gif", index:"1", name:"雷达图"}
  76. ]},
  77. {cid:"8", cname:"散点图",type:"scatter",show:false,children:[
  78. {img:"c6.gif", index:"1", name:"散点图"}
  79. ]},
  80. {cid:"9", cname:"气泡图",type:"bubble",show:false,children:[
  81. {img:"c7.gif", index:"1", name:"气泡图"}
  82. ]},
  83. {cid:"10", cname:"地图",type:"map", show:false,children:[
  84. {img:"c8.gif", index:"1", name:"地图"}
  85. ]},
  86. ]
  87. }
  88. },
  89. mounted(){
  90. this.initAreas();
  91. },
  92. computed: {
  93. },
  94. methods: {
  95. initAreas(){
  96. ajax({
  97. url:"bireport/listAreas.action",
  98. data:{},
  99. type:"GET",
  100. success:(resp)=>{
  101. this.opts.areas = resp.rows;
  102. }
  103. }, this);
  104. },
  105. save(){
  106. this.show = false;
  107. let tp = null;
  108. $(this.charts).each((a, b)=>{
  109. if(b.show === true){
  110. tp = b.type;
  111. }
  112. });
  113. this.chart.chartJson.type = tp;
  114. this.$parent.resetChart();
  115. //重新绑定拖拽事件
  116. this.$parent.initChartKpiDrop(2);
  117. this.$parent.chartView();
  118. this.$parent.setUpdate();
  119. },
  120. open(chart){
  121. this.show = true;
  122. this.chart = chart;
  123. },
  124. selectchart(chartId){
  125. $(this.charts).each((a, b)=>{
  126. if(b.cid == chartId){
  127. b.show = true
  128. }else{
  129. b.show = false;
  130. }
  131. });
  132. },
  133. },
  134. watch: {
  135. }
  136. }
  137. </script>
  138. <style lang="less" scoped>
  139. .one{
  140. margin:10px;
  141. padding:10px;
  142. cursor:pointer;
  143. text-align:left;
  144. span {
  145. width:130px;
  146. height:143px;
  147. display:inline-block;
  148. margin-right:10px;
  149. overflow:hidden;
  150. text-align:center;
  151. cursor:pointer;
  152. }
  153. }
  154. .row {
  155. ul {
  156. margin:0px;
  157. padding:0px;
  158. li {
  159. margin:0px;
  160. padding:6px;
  161. background-color:#EEE;
  162. border-bottom:solid 1px #CCCCCC;
  163. cursor:pointer;
  164. list-style: none;
  165. }
  166. li.select {
  167. background-color:#FFF;
  168. }
  169. }
  170. }
  171. </style>