123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- import $ from 'jquery'
- import { Message, Loading } from 'element-ui'
- import {baseUrl, ajax} from '@/common/biConfig'
- //默认5种布局
- export const layout = {
- l1 : {tr1:[{colspan:1, rowspan:1, width:100, height:100, id:1}]},
- l2 : {tr1:[{colspan:1, rowspan:1, width:50, height:100, id:1},{colspan:1, rowspan:1, width:50, height:100, id:2}]},
- l3: {tr1:[{colspan:2, rowspan:1, width:100, height:50, id:1}],tr2:[{colspan:1, rowspan:1, width:50, height:50, id:2},{colspan:1, rowspan:1, width:50, height:50, id:3}]},
- l4: {tr1:[{colspan:2, rowspan:1, width:100, height:33, id:1}],tr2:[{colspan:1, rowspan:1, width:50, height:33, id:2},{colspan:1, rowspan:1, width:50, height:33, id:3}], tr3:[{colspan:2, rowspan:1, width:100, height:33, id:4}]},
- l5:{tr1:[{colspan:2, rowspan:1, width:100, height:20, id:1}],tr2:[{colspan:1, rowspan:1, width:50, height:20, id:2},{colspan:1, rowspan:1, width:50, height:20, id:3}], tr3:[{colspan:2, rowspan:1, width:100, height:20, id:4}],tr4:[{colspan:1, rowspan:1, width:50, height:20, id:5},{colspan:1, rowspan:1, width:50, height:20, id:6}],tr5:[{colspan:2, rowspan:1, width:100, height:20, id:7}]}
- }
- export const fmtJson = [{
- "text":"整数",
- "value":"#,##0"
- },{
- "text":"小数(保留一位)",
- "value":"#,##0.0"
- },{
- "text":"小数(保留两位)",
- "value":"#,##0.00"
- },{
- "text":"小数(保留四位)",
- "value":"#,##0.0000"
- },{
- "text":"百分比",
- "value":"#,##0%"
- },{
- "text": "百分比(保留一位小数)",
- "value": "#,##0.0%"
- }, {
- "text": "百分比(保留两位小数)",
- "value": "#,##0.00%"
- }, {
- "text": "百分比(保留四位小数)",
- "value": "#,##0.0000%"
- }];
- export const rates = [{
- "text":"1",
- "value":"1"
- },{
- "text":"千",
- "value":"1000"
- },{
- "text":"万",
- "value":"10000"
- },{
- "text":"百万",
- "value":"1000000"
- },{
- "text":"亿",
- "value":"100000000"
- }];
- export const pielabels = [{"text":"名称","value":"n"},{"text":"名称+值","value":"nv"},{"text":"名称+比例","value":"np"}];
- export const legendpos = [{text: '右上', value: 'righttop'},{text: '中上', value: 'centertop'},{text: '中下', value: 'centerbottom'}];
- export const msginfo = (msg, type)=>{
- if(!type || type === 'error'){
- Message.error({message:msg, type:"error",showClose: true});
- }else{
- Message.success({message:msg, type:"success",showClose: true});
- }
- }
- export const findParamById = (pageInfo, id, retIndex) => {
- var ret = null;
- for(let i=0; pageInfo.params&&i<pageInfo.params.length; i++){
- var p = pageInfo.params[i];
- if(p.id == id){
- if(retIndex){
- ret = i;
- }else{
- ret = p;
- }
- }
- }
- return ret;
- }
- export const getParamTypeDesc = (paramType)=>{
- var tpname = "";
- if(paramType == "text"){
- tpname = "输入框";
- }else if(paramType == "radio"){
- tpname = "单选框";
- }else if(paramType == "checkbox"){
- tpname = "多选框";
- }else if(paramType == "dateselect"){
- tpname = "日历框";
- }else if(paramType == "monthselect"){
- tpname = "月份框";
- }else if(paramType == "yearselect"){
- tpname = "年份框";
- }
- return tpname;
- }
- export const getCompTypeDesc = (compType)=>{
- var name = "";
- if(compType === 'text'){
- name = "文本";
- }else if(compType === 'box'){
- name = "数据块";
- }else if(compType === 'chart'){
- name = "图形";
- }else if(compType === 'grid'){
- name = "表格";
- }else if(compType === 'table'){
- name = "交叉表";
- }
- return name;
- }
- //从布局器中查询td(容器)
- export const findLayoutById = (layoutId, pageInfo)=>{
- var ret = null;
- for(var i=1; true; i++){
- var tr = pageInfo.body["tr"+i];
- if(!tr || tr == null){
- break;
- }
- for(var j=0; j<tr.length; j++){
- var td = tr[j];
- if(td.id == layoutId){
- ret = td;
- break;
- }
- }
- }
- return ret;
- }
- //查询布局器中所以组件
- export const findAllComps = (pageInfo)=>{
- let ret = [];
- for(var i=1; true; i++){
- var tr = pageInfo.body["tr"+i];
- if(!tr || tr == null){
- break;
- }
- for(var j=0; j<tr.length; j++){
- var td = tr[j];
- if(td.children){
- td.children.forEach(element => {
- ret.push(element);
- });
- }
- }
- }
- return ret;
- }
- /**
- //从布局器中查询组件
- * @param {*} pageInfo
- * @param {*} compId
- * @param {*} remove 是否移除查找到的对象
- */
- export const findCompById = (pageInfo, compId, remove)=>{
- let ret = null;
- for(var i=1; true; i++){
- var tr = pageInfo.body["tr"+i];
- if(!tr || tr == null){
- break;
- }
- for(var j=0; j<tr.length; j++){
- var td = tr[j];
- if(td.children){
- $(td.children).each((a, b)=>{
- if(b.id === compId){
- ret = b;
- if(remove){
- td.children.splice(a, 1);
- }
- return false;
- }
- });
- }
- }
- }
- return ret;
- }
- /**
- * 组件事件调用,目前只支持图形,交叉表
- * @param {*} link
- */
- export const compFireEvent = (link, ts, paramName, value)=>{
- let target = link.target;
- let types = link.type.split(",");
- $(target.split(",")).each((a, b)=>{
- let loadingInstance = Loading.service({fullscreen:false, target:document.querySelector('#c_'+b+" div.ccctx")});
- let dt = ts.$parent.$parent.$refs['paramViewForm'].getParamValues(); // 获取参数
- let tp = types[a];
- if(tp === 'chart'){
- dt['serviceid'] = "ext.sys.chart.rebuild";
- }else if(tp ==='table'){
- dt['serviceid'] = "ext.sys.cross.rebuild";
- }
- dt['t_from_id'] = "mv_" + ts.$parent.pageInfo.id;
- dt['id'] = b;
- dt[paramName] = value;
- ajax({
- url:"control/extControl",
- type:"POST",
- data:dt,
- success:(resp)=>{
- loadingInstance.close();
- if(tp === 'chart'){
- //更新图形
- let c = ts.$parent.$refs['mv_'+b];
- c.data = resp.rows;
- c.$nextTick(()=>c.showChart());
- }else if(tp === 'table'){
- }
- }
- }, ts, loadingInstance);
- });
- }
|