2 次代碼提交 76df75fa5a ... 4373aee487

作者 SHA1 備註 提交日期
  zq 4373aee487 Merge branch 'master' of http://47.92.161.104:10080/yanliming/jp-charging-station-portal 4 天之前
  zq 285fe58a9e vip平台增加分时服务费。 4 天之前

+ 22 - 0
src/api/base/vipTimeSharingPrice.js

@@ -0,0 +1,22 @@
+import request from '@/utils/request'
+import constant from '@/constant'
+
+function edit(stationId,platformId){
+    return request.get(constant.chargingServerUrl + `/vipTimeSharingPrice/edit?stationId=${stationId}&platformId=${platformId}`);
+}
+
+function batchSetPrice(stationId,platformId, formModel){
+    return request.post(constant.chargingServerUrl + `/vipTimeSharingPrice/batchSetPrice?stationId=${stationId}&platformId=${platformId}`, formModel,{
+        headers: {
+        "Content-Type": "application/json"
+        }
+    });
+}
+
+function queryPriceList(stationId) {
+    return request.get(constant.chargingServerUrl + "/vipTimeSharingPrice/queryPriceList?stationId=" + stationId);
+}
+
+export default {
+    edit,batchSetPrice,queryPriceList
+}

+ 3 - 1
src/views/charging/enterpriseVipUserRelation-list.vue

@@ -172,7 +172,9 @@
         stationList:[],
         showModal8: false,
         modalTitle8 : "",
-        queryName: ""
+        queryName: "",
+        stationId: "",
+        enterpriseId: ""
       };
     },
     methods: {

+ 40 - 2
src/views/charging/stationVipPlatformRelation-list.vue

@@ -1,5 +1,6 @@
 
 <template>
+    <div>
     <el-dialog v-drag-dialog
       :visible.sync="showDialog"
       :title="title"
@@ -77,6 +78,13 @@
                   </el-form-item>
               </template>
           </el-table-column>
+          <el-table-column label="分时服务费">
+            <template slot-scope="{row}">
+              <el-form-item>
+                <el-button size="mini" @click="handleTimeSharingPrice(row)">配置</el-button>
+              </el-form-item>
+            </template>
+          </el-table-column>
           <el-table-column label="操作" width="100" fixed="right">
             <template slot-scope="{row}">
               <el-form-item>
@@ -96,10 +104,20 @@
         <el-button type="primary" @click="handleSubmit" :loading="submitting">确 定</el-button>
       </span>
     </el-dialog>
+    <vipTimeSharingPrice-list
+      v-if="showModal8"
+      :stationId="stationId"
+      :platformId="platformId"
+      :title="modalTitle8"
+      @close="onDetailModalClose8"
+    >
+    </vipTimeSharingPrice-list>
+    </div>
   </template>
   <script>
   import stationVipPlatformRelationApi from "@/api/base/stationVipPlatformRelation";
   import chargingStationApi from "@/api/base/chargingStation";
+  import vipTimeSharingPriceList from "./vipTimeSharingPrice-list";
   
   export default {
     props: ["title", "deviceType", "businessKey"],
@@ -128,7 +146,10 @@
         templateList: [],
         defaultPriceList:[],
         stationList:[],
-  
+        showModal8: false,
+        modalTitle8 : "",
+        stationId: "",
+        platformId: ""
       };
     },
     methods: {
@@ -195,6 +216,20 @@
   
           this.formModel.removeTableData.push(row);
       },
+      handleTimeSharingPrice(row) {
+        var stationName = this.stationList.filter(item=>{
+          return item.id == row.stationId
+        })[0].name;
+
+        this.modalTitle8 = stationName + "分时服务费配置";
+        this.stationId = row.stationId;
+        this.platformId = row.vipPlatformId;
+        this.showModal8 = true;
+      },
+      onDetailModalClose8(refreshed) {
+        //保存成功后回调
+        this.showModal8 = false;
+      }
     },
     created() {
         chargingStationApi.list().then((response) => {
@@ -202,7 +237,7 @@
         this.stationList = jsonData.data;
       });
     },
-    mounted: function () {
+    mounted() {
       var self = this;
   
       (function () {
@@ -222,6 +257,9 @@
           self.$message.error(error + "");
         });
     },
+    components: {
+      "vipTimeSharingPrice-list": vipTimeSharingPriceList
+    }
   };
   </script>
   

+ 234 - 0
src/views/charging/vipTimeSharingPrice-list.vue

@@ -0,0 +1,234 @@
+
+<template>
+    <div>
+      <el-dialog v-drag-dialog
+        :visible.sync="showDialog"
+        :title="title"
+        :modal-append-to-body="true"
+        append-to-body
+        style="text-align:left;"
+        width="600px"
+        :close-on-click-modal="false"
+        @close="closeDialog"
+      >
+        <div class="user-panel" v-loading="loading">
+          <el-form ref="form" :model="formModel" inline :rules="ruleValidate" :label-width="'150px'">
+            <el-table
+            :data="formModel.tableData"
+            v-loading="loading"
+            stripe
+            >
+            <el-table-column  prop="startTime" label="时段" width="250">
+                <template slot-scope="scope">
+                    <el-select v-model="scope.row.timeRange" size="mini">
+                      <el-option 
+                      v-for="(price,index) in priceList"
+                      :key="index"
+                      :label="price.startTime + '至' + price.endTime" 
+                      :value="price.startTime + ',' + price.endTime" 
+                       ></el-option>
+                    </el-select>
+                </template>
+            </el-table-column>
+            <el-table-column prop="servicePrice" label="服务费(元)" width="150">
+                <template slot-scope="scope">
+                <el-input-number :precision="2" :step="0.1" :min="0"  v-model="scope.row.servicePrice"  size="mini">
+                </el-input-number>
+                </template>
+            </el-table-column>
+            <el-table-column label="操作" width="150" fixed="right">
+              <template slot-scope="{row}">
+                  <i class="el-icon-delete my-font" @click="handleDelete(row)"></i>
+                  <i class="el-icon-document-add my-font" @click="handleInsert(row)"></i>
+                  <i class="el-icon-document-copy my-font" @click="handleCopy(row)"></i>
+              </template>
+            </el-table-column>
+            </el-table>
+          </el-form>
+        <div class="el-table__empty-block">
+          <el-button icon="el-icon-circle-plus-outline" @click="handleAdd()">新增</el-button>
+          <el-button icon="el-icon-circle-plus-outline" @click="handleAddAll()">新增所有时段</el-button>
+        </div>
+        </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>
+    </div>
+    </template>
+    <script>
+    import vipTimeSharingPriceApi from "@/api/base/vipTimeSharingPrice";
+    
+    export default {
+      props: ["title", "stationId","platformId"],
+      computed: {
+          ruleValidate (){
+            var rules = null;
+            rules = {
+                startTime: [
+                  { required: true, message: "开始时段不能为空", trigger: "blur" }
+                ],
+                endTime: [
+                  { required: true, message: "结束时段不能为空", trigger: "blur" }
+                ],
+                servicePrice: [
+                  { required: true, message: "服务费不能为空", trigger: "blur" }
+                ]
+            };
+            return rules;
+          }
+      },
+      data() {
+        return {
+          showDialog: true,
+          loading: false,
+          submitting: false,
+          priceList: [],
+          formModel: {
+            tableData:[]
+          }
+        };
+      },
+      methods: {
+        closeDialog() {
+          this.$emit("close", false);
+        },
+        handleSubmit() {
+          var self = this;
+
+          if(self.platformId==null){
+            self.$message.warning("VIP平台编号为空!");
+            return;
+          }
+    
+          this.$refs["form"].validate((valid) => {
+            if (valid) {
+              self.formModel.tableData.forEach(row=>{
+                  let timeRange = row.timeRange.split(',')
+
+                  row.startTime = timeRange[0];
+                  row.endTime = timeRange[1];
+                });
+
+              vipTimeSharingPriceApi
+              .batchSetPrice(self.stationId,self.platformId,self.formModel.tableData)
+              .then(function (response) {
+                self.loading = 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);
+                }
+              });
+            }
+          });
+        },
+        handleAdd() {
+            this.formModel.tableData.push({
+                  stationId:this.stationId,
+                  timeRange: "",
+                  startTime:"",
+                  endTime: "",
+                  servicePrice: 0
+            });
+        },
+      handleAddAll() {
+        this.priceList.forEach(price=>{
+          this.formModel.tableData.push({
+            stationId:this.stationId,
+            timeRange: price.startTime + "," + price.endTime,
+            startTime:price.startTime,
+            endTime: price.endTime,
+            servicePrice: 0
+          });
+        })
+      },
+        handleInsert(row) {
+            var tableData = this.formModel.tableData;
+            var index = tableData.indexOf(row);
+    
+            if(index>=0){
+                tableData.splice(index+1,0,{
+                  stationId:this.stationId,
+                  timeRange: "",
+                  startTime:"",
+                  endTime: "",
+                  servicePrice: 0
+                });
+            }
+        },
+        handleDelete(row) {
+            var tableData = this.formModel.tableData;
+            tableData.splice(tableData.indexOf(row), 1);
+        },
+        handleCopy(row) {
+          var tableData = this.formModel.tableData;
+          tableData.forEach(item=>{
+            item.servicePrice = row.servicePrice;
+          })
+        },
+        handleChangeStartTime(row) {
+          this.priceList.forEach(price=>{
+            if(price.startTime==row.startTime){
+              row.endTime = price.endTime;
+            }
+          })
+        }
+      },
+      created() {
+        vipTimeSharingPriceApi.queryPriceList(this.stationId)
+          .then((response) => {
+            var jsonData = response.data;
+                        
+            if (jsonData.result) {
+              this.priceList = jsonData.data;
+            }
+          })
+      },
+      mounted: function () {
+        var self = this;
+    
+        (function () {
+            return vipTimeSharingPriceApi.edit(self.stationId,self.platformId);
+        })()
+          .then((response) => {
+            var jsonData = response.data;
+            self.loading = false;
+    
+            if (jsonData.result) {
+              jsonData.data.forEach(item=>{
+                item.timeRange = item.startTime + "," + item.endTime
+              })
+              
+              self.formModel.tableData = jsonData.data; 
+            } else {
+              self.$message.error(jsonData.message + "");
+            }
+          })
+          .catch((error) => {
+            self.$message.error(error + "");
+          });
+      },
+    };
+    </script>  
+  <style rel="stylesheet/scss" lang="scss" scoped>
+    .my-font {
+    font-size: 20px;
+    cursor: pointer;
+    margin-right: 10px;
+  }
+  </style>