|
@@ -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>
|