126 lines
4.8 KiB
Plaintext
126 lines
4.8 KiB
Plaintext
@model IEnumerable<YLErp.Web.App_Start.AppConfig.ConfigFieldAttributeDto>
|
|
|
|
@{
|
|
ViewData["Title"] = "当前系统配置";
|
|
}
|
|
|
|
@section heads{
|
|
<style>
|
|
body { padding-bottom: 50px; }
|
|
input[type=checkbox] { width: 18px; height: 18px; vertical-align: middle; margin-top: -3px; margin-right: 2px; }
|
|
hr { margin-top: 1rem; margin-bottom: 1rem; }
|
|
|
|
.popover {
|
|
max-width: 450px;
|
|
}
|
|
</style>
|
|
}
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">当前系统配置</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<form id="form1" onsubmit="return false;">
|
|
@foreach (var attr in Model)
|
|
{
|
|
var label = attr.Description;
|
|
<div>
|
|
@if (attr.FieldType == typeof(Boolean))
|
|
{
|
|
<label>
|
|
<input type="checkbox" name="@(attr.FieldName)" @("True" == attr.FieldValue ? "checked" : "") value="true" />
|
|
@(label)
|
|
</label>
|
|
}
|
|
else if (attr.FieldType == typeof(String))
|
|
{
|
|
<div style="font-weight:700">@(label)</div>
|
|
if (!string.IsNullOrWhiteSpace(attr.DataMapString))
|
|
{
|
|
<textarea name="@(attr.FieldName)" rows="2" class="form-control">@(attr.FieldValue)</textarea>
|
|
<button type="button" class="btn btn-link has-popover" data-toggle="popover" data-placement="bottom" title="参数说明" data-content="@Html.Raw(attr.DataMapString.Trim().Replace("\n", "<br>"))">配置参数说明</button>
|
|
}
|
|
else
|
|
{
|
|
<input type="text" name="@(attr.FieldName)" value="@(attr.FieldValue)" class="form-control" style="display:inline-block;width:500px" />
|
|
}
|
|
}
|
|
else if (attr.FieldType == typeof(int))
|
|
{
|
|
if (attr.IsFlags && !string.IsNullOrWhiteSpace(attr.DataMapString))
|
|
{
|
|
<label class="mr-2">@(label):</label>
|
|
var flags = int.Parse(attr.FieldValue);
|
|
var nv = YieldChain.Helpers.UrlHelper.ParseQueryString(attr.DataMapString);
|
|
foreach (var key in nv.AllKeys)
|
|
{
|
|
var chked = (int.Parse(nv[key]) & flags) > 0;
|
|
<label class="mr-1"><input type="checkbox" @(chked ? "checked" : "") value="@(nv[key])" onchange="_config.changeFlags()" />@(key)</label>
|
|
}
|
|
<input type="hidden" class="flags" name="@(attr.FieldName)" value="@(attr.FieldValue)" />
|
|
}
|
|
}
|
|
</div>
|
|
<hr />
|
|
}
|
|
</form>
|
|
<div>
|
|
<button class="btn btn-primary" style="width:120px;" onclick="_config.save()">保存配置</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@section scripts{
|
|
<script>
|
|
var saveUrl = '@Url.Action("AjaxSaveWebConfig")';
|
|
|
|
const OtcWebConfig = function (options) {
|
|
|
|
if (!options || !options.saveUrl) {
|
|
alert("缺少配置参数:saveUrl");
|
|
return;
|
|
}
|
|
|
|
//保存配置
|
|
this.save = function () {
|
|
$.post(options.saveUrl, $('#form1').serialize()).done(function (resp) {
|
|
if (resp.errcode) {
|
|
layer.alert(resp.errmsg);
|
|
} else {
|
|
layer.msg('保存成功');
|
|
}
|
|
}).fail(function () {
|
|
layer.alert('请求失败');
|
|
});
|
|
};
|
|
|
|
this.changeFlags = function () {
|
|
var $e = $(event.target);
|
|
var flag = parseInt($e.val());
|
|
if (!flag) {
|
|
alert('程序错误1');
|
|
return;
|
|
}
|
|
var $ef = $e.parent().nextAll('.flags');
|
|
var flags = parseInt($ef.val());
|
|
if (isNaN(flags) || flags < 0) {
|
|
alert('程序错误2');
|
|
return;
|
|
}
|
|
if ($e.prop('checked')) {
|
|
flags |= flag;
|
|
} else {
|
|
flags ^= flag;
|
|
}
|
|
$ef.val(flags);
|
|
};
|
|
};
|
|
|
|
const _config = new OtcWebConfig({ saveUrl: saveUrl });
|
|
|
|
$(function () {
|
|
$('.has-popover').popover({ html:true});
|
|
});
|
|
</script>
|
|
}
|