zhaomiao 3 년 전
부모
커밋
bbab16d89e

+ 1 - 1
src/App.vue

@@ -1,7 +1,7 @@
 <template>
   <div
     id="app"
-    :class="'mainTheme-' + this.themeName"
+    
     style="width: 100%; height: 100%"
   >
   <router-view></router-view>

+ 15 - 8
src/api/axios.js

@@ -12,6 +12,7 @@ import { Message } from 'element-ui';
     isMust: true, // 请求是否携带 token ,默认为 true ,可缺省
     showLoading: false, // 请求是否显示加载中遮罩层,默认 false ,可缺省
     method: "GET", // 请求方式,默认为 GET ,可缺省
+    baseURL: "http://192.168.10.23:8082/", // 请求服务器地址 + 端口,可缺省
     subUrl: "api/repassword", // 请求接口地址,必传项
     timeout: 3000, // 请求超时时间,默认 3s ,可缺省
     data: { name: "admin", pasword: "123456" }, // 请求所携带参数,默认为空,可缺省
@@ -38,15 +39,16 @@ export function requestData (options) {
 
     // 请求是否携带 token
     const isMust = (options.isMust == true || options.isMust == false) ? options.isMust : true;
-    if (isMust) headers.authToken = localStorage.getItem('authToken');
+    headers.authToken = localStorage.getItem('authToken');
 
     // 创建请求实例
     const XHRReq = axios.create({
       headers,
-      baseURL: process.env.VUE_APP_API_URL || '/api/',
+      baseURL: options.baseURL || process.env.VUE_APP_API_URL || '/api/',
       timeout: options.timeout || 3000,
     });
 
+
     // 请求拦截器
     XHRReq.interceptors.request.use((config) => {
       return config;
@@ -77,7 +79,8 @@ export function requestData (options) {
           // window.__STATICVUE__.$router.replace('/login');
         }, 1000);
       } else if (response.code === 200) { // 请求成功 code
-        options.success && options.success(resolve(response));
+        options.success && options.success(response.data);
+        resolve(response);
       } else { // 其他code
         Message.error((response.data && response.data.msg) || ("请求出错[" + response.data.code + "]"));
       }
@@ -85,14 +88,15 @@ export function requestData (options) {
       if (options.showLoading) {
         store.state.loading = false;
       }
-      options.fail && options.fail(reject(error));
+      options.fail && options.fail(error);
+      reject(error);
     });
   });
 }
 
 // 创建axios实例
 const httpService = axios.create({
-  withCredentials: false, // 允许携带cookie
+  withCredentials: true, // 允许携带cookie
   baseURL: process.env.VUE_APP_API_URL || '/api/',
   timeout: 23000, // 请求超时时间 - 3s
   // transformRequest: [
@@ -110,6 +114,7 @@ const httpService = axios.create({
   //修改请求头信息
   headers: {
     'Content-Type': 'application/x-www-form-urlencoded',
+    'authToken':  localStorage.getItem('authToken')
     // 'Access-Control-Allow-Origin':'*'
     // 'Content-Type': 'multipart/form-data'
     // 'Content-Type': 'application/json;charset=UTF-8'
@@ -117,11 +122,12 @@ const httpService = axios.create({
 });
 
 const httpService_L = axios.create({
-  withCredentials: false, // 允许携带cookie
+  withCredentials: true, // 允许携带cookie
   baseURL: process.env.VUE_APP_API_URL || '/api/',
   timeout: 210000, // 请求超时时间 - 3s
   headers: {
     'Content-Type': 'application/x-www-form-urlencoded',
+    'authToken':  localStorage.getItem('authToken'),
   },
 });
 // httpService.defaults.withCredentials = true; // 表示跨域请求时是否需要使用凭证
@@ -383,12 +389,13 @@ export function postL (url, params = {}) {
 
   return new Promise((resolve, reject) => {
     axios.create({
-      withCredentials: false, // 允许携带cookie
+      withCredentials: true, // 允许携带cookie
       baseURL: process.env.VUE_APP_API_URL || '/api/',
       timeout: 210000, // 请求超时时间 - 60s
       //修改请求头信息
       headers: {
-        'Content-Type': 'application/x-www-form-urlencoded'
+        'Content-Type': 'application/x-www-form-urlencoded',
+        'authToken':  localStorage.getItem('authToken'),
       },
     })({
       url: url,

+ 10 - 0
src/assets/js/benchmarkingSys/yardBenchmark.js

@@ -267,6 +267,16 @@ export default {
 
       return this.BASE.getBzDate(date,0);
     },
+    // qqq(){
+    //   var digital = new URLSearchParams();
+    //   digital.append('authToken',localStorage.getItem('authToken'));
+    //   debugger
+    //   this.API
+    //     .post("admin/usermenu",digital).then((res) => {
+    //       debugger
+    //       console.log("1111111111111");
+    //     }).catch(console.log("3333333333333333333"));
+    // }
   },
   mounted() {
     this.query_fc();

+ 31 - 23
src/assets/js/login.js

@@ -1,39 +1,47 @@
-import { mapMutations} from 'vuex'
+import { mapMutations } from 'vuex'
 export default {
   data() {
     return {
-      loginForm:{
-        username:'',
-        password:'',
+      loginForm: {
+        username: '',
+        password: '',
       }
-      
+
     }
   },
   components: {
   },
   created() {
   },
-  
+
   methods: {
-    
+
     ...mapMutations("user", ["SET_TOKEN"]),
-    login(){
+    login() {
       let _this = this;
       var digital = new URLSearchParams();
-      digital.append("username",this.loginForm.username),
-      digital.append("password",this.loginForm.password),
-      this.API.post("/admin/loginvue", digital).then((res) => {
-       const {data,code} = res;
-       if(code == 200){
-				this.SET_TOKEN({"token":data,"username":this.loginForm.username});
-				this.$message({
-          message: '登陆成功',
-          type: 'success'
+      digital.append("username", this.loginForm.username),
+        digital.append("password", this.loginForm.password),
+        this.API.post("/admin/loginvue", digital).then((res) => {
+          const { data, code } = res;
+          if (code == 200) {
+            this.SET_TOKEN({ "token": data, "username": this.loginForm.username });
+            debugger
+            var digital1 = new URLSearchParams();
+            digital1.append('authToken', localStorage.getItem('authToken'));
+            this.API.post("admin/usermenu", digital1).then((res) => {
+                console.log(res + "1111111111111")
+                this.$router.push('/'); // 跳转到首页
+                this.$message({
+                  message: '登陆成功',
+                  type: 'success'
+                });
+              }).catch(console.log("3333333333333333333"));
+          }
+          else {
+            this.$message.error('登录失败');// ui弹窗提示
+          }
         });
-         this.$router.push('/'); // 跳转到首页
-			} else {
-        this.$message.error('登录失败');// ui弹窗提示
-			}
-      });
     }
-  }}
+  }
+}

+ 0 - 9
src/components/common/menu.vue

@@ -37,15 +37,6 @@ export default {
   methods: {
     //初始化
     getMenu () {
-      console.log(898989)
-      this.API.requestData({
-        showLoading: true, // 请求是否显示加载中遮罩层,默认 false ,可缺省
-        subUrl: "admin/usermenu", // 请求接口地址,必传项
-        success (res) {
-          // 请求成功的回调
-          console.log('res', res);
-        }
-      });
     },
 
     // 菜单点击跳转

+ 1 - 1
src/layout/vueapp.vue

@@ -1,6 +1,6 @@
 <template>
   <div style="width:100%;height:100%"
-  
+    :class="'mainTheme-' + this.themeName"
     v-loading="$store.state.loading"
     element-loading-text="拼命加载中"
     element-loading-spinner="el-icon-loading"

+ 1 - 1
src/router/index.js

@@ -69,7 +69,7 @@ const routes = [
 
 const router = new VueRouter({
   mode: 'history',
-  //base: '/sis/', // 部署单页面 404 history  带井号解决(去掉history 放web-inf)
+  base: '/sis/', // 部署单页面 404 history  带井号解决(去掉history 放web-inf)
   routes,
 })
 

+ 4 - 0
src/store/index.js

@@ -9,11 +9,15 @@ const state = {
   loading: false,   //全局 - 加载中....
   themeName: "light",
   login:false,
+  menu:[],
   z:"width:1%",
   y:"width:99%"
 };
 //改变状态的方法
 const mutations = {
+  setMenu(state,tage){
+    state.menu = tage;
+  },
   openSubmitDDTag(state, tag) {
     state.submitDDTag = tag;
   },

+ 7 - 3
src/views/lineChart/index.vue

@@ -161,6 +161,7 @@ export default {
     getEquipmentStructure () {
       let that = this;
       that.API.requestData({
+        baseURL: "http://10.155.32.4:8031/",
         subUrl: "paramComparison/equipmentStructure",
         success (res) {
           // 请求成功的回调
@@ -196,6 +197,7 @@ export default {
     getEquipmentParams () {
       let that = this;
       that.API.requestData({
+        baseURL: "http://10.155.32.4:8031/",
         subUrl: "paramComparison/equipmentParams",
         success (res) {
           that.gjcsOptions = res.data;
@@ -215,8 +217,11 @@ export default {
     // 渲染图表
     renderCharts () {
       let that = this;
-      that.$nextTick(() => {
 
+      document.getElementById("lineChart").removeAttribute("_echarts_instance_");
+      echarts.init(document.getElementById('lineChart'));
+
+      that.$nextTick(() => {
         let begin = that.form.dateArea.length ? that.form.dateArea[0] : '';
         let end = that.form.dateArea.length ? that.form.dateArea[1] : '';
         let interval = that.form.interval;
@@ -253,12 +258,11 @@ export default {
 
         if (begin && end && paramtype && wts.length && params.length) {
           that.API.requestData({
+            baseURL: "http://10.155.32.4:8031/",
             subUrl: "paramComparison/generatingCurve",
             timeout: 30000,
             data,
             success (res) {
-              console.log('res', res);
-
               if (res.data.length) {
 
                 let xAxisData = []; // x轴标题

+ 72 - 39
src/views/search/index.vue

@@ -46,7 +46,7 @@
           :total="currentPageTotal">
         </el-pagination> -->
     </div>
-    <el-dialog title="查看详情" top="50px" :visible.sync="showDialog" width="95%" @closed="(res) =>{ this.form.dateArea=[this.fmtDate(new Date(new Date().setTime(new Date().getTime() - 3600 * 1000 * 24))), this.fmtDate(new Date()) ];this.detailsTableData=[]; }">
+    <el-dialog title="查看详情" top="50px" :modal-append-to-body="false" :visible.sync="showDialog" width="95%" @closed="(res) =>{ this.form.dateArea=[this.fmtDate(new Date(new Date().setTime(new Date().getTime() - 3600 * 1000 * 24))), this.fmtDate(new Date()) ];this.detailsTableData=[]; }">
       <div class="searchBox">
         <el-form ref="form" :model="form" inline label-width="80px">
           <el-form-item label="点名:">
@@ -180,21 +180,29 @@ export default {
 
   methods: {
     // 获取表格数据
-    getTableData (skipLoading) {
-      if (!skipLoading) {
-        this.$store.commit("loadingStore", true);
-      }
-      this.API.get("datacenter/realtimeData?tableid=" + this.tableid + "&pointId=" + this.form.pointId + "&pointName=" + this.form.pointName + "&pageNum=" + this.currentPage + "&pageSize=" + this.pagesizereal).then((res) => {
-        res.data.forEach(ele => {
-          ele.timeDate = this.fmtDate(new Date(ele.time));
-          if (ele.value > 0) {
-            ele.value = parseFloat(ele.value).toFixed(4);
-          }
-        });
-        this.tableData = res.data || [];
-        this.currentPageTotal = res.count || [];
-        if (!skipLoading) {
-          this.$store.commit("loadingStore", false);
+    getTableData (showLoading) {
+      let that = this;
+      that.API.requestData({
+        showLoading, // 请求是否显示加载中遮罩层,默认 false ,可缺省
+        baseURL: "http://10.155.32.4:8031/",
+        subUrl: "datacenter/realtimeData", // 请求接口地址,必传项
+        timeout: 10000, // 请求超时时间,默认 3s ,可缺省
+        data: {
+          tableid: that.tableid || "JSFW",
+          pointId: that.form.pointId,
+          pointName: that.form.pointName,
+          pageNum: that.currentPage,
+          pageSize: that.pagesizereal
+        },
+        success (res) {
+          res.data.forEach(ele => {
+            ele.timeDate = that.fmtDate(new Date(ele.time));
+            if (ele.value > 0) {
+              ele.value = parseFloat(ele.value).toFixed(4);
+            }
+          });
+          that.tableData = res.data || [];
+          that.currentPageTotal = res.count || [];
         }
       });
     },
@@ -212,26 +220,38 @@ export default {
 
     // 获取详情
     getDetails () {
-      if (!this.form.dateArea || !this.form.dateArea.length) {
+      let that = this;
+      if (!that.form.dateArea || !that.form.dateArea.length) {
         Message.error("请先选择要查询的日期区间后再试");
       } else {
-        this.$store.commit("loadingStore", true);
-        let begin = (this.form.dateArea.length ? this.form.dateArea[0] : '');
-        let end = (this.form.dateArea.length ? this.form.dateArea[1] : '');
+        let begin = (that.form.dateArea.length ? that.form.dateArea[0] : '');
+        let end = (that.form.dateArea.length ? that.form.dateArea[1] : '');
 
-        this.API.get("datacenter/historyData?pointId=" + this.pointId + "&begin=" + begin + "&end=" + end + (this.form.interval ? ("&interval=" + this.form.interval) : '')).then((res) => {
-          if (res.data.length) {
-            res.data.forEach(ele => {
-              ele.timeDate = this.fmtDate(new Date(ele.time));
-              if (ele.value > 0) {
-                ele.value = parseFloat(ele.value).toFixed(4);
-              }
-            });
-            this.detailsTableData = res.data || [];
-          } else {
-            Message.warning("所选日期区间之内暂无数据,请重试");
+        let data = {};
+        data.pointId = that.pointId;
+        data.begin = begin;
+        data.end = end;
+        if (that.form.interval) data.interval = that.form.interval;
+
+        that.API.requestData({
+          showLoading: true, // 请求是否显示加载中遮罩层,默认 false ,可缺省
+          baseURL: "http://10.155.32.4:8031/",
+          subUrl: "datacenter/historyData", // 请求接口地址,必传项
+          timeout: 10000, // 请求超时时间,默认 3s ,可缺省
+          data,
+          success (res) {
+            if (res.data.length) {
+              res.data.forEach(ele => {
+                ele.timeDate = that.fmtDate(new Date(ele.time));
+                if (ele.value > 0) {
+                  ele.value = parseFloat(ele.value).toFixed(4);
+                }
+              });
+              that.detailsTableData = res.data || [];
+            } else {
+              Message.warning("所选日期区间之内暂无数据,请重试");
+            }
           }
-          this.$store.commit("loadingStore", false);
         });
       }
     },
@@ -255,13 +275,26 @@ export default {
         let tableid = this.tableid;
         let pointId = this.form.pointId || '';
         let pointName = this.form.pointName || '';
-        this.API.get("datacenter/realtimeExport?tableid=" + tableid + "&pointId=" + pointId + "&pointName=" + pointName).then(res => {
-          const { export_json_to_excel } = require('@tools/excel/Export2Excel.js'); // 注意这个Export2Excel路径      
-          const tHeader = ['点名', '描述']; // 上面设置Excel的表格第一行的标题       
-          const filterVal = ['id', 'name']; // 上面的index、nickName、name是tableData里对象的属性key值   
-          const list = res.data; //把要导出的数据tableData存到list 
-          const data = this.formatJson(filterVal, list);
-          export_json_to_excel(tHeader, data, '导出的Excel'); // 最后一个是表名字
+
+        let that = this;
+        that.API.requestData({
+          showLoading, // 请求是否显示加载中遮罩层,默认 false ,可缺省
+          baseURL: "http://10.155.32.4:8031/",
+          subUrl: "datacenter/realtimeExport", // 请求接口地址,必传项
+          timeout: 10000, // 请求超时时间,默认 3s ,可缺省
+          data: {
+            tableid,
+            pointId,
+            pointName,
+          },
+          success (res) {
+            const { export_json_to_excel } = require('@tools/excel/Export2Excel.js'); // 注意这个Export2Excel路径      
+            const tHeader = ['点名', '描述']; // 上面设置Excel的表格第一行的标题       
+            const filterVal = ['id', 'name']; // 上面的index、nickName、name是tableData里对象的属性key值   
+            const list = res.data; //把要导出的数据tableData存到list 
+            const data = that.formatJson(filterVal, list);
+            export_json_to_excel(tHeader, data, '导出的Excel'); // 最后一个是表名字
+          }
         });
       } else {
         const { export_json_to_excel } = require('@tools/excel/Export2Excel.js'); // 注意这个Export2Excel路径