PortalCustomiz.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. if(this.isupdate == true){
  112. if(confirm("您还未保存报表,是否确认退出?")){
  113. this.$router.push("/portal/Index");
  114. }
  115. }else{ //保存过了,直接退出
  116. this.$router.push("/portal/Index");
  117. }
  118. }
  119. if(key ==='layout'){
  120. this.$refs['layout'].setLayout();
  121. }
  122. if(key === 'data-1'){
  123. this.$refs['selectCubeForm'].select();
  124. }
  125. if(key === 'data-2'){
  126. this.$refs['selectDsetForm'].select();
  127. }
  128. if(key === 'view'){
  129. if(!this.pageInfo.id){
  130. this.$notify.error({
  131. title: '报表还未保存,不能预览!',
  132. offset: 50
  133. });
  134. return;
  135. }
  136. this.$router.push({path:"/portal/View", query:{id:this.pageInfo.id}});
  137. }
  138. if(key === 'save'){
  139. if(!this.pageInfo.id){
  140. this.saveShow = true;
  141. }else{
  142. this.savePage();
  143. }
  144. }
  145. },
  146. selectCubeCallback(cubeId){
  147. this.pageInfo.selectDs = cubeId;
  148. var o = this.$refs['layoutleftForm'];
  149. o.tabActive = 'data-tab-2';
  150. o.initcubes(cubeId);
  151. },
  152. savePage(){
  153. let ts = this;
  154. var pageId = this.pageInfo.id;
  155. //删除组件分页信息
  156. utils.findAllComps(this.pageInfo).forEach(element => {
  157. delete element.curPage;
  158. });
  159. if(!pageId){
  160. this.$refs['saveForm'].validate((valid) => {
  161. if(valid){
  162. ajax({
  163. url:"portal/save.action",
  164. type:"POST",
  165. data:{"pageInfo": JSON.stringify(ts.pageInfo), pageName:ts.saveInfo.name},
  166. success:(resp)=>{
  167. ts.$notify.success({
  168. title: '保存成功!',
  169. offset: 50
  170. });
  171. ts.saveShow = false;
  172. ts.pageInfo.id = resp.rows;
  173. ts.isupdate = false;
  174. }
  175. }, ts);
  176. }
  177. });
  178. }else{
  179. ajax({
  180. url:"portal/save.action",
  181. type:"POST",
  182. data:{"pageInfo": JSON.stringify(ts.pageInfo), pageId:pageId},
  183. success:(resp)=>{
  184. ts.$notify.success({
  185. title: '更新成功!',
  186. offset: 50
  187. });
  188. ts.isupdate = false;
  189. }
  190. }, ts);
  191. }
  192. }
  193. },
  194. watch: {
  195. },
  196. mounted() {
  197. let id = this.$route.query.id;
  198. if(id){
  199. this.init(id);
  200. }
  201. },
  202. beforeRouteLeave: function(to, from, next) {
  203. this.$destroy();
  204. next();
  205. }
  206. }
  207. </script>
  208. <style lang="less" scoped>
  209. .customizLayout {
  210. width: 100%;
  211. height: calc(100% - 32px);
  212. }
  213. .layout-center {
  214. position: inherit;
  215. margin: 0 0 0 223px;
  216. height: 100%;
  217. }
  218. .report-layut {
  219. width: 100%;
  220. height: calc(100% - 35px);
  221. }
  222. </style>