Browse Source

疯转post请求;
增加报表功能项数据导入;
去除默认登录人白玉杰

chenminghua 2 years ago
parent
commit
3b45064bf2
4 changed files with 210 additions and 24 deletions
  1. 4 4
      public/static/config/modeConfig.js
  2. 63 1
      src/api/axios.js
  3. 3 2
      src/views/layout/Header.vue
  4. 140 17
      src/views/report/misimport.vue

+ 4 - 4
public/static/config/modeConfig.js

@@ -16,17 +16,17 @@ const tilesMaxLevel = 18;
 const adapterUrl = "http://10.155.32.4:8011/";
 
 // 切换模块时是否提示当前模块名称(用于对内介绍项目时便捷显示模块名称)
-const showModuleName = 1;
+const showModuleName = 0;
 
 if (localTest) {
     // baseURL = "http://192.168.10.13:8082/" // 联机调试 - 石林
     // baseURL = "http://10.155.32.33:9001/" // 联机调试 - 谢生杰
-    baseURL = "http://192.168.10.6:8082/" // 联机调试 - 王昌盛
+    baseURL = "http://192.168.10.8:8082/" // 联机调试 - 王昌盛
 
     tilesUrl = "http://localhost:8080/static/cesium/Assets/Textures/NaturalEarthII";
 } else {
-    baseURL = "http://10.155.32.4:8082/" // 正式环境
-    // baseURL = "http://192.168.1.103:8082/" // 正式环境
+    // baseURL = "http://10.155.32.4:8082/" // 正式环境
+    baseURL = "http://192.168.10.8:8082/" // 正式环境
 
     tilesUrl = "http://10.155.32.4:8070/zhfx/new_tiles";
 }

+ 63 - 1
src/api/axios.js

@@ -110,6 +110,68 @@ export function requestData(options) {
   });
 }
 
+
+/**
+ * 原生 axios 请求方法
+ * @param {Object} options 请求配置项,调用方法:
+  this.API.get({
+    showLoading: false, // 请求是否显示加载中遮罩层,默认 false ,可缺省
+    baseURL: "http://192.168.10.23:8082/", // 请求服务器地址 + 端口,可缺省
+    subUrl: "api/repassword", // 请求接口地址,必传项
+    success (res) {
+      // 请求成功的回调
+    },
+  });
+ */
+
+export function requestPost(options) {
+  return new Promise((resolve, reject) => {
+    if (options.showLoading) {
+      BASE.showLoading();
+    }
+    axios({
+      method: options.method || "POST",
+      url: (options.baseURL || window.__MODE__.baseURL) + options.subUrl, 
+      timeout: options.timeout || 30000, // 请求超时时间 - 3s,
+      data: options.data,
+      header: {
+        "Content-Type": "application/json",
+        'Access-Control-Allow-Origin': '*',
+        'Access-Control-Allow-Credentials': 'true'
+      },
+    }).then((response) => {
+      if (options.showLoading) {
+        BASE.closeLoading();
+      }
+      if (response.data.code === 2002) { // 用户类请求错误code (账号密码错误、用户锁定、token过期等)
+  
+        localStorage.removeItem('authToken');
+        BASE.showMsg({
+          msg: (response.data && response.data.msg) || ("请求出错[" + response.data.code + "]")
+        });window.__STATICVUE__.$router.replace('/login');
+  
+      } else if (response.data.code === 200 || response.data.length >= 0 || response.data.records) { // 请求成功 code
+        options.success && options.success(response.data);
+        resolve(response);
+  
+      } else { // 其他code
+        BASE.closeLoading();
+        BASE.showMsg({
+          msg: (response.data && response.data.msg) || ("请求出错[" + response.data.code + "]")
+        });
+      }
+    }).catch(error => {
+      if (options.showLoading) {
+        BASE.closeLoading();
+      }
+      options.fail && options.fail(error);
+      reject(error);
+    });
+  })
+}
+  
+
 export default {
-  requestData
+  requestData,
+  requestPost
 }

+ 3 - 2
src/views/layout/Header.vue

@@ -30,7 +30,7 @@
           src="./static/img/appdownload.png"
           fit="fill"
         />
-        <span class="codeTip">宁夏新能源智能监盘APP下载</span>
+        <span class="codeTip">宁夏新能源智能监盘APP下载(Android)</span>
       </el-popover>
     </div>
     <!-- <ul class="header-menu-dropdown" :class="{ dropdown: dropdown }">
@@ -43,7 +43,8 @@
     </ul> -->
     <ul class="header-menu-user">
       <li class="header-menu-user-title">
-        <span class="el-dropdown-link"> <i class="fa fa-user"></i>白玉杰 </span>
+        <!-- <span class="el-dropdown-link"> <i class="fa fa-user"></i>白玉杰 </span> -->
+        <span class="el-dropdown-link"> <i class="fa fa-user"></i> </span>
         <el-dropdown
           size="small"
           trigger="hover"

+ 140 - 17
src/views/report/misimport.vue

@@ -16,13 +16,15 @@
         <div class="query-actions">
           <el-upload class="upload-demo" ref="upload" action="http://10.155.32.4:8082/misreport/import/data"
             :on-preview="handlePreview" :on-success="onSuccess" :on-remove="handleRemove" :before-remove="beforeRemove"
-            :on-exceed="handleExceed" :auto-upload="true" :limit="1" :before-upload="beforeAvatarUpload" @on-error="onError"
-            accept=".xls,.xlsx" :file-list="fileList" :show-file-list="false">
+            :on-exceed="handleExceed" :auto-upload="true" :limit="1" :before-upload="beforeAvatarUpload"
+            @on-error="onError" accept=".xls,.xlsx" :file-list="fileList" :show-file-list="false">
             <button class="btn green" @click="importExecl">数据导入</button>
           </el-upload>
         </div>
+        <div class="query-actions">
+          <button class="btn green" @click="openDialog">功率故障次数导入</button>
+        </div>
       </div>
-
     </div>
     <div>
       <el-table height="80vh" ref="multipleTable" empty-text="暂无数据" :data="tableList" :header-cell-style="{
@@ -73,7 +75,7 @@
         <el-table-column label="综合厂用电量" align="center">
           <el-table-column prop="zhcydl1" label="本期" width="120" align="center">
           </el-table-column>
-          <el-table-column prop="zhcydl2" label="同期" width="120" align="center">
+          <el-table-column prop="zhcydl1" label="同期" width="120" align="center">
           </el-table-column>
         </el-table-column>
 
@@ -86,6 +88,50 @@
       </el-table>
     </div>
   </div>
+
+  <el-dialog title="新增数据" v-model="isvisiable" width="600px" top="20vh" custom-class="modal" :close-on-click-modal="false"
+    :before-close="onClickDialogClose">
+    <div class="query mg-b-8">
+      <div class="query-items">
+        <div class="query-item">
+          <div class="lable">日期:</div>
+          <el-date-picker v-model="glycDate" @change="dateChange(glycDate)" type="date" value-format="YYYY-MM-DD"
+            placeholder="选择日期" popper-class="date-select">
+          </el-date-picker>
+        </div>
+      </div> 
+    </div>   
+
+    <div style="margin-top:80px">
+      <div class="query mg-b-8">
+        <div class="query-items" style="flex-direction: column;">
+          <div class="query-item">
+            <div class="lable" style="width: 180px">短期功率预测准确率:</div>
+            <div class="search-input">
+                <el-input
+                  placeholder="请输入"
+                  v-model="dqglyx"
+                  clearable
+                ></el-input>
+            </div>
+			    </div>
+          <div class="query-item" style="margin-top: 30px">
+            <div class="lable" style="width: 180px">百台风机故障次数:</div>
+            <div class="search-input">
+                <el-input
+                  placeholder="请输入"
+                  v-model="gzcs"
+                  clearable
+                ></el-input>
+            </div>
+			    </div>
+        </div>
+      </div>  
+      <div class="submit">
+        <button class="btn green" @click="submit">提交</button>
+      </div>
+    </div>
+  </el-dialog>
 </template>
 
 <script>
@@ -96,6 +142,12 @@ export default {
       fileList: [],
       timeValue: [],
       tableList: [],
+      isvisiable: false,
+      exportDate:'',
+      glycDate: '',
+      misdata: {},
+      dqglyx: '', //短期功率预测准确率
+      gzcs: '',  //故障次数
     };
   },
   created() {
@@ -107,6 +159,55 @@ export default {
     this.getTableData()
   },
   methods: {
+    openDialog() {
+      this.isvisiable = true
+      this.glycDate = new Date().formatDate("yyyy-MM-dd")
+      this.dateChange();
+    },
+
+    dateChange(){
+      let that = this;
+      that.API.requestData({
+        method: "GET",
+        subUrl: "misreport/glyc/data",
+        timeout: 60000,
+        data: {
+          time: that.glycDate,
+        },
+        success(res) {
+          if (res) {
+            that.dqglyx = res.data.dqglyczql
+            that.gzcs = res.data.gzcs
+            that.misdata = res.data
+          }
+        }
+      })
+    },
+    submit(){
+      let that = this;
+      that.misdata.dqglyczql = that.dqglyx;
+      that.misdata.gzcs = that.gzcs;
+      that.misdata.importdate = that.glycDate;
+      let data = that.misdata;
+      that.API.requestPost({
+        method: "POST",
+        subUrl: "misreport/save/glyc",
+        data,
+        success(res) {
+          if (res.code == 200) {
+            that.$message({
+              message: '保存成功',
+              type: 'success'
+            })
+          }else{
+            that.$message({
+              message: '保存失败',
+              type: 'error'
+            })
+          }
+        },
+      });
+    },
     getTableData() {
       let that = this;
       that.API.requestData({
@@ -146,19 +247,19 @@ export default {
       this.BASE.showLoading();
     },
     onSuccess(res) {
-      if(res.code != 200){
-        this.$message({
-          message: res.msg,
-          type: 'error'
-        })
-      }else{
-        this.$message({
-          message: '上传成功',
-          type: 'success'
-        })
-      }
-      this.BASE.closeLoading();
-      this.$refs.upload.clearFiles();
+        if(res.code != 200){
+          this.$message({
+            message: res.msg,
+            type: 'error'
+          })
+        }else{
+          this.$message({
+            message: '上传成功',
+            type: 'success'
+          })
+        }
+        this.BASE.closeLoading();
+        this.$refs.upload.clearFiles();
     },
     importExecl() {
 
@@ -185,4 +286,26 @@ export default {
   display: flex;
   flex-direction: row;
 }
+.timeDate{
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+}
+.moudles{
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  margin-top: 20px;
+}
+.title {
+  font-size: 16px;
+  color: #666666;
+  margin-right: 30px;
+  width: 150px;
+}
+.submit{
+  margin-top: 100px;
+  display: flex;
+  flex-direction: row-reverse;
+}
 </style>