Преглед изворни кода

Merge branch 'master' into 'master-copy'

Master

See merge request spfm/spfm-market-front!424
杨壁繁 пре 2 година
родитељ
комит
7d638cf55d

+ 5 - 1
.env.development

@@ -1,2 +1,6 @@
 VUE_APP_FILE_API = http://192.168.1.9:9114
-VUE_APP_GRID_API = http://192.168.1.19:9114
+VUE_APP_GRID_API = http://192.168.1.19:9114
+NODE_ENV = development
+
+VUE_APP_ENV = development
+outputDir = dist-dev

+ 6 - 1
.env.production

@@ -1,2 +1,7 @@
 VUE_APP_FILE_API =
-VUE_APP_GRID_API =
+VUE_APP_GRID_API =
+
+NODE_ENV = production
+
+VUE_APP_ENV = production
+outputDir = dist-production

+ 5 - 0
.env.test

@@ -0,0 +1,5 @@
+VUE_APP_FILE_API =
+VUE_APP_GRID_API =
+NODE_ENV = 'production'
+VUE_APP_ENV = test
+outputDir = dist-test

+ 5 - 0
.gitignore

@@ -1,7 +1,11 @@
 .DS_Store
 node_modules
 /dist
+<<<<<<< HEAD
+/dist-test
+=======
 dist.zip
+>>>>>>> b1d2e0323329f3f9e21c34540cf9e3eb31cf89a8
 
 # local env files
 .env.local
@@ -20,3 +24,4 @@ yarn-error.log*
 *.njsproj
 *.sln
 *.sw?
+*.zip

+ 0 - 0
config/config.js


+ 10 - 8
config/dev.env.js

@@ -1,18 +1,20 @@
 'use strict'
 const merge = require('webpack-merge')
 const prodEnv = require('./prod.env')
-
-module.exports = merge(prodEnv, {
+import getConfig from '/src/config/dev.js'
+let BASE_API = getConfig().BASE_API
+let BASE_URL = getConfig().BASE_URL
+export default  {
   NODE_ENV: '"development"',
   ENV_CONFIG: '"dev"',
-  ctx:'"http://127.0.0.1:8080"',
-  ctxForm: '"http://10.149.85.91:8000/api"',//dev
-  // ctxForm: '"http://43.138.50.94:8880/api"',//test
-  // ctxForm: '"http://192.168.2.92:8880/api"',//test
-  // ctxForm: '"http://10.230.26.15:8000"',//生产
+  ctx:"'"+ BASE_URL + "'",
+  // ctxForm: '"http://10.149.85.91:8000"',//dev
+  // ctxForm: '"http://43.138.50.94:8880"',//test
+  // ctxForm: '"http://192.168.2.44:8880"',//test
+  ctxForm: "'"+ BASE_API + "'",//生产
 
   excludeMeWhenSelectNextHandler:false,
   excludeFormerHanlder:false,
   envTitle:'"本地开发环境"'
-})
+}
   

+ 7 - 2
package.json

@@ -3,8 +3,13 @@
   "version": "0.1.0",
   "private": true,
   "scripts": {
-    "serve": "vue-cli-service serve",
-    "build": "vue-cli-service build",
+    "abc":"vue-cli-service build",
+    "serve": "vue-cli-service serve --mode development", 
+    "serve:test": "vue-cli-service serve --mode test", 
+    "build": "vue-cli-service build  --mode development", 
+    "build:devs": "vue-cli-service build  --mode devs", 
+    "build:test": "vue-cli-service build  --mode test",
+    "build:next": "vue-cli-service build  --mode production", 
     "lint": "vue-cli-service lint",
     "analyz": "vue-cli-service build"
   },

+ 4 - 2
public/index.html

@@ -30,14 +30,16 @@
   </noscript>
   <div id="app"></div>
   <!-- built files will be auto injected -->
-  <script type="text/javascript">
+  <!-- <script type="text/javascript">
     // window.staticHost = 'http://10.230.26.15:8000/mkt'; // 正式
     window.staticHost = 'http://10.149.85.91:8000/spfm'; // 测试
+    // window.staticHost = 'http://192.168.0.103:9600/';
     // window.staticHost = 'http://43.138.50.94:9600/';
     // window.staticHost = 'http://192.168.2.43:9600/';
 
     // document.title = "hello";
-  </script>
+  </script> -->
+
 </body>
 
 </html>

+ 1 - 1
public/static/js/api.config.js

@@ -1,6 +1,6 @@
 // api config
 var apiConfig = {
-  ctx: window.top.staticHost ? window.top.staticHost : "http://114.215.71.182:29600/spfm/",
+  ctx: window.top.staticHost ? window.top.staticHost : "http://114.215.71.182:29600/spfm",
   // http://114.215.71.182:29600/spfm/
   // ctx: "http://localhost:9601",//接口地址http://192.168.1.76:8090/ api-gateway
   // ctx: "http://192.168.2.192:9600/",//接口地址http://192.168.1.76:8090/ api-gateway

+ 3 - 0
src/assets/js/http.js

@@ -9,11 +9,14 @@ axios.defaults.headers.post['Content-Type'] = 'application/json';//'multipart/fo
 // http response 拦截器
 axios.interceptors.response.use(
   response => {
+    console.log('奇奇怪怪的网络请求');
     //vue.$store.commit('endLoading');
     if(response.config.url.indexOf('8880')!=-1 || response.config.url.indexOf('8099')!=-1){
+
       return response.data;
     }else{
       return response;
+      
     }
   },
   error => {

+ 1 - 0
src/components/p-header.vue

@@ -190,6 +190,7 @@ export default {
       }, 500);
     },
     handleLogout() {
+      console.log(123);
       this.$confirm("正在退出登录,是否继续", "提示", {
         type: "warning",
       })

+ 42 - 0
src/config/dev.js

@@ -0,0 +1,42 @@
+'use strict'
+let devs = {
+    TITLE:'本地环境',
+    BASE_URL:"http://43.138.50.94:9600/", //本地环境
+    BASE_API:"http://43.138.50.94:8880/api",//工作流本地环境
+    EXCEL_URL:"http://43.138.50.94:7777" //本地excel路径
+}
+let dev = {
+    TITLE:'本地环境',
+    BASE_URL:"http://127.0.0.1:8080", //本地环境
+    BASE_API:"http://43.138.50.94:8880/api",//工作流本地环境
+    EXCEL_URL:"http://43.138.50.94:7777" //本地excel路径
+}
+let test = {
+    TITLE:'测试环境',
+    BASE_URL:"http://10.149.85.91:8000/spfm", //测试环境
+    BASE_API:"http://10.149.85.91:8000/api",//工作流测试环境
+    EXCEL_URL:"http://10.149.85.91:7777" //测试excel路径
+}
+let prod = {
+    TITLE:'线上环境',
+    BASE_URL:"http://10.230.26.15:8000/mkt", //线上环境
+    BASE_API:"http://10.230.26.15:8000/api",//工作流线上环境
+    EXCEL_URL:"http://10.230.26.15:7777" //线上excel路径
+}
+export const getConfig  = () =>{
+    switch(process.env.VUE_APP_ENV){
+        case "development":
+            return dev;
+        case 'test':
+            return test;
+        case 'production':
+            return prod
+        case 'devs':
+            return devs; 
+    }
+}
+export default getConfig;
+
+// 根据环境引入不同配置 process.env.ENV_CONFIG  ex:dev.conf.js
+
+// module.exports = config

+ 53 - 27
src/http/index.js

@@ -1,6 +1,19 @@
 import Vue from 'vue';
 import axios from 'axios';
 import VueAxios from 'vue-axios';
+import getConfig from '../config/dev.js'
+let list = getConfig()
+const status = (res) => {
+    let regexp = /\d+\/api\//
+    let r = regexp.test(res)
+
+    return r;
+}
+// const Rstatus = (res) => {
+//     let regexps = /8000/
+//     let qr = regexps.test(res)
+//     return qr;
+// }
 // axios.defaults.headers.post['Content-Type'] = 'application/json';
 axios.defaults.transformRequest = [function (data) {
     if (data instanceof Object && !(data instanceof FormData)) {
@@ -8,36 +21,49 @@ axios.defaults.transformRequest = [function (data) {
     }
     return data;
 }],
-    // 添加请求拦截器
-    axios.interceptors.request.use(function (config) {
-        if (config.url.startsWith("http")) {
-            return config;
-        }
-        let localhost = ''
-        if (process.env.NODE_ENV == "production") {
-            localhost = window.staticHost ? window.staticHost : "/spfm/"
-        }
-        config.url = localhost + config.url
-        let url = localhost + config.url
-        if (url.indexOf('/sysmgr/sys/login/auth/captcha') == -1 && url.indexOf('/sysmgr/sys/login/auth/token') == -1) {
-            let token = window.sessionStorage.agileauthtoken;
-            if (token != undefined && token != 'undefined') {
-                token = JSON.parse(token);
+
+    axios.defaults.baseURL = list.BASE_URL
+// 添加请求拦截器
+axios.interceptors.request.use(function (config) {
+
+    var n = status(config.url)
+    // var s = Rstatus(config.url)
+
+    // console.log('[ axios.config ] >', config)
+    // if (config.url.startsWith("http")) {
+    //     return config;
+    // }
+    // let localhost = ''
+    // if (process.env.NODE_ENV == "production") {
+    //     localhost = window.staticHost ? window.staticHost : "/spfm/"
+    // }
+    // console.log('[ axios.localhost ] >', localhost)
+    // config.url = localhost + config.url
+    // let url = localhost + config.url
+    // console.log('[ axios.url ] >', url)
+
+    if (list.BASE_URL.indexOf('/sysmgr/sys/login/auth/captcha') == -1 && list.BASE_URL.indexOf('/sysmgr/sys/login/auth/token') == -1) {
+        let token = window.sessionStorage.agileauthtoken;
+        if (token != undefined && token != 'undefined') {
+            token = JSON.parse(token);
+            if (n === false) {
                 config.headers['agileauthtoken'] = token
-            } else {
-                global.$vm.$notify.error({
-                    title: '提示',
-                    message: '登录超时'
-                })
-                global.$vm.$router.push('/login')
             }
+
+        } else {
+            global.$vm.$notify.error({
+                title: '提示',
+                message: '登录超时'
+            })
+            global.$vm.$router.push('/login')
         }
-        // 在发送请求之前做些什么
-        return config;
-    }, function (error) {
-        // 对请求错误做些什么
-        return Promise.reject(error);
-    });
+    }
+    // 在发送请求之前做些什么
+    return config;
+}, function (error) {
+    // 对请求错误做些什么
+    return Promise.reject(error);
+});
 
 
 // // 添加响应拦截器

+ 1 - 0
src/pages/main/comWin/prosess.vue

@@ -183,6 +183,7 @@ export default {
       };
       this.common.httpPost(obj, success);
       function success(data) {
+        console.log(data);
         self.list = data.data.rows;
         self.total = data.data.total;
       }

+ 1 - 0
src/pages/main/leader/demand/demandHome.vue

@@ -139,6 +139,7 @@
   </div>
 </template>
 <script>
+
 import Workflow from "../../../../components/workflow";
 import WorkflowEntrance from "../../../../components/workflowEntrance";
 import FormTable from "../components/formTable.vue";

+ 2 - 0
src/pages/main/leader/leaderHome.vue

@@ -53,6 +53,7 @@
   </div>
 </template>
 <script>
+import {getConfig} from '../../../../config/config.js'
 import ProcessingInstruction from "./leaderHprocess.vue";
 import hometask from "./leaderhomeTask.vue";
 import numberhits from "./numberHits.vue";
@@ -208,6 +209,7 @@ export default {
     },
   },
   mounted() {
+    this.getConfig()
     this.getpeo();
     this.getNotice();
     this.getTags();

+ 4 - 0
src/pages/main/leader/leaderhomeTask.vue

@@ -278,6 +278,7 @@
   </div>
 </template>
 <script>
+import { getConfig } from '../../../config/dev.js'
 export default {
   components: {},
   // props:["tableDatayj","niticList"],
@@ -658,6 +659,9 @@ export default {
     },
   },
   mounted() {
+    let list = getConfig()
+    console.log(list);
+    
     this.daiban({}, 1);
     this.getListyj({}, 1);
     this.getOPlist({}, 1);

+ 3 - 2
src/pages/main/workflowdef/index.vue

@@ -109,8 +109,9 @@ export default {
             }
             this.common.httpPost(obj, success)
             function success(data) {
-                self.list = data.data.rows
-                self.total = data.data.total
+                console.log(data);
+                self.list = data.rows
+                self.total = data.total
             }
         },
         doImport() {

+ 1 - 0
vue.config.js

@@ -3,6 +3,7 @@ const webpack = require("webpack");
 const BundleAnalyzerPlugin =
     require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
 module.exports = {
+    outputDir: process.env.outputDir,
     publicPath: process.env.NODE_ENV === "production" ? "" : "/",
     productionSourceMap: false,
     lintOnSave: false,