Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
		
						commit
						8f54db2c24
					
				@ -19,12 +19,14 @@ namespace Backend.Controllers
 | 
			
		||||
    {
 | 
			
		||||
        private readonly IBackendRepository backendRepository;
 | 
			
		||||
        private string mapFileSaveAsPath = "";
 | 
			
		||||
        private string buildMapFileSaveAsPath = "";
 | 
			
		||||
 | 
			
		||||
        public BuildInfoController(IBackendRepository backendRepository)
 | 
			
		||||
        {
 | 
			
		||||
            this.backendRepository = backendRepository;
 | 
			
		||||
 | 
			
		||||
            mapFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "floor_map");
 | 
			
		||||
            buildMapFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "build_map");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IActionResult Index()
 | 
			
		||||
@ -44,7 +46,8 @@ namespace Backend.Controllers
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var sqlString = @$"SELECT A.priority, A.building_tag, A.full_name, A.ip_address, A.ip_port, (SELECT COUNT(*) FROM floor f WHERE f.deleted = 0 AND f.building_tag = A.building_tag) AS 'floorNum', A.created_at
 | 
			
		||||
                var sqlString = @$"SELECT A.priority, A.building_tag, A.full_name, A.ip_address, A.ip_port, (SELECT COUNT(*) FROM floor f WHERE f.deleted = 0 AND f.building_tag = A.building_tag) AS 'floorNum', A.created_at,
 | 
			
		||||
                                        A.orgName_3D, A.extName_3D
 | 
			
		||||
                                   FROM building A
 | 
			
		||||
                                   WHERE A.deleted = 0
 | 
			
		||||
                                   ORDER BY A.priority ASC, A.created_at DESC";
 | 
			
		||||
@ -69,7 +72,7 @@ namespace Backend.Controllers
 | 
			
		||||
        /// <param name="post"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<string>> SaveBuildInfo(BuildInfo post)
 | 
			
		||||
        public async Task<ApiResult<string>> SaveBuildInfo([FromForm] BuildInfo post)
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<string> apiResult = new ApiResult<string>();
 | 
			
		||||
 | 
			
		||||
@ -101,6 +104,7 @@ namespace Backend.Controllers
 | 
			
		||||
                    //新增
 | 
			
		||||
                    //抓取當前的Priority
 | 
			
		||||
                    var current_priority = await backendRepository.GetCurrentPriority("building");
 | 
			
		||||
                    var map_3d_guid = new Guid();
 | 
			
		||||
 | 
			
		||||
                    Dictionary<string, object> building = new Dictionary<string, object>();
 | 
			
		||||
                    building = new Dictionary<string, object>()
 | 
			
		||||
@ -110,10 +114,28 @@ namespace Backend.Controllers
 | 
			
		||||
                        { "@ip_address", post.Ip_address},
 | 
			
		||||
                        { "@ip_port", post.Ip_port},
 | 
			
		||||
                        { "@priority", current_priority + 1},
 | 
			
		||||
                        { "@orgName_3D", post.orgName_3D},
 | 
			
		||||
                        { "@saveName_3D", map_3d_guid},
 | 
			
		||||
                        { "@extName_3D", post.extName_3D},
 | 
			
		||||
                        { "@created_by", myUserInfo.Userinfo_guid}
 | 
			
		||||
                    };
 | 
			
		||||
                    await backendRepository.AddOneByCustomTable(building, "building");
 | 
			
		||||
 | 
			
		||||
                    if (post.orgName_3D != null && post.extName_3D != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        var fileName = map_3d_guid + "." + post.extName_3D;
 | 
			
		||||
 | 
			
		||||
                        var fullPath = Path.Combine(buildMapFileSaveAsPath, fileName);
 | 
			
		||||
 | 
			
		||||
                        if (!System.IO.Directory.Exists(buildMapFileSaveAsPath))
 | 
			
		||||
                            System.IO.Directory.CreateDirectory(buildMapFileSaveAsPath);
 | 
			
		||||
 | 
			
		||||
                        using (var stream = new FileStream(fullPath, FileMode.Create))
 | 
			
		||||
                        {
 | 
			
		||||
                            post.Map3dFile.CopyTo(stream);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    apiResult.Code = "0000";
 | 
			
		||||
                    apiResult.Msg = "新增成功";
 | 
			
		||||
                }
 | 
			
		||||
@ -142,7 +164,7 @@ namespace Backend.Controllers
 | 
			
		||||
        /// <param name="post"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<string>> EditBuildInfo(BuildInfo post)
 | 
			
		||||
        public async Task<ApiResult<string>> EditBuildInfo([FromForm] BuildInfo post)
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<string> apiResult = new ApiResult<string>();
 | 
			
		||||
 | 
			
		||||
@ -153,6 +175,10 @@ namespace Backend.Controllers
 | 
			
		||||
 | 
			
		||||
                var sWhere = $@"deleted = 0 AND ip_address = @ip_address AND ip_port = @ip_port AND building_tag != @building_tag";
 | 
			
		||||
                var buildInfos = await backendRepository.GetAllAsync<BuildInfo>("building", sWhere, new { ip_address = post.Ip_address, ip_port = post.Ip_port, building_tag = post.building_tag });
 | 
			
		||||
 | 
			
		||||
                sWhere = $@"deleted = 0 AND building_tag = @building_tag";
 | 
			
		||||
                var buildInfo = await backendRepository.GetOneAsync<BuildInfo>("building", sWhere, new { building_tag = post.building_tag });
 | 
			
		||||
 | 
			
		||||
                if (buildInfos.Count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    judgeIPAddressRepeat = false;
 | 
			
		||||
@ -166,11 +192,44 @@ namespace Backend.Controllers
 | 
			
		||||
                        { "@full_name", post.Full_name},
 | 
			
		||||
                        { "@ip_address", post.Ip_address},
 | 
			
		||||
                        { "@ip_port", post.Ip_port},
 | 
			
		||||
                        { "@orgName_3D", post.orgName_3D},
 | 
			
		||||
                        { "@extName_3D", post.extName_3D},
 | 
			
		||||
                        { "@updated_by", myUserInfo.Userinfo_guid},
 | 
			
		||||
                        { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}
 | 
			
		||||
                    };
 | 
			
		||||
                    await backendRepository.UpdateOneByCustomTable(building, "building", "building_tag='" + post.building_tag + "'");
 | 
			
		||||
 | 
			
		||||
                    if (post.orgName_3D != null && post.extName_3D != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        var map_3d_guid = Guid.NewGuid();
 | 
			
		||||
 | 
			
		||||
                        //刪除原本檔案
 | 
			
		||||
                        if (buildInfo.saveName_3D != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            FolderFunction folderFunction = new FolderFunction();
 | 
			
		||||
                            folderFunction.DeleteFile(Path.Combine(buildMapFileSaveAsPath, buildInfo.saveName_3D + "." + buildInfo.extName_3D));
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        Dictionary<string, object> build_map_3d_dic = new Dictionary<string, object>();
 | 
			
		||||
                        build_map_3d_dic = new Dictionary<string, object>()
 | 
			
		||||
                        {
 | 
			
		||||
                            { "@saveName_3D", map_3d_guid}
 | 
			
		||||
                        };
 | 
			
		||||
                        await backendRepository.UpdateOneByCustomTable(build_map_3d_dic, "building", "building_tag='" + post.building_tag + "'");
 | 
			
		||||
    
 | 
			
		||||
                        var fileName = map_3d_guid + "." + post.extName_3D;
 | 
			
		||||
                        
 | 
			
		||||
                        var fullPath = Path.Combine(buildMapFileSaveAsPath, fileName);
 | 
			
		||||
 | 
			
		||||
                        if (!System.IO.Directory.Exists(buildMapFileSaveAsPath))
 | 
			
		||||
                            System.IO.Directory.CreateDirectory(buildMapFileSaveAsPath);
 | 
			
		||||
 | 
			
		||||
                        using (var stream = new FileStream(fullPath, FileMode.Create))
 | 
			
		||||
                        {
 | 
			
		||||
                            post.Map3dFile.CopyTo(stream);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    apiResult.Code = "0000";
 | 
			
		||||
                    apiResult.Msg = "修改成功";
 | 
			
		||||
                }
 | 
			
		||||
@ -399,6 +458,9 @@ namespace Backend.Controllers
 | 
			
		||||
                            { "@full_name", post.Full_name},
 | 
			
		||||
                            { "@InitMapName", post.InitMapName},
 | 
			
		||||
                            { "@floor_map_name", floor_map_guid},
 | 
			
		||||
                            { "@orgName_3D", post.orgName_3D},
 | 
			
		||||
                            { "@saveName_3D", post.saveName_3D},
 | 
			
		||||
                            { "@extName_3D", post.extName_3D},
 | 
			
		||||
                            { "@priority", current_priority + 1},
 | 
			
		||||
                            { "@created_by", myUserInfo.Userinfo_guid}
 | 
			
		||||
                        };
 | 
			
		||||
@ -411,6 +473,9 @@ namespace Backend.Controllers
 | 
			
		||||
 | 
			
		||||
                        var fullPath = Path.Combine(mapFileSaveAsPath, fileName);
 | 
			
		||||
 | 
			
		||||
                        if (!System.IO.Directory.Exists(buildMapFileSaveAsPath))
 | 
			
		||||
                            System.IO.Directory.CreateDirectory(buildMapFileSaveAsPath);
 | 
			
		||||
 | 
			
		||||
                        using (var stream = new FileStream(fullPath, FileMode.Create))
 | 
			
		||||
                        {
 | 
			
		||||
                            post.MapFile.CopyTo(stream);
 | 
			
		||||
@ -451,6 +516,9 @@ namespace Backend.Controllers
 | 
			
		||||
 | 
			
		||||
                        var fullPath = Path.Combine(mapFileSaveAsPath, fileName);
 | 
			
		||||
 | 
			
		||||
                        if (!System.IO.Directory.Exists(buildMapFileSaveAsPath))
 | 
			
		||||
                            System.IO.Directory.CreateDirectory(buildMapFileSaveAsPath);
 | 
			
		||||
 | 
			
		||||
                        using (var stream = new FileStream(fullPath, FileMode.Create))
 | 
			
		||||
                        {
 | 
			
		||||
                            post.MapFile.CopyTo(stream);
 | 
			
		||||
 | 
			
		||||
@ -364,6 +364,7 @@ namespace Backend.Controllers
 | 
			
		||||
            }
 | 
			
		||||
            return apiResult;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ActionResult> BuildMenuTable(BuildMenuTablePost post)
 | 
			
		||||
        {
 | 
			
		||||
@ -618,10 +619,11 @@ namespace Backend.Controllers
 | 
			
		||||
            {
 | 
			
		||||
                var sqlString = @$"select f.floor_guid Value, f.full_name Name
 | 
			
		||||
                                    from sub_system_floor sf
 | 
			
		||||
                                    left join floor f on sf.floor_tag = f.full_name
 | 
			
		||||
                                    left join floor f on sf.floor_tag = f.full_name and sf.building_tag = f.building_tag 
 | 
			
		||||
                                    where sf.deleted = 0 and sf.status = 0 and sf.building_tag = @building_tag and sf.main_system_tag = @main_system_tag and sf.sub_system_tag = @sub_system_tag
 | 
			
		||||
                                            and (f.InitMapName + f.floor_map_name) is not null
 | 
			
		||||
                                    ORDER BY f.priority, f.created_at";
 | 
			
		||||
                KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString, new { building_tag = post.building_tag, main_system_tag = post.main_system_tag, sub_system_type = post.sub_system_tag });
 | 
			
		||||
                KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString, new { building_tag = post.building_tag, main_system_tag = post.main_system_tag, sub_system_tag = post.sub_system_tag });
 | 
			
		||||
 | 
			
		||||
                apiResult.Code = "0000";
 | 
			
		||||
                apiResult.Data = KeyValue;
 | 
			
		||||
@ -635,5 +637,29 @@ namespace Backend.Controllers
 | 
			
		||||
            return apiResult;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<int>> GetBuildingHas3D(MenuIn post)
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<int> apiResult = new ApiResult<int>();
 | 
			
		||||
            List<KeyValue> KeyValue = new List<KeyValue>();
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var sqlString = @$"select v.id
 | 
			
		||||
                                    from building b
 | 
			
		||||
                                    join variable v on v.system_type = @system_type and system_key = N'是否有3D' and v.deleted = 0
 | 
			
		||||
                                    where b.building_tag = @building_tag and (b.orgName_3D + b.saveName_3D) is not null;";
 | 
			
		||||
                KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString, new { building_tag = post.building_tag, system_type = system_setting_type });
 | 
			
		||||
 | 
			
		||||
                apiResult.Code = "0000";
 | 
			
		||||
                apiResult.Data = KeyValue.Count;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception exception)
 | 
			
		||||
            {
 | 
			
		||||
                apiResult.Code = "9999";
 | 
			
		||||
                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
			
		||||
            }
 | 
			
		||||
            return apiResult;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -33,6 +33,7 @@ namespace Backend.Controllers
 | 
			
		||||
        public string actionName;
 | 
			
		||||
        public string main_system_type = "device_system_category_layer2";
 | 
			
		||||
        public string sub_system_type = "device_system_category_layer3";
 | 
			
		||||
        public string system_setting_type = "system_setting";
 | 
			
		||||
 | 
			
		||||
        public MybaseController() { }
 | 
			
		||||
        public override void OnActionExecuting(ActionExecutingContext filterContext)
 | 
			
		||||
 | 
			
		||||
@ -16,6 +16,10 @@ namespace Backend.Models
 | 
			
		||||
        public string Ip_port { get; set; } //監控主機 IP port
 | 
			
		||||
        public string Ip_address_port { get { return Ip_address + ":" + Ip_port; } }
 | 
			
		||||
        public byte FloorNum { get; set; } //樓層數量
 | 
			
		||||
        public IFormFile Map3dFile { get; set; }
 | 
			
		||||
        public string orgName_3D { get; set; }
 | 
			
		||||
        public string saveName_3D { get; set; }
 | 
			
		||||
        public string extName_3D { get; set; }
 | 
			
		||||
        //public string Created_at { get; set; }  //建立時間
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -30,6 +34,9 @@ namespace Backend.Models
 | 
			
		||||
        public string Floor_map_name { get; set; } //平面圖檔名
 | 
			
		||||
        public IFormFile MapFile { get; set; } //平面圖檔
 | 
			
		||||
        public int Priority { get; set; }
 | 
			
		||||
        public string orgName_3D { get; set; }
 | 
			
		||||
        public string saveName_3D { get; set; }
 | 
			
		||||
        public string extName_3D { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class SelectedBuildFloor
 | 
			
		||||
 | 
			
		||||
@ -230,6 +230,19 @@
 | 
			
		||||
        }
 | 
			
		||||
        //#endregion
 | 
			
		||||
 | 
			
		||||
        //驗證是否有上傳
 | 
			
		||||
        jQuery.validator.addMethod("fileUpload", function (value, element) {
 | 
			
		||||
            var str = value;
 | 
			
		||||
            var result = false;
 | 
			
		||||
            if ($("#3d_file_modal")[0].files.length > 0) {
 | 
			
		||||
                result = true;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                result = false;
 | 
			
		||||
            }
 | 
			
		||||
            return result;
 | 
			
		||||
        }, "請選擇檔案");
 | 
			
		||||
 | 
			
		||||
        //#region 區域表單驗證
 | 
			
		||||
        var BuildInfoValidate = $("#build-form").validate({
 | 
			
		||||
            rules: {
 | 
			
		||||
@ -247,6 +260,9 @@
 | 
			
		||||
                    required: true,
 | 
			
		||||
                    maxlength: 50,
 | 
			
		||||
                    filterspace: true
 | 
			
		||||
                },
 | 
			
		||||
                file_3d_modal: {
 | 
			
		||||
                    accept: "image/svg+xml"
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
@ -257,33 +273,50 @@
 | 
			
		||||
            if ($("#build-form").valid()) {
 | 
			
		||||
                $("#save-building-btn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
 | 
			
		||||
                var url = "/BuildInfo/SaveBuildInfo";
 | 
			
		||||
                var send_data = {
 | 
			
		||||
                    building_tag: $('#build_name_tag').val(),
 | 
			
		||||
                    Full_name: $('#build_name_modal').val(),
 | 
			
		||||
                    Ip_address: $('#ip_address_modal').val(),
 | 
			
		||||
                    Ip_port: $('#ip_port_modal').val()
 | 
			
		||||
 | 
			
		||||
                var formData = new FormData();
 | 
			
		||||
                formData.append("building_tag", $('#build_name_tag').val());
 | 
			
		||||
                formData.append("Full_name", $('#build_name_modal').val());
 | 
			
		||||
                formData.append("Ip_address", $('#ip_address_modal').val());
 | 
			
		||||
                formData.append("Ip_port", $('#ip_port_modal').val());
 | 
			
		||||
 | 
			
		||||
                maps = $('#file_3d_modal')[0].files;
 | 
			
		||||
                if (maps.length > 0) {
 | 
			
		||||
                    var file_names = maps[0].name.split(".");
 | 
			
		||||
 | 
			
		||||
                    formData.append("Map3dFile", maps[0]);
 | 
			
		||||
                    formData.append("orgName_3D", file_names[0]);
 | 
			
		||||
                    formData.append("extName_3D", file_names[1]);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                $.post(url, send_data, function (rel) {
 | 
			
		||||
                    $("#save-building-btn").html('確定').attr("disabled", false);
 | 
			
		||||
                    if (rel.code != "0000") {
 | 
			
		||||
                        if (rel.code == "9999") {
 | 
			
		||||
                            toast_error(rel.msg);
 | 
			
		||||
                $.ajax({
 | 
			
		||||
                    type: "POST",
 | 
			
		||||
                    url: url,
 | 
			
		||||
                    data: formData,
 | 
			
		||||
                    cache: false,
 | 
			
		||||
                    contentType: false,
 | 
			
		||||
                    processData: false,
 | 
			
		||||
                    success: function (rel) {
 | 
			
		||||
                        $("#save-building-btn").html('確定').attr("disabled", false);
 | 
			
		||||
                        if (rel.code != "0000") {
 | 
			
		||||
                            if (rel.code == "9999") {
 | 
			
		||||
                                toast_error(rel.msg);
 | 
			
		||||
                            }
 | 
			
		||||
                            else {
 | 
			
		||||
                                toast_warning(rel.msg);
 | 
			
		||||
                            }
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        else {
 | 
			
		||||
                            toast_warning(rel.msg);
 | 
			
		||||
                            toast_ok(rel.msg);
 | 
			
		||||
                            buildInfoTable.ajax.reload(null, false);
 | 
			
		||||
                            $('#build-modal').modal('hide');
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        return;
 | 
			
		||||
                    },
 | 
			
		||||
                    fail: function (xhr, status, error) {
 | 
			
		||||
                        $("#save-building-btn").html('確定').attr("disabled", false);
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        toast_ok(rel.msg);
 | 
			
		||||
                        buildInfoTable.ajax.reload(null, false);
 | 
			
		||||
                        $('#build-modal').modal('hide');
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                }, 'json')
 | 
			
		||||
                .fail(function (xhr, status, error) {
 | 
			
		||||
                    $("#save-building-btn").html('確定').attr("disabled", false);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@ -292,33 +325,50 @@
 | 
			
		||||
            if ($("#build-form").valid()) {
 | 
			
		||||
                $("#save-building-btn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
 | 
			
		||||
                var url = "/BuildInfo/EditBuildInfo";
 | 
			
		||||
                var send_data = {
 | 
			
		||||
                    building_tag: selected_build_guid,
 | 
			
		||||
                    Full_name: $('#build_name_modal').val(),
 | 
			
		||||
                    Ip_address: $('#ip_address_modal').val(),
 | 
			
		||||
                    Ip_port: $('#ip_port_modal').val()
 | 
			
		||||
                var formData = new FormData();
 | 
			
		||||
 | 
			
		||||
                formData.append("building_tag", selected_build_guid);
 | 
			
		||||
                formData.append("Full_name", $('#build_name_modal').val());
 | 
			
		||||
                formData.append("Ip_address", $('#ip_address_modal').val());
 | 
			
		||||
                formData.append("Ip_port", $('#ip_port_modal').val());
 | 
			
		||||
 | 
			
		||||
                maps = $('#file_3d_modal')[0].files;
 | 
			
		||||
                if (maps.length > 0) {
 | 
			
		||||
                    var file_names = maps[0].name.split(".");
 | 
			
		||||
 | 
			
		||||
                    formData.append("Map3dFile", maps[0]);
 | 
			
		||||
                    formData.append("orgName_3D", file_names[0]);
 | 
			
		||||
                    formData.append("extName_3D", file_names[1]);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                $.post(url, send_data, function (rel) {
 | 
			
		||||
                    $("#save-building-btn").html('確定').attr("disabled", false);
 | 
			
		||||
                    if (rel.code != "0000") {
 | 
			
		||||
                        if (rel.code == "9999") {
 | 
			
		||||
                            toast_error(rel.msg);
 | 
			
		||||
                $.ajax({
 | 
			
		||||
                    type: "POST",
 | 
			
		||||
                    url: url,
 | 
			
		||||
                    data: formData,
 | 
			
		||||
                    cache: false,
 | 
			
		||||
                    contentType: false,
 | 
			
		||||
                    processData: false,
 | 
			
		||||
                    success: function (rel) {
 | 
			
		||||
                        $("#save-building-btn").html('確定').attr("disabled", false);
 | 
			
		||||
                        if (rel.code != "0000") {
 | 
			
		||||
                            if (rel.code == "9999") {
 | 
			
		||||
                                toast_error(rel.msg);
 | 
			
		||||
                            }
 | 
			
		||||
                            else {
 | 
			
		||||
                                toast_warning(rel.msg);
 | 
			
		||||
                            }
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        else {
 | 
			
		||||
                            toast_warning(rel.msg);
 | 
			
		||||
                            toast_ok(rel.msg);
 | 
			
		||||
                            buildInfoTable.ajax.reload(null, false);
 | 
			
		||||
                            $('#build-modal').modal('hide');
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        return;
 | 
			
		||||
                    },
 | 
			
		||||
                    fail: function (xhr, status, error) {
 | 
			
		||||
                        $("#save-building-btn").html('確定').attr("disabled", false);
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        toast_ok(rel.msg);
 | 
			
		||||
                        buildInfoTable.ajax.reload(null, false);
 | 
			
		||||
                        $('#build-modal').modal('hide');
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                }, 'json')
 | 
			
		||||
                .fail(function (xhr, status, error) {
 | 
			
		||||
                    $("#save-building-btn").html('確定').attr("disabled", false);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@ -566,7 +616,10 @@
 | 
			
		||||
                },
 | 
			
		||||
                map_file_modal: {
 | 
			
		||||
                    accept: "image/svg+xml"
 | 
			
		||||
                }
 | 
			
		||||
                },
 | 
			
		||||
                //file_3d_modal: {
 | 
			
		||||
                //    accept: "image/svg+xml"
 | 
			
		||||
                //}
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
@ -595,6 +648,7 @@
 | 
			
		||||
                var formData = new FormData();
 | 
			
		||||
 | 
			
		||||
                maps = $('#map_file_modal')[0].files
 | 
			
		||||
                maps3D = $('#file_3d_modal')[0].files
 | 
			
		||||
 | 
			
		||||
                formData.append("Floor_guid", selected_floor_guid);
 | 
			
		||||
                formData.append("building_tag", selected_build_guid_top);
 | 
			
		||||
@ -607,6 +661,13 @@
 | 
			
		||||
                    formData.append("InitMapName", maps[0].name.replace("." + file_names[file_names.length - 1], ""));
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if(maps3D.length > 0) {
 | 
			
		||||
                    var file_names = maps3D[0].name.split(".")
 | 
			
		||||
 | 
			
		||||
                    formData.append("orgName_3D", maps3D[0].name.replace("." + file_names[file_names.length - 1], ""));
 | 
			
		||||
                    formData.append("extName_3D", maps3D[1].name.replace("." + file_names[file_names.length - 1], ""));
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                $.ajax({
 | 
			
		||||
                    type: "POST",
 | 
			
		||||
                    url: url,
 | 
			
		||||
 | 
			
		||||
@ -56,6 +56,10 @@
 | 
			
		||||
                            <label class="form-label" for="map_file_modal">平面圖檔(限制SVG格式)</label>
 | 
			
		||||
                            <input type="file" id="map_file_modal" class="form-control" name="map_file_modal" onchange="changeImage(this)" accept="image/svg+xml">
 | 
			
		||||
                        </div>
 | 
			
		||||
                        @*<div class="form-group col-12">
 | 
			
		||||
                            <label class="form-label" for="map_file_modal">3D檔(限制SVG格式)</label>
 | 
			
		||||
                            <input type="file" id="map_file_modal" class="form-control" name="map_file_modal" onchange="changeImage(this)" accept="image/svg+xml">
 | 
			
		||||
                        </div>*@
 | 
			
		||||
                    </div>
 | 
			
		||||
                </form>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
@ -56,6 +56,10 @@
 | 
			
		||||
                            <label class="form-label" for="ip_port_modal"><span class="text-danger">*</span>監控主機 PORT</label>
 | 
			
		||||
                            <input type="text" id="ip_port_modal" class="form-control" name="ip_port_modal">
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="form-group col-12">
 | 
			
		||||
                            <label class="form-label" for="file_3d_modal">3D檔(限制SVG格式)</label>
 | 
			
		||||
                            <input type="file" id="file_3d_modal" class="form-control" name="file_3d_modal" onchange="changeImage(this)" accept="image/svg+xml">
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </form>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
@ -161,7 +161,7 @@
 | 
			
		||||
                                            2D
 | 
			
		||||
                                        </label>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    <div class="col">
 | 
			
		||||
                                    <div class="col" id="drawing_3_div" style="display: none;">
 | 
			
		||||
                                        <input type="radio" name="drawing" id="drawing_3" value="3">
 | 
			
		||||
                                        <label for="drawing_3">
 | 
			
		||||
                                            3D
 | 
			
		||||
@ -280,7 +280,7 @@
 | 
			
		||||
                                            2D
 | 
			
		||||
                                        </label>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    <div class="col">
 | 
			
		||||
                                    <div class="col" id="drawing_3_div_r" style="display: none;">
 | 
			
		||||
                                        <input type="radio" name="drawing_r" id="drawing_3_r" value="3">
 | 
			
		||||
                                        <label for="drawing_3_r">
 | 
			
		||||
                                            3D
 | 
			
		||||
@ -768,6 +768,7 @@
 | 
			
		||||
 | 
			
		||||
            GetSubList($('#build_menu_main_modal').val());
 | 
			
		||||
            GetFloorInSubSystem();
 | 
			
		||||
            GetBuildingHas3D();
 | 
			
		||||
            $('#planimetric_click').attr("disabled", false);
 | 
			
		||||
            $('#build-menu-modal').modal();
 | 
			
		||||
        }
 | 
			
		||||
@ -953,6 +954,7 @@
 | 
			
		||||
                    }
 | 
			
		||||
                    
 | 
			
		||||
                    changebuild_menu_drawing_modal();
 | 
			
		||||
                    GetBuildingHas3D();
 | 
			
		||||
                    GetFloorInSubSystem(rel.data.left_planimetric_floor_guid);
 | 
			
		||||
                    GetFloorInSubSystem(rel.data.right_planimetric_floor_guid);
 | 
			
		||||
                    $('.modal-title').html("選單基本資料 - 修改");
 | 
			
		||||
@ -1198,6 +1200,7 @@
 | 
			
		||||
                main_system_tag: $('#build_menu_main_modal').val(),
 | 
			
		||||
                sub_system_tag: $('#build_menu_sub_modal').val(),
 | 
			
		||||
            };
 | 
			
		||||
            
 | 
			
		||||
            $.post(url, send_data, function (rel) {
 | 
			
		||||
                if (rel.code != "0000") {
 | 
			
		||||
                    toast_error(rel.msg);
 | 
			
		||||
@ -1215,12 +1218,34 @@
 | 
			
		||||
                        });
 | 
			
		||||
                        if (floor != null) {
 | 
			
		||||
                            $('#build_menu_planimetric_floor_modal').val(floor);
 | 
			
		||||
                             $('#build_menu_planimetric_floor_modal_r').val(floor);
 | 
			
		||||
                            $('#build_menu_planimetric_floor_modal_r').val(floor);
 | 
			
		||||
                        }
 | 
			
		||||
                        $('[id^=drawing_1_div]').show();
 | 
			
		||||
 | 
			
		||||
                        $('[id^=build_menu_planimetric_floor_modal_div]').show();
 | 
			
		||||
                        changebuild_menu_drawing_modal();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }, 'json');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function GetBuildingHas3D() {
 | 
			
		||||
            var url = "/BuildMenu/GetBuildingHas3D";
 | 
			
		||||
            var send_data = {
 | 
			
		||||
                building_tag: $('#build_menu_building_modal').val(),
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            $.post(url, send_data, function (rel) {
 | 
			
		||||
                if (rel.code != "0000") {
 | 
			
		||||
                    toast_error(rel.msg);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    if (rel.data == 0) {
 | 
			
		||||
                        $('[id^=drawing_3_div]').hide();
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        $('[id^=drawing_3_div]').show();
 | 
			
		||||
                        changebuild_menu_drawing_modal();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }, 'json');
 | 
			
		||||
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
		 After Width: | Height: | Size: 130 KiB  | 
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
		 After Width: | Height: | Size: 130 KiB  | 
		Loading…
	
		Reference in New Issue
	
	Block a user