This commit is contained in:
張家睿 2024-04-24 17:49:18 +08:00
commit c1e92638f9
3 changed files with 25 additions and 13 deletions

View File

@ -54,7 +54,7 @@ namespace Backend.Controllers
{ {
var sqlString = @$"select v.system_value value, v.system_key name var sqlString = @$"select v.system_value value, v.system_key name
from ( from (
select main_system_tag from building_menu bm where bm.building_tag = @building_tag group by bm.main_system_tag select main_system_tag from building_menu bm where bm.building_tag = @building_tag and is_link = 1 group by bm.building_tag,bm.main_system_tag
) bm ) bm
join variable v on v.system_value = bm.main_system_tag AND v.system_type = @main_system_type and v.deleted = 0 join variable v on v.system_value = bm.main_system_tag AND v.system_type = @main_system_type and v.deleted = 0
ORDER BY v.system_priority ASC"; ORDER BY v.system_priority ASC";
@ -108,12 +108,12 @@ namespace Backend.Controllers
List<KeyValue> KeyValue = new List<KeyValue>(); List<KeyValue> KeyValue = new List<KeyValue>();
try try
{ {
var mainList = await backendRepository.GetAllAsync<int>("select id from variable where system_value = @main_system_tag and system_type = @main_system_type", new { main_system_tag = post.main_system_tag, main_system_type = main_system_type}); var mainList = await backendRepository.GetAllAsync<int>("select id from variable where system_value = @main_system_tag and system_type = @main_system_type and deleted = 0", new { main_system_tag = post.main_system_tag, main_system_type = main_system_type});
var sqlString = @$"select var sqlString = @$"select
sv.system_value value, sv.system_key name sv.system_value value, sv.system_key name
from variable sv from variable sv
left join ( left join (
select * from building_menu bm where bm.building_tag = @building_tag select * from building_menu bm where bm.building_tag = @building_tag and is_link = 1
) bm ) bm
on sv.system_value = bm.sub_system_tag on sv.system_value = bm.sub_system_tag
where bm.sub_system_tag is null and sv.deleted = 0 and sv.system_parent_id in @mainList ORDER BY sv.system_priority ASC, sv.created_at DESC"; where bm.sub_system_tag is null and sv.deleted = 0 and sv.system_parent_id in @mainList ORDER BY sv.system_priority ASC, sv.created_at DESC";
@ -139,7 +139,7 @@ namespace Backend.Controllers
ApiResult<string> apiResult = new ApiResult<string>(); ApiResult<string> apiResult = new ApiResult<string>();
try try
{ {
var get = await backendRepository.GetOneAsync<BuildMenu>("building_menu", $"building_tag = '{buildMenu.building_tag}' and main_system_tag = '{buildMenu.main_system_tag}' and sub_system_tag = '{buildMenu.sub_system_tag}'"); var get = await backendRepository.GetOneAsync<BuildMenu>("building_menu", $"building_tag = '{buildMenu.building_tag}' and main_system_tag = '{buildMenu.main_system_tag}' and sub_system_tag = '{buildMenu.sub_system_tag}' and is_link = 1");
if (get == null) if (get == null)
{ {
var subV = await backendRepository.GetOneAsync<VariableInfo>("variable", "system_value = @sub_tag and system_type = @sub_system_type", new { sub_tag = buildMenu.sub_system_tag, sub_system_type = sub_system_type }); var subV = await backendRepository.GetOneAsync<VariableInfo>("variable", "system_value = @sub_tag and system_type = @sub_system_type", new { sub_tag = buildMenu.sub_system_tag, sub_system_type = sub_system_type });
@ -233,7 +233,7 @@ namespace Backend.Controllers
await backendRepository.AddOneByCustomTable(dictionary, "building_menu"); await backendRepository.AddOneByCustomTable(dictionary, "building_menu");
var max = await backendRepository.GetOneAsync<int>("select Max(CONVERT(SUBSTRING(AuthCode,2,5), SIGNED)) AuthCode from auth_page ap where ap.AuthCode like 'F%'"); var max = await backendRepository.GetOneAsync<int>("select ifnull((select Max(CONVERT(SUBSTRING(AuthCode,2,5), SIGNED)) AuthCode from auth_page ap where ap.AuthCode like 'F%'),'0') AuthCode");
var pageSql = $@"select sv.system_key SubName, mv.system_key MainName var pageSql = $@"select sv.system_key SubName, mv.system_key MainName
from variable sv from variable sv
@ -494,7 +494,7 @@ namespace Backend.Controllers
from ( from (
select * select *
from sub_system_floor ssf from sub_system_floor ssf
where ssf.building_tag = @building_tag and ssf.main_system_tag = @main_system_tag and ssf.sub_system_tag = @sub_system_tag and deleted = 0 and status = 0 where ssf.building_tag = @building_tag and ssf.main_system_tag = @main_system_tag and ssf.sub_system_tag = @sub_system_tag and deleted = 0 and status = 0 and is_link = 1
) sf ) sf
left join floor f on sf.floor_tag = f.full_name and sf.building_tag = f.building_tag and f.deleted = 0 left join floor f on sf.floor_tag = f.full_name and sf.building_tag = f.building_tag and f.deleted = 0
left join variable mv on sf.main_system_tag = mv.system_value and mv.system_type = @main_system_type and mv.deleted = 0 left join variable mv on sf.main_system_tag = mv.system_value and mv.system_type = @main_system_type and mv.deleted = 0

View File

@ -129,7 +129,10 @@ namespace Backend.Controllers
var floorRawDatas = subSystemFloorRawDatas.Where(x => x.building_tag == buildingCollapse.Building_tag var floorRawDatas = subSystemFloorRawDatas.Where(x => x.building_tag == buildingCollapse.Building_tag
&& x.main_system_tag == main_System.Main_system_tag && x.main_system_tag == main_System.Main_system_tag
&& x.sub_system_tag == sub_System.Sub_system_tag).ToList(); && x.sub_system_tag == sub_System.Sub_system_tag).ToList();
if (floorRawDatas.Count == 0 ) // 如果沒有相關小類樓層則不顯示
{
continue;
}
foreach (var floorRawData in floorRawDatas) foreach (var floorRawData in floorRawDatas)
{ {
Floor floor = new Floor(); Floor floor = new Floor();

View File

@ -82,7 +82,8 @@
設備基本資料 設備基本資料
</div> </div>
<div class="ml-auto"> <div class="ml-auto">
<a href="javascript:;" class="btn btn-success waves-effect waves-themed" id="addDevice-btn" onclick="AddDevice()"><span class="fal fa-plus mr-1"></span>新增設備</a> @*隱藏新增按鈕
<a href="javascript:;" class="btn btn-success waves-effect waves-themed" id="addDevice-btn" onclick="AddDevice()"><span class="fal fa-plus mr-1"></span>新增設備</a>*@
<a href="javascript:;" class="btn btn-primary waves-effect waves-themed" id="device-master-list-btn" style="display:none"><span class="fal fa-plus mr-1"></span>分電盤</a> <a href="javascript:;" class="btn btn-primary waves-effect waves-themed" id="device-master-list-btn" style="display:none"><span class="fal fa-plus mr-1"></span>分電盤</a>
</div> </div>
</div> </div>
@ -700,13 +701,21 @@
"data": null, "data": null,
"createdCell": function (td, cellData, rowData, row, col) { "createdCell": function (td, cellData, rowData, row, col) {
$(td).empty(); $(td).empty();
if (rowData != null && (rowData.device_name_tag == "L1" || rowData.device_name_tag == "L2")) { @*if (rowData != null && (rowData.device_name_tag == "L1" || rowData.device_name_tag == "L2")) {
$(td).html(` $(td).html(`
<button class="btn btn-primary edit-btn">修改</button> <button class="btn btn-primary edit-btn">修改</button>
<button class="btn btn-info add-device-node-btn">加入子節點</button> <button class="btn btn-info add-device-node-btn">加入子節點</button>
<button class="btn btn-danger del-btn">刪除</button>`) <button class="btn btn-danger del-btn">刪除</button>`)
} else { } else {
$(td).html(`<button class="btn btn-primary edit-btn">修改</button> <button class="btn btn-danger del-btn">刪除</button>`) $(td).html(`<button class="btn btn-primary edit-btn">修改</button> <button class="btn btn-danger del-btn">刪除</button>`)
}*@
// 隱藏刪除按鈕
if (rowData != null && (rowData.device_name_tag == "L1" || rowData.device_name_tag == "L2")) {
$(td).html(`
<button class="btn btn-primary edit-btn">修改</button>
<button class="btn btn-info add-device-node-btn">加入子節點</button>`)
} else {
$(td).html(`<button class="btn btn-primary edit-btn">修改</button>`)
} }
}, },