PortalCustomiz.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="customizLayout">
  3. <el-menu @select="handleSelect" class="el-menu-demo" background-color="#f6f8f8" text-color="#777" mode="horizontal">
  4. <el-menu-item index="back"><i class="fa fa-arrow-left"></i> 返回</el-menu-item>
  5. <el-menu-item index="save"><i class="glyphicon glyphicon-save"></i> 保存</el-menu-item>
  6. <el-menu-item index="layout"><i class="glyphicon glyphicon-th-large"></i> 布局</el-menu-item>
  7. <el-submenu index="data">
  8. <template slot="title"><i class="fa fa-database"></i> 数据</template>
  9. <el-menu-item index="data-1">选择立方体</el-menu-item>
  10. <el-menu-item index="data-2">选择数据表</el-menu-item>
  11. </el-submenu>
  12. <el-menu-item index="view"><i class="glyphicon glyphicon-file"></i> 预览</el-menu-item>
  13. </el-menu>
  14. <div class="report-layut">
  15. <layout-left :pageInfo="pageInfo" ref="layoutleftForm"></layout-left>
  16. <layout-right :pageInfo="pageInfo" ref="layoutRightForm"></layout-right>
  17. <div class="layout-center">
  18. <layout-param ref="paramForm" :pageInfo="pageInfo"></layout-param>
  19. <layout-optarea ref="optarea" :pageInfo="pageInfo"></layout-optarea>
  20. </div>
  21. <layoutBottom :pageInfo="pageInfo" ref="layoutBottomForm"></layoutBottom>
  22. </div>
  23. <portal-layout :pageInfo="pageInfo" ref="layout"></portal-layout>
  24. <selectCube ref="selectCubeForm" :callback="selectCubeCallback"></selectCube>
  25. <select-dset ref="selectDsetForm"></select-dset>
  26. <layout-param-add ref="prarmAddForm" :pageInfo="pageInfo"></layout-param-add>
  27. <!-- 保存框 -->
  28. <el-dialog title="报表保存" :visible.sync="saveShow" :close-on-click-modal="false" custom-class="nopadding">
  29. <el-form :model="saveInfo" ref="saveForm" :rules="rules" label-position="left">
  30. <el-form-item label="报表名称" label-width="100px" prop="name">
  31. <el-input v-model="saveInfo.name"></el-input>
  32. </el-form-item>
  33. </el-form>
  34. <div slot="footer" class="dialog-footer">
  35. <el-button type="primary" @click="savePage()">确 定</el-button>
  36. <el-button @click="saveShow = false">取 消</el-button>
  37. </div>
  38. </el-dialog>
  39. </div>
  40. </template>
  41. <script>
  42. import {baseUrl, ajax} from '@/common/biConfig'
  43. import layoutLeft from "./LayoutLeft.vue"
  44. import PortalLayout from "./PortalLayoutDailog.vue"
  45. import selectCube from "@/view/bireport/SelectCube"
  46. import SelectDset from "./SelectDset"
  47. import layoutParam from "./LayoutParam.vue"
  48. import LayoutOptarea from './LayoutOptarea.vue'
  49. import LayoutParamAdd from './LayoutParamAdd.vue'
  50. import LayoutBottom from './LayoutBottom.vue'
  51. import * as utils from './Utils'
  52. import $ from 'jquery'
  53. import "jquery-contextmenu";
  54. import "jquery-contextmenu/dist/jquery.contextMenu.min.css";
  55. import 'jquery-ui-dist/jquery-ui'
  56. import 'jquery-ui-dist/jquery-ui.css'
  57. import LayoutRight from './LayoutRight.vue'
  58. export default {
  59. name: "customizer",
  60. components: {layoutLeft, PortalLayout, selectCube, SelectDset, layoutParam, LayoutOptarea, LayoutParamAdd, LayoutBottom, LayoutRight},
  61. props: {
  62. },
  63. data() {
  64. return {
  65. pageInfo:{"layout":1,"body":{tr1:[{colspan:1, rowspan:1, width:100, height:100, id:1}]}},
  66. isupdate:false,
  67. saveShow:false,
  68. dataPanelShow:false,
  69. saveInfo:{
  70. name:null
  71. },
  72. rules:{
  73. name:[
  74. { required: true, message: '必填', trigger: 'blur' }
  75. ]
  76. },
  77. isbindTdEvent:false //是否给布局器table的 td 绑定拖拽事件
  78. }
  79. },
  80. methods: {
  81. //回写报表
  82. init(pageId){
  83. ajax({
  84. url:"portal/get.action",
  85. data:{pageId:pageId},
  86. type:"GET",
  87. success:(resp)=>{
  88. this.pageInfo = JSON.parse(resp.rows);
  89. this.isbindTdEvent = true; //需要重新绑定事件
  90. let o = this.$refs['layoutleftForm'];
  91. o.initdset( this.pageInfo.table);
  92. o.initcubes( this.pageInfo.selectDs);
  93. }
  94. }, this);
  95. },
  96. //显示数据面板
  97. showDataPanel(comp){
  98. this.$refs['layoutBottomForm'].showPanel(comp);
  99. this.$refs['layoutRightForm'].closeproperty();
  100. },
  101. hidePanel(){
  102. this.$refs['layoutRightForm'].closeproperty();
  103. this.$refs['layoutBottomForm'].closeDatapanel();
  104. },
  105. showPropPanel(comp){
  106. this.$refs['layoutBottomForm'].closeDatapanel();
  107. this.$refs['layoutRightForm'].showPanel(comp);
  108. },
  109. handleSelect(key, keyPath){
  110. if(key === 'back'){
  111. this.$router.push("/portal/Index");
  112. }
  113. if(key ==='layout'){
  114. this.$refs['layout'].setLayout();
  115. }
  116. if(key === 'data-1'){
  117. this.$refs['selectCubeForm'].select();
  118. }
  119. if(key === 'data-2'){
  120. this.$refs['selectDsetForm'].select();
  121. }
  122. if(key === 'view'){
  123. if(!this.pageInfo.id){
  124. this.$notify.error({
  125. title: '报表还未保存,不能预览!',
  126. offset: 50
  127. });
  128. return;
  129. }
  130. this.$router.push({path:"/portal/View", query:{id:this.pageInfo.id}});
  131. }
  132. if(key === 'save'){
  133. if(!this.pageInfo.id){
  134. this.saveShow = true;
  135. }else{
  136. this.savePage();
  137. }
  138. }
  139. },
  140. selectCubeCallback(cubeId){
  141. this.pageInfo.selectDs = cubeId;
  142. var o = this.$refs['layoutleftForm'];
  143. o.tabActive = 'data-tab-2';
  144. o.initcubes(cubeId);
  145. },
  146. savePage(){
  147. let ts = this;
  148. var pageId = this.pageInfo.id;
  149. //删除组件分页信息
  150. utils.findAllComps(this.pageInfo).forEach(element => {
  151. delete element.curPage;
  152. });
  153. if(!pageId){
  154. this.$refs['saveForm'].validate((valid) => {
  155. if(valid){
  156. ajax({
  157. url:"portal/save.action",
  158. type:"POST",
  159. data:{"pageInfo": JSON.stringify(ts.pageInfo), pageName:ts.saveInfo.name},
  160. success:(resp)=>{
  161. ts.$notify.success({
  162. title: '保存成功!',
  163. offset: 50
  164. });
  165. ts.saveShow = false;
  166. ts.pageInfo.id = resp.rows;
  167. }
  168. }, ts);
  169. }
  170. });
  171. }else{
  172. ajax({
  173. url:"portal/save.action",
  174. type:"POST",
  175. data:{"pageInfo": JSON.stringify(ts.pageInfo), pageId:pageId},
  176. success:(resp)=>{
  177. ts.$notify.success({
  178. title: '更新成功!',
  179. offset: 50
  180. });
  181. }
  182. }, ts);
  183. }
  184. }
  185. },
  186. watch: {
  187. },
  188. mounted() {
  189. let id = this.$route.query.id;
  190. if(id){
  191. this.init(id);
  192. }
  193. },
  194. beforeRouteLeave: function(to, from, next) {
  195. this.$destroy();
  196. next();
  197. }
  198. }
  199. </script>
  200. <style lang="less" scoped>
  201. .customizLayout {
  202. height: 100%;
  203. width: 100%;
  204. }
  205. .layout-center {
  206. position: inherit;
  207. margin: 0 0 0 223px;
  208. height: 100%;
  209. }
  210. .report-layut {
  211. width: 100%;
  212. height: calc(100% - 35px);
  213. }
  214. </style>