GitBucket
4.6.0
Toggle navigation
Sign in
Files
Branches
1
Tags
Issues
Pull Requests
Labels
Milestones
Wiki
08335
/
hivui-platform-template
hivui平台项目模板
Browse code
Jenkins commit
master
1 parent
8ca3f21
commit
f1c23d07a4a85a7ccf0fae9dac8a2478394cc456
12896
authored
on 8 Jul 2022
Showing
4 changed files
build/webpack.get-list.js
package.json
project/hivuiBirt/App.vue
project/hivuiBirt/index.js
Ignore Space
Show notes
View
build/webpack.get-list.js
var fsextra = require('fs-extra'); const path = require("path"); const glob = require('glob') // const fs = require("fs"); // const {Chalk} = require('chalk') const merge = require('webpack-merge'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CleanWebpackPlugin = require('clean-webpack-plugin'); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const baseWebpackConfig = require('./webpack.base.conf'); const packageConfig = require('../package.json'); const projectName = packageConfig.name=='hi-vui-template'?'project':packageConfig.name // console.log('---------------------webpack.get-list.js------------', process.env.NODE_ENV) function repeat(array) { let map = new Map(); let array1 = []; // 数组用于返回结果 for (let i = 0, leng = array.length; i < leng; i++) { if (map.has(array[i])) { // 判断是否存在key map.set(array[i], true); } else { map.set(array[i], false); array1.push(array[i]); } } return array1; } // 用来记录当前打包的模块路径列表,判断进程参数 let argvs = (process.argv[2] || "").replace(/\s*$/g, "") let moduleList = []; let isBuildAll=true; if (argvs) { isBuildAll=false; moduleList = []; let list = argvs.split(','); for (let i = 0, l = list.length; i < l; i++) { // let checkPath = fs.existsSync(list[i]+'/package.json'); //如果目录存在 返回 true ,如果目录不存在 返回false // if (checkPath == false) continue; let modulePath = list[i]; let pathList = glob.sync(modulePath + '/package.json'); // 这个执行比较快 114.811ms if (pathList.length == 0) { // 查找modulePath目录 // let ls = glob.sync(`${modulePath}/!(dist|node_modules|build)/**/package.json`) // for (let k = 0, l = ls.length; k < l; k++) { // moduleList.push(ls[k].replace('/package.json', '')); // } if(modulePath=='./assets_platform'){ let res = modulePath.replace('./', ''); var isexist = fsextra.existsSync(path.resolve(__dirname, '../', res)); isexist&&fsextra.copySync(path.resolve(__dirname, '../', res), path.resolve(__dirname, '../dist/', res), { overwrite:false, // errorOnExist:false }) //拷贝模块资源目录 }else if(/\/deploy\/desktop\/[\w,\/,\.]*\/dpdst\/[\w,\/,\.]*(\.dpdst)$/.test(modulePath)){//服务部署环境配置的.json let buildScheme=fsextra.readJsonSync(path.resolve(__dirname, '../', modulePath.replace('.dpdst','.json'))); let settingPath=path.resolve(__dirname, '../dist/',projectName+'/setting/desktop/appsetting.js') fsextra.copySync(path.resolve(__dirname, '../', buildScheme.appSetting), settingPath, { overwrite:false, // errorOnExist:false }) //拷贝模块资源目录 }else{// if(/(\/res)$/.test(modulePath)) let res = modulePath.replace('./', ''); var isexist = fsextra.existsSync(path.resolve(__dirname, '../', res)); isexist&&fsextra.copySync(path.resolve(__dirname, '../', res), path.resolve(__dirname, '../dist/', res), { overwrite:false, // errorOnExist:false }) //拷贝模块资源目录 }continue } else { moduleList.push(modulePath); } } } else { //编译所有,找出模块 moduleList = require('./webpack.get-module').moduleList || []; } moduleList = repeat(moduleList); //去重 let evnConfig = require('./getEnvVar') let webpackList = [], resList = []; //构建webpack 配置 for (let i = 0, l = moduleList.length; i < l; i++) { let MODULE = moduleList[i]; // console.log('---------------模块-------------',MODULE) if(isBuildAll){ //全部编译时拷资源文件res let res = MODULE.indexOf('/view') > -1 ? MODULE.split('view')[0] + 'res' : ''; // console.log('=========================',res) if (res) { res = res.replace('./', ''); var isexist = fsextra.existsSync(path.resolve(__dirname, '..', res)); if(isexist){ // console.log('拷贝模块资源目录====',path.resolve(__dirname, '..', res)) fsextra.copySync(path.resolve(__dirname, '..', res), path.resolve(__dirname, '../dist', res), { overwrite:false, // errorOnExist:false }) //拷贝模块资源目录 } } } // continue; //添加每个模块的webpack 配置 let MODULE_NAME = MODULE.split('/').pop(); let entry = {}; let outputPath = path.resolve(__dirname, '../dist', MODULE) entry[MODULE_NAME] = ['babel-polyfill', `${MODULE}/index.js`]; // @babel/polyfill let wpk = merge({ mode: 'production', // mode: 'development', // devtool: 'source-map', }, baseWebpackConfig, { entry: entry, output: { path: outputPath, filename: `static/js/[name].js`, // publicPath:'./' // publicPath: `/${evnConfig.VITE_APP_SERVER.replace(/"/gi,"")}/render/${packageConfig.author}/${MODULE.replace('./', '')}/` publicPath: `${evnConfig.VITE_APP_USERPATH.replace(/"/gi,"")}/${MODULE.replace('./', '')}/` } }); let htmlTemplate = `${MODULE}/index.html` // var checkPath = fs.existsSync(htmlTemplate); // //如果目录存在 返回 true ,如果目录不存在 返回false // if (checkPath == false) { // htmlTemplate = path.resolve(__dirname, './template.html') // } let pathList = glob.sync(htmlTemplate); // 这个执行比较快 114.811ms if (pathList.length == 0) htmlTemplate = path.resolve(__dirname, './template.html'); wpk.plugins.push(new CleanWebpackPlugin([outputPath], { root: path.resolve(__dirname, '../'), //根目录 //其他配置按需求添加 verbose: false, //不提示删除 })); wpk.plugins.push( new MiniCssExtractPlugin({ filename: 'static/css/[name].[contenthash].css', chunkFilename: `static/css/[name].[contenthash].css` }) ); wpk.plugins.push( new HtmlWebpackPlugin({ filename: path.resolve(__dirname, '../dist', MODULE, 'index.html'), template: htmlTemplate, //如果html 不存在考虑用全局根目录下 inject: true, minify: { removeComments: true, //去除注释 collapseWhitespace: true, //是否去除空格 removeAttributeQuotes: true //去除空属性 }, compile: true })) webpackList.push(wpk); } module.exports = webpackList; // [webpackList[4]] ////[webpackList[3]];//27
var fsextra = require('fs-extra'); const path = require("path"); const glob = require('glob') // const fs = require("fs"); // const {Chalk} = require('chalk') const merge = require('webpack-merge'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CleanWebpackPlugin = require('clean-webpack-plugin'); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const baseWebpackConfig = require('./webpack.base.conf'); const packageConfig = require('../package.json'); const projectName = packageConfig.name=='hi-vui-template'?'project':packageConfig.name // console.log('---------------------webpack.get-list.js------------', process.env.NODE_ENV) function repeat(array) { let map = new Map(); let array1 = []; // 数组用于返回结果 for (let i = 0, leng = array.length; i < leng; i++) { if (map.has(array[i])) { // 判断是否存在key map.set(array[i], true); } else { map.set(array[i], false); array1.push(array[i]); } } return array1; } // 用来记录当前打包的模块路径列表,判断进程参数 let argvs = (process.argv[2] || "").replace(/\s*$/g, "") let moduleList = []; let isBuildAll=true; if (argvs) { isBuildAll=false; moduleList = []; let list = argvs.split(','); for (let i = 0, l = list.length; i < l; i++) { // let checkPath = fs.existsSync(list[i]+'/package.json'); //如果目录存在 返回 true ,如果目录不存在 返回false // if (checkPath == false) continue; let modulePath = list[i]; let pathList = glob.sync(modulePath + '/package.json'); // 这个执行比较快 114.811ms if (pathList.length == 0) { // 查找modulePath目录 // let ls = glob.sync(`${modulePath}/!(dist|node_modules|build)/**/package.json`) // for (let k = 0, l = ls.length; k < l; k++) { // moduleList.push(ls[k].replace('/package.json', '')); // } if(modulePath=='./assets_platform'){ let res = modulePath.replace('./', ''); var isexist = fsextra.existsSync(path.resolve(__dirname, '../', res)); isexist&&fsextra.copy(path.resolve(__dirname, '../', res), path.resolve(__dirname, '../dist/', res), function (err) { // ../project/AnNiu/res if (err){ return console.error('build_error:'+err) } else{ return console.log(modulePath,"拷贝文件成功!") } }) //拷贝模块资源目录 }else if(/\/deploy\/desktop\/[\w,\/,\.]*\/dpdst\/[\w,\/,\.]*(\.dpdst)$/.test(modulePath)){//服务部署环境配置的.json let buildScheme=fsextra.readJsonSync(path.resolve(__dirname, '../', modulePath.replace('.dpdst','.json'))); let settingPath=path.resolve(__dirname, '../dist/',projectName+'/setting/desktop/appsetting.js') fsextra.copy(path.resolve(__dirname, '../', buildScheme.appSetting), settingPath, function (err) { if (err){ return console.error('build_error:'+err) } else{ return console.log(buildScheme.appSetting,"拷贝文件成功!") } }) //拷贝模块资源目录 }else{// if(/(\/res)$/.test(modulePath)) let res = modulePath.replace('./', ''); var isexist = fsextra.existsSync(path.resolve(__dirname, '../', res)); isexist&&fsextra.copy(path.resolve(__dirname, '../', res), path.resolve(__dirname, '../dist/', res), function (err) { // ../project/AnNiu/res if (err){ return console.error('build_error:'+err) } else{ return console.log(modulePath,"拷贝文件成功!") } }) //拷贝模块资源目录 }continue } else { moduleList.push(modulePath); } } } else { moduleList = require('./webpack.get-module').moduleList || []; } moduleList = repeat(moduleList); //去重 let evnConfig = require('./getEnvVar') let webpackList = [], resList = []; //构建webpack 配置 for (let i = 0, l = moduleList.length; i < l; i++) { let MODULE = moduleList[i]; if(isBuildAll){ //全部编译时拷资源文件res let res = MODULE.indexOf('/view') > -1 ? MODULE.split('view')[0] + '/res' : ''; if (res) { res = res.replace('./', ''); var isexist = fsextra.existsSync(path.resolve(__dirname, '../', res)); isexist&&fsextra.copy(path.resolve(__dirname, '../', res), path.resolve(__dirname, '../dist/', res), function (err) { if (err) return console.error(err) }) //拷贝模块资源目录 } } //添加每个模块的webpack 配置 let MODULE_NAME = MODULE.split('/').pop(); let entry = {}; let outputPath = path.resolve(__dirname, '../dist', MODULE) entry[MODULE_NAME] = ['babel-polyfill', `${MODULE}/index.js`]; // @babel/polyfill let wpk = merge({ mode: 'production', // mode: 'development', // devtool: 'source-map', }, baseWebpackConfig, { entry: entry, output: { path: outputPath, filename: `static/js/[name].js`, // publicPath:'./' // publicPath: `/${evnConfig.VITE_APP_SERVER.replace(/"/gi,"")}/render/${packageConfig.author}/${MODULE.replace('./', '')}/` publicPath: `${evnConfig.VITE_APP_USERPATH.replace(/"/gi,"")}/${MODULE.replace('./', '')}/` } }); let htmlTemplate = `${MODULE}/index.html` // var checkPath = fs.existsSync(htmlTemplate); // //如果目录存在 返回 true ,如果目录不存在 返回false // if (checkPath == false) { // htmlTemplate = path.resolve(__dirname, './template.html') // } let pathList = glob.sync(htmlTemplate); // 这个执行比较快 114.811ms if (pathList.length == 0) htmlTemplate = path.resolve(__dirname, './template.html'); wpk.plugins.push(new CleanWebpackPlugin([outputPath], { root: path.resolve(__dirname, '../'), //根目录 //其他配置按需求添加 verbose: false, //不提示删除 })); wpk.plugins.push( new MiniCssExtractPlugin({ filename: 'static/css/[name].[contenthash].css', chunkFilename: `static/css/[name].[contenthash].css` }) ); wpk.plugins.push( new HtmlWebpackPlugin({ filename: path.resolve(__dirname, '../dist', MODULE, 'index.html'), template: htmlTemplate, //如果html 不存在考虑用全局根目录下 inject: true, minify: { removeComments: true, //去除注释 collapseWhitespace: true, //是否去除空格 removeAttributeQuotes: true //去除空属性 }, compile: true })) webpackList.push(wpk); } module.exports = webpackList; // [webpackList[4]] ////[webpackList[3]];//27
Ignore Space
Show notes
View
package.json
{ "name": "hi-vui-template", "version": "1.1.15", "description": "A hi-vui-template project", "author": "zhcTeam", "scripts": { "rm:vite": "rimraf node_modules/.vite && rimraf node_modules/.cache", "pm2:start": "pm2 start processes.json", "dev": "vite --host", "def": "vite --host", "build": "node build/copyBaseAssets.js && cross-env NODE_ENV=production node build/webpack.prod.conf.js", "build:modules": "cross-env NODE_ENV=production node build/webpack.prod.conf.js", "build1": "webpack --mode production --config build/webpack.prod.conf.js", "dll": "webpack --config build/webpack.dll.conf.js", "start": "webpack-dev-server --config build/webpack.dev.conf.js", "copyassets": "node build/copyBaseAssets.js" }, "devDependencies": { "@babel/core": "^7.1.2", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", "@babel/plugin-proposal-optional-chaining": "^7.16.7", "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/preset-env": "^7.1.0", "@vitejs/plugin-vue-jsx": "^1.3.3", "@vue/babel-helper-vue-jsx-merge-props": "^1.2.1", "@vue/babel-preset-jsx": "^1.2.4", "add-asset-html-webpack-plugin": "^3.2.0", "autoprefixer": "^9.1.5", "babel-loader": "^8.0.4", "babel-plugin-component": "^1.1.1", "babel-plugin-transform-vite-meta-env": "^1.0.3", "chalk": "^3.0.0", "clean-webpack-plugin": "^0.1.19", "copy-webpack-plugin": "^4.5.3", "cross-env": "^7.0.3", "css-loader": "^1.0.0", "dotenv": "^10.0.0", "file-loader": "^2.0.0", "happypack": "^5.0.1", "html-webpack-plugin": "^4.5.2", "less": "^4.1.2", "less-loader": "^5.0.0", "mini-css-extract-plugin": "^1.6.2", "node-sass": "^4.9.3", "optimize-css-assets-webpack-plugin": "^5.0.1", "parallel-webpack": "^2.6.0", "postcss-import": "^11.1.0", "postcss-loader": "^2.1.6", "postcss-url": "^7.3.2", "progress-bar-webpack-plugin": "^2.1.0", "sass": "^1.49.0", "sass-loader": "^7.1.0", "style-loader": "^0.23.0", "thread-loader": "^3.0.4", "uglifyjs-webpack-plugin": "^2.0.1", "url-loader": "^1.1.1", "vite": "2.3.7", "vite-plugin-html": "^2.1.1", "vite-plugin-imp": "^2.0.11", "vite-plugin-pagedata": "^1.0.4", "vite-plugin-vue2": "^1.9.0", "vue-loader": "^15.4.2", "vue-template-compiler": "^2.6.14", "webpack": "^4.46.0", "webpack-cli": "^4.9.2", "webpack-dev-server": "^3.11.3", "webpack-merge": "^4.1.4" }, "dependencies": { "axios": "^0.24.0", "babel-polyfill": "^6.26.0", "canvas": "^2.9.0", "classnames": "^2.3.1", "deep-lu-trans": "^1.0.5", "echarts": "^5.2.2", "echarts-liquidfill": "^3.1.0", "element-ui": "^2.15.7", "enquire.js": "^2.1.6", "font-awesome": "^4.7.0", "hi-taskcenter": "^1.0.9", "hi-ui": "^1.1.1006", "html2canvas": "^1.4.1", "jquery": "^3.6.0", "js-cookie": "^3.0.1", "js-md5": "^0.7.3", "js-pinyin": "^0.1.9", "jspdf": "^2.5.1", "lodash": "^4.17.11", "qrcodejs2": "0.0.2", "screenfull": "^6.0.0", "sortablejs": "^1.14.0", "v-clipboard": "^2.2.3", "vue": "^2.6.14", "vue-draggable-resizable": "^2.3.0", "vue-gemini-scrollbar": "^2.0.1", "vue-i18n": "^8.27.0", "vue-jstree": "^2.1.6", "vue-qr": "^3.2.4", "vue-router": "^3.0.1", "vuex": "^3.6.2", "xlsx": "^0.18.5", "zhc-birt-cmps": "^2.8.2", "zhc-birt-core": "^1.9.0", "zhc-flowchart": "^1.0.20" } }
{ "name": "hi-vui-template", "version": "1.1.15", "description": "A hi-vui-template project", "author": "zhcTeam", "scripts": { "rm:vite": "rimraf node_modules/.vite && rimraf node_modules/.cache", "pm2:start": "pm2 start processes.json", "dev": "vite --host", "def": "vite --host", "build": "node build/copyBaseAssets.js && cross-env NODE_ENV=production node build/webpack.prod.conf.js", "build:modules": "cross-env NODE_ENV=production node build/webpack.prod.conf.js", "build1": "webpack --mode production --config build/webpack.prod.conf.js", "dll": "webpack --config build/webpack.dll.conf.js", "start": "webpack-dev-server --config build/webpack.dev.conf.js", "copyassets": "node build/copyBaseAssets.js" }, "devDependencies": { "@babel/core": "^7.1.2", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", "@babel/plugin-proposal-optional-chaining": "^7.16.7", "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/preset-env": "^7.1.0", "@vitejs/plugin-vue-jsx": "^1.3.3", "@vue/babel-helper-vue-jsx-merge-props": "^1.2.1", "@vue/babel-preset-jsx": "^1.2.4", "add-asset-html-webpack-plugin": "^3.2.0", "autoprefixer": "^9.1.5", "babel-loader": "^8.0.4", "babel-plugin-component": "^1.1.1", "babel-plugin-transform-vite-meta-env": "^1.0.3", "chalk": "^3.0.0", "clean-webpack-plugin": "^0.1.19", "copy-webpack-plugin": "^4.5.3", "cross-env": "^7.0.3", "css-loader": "^1.0.0", "dotenv": "^10.0.0", "file-loader": "^2.0.0", "happypack": "^5.0.1", "html-webpack-plugin": "^4.5.2", "less": "^4.1.2", "less-loader": "^5.0.0", "mini-css-extract-plugin": "^1.6.2", "node-sass": "^4.9.3", "optimize-css-assets-webpack-plugin": "^5.0.1", "parallel-webpack": "^2.6.0", "postcss-import": "^11.1.0", "postcss-loader": "^2.1.6", "postcss-url": "^7.3.2", "progress-bar-webpack-plugin": "^2.1.0", "sass": "^1.49.0", "sass-loader": "^7.1.0", "style-loader": "^0.23.0", "thread-loader": "^3.0.4", "uglifyjs-webpack-plugin": "^2.0.1", "url-loader": "^1.1.1", "vite": "2.3.7", "vite-plugin-html": "^2.1.1", "vite-plugin-imp": "^2.0.11", "vite-plugin-pagedata": "^1.0.4", "vite-plugin-vue2": "^1.9.0", "vue-loader": "^15.4.2", "vue-template-compiler": "^2.6.14", "webpack": "^4.46.0", "webpack-cli": "^4.9.2", "webpack-dev-server": "^3.11.3", "webpack-merge": "^4.1.4" }, "dependencies": { "axios": "^0.24.0", "babel-polyfill": "^6.26.0", "canvas": "^2.9.0", "classnames": "^2.3.1", "deep-lu-trans": "^1.0.5", "echarts": "^5.2.2", "element-ui": "^2.15.7", "enquire.js": "^2.1.6", "font-awesome": "^4.7.0", "hi-taskcenter": "^1.0.9", "hi-ui": "^1.1.1006", "html2canvas": "^1.4.1", "jquery": "^3.6.0", "js-cookie": "^3.0.1", "js-md5": "^0.7.3", "js-pinyin": "^0.1.9", "jspdf": "^2.5.1", "lodash": "^4.17.11", "qrcodejs2": "0.0.2", "screenfull": "^6.0.0", "sortablejs": "^1.14.0", "v-clipboard": "^2.2.3", "vue": "^2.6.14", "vue-draggable-resizable": "^2.3.0", "vue-gemini-scrollbar": "^2.0.1", "vue-i18n": "^8.27.0", "vue-jstree": "^2.1.6", "vue-qr": "^3.2.4", "vue-router": "^3.0.1", "vuex": "^3.6.2", "xlsx": "^0.18.5", "zhc-birt-cmps": "^2.7.8", "zhc-birt-core": "^1.9.0", "zhc-flowchart": "^1.0.20" } }
Ignore Space
Show notes
View
project/hivuiBirt/App.vue
<script> // import HcPage from "./components/Birt/Page"; // import { BirtModelFactory } from "./templates/BirtModelFactory"; import cmps from 'zhc-birt-cmps' import { LoadUtil } from "./funclib/LoadUtil"; import { getToken } from "./utils/auth"; // import { Tool } from "./funclib/Tool"; import { projectName, requestUrl } from "@birt/config"; import 'echarts-liquidfill/src/liquidFill.js' export default { extends: cmps.BirtPage, data() { return { birtModel: {}, VUE_APP_BASE_API: requestUrl, pn: projectName || "birt", }; }, watch: { // $route() { // this.loadBirtModel(this.$route.path); // }, }, methods: { // 动态加载报表模型方法 birtModelMethod(routePath, birtModelMethod, scope) { return new Promise((resolve, reject) => { let me = this; let token = getToken(); // let token = '3d3fe30c-3d99-41e8-9aea-addd8528aa07' // let vId = this.getQueryVariable('viewItemId') let vId = window.scpRequestData && window.scpRequestData.__viewItemId LoadUtil.loadJsBirtModel({ loadModelUrl: this.$HI.birtModel, routePath: routePath, token: token, pn: this.pn, vId: vId }) .then(() => { try { let birtModel = cmps.BirtModelFactory.buildModel( getBirtModel(scope || me, cmps.Tool) ); birtModel.token = token; birtModel.birtModelMethod = birtModelMethod; resolve(birtModel); } catch (e) { console.error(e); } }) .catch(() => { reject(); }); }); }, loadBirtModel(routePath) { return new Promise((resolve, reject) => { let me = this; this.birtModelMethod(routePath, this.birtModelMethod) .then((birtModel) => { debugger; me.birtModel = birtModel; console.log("birtModel", birtModel); me.applyRouteParam(); me.setWorkBookParam(); resolve(); }) .catch(() => { reject(); }); }); }, // 获取地址栏参数 getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return false; }, }, mounted() { var path = window.location.pathname; // 编译后多e5 if (window.HIVUI_SETTING) { var serverName = window.HIVUI_SETTING.serverName; if (serverName && path.startsWith(serverName)) { path = path.substring(serverName.length); } } var __push = window && window.scpRequestData && window.scpRequestData.__push console.log('__push',__push) if(__push){ this.param['__push'] = JSON.parse(__push) console.log('param',this.param) } // var _push = window.scpRequestData // var path = '/platf/user-info/func/query.func' this.loadBirtModel(path).then(() => { // if (path == "/platf/permission/func/assign.func") this.getOrgData(-1); // else if (path == "/platf/permission/func/modify.func") // this.getOrgDataM(-1); }); }, }; </script>
<script> // import HcPage from "./components/Birt/Page"; // import { BirtModelFactory } from "./templates/BirtModelFactory"; import cmps from 'zhc-birt-cmps' import { LoadUtil } from "./funclib/LoadUtil"; import { getToken } from "./utils/auth"; // import { Tool } from "./funclib/Tool"; import { projectName, requestUrl } from "@birt/config"; export default { extends: cmps.BirtPage, data() { return { birtModel: {}, VUE_APP_BASE_API: requestUrl, pn: projectName || "birt", }; }, watch: { // $route() { // this.loadBirtModel(this.$route.path); // }, }, methods: { // 动态加载报表模型方法 birtModelMethod(routePath, birtModelMethod, scope) { return new Promise((resolve, reject) => { let me = this; let token = getToken(); // let token = '3d3fe30c-3d99-41e8-9aea-addd8528aa07' // let vId = this.getQueryVariable('viewItemId') let vId = window.scpRequestData && window.scpRequestData.__viewItemId LoadUtil.loadJsBirtModel({ loadModelUrl: this.$HI.birtModel, routePath: routePath, token: token, pn: this.pn, vId: vId }) .then(() => { try { let birtModel = cmps.BirtModelFactory.buildModel( getBirtModel(scope || me, cmps.Tool) ); birtModel.token = token; birtModel.birtModelMethod = birtModelMethod; resolve(birtModel); } catch (e) { console.error(e); } }) .catch(() => { reject(); }); }); }, loadBirtModel(routePath) { return new Promise((resolve, reject) => { let me = this; this.birtModelMethod(routePath, this.birtModelMethod) .then((birtModel) => { debugger; me.birtModel = birtModel; console.log("birtModel", birtModel); me.applyRouteParam(); me.setWorkBookParam(); resolve(); }) .catch(() => { reject(); }); }); }, // 获取地址栏参数 getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return false; }, }, mounted() { var path = window.location.pathname; // 编译后多e5 if (window.HIVUI_SETTING) { var serverName = window.HIVUI_SETTING.serverName; if (serverName && path.startsWith(serverName)) { path = path.substring(serverName.length); } } var __push = window && window.scpRequestData && window.scpRequestData.__push console.log('__push',__push) if(__push){ this.param['__push'] = JSON.parse(__push) console.log('param',this.param) } // var _push = window.scpRequestData // var path = '/platf/user-info/func/query.func' this.loadBirtModel(path).then(() => { // if (path == "/platf/permission/func/assign.func") this.getOrgData(-1); // else if (path == "/platf/permission/func/modify.func") // this.getOrgDataM(-1); }); }, }; </script>
Ignore Space
Show notes
View
project/hivuiBirt/index.js
import App from './App.vue' // import ElementUI from 'element-ui'; // import "hi-ui/lib/hi-ui.css"; // import 'font-awesome/css/font-awesome.css' Vue.use(ELEMENT, { size: 'mini' }) import Message from './components/vue-m-message' Vue.use(Message) // will mount `Vue.prototype.$message` import './assets/icon/iconfont.css'; import './styles/index.css'; import './assets/icon/iconfont.css'; import './styles/index.css' import "hi-taskcenter/hi-taskcenter.css" import hitaskcenter from 'hi-taskcenter'; Vue.use(hitaskcenter); import 'zhc-flowchart/lib/zhc-flowchart.css' import zhcflowchart from "zhc-flowchart"; Vue.use(zhcflowchart) import ZhcBirtCmps from 'zhc-birt-cmps' Vue.use(ZhcBirtCmps) // import window.HIVUI_SETTING from './window.HIVUI_SETTING' // import { $HCBIRT } from "@birt/funclib/HCBIRT" import Cookies from 'js-cookie' import { setToken, } from "./utils/auth.js"; // Vue.use(ElementUI) console.log('token', Cookies.get('EAP-Token')) setToken(Cookies.get('EAP-Token') || '') import axios from "./funclib/AxiosUtil"; import pinyin from 'js-pinyin' Vue.prototype.Pinyin = pinyin import md5 from 'js-md5' Vue.prototype.Md5 = md5 import { Loading } from 'element-ui'; Vue.prototype.Loading = Loading import * as echarts from "echarts" Vue.prototype.$echarts = echarts; // Vue.prototype.$HCBIRT = $HCBIRT; import i18n from './lang' Vue.prototype.$HI = { projectName: window.HIVUI_SETTING.projectName, serverUrl: window.HIVUI_SETTING.serverUrl, serverName: window.HIVUI_SETTING.serverName, request: axios, queryOperate: 'like', pageSize: 20, saveUrl: window.HIVUI_SETTING.saveUrl, queryUrl: window.HIVUI_SETTING.queryUrl, querysUrl: window.HIVUI_SETTING.serverUrl + "/data/querys", policyUrl: window.HIVUI_SETTING.policyUrl, enumsUrl: window.HIVUI_SETTING.serverUrl + "/platf/xtgn/enums/fgroupid/", upload: window.HIVUI_SETTING.upload, download: window.HIVUI_SETTING.download, review: window.HIVUI_SETTING.review, getFlowInfo: window.HIVUI_SETTING.getFlowInfo, getApprovalInfo: window.HIVUI_SETTING.getApprovalInfo, processFlow: window.HIVUI_SETTING.processFlow, queryTask: window.HIVUI_SETTING.queryTask, withdrawtask: window.HIVUI_SETTING.withdrawtask, taskDiagram: window.HIVUI_SETTING.taskDiagram, openOrdernumber: window.HIVUI_SETTING.openOrdernumber, birtModel: window.HIVUI_SETTING.serverUrl + "/birt/model1", getProcessInfo: window.HIVUI_SETTING.serverUrl + '/flow/getProcessInfo', exportUrl: window.HIVUI_SETTING.serverUrl + "/export/dataexcel" }; console.log(5555,window.HIVUI_SETTING.queryUrl) new Vue({ i18n, render: h => h(App), }).$mount('#app')
import App from './App.vue' // import ElementUI from 'element-ui'; // import "hi-ui/lib/hi-ui.css"; // import 'font-awesome/css/font-awesome.css' Vue.use(ELEMENT, { size: 'mini' }) import Message from './components/vue-m-message' Vue.use(Message) // will mount `Vue.prototype.$message` import './assets/icon/iconfont.css'; import './styles/index.css'; import './assets/icon/iconfont.css'; import './styles/index.css' import "hi-taskcenter/hi-taskcenter.css" import hitaskcenter from 'hi-taskcenter'; Vue.use(hitaskcenter); import 'zhc-flowchart/lib/zhc-flowchart.css' import zhcflowchart from "zhc-flowchart"; Vue.use(zhcflowchart) import ZhcBirtCmps from 'zhc-birt-cmps' Vue.use(ZhcBirtCmps) // import window.HIVUI_SETTING from './window.HIVUI_SETTING' // import { $HCBIRT } from "@birt/funclib/HCBIRT" import Cookies from 'js-cookie' import { setToken, } from "./utils/auth.js"; // Vue.use(ElementUI) console.log('token', Cookies.get('EAP-Token')) setToken(Cookies.get('EAP-Token') || '') import axios from "./funclib/AxiosUtil"; import pinyin from 'js-pinyin' Vue.prototype.Pinyin = pinyin import md5 from 'js-md5' Vue.prototype.Md5 = md5 import { Loading } from 'element-ui'; Vue.prototype.Loading = Loading // Vue.prototype.$HCBIRT = $HCBIRT; import i18n from './lang' Vue.prototype.$HI = { projectName: window.HIVUI_SETTING.projectName, serverUrl: window.HIVUI_SETTING.serverUrl, serverName: window.HIVUI_SETTING.serverName, request: axios, queryOperate: 'like', pageSize: 20, saveUrl: window.HIVUI_SETTING.saveUrl, queryUrl: window.HIVUI_SETTING.queryUrl, querysUrl: window.HIVUI_SETTING.serverUrl + "/data/querys", policyUrl: window.HIVUI_SETTING.policyUrl, enumsUrl: window.HIVUI_SETTING.serverUrl + "/platf/xtgn/enums/fgroupid/", upload: window.HIVUI_SETTING.upload, download: window.HIVUI_SETTING.download, review: window.HIVUI_SETTING.review, getFlowInfo: window.HIVUI_SETTING.getFlowInfo, getApprovalInfo: window.HIVUI_SETTING.getApprovalInfo, processFlow: window.HIVUI_SETTING.processFlow, queryTask: window.HIVUI_SETTING.queryTask, withdrawtask: window.HIVUI_SETTING.withdrawtask, taskDiagram: window.HIVUI_SETTING.taskDiagram, openOrdernumber: window.HIVUI_SETTING.openOrdernumber, birtModel: window.HIVUI_SETTING.serverUrl + "/birt/model1", getProcessInfo: window.HIVUI_SETTING.serverUrl + '/flow/getProcessInfo', exportUrl: window.HIVUI_SETTING.serverUrl + "/export/dataexcel" }; console.log(5555,window.HIVUI_SETTING.queryUrl) new Vue({ i18n, render: h => h(App), }).$mount('#app')
Show line notes below