Files
jsowell-charger-web/jsowell-ui/src/views/thirdparty/secret/detail.vue

406 lines
20 KiB
Vue
Raw Normal View History

2024-04-22 15:02:55 +08:00
<template>
<div class="app-container Input">
2024-04-23 16:09:56 +08:00
<el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="密钥配置" name="secret">
2024-04-23 16:20:27 +08:00
<el-form ref="form" :model="form" :rules="rules" label-width="230px">
2024-04-22 15:11:22 +08:00
<!-- -->
2024-04-22 16:24:32 +08:00
<el-col :span="24">
<el-form-item label="对接平台名称" prop="platformName">
2024-04-26 15:29:56 +08:00
<el-input v-model="form.platformName" placeholder="请输入对接平台名称" style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
<el-form-item label="接口地址前缀" prop="urlPrefix">
2024-04-26 15:29:56 +08:00
<el-input v-model="form.urlPrefix" placeholder="请输入接口地址前缀" style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
<el-form-item label="对接平台标识(OperatorId)" prop="theirOperatorId">
<el-input v-model="form.theirOperatorId" placeholder="请输入对接平台标识(OperatorId)"
2024-04-26 15:29:56 +08:00
style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
</el-col>
2024-04-22 15:11:22 +08:00
<!-- 左侧 -->
2024-04-22 16:24:32 +08:00
<el-col :span="12">
<el-card class="box-card" style="margin-right: 50px;">
2024-04-23 16:09:56 +08:00
<div slot="header" class="clearfix">对接平台密钥信息</div>
2024-04-23 16:20:27 +08:00
<el-form-item label="唯一识别密钥(OperatorSecret)" prop="theirOperatorSecret"
2024-04-26 15:29:56 +08:00
style="margin-top: 20px;">
2024-04-22 16:24:32 +08:00
<el-input v-model="form.theirOperatorSecret"
2024-04-26 15:29:56 +08:00
placeholder="请输入对接平台生成的唯一识别密钥(OperatorSecret)" style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
2024-04-23 16:20:27 +08:00
<el-form-item label="消息密钥(DataSecret)" prop="theirDataSecret">
2024-04-26 15:29:56 +08:00
<el-input v-model="form.theirDataSecret" placeholder="请输入对接平台生成的消息密钥(DataSecret)"
style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
2024-04-23 16:20:27 +08:00
<el-form-item label="初始化向量(DataSecretIv)" prop="theirDataSecretIv">
2024-04-26 15:29:56 +08:00
<el-input v-model="form.theirDataSecretIv" placeholder="请输入对接平台生成的初始化向量(DataSecretIv)"
style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
2024-04-23 16:20:27 +08:00
<el-form-item label="签名密钥(SigSecret)" prop="theirSigSecret">
2024-04-26 15:29:56 +08:00
<el-input v-model="form.theirSigSecret" placeholder="请输入对接平台生成的签名密钥(SigSecret)"
style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
</el-card>
</el-col>
2024-04-22 15:11:22 +08:00
<!-- 右侧 -->
2024-04-22 16:24:32 +08:00
<el-col :span="12">
<el-card class="box-card">
<div slot="header" class="clearfix">
2024-04-23 16:09:56 +08:00
<span>我方生成密钥信息</span>
2024-04-24 11:00:00 +08:00
<el-button style="float: right; padding: 3px 0" type="text"
2024-04-26 15:29:56 +08:00
@click="clickGenerateSecret">生成密钥
2024-04-24 11:00:00 +08:00
</el-button>
2024-04-22 16:24:32 +08:00
</div>
2024-04-23 16:20:27 +08:00
<el-form-item label="唯一识别密钥(OperatorSecret)" prop="ourOperatorSecret"
2024-04-26 15:29:56 +08:00
style="margin-top: 20px;">
<el-input v-model="form.ourOperatorSecret" placeholder="请输入我方生成的唯一识别密钥(OperatorSecret)"
style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
2024-04-23 16:20:27 +08:00
<el-form-item label="消息密钥(DataSecret)" prop="ourDataSecret">
2024-04-26 15:29:56 +08:00
<el-input v-model="form.ourDataSecret" placeholder="请输入我方生成的消息密钥(DataSecret)"
style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
2024-04-23 16:20:27 +08:00
<el-form-item label="初始化向量(DataSecretIv)" prop="ourDataSecretIv">
2024-04-26 15:29:56 +08:00
<el-input v-model="form.ourDataSecretIv" placeholder="请输入我方生成的初始化向量(DataSecretIv)"
style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
2024-04-23 16:20:27 +08:00
<el-form-item label="签名密钥(SigSecret)" prop="ourSigSecret">
2024-04-22 16:24:32 +08:00
<el-input v-model="form.ourSigSecret" placeholder="请输入我方生成的签名密钥(SigSecret)"
2024-04-26 15:29:56 +08:00
style="width: 90%" />
2024-04-22 16:24:32 +08:00
</el-form-item>
</el-card>
</el-col>
2024-04-22 15:11:22 +08:00
</el-form>
2024-04-22 16:24:32 +08:00
<div class="save">
<el-button type="primary" @click="submitForm" style="margin-top: 20px;">保存</el-button>
2024-04-22 15:11:22 +08:00
</div>
2024-04-22 15:02:55 +08:00
</el-tab-pane>
2024-04-23 16:09:56 +08:00
<el-tab-pane label="同步数据" name="notification">
2024-04-24 17:08:14 +08:00
<template v-if="stationList.length > 0">
<el-row :gutter="20">
2024-04-25 16:40:23 +08:00
<div v-for="item in stationList" class="text item">
2024-04-24 17:08:14 +08:00
<el-col :span="8">
2024-04-28 14:15:09 +08:00
<el-card class="box-card" shadow="hover" style="margin-bottom: 20px;">
2024-04-26 15:10:03 +08:00
<div slot="header" class="clearfix">
<span>站点信息</span>
2024-04-26 15:29:56 +08:00
<el-button style="float: right; padding: 3px 0" type="text"
@click="clickDrawer(item.stationId, item.stationName)">打开推送菜单</el-button>
2024-04-26 15:10:03 +08:00
</div>
<el-descriptions class="margin-top" :column="1" border>
2024-04-25 16:40:23 +08:00
<el-descriptions-item label="站点id">{{ item.stationId }}</el-descriptions-item>
<el-descriptions-item label="站点名称">{{ item.stationName }}</el-descriptions-item>
2024-04-26 15:10:03 +08:00
<!--<el-descriptions-item label="操作">
2024-04-25 16:40:23 +08:00
<el-button @click="clickDrawer(item.stationId, item.stationName)" type="primary" style="margin-left: 16px;">
2024-04-26 15:10:03 +08:00
打开推送菜单
2024-04-24 17:08:14 +08:00
</el-button>
2024-04-26 15:10:03 +08:00
</el-descriptions-item>-->
2024-04-24 17:08:14 +08:00
</el-descriptions>
</el-card>
</el-col>
</div>
</el-row>
</template>
<el-empty description="暂无数据" v-else></el-empty>
2024-04-22 15:02:55 +08:00
2024-04-26 15:29:56 +08:00
<el-drawer :title="drawerTitle" :visible.sync="drawer" :direction="direction">
2024-04-24 17:08:14 +08:00
<el-row>
<el-col :span="24">
2024-04-26 15:31:28 +08:00
<el-card class="box-card" style="margin: 0 20px;" shadow="hover">
2024-04-25 16:40:23 +08:00
<div slot="header" class="clearfix">
<span>推送充电站信息变化</span>
2024-04-26 15:29:56 +08:00
<el-button style="float: right; padding: 3px 0" type="text"
@click="clickNotificationStationInfo">推送</el-button>
2024-04-25 16:40:23 +08:00
</div>
<div class="text item">
推送站点最新信息到第三方平台
</div>
</el-card>
2024-04-24 17:08:14 +08:00
</el-col>
</el-row>
<el-row>
<el-col :span="24">
2024-04-26 15:29:56 +08:00
<el-card class="box-card" style="margin: 20px 20px 0 20px;" shadow="hover">
2024-04-26 14:56:46 +08:00
<div slot="header" class="clearfix">
<span>推送设备状态</span>
2024-04-26 15:29:56 +08:00
<el-button style="float: right; padding: 3px 0" type="text"
@click="clickNotificationStationStatus">推送</el-button>
2024-04-26 14:56:46 +08:00
</div>
2024-04-25 16:40:23 +08:00
<el-form ref="notificationForm" :model="notificationForm" label-width="20%">
2024-04-26 15:29:56 +08:00
<el-form-item label="充电桩编号" class="getCard">
2024-04-25 16:40:23 +08:00
<el-input v-model="notificationForm.pileSn"></el-input>
</el-form-item>
2024-04-26 14:56:46 +08:00
<!--<el-form-item>
2024-04-25 16:40:23 +08:00
<el-button type="primary" @click="clickNotificationStationStatus">推送设备状态</el-button>
2024-04-26 14:56:46 +08:00
</el-form-item>-->
2024-04-25 16:40:23 +08:00
</el-form>
</el-card>
2024-04-24 17:08:14 +08:00
</el-col>
</el-row>
<el-row>
<el-col :span="24">
2024-04-26 15:29:56 +08:00
<el-card class="box-card" style="margin: 20px 20px 0 20px;" shadow="hover">
2024-04-26 14:56:46 +08:00
<div slot="header" class="clearfix">
<span>推送设备充电中状态</span>
2024-04-26 15:29:56 +08:00
<el-button style="float: right; padding: 3px 0" type="text"
@click="clickNotificationConnectorChargeStatus">推送</el-button>
2024-04-26 14:56:46 +08:00
</div>
2024-04-25 16:40:23 +08:00
<el-form ref="notificationForm" :model="notificationForm" label-width="20%">
<el-form-item label="充电枪口编号">
2024-04-26 15:10:03 +08:00
<el-input v-model="notificationForm.pileConnectorCode"></el-input>
</el-form-item>
2024-04-26 15:29:56 +08:00
<el-form-item label="充电枪口状态" class="getCard">
2024-04-26 15:10:03 +08:00
<el-input v-model="notificationForm.status"></el-input>
2024-04-25 16:40:23 +08:00
</el-form-item>
2024-04-26 14:56:46 +08:00
<!--<el-form-item>
2024-04-25 16:40:23 +08:00
<el-button type="primary" @click="clickNotificationConnectorChargeStatus">推送设备充电中状态</el-button>
2024-04-26 14:56:46 +08:00
</el-form-item>-->
2024-04-25 16:40:23 +08:00
</el-form>
</el-card>
2024-04-24 17:08:14 +08:00
</el-col>
</el-row>
<el-row>
<el-col :span="24">
2024-04-26 15:29:56 +08:00
<el-card class="box-card" style="margin: 20px 20px 0 20px;" shadow="hover">
2024-04-26 14:56:46 +08:00
<div slot="header" class="clearfix">
<span>推送充电订单信息</span>
2024-04-26 15:29:56 +08:00
<el-button style="float: right; padding: 3px 0" type="text"
@click="clickNotificationChargeOrderInfo">推送</el-button>
2024-04-26 14:56:46 +08:00
</div>
2024-04-25 16:40:23 +08:00
<el-form ref="notificationForm" :model="notificationForm" label-width="20%">
2024-04-26 15:29:56 +08:00
<el-form-item label="订单编号" class="getCard">
2024-04-25 16:40:23 +08:00
<el-input v-model="notificationForm.orderCode"></el-input>
</el-form-item>
2024-04-26 15:11:43 +08:00
<!--<el-form-item>
2024-04-25 16:40:23 +08:00
<el-button type="primary" @click="clickNotificationChargeOrderInfo">推送充电订单信息</el-button>
2024-04-26 15:11:43 +08:00
</el-form-item>-->
2024-04-25 16:40:23 +08:00
</el-form>
</el-card>
2024-04-24 17:08:14 +08:00
</el-col>
</el-row>
<el-row>
<el-col :span="24">
2024-04-26 15:29:56 +08:00
<el-card class="box-card" style="margin: 20px 20px 0 20px;" shadow="hover">
2024-04-26 14:56:46 +08:00
<div slot="header" class="clearfix">
<span>推送站点费率</span>
2024-04-26 15:29:56 +08:00
<el-button style="float: right; padding: 3px 0" type="text"
@click="clickNotificationStationFee">推送</el-button>
2024-04-26 14:56:46 +08:00
</div>
2024-04-28 14:28:00 +08:00
<div class="text item">
推送站点最新计费模板到第三方平台
</div>
2024-04-25 16:40:23 +08:00
</el-card>
2024-04-24 17:08:14 +08:00
</el-col>
</el-row>
</el-drawer>
2024-04-22 15:02:55 +08:00
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
2024-04-26 15:29:56 +08:00
import { addSecret, getSecret, selectStationList, updateSecret } from "@/api/thirdParty/secret";
import { generateRandomID, isEmptyString } from "@/utils/common";
2024-04-24 17:08:14 +08:00
import Template from "@/views/billing/template";
2024-04-25 16:40:23 +08:00
import {
notificationChargeOrderInfo,
notificationConnectorChargeStatus, notificationStationFee,
notificationStationInfo,
notificationStationStatus
} from "@/api/thirdParty/notification";
2024-04-22 15:11:22 +08:00
2024-04-22 15:02:55 +08:00
export default {
dicts: ["third_party_type"],
2024-04-26 15:29:56 +08:00
components: { Template },
2024-04-22 15:02:55 +08:00
data() {
return {
2024-04-23 16:09:56 +08:00
activeName: "secret",
2024-04-22 15:02:55 +08:00
id: this.$route.params.id,
platformName: this.$route.params.platformName,
2024-04-22 15:11:22 +08:00
// 表单参数
form: {},
2024-04-25 16:40:23 +08:00
notificationStationId: null,
notificationForm: {},
2024-04-22 15:11:22 +08:00
// 表单校验
2024-04-24 17:08:14 +08:00
rules: {},
stationList: [],
platformType: null,
drawer: false,
direction: 'rtl',
drawerTitle: null,
2024-04-22 15:02:55 +08:00
};
},
created() {
this.updateTitle();
},
methods: {
2024-04-24 17:08:14 +08:00
// 提交
onSubmit() {
2024-04-25 16:40:23 +08:00
this.notificationForm.stationId = this.notificationStationId;
2024-04-26 14:35:22 +08:00
this.notificationForm.platformType = this.platformType;
2024-04-25 16:40:23 +08:00
console.log(this.notificationForm);
},
// 点击推送站点信息
clickNotificationStationInfo() {
this.notificationForm.stationId = this.notificationStationId;
2024-04-26 14:35:22 +08:00
this.notificationForm.platformType = this.platformType;
2024-04-25 16:40:23 +08:00
notificationStationInfo(this.notificationForm).then(response => {
2024-04-26 14:56:46 +08:00
this.$modal.msgSuccess("操作成功");
2024-04-25 16:40:23 +08:00
});
},
// 点出推送设备状态
clickNotificationStationStatus() {
this.notificationForm.stationId = this.notificationStationId;
2024-04-26 14:35:22 +08:00
this.notificationForm.platformType = this.platformType;
2024-04-25 16:40:23 +08:00
notificationStationStatus(this.notificationForm).then(response => {
2024-04-26 14:56:46 +08:00
this.$modal.msgSuccess("操作成功");
2024-04-25 16:40:23 +08:00
});
},
// 点击推送设备充电中状态
clickNotificationConnectorChargeStatus() {
this.notificationForm.stationId = this.notificationStationId;
2024-04-26 14:35:22 +08:00
this.notificationForm.platformType = this.platformType;
notificationConnectorChargeStatus(this.notificationForm).then(response => {
2024-04-26 14:56:46 +08:00
this.$modal.msgSuccess("操作成功");
2024-04-25 16:40:23 +08:00
});
},
// 点击推送订单信息
clickNotificationChargeOrderInfo() {
this.notificationForm.stationId = this.notificationStationId;
2024-04-26 14:35:22 +08:00
this.notificationForm.platformType = this.platformType;
notificationChargeOrderInfo(this.notificationForm).then(response => {
2024-04-26 14:56:46 +08:00
this.$modal.msgSuccess("操作成功");
2024-04-25 16:40:23 +08:00
});
},
// 点击推送站点费率
clickNotificationStationFee() {
this.notificationForm.stationId = this.notificationStationId;
2024-04-26 14:35:22 +08:00
this.notificationForm.platformType = this.platformType;
notificationStationFee(this.notificationForm).then(response => {
2024-04-26 14:56:46 +08:00
this.$modal.msgSuccess("操作成功");
2024-04-25 16:40:23 +08:00
});
2024-04-24 17:08:14 +08:00
},
2024-04-25 16:40:23 +08:00
// 点击打开 通知菜单
2024-04-24 17:08:14 +08:00
clickDrawer(stationId, stationName) {
2024-04-25 16:40:23 +08:00
// console.log("站点id", stationId);
2024-04-24 17:08:14 +08:00
this.drawerTitle = "同步【" + stationName + "】站点的数据到【" + this.platformName + "】";
this.drawer = true;
2024-04-25 16:40:23 +08:00
this.notificationStationId = stationId;
2024-04-24 17:08:14 +08:00
},
// Drawer :before-close="handleClose"
handleClose(done) {
this.$confirm('确认关闭?')
.then(_ => {
done();
})
2024-04-26 15:29:56 +08:00
.catch(_ => { });
2024-04-24 17:08:14 +08:00
},
// 查询站点列表
queryStationList() {
const param = {
platformType: this.platformType
};
selectStationList(param).then(response => {
this.stationList = response.data;
console.log(this.stationList);
});
},
2024-04-23 16:09:56 +08:00
// 生成密钥
2024-04-24 11:00:00 +08:00
clickGenerateSecret() {
// 是否有值默认false
let hasValue = false;
if (!isEmptyString(this.form.ourOperatorSecret) || !isEmptyString(this.form.ourDataSecret)
|| !isEmptyString(this.form.ourDataSecretIv) || !isEmptyString(this.form.ourSigSecret)) {
// 任一字段不为空hasValue为true
hasValue = true;
}
if (hasValue) {
// 有值时弹出提示框
this.$confirm('当前已经有值, 此操作将覆盖原值, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 点击确定生成密钥
this.generateSecret();
});
} else {
// 没有值,直接生成密钥
this.generateSecret();
}
},
// 生成密钥方法
2024-04-23 16:09:56 +08:00
generateSecret() {
this.form.ourOperatorSecret = generateRandomID(16);
this.form.ourDataSecret = generateRandomID(16);
this.form.ourDataSecretIv = generateRandomID(16);
this.form.ourSigSecret = generateRandomID(16);
},
handleClick(tab, event) {
2024-04-24 17:08:14 +08:00
// console.log("handleClick", tab, event);
this.initializeData(tab.name);
},
initializeData(name) {
if (name === "secret") {
this.querySecretDetail();
} else if (name === "notification") {
this.queryStationList();
}
2024-04-23 16:09:56 +08:00
},
querySecretDetail() {
2024-04-22 15:11:22 +08:00
getSecret(this.id).then(response => {
this.form = response.data;
2024-04-24 17:08:14 +08:00
this.platformType = response.data.platformType;
2024-04-22 15:11:22 +08:00
});
},
2024-04-22 15:02:55 +08:00
// 更新页面title显示
updateTitle() {
const platformName = this.platformName;
const title = "【" + platformName + "】平台配置";
2024-04-26 15:29:56 +08:00
const route = Object.assign({}, this.$route, { title: `${title}` });
2024-04-22 15:02:55 +08:00
this.$store.dispatch("tagsView/updateVisitedView", route);
},
2024-04-23 16:09:56 +08:00
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateSecret(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addSecret(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
}
2024-04-22 15:11:22 +08:00
},
mounted() {
2024-04-24 17:08:14 +08:00
this.initializeData(this.activeName);
2024-04-22 15:11:22 +08:00
},
2024-04-22 15:02:55 +08:00
};
</script>
<style scoped lang="scss">
2024-04-22 16:24:32 +08:00
.save {
text-align: right;
}
2024-04-26 15:29:56 +08:00
::v-deep .el-card__body {
padding: 20px !important;
}
.getCard {
margin-bottom: 0px;
}
2024-04-22 15:02:55 +08:00
</style>