|
|
|
@ -3,14 +3,16 @@
|
|
|
|
|
<h1>{{title}}</h1>
|
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<div class="form-group row" v-if="!hasPermission()">
|
|
|
|
|
<div class="el-col-sm-offset-2 col-sm-10 ">
|
|
|
|
|
<div style="color:red;">权限不足</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<form v-else-if="data.schema" ref="form" class="form-horizontal query" :action="url" @submit.prevent="onSubmit">
|
|
|
|
|
<form v-if="hasPermission()" ref="form" class="form-horizontal query" :action="action" @submit.prevent="onSubmit($event)">
|
|
|
|
|
<div class="card" v-if="data.schema">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<template v-if="data.errors">
|
|
|
|
|
<div class="form-group" v-for="error in data.errors">
|
|
|
|
|
<div class="el-col-sm-offset-2 col-sm-10 ">
|
|
|
|
|
<div style="color:red">{{error}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<input type="hidden" name="id" :value="data.model.id" />
|
|
|
|
|
<div class="form-group row" v-for="(value,key,index) in data.schema.properties" v-if="show(key,value)">
|
|
|
|
|
<label class="col-sm-2 col-form-label" :for="key">{{value.title}}:</label>
|
|
|
|
@ -20,24 +22,25 @@
|
|
|
|
|
<component :is="getDisplayComponent(key)" :title="value.title" :name="key" :value="data.model[key]" :data="data.data" v-if="data.model" />
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<component :is="getEditComponent(key)" :title="value.title" :name="key" :value="data.model[key]" :data="data.data" :valid="valid(value,key,data.model[key])" :mode="'edit'" v-if="data.model" />
|
|
|
|
|
<component :is="getEditComponent(key)" :title="value.title" :name="key" :value.sync="data.model[key]" :data="data.data" :valid="valid(value,key,data.model[key])" :mode="'edit'" v-if="data.model" />
|
|
|
|
|
</template>
|
|
|
|
|
<span class="text-danger field-validation-valid" :data-valmsg-for="key" data-valmsg-replace="true"></span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-sm-4">{{value.description}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="card-footer">
|
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col-sm-2">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-sm-10">
|
|
|
|
|
<a href="javascript:;" class="btn btn-primary" v-on:click="onSubmit()">确定</a>
|
|
|
|
|
<router-link :to="{path:'/router/shared/list.html',query:{entity:entity}}" class="btn btn-default">返回</router-link>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="card-footer">
|
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col-sm-2">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-sm-10">
|
|
|
|
|
<button type="submit" class="btn btn-primary">确定</button>
|
|
|
|
|
<router-link :to="{path:'/router/shared/list.html',query:{entity:entity}}" class="btn btn-default">返回</router-link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</layout>
|
|
|
|
@ -64,6 +67,9 @@
|
|
|
|
|
this.$route.query.entity + '/' +
|
|
|
|
|
this.$route.query.mode +
|
|
|
|
|
(this.mode === 'Edit' ? ('?id=' + this.$route.query.id) : '');
|
|
|
|
|
},
|
|
|
|
|
action: function () {
|
|
|
|
|
return '/IoTCenter/Admin/' + this.$route.query.entity + '/' + this.$route.query.mode + 'Api';
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted: function () {
|
|
|
|
@ -75,11 +81,14 @@
|
|
|
|
|
var url = this.baseUrl + this.url;
|
|
|
|
|
axios.get(url).then(function (response) {
|
|
|
|
|
vm.data = response.data;
|
|
|
|
|
vm.$nextTick(function () {
|
|
|
|
|
$(vm.$refs.form).removeData('validator');
|
|
|
|
|
$(vm.$refs.form).removeData('unobtrusiveValidation');
|
|
|
|
|
$.validator.unobtrusive.parse(vm.$refs.form);
|
|
|
|
|
});
|
|
|
|
|
this.validInit();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
validInit: function () {
|
|
|
|
|
vm.$nextTick(function () {
|
|
|
|
|
$(vm.$refs.form).removeData('validator');
|
|
|
|
|
$(vm.$refs.form).removeData('unobtrusiveValidation');
|
|
|
|
|
$.validator.unobtrusive.parse(vm.$refs.form);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
hasPermission: function () {
|
|
|
|
@ -110,8 +119,22 @@
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
},
|
|
|
|
|
onSubmit: function () {
|
|
|
|
|
|
|
|
|
|
onSubmit: function (e) {
|
|
|
|
|
if ($(e.target).validate()) {
|
|
|
|
|
var vm = this;
|
|
|
|
|
axios.post(e.target.action, this.data.model).then(function (response) {
|
|
|
|
|
if (response.status === 204) {
|
|
|
|
|
var url = '/router/shared/list.html?entity=' + vm.entity;
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
router.push(url);
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
vm.data = response.data;
|
|
|
|
|
vm.validInit();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|