|
|
|
@ -1,21 +1,21 @@
|
|
|
|
|
<template>
|
|
|
|
|
<layout v-bind:title="data.schema.title">
|
|
|
|
|
<h1>{{data.schema.title}}<span v-if="model==='Edit'">编辑页</span><span v-else>新建页</span></h1>
|
|
|
|
|
<h1>{{data.schema.title}}<span v-if="mode==='Edit'">编辑页</span><span v-else>新建页</span></h1>
|
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="card-body" v-if="hasPermission('Edit')">
|
|
|
|
|
<form class="form-horizontal query" v-if="hasPermission('Read')" :action="url" @submit.prevent="onSubmit">
|
|
|
|
|
<form ref="form" class="form-horizontal query" v-if="hasPermission('Read')" :action="url" @submit.prevent="onSubmit">
|
|
|
|
|
<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>
|
|
|
|
|
<div class="col-sm-6 form-control" style="border-color:transparent;height:auto;min-height:calc(2.25rem + 2px);" :title="key">
|
|
|
|
|
<template v-if="value.readOnly">
|
|
|
|
|
<template v-if="value.readOnly&&mode!=='Add'">
|
|
|
|
|
<input type="hidden" :name="key" :value="data.model[key]" />
|
|
|
|
|
<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="data.model[key]" :data="data.data" :valid="valid(value,key,data.model[key])" :mode="'edit'" v-if="data.model" />
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-sm-4">{{value.description}}</div>
|
|
|
|
@ -39,10 +39,10 @@
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
name: 'page-edit',
|
|
|
|
|
data: function () {
|
|
|
|
|
return {
|
|
|
|
|
model: this.$route.query.mode,
|
|
|
|
|
url: '/IoTCenter/Admin/' + this.$route.query.entity + '/' + this.$route.query.mode + '?id=' + this.$route.query.id,
|
|
|
|
|
mode: this.$route.query.mode,
|
|
|
|
|
entity: this.$route.query.entity,
|
|
|
|
|
data: {
|
|
|
|
|
schema: {
|
|
|
|
@ -53,6 +53,14 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
url: function () {
|
|
|
|
|
return '/IoTCenter/Admin/' +
|
|
|
|
|
this.$route.query.entity + '/' +
|
|
|
|
|
this.$route.query.mode +
|
|
|
|
|
(this.mode === 'Edit' ? ('?id=' + this.$route.query.id) : '');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted: function () {
|
|
|
|
|
this.load();
|
|
|
|
|
},
|
|
|
|
@ -62,6 +70,11 @@
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
hasPermission: function (cmd) {
|
|
|
|
@ -71,7 +84,6 @@
|
|
|
|
|
getEditComponent: function (key) {
|
|
|
|
|
var property = this.data.schema.properties[key];
|
|
|
|
|
var template = 'edit-' + (property.ui || property.format || property.type);
|
|
|
|
|
console.log(template);
|
|
|
|
|
return template;
|
|
|
|
|
},
|
|
|
|
|
getDisplayComponent: function (key) {
|
|
|
|
@ -83,9 +95,6 @@
|
|
|
|
|
return key !== 'id';
|
|
|
|
|
},
|
|
|
|
|
valid(schema, key, value) {
|
|
|
|
|
console.log(schema);
|
|
|
|
|
console.log(key);
|
|
|
|
|
console.log(value);
|
|
|
|
|
var result = {};
|
|
|
|
|
if (schema.required) {
|
|
|
|
|
result.required = '必须输入' + schema.title;
|
|
|
|
|