Former-commit-id: 1538d94a6b33b3542b57ff25b178c642d958b116
Former-commit-id: 5e698b291bddccb67db52c70f154b6919eaab897
TSXN
wanggang 5 years ago
parent 2eedb81c47
commit 1aa27072e4

@ -140,6 +140,12 @@ namespace Infrastructure.Web.Mvc
return Result(model);
}
[HttpPost]
public virtual IActionResult EditApi([FromBody] TEditModel model)
{
return this.Edit(model);
}
[HttpPost]
public virtual IActionResult Remove(List<Guid> list)
{
@ -181,7 +187,7 @@ namespace Infrastructure.Web.Mvc
entity.IsDeleted = null;
this.Repo.SaveChanges();
}
return RedirectTo();
return Success();
}
catch (DbUpdateException ex)
{
@ -286,7 +292,7 @@ namespace Infrastructure.Web.Mvc
}
[ApiExplorerSettings(IgnoreApi = true)]
private IActionResult Result(object model)
protected IActionResult Result(object model)
{
if (this.Request.Headers["accept"].ToString().Contains("json", StringComparison.OrdinalIgnoreCase))
{
@ -300,5 +306,15 @@ namespace Infrastructure.Web.Mvc
}
return View(model);
}
[ApiExplorerSettings(IgnoreApi = true)]
protected IActionResult Success()
{
if (this.Request.Headers["accept"].ToString().Contains("json", StringComparison.OrdinalIgnoreCase))
{
return this.NoContent();
}
return RedirectTo();
}
}
}

@ -54,7 +54,7 @@ namespace IoT.Shared.Areas.Admin.Controlls
var dataService = scope.ServiceProvider.GetService<DataService>();
dataService.Edit<TEntity, TEditModel>(model);
}
return RedirectTo();
return Success();
}
catch (Exception ex)
{
@ -63,7 +63,7 @@ namespace IoT.Shared.Areas.Admin.Controlls
}
}
this.ToEditModel(null, model);
return View(model);
return Result(model);
}
public override IActionResult Delete(List<Guid> list)

@ -19,7 +19,7 @@ Vue.directive('valid', {
},
update: function (el, binding) {
if (binding.value !== binding.oldValue) {
console.log('value changed:' + el.innerHTML);
console.log('value changed:' + el.value);
}
}
});

@ -54,7 +54,7 @@
},
hasPermission: function (cmd) {
var permission = cmd + '-' + this.entity;
return Enumerable.from(store.state.site.permissions).any(o => o === permission);
return Enumerable.from(store.state.permissions).any(o => o === permission);
},
getComponent: function (key) {
var property = this.data.schema.properties[key];

@ -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();
}
});
}
}
}
}

@ -5,6 +5,10 @@
</template>
<script>
export default {
props: ['title', 'name', 'value', 'data', 'mode']
props: ['title', 'name', 'value', 'data', 'mode'], watch: {
value(val) {
this.$emit('update:value', val)
},
}
};
</script>

@ -6,6 +6,11 @@
<script>
export default {
props: ['title', 'name', 'value', 'data'],
watch: {
value(val) {
this.$emit('update:value', val)
},
},
mounted: function () {
$(this.$refs.cron).jqCron({
lang: 'cn',

@ -1,13 +1,19 @@
<template>
<div>
<input ref="input" type="text" style="visibility: hidden; position: absolute;" :value="src" />
<a ref="link" style="display:block;" :href="src"><img ref="img" style="height:32px;" :src="src" /></a>
<a ref="link" :href="src"><img ref="img" style="height:32px;" :src="src" /></a>
<br />
<button ref="btn" class="btn btn-sm btn-default" type="button" id="btn_Image" style="margin-top:5px;">上传</button>
</div>
</template>
<script>
export default {
props: ['value'],
watch: {
value(val) {
this.$emit('update:value', val)
},
},
mounted: function () {
var vm = this;
$(this.$refs.link).fancybox();

@ -3,6 +3,11 @@
</template>
<script>
export default {
props: ['title', 'name', 'value', 'data']
props: ['title', 'name', 'value', 'data'],
watch: {
value(val) {
this.$emit('update:value', val)
},
},
};
</script>

@ -5,7 +5,11 @@
</template>
<script>
export default {
props: ['name', 'value'],
props: ['name', 'value'], watch: {
value(val) {
this.$emit('update:value', val)
},
},
mounted: function () {
var vm = this;
var editor = KindEditor.create('textarea[name="' + this.name + '"]', {

@ -10,7 +10,11 @@
</template>
<script>
export default {
props: ['name', 'value', 'valid', 'data', 'prefix'],
props: ['name', 'value', 'valid', 'data', 'prefix'], watch: {
value(val) {
this.$emit('update:value', val)
},
},
mounted: function () {
this.$nextTick(function () {
$(this.$refs.select).treeMultiselect({

@ -12,6 +12,11 @@
<script>
export default {
props: ['name', 'value', 'valid', 'data', 'prefix'],
watch: {
value(val) {
this.$emit('update:value', val)
},
},
computed: {
list: function () {
var key = this.name;

@ -6,5 +6,10 @@
<script>
export default {
props: ['name', 'value', 'valid', 'data', 'prefix'],
watch: {
value(val) {
this.$emit('update:value', val)
},
}
};
</script>

@ -12,7 +12,7 @@
<div class="form-group row">
<label class="col-sm-3 col-form-label" :for="key">{{value.title}}:</label>
<div class="col-sm-9">
<component :is="getQueryComponent(value)" :title="value.title" :name="'query.'+key" :value="data.model.query[key]" :data="data.data" :prefix="'query'" :mode="'query'" v-if="data.model.query" />
<component :is="getQueryComponent(value)" :title="value.title" :name="'query.'+key" :value="data.model.query[key]" :data="data.data" :prefix="'query'" mode="query" v-if="data.model.query" />
</div>
</div>
</div>
@ -50,7 +50,7 @@
<input type="checkbox" name="list[]" :value="item.id" />
</td>
<td v-for="(value,key,index) in data.schema.properties" v-if="showForList(key,value)">
<component :is="getDisplayComponent(key)" v-bind:name="key" v-bind:value="item[key]" v-bind:data="data.data" :mode="'list'" />
<component :is="getDisplayComponent(key)" v-bind:name="key" v-bind:value="item[key]" v-bind:data="data.data" mode="list" />
</td>
<td v-if="hasPermission('Edit')">
<router-link :to="{path:'/router/shared/edit.html',query:{mode:'Edit',entity:entity,id:item.id}}" class="btn btn-sm btn-default">编辑</router-link>

Loading…
Cancel
Save