|
|
|
@ -100,17 +100,16 @@
|
|
|
|
|
<template v-else-if="deviceName==='串口控制器'">
|
|
|
|
|
{{deviceName}}
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else v-for="param in data.model.parameters">
|
|
|
|
|
<template v-else v-for="(param,index) in data.model.parameters">
|
|
|
|
|
<div class="form-group row">
|
|
|
|
|
<label class="col-sm-2 col-form-label">{{param.description}}:</label>
|
|
|
|
|
<div class="col-sm-6 form-control" style="border-color:transparent;height:auto;min-height:calc(2.25rem + 2px);">
|
|
|
|
|
<input type="text" class="form-control" :value="param.value" />
|
|
|
|
|
<input type="text" class="form-control" v-model="param.value" @input="change2(index)" />
|
|
|
|
|
<div style="height:1em;">
|
|
|
|
|
<!--<span v-if="hasErrors('name')" class="field-validation-error text-danger">{{getPropertyErrors('apiId')}}</span>
|
|
|
|
|
<span v-else class="text-danger field-validation-valid"></span>-->
|
|
|
|
|
<span v-if="hasErrors2(index)" class="field-validation-error text-danger">{{getPropertyErrors2(index)}}</span>
|
|
|
|
|
<span v-else class="text-danger field-validation-valid"></span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<!--<div class="col-sm-4">{{data.schema.properties.apiId.description}}</div>-->
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
|
|
|
@ -147,7 +146,8 @@
|
|
|
|
|
schema: null,
|
|
|
|
|
model: null,
|
|
|
|
|
data: null
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
errors: []
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
@ -212,6 +212,53 @@
|
|
|
|
|
change: function (name) {
|
|
|
|
|
return this.$validProperty(name);
|
|
|
|
|
},
|
|
|
|
|
updateErrorMessages2: function (messages, message, valid) {
|
|
|
|
|
if (valid()) {
|
|
|
|
|
if (Enumerable.from(messages).any(o => o === message)) {
|
|
|
|
|
var index = _.findIndex(messages, o => o === message);
|
|
|
|
|
messages.splice(index, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!Enumerable.from(messages).any(o => o === message)) {
|
|
|
|
|
messages.push(message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
change2: function (index) {
|
|
|
|
|
var item = this.data.model.parameters[index];
|
|
|
|
|
var value = item.value;
|
|
|
|
|
if (item.type === 'integer') {
|
|
|
|
|
value = parseInt(value);
|
|
|
|
|
}
|
|
|
|
|
else if (item.type === 'float') {
|
|
|
|
|
value = parseFloat(value);
|
|
|
|
|
}
|
|
|
|
|
var messages = this.errors[index];
|
|
|
|
|
if (!messages) {
|
|
|
|
|
messages = this.errors[index] = [];
|
|
|
|
|
}
|
|
|
|
|
if (item.required) {
|
|
|
|
|
var message = "必须填写" + item.description;
|
|
|
|
|
this.updateErrorMessages2(messages, '必填项', o => !(o === 0 || o));
|
|
|
|
|
}
|
|
|
|
|
if (item.minimum) {
|
|
|
|
|
var minimum = parseFloat(item.minimum);
|
|
|
|
|
var message = "必须大于" + item.minimum;
|
|
|
|
|
this.updateErrorMessages2(messages, message, o => value > minimum);
|
|
|
|
|
}
|
|
|
|
|
if (item.maxinum) {
|
|
|
|
|
var maxinum = parseFloat(item.maxinum);
|
|
|
|
|
var message = "必须小于" + item.maxinum;
|
|
|
|
|
this.updateErrorMessages2(messages, message, o => value < maxinum);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
hasErrors2: function (index) {
|
|
|
|
|
return this.errors[index] && this.errors[index].length;
|
|
|
|
|
},
|
|
|
|
|
getPropertyErrors2: function (index) {
|
|
|
|
|
return this.errors[index];
|
|
|
|
|
},
|
|
|
|
|
hasPermission: function () {
|
|
|
|
|
var permission = this.mode + '-' + this.entity;
|
|
|
|
|
return Enumerable.from(store.state.permissions).any(o => o.toLowerCase() === permission.toLowerCase());
|
|
|
|
@ -277,6 +324,7 @@
|
|
|
|
|
'data.model.apiId': function (val) {
|
|
|
|
|
var vm = this;
|
|
|
|
|
if (val && this.data.model.deviceId) {
|
|
|
|
|
vm.errors = [];
|
|
|
|
|
var url = this.path + 'Api?apiId=' + val + '&deviceId=' + this.data.model.deviceId;
|
|
|
|
|
axios.get(url).then(function (response) {
|
|
|
|
|
console.log(response.data);
|
|
|
|
|