回收记录界面展示:
1.增加单价/金额/操作员; 2.支持用户自定义展示列; 2.支持管理员自定义列名/是否展示;
This commit is contained in:
parent
49bd413766
commit
9125b98045
|
|
@ -146,6 +146,27 @@ namespace Waste.Application
|
|||
/// 上报是否成功,1-成功,0-失败
|
||||
/// </summary>
|
||||
public int PostStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物品小类
|
||||
/// </summary>
|
||||
public string Measure_WasteSType { get; set; }
|
||||
/// <summary>
|
||||
/// 价格
|
||||
/// </summary>
|
||||
public decimal? Measure_Price { get; set; }
|
||||
/// <summary>
|
||||
/// 金额
|
||||
/// </summary>
|
||||
public decimal? Measure_Amount { get; set; }
|
||||
/// <summary>
|
||||
/// 操作员
|
||||
/// </summary>
|
||||
public string Measure_OpUser { get; set; }
|
||||
/// <summary>
|
||||
/// 唯一消息ID
|
||||
/// </summary>
|
||||
public string Measure_UUID { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -145,6 +145,11 @@ namespace Waste.Application
|
|||
});
|
||||
var ext = allext.FirstOrDefault(e => e.ResultId == it.Id);
|
||||
it.WasteType = ext != null && !ext.WasteSType.IsEmpty() ? $"{ext.WasteSType}【{it.WasteType}】" : it.WasteType;
|
||||
it.Measure_WasteSType = ext?.WasteSType;
|
||||
it.Measure_Price = ext?.Price;
|
||||
it.Measure_Amount = ext?.Amount;
|
||||
it.Measure_OpUser = ext?.OpUser;
|
||||
it.Measure_UUID = ext?.UUID;
|
||||
})
|
||||
.ToPageListAsync(param.offset, param.limit, totalnum);
|
||||
return new PageParms<ResultList>
|
||||
|
|
|
|||
|
|
@ -1722,6 +1722,31 @@
|
|||
上报是否成功,1-成功,0-失败
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.ResultList.Measure_WasteSType">
|
||||
<summary>
|
||||
物品小类
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.ResultList.Measure_Price">
|
||||
<summary>
|
||||
价格
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.ResultList.Measure_Amount">
|
||||
<summary>
|
||||
金额
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.ResultList.Measure_OpUser">
|
||||
<summary>
|
||||
操作员
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.ResultList.Measure_UUID">
|
||||
<summary>
|
||||
唯一消息ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.MyPackage">
|
||||
<summary>
|
||||
上传的数据包体
|
||||
|
|
@ -2398,6 +2423,36 @@
|
|||
上报时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscribeS2SDto.ecode">
|
||||
<summary>
|
||||
设备机器码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscribeS2SDto.faccode">
|
||||
<summary>
|
||||
设备编号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscribeS2SDto.province">
|
||||
<summary>
|
||||
设备所属省份
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscribeS2SDto.city">
|
||||
<summary>
|
||||
设备所属城市
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscribeS2SDto.area">
|
||||
<summary>
|
||||
设备所属区/县
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscribeS2SDto.address">
|
||||
<summary>
|
||||
设备详细地址
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.SubscribeInfo.SendThirdMessageSubscriDto">
|
||||
<summary>
|
||||
发送第三方消息
|
||||
|
|
@ -2448,6 +2503,41 @@
|
|||
设备ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.ecode">
|
||||
<summary>
|
||||
设备机器码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.faccode">
|
||||
<summary>
|
||||
设备编号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.province">
|
||||
<summary>
|
||||
设备所属省份
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.city">
|
||||
<summary>
|
||||
设备所属城市
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.area">
|
||||
<summary>
|
||||
设备所属区/县
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.address">
|
||||
<summary>
|
||||
设备详细地址
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.BeatTime">
|
||||
<summary>
|
||||
最近心跳时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.SubscribeInfo.ISubscribeService">
|
||||
<summary>
|
||||
CAP订阅相关接口
|
||||
|
|
|
|||
|
|
@ -0,0 +1,311 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Furion.DependencyInjection;
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore.Query.Internal;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Waste.Domain
|
||||
{
|
||||
public class JT_Setting
|
||||
{
|
||||
public JT_Setting() { }
|
||||
public JT_Setting(Guid id, string name, string value, string providerName, string providerKey)
|
||||
{
|
||||
this.Id = id;
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
this.ProviderName = providerName;
|
||||
this.ProviderKey = providerKey;
|
||||
}
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
|
||||
public string ProviderName { get; set; }
|
||||
public string ProviderKey { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{base.ToString()}, Name = {Name}, Value = {Value}, ProviderName = {ProviderName}, ProviderKey = {ProviderKey}";
|
||||
}
|
||||
}
|
||||
public class SettingProvider : ITransient
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
private readonly SettingDefinitionManager SettingDefinitionManager;
|
||||
private readonly SettingValueProviderManager SettingValueProviderManager;
|
||||
|
||||
|
||||
public SettingProvider(IServiceProvider serviceProvider, SettingDefinitionManager settingDefinitionManager, SettingValueProviderManager settingValueProviderManager)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
SettingDefinitionManager = settingDefinitionManager;
|
||||
SettingValueProviderManager = settingValueProviderManager;
|
||||
}
|
||||
|
||||
public virtual async Task<string?> GetOrNullAsync(string name)
|
||||
{
|
||||
var setting = await SettingDefinitionManager.GetAsync(name);
|
||||
var providers = Enumerable
|
||||
.Reverse(SettingValueProviderManager.Providers);
|
||||
|
||||
if (setting.Providers.Any())
|
||||
{
|
||||
providers = providers.Where(p => setting.Providers.Contains(p.Name));
|
||||
}
|
||||
|
||||
//TODO: How to implement setting.IsInherited?
|
||||
|
||||
var value = await GetOrNullValueFromProvidersAsync(providers, setting);
|
||||
/* if (value != null && setting.IsEncrypted)
|
||||
{
|
||||
value = SettingEncryptionService.Decrypt(setting, value);
|
||||
}*/
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected virtual async Task<string?> GetOrNullValueFromProvidersAsync(
|
||||
IEnumerable<SettingValueProvider> providers,
|
||||
SettingDefinition setting)
|
||||
{
|
||||
foreach (var provider in providers)
|
||||
{
|
||||
var value = await provider.GetOrNullAsync(setting);
|
||||
if (value != null)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class SettingDefinitionManager : ISingleton
|
||||
{
|
||||
protected IDictionary<string, SettingDefinition> SettingDefinitions { get; } =
|
||||
new Dictionary<string, SettingDefinition>();
|
||||
|
||||
public SettingDefinitionManager AddSettingDefinition(SettingDefinition settingDefinition)
|
||||
{
|
||||
SettingDefinitions[settingDefinition.Name] = settingDefinition;
|
||||
return this;
|
||||
}
|
||||
public virtual async Task<SettingDefinition> GetAsync(string name)
|
||||
{
|
||||
|
||||
var setting = await GetOrNullAsync(name);
|
||||
|
||||
if (setting == null)
|
||||
{
|
||||
throw new Exception("Undefined setting: " + name);
|
||||
}
|
||||
|
||||
return setting;
|
||||
}
|
||||
public virtual Task<SettingDefinition?> GetOrNullAsync(string name)
|
||||
{
|
||||
return Task.FromResult(GetOrDefault(SettingDefinitions, name));
|
||||
}
|
||||
public static TValue? GetOrDefault<TKey, TValue>(IDictionary<TKey, TValue> dictionary, TKey key)
|
||||
{
|
||||
return dictionary.TryGetValue(key, out var obj) ? obj : default;
|
||||
}
|
||||
}
|
||||
|
||||
public class SettingValueProviderManager : ISingleton
|
||||
{
|
||||
public List<SettingValueProvider> Providers => _lazyProviders.Value;
|
||||
private readonly Lazy<List<SettingValueProvider>> _lazyProviders;
|
||||
protected IServiceProvider ServiceProvider { get; }
|
||||
public SettingValueProviderManager(IServiceProvider serviceProvider)
|
||||
{
|
||||
ServiceProvider = serviceProvider;
|
||||
_lazyProviders = new Lazy<List<SettingValueProvider>>(GetProviders, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected virtual List<SettingValueProvider> GetProviders()
|
||||
{
|
||||
|
||||
using (var scope = ServiceProvider.CreateScope())
|
||||
|
||||
return new List<SettingValueProvider>()
|
||||
{
|
||||
scope.ServiceProvider.GetRequiredService<DefaultValueSettingValueProvider>(),
|
||||
scope.ServiceProvider.GetRequiredService<GlobalSettingValueProvider>(),
|
||||
scope.ServiceProvider.GetRequiredService<UserSettingValueProvider>(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SettingManagementStore : ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<JT_Setting> repository;
|
||||
|
||||
public SettingManagementStore(ISqlSugarRepository<JT_Setting> repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public virtual async Task<string> GetOrNullAsync(string name, string providerName, string providerKey)
|
||||
{
|
||||
return (await FindAsync(name, providerName, providerKey))?.Value;
|
||||
}
|
||||
public virtual async Task SetAsync(string name, string value, string providerName, string providerKey)
|
||||
{
|
||||
var setting = await FindAsync(name, providerName, providerKey);
|
||||
if (setting == null)
|
||||
{
|
||||
setting = new JT_Setting(Guid.NewGuid(), name, value, providerName, providerKey);
|
||||
await repository.InsertAsync(setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
setting.Value = value;
|
||||
await repository.UpdateAsync(setting);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async Task<JT_Setting> FindAsync(string name, string providerName, string providerKey)
|
||||
{
|
||||
return await repository.Where(x =>
|
||||
x.Name == name && x.ProviderName == providerName)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(providerKey), x => x.ProviderKey == providerKey).FirstAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class SettingValueProvider : ITransient
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
|
||||
protected SettingManagementStore SettingStore { get; }
|
||||
|
||||
protected SettingValueProvider(SettingManagementStore settingStore)
|
||||
{
|
||||
SettingStore = settingStore;
|
||||
}
|
||||
public abstract Task<string?> GetOrNullAsync(SettingDefinition setting);
|
||||
|
||||
protected virtual async Task SetAsync(string name, string value, string providerKey)
|
||||
{
|
||||
await SettingStore.SetAsync(name, value, Name, providerKey);
|
||||
|
||||
}
|
||||
|
||||
protected virtual async Task SetAsync(SettingDefinition setting, string value, string providerKey)
|
||||
{
|
||||
await SettingStore.SetAsync(setting.Name, value, Name, providerKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class GlobalSettingValueProvider : SettingValueProvider
|
||||
{
|
||||
public GlobalSettingValueProvider(SettingManagementStore settingStore) : base(settingStore)
|
||||
{
|
||||
}
|
||||
|
||||
public const string ProviderName = "G";
|
||||
|
||||
public override string Name => ProviderName;
|
||||
|
||||
public override Task<string> GetOrNullAsync(SettingDefinition setting)
|
||||
{
|
||||
return SettingStore.GetOrNullAsync(setting.Name, Name, null);
|
||||
}
|
||||
public Task SetAsync(string name, string value)
|
||||
{
|
||||
return base.SetAsync(name, value, null);
|
||||
}
|
||||
}
|
||||
public class UserSettingValueProvider : SettingValueProvider
|
||||
{
|
||||
public const string ProviderName = "U";
|
||||
|
||||
public override string Name => ProviderName;
|
||||
|
||||
protected ICurrentUser CurrentUser { get; }
|
||||
|
||||
public UserSettingValueProvider(SettingManagementStore settingStore, ICurrentUser currentUser)
|
||||
: base(settingStore)
|
||||
{
|
||||
CurrentUser = currentUser;
|
||||
}
|
||||
|
||||
public override async Task<string?> GetOrNullAsync(SettingDefinition setting)
|
||||
{
|
||||
if (CurrentUser.Id == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return await SettingStore.GetOrNullAsync(setting.Name, Name, CurrentUser.Id.ToString());
|
||||
}
|
||||
|
||||
public Task SetAsync(string name, string value)
|
||||
{
|
||||
return base.SetAsync(name, value, CurrentUser.Id.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public interface ICurrentUser
|
||||
{
|
||||
Guid? Id { get; }
|
||||
}
|
||||
public class DefaultValueSettingValueProvider : SettingValueProvider
|
||||
{
|
||||
public const string ProviderName = "D";
|
||||
|
||||
public override string Name => ProviderName;
|
||||
|
||||
public DefaultValueSettingValueProvider(SettingManagementStore settingStore)
|
||||
: base(settingStore)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override Task<string?> GetOrNullAsync(SettingDefinition setting)
|
||||
{
|
||||
return Task.FromResult(setting.DefaultValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// public Guid UserId { get; set; }
|
||||
|
||||
public class SettingDefinition
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique name of the setting.
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public string Name { get; set; }
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Default value of the setting.
|
||||
/// </summary>
|
||||
public string? DefaultValue { get; set; }
|
||||
/// <summary>
|
||||
/// A list of allowed providers to get/set value of this setting.
|
||||
/// An empty list indicates that all providers are allowed.
|
||||
/// </summary>
|
||||
public List<string> Providers { get; } = new List<string>();
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Furion.DependencyInjection;
|
||||
using Waste.Domain;
|
||||
|
||||
namespace Waste.Web.Entry
|
||||
{
|
||||
|
|
@ -65,4 +67,9 @@ namespace Waste.Web.Entry
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class CurrentUser : ICurrentUser, ITransient
|
||||
{
|
||||
public Guid? Id => OperatorProvider.Provider.GetCurrent()?.UserId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
@page
|
||||
@model Waste.Web.Entry.Pages.Result.GlobalConfigModel
|
||||
@{
|
||||
ViewData["Title"] = "字段配置";
|
||||
}
|
||||
<div class="layui-card">
|
||||
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form" action="" style="text-align:center">
|
||||
@foreach (var item in Model.Column)
|
||||
{
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">@item.SystemTitle</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="@item.Name" lay-verify="required" value="@item.Title" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input type="checkbox" name="show-@item.Name" title="" checked="@item.IsShow">
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button type="submit" class="layui-btn" lay-submit lay-filter="demo1">更新</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script type="text/javascript">
|
||||
layui.use(['form', 'util'], function () {
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
var util = layui.util;
|
||||
|
||||
|
||||
|
||||
|
||||
// 提交事件
|
||||
form.on('submit(demo1)', function (data) {
|
||||
var field = data.field; // 获取表单字段值
|
||||
// 显示填写结果,仅作演示用
|
||||
// layer.alert(JSON.stringify(field), {
|
||||
// title: '当前填写的字段值'
|
||||
// });
|
||||
|
||||
const arr = [];
|
||||
for (const property in field) {
|
||||
if (!property.startsWith('show-')) {
|
||||
arr.push({ Name: property, Title: field[property], IsShow: field['show-' + property] == 'on' })
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
url: "?handler=UpdateConfig",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: JSON.stringify(arr),
|
||||
contentType: "application/json;charset=utf-8",
|
||||
success: function (res) {
|
||||
|
||||
|
||||
},
|
||||
complete: function () {
|
||||
layer.msg('更新成功');
|
||||
},
|
||||
fail: function (res) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return false; // 阻止默认 form 跳转
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.layui-form-label {
|
||||
width: 100px !important;
|
||||
}
|
||||
|
||||
.layui-form-checkbox i {
|
||||
border-left: 1px solid #d2d2d2;
|
||||
}
|
||||
|
||||
.layui-form-item{
|
||||
margin-bottom: 0px !important;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace Waste.Web.Entry.Pages.Result
|
||||
{
|
||||
public class GlobalConfigModel : PageModel
|
||||
{
|
||||
private readonly ResultColumnConfigService columnConfigService;
|
||||
|
||||
public GlobalConfigModel(ResultColumnConfigService columnConfigService)
|
||||
{
|
||||
this.columnConfigService = columnConfigService;
|
||||
}
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
Column = (await columnConfigService.GetGlobalColumn()).Select(x => new GlobalColumnConfigOutput
|
||||
{
|
||||
SystemTitle = ResultColumnConfigService.SystemColumn[x.Name],
|
||||
Name = x.Name,
|
||||
Title = x.Title,
|
||||
IsShow = x.IsShow
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostUpdateConfigAsync([FromBody] List<GlobalColumnConfig> input)
|
||||
{
|
||||
await columnConfigService.WriteGlobalConfig(input);
|
||||
//await service.UpdateAccountConfig(Baseuser.UserId, config);
|
||||
return Content("ok");
|
||||
}
|
||||
|
||||
public IEnumerable<GlobalColumnConfigOutput> Column { get; set; }
|
||||
public class GlobalColumnConfigOutput : GlobalColumnConfig
|
||||
{
|
||||
public string SystemTitle { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -58,6 +58,22 @@
|
|||
@section Scripts
|
||||
{
|
||||
<script type="text/javascript">
|
||||
let defColumn = @Json.Serialize(Model.DefaultColumn);
|
||||
let oColumn = @Json.Serialize(Model.Column);
|
||||
console.log(defColumn)
|
||||
console.log(oColumn)
|
||||
const column = [];
|
||||
for (const property in defColumn) {
|
||||
console.log(`${property}: ${defColumn[property]}`);
|
||||
const col = {
|
||||
field: property, title: defColumn[property], hide: true
|
||||
};
|
||||
oColumn[property] && (col.hide=false)
|
||||
property == 'poststatus' && (col.templet= '#netstatustpl');
|
||||
column.push(col);
|
||||
}
|
||||
console.log(column)
|
||||
|
||||
layui.use(['common'], function () {
|
||||
var common = layui.common;
|
||||
var queryparam = [];
|
||||
|
|
@ -81,63 +97,36 @@
|
|||
where: {
|
||||
queryParam: queryparam
|
||||
}
|
||||
, cols: [[
|
||||
{
|
||||
field: 'devicefacecode', title: '设备编号'
|
||||
},
|
||||
{
|
||||
field: 'deviceecode', title: '机器码', hide: true
|
||||
},
|
||||
{
|
||||
field: 'devicename', title: '设备名称'
|
||||
}
|
||||
,
|
||||
{
|
||||
field: 'businessname', title: '所属商户'
|
||||
}
|
||||
//,
|
||||
//{
|
||||
// field: 'nettype', title: '联网方式', templet: function (d) {
|
||||
// return DeviceNetType[d.nettype];
|
||||
// }
|
||||
//}
|
||||
,
|
||||
{
|
||||
field: 'wastetype', title: '物品编码'
|
||||
}
|
||||
,
|
||||
{
|
||||
field: 'grossweight', title: '毛重(KG)'
|
||||
}
|
||||
,
|
||||
{
|
||||
field: 'registration', title: '垃圾桶'
|
||||
}
|
||||
,
|
||||
{
|
||||
field: 'tare', title: '皮重(KG)', hide: true
|
||||
}
|
||||
,
|
||||
{
|
||||
field: 'netweight', title: '净重(KG)', hide: true
|
||||
}
|
||||
,
|
||||
{
|
||||
field: 'deviceaddress', title: '地址'
|
||||
}
|
||||
,
|
||||
{
|
||||
field: 'poststatus', title: '状态', templet:'#netstatustpl'
|
||||
}
|
||||
,
|
||||
{
|
||||
field: 'createtime', title: '回收时间'
|
||||
}
|
||||
//,
|
||||
//{
|
||||
// title: '操作', templet: "#optpl"
|
||||
//}
|
||||
]]
|
||||
, cols: [column]
|
||||
, done: function () {
|
||||
// 记录筛选状态
|
||||
const that = this;
|
||||
that.elem.next().on('mousedown', 'input[lay-filter="LAY_TABLE_TOOL_COLS"]+', function () {
|
||||
const input = $(this).prev()[0];
|
||||
console.log('LAY_TABLE_TOOL_COLS', {
|
||||
key: input.name
|
||||
, value: input.checked
|
||||
});
|
||||
|
||||
!input.checked ? (oColumn[input.name] = input.title): (oColumn[input.name]=null)
|
||||
$.ajax({
|
||||
url: "?handler=UpdateAccountConfig",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: JSON.stringify(Object.keys(oColumn).filter(x=>oColumn[x]).map(x=>({name:x,title:oColumn[x]}))),
|
||||
contentType: "application/json;charset=utf-8",
|
||||
success: function (res) {
|
||||
|
||||
},
|
||||
complete: function () {
|
||||
|
||||
},
|
||||
fail: function (res) {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
$(".js-search").on("click", function () {
|
||||
var queryparam = [{
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Furion;
|
||||
using Furion.DatabaseAccessor;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Waste.Application;
|
||||
using Waste.Domain;
|
||||
|
||||
|
||||
namespace Waste.Web.Entry.Pages.Result
|
||||
{
|
||||
|
|
@ -13,9 +21,44 @@ namespace Waste.Web.Entry.Pages.Result
|
|||
public class IndexModel : BaseModel
|
||||
{
|
||||
public string defaulttime = "";
|
||||
public void OnGet()
|
||||
|
||||
private readonly ResultColumnConfigService columnConfigService;
|
||||
|
||||
public IndexModel(ResultColumnConfigService columnConfigService)
|
||||
{
|
||||
|
||||
this.columnConfigService = columnConfigService;
|
||||
}
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
defaulttime = $"{DateTime.Now.Date} ~ {DateTime.Now.Date.AddDays(1).AddSeconds(-1)}";
|
||||
|
||||
|
||||
//var value = await service.GetAccountConfig(Baseuser.UserId);
|
||||
Column = await columnConfigService.GetAccountColumn();
|
||||
|
||||
DefaultColumn = await columnConfigService.GetAccountDefaultColumn();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<IActionResult> OnPostUpdateAccountConfigAsync([FromBody] List<ColumnConfig> input)
|
||||
{
|
||||
await columnConfigService.WriteAccountConfig(input);
|
||||
//await service.UpdateAccountConfig(Baseuser.UserId, config);
|
||||
return Content("ok");
|
||||
}
|
||||
|
||||
public Dictionary<string, string> Column { get; set; }
|
||||
//private static Dictionary<string, string> EmptyColumn = new Dictionary<string, string>();
|
||||
|
||||
public Dictionary<string, string> DefaultColumn = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,206 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Formats.Asn1;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Furion;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.JsonSerialization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Waste.Application;
|
||||
using Waste.Domain;
|
||||
|
||||
namespace Waste.Web.Entry.Pages.Result
|
||||
{
|
||||
public class ResultColumnConfigService : ITransient
|
||||
{
|
||||
public const string AccountSettingDefinitionName = "AccountResultColumnConfig";
|
||||
public const string GlobalSettingDefinitionName = "GlobalResultColumnConfig";
|
||||
private readonly ILogger<ResultColumnConfigService> logger;
|
||||
private readonly SettingProvider settingProvider;
|
||||
private readonly UserSettingValueProvider userSettingValueProvider;
|
||||
private readonly GlobalSettingValueProvider globalSettingValueProvider;
|
||||
|
||||
public static readonly Dictionary<string, string> SystemColumn = new Dictionary<string, string>()
|
||||
{
|
||||
{nameof(ResultList.DeviceFacEcode).ToLower(),"设备编号"},
|
||||
{nameof(ResultList.DeviceEcode).ToLower(),"机器码"},
|
||||
{nameof(ResultList.DeviceName).ToLower(),"设备名称"},
|
||||
{nameof(ResultList.BusinessName).ToLower(),"所属商户"},
|
||||
{nameof(ResultList.WasteType).ToLower(),"物品编码"},
|
||||
{nameof(ResultList.GrossWeight).ToLower(),"毛重(KG)"},
|
||||
{nameof(ResultList.Registration).ToLower(),"垃圾桶"},
|
||||
{nameof(ResultList.Tare).ToLower(),"皮重(KG)"},
|
||||
{nameof(ResultList.NetWeight).ToLower(),"净重(KG)"},
|
||||
{nameof(ResultList.DeviceAddress).ToLower(),"地址"},
|
||||
{nameof(ResultList.PostStatus).ToLower(),"状态"},
|
||||
{nameof(ResultList.CreateTime).ToLower(),"回收时间"},
|
||||
{nameof(ResultList.Measure_Price).ToLower(),"单价"},
|
||||
{nameof(ResultList.Measure_Amount).ToLower(),"金额"},
|
||||
{nameof(ResultList.Measure_OpUser).ToLower(),"操作员"},
|
||||
{nameof(ResultList.Measure_UUID).ToLower(),"消息ID"},
|
||||
{nameof(ResultList.Measure_WasteSType).ToLower(),"物品小类"},
|
||||
};
|
||||
|
||||
public ResultColumnConfigService(ILogger<ResultColumnConfigService> logger, SettingProvider settingProvider, UserSettingValueProvider userSettingValueProvider, GlobalSettingValueProvider globalSettingValueProvider)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.settingProvider = settingProvider;
|
||||
this.userSettingValueProvider = userSettingValueProvider;
|
||||
this.globalSettingValueProvider = globalSettingValueProvider;
|
||||
}
|
||||
|
||||
private Task<Dictionary<string, string>> GetDefaultColumn()
|
||||
{
|
||||
return Task.FromResult(SystemColumn);
|
||||
}
|
||||
public async Task<Dictionary<string, string>> GetAccountDefaultColumn()
|
||||
{
|
||||
return (await GetGlobalColumn()).Where(x => x.IsShow).ToDictionary(x => x.Name, x => x.Title);
|
||||
}
|
||||
public async Task<List<GlobalColumnConfig>> GetGlobalColumn()
|
||||
{
|
||||
var def = await GetDefaultColumn();
|
||||
var value = await settingProvider.GetOrNullAsync(GlobalSettingDefinitionName);
|
||||
if (string.IsNullOrWhiteSpace(value)) return DefaultList();
|
||||
|
||||
try
|
||||
{
|
||||
var config = JSON.Deserialize<GlobalConfig>(value);
|
||||
if (config.ResultColumn != null && config.ResultColumn.Any())
|
||||
{
|
||||
return config.ResultColumn.GroupBy(x => x.Name)
|
||||
.Where(x => def.ContainsKey(x.Key))
|
||||
.Select(x =>
|
||||
new GlobalColumnConfig { Name = x.Key, Title = x.First().Title, IsShow = x.First().IsShow }).ToList();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, "反序列化失败:{value}", value);
|
||||
|
||||
}
|
||||
return DefaultList();
|
||||
|
||||
List<GlobalColumnConfig> DefaultList()
|
||||
{
|
||||
return def.Select(x =>
|
||||
new GlobalColumnConfig { Name = x.Key, Title = x.Value, IsShow = true }).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<Dictionary<string, string>> GetAccountColumn()
|
||||
{
|
||||
var _GlobalColumn = (await GetGlobalColumn()).Where(x => SystemColumn.ContainsKey(x.Name) && x.IsShow).ToDictionary(x => x.Name, x => string.IsNullOrWhiteSpace(x.Title) ? SystemColumn[x.Name] : x.Title);
|
||||
var value = await settingProvider.GetOrNullAsync(AccountSettingDefinitionName);
|
||||
if (string.IsNullOrWhiteSpace(value)) return _GlobalColumn;
|
||||
|
||||
try
|
||||
{
|
||||
var config = JSON.Deserialize<AccountConfig>(value);
|
||||
if (config.ResultColumn != null && config.ResultColumn.Any())
|
||||
{
|
||||
return config.ResultColumn.GroupBy(x => x.Name)
|
||||
.Where(x => _GlobalColumn.ContainsKey(x.Key))
|
||||
.ToDictionary(x => x.Key,
|
||||
//x => x.First().Title
|
||||
x => _GlobalColumn[x.Key]
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, "反序列化失败:{value}", value);
|
||||
}
|
||||
|
||||
return _GlobalColumn;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task WriteAccountConfig(List<ColumnConfig> ResultColumn)
|
||||
{
|
||||
var value = SerializeConfig(ResultColumn, SystemColumn);
|
||||
await userSettingValueProvider.SetAsync(AccountSettingDefinitionName, value);
|
||||
}
|
||||
|
||||
public static string SerializeConfig(List<ColumnConfig> ResultColumn, Dictionary<string, string> DefaultColumn)
|
||||
{
|
||||
if (ResultColumn != null && ResultColumn.Any())
|
||||
{
|
||||
return JSON.Serialize(new AccountConfig
|
||||
{ ResultColumn = ResultColumn.GroupBy(x => x.Name).Where(x => DefaultColumn.ContainsKey(x.Key) && x.Any()).Select(x => new ColumnConfig { Name = x.Key/*, Title = x.First().Title*/ }).ToList() });
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task WriteGlobalConfig(List<GlobalColumnConfig> ResultColumn)
|
||||
{
|
||||
var value = SerializeConfig(ResultColumn, SystemColumn);
|
||||
await globalSettingValueProvider.SetAsync(GlobalSettingDefinitionName, value);
|
||||
}
|
||||
|
||||
public static string SerializeConfig(List<GlobalColumnConfig> ResultColumn, Dictionary<string, string> DefaultColumn)
|
||||
{
|
||||
if (ResultColumn != null && ResultColumn.Any())
|
||||
{
|
||||
return JSON.Serialize(new GlobalConfig
|
||||
{ ResultColumn = ResultColumn.Where(x => DefaultColumn.ContainsKey(x.Name)).ToList() });
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ResultColumnConfigStartup : AppStartup
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
app.ApplicationServices.GetRequiredService<SettingDefinitionManager>()
|
||||
.AddSettingDefinition(new SettingDefinition()
|
||||
{
|
||||
Name = ResultColumnConfigService.GlobalSettingDefinitionName,
|
||||
Providers = { GlobalSettingValueProvider.ProviderName }
|
||||
})
|
||||
.AddSettingDefinition(new SettingDefinition()
|
||||
{
|
||||
Name = ResultColumnConfigService.AccountSettingDefinitionName,
|
||||
Providers = { UserSettingValueProvider.ProviderName }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class AccountConfig
|
||||
{
|
||||
public List<ColumnConfig> ResultColumn { get; set; }
|
||||
}
|
||||
public class GlobalConfig
|
||||
{
|
||||
public List<GlobalColumnConfig> ResultColumn { get; set; }
|
||||
}
|
||||
|
||||
public class ColumnConfig
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class GlobalColumnConfig : ColumnConfig
|
||||
{
|
||||
//public string SystemTitle { get; set; }
|
||||
public string Title { get; set; }
|
||||
public bool IsShow { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue