| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <template>
- <el-dialog
- class="dialog-ocpi"
- :visible="visible"
- :before-close="e => hideDialog(false)"
- :close-on-click-modal="false"
- title="CREATE OCPI CONNECTION">
- <el-form
- ref="ocpiForm"
- :model="form"
- :rules="rules"
- label-width="120px"
- label-position="right"
- v-loading="initial">
- <el-form-item
- prop="url"
- class="form-item"
- label="Party URL:">
- <el-input
- v-model="form.url"
- class="flex-item"
- maxlength="100"/>
- </el-form-item>
- <el-form-item
- prop="token"
- class="form-item"
- label="Party Token:">
- <el-input
- class="flex-item"
- type="textarea"
- maxlength="300"
- :autosize="autosize"
- v-model="form.token"/>
- </el-form-item>
- <div class="flexcc" style="padding-top: 20px;">
- <el-button
- class="button"
- @click="hideDialog(false)">
- CANCEL
- </el-button>
- <el-button
- class="button"
- type="primary"
- :loading="loading"
- @click="onFormSave">
- INITIALIZE
- </el-button>
- </div>
- </el-form>
- </el-dialog>
- </template>
- <script>
- import ocpi from '../../../http/api/ocpi.js';
- export default {
- name: "DialogOperators",
- props: {
- visible: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- initial: false,
- loading: false,
- form: {
- url: "",
- token: ""
- },
- rules: {
- url: {
- required: true,
- message: "Url is required",
- trigger: "blur"
- },
- token: {
- required: true,
- message: "Token is required",
- trigger: "blur"
- }
- },
- autosize: {
- minRows: 3,
- maxRows: 6
- }
- };
- },
- mounted() {
-
- },
- methods: {
- hideDialog(success) {
- this.init();
- this.$emit("hide", success || false);
- },
- init() {
- this.form = {
- url: "",
- token: ""
- }
- this.loading = false;
- this.$nextTick(() => {
- if (this.$refs['ocpiForm']) {
- this.$refs['ocpiForm'].clearValidate();
- }
- })
- },
- onFormSave() {
- this.$refs['ocpiForm'].validate((valid) => {
- if (valid) {
- this.onReceive();
- }
- })
- },
- onReceive() {
- this.loading = true;
- ocpi.initRoamingOperators(this.form).then(res => {
- this.$message({
- type: 'success',
- message: "Initialize successfully"
- });
- this.hideDialog(true);
- }).catch(err => {
- this.loading = false;
- this.$message({
- type: 'error',
- message: err
- })
- });
- }
- }
- }
- </script>
- <style scoped>
- .dialog-ocpi {
- display: flex;
- align-items: center;
- flex-direction: column;
- justify-content: center;
- }
- .dialog-ocpi >>> .el-dialog {
- width: 100%;
- max-width: 550px;
- margin-top: 0 !important;
- }
- .dialog-ocpi >>> .el-dialog__body {
- padding: 10px 20px 30px;
- }
- .dialog-ocpi >>> .el-form {
- padding-right: 10px;
- }
- .form-row {
- display: flex;
- flex-wrap: wrap;
- padding-bottom: 5px;
- }
- .form-item {
- flex: 1;
- margin-left: 10px;
- /*margin-bottom: 10px; TOP*/
- }
- .form-item >>> label {
- /*padding: 0; TOP*/
- }
- .flex-item {
- width: 100%;
- min-width: 200px;
- max-width: 420px;
- }
- .flex-item ::v-deep .el-textarea__inner {
- font-family: sans-serif;
- }
- @media screen and (max-width: 500px) {
- .flex-item {
- width: 100%;
- max-width: none;
- }
- }
- </style>
|