|
|
@@ -238,6 +238,45 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
+ <div class="hr"></div>
|
|
|
+ <div class="section-title">Charge Type Settings</div>
|
|
|
+ <div class="rate-list-view" v-for="(item, index) in settingsForm.chargeTypes" :key="index">
|
|
|
+ <el-form-item
|
|
|
+ label="Type:"
|
|
|
+ label-width="50px"
|
|
|
+ :prop="'chargeTypes.'+index+'.chargeType'"
|
|
|
+ :rules="rule.chargeTypes.chargeType">
|
|
|
+ <el-select
|
|
|
+ v-model="item.chargeType"
|
|
|
+ class="rate-text">
|
|
|
+ <el-option
|
|
|
+ v-for="i in chargeTypeOptions"
|
|
|
+ :key="i"
|
|
|
+ :label="i"
|
|
|
+ :value="i" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ label="Wattage:"
|
|
|
+ label-width="75px"
|
|
|
+ :prop="'chargeTypes.'+index+'.wattage'"
|
|
|
+ :rules="rule.chargeTypes.wattage">
|
|
|
+ <el-input
|
|
|
+ v-model="item.wattage"
|
|
|
+ class="rate-text"
|
|
|
+ maxlength="5"/>
|
|
|
+ </el-form-item>
|
|
|
+ <img
|
|
|
+ class="list-item-icon"
|
|
|
+ @click="subChargeType(index)"
|
|
|
+ src="../assets/form-list-sub.png"
|
|
|
+ v-if="settingsForm.chargeTypes.length > 1"/>
|
|
|
+ <img
|
|
|
+ class="list-item-icon"
|
|
|
+ @click="addChargeType"
|
|
|
+ src="../assets/form-list-add.png"
|
|
|
+ v-if="index == settingsForm.chargeTypes.length - 1"/>
|
|
|
+ </div>
|
|
|
<div class="hr-full"></div>
|
|
|
<div class="buttons">
|
|
|
<el-button
|
|
|
@@ -261,6 +300,7 @@
|
|
|
|
|
|
<script>
|
|
|
import api from '../http/api/settings'
|
|
|
+ import site from '../http/api/site'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -268,8 +308,14 @@
|
|
|
settingsForm: {
|
|
|
enabled: false,
|
|
|
recipients: [],
|
|
|
+ chargeTypes: [],
|
|
|
enabledFeatures: []
|
|
|
},
|
|
|
+ chargeType: {
|
|
|
+ chargeType: '',
|
|
|
+ chargeTypePk: '',
|
|
|
+ wattage: ''
|
|
|
+ },
|
|
|
rule: {
|
|
|
"heartbeat": {
|
|
|
required: true,
|
|
|
@@ -315,6 +361,22 @@
|
|
|
pattern: /^[a-zA-Z0-9]+[\S]+@[a-zA-Z0-9_-]+[\.][\Sa-zA-Z]+$/,
|
|
|
trigger: 'blur',
|
|
|
message: 'Please type a correct recipient'
|
|
|
+ },
|
|
|
+ chargeTypes: {
|
|
|
+ chargeType: {
|
|
|
+ required: true,
|
|
|
+ trigger: 'change',
|
|
|
+ message: 'Charge Type is required',
|
|
|
+ },
|
|
|
+ wattage: [{
|
|
|
+ required: true,
|
|
|
+ trigger: 'change',
|
|
|
+ message: 'Wattage is required',
|
|
|
+ }, {
|
|
|
+ pattern: /^[1-9]+\d*.?\d*$/,
|
|
|
+ trigger: 'blur',
|
|
|
+ message: 'Please type a correct wattage'
|
|
|
+ }]
|
|
|
}
|
|
|
},
|
|
|
recipient: '',
|
|
|
@@ -329,11 +391,13 @@
|
|
|
"protocol": "",
|
|
|
"port": '',
|
|
|
"recipients": [],
|
|
|
+ chargeTypes: [],
|
|
|
"enabledFeatures": []
|
|
|
},
|
|
|
features: [],
|
|
|
featuresGroup: 0,
|
|
|
- manualValid: false
|
|
|
+ manualValid: false,
|
|
|
+ chargeTypeOptions: []
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
@@ -347,6 +411,7 @@
|
|
|
this.features = res.data;
|
|
|
this.featuresGroup = res.data.length / 2
|
|
|
}
|
|
|
+ this.getChargeTypeOptions()
|
|
|
this.getSettings();
|
|
|
},
|
|
|
async getSettings() {
|
|
|
@@ -354,12 +419,27 @@
|
|
|
if (res.data) {
|
|
|
this.settingsForm = res.data;
|
|
|
}
|
|
|
- this.loading = false;
|
|
|
+ },
|
|
|
+ getChargeTypeOptions() {
|
|
|
+ site.getTypeList().then(res => {
|
|
|
+ if (res.data) {
|
|
|
+ this.chargeTypeOptions = res.data
|
|
|
+ this.chargeType.chargeType = res.data[0]
|
|
|
+ if (!this.settingsForm.chargeTypes) {
|
|
|
+ this.settingsForm.chargeTypes = []
|
|
|
+ this.addChargeType()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.loading = false;
|
|
|
+ }).catch(err => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
},
|
|
|
init() {
|
|
|
this.recipient = "";
|
|
|
const info = JSON.parse(JSON.stringify(this.clearForm));
|
|
|
this.settingsForm = info;
|
|
|
+ this.addChargeType()
|
|
|
this.manualValid = false;
|
|
|
this.$forceUpdate();
|
|
|
},
|
|
|
@@ -432,6 +512,35 @@
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ deleteChargeType(id, back) {
|
|
|
+ api.deleteChargeType(id).then(res => {
|
|
|
+ back()
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ message: err,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ subChargeType(index) {
|
|
|
+ var chargeType = this.settingsForm.chargeTypes[index]
|
|
|
+ if (chargeType.chargeTypePk) {
|
|
|
+ this.$confirm('Confirm delete this charge type?', 'Delete', {
|
|
|
+ confirmButtonText: 'Confirm',
|
|
|
+ cancelButtonText: 'Cancel',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(res => {
|
|
|
+ this.deleteChargeType(chargeType.chargeTypePk, () => {
|
|
|
+ this.settingsForm.chargeTypes.splice(index, 1)
|
|
|
+ })
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.settingsForm.chargeTypes.splice(index, 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ addChargeType() {
|
|
|
+ this.settingsForm.chargeTypes.push(JSON.parse(JSON.stringify(this.chargeType)))
|
|
|
+ },
|
|
|
handleUpateButton() {
|
|
|
this.$refs['settingsForm'].validate(result => {
|
|
|
if (this.settingsForm.recipients.length == 0) {
|
|
|
@@ -442,6 +551,7 @@
|
|
|
this.loading = true;
|
|
|
api.updateSettings(this.settingsForm).then(res => {
|
|
|
this.loading = false;
|
|
|
+ this.getSettings();
|
|
|
this.$message({
|
|
|
message: 'Save settings successfully',
|
|
|
type: 'success'
|