Browse Source

Merge branch 'master' of http://47.92.161.104:10080/yanliming/jp-charging-station-portal

shuzhan 4 days ago
parent
commit
4d60400edf

+ 18 - 0
src/api/base/chargingFundsStation.js

@@ -0,0 +1,18 @@
+import request from '@/utils/request'
+import constant from '@/constant'
+
+function queryRelatedStationList(id) {
+    return request.get(constant.chargingServerUrl + "/base/chargingFundsStation/queryRelatedStationList?regUserId=" + id);
+}
+
+function saveRelatedStation(formModel) {
+    return request.post(constant.chargingServerUrl + "/base/chargingFundsStation/saveRelatedStation", formModel,{
+    headers: {
+      "Content-Type": "application/json"
+    }
+  });
+}
+
+export default {
+    queryRelatedStationList,saveRelatedStation
+}

+ 139 - 0
src/views/charging/chargingFundsStation-detail.vue

@@ -0,0 +1,139 @@
+<template>
+    <el-dialog v-drag-dialog
+    :visible.sync="showDialog"
+    :title="title"
+    :modal-append-to-body="true"
+    append-to-body
+    style="text-align:left;"
+    width="900px"
+    :close-on-click-modal="false"
+    @close="closeDialog"
+    >
+  <div class="user-panel" v-loading="loading">
+    <el-transfer
+      v-model="formModel.relatedList"
+      :data="stationList"
+      v-loading="loading"
+      filterable
+      :filter-method="filterMethod"
+      filter-placeholder="请输入关键字"
+      :props="{key: 'id',label: 'name'}"
+      :titles="['未分配充电站','已分配充电站']"
+    ></el-transfer>
+  </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="closeDialog">取 消</el-button>
+        <el-button type="primary" @click="handleSubmit" :loading="submitting">确 定</el-button>
+      </span>
+    </el-dialog>
+</template>
+<script>
+
+import chargingStationApi from "@/api/base/chargingStation";
+import chargingFundsStationApi from "@/api/base/chargingFundsStation";
+
+export default {
+  props: ["businessKey", "title"],
+  data() {
+    return {
+      showDialog: true,
+      loading: false,
+      submitting: false,
+      formModel:{
+        userId:"",
+        relatedList: []
+      },
+      stationList:[],
+      ruleValidate: {}
+    };
+  },
+  methods: {
+    closeDialog() {
+      this.$emit("close", false);
+    },
+    filterMethod(query, item) {
+      return item.name.indexOf(query) > -1;
+    },
+    handleSubmit() {
+      var self = this;
+
+      self.submitting = true;
+
+      chargingFundsStationApi.saveRelatedStation(self.formModel)
+      .then((response)=>{
+        self.submitting = false;
+      
+        var jsonData = response.data;
+
+        if (jsonData.result) {
+          self.$message({
+            message: "保存成功!",
+            type: "success"
+          });
+
+          self.$emit("close",true);
+        } else {
+          self.$message({
+            message: jsonData.message + "",
+            type: "warning"
+          });
+
+          self.$emit("close",false);
+        }
+      });
+    }
+  },
+  created() {
+    var self = this;
+
+    chargingStationApi.stationList().then((response)=>{
+      var jsonData = response.data;
+
+      if (jsonData.result) {
+          self.stationList = jsonData.data;
+      }
+    });
+  },
+  mounted() {
+      var self = this;
+
+      self.loading = true;
+      self.formModel.userId = self.businessKey;
+
+      chargingFundsStationApi.queryRelatedStationList(self.formModel.userId)
+      .then(response => {
+        var jsonData = response.data;
+        self.loading = false;
+
+        if (jsonData.result) {
+          self.formModel.relatedList = jsonData.data.map(e=>e.stationId);
+        } else {
+          self.$message.error(jsonData.message + "");
+        }
+      })
+      .catch(error => {
+        self.loading = false;
+
+        self.$message.error(error + "");
+      });
+  }
+};
+</script>
+<style lang="scss">
+.user-panel {
+  margin: 10px auto;
+
+  .el-transfer-panel {
+    border: 1px solid #ebeef5;
+    border-radius: 4px;
+    overflow: hidden;
+    background: #fff;
+    display: inline-block;
+    vertical-align: middle;
+    width: 320px;
+    -webkit-box-sizing: border-box;
+    box-sizing: border-box;
+    position: relative;
+  }
+}
+</style>

+ 18 - 1
src/views/charging/chargingRegUser-funds.vue

@@ -12,6 +12,8 @@
             <el-row class="button-group">
               <el-button type="primary" size="small" plain icon="el-icon-circle-plus" @click="handleAdd"
                 v-show="giveVisible">充值</el-button>
+              <el-button type="success" size="small" plain icon="el-icon-circle-plus" @click="handleRelatedStation"
+              v-show="giveVisible">关联站点</el-button>
             </el-row>
             <el-table :data="tableData" style="min-height: 400px" v-loading="loading" stripe>
               <el-table-column prop="depositAmount" label="存入金额(元)"></el-table-column>
@@ -78,11 +80,18 @@
       title="充电明细"
       @close="onDetailModalClose"
     ></chargingRecord-detail>
+    <chargingFundsStation-detail
+      v-if="showModal2"
+      :businessKey="businessKey"
+      title="关联充电站"
+      @close="onDetailModalClose2"
+    ></chargingFundsStation-detail>
   </div>
 </template>
 <script>
 import chargingFundsRecordApi from "@/api/base/chargingFundsRecord";
 import chargingRecordDetail from "./chargingRecord-detail";
+import chargingFundsStationDetail from "./chargingFundsStation-detail";
 import permissionApi from "@/api/sys/permission";
 import chargingFundsHistoryApi from "@/api/base/chargingFundsHistory";
 import chargingFundsScheduleList from "./chargingFundsSchedule-list";
@@ -132,6 +141,7 @@ export default {
       pageSize2: 10,
       totalPages2: 0,
       totalElements2: 0,
+      showModal2:false
     };
   },
   methods: {
@@ -276,6 +286,12 @@ export default {
       //保存成功后回调
       this.showModal = false;
     },
+    handleRelatedStation() {
+      this.showModal2 = true;
+    },
+    onDetailModalClose2() {
+      this.showModal2 = false;
+    },
     handleView(row) {
       this.chargingRecordId = row.chargingRecordId;
       this.showModal = true;
@@ -294,7 +310,8 @@ export default {
   },
   components: {
     "chargingRecord-detail": chargingRecordDetail,
-    "chargingFundsSchedule-list": chargingFundsScheduleList
+    "chargingFundsSchedule-list": chargingFundsScheduleList,
+    "chargingFundsStation-detail": chargingFundsStationDetail,
   }
 };
 </script>